@midcontract/protocol
Advanced tools
Comparing version 1.0.0-rc.26-e63b84f to 1.0.0-rc.29-1bbec05
// Generated by dts-bundle-generator v9.3.1 | ||
import { Account, Address, Chain, CustomTransport, EIP1193Provider, Hash, HttpTransport } from 'viem'; | ||
import { Abi, Account, Address, Chain, CustomTransport, EIP1193Provider, Hash, HttpTransport } from 'viem'; | ||
import { Transaction, TransactionReceipt } from 'viem/types/transaction'; | ||
@@ -9,3 +9,3 @@ | ||
}; | ||
export type Environment = "prod" | "beta" | "test" | "local"; | ||
export type Environment = "prod" | "beta" | "beta2" | "test" | "local"; | ||
export type SymbolToken = "USDT" | "USDC" | "MockUSDT"; | ||
@@ -19,8 +19,14 @@ export type DataToken = { | ||
export type ContractList = { | ||
chainName: string; | ||
chainName: ChainNameEnum; | ||
escrow: { | ||
[key: string]: Address; | ||
[key: string]: Address | Abi; | ||
}; | ||
tokenList: TokenList; | ||
}; | ||
declare enum ChainNameEnum { | ||
Localhost = "Localhost", | ||
Sepolia = "Sepolia", | ||
BlastSepolia = "BlastSepolia", | ||
PolygonAmoy = "PolygonAmoy" | ||
} | ||
declare enum DepositStatus { | ||
@@ -120,2 +126,9 @@ ACTIVE = 0,// The contract is active and ongoing | ||
} | ||
export interface ApproveInputHourly { | ||
contractId: bigint; | ||
weekId: bigint; | ||
valueApprove: number; | ||
recipient: Address; | ||
token: SymbolToken; | ||
} | ||
export type TransactionStatus = "pending" | "success" | "reverted"; | ||
@@ -140,2 +153,9 @@ export interface TransactionData { | ||
} | ||
export interface AbiList { | ||
fixedPriceAbi: readonly object[]; | ||
milestoneAbi: readonly object[]; | ||
hourlyAbi: readonly object[]; | ||
feeManagerAbi: readonly object[]; | ||
factoryAbi: readonly object[]; | ||
} | ||
export declare class MidcontractProtocol { | ||
@@ -151,5 +171,13 @@ private readonly contractList; | ||
private readonly ownerAddress; | ||
private readonly onTransactionCompleteWebhookUrl; | ||
private readonly sdkSecret; | ||
constructor(chain: Chain, transport: HttpTransport, contractList: ContractList, account?: Account, onTransactionCompleteWebhookUrl?: string, sdkSecret?: string); | ||
fixedPriceAbi: [ | ||
]; | ||
milestoneAbi: [ | ||
]; | ||
hourlyAbi: [ | ||
]; | ||
feeManagerAbi: [ | ||
]; | ||
factoryAbi: [ | ||
]; | ||
constructor(chain: Chain, transport: HttpTransport, contractList: ContractList, abiList: AbiList, account?: Account); | ||
static buildByEnvironment(name?: Environment, account?: Account, url?: string): MidcontractProtocol; | ||
@@ -168,3 +196,5 @@ /** @deprecated */ | ||
getDepositListMilestone(contractId: bigint, milestoneId: bigint): Promise<Deposit>; | ||
getDepositListHourly(contractId: bigint, weekId: bigint): Promise<Deposit>; | ||
currentContractId(): Promise<bigint>; | ||
currentContractIdMilestone(): Promise<bigint>; | ||
get blockNumber(): Promise<number>; | ||
@@ -184,22 +214,33 @@ get account(): Account; | ||
escrowMilestoneDeposit(deposits: DepositInput[], token: SymbolToken, escrowContractId?: bigint, waitReceipt?: boolean): Promise<DepositResponse>; | ||
escrowDepositHourly(deposits: DepositInput[], token: SymbolToken, escrowContractId?: bigint, waitReceipt?: boolean): Promise<DepositResponse>; | ||
escrowSubmit(contractId: bigint, salt: Hash, data: string, waitReceipt?: boolean): Promise<TransactionId>; | ||
escrowSubmitMilestone(contractId: bigint, milestoneId: bigint, salt: Hash, data: string, waitReceipt?: boolean): Promise<TransactionId>; | ||
escrowSubmitHourly(contractId: bigint, weekId: bigint, salt: Hash, data: string, waitReceipt?: boolean): Promise<TransactionId>; | ||
escrowRefill(contractId: bigint, value: number, waitReceipt?: boolean): Promise<TransactionId>; | ||
escrowRefillMilestone(contractId: bigint, milestoneId: bigint, value: number, waitReceipt?: boolean): Promise<TransactionId>; | ||
escrowRefillHourly(contractId: bigint, weekId: bigint, value: number, waitReceipt?: boolean): Promise<TransactionId>; | ||
escrowApprove(input: ApproveInput, waitReceipt?: boolean): Promise<TransactionId>; | ||
escrowApproveMilestone(input: ApproveInputMilestone, waitReceipt?: boolean): Promise<TransactionId>; | ||
escrowApproveHourly(input: ApproveInputHourly, waitReceipt?: boolean): Promise<TransactionId>; | ||
escrowClaim(contractId: bigint, waitReceipt?: boolean): Promise<TransactionId>; | ||
escrowClaimMilestone(contractId: bigint, milestoneId: bigint, waitReceipt?: boolean): Promise<TransactionId>; | ||
escrowClaimHourly(contractId: bigint, weekId: bigint, waitReceipt?: boolean): Promise<TransactionId>; | ||
escrowWithdraw(contractId: bigint, waitReceipt?: boolean): Promise<TransactionId>; | ||
escrowWithdrawMilestone(contractId: bigint, milestoneId: bigint, waitReceipt?: boolean): Promise<TransactionId>; | ||
escrowWithdrawHourly(contractId: bigint, weekId: bigint, waitReceipt?: boolean): Promise<TransactionId>; | ||
requestReturn(contractId: bigint, waitReceipt?: boolean): Promise<TransactionId>; | ||
requestReturnMilestone(contractId: bigint, milestoneId: bigint, waitReceipt?: boolean): Promise<TransactionId>; | ||
requestReturnHourly(contractId: bigint, weekId: bigint, waitReceipt?: boolean): Promise<TransactionId>; | ||
approveReturn(contractId: bigint, waitReceipt?: boolean): Promise<TransactionId>; | ||
approveReturnMilestone(contractId: bigint, milestoneId: bigint, waitReceipt?: boolean): Promise<TransactionId>; | ||
approveReturnHourly(contractId: bigint, weekId: bigint, waitReceipt?: boolean): Promise<TransactionId>; | ||
cancelReturn(contractId: bigint, status: DepositStatus, waitReceipt?: boolean): Promise<TransactionId>; | ||
cancelReturnMilestone(contractId: bigint, milestoneId: bigint, status: DepositStatus, waitReceipt?: boolean): Promise<TransactionId>; | ||
cancelReturnHourly(contractId: bigint, weekId: bigint, status: DepositStatus, waitReceipt?: boolean): Promise<TransactionId>; | ||
createDispute(contractId: bigint, waitReceipt?: boolean): Promise<TransactionId>; | ||
createDisputeMilestone(contractId: bigint, milestoneId: bigint, waitReceipt?: boolean): Promise<TransactionId>; | ||
createDisputeHourly(contractId: bigint, weekId: bigint, waitReceipt?: boolean): Promise<TransactionId>; | ||
resolveDispute(contractId: bigint, winner: DisputeWinner, clientAmount: number, contractorAmount: number, waitReceipt?: boolean): Promise<TransactionId>; | ||
resolveDisputeMilestone(contractId: bigint, milestoneId: bigint, winner: DisputeWinner, clientAmount: number, contractorAmount: number, waitReceipt?: boolean): Promise<TransactionId>; | ||
resolveDisputeHourly(contractId: bigint, weekId: bigint, winner: DisputeWinner, clientAmount: number, contractorAmount: number, waitReceipt?: boolean): Promise<TransactionId>; | ||
deployEscrow(): Promise<{ | ||
@@ -213,2 +254,6 @@ userEscrow: Address; | ||
}>; | ||
deployHourlyEscrow(): Promise<{ | ||
userEscrow: Address; | ||
salt: Hash; | ||
}>; | ||
updateDefaultFees(coverageFee: number, claimFee: number): Promise<void>; | ||
@@ -218,181 +263,36 @@ setSpecialFees(accountAddress: Address, coverageFee: number, claimFee: number): Promise<void>; | ||
transactionByHash(hash: Hash, waitReceipt?: boolean): Promise<TransactionData>; | ||
transactionByHashMilestoneWait(hash: Hash): Promise<TransactionData>; | ||
transactionByHashMilestone(hash: Hash, waitReceipt?: boolean): Promise<TransactionData>; | ||
transactionByHashHourlyWait(hash: Hash): Promise<TransactionData>; | ||
transactionByHashHourly(hash: Hash, waitReceipt?: boolean): Promise<TransactionData>; | ||
transactionParse(data: TransactionData): Promise<{ | ||
input: { | ||
args: readonly [ | ||
]; | ||
functionName: "registry"; | ||
} | { | ||
args: readonly [ | ||
bigint, | ||
bigint, | ||
`0x${string}` | ||
]; | ||
functionName: "approve"; | ||
} | { | ||
args: readonly [ | ||
bigint | ||
]; | ||
functionName: "approveReturn"; | ||
} | { | ||
args: readonly [ | ||
bigint, | ||
number | ||
]; | ||
functionName: "cancelReturn"; | ||
} | { | ||
args: readonly [ | ||
bigint | ||
]; | ||
functionName: "claim"; | ||
} | { | ||
args: readonly [ | ||
]; | ||
functionName: "client"; | ||
} | { | ||
args: readonly [ | ||
bigint | ||
]; | ||
functionName: "createDispute"; | ||
} | { | ||
args: readonly [ | ||
{ | ||
contractor: `0x${string}`; | ||
paymentToken: `0x${string}`; | ||
amount: bigint; | ||
amountToClaim: bigint; | ||
amountToWithdraw: bigint; | ||
timeLock: bigint; | ||
contractorData: `0x${string}`; | ||
feeConfig: number; | ||
status: number; | ||
} | ||
]; | ||
functionName: "deposit"; | ||
} | { | ||
args: readonly [ | ||
bigint | ||
]; | ||
functionName: "deposits"; | ||
} | { | ||
args: readonly [ | ||
`0x${string}`, | ||
`0x${string}` | ||
]; | ||
functionName: "getContractorDataHash"; | ||
} | { | ||
args: readonly [ | ||
]; | ||
functionName: "getCurrentContractId"; | ||
} | { | ||
args: readonly [ | ||
`0x${string}`, | ||
`0x${string}`, | ||
`0x${string}` | ||
]; | ||
functionName: "initialize"; | ||
} | { | ||
args: readonly [ | ||
]; | ||
functionName: "initialized"; | ||
} | { | ||
args: readonly [ | ||
`0x${string}`, | ||
`0x${string}` | ||
]; | ||
functionName: "isValidSignature"; | ||
} | { | ||
args: readonly [ | ||
]; | ||
functionName: "owner"; | ||
} | { | ||
args: readonly [ | ||
bigint, | ||
bigint | ||
]; | ||
functionName: "refill"; | ||
} | { | ||
args: readonly [ | ||
bigint | ||
]; | ||
functionName: "requestReturn"; | ||
} | { | ||
args: readonly [ | ||
bigint, | ||
number, | ||
bigint, | ||
bigint | ||
]; | ||
functionName: "resolveDispute"; | ||
} | { | ||
args: readonly [ | ||
bigint, | ||
`0x${string}`, | ||
`0x${string}` | ||
]; | ||
functionName: "submit"; | ||
} | { | ||
args: readonly [ | ||
`0x${string}` | ||
]; | ||
functionName: "transferOwnership"; | ||
} | { | ||
args: readonly [ | ||
`0x${string}` | ||
]; | ||
functionName: "updateRegistry"; | ||
} | { | ||
args: readonly [ | ||
bigint | ||
]; | ||
functionName: "withdraw"; | ||
args: readonly unknown[]; | ||
functionName: string; | ||
}; | ||
events: { | ||
eventName: "Approved" | "Claimed" | "Deposited" | "DisputeCreated" | "DisputeResolved" | "OwnershipTransferred" | "Refilled" | "RegistryUpdated" | "ReturnApproved" | "ReturnCanceled" | "ReturnRequested" | "Submitted" | "Withdrawn"; | ||
args: { | ||
contractId: bigint; | ||
amountApprove: bigint; | ||
receiver: `0x${string}`; | ||
} | { | ||
contractId: bigint; | ||
paymentToken: `0x${string}`; | ||
amount: bigint; | ||
} | { | ||
sender: `0x${string}`; | ||
contractId: bigint; | ||
paymentToken: `0x${string}`; | ||
amount: bigint; | ||
feeConfig: number; | ||
} | { | ||
contractId: bigint; | ||
sender: `0x${string}`; | ||
} | { | ||
contractId: bigint; | ||
winner: number; | ||
clientAmount: bigint; | ||
contractorAmount: bigint; | ||
} | { | ||
oldOwner: `0x${string}`; | ||
newOwner: `0x${string}`; | ||
} | { | ||
contractId: bigint; | ||
amountAdditional: bigint; | ||
} | { | ||
registry: `0x${string}`; | ||
} | { | ||
contractId: bigint; | ||
sender: `0x${string}`; | ||
} | { | ||
contractId: bigint; | ||
} | { | ||
contractId: bigint; | ||
} | { | ||
sender: `0x${string}`; | ||
contractId: bigint; | ||
} | { | ||
contractId: bigint; | ||
paymentToken: `0x${string}`; | ||
amount: bigint; | ||
}; | ||
eventName: string; | ||
args: readonly unknown[] | Record<string, unknown>; | ||
}[]; | ||
}>; | ||
transactionParseMilestone(data: TransactionData): Promise<{ | ||
input: { | ||
args: readonly unknown[]; | ||
functionName: string; | ||
}; | ||
events: { | ||
eventName: string; | ||
args: readonly unknown[] | Record<string, unknown>; | ||
}[]; | ||
}>; | ||
transactionParseHourly(data: TransactionData): Promise<{ | ||
input: { | ||
args: readonly unknown[]; | ||
functionName: string; | ||
}; | ||
events: { | ||
eventName: string; | ||
args: readonly unknown[] | Record<string, unknown>; | ||
}[]; | ||
}>; | ||
private get tokenList(); | ||
@@ -404,6 +304,9 @@ parseAmount(tokenAddress: Address, amount: bigint): { | ||
private parseLogs; | ||
private parseLogsMilestone; | ||
private parseLogsHourly; | ||
private parseInput; | ||
private parseInputMilestone; | ||
private parseInputHourly; | ||
private send; | ||
private generateRandomNumber; | ||
private onTransactionCompleteWebhook; | ||
transactionUrl(transactionHash: Hash): string; | ||
@@ -410,0 +313,0 @@ accountUrl(account: Address): string; |
{ | ||
"name": "@midcontract/protocol", | ||
"version": "1.0.0-rc.26-e63b84f", | ||
"version": "1.0.0-rc.29-1bbec05", | ||
"description": "Crypto payment protocol with escrow", | ||
@@ -43,3 +43,3 @@ "keywords": [ | ||
"build": "rimraf build/**/* && pnpm build:chain && pnpm build:sdk", | ||
"build:abi": "echo \\\"export const escrow = $(jq '.abi' out/Escrow.sol/Escrow.json) as const\\\" > sdk/abi/EscrowHourly.ts", | ||
"build:abi": "echo \\\\\\\"export const escrow = $(jq '.abi' out/Escrow.sol/Escrow.json) as const\\\\\\\" > sdk/abi/EscrowFixedPrice.ts", | ||
"build:chain": "pnpm build:remap && forge build && pnpm build:abi", | ||
@@ -46,0 +46,0 @@ "build:optimized": "FOUNDRY_PROFILE=optimized forge build", |
# `@midcontract/protocol` | ||
Crypto payment protocol with escrow | ||
```mermaid | ||
stateDiagram-v2 | ||
[*] --> PENDING | ||
PENDING --> SUBMITTED: submit | ||
SUBMITTED --> PENDING: approve | ||
SUBMITTED --> DISPUTED: dispute | ||
PENDING --> DISPUTED: dispute | ||
DISPUTED --> PENDING: resolve | ||
PENDING --> [*] | ||
``` | ||
```mermaid | ||
sequenceDiagram | ||
opt Success | ||
Alice ->> Escrow: deposit | ||
Bob ->> Escrow: submit | ||
Alice ->> Escrow: reject | ||
Bob ->> Escrow: submit | ||
Alice ->> Escrow: approve | ||
Bob ->> Escrow: claim | ||
end | ||
opt Withdraw | ||
Alice ->> Escrow: deposit | ||
Bob -x Escrow: submit | ||
Alice ->> Escrow: withdraw | ||
end | ||
opt Dispute | ||
Alice ->> Escrow: deposit | ||
Bob ->> Escrow: submit | ||
Alice ->> Escrow: reject | ||
Bob ->> Escrow: dispute | ||
alt Bob | ||
Platform ->> Escrow: approve | ||
Bob ->> Escrow: claim | ||
else Alice | ||
Platform ->> Escrow: reject | ||
Alice ->> Escrow: withdraw | ||
end | ||
end | ||
``` | ||
## Install | ||
@@ -47,0 +5,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
580914
11861
9
12