@virtuals-protocol/acp-node 0.3.0-beta.14 → 0.3.0-beta.15
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/dist/index.d.mts +13 -12
- package/dist/index.d.ts +13 -12
- package/dist/index.js +26 -8
- package/dist/index.mjs +26 -8
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -343,6 +343,7 @@ interface IAcpClientOptions {
|
|
|
343
343
|
onNewTask?: (job: AcpJob, memoToSign?: AcpMemo) => void;
|
|
344
344
|
onEvaluate?: (job: AcpJob) => void;
|
|
345
345
|
customRpcUrl?: string;
|
|
346
|
+
skipSocketConnection?: boolean;
|
|
346
347
|
}
|
|
347
348
|
type AcpAgent = {
|
|
348
349
|
id: number;
|
|
@@ -605,6 +606,10 @@ declare abstract class BaseAcpContractClient {
|
|
|
605
606
|
abstract getAcpVersion(): string;
|
|
606
607
|
}
|
|
607
608
|
|
|
609
|
+
declare class AcpError extends Error {
|
|
610
|
+
constructor(message: string, originalError?: unknown);
|
|
611
|
+
}
|
|
612
|
+
|
|
608
613
|
interface IAcpBrowseAgentsOptions {
|
|
609
614
|
cluster?: string;
|
|
610
615
|
sort_by?: AcpAgentSort[];
|
|
@@ -621,8 +626,8 @@ declare class AcpClient {
|
|
|
621
626
|
get acpContractClient(): BaseAcpContractClient;
|
|
622
627
|
get acpUrl(): string;
|
|
623
628
|
private defaultOnEvaluate;
|
|
624
|
-
get walletAddress():
|
|
625
|
-
init(): Promise<void>;
|
|
629
|
+
get walletAddress(): `0x${string}`;
|
|
630
|
+
init(skipSocketConnection?: boolean): Promise<void>;
|
|
626
631
|
browseAgents(keyword: string, options: IAcpBrowseAgentsOptions): Promise<{
|
|
627
632
|
id: number;
|
|
628
633
|
name: string;
|
|
@@ -647,12 +652,12 @@ declare class AcpClient {
|
|
|
647
652
|
}[];
|
|
648
653
|
}[]>;
|
|
649
654
|
initiateJob(providerAddress: Address, serviceRequirement: Object | string, fareAmount: FareAmountBase, evaluatorAddress?: Address, expiredAt?: Date): Promise<number>;
|
|
650
|
-
getActiveJobs(page?: number, pageSize?: number): Promise<AcpJob[]>;
|
|
651
|
-
getPendingMemoJobs(page?: number, pageSize?: number): Promise<AcpJob[]>;
|
|
652
|
-
getCompletedJobs(page?: number, pageSize?: number): Promise<AcpJob[]>;
|
|
653
|
-
getCancelledJobs(page?: number, pageSize?: number): Promise<AcpJob[]>;
|
|
654
|
-
getJobById(jobId: number): Promise<AcpJob | undefined>;
|
|
655
|
-
getMemoById(jobId: number, memoId: number): Promise<AcpMemo | undefined>;
|
|
655
|
+
getActiveJobs(page?: number, pageSize?: number): Promise<AcpError | AcpJob[]>;
|
|
656
|
+
getPendingMemoJobs(page?: number, pageSize?: number): Promise<AcpError | AcpJob[]>;
|
|
657
|
+
getCompletedJobs(page?: number, pageSize?: number): Promise<AcpError | AcpJob[]>;
|
|
658
|
+
getCancelledJobs(page?: number, pageSize?: number): Promise<Error | AcpJob[]>;
|
|
659
|
+
getJobById(jobId: number): Promise<AcpError | AcpJob | undefined>;
|
|
660
|
+
getMemoById(jobId: number, memoId: number): Promise<AcpError | AcpMemo | undefined>;
|
|
656
661
|
getAgent(walletAddress: Address): Promise<AcpAgent | undefined>;
|
|
657
662
|
getAccountByJobId(jobId: number, acpContractClient?: BaseAcpContractClient): Promise<AcpAccount | null>;
|
|
658
663
|
getByClientAndProvider(clientAddress: Address, providerAddress: Address, acpContractClient?: BaseAcpContractClient): Promise<AcpAccount | null>;
|
|
@@ -8949,10 +8954,6 @@ declare class AcpContractClient extends BaseAcpContractClient {
|
|
|
8949
8954
|
|
|
8950
8955
|
declare function preparePayload(payload: string | object): string;
|
|
8951
8956
|
|
|
8952
|
-
declare class AcpError extends Error {
|
|
8953
|
-
constructor(message: string, originalError?: unknown);
|
|
8954
|
-
}
|
|
8955
|
-
|
|
8956
8957
|
declare class AcpContractClientV2 extends BaseAcpContractClient {
|
|
8957
8958
|
private jobManagerAddress;
|
|
8958
8959
|
private memoManagerAddress;
|
package/dist/index.d.ts
CHANGED
|
@@ -343,6 +343,7 @@ interface IAcpClientOptions {
|
|
|
343
343
|
onNewTask?: (job: AcpJob, memoToSign?: AcpMemo) => void;
|
|
344
344
|
onEvaluate?: (job: AcpJob) => void;
|
|
345
345
|
customRpcUrl?: string;
|
|
346
|
+
skipSocketConnection?: boolean;
|
|
346
347
|
}
|
|
347
348
|
type AcpAgent = {
|
|
348
349
|
id: number;
|
|
@@ -605,6 +606,10 @@ declare abstract class BaseAcpContractClient {
|
|
|
605
606
|
abstract getAcpVersion(): string;
|
|
606
607
|
}
|
|
607
608
|
|
|
609
|
+
declare class AcpError extends Error {
|
|
610
|
+
constructor(message: string, originalError?: unknown);
|
|
611
|
+
}
|
|
612
|
+
|
|
608
613
|
interface IAcpBrowseAgentsOptions {
|
|
609
614
|
cluster?: string;
|
|
610
615
|
sort_by?: AcpAgentSort[];
|
|
@@ -621,8 +626,8 @@ declare class AcpClient {
|
|
|
621
626
|
get acpContractClient(): BaseAcpContractClient;
|
|
622
627
|
get acpUrl(): string;
|
|
623
628
|
private defaultOnEvaluate;
|
|
624
|
-
get walletAddress():
|
|
625
|
-
init(): Promise<void>;
|
|
629
|
+
get walletAddress(): `0x${string}`;
|
|
630
|
+
init(skipSocketConnection?: boolean): Promise<void>;
|
|
626
631
|
browseAgents(keyword: string, options: IAcpBrowseAgentsOptions): Promise<{
|
|
627
632
|
id: number;
|
|
628
633
|
name: string;
|
|
@@ -647,12 +652,12 @@ declare class AcpClient {
|
|
|
647
652
|
}[];
|
|
648
653
|
}[]>;
|
|
649
654
|
initiateJob(providerAddress: Address, serviceRequirement: Object | string, fareAmount: FareAmountBase, evaluatorAddress?: Address, expiredAt?: Date): Promise<number>;
|
|
650
|
-
getActiveJobs(page?: number, pageSize?: number): Promise<AcpJob[]>;
|
|
651
|
-
getPendingMemoJobs(page?: number, pageSize?: number): Promise<AcpJob[]>;
|
|
652
|
-
getCompletedJobs(page?: number, pageSize?: number): Promise<AcpJob[]>;
|
|
653
|
-
getCancelledJobs(page?: number, pageSize?: number): Promise<AcpJob[]>;
|
|
654
|
-
getJobById(jobId: number): Promise<AcpJob | undefined>;
|
|
655
|
-
getMemoById(jobId: number, memoId: number): Promise<AcpMemo | undefined>;
|
|
655
|
+
getActiveJobs(page?: number, pageSize?: number): Promise<AcpError | AcpJob[]>;
|
|
656
|
+
getPendingMemoJobs(page?: number, pageSize?: number): Promise<AcpError | AcpJob[]>;
|
|
657
|
+
getCompletedJobs(page?: number, pageSize?: number): Promise<AcpError | AcpJob[]>;
|
|
658
|
+
getCancelledJobs(page?: number, pageSize?: number): Promise<Error | AcpJob[]>;
|
|
659
|
+
getJobById(jobId: number): Promise<AcpError | AcpJob | undefined>;
|
|
660
|
+
getMemoById(jobId: number, memoId: number): Promise<AcpError | AcpMemo | undefined>;
|
|
656
661
|
getAgent(walletAddress: Address): Promise<AcpAgent | undefined>;
|
|
657
662
|
getAccountByJobId(jobId: number, acpContractClient?: BaseAcpContractClient): Promise<AcpAccount | null>;
|
|
658
663
|
getByClientAndProvider(clientAddress: Address, providerAddress: Address, acpContractClient?: BaseAcpContractClient): Promise<AcpAccount | null>;
|
|
@@ -8949,10 +8954,6 @@ declare class AcpContractClient extends BaseAcpContractClient {
|
|
|
8949
8954
|
|
|
8950
8955
|
declare function preparePayload(payload: string | object): string;
|
|
8951
8956
|
|
|
8952
|
-
declare class AcpError extends Error {
|
|
8953
|
-
constructor(message: string, originalError?: unknown);
|
|
8954
|
-
}
|
|
8955
|
-
|
|
8956
8957
|
declare class AcpContractClientV2 extends BaseAcpContractClient {
|
|
8957
8958
|
private jobManagerAddress;
|
|
8958
8959
|
private memoManagerAddress;
|
package/dist/index.js
CHANGED
|
@@ -35,7 +35,7 @@ var require_package = __commonJS({
|
|
|
35
35
|
"package.json"(exports2, module2) {
|
|
36
36
|
module2.exports = {
|
|
37
37
|
name: "@virtuals-protocol/acp-node",
|
|
38
|
-
version: "0.3.0-beta.
|
|
38
|
+
version: "0.3.0-beta.15",
|
|
39
39
|
main: "./dist/index.js",
|
|
40
40
|
module: "./dist/index.mjs",
|
|
41
41
|
types: "./dist/index.d.ts",
|
|
@@ -4420,8 +4420,8 @@ var AcpClient = class {
|
|
|
4420
4420
|
if (this.contractClients.length === 0) {
|
|
4421
4421
|
throw new acpError_default("ACP contract client is required");
|
|
4422
4422
|
}
|
|
4423
|
-
this.contractClients.
|
|
4424
|
-
if (client.
|
|
4423
|
+
this.contractClients.forEach((client) => {
|
|
4424
|
+
if (client.walletAddress !== this.contractClients[0].walletAddress) {
|
|
4425
4425
|
throw new acpError_default(
|
|
4426
4426
|
"All contract clients must have the same agent wallet address"
|
|
4427
4427
|
);
|
|
@@ -4429,7 +4429,7 @@ var AcpClient = class {
|
|
|
4429
4429
|
});
|
|
4430
4430
|
this.onNewTask = options.onNewTask;
|
|
4431
4431
|
this.onEvaluate = options.onEvaluate || this.defaultOnEvaluate;
|
|
4432
|
-
this.init();
|
|
4432
|
+
this.init(options.skipSocketConnection);
|
|
4433
4433
|
}
|
|
4434
4434
|
contractClientByAddress(address) {
|
|
4435
4435
|
if (!address) {
|
|
@@ -4453,12 +4453,12 @@ var AcpClient = class {
|
|
|
4453
4453
|
await job.evaluate(true, "Evaluated by default");
|
|
4454
4454
|
}
|
|
4455
4455
|
get walletAddress() {
|
|
4456
|
-
if (Array.isArray(this.acpContractClient)) {
|
|
4457
|
-
return this.acpContractClient[0].walletAddress;
|
|
4458
|
-
}
|
|
4459
4456
|
return this.acpContractClient.walletAddress;
|
|
4460
4457
|
}
|
|
4461
|
-
async init() {
|
|
4458
|
+
async init(skipSocketConnection = false) {
|
|
4459
|
+
if (skipSocketConnection) {
|
|
4460
|
+
return;
|
|
4461
|
+
}
|
|
4462
4462
|
const socket = (0, import_socket.io)(this.acpUrl, {
|
|
4463
4463
|
auth: {
|
|
4464
4464
|
walletAddress: this.walletAddress
|
|
@@ -4736,6 +4736,9 @@ var AcpClient = class {
|
|
|
4736
4736
|
);
|
|
4737
4737
|
});
|
|
4738
4738
|
} catch (error) {
|
|
4739
|
+
if (error instanceof acpError_default) {
|
|
4740
|
+
return error;
|
|
4741
|
+
}
|
|
4739
4742
|
throw new acpError_default("Failed to get active jobs", error);
|
|
4740
4743
|
}
|
|
4741
4744
|
}
|
|
@@ -4783,6 +4786,9 @@ var AcpClient = class {
|
|
|
4783
4786
|
);
|
|
4784
4787
|
});
|
|
4785
4788
|
} catch (error) {
|
|
4789
|
+
if (error instanceof acpError_default) {
|
|
4790
|
+
return error;
|
|
4791
|
+
}
|
|
4786
4792
|
throw new acpError_default("Failed to get pending memo jobs", error);
|
|
4787
4793
|
}
|
|
4788
4794
|
}
|
|
@@ -4830,6 +4836,9 @@ var AcpClient = class {
|
|
|
4830
4836
|
);
|
|
4831
4837
|
});
|
|
4832
4838
|
} catch (error) {
|
|
4839
|
+
if (error instanceof acpError_default) {
|
|
4840
|
+
return error;
|
|
4841
|
+
}
|
|
4833
4842
|
throw new acpError_default("Failed to get completed jobs", error);
|
|
4834
4843
|
}
|
|
4835
4844
|
}
|
|
@@ -4877,6 +4886,9 @@ var AcpClient = class {
|
|
|
4877
4886
|
);
|
|
4878
4887
|
});
|
|
4879
4888
|
} catch (error) {
|
|
4889
|
+
if (error instanceof Error) {
|
|
4890
|
+
return error;
|
|
4891
|
+
}
|
|
4880
4892
|
throw new acpError_default("Failed to get cancelled jobs", error);
|
|
4881
4893
|
}
|
|
4882
4894
|
}
|
|
@@ -4926,6 +4938,9 @@ var AcpClient = class {
|
|
|
4926
4938
|
job.netPayableAmount
|
|
4927
4939
|
);
|
|
4928
4940
|
} catch (error) {
|
|
4941
|
+
if (error instanceof acpError_default) {
|
|
4942
|
+
return error;
|
|
4943
|
+
}
|
|
4929
4944
|
throw new acpError_default("Failed to get job by id", error);
|
|
4930
4945
|
}
|
|
4931
4946
|
}
|
|
@@ -4960,6 +4975,9 @@ var AcpClient = class {
|
|
|
4960
4975
|
memo.signedTxHash
|
|
4961
4976
|
);
|
|
4962
4977
|
} catch (error) {
|
|
4978
|
+
if (error instanceof acpError_default) {
|
|
4979
|
+
return error;
|
|
4980
|
+
}
|
|
4963
4981
|
throw new acpError_default("Failed to get memo by id", error);
|
|
4964
4982
|
}
|
|
4965
4983
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -8,7 +8,7 @@ var require_package = __commonJS({
|
|
|
8
8
|
"package.json"(exports, module) {
|
|
9
9
|
module.exports = {
|
|
10
10
|
name: "@virtuals-protocol/acp-node",
|
|
11
|
-
version: "0.3.0-beta.
|
|
11
|
+
version: "0.3.0-beta.15",
|
|
12
12
|
main: "./dist/index.js",
|
|
13
13
|
module: "./dist/index.mjs",
|
|
14
14
|
types: "./dist/index.d.ts",
|
|
@@ -4373,8 +4373,8 @@ var AcpClient = class {
|
|
|
4373
4373
|
if (this.contractClients.length === 0) {
|
|
4374
4374
|
throw new acpError_default("ACP contract client is required");
|
|
4375
4375
|
}
|
|
4376
|
-
this.contractClients.
|
|
4377
|
-
if (client.
|
|
4376
|
+
this.contractClients.forEach((client) => {
|
|
4377
|
+
if (client.walletAddress !== this.contractClients[0].walletAddress) {
|
|
4378
4378
|
throw new acpError_default(
|
|
4379
4379
|
"All contract clients must have the same agent wallet address"
|
|
4380
4380
|
);
|
|
@@ -4382,7 +4382,7 @@ var AcpClient = class {
|
|
|
4382
4382
|
});
|
|
4383
4383
|
this.onNewTask = options.onNewTask;
|
|
4384
4384
|
this.onEvaluate = options.onEvaluate || this.defaultOnEvaluate;
|
|
4385
|
-
this.init();
|
|
4385
|
+
this.init(options.skipSocketConnection);
|
|
4386
4386
|
}
|
|
4387
4387
|
contractClientByAddress(address) {
|
|
4388
4388
|
if (!address) {
|
|
@@ -4406,12 +4406,12 @@ var AcpClient = class {
|
|
|
4406
4406
|
await job.evaluate(true, "Evaluated by default");
|
|
4407
4407
|
}
|
|
4408
4408
|
get walletAddress() {
|
|
4409
|
-
if (Array.isArray(this.acpContractClient)) {
|
|
4410
|
-
return this.acpContractClient[0].walletAddress;
|
|
4411
|
-
}
|
|
4412
4409
|
return this.acpContractClient.walletAddress;
|
|
4413
4410
|
}
|
|
4414
|
-
async init() {
|
|
4411
|
+
async init(skipSocketConnection = false) {
|
|
4412
|
+
if (skipSocketConnection) {
|
|
4413
|
+
return;
|
|
4414
|
+
}
|
|
4415
4415
|
const socket = io(this.acpUrl, {
|
|
4416
4416
|
auth: {
|
|
4417
4417
|
walletAddress: this.walletAddress
|
|
@@ -4689,6 +4689,9 @@ var AcpClient = class {
|
|
|
4689
4689
|
);
|
|
4690
4690
|
});
|
|
4691
4691
|
} catch (error) {
|
|
4692
|
+
if (error instanceof acpError_default) {
|
|
4693
|
+
return error;
|
|
4694
|
+
}
|
|
4692
4695
|
throw new acpError_default("Failed to get active jobs", error);
|
|
4693
4696
|
}
|
|
4694
4697
|
}
|
|
@@ -4736,6 +4739,9 @@ var AcpClient = class {
|
|
|
4736
4739
|
);
|
|
4737
4740
|
});
|
|
4738
4741
|
} catch (error) {
|
|
4742
|
+
if (error instanceof acpError_default) {
|
|
4743
|
+
return error;
|
|
4744
|
+
}
|
|
4739
4745
|
throw new acpError_default("Failed to get pending memo jobs", error);
|
|
4740
4746
|
}
|
|
4741
4747
|
}
|
|
@@ -4783,6 +4789,9 @@ var AcpClient = class {
|
|
|
4783
4789
|
);
|
|
4784
4790
|
});
|
|
4785
4791
|
} catch (error) {
|
|
4792
|
+
if (error instanceof acpError_default) {
|
|
4793
|
+
return error;
|
|
4794
|
+
}
|
|
4786
4795
|
throw new acpError_default("Failed to get completed jobs", error);
|
|
4787
4796
|
}
|
|
4788
4797
|
}
|
|
@@ -4830,6 +4839,9 @@ var AcpClient = class {
|
|
|
4830
4839
|
);
|
|
4831
4840
|
});
|
|
4832
4841
|
} catch (error) {
|
|
4842
|
+
if (error instanceof Error) {
|
|
4843
|
+
return error;
|
|
4844
|
+
}
|
|
4833
4845
|
throw new acpError_default("Failed to get cancelled jobs", error);
|
|
4834
4846
|
}
|
|
4835
4847
|
}
|
|
@@ -4879,6 +4891,9 @@ var AcpClient = class {
|
|
|
4879
4891
|
job.netPayableAmount
|
|
4880
4892
|
);
|
|
4881
4893
|
} catch (error) {
|
|
4894
|
+
if (error instanceof acpError_default) {
|
|
4895
|
+
return error;
|
|
4896
|
+
}
|
|
4882
4897
|
throw new acpError_default("Failed to get job by id", error);
|
|
4883
4898
|
}
|
|
4884
4899
|
}
|
|
@@ -4913,6 +4928,9 @@ var AcpClient = class {
|
|
|
4913
4928
|
memo.signedTxHash
|
|
4914
4929
|
);
|
|
4915
4930
|
} catch (error) {
|
|
4931
|
+
if (error instanceof acpError_default) {
|
|
4932
|
+
return error;
|
|
4933
|
+
}
|
|
4916
4934
|
throw new acpError_default("Failed to get memo by id", error);
|
|
4917
4935
|
}
|
|
4918
4936
|
}
|