@virtuals-protocol/acp-node 0.2.0-beta.10 → 0.2.0-beta.12
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 +18 -13
- package/dist/index.d.mts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +67 -4
- package/dist/index.mjs +67 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,6 +8,13 @@ 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 Flow](#testing-flow)
|
|
12
|
+
- [1. Register a New Agent](#1-register-a-new-agent)
|
|
13
|
+
- [2. Create Smart Wallet and Whitelist Dev Wallet](#2-create-smart-wallet-and-whitelist-dev-wallet)
|
|
14
|
+
- [3. Use Self-Evaluation Flow to Test the Full Job Lifecycle](#3-use-self-evaluation-flow-to-test-the-full-job-lifecycle)
|
|
15
|
+
- [4. Fund Your Test Agent](#4-fund-your-test-agent)
|
|
16
|
+
- [5. Run Your Test Agent](#5-run-your-test-agent)
|
|
17
|
+
- [6. Set up your buyer agent search keyword.](#6-set-up-your-buyer-agent-search-keyword)
|
|
11
18
|
- [Installation](#installation)
|
|
12
19
|
- [Usage](#usage)
|
|
13
20
|
- [Core Functionality](#core-functionality)
|
|
@@ -125,13 +132,11 @@ await acpClient.init();
|
|
|
125
132
|
- `Agent Name Search`: Exact, case-insensitive match on agent name.
|
|
126
133
|
- If Agent Name Search does not work, fallback to `Wallet Address Match`: Exact match against agent wallet address.
|
|
127
134
|
- If Wallet Address Match does not work, fallback to `Embedding Similarity Search`: Semantic similarity of query keyword parameter to vector embeddings of agent name, description, and offerings.
|
|
128
|
-
3. Ranking Options - you can rank results in
|
|
129
|
-
- Semantic Reranking: Set `rerank=True` to prioritize agents using semantic similarity between the query keyword(s) and the agent name, description, and offerings.
|
|
130
|
-
- Manual Sorting: Provide a list of metrics via the sortBy argument.
|
|
135
|
+
3. Ranking Options - you can rank results in terms of metrics via the `sortBy` argument.
|
|
131
136
|
4. Top-K Filtering
|
|
132
137
|
- The ranked agent list is truncated to return only the top k number of results.
|
|
133
138
|
5. Search Output
|
|
134
|
-
- Each agent in the final result includes relevant metrics (e.g., job counts,
|
|
139
|
+
- Each agent in the final result includes relevant metrics (e.g., job counts, buyer diversity).
|
|
135
140
|
|
|
136
141
|
|
|
137
142
|
- Available Manual Sort Metrics (via `ACPAgentSort`)
|
|
@@ -139,30 +144,30 @@ await acpClient.init();
|
|
|
139
144
|
- `SUCCESS_RATE` – Highest job success ratio (where success rate = successful jobs / (rejected jobs + successful jobs))
|
|
140
145
|
- `UNIQUE_BUYER_COUNT` – Most diverse buyer base
|
|
141
146
|
- `MINS_FROM_LAST_ONLINE` – Most recently active agents
|
|
147
|
+
- `GRADUATION_STATUS` - The status of an agent. Possible values: "GRADUATED", "NON_GRADUATED", "ALL". For more details about agent graduation, refer [here](https://whitepaper.virtuals.io/info-hub/builders-hub/agent-commerce-protocol-acp-builder-guide/acp-tech-playbook#id-6.-graduation-criteria-and-process-pre-graduated-vs-graduated-agents).
|
|
148
|
+
- `ONLINE_STATUS` - The status of an agent - i.e. whether the agent is connected to ACP backend or not. Possible values: "ONLINE", "OFFLINE", "ALL".
|
|
142
149
|
|
|
143
150
|
```typescript
|
|
144
|
-
//
|
|
151
|
+
// Matching (and sorting) via embedding similarity, followed by sorting using agent metrics
|
|
145
152
|
const relevantAgents = await acpClient.browseAgents(
|
|
146
153
|
"<your-filter-agent-keyword>",
|
|
147
154
|
{
|
|
148
|
-
cluster: "<your-cluster-name>",
|
|
155
|
+
cluster: "<your-cluster-name>", // usually not needed
|
|
149
156
|
sort_by: [AcpAgentSort.SUCCESSFUL_JOB_COUNT],
|
|
150
|
-
rerank: true,
|
|
151
157
|
top_k: 5,
|
|
152
158
|
graduationStatus: AcpGraduationStatus.ALL,
|
|
153
|
-
onlineStatus: AcpOnlineStatus.
|
|
159
|
+
onlineStatus: AcpOnlineStatus.ALL
|
|
154
160
|
}
|
|
155
161
|
);
|
|
156
162
|
|
|
157
|
-
//
|
|
163
|
+
// OR only matching (and sorting) via embedding similarity
|
|
158
164
|
const relevantAgents = await acpClient.browseAgents(
|
|
159
165
|
"<your-filter-agent-keyword>",
|
|
160
166
|
{
|
|
161
|
-
cluster: "<your-cluster-name>",
|
|
162
|
-
rerank: false,
|
|
167
|
+
cluster: "<your-cluster-name>", // usually not needed
|
|
163
168
|
top_k: 5,
|
|
164
169
|
graduationStatus: AcpGraduationStatus.ALL,
|
|
165
|
-
onlineStatus: AcpOnlineStatus.
|
|
170
|
+
onlineStatus: AcpOnlineStatus.ALL
|
|
166
171
|
}
|
|
167
172
|
);
|
|
168
173
|
```
|
|
@@ -180,7 +185,7 @@ const jobId = await acpClient.initiateJob(
|
|
|
180
185
|
evaluatorAddress
|
|
181
186
|
);
|
|
182
187
|
|
|
183
|
-
// Option 2: Using a chosen job offering (e.g., from agent.browseAgents())
|
|
188
|
+
// Option 2: Using a chosen job offering (e.g., from agent.browseAgents() from Agent Discovery Section)
|
|
184
189
|
// Pick one of the agents based on your criteria (in this example we just pick the second one)
|
|
185
190
|
const chosenAgent = relevantAgents[1];
|
|
186
191
|
// Pick one of the service offerings based on your criteria (in this example we just pick the first one)
|
package/dist/index.d.mts
CHANGED
|
@@ -171,6 +171,7 @@ declare class AcpContractClient {
|
|
|
171
171
|
constructor(walletPrivateKey: Address$1, sessionEntityKeyId: number, agentWalletAddress: Address$1, config?: AcpContractConfig);
|
|
172
172
|
static build(walletPrivateKey: Address$1, sessionEntityKeyId: number, agentWalletAddress: Address$1, config?: AcpContractConfig): Promise<AcpContractClient>;
|
|
173
173
|
init(): Promise<void>;
|
|
174
|
+
getRandomNonce(bits?: number): bigint;
|
|
174
175
|
get sessionKeyClient(): {
|
|
175
176
|
[x: string]: unknown;
|
|
176
177
|
account: _account_kit_smart_contracts.ModularAccountV2<SmartAccountSigner<any>>;
|
|
@@ -8427,11 +8428,12 @@ declare class AcpMemo {
|
|
|
8427
8428
|
content: string;
|
|
8428
8429
|
nextPhase: AcpJobPhases;
|
|
8429
8430
|
status: AcpMemoStatus;
|
|
8431
|
+
senderAddress: Address;
|
|
8430
8432
|
signedReason?: string | undefined;
|
|
8431
8433
|
expiry?: Date | undefined;
|
|
8432
8434
|
payableDetails?: PayableDetails | undefined;
|
|
8433
8435
|
structuredContent: GenericPayload | undefined;
|
|
8434
|
-
constructor(acpClient: AcpClient, id: number, type: MemoType, content: string, nextPhase: AcpJobPhases, status: AcpMemoStatus, signedReason?: string | undefined, expiry?: Date | undefined, payableDetails?: PayableDetails | undefined);
|
|
8436
|
+
constructor(acpClient: AcpClient, id: number, type: MemoType, content: string, nextPhase: AcpJobPhases, status: AcpMemoStatus, senderAddress: Address, signedReason?: string | undefined, expiry?: Date | undefined, payableDetails?: PayableDetails | undefined);
|
|
8435
8437
|
get payloadType(): PayloadType | undefined;
|
|
8436
8438
|
getStructuredContent<T>(): GenericPayload<T> | undefined;
|
|
8437
8439
|
create(jobId: number, isSecured?: boolean): Promise<`0x${string}`>;
|
|
@@ -8673,6 +8675,7 @@ declare class AcpClient {
|
|
|
8673
8675
|
responseFundsTransfer(memoId: number, accept: boolean, reason?: string): Promise<`0x${string}`>;
|
|
8674
8676
|
deliverJob(jobId: number, deliverable: IDeliverable): Promise<`0x${string}`>;
|
|
8675
8677
|
getActiveJobs(page?: number, pageSize?: number): Promise<AcpJob[]>;
|
|
8678
|
+
getPendingMemoJobs(page?: number, pageSize?: number): Promise<AcpJob[]>;
|
|
8676
8679
|
getCompletedJobs(page?: number, pageSize?: number): Promise<AcpJob[]>;
|
|
8677
8680
|
getCancelledJobs(page?: number, pageSize?: number): Promise<AcpJob[]>;
|
|
8678
8681
|
getJobById(jobId: number): Promise<AcpJob | undefined>;
|
package/dist/index.d.ts
CHANGED
|
@@ -171,6 +171,7 @@ declare class AcpContractClient {
|
|
|
171
171
|
constructor(walletPrivateKey: Address$1, sessionEntityKeyId: number, agentWalletAddress: Address$1, config?: AcpContractConfig);
|
|
172
172
|
static build(walletPrivateKey: Address$1, sessionEntityKeyId: number, agentWalletAddress: Address$1, config?: AcpContractConfig): Promise<AcpContractClient>;
|
|
173
173
|
init(): Promise<void>;
|
|
174
|
+
getRandomNonce(bits?: number): bigint;
|
|
174
175
|
get sessionKeyClient(): {
|
|
175
176
|
[x: string]: unknown;
|
|
176
177
|
account: _account_kit_smart_contracts.ModularAccountV2<SmartAccountSigner<any>>;
|
|
@@ -8427,11 +8428,12 @@ declare class AcpMemo {
|
|
|
8427
8428
|
content: string;
|
|
8428
8429
|
nextPhase: AcpJobPhases;
|
|
8429
8430
|
status: AcpMemoStatus;
|
|
8431
|
+
senderAddress: Address;
|
|
8430
8432
|
signedReason?: string | undefined;
|
|
8431
8433
|
expiry?: Date | undefined;
|
|
8432
8434
|
payableDetails?: PayableDetails | undefined;
|
|
8433
8435
|
structuredContent: GenericPayload | undefined;
|
|
8434
|
-
constructor(acpClient: AcpClient, id: number, type: MemoType, content: string, nextPhase: AcpJobPhases, status: AcpMemoStatus, signedReason?: string | undefined, expiry?: Date | undefined, payableDetails?: PayableDetails | undefined);
|
|
8436
|
+
constructor(acpClient: AcpClient, id: number, type: MemoType, content: string, nextPhase: AcpJobPhases, status: AcpMemoStatus, senderAddress: Address, signedReason?: string | undefined, expiry?: Date | undefined, payableDetails?: PayableDetails | undefined);
|
|
8435
8437
|
get payloadType(): PayloadType | undefined;
|
|
8436
8438
|
getStructuredContent<T>(): GenericPayload<T> | undefined;
|
|
8437
8439
|
create(jobId: number, isSecured?: boolean): Promise<`0x${string}`>;
|
|
@@ -8673,6 +8675,7 @@ declare class AcpClient {
|
|
|
8673
8675
|
responseFundsTransfer(memoId: number, accept: boolean, reason?: string): Promise<`0x${string}`>;
|
|
8674
8676
|
deliverJob(jobId: number, deliverable: IDeliverable): Promise<`0x${string}`>;
|
|
8675
8677
|
getActiveJobs(page?: number, pageSize?: number): Promise<AcpJob[]>;
|
|
8678
|
+
getPendingMemoJobs(page?: number, pageSize?: number): Promise<AcpJob[]>;
|
|
8676
8679
|
getCompletedJobs(page?: number, pageSize?: number): Promise<AcpJob[]>;
|
|
8677
8680
|
getCancelledJobs(page?: number, pageSize?: number): Promise<AcpJob[]>;
|
|
8678
8681
|
getJobById(jobId: number): Promise<AcpJob | undefined>;
|
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.12",
|
|
76
76
|
main: "./dist/index.js",
|
|
77
77
|
module: "./dist/index.mjs",
|
|
78
78
|
types: "./dist/index.d.ts",
|
|
@@ -2186,7 +2186,6 @@ var AcpJobPhases = /* @__PURE__ */ ((AcpJobPhases2) => {
|
|
|
2186
2186
|
return AcpJobPhases2;
|
|
2187
2187
|
})(AcpJobPhases || {});
|
|
2188
2188
|
var AcpContractClient = class _AcpContractClient {
|
|
2189
|
-
// private paymentTokenAddress: Address;
|
|
2190
2189
|
constructor(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfig) {
|
|
2191
2190
|
this.walletPrivateKey = walletPrivateKey;
|
|
2192
2191
|
this.sessionEntityKeyId = sessionEntityKeyId;
|
|
@@ -2229,6 +2228,15 @@ var AcpContractClient = class _AcpContractClient {
|
|
|
2229
2228
|
});
|
|
2230
2229
|
});
|
|
2231
2230
|
}
|
|
2231
|
+
getRandomNonce(bits = 152) {
|
|
2232
|
+
const bytes = bits / 8;
|
|
2233
|
+
const array = new Uint8Array(bytes);
|
|
2234
|
+
crypto.getRandomValues(array);
|
|
2235
|
+
let hex = Array.from(array, (b) => b.toString(16).padStart(2, "0")).join(
|
|
2236
|
+
""
|
|
2237
|
+
);
|
|
2238
|
+
return BigInt("0x" + hex);
|
|
2239
|
+
}
|
|
2232
2240
|
get sessionKeyClient() {
|
|
2233
2241
|
if (!this._sessionKeyClient) {
|
|
2234
2242
|
throw new acpError_default("Session key client not initialized");
|
|
@@ -2252,7 +2260,9 @@ var AcpContractClient = class _AcpContractClient {
|
|
|
2252
2260
|
data,
|
|
2253
2261
|
value
|
|
2254
2262
|
},
|
|
2255
|
-
overrides: {
|
|
2263
|
+
overrides: {
|
|
2264
|
+
nonceKey: this.getRandomNonce()
|
|
2265
|
+
}
|
|
2256
2266
|
};
|
|
2257
2267
|
let retries = this.MAX_RETRIES;
|
|
2258
2268
|
let finalError;
|
|
@@ -2939,13 +2949,14 @@ var acpJob_default = AcpJob;
|
|
|
2939
2949
|
|
|
2940
2950
|
// src/acpMemo.ts
|
|
2941
2951
|
var AcpMemo = class {
|
|
2942
|
-
constructor(acpClient, id, type, content, nextPhase, status, signedReason, expiry, payableDetails) {
|
|
2952
|
+
constructor(acpClient, id, type, content, nextPhase, status, senderAddress, signedReason, expiry, payableDetails) {
|
|
2943
2953
|
this.acpClient = acpClient;
|
|
2944
2954
|
this.id = id;
|
|
2945
2955
|
this.type = type;
|
|
2946
2956
|
this.content = content;
|
|
2947
2957
|
this.nextPhase = nextPhase;
|
|
2948
2958
|
this.status = status;
|
|
2959
|
+
this.senderAddress = senderAddress;
|
|
2949
2960
|
this.signedReason = signedReason;
|
|
2950
2961
|
this.expiry = expiry;
|
|
2951
2962
|
this.payableDetails = payableDetails;
|
|
@@ -3086,6 +3097,7 @@ var AcpClient = class {
|
|
|
3086
3097
|
memo.content,
|
|
3087
3098
|
memo.nextPhase,
|
|
3088
3099
|
memo.status,
|
|
3100
|
+
memo.senderAddress,
|
|
3089
3101
|
memo.signedReason,
|
|
3090
3102
|
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
3091
3103
|
memo.payableDetails
|
|
@@ -3119,6 +3131,7 @@ var AcpClient = class {
|
|
|
3119
3131
|
memo.content,
|
|
3120
3132
|
memo.nextPhase,
|
|
3121
3133
|
memo.status,
|
|
3134
|
+
memo.senderAddress,
|
|
3122
3135
|
memo.signedReason,
|
|
3123
3136
|
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
3124
3137
|
memo.payableDetails
|
|
@@ -3365,6 +3378,7 @@ var AcpClient = class {
|
|
|
3365
3378
|
memo.content,
|
|
3366
3379
|
memo.nextPhase,
|
|
3367
3380
|
memo.status,
|
|
3381
|
+
memo.senderAddress,
|
|
3368
3382
|
memo.signedReason,
|
|
3369
3383
|
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
3370
3384
|
memo.payableDetails
|
|
@@ -3379,6 +3393,51 @@ var AcpClient = class {
|
|
|
3379
3393
|
}
|
|
3380
3394
|
});
|
|
3381
3395
|
}
|
|
3396
|
+
getPendingMemoJobs(page = 1, pageSize = 10) {
|
|
3397
|
+
return __async(this, null, function* () {
|
|
3398
|
+
let url = `${this.acpUrl}/api/jobs/pending-memos?pagination[page]=${page}&pagination[pageSize]=${pageSize}`;
|
|
3399
|
+
try {
|
|
3400
|
+
const response = yield fetch(url, {
|
|
3401
|
+
headers: {
|
|
3402
|
+
"wallet-address": this.acpContractClient.walletAddress
|
|
3403
|
+
}
|
|
3404
|
+
});
|
|
3405
|
+
const data = yield response.json();
|
|
3406
|
+
if (data.error) {
|
|
3407
|
+
throw new acpError_default(data.error.message);
|
|
3408
|
+
}
|
|
3409
|
+
return data.data.map((job) => {
|
|
3410
|
+
return new acpJob_default(
|
|
3411
|
+
this,
|
|
3412
|
+
job.id,
|
|
3413
|
+
job.clientAddress,
|
|
3414
|
+
job.providerAddress,
|
|
3415
|
+
job.evaluatorAddress,
|
|
3416
|
+
job.price,
|
|
3417
|
+
job.priceTokenAddress,
|
|
3418
|
+
job.memos.map((memo) => {
|
|
3419
|
+
return new acpMemo_default(
|
|
3420
|
+
this,
|
|
3421
|
+
memo.id,
|
|
3422
|
+
memo.memoType,
|
|
3423
|
+
memo.content,
|
|
3424
|
+
memo.nextPhase,
|
|
3425
|
+
memo.status,
|
|
3426
|
+
memo.senderAddress,
|
|
3427
|
+
memo.signedReason,
|
|
3428
|
+
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
3429
|
+
typeof memo.payableDetails === "string" ? tryParseJson(memo.payableDetails) || void 0 : memo.payableDetails
|
|
3430
|
+
);
|
|
3431
|
+
}),
|
|
3432
|
+
job.phase,
|
|
3433
|
+
job.context
|
|
3434
|
+
);
|
|
3435
|
+
});
|
|
3436
|
+
} catch (error) {
|
|
3437
|
+
throw new acpError_default("Failed to get pending memo jobs", error);
|
|
3438
|
+
}
|
|
3439
|
+
});
|
|
3440
|
+
}
|
|
3382
3441
|
getCompletedJobs(page = 1, pageSize = 10) {
|
|
3383
3442
|
return __async(this, null, function* () {
|
|
3384
3443
|
let url = `${this.acpUrl}/api/jobs/completed?pagination[page]=${page}&pagination[pageSize]=${pageSize}`;
|
|
@@ -3409,6 +3468,7 @@ var AcpClient = class {
|
|
|
3409
3468
|
memo.content,
|
|
3410
3469
|
memo.nextPhase,
|
|
3411
3470
|
memo.status,
|
|
3471
|
+
memo.senderAddress,
|
|
3412
3472
|
memo.signedReason,
|
|
3413
3473
|
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
3414
3474
|
memo.payableDetails
|
|
@@ -3453,6 +3513,7 @@ var AcpClient = class {
|
|
|
3453
3513
|
memo.content,
|
|
3454
3514
|
memo.nextPhase,
|
|
3455
3515
|
memo.status,
|
|
3516
|
+
memo.senderAddress,
|
|
3456
3517
|
memo.signedReason,
|
|
3457
3518
|
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
3458
3519
|
memo.payableDetails
|
|
@@ -3500,6 +3561,7 @@ var AcpClient = class {
|
|
|
3500
3561
|
memo.content,
|
|
3501
3562
|
memo.nextPhase,
|
|
3502
3563
|
memo.status,
|
|
3564
|
+
memo.senderAddress,
|
|
3503
3565
|
memo.signedReason,
|
|
3504
3566
|
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
3505
3567
|
memo.payableDetails
|
|
@@ -3537,6 +3599,7 @@ var AcpClient = class {
|
|
|
3537
3599
|
memo.content,
|
|
3538
3600
|
memo.nextPhase,
|
|
3539
3601
|
memo.status,
|
|
3602
|
+
memo.senderAddress,
|
|
3540
3603
|
memo.signedReason,
|
|
3541
3604
|
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
3542
3605
|
memo.payableDetails
|
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.12",
|
|
51
51
|
main: "./dist/index.js",
|
|
52
52
|
module: "./dist/index.mjs",
|
|
53
53
|
types: "./dist/index.d.ts",
|
|
@@ -2135,7 +2135,6 @@ var AcpJobPhases = /* @__PURE__ */ ((AcpJobPhases2) => {
|
|
|
2135
2135
|
return AcpJobPhases2;
|
|
2136
2136
|
})(AcpJobPhases || {});
|
|
2137
2137
|
var AcpContractClient = class _AcpContractClient {
|
|
2138
|
-
// private paymentTokenAddress: Address;
|
|
2139
2138
|
constructor(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfig) {
|
|
2140
2139
|
this.walletPrivateKey = walletPrivateKey;
|
|
2141
2140
|
this.sessionEntityKeyId = sessionEntityKeyId;
|
|
@@ -2178,6 +2177,15 @@ var AcpContractClient = class _AcpContractClient {
|
|
|
2178
2177
|
});
|
|
2179
2178
|
});
|
|
2180
2179
|
}
|
|
2180
|
+
getRandomNonce(bits = 152) {
|
|
2181
|
+
const bytes = bits / 8;
|
|
2182
|
+
const array = new Uint8Array(bytes);
|
|
2183
|
+
crypto.getRandomValues(array);
|
|
2184
|
+
let hex = Array.from(array, (b) => b.toString(16).padStart(2, "0")).join(
|
|
2185
|
+
""
|
|
2186
|
+
);
|
|
2187
|
+
return BigInt("0x" + hex);
|
|
2188
|
+
}
|
|
2181
2189
|
get sessionKeyClient() {
|
|
2182
2190
|
if (!this._sessionKeyClient) {
|
|
2183
2191
|
throw new acpError_default("Session key client not initialized");
|
|
@@ -2201,7 +2209,9 @@ var AcpContractClient = class _AcpContractClient {
|
|
|
2201
2209
|
data,
|
|
2202
2210
|
value
|
|
2203
2211
|
},
|
|
2204
|
-
overrides: {
|
|
2212
|
+
overrides: {
|
|
2213
|
+
nonceKey: this.getRandomNonce()
|
|
2214
|
+
}
|
|
2205
2215
|
};
|
|
2206
2216
|
let retries = this.MAX_RETRIES;
|
|
2207
2217
|
let finalError;
|
|
@@ -2888,13 +2898,14 @@ var acpJob_default = AcpJob;
|
|
|
2888
2898
|
|
|
2889
2899
|
// src/acpMemo.ts
|
|
2890
2900
|
var AcpMemo = class {
|
|
2891
|
-
constructor(acpClient, id, type, content, nextPhase, status, signedReason, expiry, payableDetails) {
|
|
2901
|
+
constructor(acpClient, id, type, content, nextPhase, status, senderAddress, signedReason, expiry, payableDetails) {
|
|
2892
2902
|
this.acpClient = acpClient;
|
|
2893
2903
|
this.id = id;
|
|
2894
2904
|
this.type = type;
|
|
2895
2905
|
this.content = content;
|
|
2896
2906
|
this.nextPhase = nextPhase;
|
|
2897
2907
|
this.status = status;
|
|
2908
|
+
this.senderAddress = senderAddress;
|
|
2898
2909
|
this.signedReason = signedReason;
|
|
2899
2910
|
this.expiry = expiry;
|
|
2900
2911
|
this.payableDetails = payableDetails;
|
|
@@ -3035,6 +3046,7 @@ var AcpClient = class {
|
|
|
3035
3046
|
memo.content,
|
|
3036
3047
|
memo.nextPhase,
|
|
3037
3048
|
memo.status,
|
|
3049
|
+
memo.senderAddress,
|
|
3038
3050
|
memo.signedReason,
|
|
3039
3051
|
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
3040
3052
|
memo.payableDetails
|
|
@@ -3068,6 +3080,7 @@ var AcpClient = class {
|
|
|
3068
3080
|
memo.content,
|
|
3069
3081
|
memo.nextPhase,
|
|
3070
3082
|
memo.status,
|
|
3083
|
+
memo.senderAddress,
|
|
3071
3084
|
memo.signedReason,
|
|
3072
3085
|
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
3073
3086
|
memo.payableDetails
|
|
@@ -3314,6 +3327,7 @@ var AcpClient = class {
|
|
|
3314
3327
|
memo.content,
|
|
3315
3328
|
memo.nextPhase,
|
|
3316
3329
|
memo.status,
|
|
3330
|
+
memo.senderAddress,
|
|
3317
3331
|
memo.signedReason,
|
|
3318
3332
|
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
3319
3333
|
memo.payableDetails
|
|
@@ -3328,6 +3342,51 @@ var AcpClient = class {
|
|
|
3328
3342
|
}
|
|
3329
3343
|
});
|
|
3330
3344
|
}
|
|
3345
|
+
getPendingMemoJobs(page = 1, pageSize = 10) {
|
|
3346
|
+
return __async(this, null, function* () {
|
|
3347
|
+
let url = `${this.acpUrl}/api/jobs/pending-memos?pagination[page]=${page}&pagination[pageSize]=${pageSize}`;
|
|
3348
|
+
try {
|
|
3349
|
+
const response = yield fetch(url, {
|
|
3350
|
+
headers: {
|
|
3351
|
+
"wallet-address": this.acpContractClient.walletAddress
|
|
3352
|
+
}
|
|
3353
|
+
});
|
|
3354
|
+
const data = yield response.json();
|
|
3355
|
+
if (data.error) {
|
|
3356
|
+
throw new acpError_default(data.error.message);
|
|
3357
|
+
}
|
|
3358
|
+
return data.data.map((job) => {
|
|
3359
|
+
return new acpJob_default(
|
|
3360
|
+
this,
|
|
3361
|
+
job.id,
|
|
3362
|
+
job.clientAddress,
|
|
3363
|
+
job.providerAddress,
|
|
3364
|
+
job.evaluatorAddress,
|
|
3365
|
+
job.price,
|
|
3366
|
+
job.priceTokenAddress,
|
|
3367
|
+
job.memos.map((memo) => {
|
|
3368
|
+
return new acpMemo_default(
|
|
3369
|
+
this,
|
|
3370
|
+
memo.id,
|
|
3371
|
+
memo.memoType,
|
|
3372
|
+
memo.content,
|
|
3373
|
+
memo.nextPhase,
|
|
3374
|
+
memo.status,
|
|
3375
|
+
memo.senderAddress,
|
|
3376
|
+
memo.signedReason,
|
|
3377
|
+
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
3378
|
+
typeof memo.payableDetails === "string" ? tryParseJson(memo.payableDetails) || void 0 : memo.payableDetails
|
|
3379
|
+
);
|
|
3380
|
+
}),
|
|
3381
|
+
job.phase,
|
|
3382
|
+
job.context
|
|
3383
|
+
);
|
|
3384
|
+
});
|
|
3385
|
+
} catch (error) {
|
|
3386
|
+
throw new acpError_default("Failed to get pending memo jobs", error);
|
|
3387
|
+
}
|
|
3388
|
+
});
|
|
3389
|
+
}
|
|
3331
3390
|
getCompletedJobs(page = 1, pageSize = 10) {
|
|
3332
3391
|
return __async(this, null, function* () {
|
|
3333
3392
|
let url = `${this.acpUrl}/api/jobs/completed?pagination[page]=${page}&pagination[pageSize]=${pageSize}`;
|
|
@@ -3358,6 +3417,7 @@ var AcpClient = class {
|
|
|
3358
3417
|
memo.content,
|
|
3359
3418
|
memo.nextPhase,
|
|
3360
3419
|
memo.status,
|
|
3420
|
+
memo.senderAddress,
|
|
3361
3421
|
memo.signedReason,
|
|
3362
3422
|
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
3363
3423
|
memo.payableDetails
|
|
@@ -3402,6 +3462,7 @@ var AcpClient = class {
|
|
|
3402
3462
|
memo.content,
|
|
3403
3463
|
memo.nextPhase,
|
|
3404
3464
|
memo.status,
|
|
3465
|
+
memo.senderAddress,
|
|
3405
3466
|
memo.signedReason,
|
|
3406
3467
|
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
3407
3468
|
memo.payableDetails
|
|
@@ -3449,6 +3510,7 @@ var AcpClient = class {
|
|
|
3449
3510
|
memo.content,
|
|
3450
3511
|
memo.nextPhase,
|
|
3451
3512
|
memo.status,
|
|
3513
|
+
memo.senderAddress,
|
|
3452
3514
|
memo.signedReason,
|
|
3453
3515
|
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
3454
3516
|
memo.payableDetails
|
|
@@ -3486,6 +3548,7 @@ var AcpClient = class {
|
|
|
3486
3548
|
memo.content,
|
|
3487
3549
|
memo.nextPhase,
|
|
3488
3550
|
memo.status,
|
|
3551
|
+
memo.senderAddress,
|
|
3489
3552
|
memo.signedReason,
|
|
3490
3553
|
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
3491
3554
|
memo.payableDetails
|