@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.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.17",
|
|
39
39
|
main: "./dist/index.js",
|
|
40
40
|
module: "./dist/index.mjs",
|
|
41
41
|
types: "./dist/index.d.ts",
|
|
@@ -3974,6 +3974,7 @@ var AcpJobOffering = class {
|
|
|
3974
3974
|
var acpJobOffering_default = AcpJobOffering;
|
|
3975
3975
|
|
|
3976
3976
|
// src/acpJob.ts
|
|
3977
|
+
var util = __toESM(require("util"));
|
|
3977
3978
|
var AcpJob = class {
|
|
3978
3979
|
constructor(acpClient, id, clientAddress, providerAddress, evaluatorAddress, price, priceTokenAddress, memos, phase, context, contractAddress, netPayableAmount) {
|
|
3979
3980
|
this.acpClient = acpClient;
|
|
@@ -4129,9 +4130,11 @@ var AcpJob = class {
|
|
|
4129
4130
|
3 /* EVALUATION */
|
|
4130
4131
|
)
|
|
4131
4132
|
);
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4133
|
+
if (this.price > 0) {
|
|
4134
|
+
const x402PaymentDetails = await this.acpContractClient.getX402PaymentDetails(this.id);
|
|
4135
|
+
if (x402PaymentDetails.isX402) {
|
|
4136
|
+
await this.performX402Payment(this.price);
|
|
4137
|
+
}
|
|
4135
4138
|
}
|
|
4136
4139
|
return await this.acpContractClient.handleOperation(operations);
|
|
4137
4140
|
}
|
|
@@ -4348,10 +4351,28 @@ var AcpJob = class {
|
|
|
4348
4351
|
waitMs = Math.min(waitMs * 2, maxWaitMs);
|
|
4349
4352
|
}
|
|
4350
4353
|
}
|
|
4354
|
+
[util.inspect.custom]() {
|
|
4355
|
+
return {
|
|
4356
|
+
id: this.id,
|
|
4357
|
+
clientAddress: this.clientAddress,
|
|
4358
|
+
providerAddress: this.providerAddress,
|
|
4359
|
+
name: this.name,
|
|
4360
|
+
requirement: this.requirement,
|
|
4361
|
+
priceType: this.priceType,
|
|
4362
|
+
priceValue: this.priceValue,
|
|
4363
|
+
priceTokenAddress: this.priceTokenAddress,
|
|
4364
|
+
memos: this.memos,
|
|
4365
|
+
phase: this.phase,
|
|
4366
|
+
context: this.context,
|
|
4367
|
+
contractAddress: this.contractAddress,
|
|
4368
|
+
netPayableAmount: this.netPayableAmount
|
|
4369
|
+
};
|
|
4370
|
+
}
|
|
4351
4371
|
};
|
|
4352
4372
|
var acpJob_default = AcpJob;
|
|
4353
4373
|
|
|
4354
4374
|
// src/acpMemo.ts
|
|
4375
|
+
var import_util = __toESM(require("util"));
|
|
4355
4376
|
var AcpMemo = class {
|
|
4356
4377
|
constructor(contractClient, id, type, content, nextPhase, status, senderAddress, signedReason, expiry, payableDetails, txHash, signedTxHash) {
|
|
4357
4378
|
this.contractClient = contractClient;
|
|
@@ -4391,6 +4412,21 @@ var AcpMemo = class {
|
|
|
4391
4412
|
const payload = this.contractClient.signMemo(this.id, approved, reason);
|
|
4392
4413
|
return await this.contractClient.handleOperation([payload]);
|
|
4393
4414
|
}
|
|
4415
|
+
[import_util.default.inspect.custom]() {
|
|
4416
|
+
return {
|
|
4417
|
+
id: this.id,
|
|
4418
|
+
senderAddress: this.senderAddress,
|
|
4419
|
+
type: MemoType[this.type],
|
|
4420
|
+
status: this.status,
|
|
4421
|
+
content: this.content,
|
|
4422
|
+
signedReason: this.signedReason,
|
|
4423
|
+
txHash: this.txHash,
|
|
4424
|
+
signedTxHash: this.signedTxHash,
|
|
4425
|
+
nextPhase: AcpJobPhases[this.nextPhase],
|
|
4426
|
+
expiry: this.expiry,
|
|
4427
|
+
payableDetails: this.payableDetails
|
|
4428
|
+
};
|
|
4429
|
+
}
|
|
4394
4430
|
};
|
|
4395
4431
|
var acpMemo_default = AcpMemo;
|
|
4396
4432
|
|
|
@@ -4564,7 +4600,7 @@ var AcpClient = class {
|
|
|
4564
4600
|
process.on("SIGTERM", cleanup);
|
|
4565
4601
|
}
|
|
4566
4602
|
async browseAgents(keyword, options) {
|
|
4567
|
-
let { cluster, sort_by, top_k, graduationStatus, onlineStatus } = options;
|
|
4603
|
+
let { cluster, sort_by, top_k, graduationStatus, onlineStatus, showHiddenOfferings } = options;
|
|
4568
4604
|
top_k = top_k ?? 5;
|
|
4569
4605
|
let url = `${this.acpUrl}/api/agents/v4/search?search=${keyword}`;
|
|
4570
4606
|
if (sort_by && sort_by.length > 0) {
|
|
@@ -4585,6 +4621,9 @@ var AcpClient = class {
|
|
|
4585
4621
|
if (onlineStatus) {
|
|
4586
4622
|
url += `&onlineStatus=${onlineStatus}`;
|
|
4587
4623
|
}
|
|
4624
|
+
if (showHiddenOfferings) {
|
|
4625
|
+
url += `&showHiddenOfferings=${showHiddenOfferings}`;
|
|
4626
|
+
}
|
|
4588
4627
|
const response = await fetch(url);
|
|
4589
4628
|
const data = await response.json();
|
|
4590
4629
|
const availableContractClientAddresses = this.contractClients.map(
|
|
@@ -4622,7 +4661,7 @@ var AcpClient = class {
|
|
|
4622
4661
|
twitterHandle: agent.twitterHandle,
|
|
4623
4662
|
walletAddress: agent.walletAddress,
|
|
4624
4663
|
metrics: agent.metrics,
|
|
4625
|
-
|
|
4664
|
+
resources: agent.resources
|
|
4626
4665
|
};
|
|
4627
4666
|
});
|
|
4628
4667
|
}
|
|
@@ -4693,221 +4732,142 @@ var AcpClient = class {
|
|
|
4693
4732
|
return jobId;
|
|
4694
4733
|
}
|
|
4695
4734
|
async getActiveJobs(page = 1, pageSize = 10) {
|
|
4696
|
-
|
|
4697
|
-
|
|
4698
|
-
|
|
4699
|
-
headers: {
|
|
4700
|
-
"wallet-address": this.walletAddress
|
|
4701
|
-
}
|
|
4702
|
-
});
|
|
4703
|
-
const data = await response.json();
|
|
4704
|
-
if (data.error) {
|
|
4705
|
-
throw new acpError_default(data.error.message);
|
|
4706
|
-
}
|
|
4707
|
-
return data.data.map((job) => {
|
|
4708
|
-
return new acpJob_default(
|
|
4709
|
-
this,
|
|
4710
|
-
job.id,
|
|
4711
|
-
job.clientAddress,
|
|
4712
|
-
job.providerAddress,
|
|
4713
|
-
job.evaluatorAddress,
|
|
4714
|
-
job.price,
|
|
4715
|
-
job.priceTokenAddress,
|
|
4716
|
-
job.memos.map((memo) => {
|
|
4717
|
-
return new acpMemo_default(
|
|
4718
|
-
this.contractClientByAddress(job.contractAddress),
|
|
4719
|
-
memo.id,
|
|
4720
|
-
memo.memoType,
|
|
4721
|
-
memo.content,
|
|
4722
|
-
memo.nextPhase,
|
|
4723
|
-
memo.status,
|
|
4724
|
-
memo.senderAddress,
|
|
4725
|
-
memo.signedReason,
|
|
4726
|
-
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
4727
|
-
memo.payableDetails,
|
|
4728
|
-
memo.txHash,
|
|
4729
|
-
memo.signedTxHash
|
|
4730
|
-
);
|
|
4731
|
-
}),
|
|
4732
|
-
job.phase,
|
|
4733
|
-
job.context,
|
|
4734
|
-
job.contractAddress,
|
|
4735
|
-
job.netPayableAmount
|
|
4736
|
-
);
|
|
4737
|
-
});
|
|
4738
|
-
} catch (error) {
|
|
4739
|
-
if (error instanceof acpError_default) {
|
|
4740
|
-
return error;
|
|
4741
|
-
}
|
|
4742
|
-
throw new acpError_default("Failed to get active jobs", error);
|
|
4743
|
-
}
|
|
4735
|
+
const url = `${this.acpUrl}/api/jobs/active?pagination[page]=${page}&pagination[pageSize]=${pageSize}`;
|
|
4736
|
+
const rawJobs = await this._fetchJobList(url);
|
|
4737
|
+
return this._hydrateJobs(rawJobs, { logPrefix: "Active jobs" });
|
|
4744
4738
|
}
|
|
4745
4739
|
async getPendingMemoJobs(page = 1, pageSize = 10) {
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
headers: {
|
|
4750
|
-
"wallet-address": this.acpContractClient.walletAddress
|
|
4751
|
-
}
|
|
4752
|
-
});
|
|
4753
|
-
const data = await response.json();
|
|
4754
|
-
if (data.error) {
|
|
4755
|
-
throw new acpError_default(data.error.message);
|
|
4756
|
-
}
|
|
4757
|
-
return data.data.map((job) => {
|
|
4758
|
-
return new acpJob_default(
|
|
4759
|
-
this,
|
|
4760
|
-
job.id,
|
|
4761
|
-
job.clientAddress,
|
|
4762
|
-
job.providerAddress,
|
|
4763
|
-
job.evaluatorAddress,
|
|
4764
|
-
job.price,
|
|
4765
|
-
job.priceTokenAddress,
|
|
4766
|
-
job.memos.map((memo) => {
|
|
4767
|
-
return new acpMemo_default(
|
|
4768
|
-
this.contractClientByAddress(job.contractAddress),
|
|
4769
|
-
memo.id,
|
|
4770
|
-
memo.memoType,
|
|
4771
|
-
memo.content,
|
|
4772
|
-
memo.nextPhase,
|
|
4773
|
-
memo.status,
|
|
4774
|
-
memo.senderAddress,
|
|
4775
|
-
memo.signedReason,
|
|
4776
|
-
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
4777
|
-
typeof memo.payableDetails === "string" ? tryParseJson(memo.payableDetails) || void 0 : memo.payableDetails,
|
|
4778
|
-
memo.txHash,
|
|
4779
|
-
memo.signedTxHash
|
|
4780
|
-
);
|
|
4781
|
-
}),
|
|
4782
|
-
job.phase,
|
|
4783
|
-
job.context,
|
|
4784
|
-
job.contractAddress,
|
|
4785
|
-
job.netPayableAmount
|
|
4786
|
-
);
|
|
4787
|
-
});
|
|
4788
|
-
} catch (error) {
|
|
4789
|
-
if (error instanceof acpError_default) {
|
|
4790
|
-
return error;
|
|
4791
|
-
}
|
|
4792
|
-
throw new acpError_default("Failed to get pending memo jobs", error);
|
|
4793
|
-
}
|
|
4740
|
+
const url = `${this.acpUrl}/api/jobs/pending-memos?pagination[page]=${page}&pagination[pageSize]=${pageSize}`;
|
|
4741
|
+
const rawJobs = await this._fetchJobList(url);
|
|
4742
|
+
return this._hydrateJobs(rawJobs, { logPrefix: "Pending memo jobs" });
|
|
4794
4743
|
}
|
|
4795
4744
|
async getCompletedJobs(page = 1, pageSize = 10) {
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
headers: {
|
|
4800
|
-
"wallet-address": this.acpContractClient.walletAddress
|
|
4801
|
-
}
|
|
4802
|
-
});
|
|
4803
|
-
const data = await response.json();
|
|
4804
|
-
if (data.error) {
|
|
4805
|
-
throw new acpError_default(data.error.message);
|
|
4806
|
-
}
|
|
4807
|
-
return data.data.map((job) => {
|
|
4808
|
-
return new acpJob_default(
|
|
4809
|
-
this,
|
|
4810
|
-
job.id,
|
|
4811
|
-
job.clientAddress,
|
|
4812
|
-
job.providerAddress,
|
|
4813
|
-
job.evaluatorAddress,
|
|
4814
|
-
job.price,
|
|
4815
|
-
job.priceTokenAddress,
|
|
4816
|
-
job.memos.map((memo) => {
|
|
4817
|
-
return new acpMemo_default(
|
|
4818
|
-
this.contractClientByAddress(job.contractAddress),
|
|
4819
|
-
memo.id,
|
|
4820
|
-
memo.memoType,
|
|
4821
|
-
memo.content,
|
|
4822
|
-
memo.nextPhase,
|
|
4823
|
-
memo.status,
|
|
4824
|
-
memo.senderAddress,
|
|
4825
|
-
memo.signedReason,
|
|
4826
|
-
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
4827
|
-
memo.payableDetails,
|
|
4828
|
-
memo.txHash,
|
|
4829
|
-
memo.signedTxHash
|
|
4830
|
-
);
|
|
4831
|
-
}),
|
|
4832
|
-
job.phase,
|
|
4833
|
-
job.context,
|
|
4834
|
-
job.contractAddress,
|
|
4835
|
-
job.netPayableAmount
|
|
4836
|
-
);
|
|
4837
|
-
});
|
|
4838
|
-
} catch (error) {
|
|
4839
|
-
if (error instanceof acpError_default) {
|
|
4840
|
-
return error;
|
|
4841
|
-
}
|
|
4842
|
-
throw new acpError_default("Failed to get completed jobs", error);
|
|
4843
|
-
}
|
|
4745
|
+
const url = `${this.acpUrl}/api/jobs/completed?pagination[page]=${page}&pagination[pageSize]=${pageSize}`;
|
|
4746
|
+
const rawJobs = await this._fetchJobList(url);
|
|
4747
|
+
return this._hydrateJobs(rawJobs, { logPrefix: "Completed jobs" });
|
|
4844
4748
|
}
|
|
4845
4749
|
async getCancelledJobs(page = 1, pageSize = 10) {
|
|
4846
|
-
|
|
4750
|
+
const url = `${this.acpUrl}/api/jobs/cancelled?pagination[page]=${page}&pagination[pageSize]=${pageSize}`;
|
|
4751
|
+
const rawJobs = await this._fetchJobList(url);
|
|
4752
|
+
return this._hydrateJobs(rawJobs, { logPrefix: "Cancelled jobs" });
|
|
4753
|
+
}
|
|
4754
|
+
async _fetchJobList(url) {
|
|
4755
|
+
let response;
|
|
4847
4756
|
try {
|
|
4848
|
-
|
|
4757
|
+
response = await fetch(url, {
|
|
4849
4758
|
headers: {
|
|
4850
4759
|
"wallet-address": this.walletAddress
|
|
4851
4760
|
}
|
|
4852
4761
|
});
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
4762
|
+
} catch (err) {
|
|
4763
|
+
throw new acpError_default("Failed to fetch ACP jobs (network error)", err);
|
|
4764
|
+
}
|
|
4765
|
+
let data;
|
|
4766
|
+
try {
|
|
4767
|
+
data = await response.json();
|
|
4768
|
+
} catch (err) {
|
|
4769
|
+
throw new acpError_default("Failed to parse ACP jobs response", err);
|
|
4770
|
+
}
|
|
4771
|
+
if (data.error) {
|
|
4772
|
+
throw new acpError_default(data.error.message);
|
|
4773
|
+
}
|
|
4774
|
+
return data.data;
|
|
4775
|
+
}
|
|
4776
|
+
_hydrateJobs(rawJobs, options) {
|
|
4777
|
+
const jobs = [];
|
|
4778
|
+
const errors = [];
|
|
4779
|
+
for (const job of rawJobs) {
|
|
4780
|
+
try {
|
|
4781
|
+
const memos = job.memos.map(
|
|
4782
|
+
(memo) => new acpMemo_default(
|
|
4783
|
+
this.contractClientByAddress(job.contractAddress),
|
|
4784
|
+
memo.id,
|
|
4785
|
+
memo.memoType,
|
|
4786
|
+
memo.content,
|
|
4787
|
+
memo.nextPhase,
|
|
4788
|
+
memo.status,
|
|
4789
|
+
memo.senderAddress,
|
|
4790
|
+
memo.signedReason,
|
|
4791
|
+
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
4792
|
+
memo.payableDetails,
|
|
4793
|
+
memo.txHash,
|
|
4794
|
+
memo.signedTxHash
|
|
4795
|
+
)
|
|
4886
4796
|
);
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4797
|
+
jobs.push(
|
|
4798
|
+
new acpJob_default(
|
|
4799
|
+
this,
|
|
4800
|
+
job.id,
|
|
4801
|
+
job.clientAddress,
|
|
4802
|
+
job.providerAddress,
|
|
4803
|
+
job.evaluatorAddress,
|
|
4804
|
+
job.price,
|
|
4805
|
+
job.priceTokenAddress,
|
|
4806
|
+
memos,
|
|
4807
|
+
job.phase,
|
|
4808
|
+
job.context,
|
|
4809
|
+
job.contractAddress,
|
|
4810
|
+
job.netPayableAmount
|
|
4811
|
+
)
|
|
4812
|
+
);
|
|
4813
|
+
} catch (err) {
|
|
4814
|
+
errors.push({ jobId: job.id, error: err });
|
|
4891
4815
|
}
|
|
4892
|
-
throw new acpError_default("Failed to get cancelled jobs", error);
|
|
4893
4816
|
}
|
|
4817
|
+
if (errors.length > 0) {
|
|
4818
|
+
console.warn(
|
|
4819
|
+
`${options?.logPrefix ?? "Skipped"} ${errors.length} malformed job(s)
|
|
4820
|
+
` + JSON.stringify(
|
|
4821
|
+
errors.map((e) => ({ jobId: e.jobId, message: e.error.message })),
|
|
4822
|
+
null,
|
|
4823
|
+
2
|
|
4824
|
+
)
|
|
4825
|
+
);
|
|
4826
|
+
}
|
|
4827
|
+
return jobs;
|
|
4894
4828
|
}
|
|
4895
4829
|
async getJobById(jobId) {
|
|
4896
|
-
|
|
4830
|
+
const url = `${this.acpUrl}/api/jobs/${jobId}`;
|
|
4831
|
+
let response;
|
|
4897
4832
|
try {
|
|
4898
|
-
|
|
4833
|
+
response = await fetch(url, {
|
|
4899
4834
|
headers: {
|
|
4900
4835
|
"wallet-address": this.acpContractClient.walletAddress
|
|
4901
4836
|
}
|
|
4902
4837
|
});
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
4838
|
+
} catch (err) {
|
|
4839
|
+
throw new acpError_default("Failed to fetch job by id (network error)", err);
|
|
4840
|
+
}
|
|
4841
|
+
let data;
|
|
4842
|
+
try {
|
|
4843
|
+
data = await response.json();
|
|
4844
|
+
} catch (err) {
|
|
4845
|
+
throw new acpError_default("Failed to parse job by id response", err);
|
|
4846
|
+
}
|
|
4847
|
+
if (data.error) {
|
|
4848
|
+
throw new acpError_default(data.error.message);
|
|
4849
|
+
}
|
|
4850
|
+
const job = data.data;
|
|
4851
|
+
if (!job) {
|
|
4852
|
+
return void 0;
|
|
4853
|
+
}
|
|
4854
|
+
try {
|
|
4855
|
+
const memos = job.memos.map(
|
|
4856
|
+
(memo) => new acpMemo_default(
|
|
4857
|
+
this.contractClientByAddress(job.contractAddress),
|
|
4858
|
+
memo.id,
|
|
4859
|
+
memo.memoType,
|
|
4860
|
+
memo.content,
|
|
4861
|
+
memo.nextPhase,
|
|
4862
|
+
memo.status,
|
|
4863
|
+
memo.senderAddress,
|
|
4864
|
+
memo.signedReason,
|
|
4865
|
+
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
4866
|
+
memo.payableDetails,
|
|
4867
|
+
memo.txHash,
|
|
4868
|
+
memo.signedTxHash
|
|
4869
|
+
)
|
|
4870
|
+
);
|
|
4911
4871
|
return new acpJob_default(
|
|
4912
4872
|
this,
|
|
4913
4873
|
job.id,
|
|
@@ -4916,50 +4876,42 @@ var AcpClient = class {
|
|
|
4916
4876
|
job.evaluatorAddress,
|
|
4917
4877
|
job.price,
|
|
4918
4878
|
job.priceTokenAddress,
|
|
4919
|
-
|
|
4920
|
-
return new acpMemo_default(
|
|
4921
|
-
this.contractClientByAddress(job.contractAddress),
|
|
4922
|
-
memo.id,
|
|
4923
|
-
memo.memoType,
|
|
4924
|
-
memo.content,
|
|
4925
|
-
memo.nextPhase,
|
|
4926
|
-
memo.status,
|
|
4927
|
-
memo.senderAddress,
|
|
4928
|
-
memo.signedReason,
|
|
4929
|
-
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
4930
|
-
memo.payableDetails,
|
|
4931
|
-
memo.txHash,
|
|
4932
|
-
memo.signedTxHash
|
|
4933
|
-
);
|
|
4934
|
-
}),
|
|
4879
|
+
memos,
|
|
4935
4880
|
job.phase,
|
|
4936
4881
|
job.context,
|
|
4937
4882
|
job.contractAddress,
|
|
4938
4883
|
job.netPayableAmount
|
|
4939
4884
|
);
|
|
4940
|
-
} catch (
|
|
4941
|
-
|
|
4942
|
-
return error;
|
|
4943
|
-
}
|
|
4944
|
-
throw new acpError_default("Failed to get job by id", error);
|
|
4885
|
+
} catch (err) {
|
|
4886
|
+
throw new acpError_default(`Failed to hydrate job ${jobId}`, err);
|
|
4945
4887
|
}
|
|
4946
4888
|
}
|
|
4947
4889
|
async getMemoById(jobId, memoId) {
|
|
4948
|
-
|
|
4890
|
+
const url = `${this.acpUrl}/api/jobs/${jobId}/memos/${memoId}`;
|
|
4891
|
+
let response;
|
|
4949
4892
|
try {
|
|
4950
|
-
|
|
4893
|
+
response = await fetch(url, {
|
|
4951
4894
|
headers: {
|
|
4952
4895
|
"wallet-address": this.walletAddress
|
|
4953
4896
|
}
|
|
4954
4897
|
});
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
|
|
4961
|
-
|
|
4962
|
-
|
|
4898
|
+
} catch (err) {
|
|
4899
|
+
throw new acpError_default("Failed to fetch memo by id (network error)", err);
|
|
4900
|
+
}
|
|
4901
|
+
let data;
|
|
4902
|
+
try {
|
|
4903
|
+
data = await response.json();
|
|
4904
|
+
} catch (err) {
|
|
4905
|
+
throw new acpError_default("Failed to parse memo by id response", err);
|
|
4906
|
+
}
|
|
4907
|
+
if (data.error) {
|
|
4908
|
+
throw new acpError_default(data.error.message);
|
|
4909
|
+
}
|
|
4910
|
+
const memo = data.data;
|
|
4911
|
+
if (!memo) {
|
|
4912
|
+
return void 0;
|
|
4913
|
+
}
|
|
4914
|
+
try {
|
|
4963
4915
|
return new acpMemo_default(
|
|
4964
4916
|
this.contractClientByAddress(memo.contractAddress),
|
|
4965
4917
|
memo.id,
|
|
@@ -4974,11 +4926,11 @@ var AcpClient = class {
|
|
|
4974
4926
|
memo.txHash,
|
|
4975
4927
|
memo.signedTxHash
|
|
4976
4928
|
);
|
|
4977
|
-
} catch (
|
|
4978
|
-
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
|
-
|
|
4929
|
+
} catch (err) {
|
|
4930
|
+
throw new acpError_default(
|
|
4931
|
+
`Failed to hydrate memo ${memoId} for job ${jobId}`,
|
|
4932
|
+
err
|
|
4933
|
+
);
|
|
4982
4934
|
}
|
|
4983
4935
|
}
|
|
4984
4936
|
async getAgent(walletAddress) {
|
|
@@ -5218,7 +5170,7 @@ var AcpContractClient = class _AcpContractClient extends baseAcpContractClient_d
|
|
|
5218
5170
|
);
|
|
5219
5171
|
}
|
|
5220
5172
|
await this.validateSessionKeyOnChain(sessionSignerAddress, sessionEntityKeyId);
|
|
5221
|
-
console.log("Connected to ACP:", {
|
|
5173
|
+
console.log("Connected to ACP with v1 Contract Client (Legacy):", {
|
|
5222
5174
|
agentWalletAddress: this.agentWalletAddress,
|
|
5223
5175
|
whitelistedWalletAddress: sessionSignerAddress,
|
|
5224
5176
|
entityId: sessionEntityKeyId
|