@virtuals-protocol/acp-node 0.2.0-beta.3 → 0.2.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -7
- package/dist/index.d.mts +11 -12
- package/dist/index.d.ts +11 -12
- package/dist/index.js +92 -59
- package/dist/index.mjs +92 -59
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,7 +8,6 @@ The Agent Commerce Protocol (ACP) Node SDK is a modular, agentic-framework-agnos
|
|
|
8
8
|
- [ACP Node SDK](#acp-node-sdk)
|
|
9
9
|
- [Features](#features)
|
|
10
10
|
- [Prerequisites](#prerequisites)
|
|
11
|
-
- [Testing Requirements](#testing-requirements)
|
|
12
11
|
- [Installation](#installation)
|
|
13
12
|
- [Usage](#usage)
|
|
14
13
|
- [Core Functionality](#core-functionality)
|
|
@@ -46,14 +45,29 @@ The ACP Node SDK provides the following core functionalities:
|
|
|
46
45
|
|
|
47
46
|
## Prerequisites
|
|
48
47
|
|
|
49
|
-
⚠️ **Important**: Before testing your agent's services with a counterpart agent, you must register your agent with the [Service Registry](https://
|
|
48
|
+
⚠️ **Important**: Before testing your agent's services with a counterpart agent, you must register your agent with the [Service Registry](https://app.virtuals.io/acp/join). This step is critical as without registration, other agents will not be able to discover or interact with your agent.
|
|
50
49
|
|
|
51
|
-
### Testing
|
|
50
|
+
### Testing Flow
|
|
51
|
+
#### 1. Register a New Agent
|
|
52
|
+
- You’ll be working in the sandbox environment. Follow the [tutorial](https://whitepaper.virtuals.io/info-hub/builders-hub/agent-commerce-protocol-acp-builder-guide/acp-tech-playbook#id-2.-agent-creation-and-whitelisting) here to create your agent.
|
|
52
53
|
|
|
53
|
-
|
|
54
|
-
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
#### 2. Create Smart Wallet and Whitelist Dev Wallet
|
|
55
|
+
- Follow the [tutorial](https://whitepaper.virtuals.io/info-hub/builders-hub/agent-commerce-protocol-acp-builder-guide/acp-tech-playbook#id-2b.-create-smart-wallet-account-and-wallet-whitelisting-steps) here
|
|
56
|
+
|
|
57
|
+
#### 3. Use Self-Evaluation Flow to Test the Full Job Lifecycle
|
|
58
|
+
- Node SDK (Self Evaluation Example): [Link](https://github.com/Virtual-Protocol/acp-node/tree/main/examples/acp-base/self-evaluation)
|
|
59
|
+
|
|
60
|
+
#### 4. Fund Your Test Agent
|
|
61
|
+
- Top up your test buyer agent with $VIRTUAL. Gas fee is sponsored, ETH are not required.
|
|
62
|
+
- It is recommended to set the service price of the seller agent to $0.01 for testing purposes.
|
|
63
|
+
|
|
64
|
+
#### 5. Run Your Test Agent
|
|
65
|
+
- Set up your environment variables correctly (private key, wallet address, entity ID, etc.)
|
|
66
|
+
- When inserting `WHITELISTED_WALLET_PRIVATE_KEY`, you do not need to include the 0x prefix.
|
|
67
|
+
|
|
68
|
+
#### 6. Set up your buyer agent search keyword.
|
|
69
|
+
- Run your agent script.
|
|
70
|
+
- Note: Your agent will only appear in the sandbox after it has initiated at least 1 job request.
|
|
57
71
|
|
|
58
72
|
## Installation
|
|
59
73
|
|
package/dist/index.d.mts
CHANGED
|
@@ -114,8 +114,7 @@ declare enum MemoType {
|
|
|
114
114
|
TXHASH = 5,
|
|
115
115
|
PAYABLE_REQUEST = 6,
|
|
116
116
|
PAYABLE_TRANSFER = 7,
|
|
117
|
-
|
|
118
|
-
PAYABLE_FEE_REQUEST = 9
|
|
117
|
+
PAYABLE_TRANSFER_ESCROW = 8
|
|
119
118
|
}
|
|
120
119
|
declare enum AcpJobPhases {
|
|
121
120
|
REQUEST = 0,
|
|
@@ -8386,8 +8385,7 @@ declare class AcpContractClient {
|
|
|
8386
8385
|
jobId: number;
|
|
8387
8386
|
}>;
|
|
8388
8387
|
approveAllowance(priceInWei: bigint): Promise<`0x${string}`>;
|
|
8389
|
-
|
|
8390
|
-
createPayableMemo(jobId: number, content: string, amount: bigint, recipient: Address, feeAmount: bigint, feeType: FeeType, nextPhase: AcpJobPhases, type: MemoType.PAYABLE_REQUEST | MemoType.PAYABLE_TRANSFER, expiredAt?: Date, token?: Address): Promise<`0x${string}`>;
|
|
8388
|
+
createPayableMemo(jobId: number, content: string, amount: bigint, recipient: Address, feeAmount: bigint, feeType: FeeType, nextPhase: AcpJobPhases, type: MemoType.PAYABLE_REQUEST | MemoType.PAYABLE_TRANSFER_ESCROW, expiredAt: Date, token?: Address): Promise<`0x${string}`>;
|
|
8391
8389
|
createMemo(jobId: number, content: string, type: MemoType, isSecured: boolean, nextPhase: AcpJobPhases): Promise<Address>;
|
|
8392
8390
|
getMemoId(hash: Address): Promise<number>;
|
|
8393
8391
|
signMemo(memoId: number, isApproved: boolean, reason?: string): Promise<`0x${string}`>;
|
|
@@ -8547,19 +8545,20 @@ declare class AcpJob {
|
|
|
8547
8545
|
respond<T>(accept: boolean, payload?: GenericPayload<T>, reason?: string): Promise<`0x${string}` | undefined>;
|
|
8548
8546
|
deliver(deliverable: IDeliverable): Promise<`0x${string}`>;
|
|
8549
8547
|
evaluate(accept: boolean, reason?: string): Promise<`0x${string}`>;
|
|
8550
|
-
openPosition(payload: OpenPositionPayload[], feeAmount: number, expiredAt?: Date,
|
|
8548
|
+
openPosition(payload: OpenPositionPayload[], feeAmount: number, expiredAt?: Date, // 3 minutes
|
|
8549
|
+
walletAddress?: Address$1): Promise<`0x${string}`>;
|
|
8551
8550
|
responseOpenPosition(memoId: number, accept: boolean, reason: string): Promise<`0x${string}`>;
|
|
8552
|
-
closePartialPosition(payload: ClosePositionPayload): Promise<`0x${string}`>;
|
|
8551
|
+
closePartialPosition(payload: ClosePositionPayload, expireAt?: Date): Promise<`0x${string}`>;
|
|
8553
8552
|
responseClosePartialPosition(memoId: number, accept: boolean, reason: string): Promise<`0x${string}`>;
|
|
8554
8553
|
requestClosePosition(payload: RequestClosePositionPayload): Promise<`0x${string}`>;
|
|
8555
|
-
responseRequestClosePosition(memoId: number, accept: boolean, payload: ClosePositionPayload, reason?: string): Promise<`0x${string}` | undefined>;
|
|
8554
|
+
responseRequestClosePosition(memoId: number, accept: boolean, payload: ClosePositionPayload, reason?: string, expiredAt?: Date): Promise<`0x${string}` | undefined>;
|
|
8556
8555
|
confirmClosePosition(memoId: number, accept: boolean, reason?: string): Promise<void>;
|
|
8557
|
-
positionFulfilled(payload: PositionFulfilledPayload): Promise<`0x${string}`>;
|
|
8558
|
-
unfulfilledPosition(payload: UnfulfilledPositionPayload): Promise<`0x${string}`>;
|
|
8556
|
+
positionFulfilled(payload: PositionFulfilledPayload, expiredAt?: Date): Promise<`0x${string}`>;
|
|
8557
|
+
unfulfilledPosition(payload: UnfulfilledPositionPayload, expiredAt?: Date): Promise<`0x${string}`>;
|
|
8559
8558
|
responseUnfulfilledPosition(memoId: number, accept: boolean, reason: string): Promise<`0x${string}`>;
|
|
8560
8559
|
responsePositionFulfilled(memoId: number, accept: boolean, reason: string): Promise<`0x${string}`>;
|
|
8561
8560
|
closeJob(message?: string): Promise<`0x${string}`>;
|
|
8562
|
-
responseCloseJob(memoId: number, accept: boolean, fulfilledPositions: PositionFulfilledPayload[], reason?: string): Promise<`0x${string}` | undefined>;
|
|
8561
|
+
responseCloseJob(memoId: number, accept: boolean, fulfilledPositions: PositionFulfilledPayload[], reason?: string, expiredAt?: Date): Promise<`0x${string}` | undefined>;
|
|
8563
8562
|
confirmJobClosure(memoId: number, accept: boolean, reason?: string): Promise<void>;
|
|
8564
8563
|
}
|
|
8565
8564
|
|
|
@@ -8607,9 +8606,9 @@ declare class AcpClient {
|
|
|
8607
8606
|
initiateJob(providerAddress: Address$1, serviceRequirement: Object | string, amount: number, evaluatorAddress?: Address$1, expiredAt?: Date): Promise<number>;
|
|
8608
8607
|
respondJob(jobId: number, memoId: number, accept: boolean, content?: string, reason?: string): Promise<`0x${string}` | undefined>;
|
|
8609
8608
|
payJob(jobId: number, amount: number, memoId: number, reason?: string): Promise<`0x${string}`>;
|
|
8610
|
-
requestFunds<T>(jobId: number, amount: number, recipient: Address$1, feeAmount: number, feeType: FeeType, reason: GenericPayload<T>, nextPhase: AcpJobPhases): Promise<`0x${string}`>;
|
|
8609
|
+
requestFunds<T>(jobId: number, amount: number, recipient: Address$1, feeAmount: number, feeType: FeeType, reason: GenericPayload<T>, nextPhase: AcpJobPhases, expiredAt: Date): Promise<`0x${string}`>;
|
|
8611
8610
|
responseFundsRequest(memoId: number, accept: boolean, amount: number, reason?: string): Promise<`0x${string}`>;
|
|
8612
|
-
transferFunds<T>(jobId: number, amount: number, recipient: Address$1, feeAmount: number, feeType: FeeType, reason: GenericPayload<T>, nextPhase: AcpJobPhases, expiredAt
|
|
8611
|
+
transferFunds<T>(jobId: number, amount: number, recipient: Address$1, feeAmount: number, feeType: FeeType, reason: GenericPayload<T>, nextPhase: AcpJobPhases, expiredAt: Date): Promise<`0x${string}`>;
|
|
8613
8612
|
sendMessage<T>(jobId: number, message: GenericPayload<T>, nextPhase: AcpJobPhases): Promise<`0x${string}`>;
|
|
8614
8613
|
responseFundsTransfer(memoId: number, accept: boolean, reason?: string): Promise<`0x${string}`>;
|
|
8615
8614
|
deliverJob(jobId: number, deliverable: IDeliverable): Promise<`0x${string}`>;
|
package/dist/index.d.ts
CHANGED
|
@@ -114,8 +114,7 @@ declare enum MemoType {
|
|
|
114
114
|
TXHASH = 5,
|
|
115
115
|
PAYABLE_REQUEST = 6,
|
|
116
116
|
PAYABLE_TRANSFER = 7,
|
|
117
|
-
|
|
118
|
-
PAYABLE_FEE_REQUEST = 9
|
|
117
|
+
PAYABLE_TRANSFER_ESCROW = 8
|
|
119
118
|
}
|
|
120
119
|
declare enum AcpJobPhases {
|
|
121
120
|
REQUEST = 0,
|
|
@@ -8386,8 +8385,7 @@ declare class AcpContractClient {
|
|
|
8386
8385
|
jobId: number;
|
|
8387
8386
|
}>;
|
|
8388
8387
|
approveAllowance(priceInWei: bigint): Promise<`0x${string}`>;
|
|
8389
|
-
|
|
8390
|
-
createPayableMemo(jobId: number, content: string, amount: bigint, recipient: Address, feeAmount: bigint, feeType: FeeType, nextPhase: AcpJobPhases, type: MemoType.PAYABLE_REQUEST | MemoType.PAYABLE_TRANSFER, expiredAt?: Date, token?: Address): Promise<`0x${string}`>;
|
|
8388
|
+
createPayableMemo(jobId: number, content: string, amount: bigint, recipient: Address, feeAmount: bigint, feeType: FeeType, nextPhase: AcpJobPhases, type: MemoType.PAYABLE_REQUEST | MemoType.PAYABLE_TRANSFER_ESCROW, expiredAt: Date, token?: Address): Promise<`0x${string}`>;
|
|
8391
8389
|
createMemo(jobId: number, content: string, type: MemoType, isSecured: boolean, nextPhase: AcpJobPhases): Promise<Address>;
|
|
8392
8390
|
getMemoId(hash: Address): Promise<number>;
|
|
8393
8391
|
signMemo(memoId: number, isApproved: boolean, reason?: string): Promise<`0x${string}`>;
|
|
@@ -8547,19 +8545,20 @@ declare class AcpJob {
|
|
|
8547
8545
|
respond<T>(accept: boolean, payload?: GenericPayload<T>, reason?: string): Promise<`0x${string}` | undefined>;
|
|
8548
8546
|
deliver(deliverable: IDeliverable): Promise<`0x${string}`>;
|
|
8549
8547
|
evaluate(accept: boolean, reason?: string): Promise<`0x${string}`>;
|
|
8550
|
-
openPosition(payload: OpenPositionPayload[], feeAmount: number, expiredAt?: Date,
|
|
8548
|
+
openPosition(payload: OpenPositionPayload[], feeAmount: number, expiredAt?: Date, // 3 minutes
|
|
8549
|
+
walletAddress?: Address$1): Promise<`0x${string}`>;
|
|
8551
8550
|
responseOpenPosition(memoId: number, accept: boolean, reason: string): Promise<`0x${string}`>;
|
|
8552
|
-
closePartialPosition(payload: ClosePositionPayload): Promise<`0x${string}`>;
|
|
8551
|
+
closePartialPosition(payload: ClosePositionPayload, expireAt?: Date): Promise<`0x${string}`>;
|
|
8553
8552
|
responseClosePartialPosition(memoId: number, accept: boolean, reason: string): Promise<`0x${string}`>;
|
|
8554
8553
|
requestClosePosition(payload: RequestClosePositionPayload): Promise<`0x${string}`>;
|
|
8555
|
-
responseRequestClosePosition(memoId: number, accept: boolean, payload: ClosePositionPayload, reason?: string): Promise<`0x${string}` | undefined>;
|
|
8554
|
+
responseRequestClosePosition(memoId: number, accept: boolean, payload: ClosePositionPayload, reason?: string, expiredAt?: Date): Promise<`0x${string}` | undefined>;
|
|
8556
8555
|
confirmClosePosition(memoId: number, accept: boolean, reason?: string): Promise<void>;
|
|
8557
|
-
positionFulfilled(payload: PositionFulfilledPayload): Promise<`0x${string}`>;
|
|
8558
|
-
unfulfilledPosition(payload: UnfulfilledPositionPayload): Promise<`0x${string}`>;
|
|
8556
|
+
positionFulfilled(payload: PositionFulfilledPayload, expiredAt?: Date): Promise<`0x${string}`>;
|
|
8557
|
+
unfulfilledPosition(payload: UnfulfilledPositionPayload, expiredAt?: Date): Promise<`0x${string}`>;
|
|
8559
8558
|
responseUnfulfilledPosition(memoId: number, accept: boolean, reason: string): Promise<`0x${string}`>;
|
|
8560
8559
|
responsePositionFulfilled(memoId: number, accept: boolean, reason: string): Promise<`0x${string}`>;
|
|
8561
8560
|
closeJob(message?: string): Promise<`0x${string}`>;
|
|
8562
|
-
responseCloseJob(memoId: number, accept: boolean, fulfilledPositions: PositionFulfilledPayload[], reason?: string): Promise<`0x${string}` | undefined>;
|
|
8561
|
+
responseCloseJob(memoId: number, accept: boolean, fulfilledPositions: PositionFulfilledPayload[], reason?: string, expiredAt?: Date): Promise<`0x${string}` | undefined>;
|
|
8563
8562
|
confirmJobClosure(memoId: number, accept: boolean, reason?: string): Promise<void>;
|
|
8564
8563
|
}
|
|
8565
8564
|
|
|
@@ -8607,9 +8606,9 @@ declare class AcpClient {
|
|
|
8607
8606
|
initiateJob(providerAddress: Address$1, serviceRequirement: Object | string, amount: number, evaluatorAddress?: Address$1, expiredAt?: Date): Promise<number>;
|
|
8608
8607
|
respondJob(jobId: number, memoId: number, accept: boolean, content?: string, reason?: string): Promise<`0x${string}` | undefined>;
|
|
8609
8608
|
payJob(jobId: number, amount: number, memoId: number, reason?: string): Promise<`0x${string}`>;
|
|
8610
|
-
requestFunds<T>(jobId: number, amount: number, recipient: Address$1, feeAmount: number, feeType: FeeType, reason: GenericPayload<T>, nextPhase: AcpJobPhases): Promise<`0x${string}`>;
|
|
8609
|
+
requestFunds<T>(jobId: number, amount: number, recipient: Address$1, feeAmount: number, feeType: FeeType, reason: GenericPayload<T>, nextPhase: AcpJobPhases, expiredAt: Date): Promise<`0x${string}`>;
|
|
8611
8610
|
responseFundsRequest(memoId: number, accept: boolean, amount: number, reason?: string): Promise<`0x${string}`>;
|
|
8612
|
-
transferFunds<T>(jobId: number, amount: number, recipient: Address$1, feeAmount: number, feeType: FeeType, reason: GenericPayload<T>, nextPhase: AcpJobPhases, expiredAt
|
|
8611
|
+
transferFunds<T>(jobId: number, amount: number, recipient: Address$1, feeAmount: number, feeType: FeeType, reason: GenericPayload<T>, nextPhase: AcpJobPhases, expiredAt: Date): Promise<`0x${string}`>;
|
|
8613
8612
|
sendMessage<T>(jobId: number, message: GenericPayload<T>, nextPhase: AcpJobPhases): Promise<`0x${string}`>;
|
|
8614
8613
|
responseFundsTransfer(memoId: number, accept: boolean, reason?: string): Promise<`0x${string}`>;
|
|
8615
8614
|
deliverJob(jobId: number, deliverable: IDeliverable): Promise<`0x${string}`>;
|
package/dist/index.js
CHANGED
|
@@ -72,7 +72,7 @@ var require_package = __commonJS({
|
|
|
72
72
|
"package.json"(exports2, module2) {
|
|
73
73
|
module2.exports = {
|
|
74
74
|
name: "@virtuals-protocol/acp-node",
|
|
75
|
-
version: "0.2.0-beta.
|
|
75
|
+
version: "0.2.0-beta.5",
|
|
76
76
|
main: "./dist/index.js",
|
|
77
77
|
module: "./dist/index.mjs",
|
|
78
78
|
types: "./dist/index.d.ts",
|
|
@@ -410,6 +410,49 @@ var ACP_ABI = [
|
|
|
410
410
|
name: "PayableFeeRequestExecuted",
|
|
411
411
|
type: "event"
|
|
412
412
|
},
|
|
413
|
+
{
|
|
414
|
+
anonymous: false,
|
|
415
|
+
inputs: [
|
|
416
|
+
{
|
|
417
|
+
indexed: true,
|
|
418
|
+
internalType: "uint256",
|
|
419
|
+
name: "jobId",
|
|
420
|
+
type: "uint256"
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
indexed: true,
|
|
424
|
+
internalType: "uint256",
|
|
425
|
+
name: "memoId",
|
|
426
|
+
type: "uint256"
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
indexed: true,
|
|
430
|
+
internalType: "address",
|
|
431
|
+
name: "sender",
|
|
432
|
+
type: "address"
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
indexed: false,
|
|
436
|
+
internalType: "address",
|
|
437
|
+
name: "token",
|
|
438
|
+
type: "address"
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
indexed: false,
|
|
442
|
+
internalType: "uint256",
|
|
443
|
+
name: "amount",
|
|
444
|
+
type: "uint256"
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
indexed: false,
|
|
448
|
+
internalType: "uint256",
|
|
449
|
+
name: "feeAmount",
|
|
450
|
+
type: "uint256"
|
|
451
|
+
}
|
|
452
|
+
],
|
|
453
|
+
name: "PayableFundsEscrowed",
|
|
454
|
+
type: "event"
|
|
455
|
+
},
|
|
413
456
|
{
|
|
414
457
|
anonymous: false,
|
|
415
458
|
inputs: [
|
|
@@ -908,6 +951,15 @@ var ACP_ABI = [
|
|
|
908
951
|
stateMutability: "view",
|
|
909
952
|
type: "function"
|
|
910
953
|
},
|
|
954
|
+
{
|
|
955
|
+
inputs: [{ internalType: "uint256", name: "jobId", type: "uint256" }],
|
|
956
|
+
name: "jobPayment",
|
|
957
|
+
outputs: [
|
|
958
|
+
{ internalType: "address", name: "paymentToken", type: "address" }
|
|
959
|
+
],
|
|
960
|
+
stateMutability: "view",
|
|
961
|
+
type: "function"
|
|
962
|
+
},
|
|
911
963
|
{
|
|
912
964
|
inputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
913
965
|
name: "jobs",
|
|
@@ -1079,6 +1131,13 @@ var ACP_ABI = [
|
|
|
1079
1131
|
outputs: [],
|
|
1080
1132
|
stateMutability: "nonpayable",
|
|
1081
1133
|
type: "function"
|
|
1134
|
+
},
|
|
1135
|
+
{
|
|
1136
|
+
inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
|
|
1137
|
+
name: "withdrawEscrowedFunds",
|
|
1138
|
+
outputs: [],
|
|
1139
|
+
stateMutability: "nonpayable",
|
|
1140
|
+
type: "function"
|
|
1082
1141
|
}
|
|
1083
1142
|
];
|
|
1084
1143
|
var acpAbi_default = ACP_ABI;
|
|
@@ -1127,8 +1186,7 @@ var MemoType = /* @__PURE__ */ ((MemoType2) => {
|
|
|
1127
1186
|
MemoType2[MemoType2["TXHASH"] = 5] = "TXHASH";
|
|
1128
1187
|
MemoType2[MemoType2["PAYABLE_REQUEST"] = 6] = "PAYABLE_REQUEST";
|
|
1129
1188
|
MemoType2[MemoType2["PAYABLE_TRANSFER"] = 7] = "PAYABLE_TRANSFER";
|
|
1130
|
-
MemoType2[MemoType2["
|
|
1131
|
-
MemoType2[MemoType2["PAYABLE_FEE_REQUEST"] = 9] = "PAYABLE_FEE_REQUEST";
|
|
1189
|
+
MemoType2[MemoType2["PAYABLE_TRANSFER_ESCROW"] = 8] = "PAYABLE_TRANSFER_ESCROW";
|
|
1132
1190
|
return MemoType2;
|
|
1133
1191
|
})(MemoType || {});
|
|
1134
1192
|
var AcpJobPhases = /* @__PURE__ */ ((AcpJobPhases2) => {
|
|
@@ -1300,37 +1358,6 @@ var AcpContractClient = class _AcpContractClient {
|
|
|
1300
1358
|
}
|
|
1301
1359
|
});
|
|
1302
1360
|
}
|
|
1303
|
-
createPayableFeeMemo(jobId, content, amount, memoType, nextPhase) {
|
|
1304
|
-
return __async(this, null, function* () {
|
|
1305
|
-
let retries = 3;
|
|
1306
|
-
while (retries > 0) {
|
|
1307
|
-
try {
|
|
1308
|
-
const data = (0, import_viem.encodeFunctionData)({
|
|
1309
|
-
abi: acpAbi_default,
|
|
1310
|
-
functionName: "createPayableFeeMemo",
|
|
1311
|
-
args: [jobId, content, amount, memoType, nextPhase]
|
|
1312
|
-
});
|
|
1313
|
-
const { hash } = yield this.sessionKeyClient.sendUserOperation({
|
|
1314
|
-
uo: {
|
|
1315
|
-
target: this.contractAddress,
|
|
1316
|
-
data
|
|
1317
|
-
}
|
|
1318
|
-
});
|
|
1319
|
-
yield this.sessionKeyClient.waitForUserOperationTransaction({
|
|
1320
|
-
hash
|
|
1321
|
-
});
|
|
1322
|
-
return hash;
|
|
1323
|
-
} catch (error) {
|
|
1324
|
-
console.error(
|
|
1325
|
-
`failed to create payable fee memo ${jobId} ${content} ${error}`
|
|
1326
|
-
);
|
|
1327
|
-
retries -= 1;
|
|
1328
|
-
yield new Promise((resolve) => setTimeout(resolve, 2e3 * retries));
|
|
1329
|
-
}
|
|
1330
|
-
}
|
|
1331
|
-
throw new Error("Failed to create payable fee memo");
|
|
1332
|
-
});
|
|
1333
|
-
}
|
|
1334
1361
|
createPayableMemo(_0, _1, _2, _3, _4, _5, _6, _7, _8) {
|
|
1335
1362
|
return __async(this, arguments, function* (jobId, content, amount, recipient, feeAmount, feeType, nextPhase, type, expiredAt, token = this.config.virtualsTokenAddress) {
|
|
1336
1363
|
let retries = 3;
|
|
@@ -1349,7 +1376,7 @@ var AcpContractClient = class _AcpContractClient {
|
|
|
1349
1376
|
feeType,
|
|
1350
1377
|
type,
|
|
1351
1378
|
nextPhase,
|
|
1352
|
-
|
|
1379
|
+
Math.floor(expiredAt.getTime() / 1e3)
|
|
1353
1380
|
]
|
|
1354
1381
|
});
|
|
1355
1382
|
const { hash } = yield this.sessionKeyClient.sendUserOperation({
|
|
@@ -1571,8 +1598,8 @@ var AcpJob = class {
|
|
|
1571
1598
|
);
|
|
1572
1599
|
});
|
|
1573
1600
|
}
|
|
1574
|
-
openPosition(
|
|
1575
|
-
return __async(this,
|
|
1601
|
+
openPosition(_0, _1) {
|
|
1602
|
+
return __async(this, arguments, function* (payload, feeAmount, expiredAt = new Date(Date.now() + 1e3 * 60 * 3), walletAddress) {
|
|
1576
1603
|
if (payload.length === 0) {
|
|
1577
1604
|
throw new Error("No positions to open");
|
|
1578
1605
|
}
|
|
@@ -1594,7 +1621,7 @@ var AcpJob = class {
|
|
|
1594
1621
|
responseOpenPosition(memoId, accept, reason) {
|
|
1595
1622
|
return __async(this, null, function* () {
|
|
1596
1623
|
const memo = this.memos.find((m) => m.id === memoId);
|
|
1597
|
-
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !==
|
|
1624
|
+
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !== 8 /* PAYABLE_TRANSFER_ESCROW */) {
|
|
1598
1625
|
throw new Error("No open position memo found");
|
|
1599
1626
|
}
|
|
1600
1627
|
const payload = tryParseJson(
|
|
@@ -1606,8 +1633,8 @@ var AcpJob = class {
|
|
|
1606
1633
|
return yield this.acpClient.responseFundsTransfer(memo.id, accept, reason);
|
|
1607
1634
|
});
|
|
1608
1635
|
}
|
|
1609
|
-
closePartialPosition(
|
|
1610
|
-
return __async(this,
|
|
1636
|
+
closePartialPosition(_0) {
|
|
1637
|
+
return __async(this, arguments, function* (payload, expireAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
|
|
1611
1638
|
return yield this.acpClient.requestFunds(
|
|
1612
1639
|
this.id,
|
|
1613
1640
|
payload.amount,
|
|
@@ -1618,7 +1645,8 @@ var AcpJob = class {
|
|
|
1618
1645
|
type: "close_partial_position" /* CLOSE_PARTIAL_POSITION */,
|
|
1619
1646
|
data: payload
|
|
1620
1647
|
},
|
|
1621
|
-
2 /* TRANSACTION
|
|
1648
|
+
2 /* TRANSACTION */,
|
|
1649
|
+
expireAt
|
|
1622
1650
|
);
|
|
1623
1651
|
});
|
|
1624
1652
|
}
|
|
@@ -1654,8 +1682,8 @@ var AcpJob = class {
|
|
|
1654
1682
|
);
|
|
1655
1683
|
});
|
|
1656
1684
|
}
|
|
1657
|
-
responseRequestClosePosition(
|
|
1658
|
-
return __async(this,
|
|
1685
|
+
responseRequestClosePosition(_0, _1, _2, _3) {
|
|
1686
|
+
return __async(this, arguments, function* (memoId, accept, payload, reason, expiredAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
|
|
1659
1687
|
const memo = this.memos.find((m) => m.id === memoId);
|
|
1660
1688
|
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !== 0 /* MESSAGE */) {
|
|
1661
1689
|
throw new Error("No message memo found");
|
|
@@ -1676,7 +1704,8 @@ var AcpJob = class {
|
|
|
1676
1704
|
type: "close_position" /* CLOSE_POSITION */,
|
|
1677
1705
|
data: payload
|
|
1678
1706
|
},
|
|
1679
|
-
2 /* TRANSACTION
|
|
1707
|
+
2 /* TRANSACTION */,
|
|
1708
|
+
expiredAt
|
|
1680
1709
|
);
|
|
1681
1710
|
}
|
|
1682
1711
|
});
|
|
@@ -1684,7 +1713,7 @@ var AcpJob = class {
|
|
|
1684
1713
|
confirmClosePosition(memoId, accept, reason) {
|
|
1685
1714
|
return __async(this, null, function* () {
|
|
1686
1715
|
const memo = this.memos.find((m) => m.id === memoId);
|
|
1687
|
-
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !==
|
|
1716
|
+
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !== 8 /* PAYABLE_TRANSFER_ESCROW */) {
|
|
1688
1717
|
throw new Error("No payable transfer memo found");
|
|
1689
1718
|
}
|
|
1690
1719
|
const payload = tryParseJson(
|
|
@@ -1696,8 +1725,8 @@ var AcpJob = class {
|
|
|
1696
1725
|
yield memo.sign(accept, reason);
|
|
1697
1726
|
});
|
|
1698
1727
|
}
|
|
1699
|
-
positionFulfilled(
|
|
1700
|
-
return __async(this,
|
|
1728
|
+
positionFulfilled(_0) {
|
|
1729
|
+
return __async(this, arguments, function* (payload, expiredAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
|
|
1701
1730
|
return yield this.acpClient.transferFunds(
|
|
1702
1731
|
this.id,
|
|
1703
1732
|
payload.amount,
|
|
@@ -1708,12 +1737,13 @@ var AcpJob = class {
|
|
|
1708
1737
|
type: "position_fulfilled" /* POSITION_FULFILLED */,
|
|
1709
1738
|
data: payload
|
|
1710
1739
|
},
|
|
1711
|
-
2 /* TRANSACTION
|
|
1740
|
+
2 /* TRANSACTION */,
|
|
1741
|
+
expiredAt
|
|
1712
1742
|
);
|
|
1713
1743
|
});
|
|
1714
1744
|
}
|
|
1715
|
-
unfulfilledPosition(
|
|
1716
|
-
return __async(this,
|
|
1745
|
+
unfulfilledPosition(_0) {
|
|
1746
|
+
return __async(this, arguments, function* (payload, expiredAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
|
|
1717
1747
|
return yield this.acpClient.transferFunds(
|
|
1718
1748
|
this.id,
|
|
1719
1749
|
payload.amount,
|
|
@@ -1724,14 +1754,15 @@ var AcpJob = class {
|
|
|
1724
1754
|
type: "unfulfilled_position" /* UNFULFILLED_POSITION */,
|
|
1725
1755
|
data: payload
|
|
1726
1756
|
},
|
|
1727
|
-
2 /* TRANSACTION
|
|
1757
|
+
2 /* TRANSACTION */,
|
|
1758
|
+
expiredAt
|
|
1728
1759
|
);
|
|
1729
1760
|
});
|
|
1730
1761
|
}
|
|
1731
1762
|
responseUnfulfilledPosition(memoId, accept, reason) {
|
|
1732
1763
|
return __async(this, null, function* () {
|
|
1733
1764
|
const memo = this.memos.find((m) => m.id === memoId);
|
|
1734
|
-
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !==
|
|
1765
|
+
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !== 8 /* PAYABLE_TRANSFER_ESCROW */) {
|
|
1735
1766
|
throw new Error("No unfulfilled position memo found");
|
|
1736
1767
|
}
|
|
1737
1768
|
const payload = tryParseJson(
|
|
@@ -1746,7 +1777,7 @@ var AcpJob = class {
|
|
|
1746
1777
|
responsePositionFulfilled(memoId, accept, reason) {
|
|
1747
1778
|
return __async(this, null, function* () {
|
|
1748
1779
|
const memo = this.memos.find((m) => m.id === memoId);
|
|
1749
|
-
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !==
|
|
1780
|
+
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !== 8 /* PAYABLE_TRANSFER_ESCROW */) {
|
|
1750
1781
|
throw new Error("No position fulfilled memo found");
|
|
1751
1782
|
}
|
|
1752
1783
|
const payload = tryParseJson(
|
|
@@ -1772,8 +1803,8 @@ var AcpJob = class {
|
|
|
1772
1803
|
);
|
|
1773
1804
|
});
|
|
1774
1805
|
}
|
|
1775
|
-
responseCloseJob(
|
|
1776
|
-
return __async(this,
|
|
1806
|
+
responseCloseJob(_0, _1, _2, _3) {
|
|
1807
|
+
return __async(this, arguments, function* (memoId, accept, fulfilledPositions, reason, expiredAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
|
|
1777
1808
|
const memo = this.memos.find((m) => m.id === memoId);
|
|
1778
1809
|
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !== 0 /* MESSAGE */) {
|
|
1779
1810
|
throw new Error("No message memo found");
|
|
@@ -1812,7 +1843,8 @@ var AcpJob = class {
|
|
|
1812
1843
|
type: "close_job_and_withdraw" /* CLOSE_JOB_AND_WITHDRAW */,
|
|
1813
1844
|
data: fulfilledPositions
|
|
1814
1845
|
},
|
|
1815
|
-
4 /* COMPLETED
|
|
1846
|
+
4 /* COMPLETED */,
|
|
1847
|
+
expiredAt
|
|
1816
1848
|
);
|
|
1817
1849
|
});
|
|
1818
1850
|
}
|
|
@@ -2130,7 +2162,7 @@ var AcpClient = class {
|
|
|
2130
2162
|
);
|
|
2131
2163
|
});
|
|
2132
2164
|
}
|
|
2133
|
-
requestFunds(jobId, amount, recipient, feeAmount, feeType, reason, nextPhase) {
|
|
2165
|
+
requestFunds(jobId, amount, recipient, feeAmount, feeType, reason, nextPhase, expiredAt) {
|
|
2134
2166
|
return __async(this, null, function* () {
|
|
2135
2167
|
return yield this.acpContractClient.createPayableMemo(
|
|
2136
2168
|
jobId,
|
|
@@ -2140,7 +2172,8 @@ var AcpClient = class {
|
|
|
2140
2172
|
(0, import_viem2.parseEther)(feeAmount.toString()),
|
|
2141
2173
|
feeType,
|
|
2142
2174
|
nextPhase,
|
|
2143
|
-
6 /* PAYABLE_REQUEST
|
|
2175
|
+
6 /* PAYABLE_REQUEST */,
|
|
2176
|
+
expiredAt
|
|
2144
2177
|
);
|
|
2145
2178
|
});
|
|
2146
2179
|
}
|
|
@@ -2173,7 +2206,7 @@ var AcpClient = class {
|
|
|
2173
2206
|
(0, import_viem2.parseEther)(feeAmount.toString()),
|
|
2174
2207
|
feeType,
|
|
2175
2208
|
nextPhase,
|
|
2176
|
-
|
|
2209
|
+
8 /* PAYABLE_TRANSFER_ESCROW */,
|
|
2177
2210
|
expiredAt
|
|
2178
2211
|
);
|
|
2179
2212
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -47,7 +47,7 @@ var require_package = __commonJS({
|
|
|
47
47
|
"package.json"(exports, module) {
|
|
48
48
|
module.exports = {
|
|
49
49
|
name: "@virtuals-protocol/acp-node",
|
|
50
|
-
version: "0.2.0-beta.
|
|
50
|
+
version: "0.2.0-beta.5",
|
|
51
51
|
main: "./dist/index.js",
|
|
52
52
|
module: "./dist/index.mjs",
|
|
53
53
|
types: "./dist/index.d.ts",
|
|
@@ -365,6 +365,49 @@ var ACP_ABI = [
|
|
|
365
365
|
name: "PayableFeeRequestExecuted",
|
|
366
366
|
type: "event"
|
|
367
367
|
},
|
|
368
|
+
{
|
|
369
|
+
anonymous: false,
|
|
370
|
+
inputs: [
|
|
371
|
+
{
|
|
372
|
+
indexed: true,
|
|
373
|
+
internalType: "uint256",
|
|
374
|
+
name: "jobId",
|
|
375
|
+
type: "uint256"
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
indexed: true,
|
|
379
|
+
internalType: "uint256",
|
|
380
|
+
name: "memoId",
|
|
381
|
+
type: "uint256"
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
indexed: true,
|
|
385
|
+
internalType: "address",
|
|
386
|
+
name: "sender",
|
|
387
|
+
type: "address"
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
indexed: false,
|
|
391
|
+
internalType: "address",
|
|
392
|
+
name: "token",
|
|
393
|
+
type: "address"
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
indexed: false,
|
|
397
|
+
internalType: "uint256",
|
|
398
|
+
name: "amount",
|
|
399
|
+
type: "uint256"
|
|
400
|
+
},
|
|
401
|
+
{
|
|
402
|
+
indexed: false,
|
|
403
|
+
internalType: "uint256",
|
|
404
|
+
name: "feeAmount",
|
|
405
|
+
type: "uint256"
|
|
406
|
+
}
|
|
407
|
+
],
|
|
408
|
+
name: "PayableFundsEscrowed",
|
|
409
|
+
type: "event"
|
|
410
|
+
},
|
|
368
411
|
{
|
|
369
412
|
anonymous: false,
|
|
370
413
|
inputs: [
|
|
@@ -863,6 +906,15 @@ var ACP_ABI = [
|
|
|
863
906
|
stateMutability: "view",
|
|
864
907
|
type: "function"
|
|
865
908
|
},
|
|
909
|
+
{
|
|
910
|
+
inputs: [{ internalType: "uint256", name: "jobId", type: "uint256" }],
|
|
911
|
+
name: "jobPayment",
|
|
912
|
+
outputs: [
|
|
913
|
+
{ internalType: "address", name: "paymentToken", type: "address" }
|
|
914
|
+
],
|
|
915
|
+
stateMutability: "view",
|
|
916
|
+
type: "function"
|
|
917
|
+
},
|
|
866
918
|
{
|
|
867
919
|
inputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
868
920
|
name: "jobs",
|
|
@@ -1034,6 +1086,13 @@ var ACP_ABI = [
|
|
|
1034
1086
|
outputs: [],
|
|
1035
1087
|
stateMutability: "nonpayable",
|
|
1036
1088
|
type: "function"
|
|
1089
|
+
},
|
|
1090
|
+
{
|
|
1091
|
+
inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
|
|
1092
|
+
name: "withdrawEscrowedFunds",
|
|
1093
|
+
outputs: [],
|
|
1094
|
+
stateMutability: "nonpayable",
|
|
1095
|
+
type: "function"
|
|
1037
1096
|
}
|
|
1038
1097
|
];
|
|
1039
1098
|
var acpAbi_default = ACP_ABI;
|
|
@@ -1091,8 +1150,7 @@ var MemoType = /* @__PURE__ */ ((MemoType2) => {
|
|
|
1091
1150
|
MemoType2[MemoType2["TXHASH"] = 5] = "TXHASH";
|
|
1092
1151
|
MemoType2[MemoType2["PAYABLE_REQUEST"] = 6] = "PAYABLE_REQUEST";
|
|
1093
1152
|
MemoType2[MemoType2["PAYABLE_TRANSFER"] = 7] = "PAYABLE_TRANSFER";
|
|
1094
|
-
MemoType2[MemoType2["
|
|
1095
|
-
MemoType2[MemoType2["PAYABLE_FEE_REQUEST"] = 9] = "PAYABLE_FEE_REQUEST";
|
|
1153
|
+
MemoType2[MemoType2["PAYABLE_TRANSFER_ESCROW"] = 8] = "PAYABLE_TRANSFER_ESCROW";
|
|
1096
1154
|
return MemoType2;
|
|
1097
1155
|
})(MemoType || {});
|
|
1098
1156
|
var AcpJobPhases = /* @__PURE__ */ ((AcpJobPhases2) => {
|
|
@@ -1264,37 +1322,6 @@ var AcpContractClient = class _AcpContractClient {
|
|
|
1264
1322
|
}
|
|
1265
1323
|
});
|
|
1266
1324
|
}
|
|
1267
|
-
createPayableFeeMemo(jobId, content, amount, memoType, nextPhase) {
|
|
1268
|
-
return __async(this, null, function* () {
|
|
1269
|
-
let retries = 3;
|
|
1270
|
-
while (retries > 0) {
|
|
1271
|
-
try {
|
|
1272
|
-
const data = encodeFunctionData({
|
|
1273
|
-
abi: acpAbi_default,
|
|
1274
|
-
functionName: "createPayableFeeMemo",
|
|
1275
|
-
args: [jobId, content, amount, memoType, nextPhase]
|
|
1276
|
-
});
|
|
1277
|
-
const { hash } = yield this.sessionKeyClient.sendUserOperation({
|
|
1278
|
-
uo: {
|
|
1279
|
-
target: this.contractAddress,
|
|
1280
|
-
data
|
|
1281
|
-
}
|
|
1282
|
-
});
|
|
1283
|
-
yield this.sessionKeyClient.waitForUserOperationTransaction({
|
|
1284
|
-
hash
|
|
1285
|
-
});
|
|
1286
|
-
return hash;
|
|
1287
|
-
} catch (error) {
|
|
1288
|
-
console.error(
|
|
1289
|
-
`failed to create payable fee memo ${jobId} ${content} ${error}`
|
|
1290
|
-
);
|
|
1291
|
-
retries -= 1;
|
|
1292
|
-
yield new Promise((resolve) => setTimeout(resolve, 2e3 * retries));
|
|
1293
|
-
}
|
|
1294
|
-
}
|
|
1295
|
-
throw new Error("Failed to create payable fee memo");
|
|
1296
|
-
});
|
|
1297
|
-
}
|
|
1298
1325
|
createPayableMemo(_0, _1, _2, _3, _4, _5, _6, _7, _8) {
|
|
1299
1326
|
return __async(this, arguments, function* (jobId, content, amount, recipient, feeAmount, feeType, nextPhase, type, expiredAt, token = this.config.virtualsTokenAddress) {
|
|
1300
1327
|
let retries = 3;
|
|
@@ -1313,7 +1340,7 @@ var AcpContractClient = class _AcpContractClient {
|
|
|
1313
1340
|
feeType,
|
|
1314
1341
|
type,
|
|
1315
1342
|
nextPhase,
|
|
1316
|
-
|
|
1343
|
+
Math.floor(expiredAt.getTime() / 1e3)
|
|
1317
1344
|
]
|
|
1318
1345
|
});
|
|
1319
1346
|
const { hash } = yield this.sessionKeyClient.sendUserOperation({
|
|
@@ -1535,8 +1562,8 @@ var AcpJob = class {
|
|
|
1535
1562
|
);
|
|
1536
1563
|
});
|
|
1537
1564
|
}
|
|
1538
|
-
openPosition(
|
|
1539
|
-
return __async(this,
|
|
1565
|
+
openPosition(_0, _1) {
|
|
1566
|
+
return __async(this, arguments, function* (payload, feeAmount, expiredAt = new Date(Date.now() + 1e3 * 60 * 3), walletAddress) {
|
|
1540
1567
|
if (payload.length === 0) {
|
|
1541
1568
|
throw new Error("No positions to open");
|
|
1542
1569
|
}
|
|
@@ -1558,7 +1585,7 @@ var AcpJob = class {
|
|
|
1558
1585
|
responseOpenPosition(memoId, accept, reason) {
|
|
1559
1586
|
return __async(this, null, function* () {
|
|
1560
1587
|
const memo = this.memos.find((m) => m.id === memoId);
|
|
1561
|
-
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !==
|
|
1588
|
+
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !== 8 /* PAYABLE_TRANSFER_ESCROW */) {
|
|
1562
1589
|
throw new Error("No open position memo found");
|
|
1563
1590
|
}
|
|
1564
1591
|
const payload = tryParseJson(
|
|
@@ -1570,8 +1597,8 @@ var AcpJob = class {
|
|
|
1570
1597
|
return yield this.acpClient.responseFundsTransfer(memo.id, accept, reason);
|
|
1571
1598
|
});
|
|
1572
1599
|
}
|
|
1573
|
-
closePartialPosition(
|
|
1574
|
-
return __async(this,
|
|
1600
|
+
closePartialPosition(_0) {
|
|
1601
|
+
return __async(this, arguments, function* (payload, expireAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
|
|
1575
1602
|
return yield this.acpClient.requestFunds(
|
|
1576
1603
|
this.id,
|
|
1577
1604
|
payload.amount,
|
|
@@ -1582,7 +1609,8 @@ var AcpJob = class {
|
|
|
1582
1609
|
type: "close_partial_position" /* CLOSE_PARTIAL_POSITION */,
|
|
1583
1610
|
data: payload
|
|
1584
1611
|
},
|
|
1585
|
-
2 /* TRANSACTION
|
|
1612
|
+
2 /* TRANSACTION */,
|
|
1613
|
+
expireAt
|
|
1586
1614
|
);
|
|
1587
1615
|
});
|
|
1588
1616
|
}
|
|
@@ -1618,8 +1646,8 @@ var AcpJob = class {
|
|
|
1618
1646
|
);
|
|
1619
1647
|
});
|
|
1620
1648
|
}
|
|
1621
|
-
responseRequestClosePosition(
|
|
1622
|
-
return __async(this,
|
|
1649
|
+
responseRequestClosePosition(_0, _1, _2, _3) {
|
|
1650
|
+
return __async(this, arguments, function* (memoId, accept, payload, reason, expiredAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
|
|
1623
1651
|
const memo = this.memos.find((m) => m.id === memoId);
|
|
1624
1652
|
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !== 0 /* MESSAGE */) {
|
|
1625
1653
|
throw new Error("No message memo found");
|
|
@@ -1640,7 +1668,8 @@ var AcpJob = class {
|
|
|
1640
1668
|
type: "close_position" /* CLOSE_POSITION */,
|
|
1641
1669
|
data: payload
|
|
1642
1670
|
},
|
|
1643
|
-
2 /* TRANSACTION
|
|
1671
|
+
2 /* TRANSACTION */,
|
|
1672
|
+
expiredAt
|
|
1644
1673
|
);
|
|
1645
1674
|
}
|
|
1646
1675
|
});
|
|
@@ -1648,7 +1677,7 @@ var AcpJob = class {
|
|
|
1648
1677
|
confirmClosePosition(memoId, accept, reason) {
|
|
1649
1678
|
return __async(this, null, function* () {
|
|
1650
1679
|
const memo = this.memos.find((m) => m.id === memoId);
|
|
1651
|
-
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !==
|
|
1680
|
+
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !== 8 /* PAYABLE_TRANSFER_ESCROW */) {
|
|
1652
1681
|
throw new Error("No payable transfer memo found");
|
|
1653
1682
|
}
|
|
1654
1683
|
const payload = tryParseJson(
|
|
@@ -1660,8 +1689,8 @@ var AcpJob = class {
|
|
|
1660
1689
|
yield memo.sign(accept, reason);
|
|
1661
1690
|
});
|
|
1662
1691
|
}
|
|
1663
|
-
positionFulfilled(
|
|
1664
|
-
return __async(this,
|
|
1692
|
+
positionFulfilled(_0) {
|
|
1693
|
+
return __async(this, arguments, function* (payload, expiredAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
|
|
1665
1694
|
return yield this.acpClient.transferFunds(
|
|
1666
1695
|
this.id,
|
|
1667
1696
|
payload.amount,
|
|
@@ -1672,12 +1701,13 @@ var AcpJob = class {
|
|
|
1672
1701
|
type: "position_fulfilled" /* POSITION_FULFILLED */,
|
|
1673
1702
|
data: payload
|
|
1674
1703
|
},
|
|
1675
|
-
2 /* TRANSACTION
|
|
1704
|
+
2 /* TRANSACTION */,
|
|
1705
|
+
expiredAt
|
|
1676
1706
|
);
|
|
1677
1707
|
});
|
|
1678
1708
|
}
|
|
1679
|
-
unfulfilledPosition(
|
|
1680
|
-
return __async(this,
|
|
1709
|
+
unfulfilledPosition(_0) {
|
|
1710
|
+
return __async(this, arguments, function* (payload, expiredAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
|
|
1681
1711
|
return yield this.acpClient.transferFunds(
|
|
1682
1712
|
this.id,
|
|
1683
1713
|
payload.amount,
|
|
@@ -1688,14 +1718,15 @@ var AcpJob = class {
|
|
|
1688
1718
|
type: "unfulfilled_position" /* UNFULFILLED_POSITION */,
|
|
1689
1719
|
data: payload
|
|
1690
1720
|
},
|
|
1691
|
-
2 /* TRANSACTION
|
|
1721
|
+
2 /* TRANSACTION */,
|
|
1722
|
+
expiredAt
|
|
1692
1723
|
);
|
|
1693
1724
|
});
|
|
1694
1725
|
}
|
|
1695
1726
|
responseUnfulfilledPosition(memoId, accept, reason) {
|
|
1696
1727
|
return __async(this, null, function* () {
|
|
1697
1728
|
const memo = this.memos.find((m) => m.id === memoId);
|
|
1698
|
-
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !==
|
|
1729
|
+
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !== 8 /* PAYABLE_TRANSFER_ESCROW */) {
|
|
1699
1730
|
throw new Error("No unfulfilled position memo found");
|
|
1700
1731
|
}
|
|
1701
1732
|
const payload = tryParseJson(
|
|
@@ -1710,7 +1741,7 @@ var AcpJob = class {
|
|
|
1710
1741
|
responsePositionFulfilled(memoId, accept, reason) {
|
|
1711
1742
|
return __async(this, null, function* () {
|
|
1712
1743
|
const memo = this.memos.find((m) => m.id === memoId);
|
|
1713
|
-
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !==
|
|
1744
|
+
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !== 8 /* PAYABLE_TRANSFER_ESCROW */) {
|
|
1714
1745
|
throw new Error("No position fulfilled memo found");
|
|
1715
1746
|
}
|
|
1716
1747
|
const payload = tryParseJson(
|
|
@@ -1736,8 +1767,8 @@ var AcpJob = class {
|
|
|
1736
1767
|
);
|
|
1737
1768
|
});
|
|
1738
1769
|
}
|
|
1739
|
-
responseCloseJob(
|
|
1740
|
-
return __async(this,
|
|
1770
|
+
responseCloseJob(_0, _1, _2, _3) {
|
|
1771
|
+
return __async(this, arguments, function* (memoId, accept, fulfilledPositions, reason, expiredAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
|
|
1741
1772
|
const memo = this.memos.find((m) => m.id === memoId);
|
|
1742
1773
|
if ((memo == null ? void 0 : memo.nextPhase) !== 2 /* TRANSACTION */ || (memo == null ? void 0 : memo.type) !== 0 /* MESSAGE */) {
|
|
1743
1774
|
throw new Error("No message memo found");
|
|
@@ -1776,7 +1807,8 @@ var AcpJob = class {
|
|
|
1776
1807
|
type: "close_job_and_withdraw" /* CLOSE_JOB_AND_WITHDRAW */,
|
|
1777
1808
|
data: fulfilledPositions
|
|
1778
1809
|
},
|
|
1779
|
-
4 /* COMPLETED
|
|
1810
|
+
4 /* COMPLETED */,
|
|
1811
|
+
expiredAt
|
|
1780
1812
|
);
|
|
1781
1813
|
});
|
|
1782
1814
|
}
|
|
@@ -2094,7 +2126,7 @@ var AcpClient = class {
|
|
|
2094
2126
|
);
|
|
2095
2127
|
});
|
|
2096
2128
|
}
|
|
2097
|
-
requestFunds(jobId, amount, recipient, feeAmount, feeType, reason, nextPhase) {
|
|
2129
|
+
requestFunds(jobId, amount, recipient, feeAmount, feeType, reason, nextPhase, expiredAt) {
|
|
2098
2130
|
return __async(this, null, function* () {
|
|
2099
2131
|
return yield this.acpContractClient.createPayableMemo(
|
|
2100
2132
|
jobId,
|
|
@@ -2104,7 +2136,8 @@ var AcpClient = class {
|
|
|
2104
2136
|
parseEther(feeAmount.toString()),
|
|
2105
2137
|
feeType,
|
|
2106
2138
|
nextPhase,
|
|
2107
|
-
6 /* PAYABLE_REQUEST
|
|
2139
|
+
6 /* PAYABLE_REQUEST */,
|
|
2140
|
+
expiredAt
|
|
2108
2141
|
);
|
|
2109
2142
|
});
|
|
2110
2143
|
}
|
|
@@ -2137,7 +2170,7 @@ var AcpClient = class {
|
|
|
2137
2170
|
parseEther(feeAmount.toString()),
|
|
2138
2171
|
feeType,
|
|
2139
2172
|
nextPhase,
|
|
2140
|
-
|
|
2173
|
+
8 /* PAYABLE_TRANSFER_ESCROW */,
|
|
2141
2174
|
expiredAt
|
|
2142
2175
|
);
|
|
2143
2176
|
});
|