@virtuals-protocol/acp-node 0.3.0-beta.15 → 0.3.0-beta.17
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 +53 -46
- package/dist/index.d.mts +44 -11
- package/dist/index.d.ts +44 -11
- package/dist/index.js +189 -237
- package/dist/index.mjs +189 -237
- package/package.json +1 -1
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.17",
|
|
12
12
|
main: "./dist/index.js",
|
|
13
13
|
module: "./dist/index.mjs",
|
|
14
14
|
types: "./dist/index.d.ts",
|
|
@@ -3927,6 +3927,7 @@ var AcpJobOffering = class {
|
|
|
3927
3927
|
var acpJobOffering_default = AcpJobOffering;
|
|
3928
3928
|
|
|
3929
3929
|
// src/acpJob.ts
|
|
3930
|
+
import * as util from "util";
|
|
3930
3931
|
var AcpJob = class {
|
|
3931
3932
|
constructor(acpClient, id, clientAddress, providerAddress, evaluatorAddress, price, priceTokenAddress, memos, phase, context, contractAddress, netPayableAmount) {
|
|
3932
3933
|
this.acpClient = acpClient;
|
|
@@ -4082,9 +4083,11 @@ var AcpJob = class {
|
|
|
4082
4083
|
3 /* EVALUATION */
|
|
4083
4084
|
)
|
|
4084
4085
|
);
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4086
|
+
if (this.price > 0) {
|
|
4087
|
+
const x402PaymentDetails = await this.acpContractClient.getX402PaymentDetails(this.id);
|
|
4088
|
+
if (x402PaymentDetails.isX402) {
|
|
4089
|
+
await this.performX402Payment(this.price);
|
|
4090
|
+
}
|
|
4088
4091
|
}
|
|
4089
4092
|
return await this.acpContractClient.handleOperation(operations);
|
|
4090
4093
|
}
|
|
@@ -4301,10 +4304,28 @@ var AcpJob = class {
|
|
|
4301
4304
|
waitMs = Math.min(waitMs * 2, maxWaitMs);
|
|
4302
4305
|
}
|
|
4303
4306
|
}
|
|
4307
|
+
[util.inspect.custom]() {
|
|
4308
|
+
return {
|
|
4309
|
+
id: this.id,
|
|
4310
|
+
clientAddress: this.clientAddress,
|
|
4311
|
+
providerAddress: this.providerAddress,
|
|
4312
|
+
name: this.name,
|
|
4313
|
+
requirement: this.requirement,
|
|
4314
|
+
priceType: this.priceType,
|
|
4315
|
+
priceValue: this.priceValue,
|
|
4316
|
+
priceTokenAddress: this.priceTokenAddress,
|
|
4317
|
+
memos: this.memos,
|
|
4318
|
+
phase: this.phase,
|
|
4319
|
+
context: this.context,
|
|
4320
|
+
contractAddress: this.contractAddress,
|
|
4321
|
+
netPayableAmount: this.netPayableAmount
|
|
4322
|
+
};
|
|
4323
|
+
}
|
|
4304
4324
|
};
|
|
4305
4325
|
var acpJob_default = AcpJob;
|
|
4306
4326
|
|
|
4307
4327
|
// src/acpMemo.ts
|
|
4328
|
+
import util2 from "util";
|
|
4308
4329
|
var AcpMemo = class {
|
|
4309
4330
|
constructor(contractClient, id, type, content, nextPhase, status, senderAddress, signedReason, expiry, payableDetails, txHash, signedTxHash) {
|
|
4310
4331
|
this.contractClient = contractClient;
|
|
@@ -4344,6 +4365,21 @@ var AcpMemo = class {
|
|
|
4344
4365
|
const payload = this.contractClient.signMemo(this.id, approved, reason);
|
|
4345
4366
|
return await this.contractClient.handleOperation([payload]);
|
|
4346
4367
|
}
|
|
4368
|
+
[util2.inspect.custom]() {
|
|
4369
|
+
return {
|
|
4370
|
+
id: this.id,
|
|
4371
|
+
senderAddress: this.senderAddress,
|
|
4372
|
+
type: MemoType[this.type],
|
|
4373
|
+
status: this.status,
|
|
4374
|
+
content: this.content,
|
|
4375
|
+
signedReason: this.signedReason,
|
|
4376
|
+
txHash: this.txHash,
|
|
4377
|
+
signedTxHash: this.signedTxHash,
|
|
4378
|
+
nextPhase: AcpJobPhases[this.nextPhase],
|
|
4379
|
+
expiry: this.expiry,
|
|
4380
|
+
payableDetails: this.payableDetails
|
|
4381
|
+
};
|
|
4382
|
+
}
|
|
4347
4383
|
};
|
|
4348
4384
|
var acpMemo_default = AcpMemo;
|
|
4349
4385
|
|
|
@@ -4517,7 +4553,7 @@ var AcpClient = class {
|
|
|
4517
4553
|
process.on("SIGTERM", cleanup);
|
|
4518
4554
|
}
|
|
4519
4555
|
async browseAgents(keyword, options) {
|
|
4520
|
-
let { cluster, sort_by, top_k, graduationStatus, onlineStatus } = options;
|
|
4556
|
+
let { cluster, sort_by, top_k, graduationStatus, onlineStatus, showHiddenOfferings } = options;
|
|
4521
4557
|
top_k = top_k ?? 5;
|
|
4522
4558
|
let url = `${this.acpUrl}/api/agents/v4/search?search=${keyword}`;
|
|
4523
4559
|
if (sort_by && sort_by.length > 0) {
|
|
@@ -4538,6 +4574,9 @@ var AcpClient = class {
|
|
|
4538
4574
|
if (onlineStatus) {
|
|
4539
4575
|
url += `&onlineStatus=${onlineStatus}`;
|
|
4540
4576
|
}
|
|
4577
|
+
if (showHiddenOfferings) {
|
|
4578
|
+
url += `&showHiddenOfferings=${showHiddenOfferings}`;
|
|
4579
|
+
}
|
|
4541
4580
|
const response = await fetch(url);
|
|
4542
4581
|
const data = await response.json();
|
|
4543
4582
|
const availableContractClientAddresses = this.contractClients.map(
|
|
@@ -4575,7 +4614,7 @@ var AcpClient = class {
|
|
|
4575
4614
|
twitterHandle: agent.twitterHandle,
|
|
4576
4615
|
walletAddress: agent.walletAddress,
|
|
4577
4616
|
metrics: agent.metrics,
|
|
4578
|
-
|
|
4617
|
+
resources: agent.resources
|
|
4579
4618
|
};
|
|
4580
4619
|
});
|
|
4581
4620
|
}
|
|
@@ -4646,221 +4685,142 @@ var AcpClient = class {
|
|
|
4646
4685
|
return jobId;
|
|
4647
4686
|
}
|
|
4648
4687
|
async getActiveJobs(page = 1, pageSize = 10) {
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
headers: {
|
|
4653
|
-
"wallet-address": this.walletAddress
|
|
4654
|
-
}
|
|
4655
|
-
});
|
|
4656
|
-
const data = await response.json();
|
|
4657
|
-
if (data.error) {
|
|
4658
|
-
throw new acpError_default(data.error.message);
|
|
4659
|
-
}
|
|
4660
|
-
return data.data.map((job) => {
|
|
4661
|
-
return new acpJob_default(
|
|
4662
|
-
this,
|
|
4663
|
-
job.id,
|
|
4664
|
-
job.clientAddress,
|
|
4665
|
-
job.providerAddress,
|
|
4666
|
-
job.evaluatorAddress,
|
|
4667
|
-
job.price,
|
|
4668
|
-
job.priceTokenAddress,
|
|
4669
|
-
job.memos.map((memo) => {
|
|
4670
|
-
return new acpMemo_default(
|
|
4671
|
-
this.contractClientByAddress(job.contractAddress),
|
|
4672
|
-
memo.id,
|
|
4673
|
-
memo.memoType,
|
|
4674
|
-
memo.content,
|
|
4675
|
-
memo.nextPhase,
|
|
4676
|
-
memo.status,
|
|
4677
|
-
memo.senderAddress,
|
|
4678
|
-
memo.signedReason,
|
|
4679
|
-
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
4680
|
-
memo.payableDetails,
|
|
4681
|
-
memo.txHash,
|
|
4682
|
-
memo.signedTxHash
|
|
4683
|
-
);
|
|
4684
|
-
}),
|
|
4685
|
-
job.phase,
|
|
4686
|
-
job.context,
|
|
4687
|
-
job.contractAddress,
|
|
4688
|
-
job.netPayableAmount
|
|
4689
|
-
);
|
|
4690
|
-
});
|
|
4691
|
-
} catch (error) {
|
|
4692
|
-
if (error instanceof acpError_default) {
|
|
4693
|
-
return error;
|
|
4694
|
-
}
|
|
4695
|
-
throw new acpError_default("Failed to get active jobs", error);
|
|
4696
|
-
}
|
|
4688
|
+
const url = `${this.acpUrl}/api/jobs/active?pagination[page]=${page}&pagination[pageSize]=${pageSize}`;
|
|
4689
|
+
const rawJobs = await this._fetchJobList(url);
|
|
4690
|
+
return this._hydrateJobs(rawJobs, { logPrefix: "Active jobs" });
|
|
4697
4691
|
}
|
|
4698
4692
|
async getPendingMemoJobs(page = 1, pageSize = 10) {
|
|
4699
|
-
|
|
4700
|
-
|
|
4701
|
-
|
|
4702
|
-
headers: {
|
|
4703
|
-
"wallet-address": this.acpContractClient.walletAddress
|
|
4704
|
-
}
|
|
4705
|
-
});
|
|
4706
|
-
const data = await response.json();
|
|
4707
|
-
if (data.error) {
|
|
4708
|
-
throw new acpError_default(data.error.message);
|
|
4709
|
-
}
|
|
4710
|
-
return data.data.map((job) => {
|
|
4711
|
-
return new acpJob_default(
|
|
4712
|
-
this,
|
|
4713
|
-
job.id,
|
|
4714
|
-
job.clientAddress,
|
|
4715
|
-
job.providerAddress,
|
|
4716
|
-
job.evaluatorAddress,
|
|
4717
|
-
job.price,
|
|
4718
|
-
job.priceTokenAddress,
|
|
4719
|
-
job.memos.map((memo) => {
|
|
4720
|
-
return new acpMemo_default(
|
|
4721
|
-
this.contractClientByAddress(job.contractAddress),
|
|
4722
|
-
memo.id,
|
|
4723
|
-
memo.memoType,
|
|
4724
|
-
memo.content,
|
|
4725
|
-
memo.nextPhase,
|
|
4726
|
-
memo.status,
|
|
4727
|
-
memo.senderAddress,
|
|
4728
|
-
memo.signedReason,
|
|
4729
|
-
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
4730
|
-
typeof memo.payableDetails === "string" ? tryParseJson(memo.payableDetails) || void 0 : memo.payableDetails,
|
|
4731
|
-
memo.txHash,
|
|
4732
|
-
memo.signedTxHash
|
|
4733
|
-
);
|
|
4734
|
-
}),
|
|
4735
|
-
job.phase,
|
|
4736
|
-
job.context,
|
|
4737
|
-
job.contractAddress,
|
|
4738
|
-
job.netPayableAmount
|
|
4739
|
-
);
|
|
4740
|
-
});
|
|
4741
|
-
} catch (error) {
|
|
4742
|
-
if (error instanceof acpError_default) {
|
|
4743
|
-
return error;
|
|
4744
|
-
}
|
|
4745
|
-
throw new acpError_default("Failed to get pending memo jobs", error);
|
|
4746
|
-
}
|
|
4693
|
+
const url = `${this.acpUrl}/api/jobs/pending-memos?pagination[page]=${page}&pagination[pageSize]=${pageSize}`;
|
|
4694
|
+
const rawJobs = await this._fetchJobList(url);
|
|
4695
|
+
return this._hydrateJobs(rawJobs, { logPrefix: "Pending memo jobs" });
|
|
4747
4696
|
}
|
|
4748
4697
|
async getCompletedJobs(page = 1, pageSize = 10) {
|
|
4749
|
-
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
headers: {
|
|
4753
|
-
"wallet-address": this.acpContractClient.walletAddress
|
|
4754
|
-
}
|
|
4755
|
-
});
|
|
4756
|
-
const data = await response.json();
|
|
4757
|
-
if (data.error) {
|
|
4758
|
-
throw new acpError_default(data.error.message);
|
|
4759
|
-
}
|
|
4760
|
-
return data.data.map((job) => {
|
|
4761
|
-
return new acpJob_default(
|
|
4762
|
-
this,
|
|
4763
|
-
job.id,
|
|
4764
|
-
job.clientAddress,
|
|
4765
|
-
job.providerAddress,
|
|
4766
|
-
job.evaluatorAddress,
|
|
4767
|
-
job.price,
|
|
4768
|
-
job.priceTokenAddress,
|
|
4769
|
-
job.memos.map((memo) => {
|
|
4770
|
-
return new acpMemo_default(
|
|
4771
|
-
this.contractClientByAddress(job.contractAddress),
|
|
4772
|
-
memo.id,
|
|
4773
|
-
memo.memoType,
|
|
4774
|
-
memo.content,
|
|
4775
|
-
memo.nextPhase,
|
|
4776
|
-
memo.status,
|
|
4777
|
-
memo.senderAddress,
|
|
4778
|
-
memo.signedReason,
|
|
4779
|
-
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
4780
|
-
memo.payableDetails,
|
|
4781
|
-
memo.txHash,
|
|
4782
|
-
memo.signedTxHash
|
|
4783
|
-
);
|
|
4784
|
-
}),
|
|
4785
|
-
job.phase,
|
|
4786
|
-
job.context,
|
|
4787
|
-
job.contractAddress,
|
|
4788
|
-
job.netPayableAmount
|
|
4789
|
-
);
|
|
4790
|
-
});
|
|
4791
|
-
} catch (error) {
|
|
4792
|
-
if (error instanceof acpError_default) {
|
|
4793
|
-
return error;
|
|
4794
|
-
}
|
|
4795
|
-
throw new acpError_default("Failed to get completed jobs", error);
|
|
4796
|
-
}
|
|
4698
|
+
const url = `${this.acpUrl}/api/jobs/completed?pagination[page]=${page}&pagination[pageSize]=${pageSize}`;
|
|
4699
|
+
const rawJobs = await this._fetchJobList(url);
|
|
4700
|
+
return this._hydrateJobs(rawJobs, { logPrefix: "Completed jobs" });
|
|
4797
4701
|
}
|
|
4798
4702
|
async getCancelledJobs(page = 1, pageSize = 10) {
|
|
4799
|
-
|
|
4703
|
+
const url = `${this.acpUrl}/api/jobs/cancelled?pagination[page]=${page}&pagination[pageSize]=${pageSize}`;
|
|
4704
|
+
const rawJobs = await this._fetchJobList(url);
|
|
4705
|
+
return this._hydrateJobs(rawJobs, { logPrefix: "Cancelled jobs" });
|
|
4706
|
+
}
|
|
4707
|
+
async _fetchJobList(url) {
|
|
4708
|
+
let response;
|
|
4800
4709
|
try {
|
|
4801
|
-
|
|
4710
|
+
response = await fetch(url, {
|
|
4802
4711
|
headers: {
|
|
4803
4712
|
"wallet-address": this.walletAddress
|
|
4804
4713
|
}
|
|
4805
4714
|
});
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
4832
|
-
|
|
4833
|
-
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4715
|
+
} catch (err) {
|
|
4716
|
+
throw new acpError_default("Failed to fetch ACP jobs (network error)", err);
|
|
4717
|
+
}
|
|
4718
|
+
let data;
|
|
4719
|
+
try {
|
|
4720
|
+
data = await response.json();
|
|
4721
|
+
} catch (err) {
|
|
4722
|
+
throw new acpError_default("Failed to parse ACP jobs response", err);
|
|
4723
|
+
}
|
|
4724
|
+
if (data.error) {
|
|
4725
|
+
throw new acpError_default(data.error.message);
|
|
4726
|
+
}
|
|
4727
|
+
return data.data;
|
|
4728
|
+
}
|
|
4729
|
+
_hydrateJobs(rawJobs, options) {
|
|
4730
|
+
const jobs = [];
|
|
4731
|
+
const errors = [];
|
|
4732
|
+
for (const job of rawJobs) {
|
|
4733
|
+
try {
|
|
4734
|
+
const memos = job.memos.map(
|
|
4735
|
+
(memo) => new acpMemo_default(
|
|
4736
|
+
this.contractClientByAddress(job.contractAddress),
|
|
4737
|
+
memo.id,
|
|
4738
|
+
memo.memoType,
|
|
4739
|
+
memo.content,
|
|
4740
|
+
memo.nextPhase,
|
|
4741
|
+
memo.status,
|
|
4742
|
+
memo.senderAddress,
|
|
4743
|
+
memo.signedReason,
|
|
4744
|
+
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
4745
|
+
memo.payableDetails,
|
|
4746
|
+
memo.txHash,
|
|
4747
|
+
memo.signedTxHash
|
|
4748
|
+
)
|
|
4839
4749
|
);
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4750
|
+
jobs.push(
|
|
4751
|
+
new acpJob_default(
|
|
4752
|
+
this,
|
|
4753
|
+
job.id,
|
|
4754
|
+
job.clientAddress,
|
|
4755
|
+
job.providerAddress,
|
|
4756
|
+
job.evaluatorAddress,
|
|
4757
|
+
job.price,
|
|
4758
|
+
job.priceTokenAddress,
|
|
4759
|
+
memos,
|
|
4760
|
+
job.phase,
|
|
4761
|
+
job.context,
|
|
4762
|
+
job.contractAddress,
|
|
4763
|
+
job.netPayableAmount
|
|
4764
|
+
)
|
|
4765
|
+
);
|
|
4766
|
+
} catch (err) {
|
|
4767
|
+
errors.push({ jobId: job.id, error: err });
|
|
4844
4768
|
}
|
|
4845
|
-
throw new acpError_default("Failed to get cancelled jobs", error);
|
|
4846
4769
|
}
|
|
4770
|
+
if (errors.length > 0) {
|
|
4771
|
+
console.warn(
|
|
4772
|
+
`${options?.logPrefix ?? "Skipped"} ${errors.length} malformed job(s)
|
|
4773
|
+
` + JSON.stringify(
|
|
4774
|
+
errors.map((e) => ({ jobId: e.jobId, message: e.error.message })),
|
|
4775
|
+
null,
|
|
4776
|
+
2
|
|
4777
|
+
)
|
|
4778
|
+
);
|
|
4779
|
+
}
|
|
4780
|
+
return jobs;
|
|
4847
4781
|
}
|
|
4848
4782
|
async getJobById(jobId) {
|
|
4849
|
-
|
|
4783
|
+
const url = `${this.acpUrl}/api/jobs/${jobId}`;
|
|
4784
|
+
let response;
|
|
4850
4785
|
try {
|
|
4851
|
-
|
|
4786
|
+
response = await fetch(url, {
|
|
4852
4787
|
headers: {
|
|
4853
4788
|
"wallet-address": this.acpContractClient.walletAddress
|
|
4854
4789
|
}
|
|
4855
4790
|
});
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
|
|
4863
|
-
|
|
4791
|
+
} catch (err) {
|
|
4792
|
+
throw new acpError_default("Failed to fetch job by id (network error)", err);
|
|
4793
|
+
}
|
|
4794
|
+
let data;
|
|
4795
|
+
try {
|
|
4796
|
+
data = await response.json();
|
|
4797
|
+
} catch (err) {
|
|
4798
|
+
throw new acpError_default("Failed to parse job by id response", err);
|
|
4799
|
+
}
|
|
4800
|
+
if (data.error) {
|
|
4801
|
+
throw new acpError_default(data.error.message);
|
|
4802
|
+
}
|
|
4803
|
+
const job = data.data;
|
|
4804
|
+
if (!job) {
|
|
4805
|
+
return void 0;
|
|
4806
|
+
}
|
|
4807
|
+
try {
|
|
4808
|
+
const memos = job.memos.map(
|
|
4809
|
+
(memo) => new acpMemo_default(
|
|
4810
|
+
this.contractClientByAddress(job.contractAddress),
|
|
4811
|
+
memo.id,
|
|
4812
|
+
memo.memoType,
|
|
4813
|
+
memo.content,
|
|
4814
|
+
memo.nextPhase,
|
|
4815
|
+
memo.status,
|
|
4816
|
+
memo.senderAddress,
|
|
4817
|
+
memo.signedReason,
|
|
4818
|
+
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
4819
|
+
memo.payableDetails,
|
|
4820
|
+
memo.txHash,
|
|
4821
|
+
memo.signedTxHash
|
|
4822
|
+
)
|
|
4823
|
+
);
|
|
4864
4824
|
return new acpJob_default(
|
|
4865
4825
|
this,
|
|
4866
4826
|
job.id,
|
|
@@ -4869,50 +4829,42 @@ var AcpClient = class {
|
|
|
4869
4829
|
job.evaluatorAddress,
|
|
4870
4830
|
job.price,
|
|
4871
4831
|
job.priceTokenAddress,
|
|
4872
|
-
|
|
4873
|
-
return new acpMemo_default(
|
|
4874
|
-
this.contractClientByAddress(job.contractAddress),
|
|
4875
|
-
memo.id,
|
|
4876
|
-
memo.memoType,
|
|
4877
|
-
memo.content,
|
|
4878
|
-
memo.nextPhase,
|
|
4879
|
-
memo.status,
|
|
4880
|
-
memo.senderAddress,
|
|
4881
|
-
memo.signedReason,
|
|
4882
|
-
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
4883
|
-
memo.payableDetails,
|
|
4884
|
-
memo.txHash,
|
|
4885
|
-
memo.signedTxHash
|
|
4886
|
-
);
|
|
4887
|
-
}),
|
|
4832
|
+
memos,
|
|
4888
4833
|
job.phase,
|
|
4889
4834
|
job.context,
|
|
4890
4835
|
job.contractAddress,
|
|
4891
4836
|
job.netPayableAmount
|
|
4892
4837
|
);
|
|
4893
|
-
} catch (
|
|
4894
|
-
|
|
4895
|
-
return error;
|
|
4896
|
-
}
|
|
4897
|
-
throw new acpError_default("Failed to get job by id", error);
|
|
4838
|
+
} catch (err) {
|
|
4839
|
+
throw new acpError_default(`Failed to hydrate job ${jobId}`, err);
|
|
4898
4840
|
}
|
|
4899
4841
|
}
|
|
4900
4842
|
async getMemoById(jobId, memoId) {
|
|
4901
|
-
|
|
4843
|
+
const url = `${this.acpUrl}/api/jobs/${jobId}/memos/${memoId}`;
|
|
4844
|
+
let response;
|
|
4902
4845
|
try {
|
|
4903
|
-
|
|
4846
|
+
response = await fetch(url, {
|
|
4904
4847
|
headers: {
|
|
4905
4848
|
"wallet-address": this.walletAddress
|
|
4906
4849
|
}
|
|
4907
4850
|
});
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
4851
|
+
} catch (err) {
|
|
4852
|
+
throw new acpError_default("Failed to fetch memo by id (network error)", err);
|
|
4853
|
+
}
|
|
4854
|
+
let data;
|
|
4855
|
+
try {
|
|
4856
|
+
data = await response.json();
|
|
4857
|
+
} catch (err) {
|
|
4858
|
+
throw new acpError_default("Failed to parse memo by id response", err);
|
|
4859
|
+
}
|
|
4860
|
+
if (data.error) {
|
|
4861
|
+
throw new acpError_default(data.error.message);
|
|
4862
|
+
}
|
|
4863
|
+
const memo = data.data;
|
|
4864
|
+
if (!memo) {
|
|
4865
|
+
return void 0;
|
|
4866
|
+
}
|
|
4867
|
+
try {
|
|
4916
4868
|
return new acpMemo_default(
|
|
4917
4869
|
this.contractClientByAddress(memo.contractAddress),
|
|
4918
4870
|
memo.id,
|
|
@@ -4927,11 +4879,11 @@ var AcpClient = class {
|
|
|
4927
4879
|
memo.txHash,
|
|
4928
4880
|
memo.signedTxHash
|
|
4929
4881
|
);
|
|
4930
|
-
} catch (
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
4882
|
+
} catch (err) {
|
|
4883
|
+
throw new acpError_default(
|
|
4884
|
+
`Failed to hydrate memo ${memoId} for job ${jobId}`,
|
|
4885
|
+
err
|
|
4886
|
+
);
|
|
4935
4887
|
}
|
|
4936
4888
|
}
|
|
4937
4889
|
async getAgent(walletAddress) {
|
|
@@ -5175,7 +5127,7 @@ var AcpContractClient = class _AcpContractClient extends baseAcpContractClient_d
|
|
|
5175
5127
|
);
|
|
5176
5128
|
}
|
|
5177
5129
|
await this.validateSessionKeyOnChain(sessionSignerAddress, sessionEntityKeyId);
|
|
5178
|
-
console.log("Connected to ACP:", {
|
|
5130
|
+
console.log("Connected to ACP with v1 Contract Client (Legacy):", {
|
|
5179
5131
|
agentWalletAddress: this.agentWalletAddress,
|
|
5180
5132
|
whitelistedWalletAddress: sessionSignerAddress,
|
|
5181
5133
|
entityId: sessionEntityKeyId
|