@midcontract/protocol
Advanced tools
Comparing version 1.0.0-rc.26-e63b84f to 1.0.0-rc.29-19a5bac
// 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 { | ||
@@ -38,7 +44,11 @@ ACTIVE = 0,// The contract is active and ongoing | ||
declare enum FeeConfig { | ||
CLIENT_COVERS_ALL = 0, | ||
CLIENT_COVERS_ONLY = 1, | ||
CONTRACTOR_COVERS_CLAIM = 2, | ||
CLIENT_COVERS_ALL = 0,// Client covers all fees | ||
CLIENT_COVERS_ONLY = 1,// Client pays only for his fee | ||
CONTRACTOR_COVERS_CLAIM = 2,// Client covers only freelancer's claim fee | ||
NO_FEES = 3 | ||
} | ||
declare enum RefillType { | ||
PREPAYMENT = 0,// Indicates a refill to the contract's general prepayment pool, which can be used to cover future claims. | ||
WEEK_PAYMENT = 1 | ||
} | ||
declare enum DisputeWinner { | ||
@@ -107,2 +117,8 @@ CLIENT = 0, | ||
} | ||
export interface HourlyDepositInput { | ||
contractorAddress: Address; | ||
amountToClaim?: number; | ||
amountToWithdraw?: number; | ||
feeConfig: FeeConfig; | ||
} | ||
export interface ApproveInput { | ||
@@ -122,2 +138,9 @@ contractId: bigint; | ||
} | ||
export interface ApproveInputHourly { | ||
contractId: bigint; | ||
weekId: bigint; | ||
valueApprove: number; | ||
recipient: Address; | ||
token: SymbolToken; | ||
} | ||
export type TransactionStatus = "pending" | "success" | "reverted"; | ||
@@ -142,2 +165,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 { | ||
@@ -153,5 +183,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; | ||
@@ -170,3 +208,6 @@ /** @deprecated */ | ||
getDepositListMilestone(contractId: bigint, milestoneId: bigint): Promise<Deposit>; | ||
getDepositListHourly(contractId: bigint, weekId: bigint): Promise<Deposit>; | ||
currentContractId(): Promise<bigint>; | ||
currentContractIdMilestone(): Promise<bigint>; | ||
currentContractIdHourly(): Promise<bigint>; | ||
get blockNumber(): Promise<number>; | ||
@@ -186,2 +227,3 @@ get account(): Account; | ||
escrowMilestoneDeposit(deposits: DepositInput[], token: SymbolToken, escrowContractId?: bigint, waitReceipt?: boolean): Promise<DepositResponse>; | ||
escrowDepositHourly(tokenSymbol: SymbolToken, prepaymentAmount: number | undefined, escrowContractId: bigint | undefined, deposit: HourlyDepositInput, waitReceipt?: boolean): Promise<DepositResponse>; | ||
escrowSubmit(contractId: bigint, salt: Hash, data: string, waitReceipt?: boolean): Promise<TransactionId>; | ||
@@ -191,18 +233,27 @@ escrowSubmitMilestone(contractId: bigint, milestoneId: bigint, salt: Hash, data: string, waitReceipt?: boolean): Promise<TransactionId>; | ||
escrowRefillMilestone(contractId: bigint, milestoneId: bigint, value: number, waitReceipt?: boolean): Promise<TransactionId>; | ||
escrowRefillHourly(contractId: bigint, weekId: bigint, value: number, refillType: RefillType, 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<{ | ||
@@ -216,2 +267,6 @@ userEscrow: Address; | ||
}>; | ||
deployHourlyEscrow(): Promise<{ | ||
userEscrow: Address; | ||
salt: Hash; | ||
}>; | ||
updateDefaultFees(coverageFee: number, claimFee: number): Promise<void>; | ||
@@ -221,181 +276,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(); | ||
@@ -407,6 +317,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; | ||
@@ -413,0 +326,0 @@ accountUrl(account: Address): string; |
{ | ||
"name": "@midcontract/protocol", | ||
"version": "1.0.0-rc.26-e63b84f", | ||
"version": "1.0.0-rc.29-19a5bac", | ||
"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
603623
12269
9
12