@virtuals-protocol/acp-node 0.3.0-beta.23 → 0.3.0-beta.25
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 +2 -2
- package/dist/index.d.mts +288 -391
- package/dist/index.d.ts +288 -391
- package/dist/index.js +487 -1940
- package/dist/index.mjs +485 -1945
- package/package.json +3 -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.25",
|
|
39
39
|
main: "./dist/index.js",
|
|
40
40
|
module: "./dist/index.mjs",
|
|
41
41
|
types: "./dist/index.d.ts",
|
|
@@ -68,6 +68,8 @@ var require_package = __commonJS({
|
|
|
68
68
|
"@account-kit/smart-contracts": "^4.73.0",
|
|
69
69
|
"@virtuals-protocol/acp-node": "^0.3.0-beta.10",
|
|
70
70
|
ajv: "^8.17.1",
|
|
71
|
+
axios: "^1.13.2",
|
|
72
|
+
"jwt-decode": "^4.0.0",
|
|
71
73
|
"socket.io-client": "^4.8.1",
|
|
72
74
|
tsup: "^8.5.0",
|
|
73
75
|
viem: "^2.28.2"
|
|
@@ -83,6 +85,7 @@ var require_package = __commonJS({
|
|
|
83
85
|
var index_exports = {};
|
|
84
86
|
__export(index_exports, {
|
|
85
87
|
ACP_ABI: () => acpAbi_default,
|
|
88
|
+
AcpAgent: () => acpAgent_default,
|
|
86
89
|
AcpAgentSort: () => AcpAgentSort,
|
|
87
90
|
AcpContractClient: () => acpContractClient_default,
|
|
88
91
|
AcpContractClientV2: () => acpContractClientV2_default,
|
|
@@ -92,7 +95,6 @@ __export(index_exports, {
|
|
|
92
95
|
AcpJob: () => acpJob_default,
|
|
93
96
|
AcpJobPhases: () => AcpJobPhases,
|
|
94
97
|
AcpMemo: () => acpMemo_default,
|
|
95
|
-
AcpMemoState: () => AcpMemoState,
|
|
96
98
|
AcpMemoStatus: () => AcpMemoStatus,
|
|
97
99
|
AcpOnlineStatus: () => AcpOnlineStatus,
|
|
98
100
|
BaseAcpContractClient: () => baseAcpContractClient_default,
|
|
@@ -100,15 +102,12 @@ __export(index_exports, {
|
|
|
100
102
|
FareAmount: () => FareAmount,
|
|
101
103
|
FareBigInt: () => FareBigInt,
|
|
102
104
|
MemoType: () => MemoType,
|
|
103
|
-
PayloadType: () => PayloadType,
|
|
104
|
-
PositionDirection: () => PositionDirection,
|
|
105
105
|
baseAcpConfig: () => baseAcpConfig,
|
|
106
106
|
baseAcpConfigV2: () => baseAcpConfigV2,
|
|
107
107
|
baseAcpX402Config: () => baseAcpX402Config,
|
|
108
108
|
baseAcpX402ConfigV2: () => baseAcpX402ConfigV2,
|
|
109
109
|
baseSepoliaAcpConfig: () => baseSepoliaAcpConfig,
|
|
110
110
|
baseSepoliaAcpConfigV2: () => baseSepoliaAcpConfigV2,
|
|
111
|
-
baseSepoliaAcpX402ConfigV2: () => baseSepoliaAcpX402ConfigV2,
|
|
112
111
|
default: () => index_default,
|
|
113
112
|
ethFare: () => ethFare,
|
|
114
113
|
preparePayload: () => preparePayload,
|
|
@@ -1287,8 +1286,9 @@ var ACP_ABI = [
|
|
|
1287
1286
|
var acpAbi_default = ACP_ABI;
|
|
1288
1287
|
|
|
1289
1288
|
// src/acpClient.ts
|
|
1290
|
-
var
|
|
1289
|
+
var import_viem4 = require("viem");
|
|
1291
1290
|
var import_socket = require("socket.io-client");
|
|
1291
|
+
var import_jwt_decode = require("jwt-decode");
|
|
1292
1292
|
|
|
1293
1293
|
// src/contractClients/baseAcpContractClient.ts
|
|
1294
1294
|
var import_viem2 = require("viem");
|
|
@@ -1316,42 +1316,27 @@ var acpError_default = AcpError;
|
|
|
1316
1316
|
|
|
1317
1317
|
// src/acpFare.ts
|
|
1318
1318
|
var Fare = class _Fare {
|
|
1319
|
-
constructor(contractAddress, decimals
|
|
1319
|
+
constructor(contractAddress, decimals) {
|
|
1320
1320
|
this.contractAddress = contractAddress;
|
|
1321
1321
|
this.decimals = decimals;
|
|
1322
|
-
this.chainId = chainId;
|
|
1323
1322
|
}
|
|
1324
1323
|
formatAmount(amount) {
|
|
1325
1324
|
return (0, import_viem.parseUnits)(amount.toString(), this.decimals);
|
|
1326
1325
|
}
|
|
1327
|
-
static async fromContractAddress(contractAddress, config = baseAcpConfig
|
|
1326
|
+
static async fromContractAddress(contractAddress, config = baseAcpConfig) {
|
|
1328
1327
|
if (contractAddress === config.baseFare.contractAddress) {
|
|
1329
1328
|
return config.baseFare;
|
|
1330
1329
|
}
|
|
1331
|
-
let chainConfig = config.chain;
|
|
1332
|
-
let rpcUrl = config.rpcEndpoint;
|
|
1333
|
-
if (chainId !== config.chain.id) {
|
|
1334
|
-
const selectedConfig = config.chains?.find(
|
|
1335
|
-
(chain) => chain.chain.id === chainId
|
|
1336
|
-
);
|
|
1337
|
-
if (!selectedConfig) {
|
|
1338
|
-
throw new acpError_default(
|
|
1339
|
-
`Chain configuration for chainId ${chainId} not found.`
|
|
1340
|
-
);
|
|
1341
|
-
}
|
|
1342
|
-
chainConfig = selectedConfig.chain;
|
|
1343
|
-
rpcUrl = selectedConfig.rpcUrl;
|
|
1344
|
-
}
|
|
1345
1330
|
const publicClient = (0, import_viem.createPublicClient)({
|
|
1346
|
-
chain:
|
|
1347
|
-
transport: (0, import_viem.http)(
|
|
1331
|
+
chain: config.chain,
|
|
1332
|
+
transport: (0, import_viem.http)(config.rpcEndpoint)
|
|
1348
1333
|
});
|
|
1349
1334
|
const decimals = await publicClient.readContract({
|
|
1350
1335
|
address: contractAddress,
|
|
1351
1336
|
abi: import_viem.erc20Abi,
|
|
1352
1337
|
functionName: "decimals"
|
|
1353
1338
|
});
|
|
1354
|
-
return new _Fare(contractAddress, decimals
|
|
1339
|
+
return new _Fare(contractAddress, decimals);
|
|
1355
1340
|
}
|
|
1356
1341
|
};
|
|
1357
1342
|
var FareAmountBase = class {
|
|
@@ -1770,34 +1755,6 @@ var ACP_V2_ABI = [
|
|
|
1770
1755
|
stateMutability: "nonpayable",
|
|
1771
1756
|
type: "function"
|
|
1772
1757
|
},
|
|
1773
|
-
{
|
|
1774
|
-
inputs: [
|
|
1775
|
-
{ internalType: "uint256", name: "jobId", type: "uint256" },
|
|
1776
|
-
{ internalType: "string", name: "content", type: "string" },
|
|
1777
|
-
{ internalType: "address", name: "token", type: "address" },
|
|
1778
|
-
{ internalType: "uint256", name: "amount", type: "uint256" },
|
|
1779
|
-
{ internalType: "address", name: "recipient", type: "address" },
|
|
1780
|
-
{ internalType: "uint256", name: "feeAmount", type: "uint256" },
|
|
1781
|
-
{ internalType: "enum ACPTypes.FeeType", name: "feeType", type: "uint8" },
|
|
1782
|
-
{
|
|
1783
|
-
internalType: "enum ACPTypes.MemoType",
|
|
1784
|
-
name: "memoType",
|
|
1785
|
-
type: "uint8"
|
|
1786
|
-
},
|
|
1787
|
-
{ internalType: "uint256", name: "expiredAt", type: "uint256" },
|
|
1788
|
-
{ internalType: "bool", name: "isSecured", type: "bool" },
|
|
1789
|
-
{
|
|
1790
|
-
internalType: "enum ACPTypes.JobPhase",
|
|
1791
|
-
name: "nextPhase",
|
|
1792
|
-
type: "uint8"
|
|
1793
|
-
},
|
|
1794
|
-
{ internalType: "uint32", name: "lzDstEid", type: "uint32" }
|
|
1795
|
-
],
|
|
1796
|
-
name: "createCrossChainPayableMemo",
|
|
1797
|
-
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
1798
|
-
stateMutability: "nonpayable",
|
|
1799
|
-
type: "function"
|
|
1800
|
-
},
|
|
1801
1758
|
{
|
|
1802
1759
|
inputs: [
|
|
1803
1760
|
{ internalType: "address", name: "provider", type: "address" },
|
|
@@ -1982,12 +1939,7 @@ var ACP_V2_ABI = [
|
|
|
1982
1939
|
name: "nextPhase",
|
|
1983
1940
|
type: "uint8"
|
|
1984
1941
|
},
|
|
1985
|
-
{ internalType: "uint256", name: "expiredAt", type: "uint256" }
|
|
1986
|
-
{
|
|
1987
|
-
internalType: "enum ACPTypes.MemoState",
|
|
1988
|
-
name: "state",
|
|
1989
|
-
type: "uint8"
|
|
1990
|
-
}
|
|
1942
|
+
{ internalType: "uint256", name: "expiredAt", type: "uint256" }
|
|
1991
1943
|
],
|
|
1992
1944
|
internalType: "struct ACPTypes.Memo[]",
|
|
1993
1945
|
name: "memos",
|
|
@@ -2034,12 +1986,7 @@ var ACP_V2_ABI = [
|
|
|
2034
1986
|
name: "nextPhase",
|
|
2035
1987
|
type: "uint8"
|
|
2036
1988
|
},
|
|
2037
|
-
{ internalType: "uint256", name: "expiredAt", type: "uint256" }
|
|
2038
|
-
{
|
|
2039
|
-
internalType: "enum ACPTypes.MemoState",
|
|
2040
|
-
name: "state",
|
|
2041
|
-
type: "uint8"
|
|
2042
|
-
}
|
|
1989
|
+
{ internalType: "uint256", name: "expiredAt", type: "uint256" }
|
|
2043
1990
|
],
|
|
2044
1991
|
internalType: "struct ACPTypes.Memo[]",
|
|
2045
1992
|
name: "memos",
|
|
@@ -2082,12 +2029,7 @@ var ACP_V2_ABI = [
|
|
|
2082
2029
|
name: "nextPhase",
|
|
2083
2030
|
type: "uint8"
|
|
2084
2031
|
},
|
|
2085
|
-
{ internalType: "uint256", name: "expiredAt", type: "uint256" }
|
|
2086
|
-
{
|
|
2087
|
-
internalType: "enum ACPTypes.MemoState",
|
|
2088
|
-
name: "state",
|
|
2089
|
-
type: "uint8"
|
|
2090
|
-
}
|
|
2032
|
+
{ internalType: "uint256", name: "expiredAt", type: "uint256" }
|
|
2091
2033
|
],
|
|
2092
2034
|
internalType: "struct ACPTypes.Memo[]",
|
|
2093
2035
|
name: "memos",
|
|
@@ -2343,7 +2285,7 @@ var acpAbiV2_default = ACP_V2_ABI;
|
|
|
2343
2285
|
var V1_MAX_RETRIES = 10;
|
|
2344
2286
|
var V2_MAX_RETRIES = 3;
|
|
2345
2287
|
var AcpContractConfig2 = class {
|
|
2346
|
-
constructor(chain, contractAddress, baseFare, alchemyRpcUrl, acpUrl, abi, maxRetries, rpcEndpoint, x402Config, retryConfig
|
|
2288
|
+
constructor(chain, contractAddress, baseFare, alchemyRpcUrl, acpUrl, abi, maxRetries, rpcEndpoint, x402Config, retryConfig) {
|
|
2347
2289
|
this.chain = chain;
|
|
2348
2290
|
this.contractAddress = contractAddress;
|
|
2349
2291
|
this.baseFare = baseFare;
|
|
@@ -2354,7 +2296,6 @@ var AcpContractConfig2 = class {
|
|
|
2354
2296
|
this.rpcEndpoint = rpcEndpoint;
|
|
2355
2297
|
this.x402Config = x402Config;
|
|
2356
2298
|
this.retryConfig = retryConfig;
|
|
2357
|
-
this.chains = chains;
|
|
2358
2299
|
}
|
|
2359
2300
|
};
|
|
2360
2301
|
var baseSepoliaAcpConfig = new AcpContractConfig2(
|
|
@@ -3630,7 +3571,6 @@ var BaseAcpContractClient = class {
|
|
|
3630
3571
|
constructor(agentWalletAddress, config = baseAcpConfig) {
|
|
3631
3572
|
this.agentWalletAddress = agentWalletAddress;
|
|
3632
3573
|
this.config = config;
|
|
3633
|
-
this.publicClients = {};
|
|
3634
3574
|
this.chain = config.chain;
|
|
3635
3575
|
this.abi = config.abi;
|
|
3636
3576
|
this.contractAddress = config.contractAddress;
|
|
@@ -3730,12 +3670,12 @@ ${JSON.stringify(
|
|
|
3730
3670
|
throw new acpError_default("Failed to create job", error);
|
|
3731
3671
|
}
|
|
3732
3672
|
}
|
|
3733
|
-
approveAllowance(amountBaseUnit, paymentTokenAddress = this.config.baseFare.contractAddress
|
|
3673
|
+
approveAllowance(amountBaseUnit, paymentTokenAddress = this.config.baseFare.contractAddress) {
|
|
3734
3674
|
try {
|
|
3735
3675
|
const data = (0, import_viem2.encodeFunctionData)({
|
|
3736
3676
|
abi: import_viem2.erc20Abi,
|
|
3737
3677
|
functionName: "approve",
|
|
3738
|
-
args: [
|
|
3678
|
+
args: [this.contractAddress, amountBaseUnit]
|
|
3739
3679
|
});
|
|
3740
3680
|
const payload = {
|
|
3741
3681
|
data,
|
|
@@ -3774,35 +3714,6 @@ ${JSON.stringify(
|
|
|
3774
3714
|
throw new acpError_default("Failed to create payable memo", error);
|
|
3775
3715
|
}
|
|
3776
3716
|
}
|
|
3777
|
-
createCrossChainPayableMemo(jobId, content, token, amountBaseUnit, recipient, feeAmountBaseUnit, feeType, type, expiredAt, nextPhase, destinationEid, secured = true) {
|
|
3778
|
-
try {
|
|
3779
|
-
const data = (0, import_viem2.encodeFunctionData)({
|
|
3780
|
-
abi: this.abi,
|
|
3781
|
-
functionName: "createCrossChainPayableMemo",
|
|
3782
|
-
args: [
|
|
3783
|
-
jobId,
|
|
3784
|
-
content,
|
|
3785
|
-
token,
|
|
3786
|
-
amountBaseUnit,
|
|
3787
|
-
recipient,
|
|
3788
|
-
feeAmountBaseUnit,
|
|
3789
|
-
feeType,
|
|
3790
|
-
type,
|
|
3791
|
-
expiredAt,
|
|
3792
|
-
secured,
|
|
3793
|
-
nextPhase,
|
|
3794
|
-
destinationEid
|
|
3795
|
-
]
|
|
3796
|
-
});
|
|
3797
|
-
const payload = {
|
|
3798
|
-
data,
|
|
3799
|
-
contractAddress: this.contractAddress
|
|
3800
|
-
};
|
|
3801
|
-
return payload;
|
|
3802
|
-
} catch (error) {
|
|
3803
|
-
throw new acpError_default("Failed to create cross chain payable memo", error);
|
|
3804
|
-
}
|
|
3805
|
-
}
|
|
3806
3717
|
createMemo(jobId, content, type, isSecured, nextPhase) {
|
|
3807
3718
|
try {
|
|
3808
3719
|
const data = (0, import_viem2.encodeFunctionData)({
|
|
@@ -3819,22 +3730,6 @@ ${JSON.stringify(
|
|
|
3819
3730
|
throw new acpError_default("Failed to create memo", error);
|
|
3820
3731
|
}
|
|
3821
3732
|
}
|
|
3822
|
-
createMemoWithMetadata(jobId, content, type, isSecured, nextPhase, metadata) {
|
|
3823
|
-
try {
|
|
3824
|
-
const data = (0, import_viem2.encodeFunctionData)({
|
|
3825
|
-
abi: this.abi,
|
|
3826
|
-
functionName: "createMemoWithMetadata",
|
|
3827
|
-
args: [jobId, content, type, isSecured, nextPhase, metadata]
|
|
3828
|
-
});
|
|
3829
|
-
const payload = {
|
|
3830
|
-
data,
|
|
3831
|
-
contractAddress: this.contractAddress
|
|
3832
|
-
};
|
|
3833
|
-
return payload;
|
|
3834
|
-
} catch (error) {
|
|
3835
|
-
throw new acpError_default("Failed to create memo with metadata", error);
|
|
3836
|
-
}
|
|
3837
|
-
}
|
|
3838
3733
|
signMemo(memoId, isApproved, reason) {
|
|
3839
3734
|
try {
|
|
3840
3735
|
const data = (0, import_viem2.encodeFunctionData)({
|
|
@@ -3920,47 +3815,9 @@ ${JSON.stringify(
|
|
|
3920
3815
|
throw new acpError_default("Failed to submit TransferWithAuthorization", error);
|
|
3921
3816
|
}
|
|
3922
3817
|
}
|
|
3923
|
-
async getERC20Balance(chainId, tokenAddress, walletAddress) {
|
|
3924
|
-
const publicClient = this.publicClients[chainId];
|
|
3925
|
-
if (!publicClient) {
|
|
3926
|
-
throw new acpError_default(`Public client for chainId ${chainId} not found`);
|
|
3927
|
-
}
|
|
3928
|
-
return await publicClient.readContract({
|
|
3929
|
-
address: tokenAddress,
|
|
3930
|
-
abi: import_viem2.erc20Abi,
|
|
3931
|
-
functionName: "balanceOf",
|
|
3932
|
-
args: [walletAddress]
|
|
3933
|
-
});
|
|
3934
|
-
}
|
|
3935
|
-
async getERC20Allowance(chainId, tokenAddress, walletAddress, spenderAddress) {
|
|
3936
|
-
const publicClient = this.publicClients[chainId];
|
|
3937
|
-
if (!publicClient) {
|
|
3938
|
-
throw new acpError_default(`Public client for chainId ${chainId} not found`);
|
|
3939
|
-
}
|
|
3940
|
-
return await publicClient.readContract({
|
|
3941
|
-
address: tokenAddress,
|
|
3942
|
-
abi: import_viem2.erc20Abi,
|
|
3943
|
-
functionName: "allowance",
|
|
3944
|
-
args: [walletAddress, spenderAddress]
|
|
3945
|
-
});
|
|
3946
|
-
}
|
|
3947
|
-
async getERC20Symbol(chainId, tokenAddress) {
|
|
3948
|
-
const publicClient = this.publicClients[chainId];
|
|
3949
|
-
if (!publicClient) {
|
|
3950
|
-
throw new acpError_default(`Public client for chainId ${chainId} not found`);
|
|
3951
|
-
}
|
|
3952
|
-
return await publicClient.readContract({
|
|
3953
|
-
address: tokenAddress,
|
|
3954
|
-
abi: import_viem2.erc20Abi,
|
|
3955
|
-
functionName: "symbol"
|
|
3956
|
-
});
|
|
3957
|
-
}
|
|
3958
3818
|
};
|
|
3959
3819
|
var baseAcpContractClient_default = BaseAcpContractClient;
|
|
3960
3820
|
|
|
3961
|
-
// src/acpJob.ts
|
|
3962
|
-
var import_viem5 = require("viem");
|
|
3963
|
-
|
|
3964
3821
|
// src/interfaces.ts
|
|
3965
3822
|
var AcpMemoStatus = /* @__PURE__ */ ((AcpMemoStatus2) => {
|
|
3966
3823
|
AcpMemoStatus2["PENDING"] = "PENDING";
|
|
@@ -3968,15 +3825,6 @@ var AcpMemoStatus = /* @__PURE__ */ ((AcpMemoStatus2) => {
|
|
|
3968
3825
|
AcpMemoStatus2["REJECTED"] = "REJECTED";
|
|
3969
3826
|
return AcpMemoStatus2;
|
|
3970
3827
|
})(AcpMemoStatus || {});
|
|
3971
|
-
var AcpMemoState = /* @__PURE__ */ ((AcpMemoState2) => {
|
|
3972
|
-
AcpMemoState2[AcpMemoState2["NONE"] = 0] = "NONE";
|
|
3973
|
-
AcpMemoState2[AcpMemoState2["PENDING"] = 1] = "PENDING";
|
|
3974
|
-
AcpMemoState2[AcpMemoState2["IN_PROGRESS"] = 2] = "IN_PROGRESS";
|
|
3975
|
-
AcpMemoState2[AcpMemoState2["READY"] = 3] = "READY";
|
|
3976
|
-
AcpMemoState2[AcpMemoState2["COMPLETED"] = 4] = "COMPLETED";
|
|
3977
|
-
AcpMemoState2[AcpMemoState2["REJECTED"] = 5] = "REJECTED";
|
|
3978
|
-
return AcpMemoState2;
|
|
3979
|
-
})(AcpMemoState || {});
|
|
3980
3828
|
var AcpAgentSort = /* @__PURE__ */ ((AcpAgentSort2) => {
|
|
3981
3829
|
AcpAgentSort2["SUCCESSFUL_JOB_COUNT"] = "successfulJobCount";
|
|
3982
3830
|
AcpAgentSort2["SUCCESS_RATE"] = "successRate";
|
|
@@ -3996,27 +3844,8 @@ var AcpOnlineStatus = /* @__PURE__ */ ((AcpOnlineStatus2) => {
|
|
|
3996
3844
|
AcpOnlineStatus2["OFFLINE"] = "offline";
|
|
3997
3845
|
return AcpOnlineStatus2;
|
|
3998
3846
|
})(AcpOnlineStatus || {});
|
|
3999
|
-
var PayloadType = /* @__PURE__ */ ((PayloadType2) => {
|
|
4000
|
-
PayloadType2["FUND_RESPONSE"] = "fund_response";
|
|
4001
|
-
PayloadType2["OPEN_POSITION"] = "open_position";
|
|
4002
|
-
PayloadType2["SWAP_TOKEN"] = "swap_token";
|
|
4003
|
-
PayloadType2["RESPONSE_SWAP_TOKEN"] = "response_swap_token";
|
|
4004
|
-
PayloadType2["CLOSE_PARTIAL_POSITION"] = "close_partial_position";
|
|
4005
|
-
PayloadType2["CLOSE_POSITION"] = "close_position";
|
|
4006
|
-
PayloadType2["POSITION_FULFILLED"] = "position_fulfilled";
|
|
4007
|
-
PayloadType2["CLOSE_JOB_AND_WITHDRAW"] = "close_job_and_withdraw";
|
|
4008
|
-
PayloadType2["UNFULFILLED_POSITION"] = "unfulfilled_position";
|
|
4009
|
-
return PayloadType2;
|
|
4010
|
-
})(PayloadType || {});
|
|
4011
|
-
var PositionDirection = /* @__PURE__ */ ((PositionDirection2) => {
|
|
4012
|
-
PositionDirection2["LONG"] = "long";
|
|
4013
|
-
PositionDirection2["SHORT"] = "short";
|
|
4014
|
-
return PositionDirection2;
|
|
4015
|
-
})(PositionDirection || {});
|
|
4016
3847
|
|
|
4017
3848
|
// src/utils.ts
|
|
4018
|
-
var import_viem3 = require("viem");
|
|
4019
|
-
var import_chains2 = require("viem/chains");
|
|
4020
3849
|
function tryParseJson(content) {
|
|
4021
3850
|
try {
|
|
4022
3851
|
return JSON.parse(content);
|
|
@@ -4033,34 +3862,9 @@ function safeBase64Encode(data) {
|
|
|
4033
3862
|
}
|
|
4034
3863
|
return Buffer.from(data).toString("base64");
|
|
4035
3864
|
}
|
|
4036
|
-
function getDestinationEndpointId(chainId) {
|
|
4037
|
-
switch (chainId) {
|
|
4038
|
-
case import_chains2.baseSepolia.id:
|
|
4039
|
-
return 40245;
|
|
4040
|
-
case import_chains2.sepolia.id:
|
|
4041
|
-
return 40161;
|
|
4042
|
-
case import_chains2.polygonAmoy.id:
|
|
4043
|
-
return 40267;
|
|
4044
|
-
case import_chains2.arbitrumSepolia.id:
|
|
4045
|
-
return 40231;
|
|
4046
|
-
case import_chains2.bscTestnet.id:
|
|
4047
|
-
return 40102;
|
|
4048
|
-
case import_chains2.base.id:
|
|
4049
|
-
return 30184;
|
|
4050
|
-
case import_chains2.mainnet.id:
|
|
4051
|
-
return 30101;
|
|
4052
|
-
case import_chains2.polygon.id:
|
|
4053
|
-
return 30109;
|
|
4054
|
-
case import_chains2.arbitrum.id:
|
|
4055
|
-
return 30110;
|
|
4056
|
-
case import_chains2.bsc.id:
|
|
4057
|
-
return 30102;
|
|
4058
|
-
}
|
|
4059
|
-
throw new Error(`Unsupported chain ID: ${chainId}`);
|
|
4060
|
-
}
|
|
4061
3865
|
|
|
4062
3866
|
// src/acpJobOffering.ts
|
|
4063
|
-
var
|
|
3867
|
+
var import_viem3 = require("viem");
|
|
4064
3868
|
var import_ajv = __toESM(require("ajv"));
|
|
4065
3869
|
var AcpJobOffering = class {
|
|
4066
3870
|
constructor(acpClient, acpContractClient, providerAddress, name, price, priceType = "fixed" /* FIXED */, requirement) {
|
|
@@ -4074,6 +3878,11 @@ var AcpJobOffering = class {
|
|
|
4074
3878
|
this.ajv = new import_ajv.default({ allErrors: true });
|
|
4075
3879
|
}
|
|
4076
3880
|
async initiateJob(serviceRequirement, evaluatorAddress, expiredAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
|
|
3881
|
+
if (this.providerAddress === this.acpClient.walletAddress) {
|
|
3882
|
+
throw new acpError_default(
|
|
3883
|
+
"Provider address cannot be the same as the client address"
|
|
3884
|
+
);
|
|
3885
|
+
}
|
|
4077
3886
|
if (this.requirement && typeof this.requirement === "object") {
|
|
4078
3887
|
const validator = this.ajv.compile(this.requirement);
|
|
4079
3888
|
const valid = validator(serviceRequirement);
|
|
@@ -4119,7 +3928,7 @@ var AcpJobOffering = class {
|
|
|
4119
3928
|
} else {
|
|
4120
3929
|
createJobPayload = this.acpContractClient.createJobWithAccount(
|
|
4121
3930
|
account.id,
|
|
4122
|
-
evaluatorAddress ||
|
|
3931
|
+
evaluatorAddress || import_viem3.zeroAddress,
|
|
4123
3932
|
fareAmount.amount,
|
|
4124
3933
|
fareAmount.fare.contractAddress,
|
|
4125
3934
|
expiredAt,
|
|
@@ -4260,43 +4069,25 @@ var AcpJob = class {
|
|
|
4260
4069
|
}
|
|
4261
4070
|
const feeAmount = new FareAmount(0, this.acpContractClient.config.baseFare);
|
|
4262
4071
|
const isPercentagePricing = this.priceType === "percentage" /* PERCENTAGE */;
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
this.
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
)
|
|
4278
|
-
);
|
|
4279
|
-
} else {
|
|
4280
|
-
operations.push(
|
|
4281
|
-
this.acpContractClient.createPayableMemo(
|
|
4282
|
-
this.id,
|
|
4283
|
-
content,
|
|
4284
|
-
amount.amount,
|
|
4285
|
-
recipient,
|
|
4286
|
-
isPercentagePricing ? BigInt(Math.round(this.priceValue * 1e4)) : feeAmount.amount,
|
|
4287
|
-
isPercentagePricing ? 3 /* PERCENTAGE_FEE */ : 0 /* NO_FEE */,
|
|
4288
|
-
2 /* TRANSACTION */,
|
|
4289
|
-
type,
|
|
4290
|
-
expiredAt,
|
|
4291
|
-
amount.fare.contractAddress
|
|
4292
|
-
)
|
|
4293
|
-
);
|
|
4294
|
-
}
|
|
4072
|
+
operations.push(
|
|
4073
|
+
this.acpContractClient.createPayableMemo(
|
|
4074
|
+
this.id,
|
|
4075
|
+
content,
|
|
4076
|
+
amount.amount,
|
|
4077
|
+
recipient,
|
|
4078
|
+
isPercentagePricing ? BigInt(Math.round(this.priceValue * 1e4)) : feeAmount.amount,
|
|
4079
|
+
isPercentagePricing ? 3 /* PERCENTAGE_FEE */ : 0 /* NO_FEE */,
|
|
4080
|
+
2 /* TRANSACTION */,
|
|
4081
|
+
type,
|
|
4082
|
+
expiredAt,
|
|
4083
|
+
amount.fare.contractAddress
|
|
4084
|
+
)
|
|
4085
|
+
);
|
|
4295
4086
|
return await this.acpContractClient.handleOperation(operations);
|
|
4296
4087
|
}
|
|
4297
4088
|
async payAndAcceptRequirement(reason) {
|
|
4298
4089
|
const memo = this.memos.find(
|
|
4299
|
-
(m) => m.nextPhase === 2 /* TRANSACTION */
|
|
4090
|
+
(m) => m.nextPhase === 2 /* TRANSACTION */
|
|
4300
4091
|
);
|
|
4301
4092
|
if (!memo) {
|
|
4302
4093
|
throw new acpError_default("No notification memo found");
|
|
@@ -4405,8 +4196,8 @@ var AcpJob = class {
|
|
|
4405
4196
|
return await this.acpContractClient.handleOperation(operations);
|
|
4406
4197
|
}
|
|
4407
4198
|
async deliver(deliverable) {
|
|
4408
|
-
if (this.
|
|
4409
|
-
throw new acpError_default("
|
|
4199
|
+
if (this.phase !== 2 /* TRANSACTION */) {
|
|
4200
|
+
throw new acpError_default("Job is not in transaction phase");
|
|
4410
4201
|
}
|
|
4411
4202
|
const operations = [];
|
|
4412
4203
|
operations.push(
|
|
@@ -4424,9 +4215,6 @@ var AcpJob = class {
|
|
|
4424
4215
|
if (this.latestMemo?.nextPhase !== 3 /* EVALUATION */) {
|
|
4425
4216
|
throw new acpError_default("No transaction memo found");
|
|
4426
4217
|
}
|
|
4427
|
-
if (amount.fare.chainId !== this.acpContractClient.config.chain.id) {
|
|
4428
|
-
return await this.deliverCrossChainPayable(this.clientAddress, amount);
|
|
4429
|
-
}
|
|
4430
4218
|
const operations = [];
|
|
4431
4219
|
operations.push(
|
|
4432
4220
|
this.acpContractClient.approveAllowance(
|
|
@@ -4439,6 +4227,7 @@ var AcpJob = class {
|
|
|
4439
4227
|
operations.push(
|
|
4440
4228
|
this.acpContractClient.createPayableMemo(
|
|
4441
4229
|
this.id,
|
|
4230
|
+
// memoContent.url,
|
|
4442
4231
|
preparePayload(deliverable),
|
|
4443
4232
|
amount.amount,
|
|
4444
4233
|
this.clientAddress,
|
|
@@ -4557,57 +4346,6 @@ var AcpJob = class {
|
|
|
4557
4346
|
waitMs = Math.min(waitMs * 2, maxWaitMs);
|
|
4558
4347
|
}
|
|
4559
4348
|
}
|
|
4560
|
-
async deliverCrossChainPayable(recipient, amount, isRequest = false) {
|
|
4561
|
-
if (!amount.fare.chainId) {
|
|
4562
|
-
throw new acpError_default("Chain ID is required for cross chain payable");
|
|
4563
|
-
}
|
|
4564
|
-
const chainId = amount.fare.chainId;
|
|
4565
|
-
const assetManagerAddress = await this.acpContractClient.getAssetManager();
|
|
4566
|
-
const tokenBalance = await this.acpContractClient.getERC20Balance(
|
|
4567
|
-
chainId,
|
|
4568
|
-
amount.fare.contractAddress,
|
|
4569
|
-
this.acpContractClient.agentWalletAddress
|
|
4570
|
-
);
|
|
4571
|
-
if (tokenBalance < amount.amount) {
|
|
4572
|
-
throw new acpError_default("Insufficient token balance for cross chain payable");
|
|
4573
|
-
}
|
|
4574
|
-
const currentAllowance = await this.acpContractClient.getERC20Allowance(
|
|
4575
|
-
chainId,
|
|
4576
|
-
amount.fare.contractAddress,
|
|
4577
|
-
this.acpContractClient.agentWalletAddress,
|
|
4578
|
-
assetManagerAddress
|
|
4579
|
-
);
|
|
4580
|
-
const approveAllowanceOperation = this.acpContractClient.approveAllowance(
|
|
4581
|
-
amount.amount + currentAllowance,
|
|
4582
|
-
amount.fare.contractAddress,
|
|
4583
|
-
assetManagerAddress
|
|
4584
|
-
);
|
|
4585
|
-
await this.acpContractClient.handleOperation(
|
|
4586
|
-
[approveAllowanceOperation],
|
|
4587
|
-
chainId
|
|
4588
|
-
);
|
|
4589
|
-
const tokenSymbol = await this.acpContractClient.getERC20Symbol(
|
|
4590
|
-
chainId,
|
|
4591
|
-
amount.fare.contractAddress
|
|
4592
|
-
);
|
|
4593
|
-
const createMemoOperation = this.acpContractClient.createCrossChainPayableMemo(
|
|
4594
|
-
this.id,
|
|
4595
|
-
`Performing cross chain payable transfer of ${(0, import_viem5.formatUnits)(
|
|
4596
|
-
amount.amount,
|
|
4597
|
-
amount.fare.decimals
|
|
4598
|
-
)} ${tokenSymbol} to ${recipient}`,
|
|
4599
|
-
amount.fare.contractAddress,
|
|
4600
|
-
amount.amount,
|
|
4601
|
-
recipient,
|
|
4602
|
-
BigInt(0),
|
|
4603
|
-
0 /* NO_FEE */,
|
|
4604
|
-
isRequest ? 6 /* PAYABLE_REQUEST */ : 7 /* PAYABLE_TRANSFER */,
|
|
4605
|
-
new Date(Date.now() + 1e3 * 60 * 5),
|
|
4606
|
-
isRequest ? 2 /* TRANSACTION */ : 4 /* COMPLETED */,
|
|
4607
|
-
getDestinationEndpointId(chainId)
|
|
4608
|
-
);
|
|
4609
|
-
await this.acpContractClient.handleOperation([createMemoOperation]);
|
|
4610
|
-
}
|
|
4611
4349
|
[util.inspect.custom]() {
|
|
4612
4350
|
return {
|
|
4613
4351
|
id: this.id,
|
|
@@ -4631,7 +4369,7 @@ var acpJob_default = AcpJob;
|
|
|
4631
4369
|
// src/acpMemo.ts
|
|
4632
4370
|
var import_util = __toESM(require("util"));
|
|
4633
4371
|
var AcpMemo = class {
|
|
4634
|
-
constructor(contractClient, id, type, content, nextPhase, status, senderAddress, signedReason, expiry, payableDetails, txHash, signedTxHash
|
|
4372
|
+
constructor(contractClient, id, type, content, nextPhase, status, senderAddress, signedReason, expiry, payableDetails, txHash, signedTxHash) {
|
|
4635
4373
|
this.contractClient = contractClient;
|
|
4636
4374
|
this.id = id;
|
|
4637
4375
|
this.type = type;
|
|
@@ -4644,21 +4382,13 @@ var AcpMemo = class {
|
|
|
4644
4382
|
this.payableDetails = payableDetails;
|
|
4645
4383
|
this.txHash = txHash;
|
|
4646
4384
|
this.signedTxHash = signedTxHash;
|
|
4647
|
-
this.state = state;
|
|
4648
4385
|
if (this.payableDetails) {
|
|
4649
4386
|
this.payableDetails.amount = BigInt(this.payableDetails.amount);
|
|
4650
4387
|
this.payableDetails.feeAmount = BigInt(this.payableDetails.feeAmount);
|
|
4651
4388
|
}
|
|
4652
|
-
this.structuredContent = tryParseJson(this.content) || void 0;
|
|
4653
|
-
}
|
|
4654
|
-
get payloadType() {
|
|
4655
|
-
return this.structuredContent?.type;
|
|
4656
|
-
}
|
|
4657
|
-
getStructuredContent() {
|
|
4658
|
-
return this.structuredContent;
|
|
4659
4389
|
}
|
|
4660
4390
|
async create(jobId, isSecured = true) {
|
|
4661
|
-
return
|
|
4391
|
+
return this.contractClient.createMemo(
|
|
4662
4392
|
jobId,
|
|
4663
4393
|
this.content,
|
|
4664
4394
|
this.type,
|
|
@@ -4706,10 +4436,31 @@ var AcpAccount = class {
|
|
|
4706
4436
|
}
|
|
4707
4437
|
};
|
|
4708
4438
|
|
|
4439
|
+
// src/acpClient.ts
|
|
4440
|
+
var import_axios = __toESM(require("axios"));
|
|
4441
|
+
|
|
4442
|
+
// src/acpAgent.ts
|
|
4443
|
+
var AcpAgent = class {
|
|
4444
|
+
constructor(args) {
|
|
4445
|
+
this.id = String(args.id);
|
|
4446
|
+
this.name = args.name;
|
|
4447
|
+
this.contractAddress = args.contractAddress;
|
|
4448
|
+
this.walletAddress = args.walletAddress;
|
|
4449
|
+
this.jobOfferings = Object.freeze([...args.jobOfferings]);
|
|
4450
|
+
this.description = args.description;
|
|
4451
|
+
this.twitterHandle = args.twitterHandle;
|
|
4452
|
+
this.metrics = args.metrics;
|
|
4453
|
+
this.resources = args.resources;
|
|
4454
|
+
}
|
|
4455
|
+
};
|
|
4456
|
+
var acpAgent_default = AcpAgent;
|
|
4457
|
+
|
|
4709
4458
|
// src/acpClient.ts
|
|
4710
4459
|
var { version } = require_package();
|
|
4711
4460
|
var AcpClient = class {
|
|
4712
4461
|
constructor(options) {
|
|
4462
|
+
this.accessToken = null;
|
|
4463
|
+
this.accessTokenInflight = null;
|
|
4713
4464
|
this.contractClients = Array.isArray(options.acpContractClient) ? options.acpContractClient : [options.acpContractClient];
|
|
4714
4465
|
if (this.contractClients.length === 0) {
|
|
4715
4466
|
throw new acpError_default("ACP contract client is required");
|
|
@@ -4721,10 +4472,86 @@ var AcpClient = class {
|
|
|
4721
4472
|
);
|
|
4722
4473
|
}
|
|
4723
4474
|
});
|
|
4475
|
+
this.acpClient = import_axios.default.create({
|
|
4476
|
+
baseURL: `${this.acpUrl}/api`,
|
|
4477
|
+
headers: {
|
|
4478
|
+
"wallet-address": this.walletAddress
|
|
4479
|
+
}
|
|
4480
|
+
});
|
|
4481
|
+
this.noAuthAcpClient = this.acpClient.create({
|
|
4482
|
+
baseURL: `${this.acpUrl}/api`
|
|
4483
|
+
});
|
|
4484
|
+
this.acpClient.interceptors.request.use(async (config) => {
|
|
4485
|
+
const accessToken = await this.getAccessToken();
|
|
4486
|
+
config.headers["authorization"] = `Bearer ${accessToken}`;
|
|
4487
|
+
return config;
|
|
4488
|
+
});
|
|
4724
4489
|
this.onNewTask = options.onNewTask;
|
|
4725
4490
|
this.onEvaluate = options.onEvaluate || this.defaultOnEvaluate;
|
|
4726
4491
|
this.init(options.skipSocketConnection);
|
|
4727
4492
|
}
|
|
4493
|
+
async getAccessToken() {
|
|
4494
|
+
if (this.accessTokenInflight) {
|
|
4495
|
+
return await this.accessTokenInflight;
|
|
4496
|
+
}
|
|
4497
|
+
let refreshToken = this.accessToken ? false : true;
|
|
4498
|
+
if (this.accessToken) {
|
|
4499
|
+
const decodedToken = (0, import_jwt_decode.jwtDecode)(this.accessToken);
|
|
4500
|
+
if (decodedToken.exp && decodedToken.exp - 60 * 5 < Math.floor(Date.now() / 1e3)) {
|
|
4501
|
+
refreshToken = true;
|
|
4502
|
+
}
|
|
4503
|
+
}
|
|
4504
|
+
if (!refreshToken) {
|
|
4505
|
+
return this.accessToken;
|
|
4506
|
+
}
|
|
4507
|
+
this.accessTokenInflight = (async () => {
|
|
4508
|
+
this.accessToken = await this.refreshToken();
|
|
4509
|
+
return this.accessToken;
|
|
4510
|
+
})().finally(() => {
|
|
4511
|
+
this.accessTokenInflight = null;
|
|
4512
|
+
});
|
|
4513
|
+
return await this.accessTokenInflight;
|
|
4514
|
+
}
|
|
4515
|
+
async refreshToken() {
|
|
4516
|
+
const challenge = await this.getAuthChallenge();
|
|
4517
|
+
const signature = await this.acpContractClient.signTypedData(challenge);
|
|
4518
|
+
const verified = await this.verifyAuthChallenge(
|
|
4519
|
+
challenge.message["walletAddress"],
|
|
4520
|
+
challenge.message["nonce"],
|
|
4521
|
+
challenge.message["expiresAt"],
|
|
4522
|
+
signature
|
|
4523
|
+
);
|
|
4524
|
+
return verified.accessToken;
|
|
4525
|
+
}
|
|
4526
|
+
async getAuthChallenge() {
|
|
4527
|
+
try {
|
|
4528
|
+
const response = await this.noAuthAcpClient.get("/auth/challenge", {
|
|
4529
|
+
params: {
|
|
4530
|
+
walletAddress: this.walletAddress
|
|
4531
|
+
}
|
|
4532
|
+
});
|
|
4533
|
+
return response.data.data;
|
|
4534
|
+
} catch (err) {
|
|
4535
|
+
console.error(
|
|
4536
|
+
"Failed to get auth challenge",
|
|
4537
|
+
err.response?.data
|
|
4538
|
+
);
|
|
4539
|
+
throw new acpError_default("Failed to get auth challenge", err);
|
|
4540
|
+
}
|
|
4541
|
+
}
|
|
4542
|
+
async verifyAuthChallenge(walletAddress, nonce, expiresAt, signature) {
|
|
4543
|
+
try {
|
|
4544
|
+
const response = await this.noAuthAcpClient.post("/auth/verify-typed-signature", {
|
|
4545
|
+
walletAddress,
|
|
4546
|
+
nonce,
|
|
4547
|
+
expiresAt,
|
|
4548
|
+
signature
|
|
4549
|
+
});
|
|
4550
|
+
return response.data.data;
|
|
4551
|
+
} catch (err) {
|
|
4552
|
+
throw new acpError_default("Failed to verify auth challenge", err);
|
|
4553
|
+
}
|
|
4554
|
+
}
|
|
4728
4555
|
contractClientByAddress(address) {
|
|
4729
4556
|
if (!address) {
|
|
4730
4557
|
return this.contractClients[0];
|
|
@@ -4753,9 +4580,13 @@ var AcpClient = class {
|
|
|
4753
4580
|
if (skipSocketConnection) {
|
|
4754
4581
|
return;
|
|
4755
4582
|
}
|
|
4583
|
+
console.log("Initializing socket");
|
|
4756
4584
|
const socket = (0, import_socket.io)(this.acpUrl, {
|
|
4757
|
-
auth: {
|
|
4758
|
-
|
|
4585
|
+
auth: async (cb) => {
|
|
4586
|
+
cb({
|
|
4587
|
+
walletAddress: this.walletAddress,
|
|
4588
|
+
accessToken: await this.getAccessToken()
|
|
4589
|
+
});
|
|
4759
4590
|
},
|
|
4760
4591
|
extraHeaders: {
|
|
4761
4592
|
"x-sdk-version": version,
|
|
@@ -4769,87 +4600,23 @@ var AcpClient = class {
|
|
|
4769
4600
|
console.log("Joined ACP Room");
|
|
4770
4601
|
callback(true);
|
|
4771
4602
|
});
|
|
4772
|
-
socket.on(
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
const job = new acpJob_default(
|
|
4778
|
-
this,
|
|
4779
|
-
data.id,
|
|
4780
|
-
data.clientAddress,
|
|
4781
|
-
data.providerAddress,
|
|
4782
|
-
data.evaluatorAddress,
|
|
4783
|
-
data.price,
|
|
4784
|
-
data.priceTokenAddress,
|
|
4785
|
-
data.memos.map((memo) => {
|
|
4786
|
-
return new acpMemo_default(
|
|
4787
|
-
this.contractClientByAddress(data.contractAddress),
|
|
4788
|
-
memo.id,
|
|
4789
|
-
memo.memoType,
|
|
4790
|
-
memo.content,
|
|
4791
|
-
memo.nextPhase,
|
|
4792
|
-
memo.status,
|
|
4793
|
-
memo.senderAddress,
|
|
4794
|
-
memo.signedReason,
|
|
4795
|
-
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
4796
|
-
memo.payableDetails,
|
|
4797
|
-
memo.txHash,
|
|
4798
|
-
memo.signedTxHash,
|
|
4799
|
-
memo.state
|
|
4800
|
-
);
|
|
4801
|
-
}),
|
|
4802
|
-
data.phase,
|
|
4803
|
-
data.context,
|
|
4804
|
-
data.contractAddress,
|
|
4805
|
-
data.netPayableAmount
|
|
4806
|
-
);
|
|
4807
|
-
this.onEvaluate(job);
|
|
4808
|
-
}
|
|
4603
|
+
socket.on("onEvaluate" /* ON_EVALUATE */, async (data, callback) => {
|
|
4604
|
+
callback(true);
|
|
4605
|
+
if (this.onEvaluate) {
|
|
4606
|
+
const job = this._hydrateJob(data);
|
|
4607
|
+
this.onEvaluate(job);
|
|
4809
4608
|
}
|
|
4810
|
-
);
|
|
4811
|
-
socket.on(
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
data.clientAddress,
|
|
4820
|
-
data.providerAddress,
|
|
4821
|
-
data.evaluatorAddress,
|
|
4822
|
-
data.price,
|
|
4823
|
-
data.priceTokenAddress,
|
|
4824
|
-
data.memos.map((memo) => {
|
|
4825
|
-
return new acpMemo_default(
|
|
4826
|
-
this.contractClientByAddress(data.contractAddress),
|
|
4827
|
-
memo.id,
|
|
4828
|
-
memo.memoType,
|
|
4829
|
-
memo.content,
|
|
4830
|
-
memo.nextPhase,
|
|
4831
|
-
memo.status,
|
|
4832
|
-
memo.senderAddress,
|
|
4833
|
-
memo.signedReason,
|
|
4834
|
-
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
4835
|
-
memo.payableDetails,
|
|
4836
|
-
memo.txHash,
|
|
4837
|
-
memo.signedTxHash,
|
|
4838
|
-
memo.state
|
|
4839
|
-
);
|
|
4840
|
-
}),
|
|
4841
|
-
data.phase,
|
|
4842
|
-
data.context,
|
|
4843
|
-
data.contractAddress,
|
|
4844
|
-
data.netPayableAmount
|
|
4845
|
-
);
|
|
4846
|
-
this.onNewTask(
|
|
4847
|
-
job,
|
|
4848
|
-
job.memos.find((m) => m.id == data.memoToSign)
|
|
4849
|
-
);
|
|
4850
|
-
}
|
|
4609
|
+
});
|
|
4610
|
+
socket.on("onNewTask" /* ON_NEW_TASK */, async (data, callback) => {
|
|
4611
|
+
callback(true);
|
|
4612
|
+
if (this.onNewTask) {
|
|
4613
|
+
const job = this._hydrateJob(data);
|
|
4614
|
+
this.onNewTask(
|
|
4615
|
+
job,
|
|
4616
|
+
job.memos.find((m) => m.id == data.memoToSign)
|
|
4617
|
+
);
|
|
4851
4618
|
}
|
|
4852
|
-
);
|
|
4619
|
+
});
|
|
4853
4620
|
const cleanup = async () => {
|
|
4854
4621
|
if (socket) {
|
|
4855
4622
|
socket.disconnect();
|
|
@@ -4859,77 +4626,156 @@ var AcpClient = class {
|
|
|
4859
4626
|
process.on("SIGINT", cleanup);
|
|
4860
4627
|
process.on("SIGTERM", cleanup);
|
|
4861
4628
|
}
|
|
4862
|
-
async
|
|
4863
|
-
|
|
4629
|
+
async _fetch(url, method = "GET", params, data, errCallback) {
|
|
4630
|
+
try {
|
|
4631
|
+
const response = await this.acpClient.request({
|
|
4632
|
+
url,
|
|
4633
|
+
method,
|
|
4634
|
+
params,
|
|
4635
|
+
data
|
|
4636
|
+
});
|
|
4637
|
+
return response.data.data;
|
|
4638
|
+
} catch (err) {
|
|
4639
|
+
if (err instanceof import_axios.AxiosError) {
|
|
4640
|
+
if (errCallback) {
|
|
4641
|
+
errCallback(err);
|
|
4642
|
+
} else if (err.response?.data.error?.message) {
|
|
4643
|
+
throw new acpError_default(err.response?.data.error.message);
|
|
4644
|
+
}
|
|
4645
|
+
} else {
|
|
4646
|
+
throw new acpError_default(
|
|
4647
|
+
`Failed to fetch ACP Endpoint: ${url} (network error)`,
|
|
4648
|
+
err
|
|
4649
|
+
);
|
|
4650
|
+
}
|
|
4651
|
+
}
|
|
4652
|
+
}
|
|
4653
|
+
_hydrateMemo(memo, contractClient) {
|
|
4654
|
+
try {
|
|
4655
|
+
return new acpMemo_default(
|
|
4656
|
+
contractClient,
|
|
4657
|
+
memo.id,
|
|
4658
|
+
memo.memoType,
|
|
4659
|
+
memo.content,
|
|
4660
|
+
memo.nextPhase,
|
|
4661
|
+
memo.status,
|
|
4662
|
+
memo.senderAddress,
|
|
4663
|
+
memo.signedReason,
|
|
4664
|
+
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
4665
|
+
memo.payableDetails,
|
|
4666
|
+
memo.txHash,
|
|
4667
|
+
memo.signedTxHash
|
|
4668
|
+
);
|
|
4669
|
+
} catch (err) {
|
|
4670
|
+
throw new acpError_default(`Failed to hydrate memo ${memo.id}`, err);
|
|
4671
|
+
}
|
|
4672
|
+
}
|
|
4673
|
+
_hydrateJob(job) {
|
|
4674
|
+
try {
|
|
4675
|
+
return new acpJob_default(
|
|
4676
|
+
this,
|
|
4677
|
+
job.id,
|
|
4678
|
+
job.clientAddress,
|
|
4679
|
+
job.providerAddress,
|
|
4680
|
+
job.evaluatorAddress,
|
|
4681
|
+
job.price,
|
|
4682
|
+
job.priceTokenAddress,
|
|
4683
|
+
job.memos.map(
|
|
4684
|
+
(memo) => this._hydrateMemo(
|
|
4685
|
+
memo,
|
|
4686
|
+
this.contractClientByAddress(job.contractAddress)
|
|
4687
|
+
)
|
|
4688
|
+
),
|
|
4689
|
+
job.phase,
|
|
4690
|
+
job.context,
|
|
4691
|
+
job.contractAddress,
|
|
4692
|
+
job.netPayableAmount
|
|
4693
|
+
);
|
|
4694
|
+
} catch (err) {
|
|
4695
|
+
throw new acpError_default(`Failed to hydrate job ${job.id}`, err);
|
|
4696
|
+
}
|
|
4697
|
+
}
|
|
4698
|
+
_hydrateJobs(rawJobs, options) {
|
|
4699
|
+
const jobs = rawJobs.map((job) => {
|
|
4700
|
+
try {
|
|
4701
|
+
return this._hydrateJob(job);
|
|
4702
|
+
} catch (err) {
|
|
4703
|
+
console.warn(`${options?.logPrefix ?? "Skipped"}`, err);
|
|
4704
|
+
return null;
|
|
4705
|
+
}
|
|
4706
|
+
});
|
|
4707
|
+
return jobs.filter((job) => !!job);
|
|
4708
|
+
}
|
|
4709
|
+
_hydrateAgent(agent) {
|
|
4710
|
+
const acpContractClient = this.contractClients.find(
|
|
4711
|
+
(client) => client.contractAddress.toLowerCase() === agent.contractAddress.toLowerCase()
|
|
4712
|
+
);
|
|
4713
|
+
if (!acpContractClient) {
|
|
4714
|
+
throw new acpError_default("ACP contract client not found");
|
|
4715
|
+
}
|
|
4716
|
+
return new acpAgent_default({
|
|
4717
|
+
id: agent.id,
|
|
4718
|
+
name: agent.name,
|
|
4719
|
+
description: agent.description,
|
|
4720
|
+
jobOfferings: agent.jobs.map((jobs) => {
|
|
4721
|
+
return new acpJobOffering_default(
|
|
4722
|
+
this,
|
|
4723
|
+
acpContractClient,
|
|
4724
|
+
agent.walletAddress,
|
|
4725
|
+
jobs.name,
|
|
4726
|
+
jobs.priceV2.value,
|
|
4727
|
+
jobs.priceV2.type,
|
|
4728
|
+
jobs.requirement
|
|
4729
|
+
);
|
|
4730
|
+
}),
|
|
4731
|
+
contractAddress: agent.contractAddress,
|
|
4732
|
+
twitterHandle: agent.twitterHandle,
|
|
4733
|
+
walletAddress: agent.walletAddress,
|
|
4734
|
+
metrics: agent.metrics,
|
|
4735
|
+
resources: agent.resources
|
|
4736
|
+
});
|
|
4737
|
+
}
|
|
4738
|
+
async browseAgents(keyword, options = {}) {
|
|
4739
|
+
const {
|
|
4864
4740
|
cluster,
|
|
4865
|
-
|
|
4866
|
-
|
|
4741
|
+
sortBy,
|
|
4742
|
+
topK = 5,
|
|
4867
4743
|
graduationStatus,
|
|
4868
4744
|
onlineStatus,
|
|
4869
4745
|
showHiddenOfferings
|
|
4870
4746
|
} = options;
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
if (
|
|
4877
|
-
|
|
4878
|
-
}
|
|
4879
|
-
if (this.walletAddress) {
|
|
4880
|
-
url += `&walletAddressesToExclude=${this.walletAddress}`;
|
|
4747
|
+
const params = {
|
|
4748
|
+
search: keyword
|
|
4749
|
+
};
|
|
4750
|
+
params.top_k = topK;
|
|
4751
|
+
params.walletAddressesToExclude = this.walletAddress;
|
|
4752
|
+
if (sortBy && sortBy.length > 0) {
|
|
4753
|
+
params.sortBy = sortBy.join(",");
|
|
4881
4754
|
}
|
|
4882
4755
|
if (cluster) {
|
|
4883
|
-
|
|
4756
|
+
params.cluster = cluster;
|
|
4884
4757
|
}
|
|
4885
4758
|
if (graduationStatus) {
|
|
4886
|
-
|
|
4759
|
+
params.graduationStatus = graduationStatus;
|
|
4887
4760
|
}
|
|
4888
4761
|
if (onlineStatus) {
|
|
4889
|
-
|
|
4762
|
+
params.onlineStatus = onlineStatus;
|
|
4890
4763
|
}
|
|
4891
4764
|
if (showHiddenOfferings) {
|
|
4892
|
-
|
|
4765
|
+
params.showHiddenOfferings = true;
|
|
4893
4766
|
}
|
|
4894
|
-
const
|
|
4895
|
-
const data = await response.json();
|
|
4767
|
+
const agents = await this._fetch("/agents/v4/search", "GET", params) || [];
|
|
4896
4768
|
const availableContractClientAddresses = this.contractClients.map(
|
|
4897
4769
|
(client) => client.contractAddress.toLowerCase()
|
|
4898
4770
|
);
|
|
4899
|
-
return
|
|
4771
|
+
return agents.filter(
|
|
4900
4772
|
(agent) => agent.walletAddress.toLowerCase() !== this.walletAddress.toLowerCase()
|
|
4901
4773
|
).filter(
|
|
4902
4774
|
(agent) => availableContractClientAddresses.includes(
|
|
4903
4775
|
agent.contractAddress.toLowerCase()
|
|
4904
4776
|
)
|
|
4905
4777
|
).map((agent) => {
|
|
4906
|
-
|
|
4907
|
-
(client) => client.contractAddress.toLowerCase() === agent.contractAddress.toLowerCase()
|
|
4908
|
-
);
|
|
4909
|
-
if (!acpContractClient) {
|
|
4910
|
-
throw new acpError_default("ACP contract client not found");
|
|
4911
|
-
}
|
|
4912
|
-
return {
|
|
4913
|
-
id: agent.id,
|
|
4914
|
-
name: agent.name,
|
|
4915
|
-
description: agent.description,
|
|
4916
|
-
jobOfferings: agent.jobs.map((jobs) => {
|
|
4917
|
-
return new acpJobOffering_default(
|
|
4918
|
-
this,
|
|
4919
|
-
acpContractClient,
|
|
4920
|
-
agent.walletAddress,
|
|
4921
|
-
jobs.name,
|
|
4922
|
-
jobs.priceV2.value,
|
|
4923
|
-
jobs.priceV2.type,
|
|
4924
|
-
jobs.requirement
|
|
4925
|
-
);
|
|
4926
|
-
}),
|
|
4927
|
-
contractAddress: agent.contractAddress,
|
|
4928
|
-
twitterHandle: agent.twitterHandle,
|
|
4929
|
-
walletAddress: agent.walletAddress,
|
|
4930
|
-
metrics: agent.metrics,
|
|
4931
|
-
resources: agent.resources
|
|
4932
|
-
};
|
|
4778
|
+
return this._hydrateAgent(agent);
|
|
4933
4779
|
});
|
|
4934
4780
|
}
|
|
4935
4781
|
async initiateJob(providerAddress, serviceRequirement, fareAmount, evaluatorAddress, expiredAt = new Date(Date.now() + 1e3 * 60 * 60 * 24)) {
|
|
@@ -4949,7 +4795,7 @@ var AcpClient = class {
|
|
|
4949
4795
|
baseAcpConfig.contractAddress,
|
|
4950
4796
|
baseAcpX402Config.contractAddress
|
|
4951
4797
|
].includes(this.acpContractClient.config.contractAddress);
|
|
4952
|
-
const defaultEvaluatorAddress = isV1 && !evaluatorAddress ? this.walletAddress :
|
|
4798
|
+
const defaultEvaluatorAddress = isV1 && !evaluatorAddress ? this.walletAddress : import_viem4.zeroAddress;
|
|
4953
4799
|
const chainId = this.acpContractClient.config.chain.id;
|
|
4954
4800
|
const isUsdcPaymentToken = USDC_TOKEN_ADDRESS[chainId].toLowerCase() === fareAmount.fare.contractAddress.toLowerCase();
|
|
4955
4801
|
const isX402Job = this.acpContractClient.config.x402Config && isUsdcPaymentToken;
|
|
@@ -4999,257 +4845,137 @@ var AcpClient = class {
|
|
|
4999
4845
|
return jobId;
|
|
5000
4846
|
}
|
|
5001
4847
|
async getActiveJobs(page = 1, pageSize = 10) {
|
|
5002
|
-
const
|
|
5003
|
-
|
|
5004
|
-
|
|
4848
|
+
const rawJobs = await this._fetch("/jobs/active", "GET", {
|
|
4849
|
+
pagination: {
|
|
4850
|
+
page,
|
|
4851
|
+
pageSize
|
|
4852
|
+
}
|
|
4853
|
+
});
|
|
4854
|
+
return this._hydrateJobs(rawJobs ?? [], { logPrefix: "Active jobs" });
|
|
5005
4855
|
}
|
|
5006
4856
|
async getPendingMemoJobs(page = 1, pageSize = 10) {
|
|
5007
|
-
const
|
|
5008
|
-
|
|
5009
|
-
|
|
4857
|
+
const rawJobs = await this._fetch("/jobs/pending-memos", "GET", {
|
|
4858
|
+
pagination: {
|
|
4859
|
+
page,
|
|
4860
|
+
pageSize
|
|
4861
|
+
}
|
|
4862
|
+
});
|
|
4863
|
+
return this._hydrateJobs(rawJobs ?? [], { logPrefix: "Pending memo jobs" });
|
|
5010
4864
|
}
|
|
5011
4865
|
async getCompletedJobs(page = 1, pageSize = 10) {
|
|
5012
|
-
const
|
|
5013
|
-
|
|
5014
|
-
|
|
4866
|
+
const rawJobs = await this._fetch("/jobs/completed", "GET", {
|
|
4867
|
+
pagination: {
|
|
4868
|
+
page,
|
|
4869
|
+
pageSize
|
|
4870
|
+
}
|
|
4871
|
+
});
|
|
4872
|
+
return this._hydrateJobs(rawJobs ?? [], { logPrefix: "Completed jobs" });
|
|
5015
4873
|
}
|
|
5016
4874
|
async getCancelledJobs(page = 1, pageSize = 10) {
|
|
5017
|
-
const
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
async _fetchJobList(url) {
|
|
5022
|
-
let response;
|
|
5023
|
-
try {
|
|
5024
|
-
response = await fetch(url, {
|
|
5025
|
-
headers: {
|
|
5026
|
-
"wallet-address": this.walletAddress
|
|
5027
|
-
}
|
|
5028
|
-
});
|
|
5029
|
-
} catch (err) {
|
|
5030
|
-
throw new acpError_default("Failed to fetch ACP jobs (network error)", err);
|
|
5031
|
-
}
|
|
5032
|
-
let data;
|
|
5033
|
-
try {
|
|
5034
|
-
data = await response.json();
|
|
5035
|
-
} catch (err) {
|
|
5036
|
-
throw new acpError_default("Failed to parse ACP jobs response", err);
|
|
5037
|
-
}
|
|
5038
|
-
if (data.error) {
|
|
5039
|
-
throw new acpError_default(data.error.message);
|
|
5040
|
-
}
|
|
5041
|
-
return data.data;
|
|
5042
|
-
}
|
|
5043
|
-
_hydrateJobs(rawJobs, options) {
|
|
5044
|
-
const jobs = [];
|
|
5045
|
-
const errors = [];
|
|
5046
|
-
for (const job of rawJobs) {
|
|
5047
|
-
try {
|
|
5048
|
-
const memos = job.memos.map(
|
|
5049
|
-
(memo) => new acpMemo_default(
|
|
5050
|
-
this.contractClientByAddress(job.contractAddress),
|
|
5051
|
-
memo.id,
|
|
5052
|
-
memo.memoType,
|
|
5053
|
-
memo.content,
|
|
5054
|
-
memo.nextPhase,
|
|
5055
|
-
memo.status,
|
|
5056
|
-
memo.senderAddress,
|
|
5057
|
-
memo.signedReason,
|
|
5058
|
-
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
5059
|
-
memo.payableDetails,
|
|
5060
|
-
memo.txHash,
|
|
5061
|
-
memo.signedTxHash,
|
|
5062
|
-
memo.state
|
|
5063
|
-
)
|
|
5064
|
-
);
|
|
5065
|
-
jobs.push(
|
|
5066
|
-
new acpJob_default(
|
|
5067
|
-
this,
|
|
5068
|
-
job.id,
|
|
5069
|
-
job.clientAddress,
|
|
5070
|
-
job.providerAddress,
|
|
5071
|
-
job.evaluatorAddress,
|
|
5072
|
-
job.price,
|
|
5073
|
-
job.priceTokenAddress,
|
|
5074
|
-
memos,
|
|
5075
|
-
job.phase,
|
|
5076
|
-
job.context,
|
|
5077
|
-
job.contractAddress,
|
|
5078
|
-
job.netPayableAmount
|
|
5079
|
-
)
|
|
5080
|
-
);
|
|
5081
|
-
} catch (err) {
|
|
5082
|
-
errors.push({ jobId: job.id, error: err });
|
|
4875
|
+
const rawJobs = await this._fetch("/jobs/cancelled", "GET", {
|
|
4876
|
+
pagination: {
|
|
4877
|
+
page,
|
|
4878
|
+
pageSize
|
|
5083
4879
|
}
|
|
5084
|
-
}
|
|
5085
|
-
|
|
5086
|
-
console.warn(
|
|
5087
|
-
`${options?.logPrefix ?? "Skipped"} ${errors.length} malformed job(s)
|
|
5088
|
-
` + JSON.stringify(
|
|
5089
|
-
errors.map((e) => ({ jobId: e.jobId, message: e.error.message })),
|
|
5090
|
-
null,
|
|
5091
|
-
2
|
|
5092
|
-
)
|
|
5093
|
-
);
|
|
5094
|
-
}
|
|
5095
|
-
return jobs;
|
|
4880
|
+
});
|
|
4881
|
+
return this._hydrateJobs(rawJobs ?? [], { logPrefix: "Cancelled jobs" });
|
|
5096
4882
|
}
|
|
5097
4883
|
async getJobById(jobId) {
|
|
5098
|
-
const
|
|
5099
|
-
let response;
|
|
5100
|
-
try {
|
|
5101
|
-
response = await fetch(url, {
|
|
5102
|
-
headers: {
|
|
5103
|
-
"wallet-address": this.acpContractClient.walletAddress
|
|
5104
|
-
}
|
|
5105
|
-
});
|
|
5106
|
-
} catch (err) {
|
|
5107
|
-
throw new acpError_default("Failed to fetch job by id (network error)", err);
|
|
5108
|
-
}
|
|
5109
|
-
let data;
|
|
5110
|
-
try {
|
|
5111
|
-
data = await response.json();
|
|
5112
|
-
} catch (err) {
|
|
5113
|
-
throw new acpError_default("Failed to parse job by id response", err);
|
|
5114
|
-
}
|
|
5115
|
-
if (data.error) {
|
|
5116
|
-
throw new acpError_default(data.error.message);
|
|
5117
|
-
}
|
|
5118
|
-
const job = data.data;
|
|
4884
|
+
const job = await this._fetch(`/jobs/${jobId}`);
|
|
5119
4885
|
if (!job) {
|
|
5120
|
-
return
|
|
5121
|
-
}
|
|
5122
|
-
try {
|
|
5123
|
-
const memos = job.memos.map(
|
|
5124
|
-
(memo) => new acpMemo_default(
|
|
5125
|
-
this.contractClientByAddress(job.contractAddress),
|
|
5126
|
-
memo.id,
|
|
5127
|
-
memo.memoType,
|
|
5128
|
-
memo.content,
|
|
5129
|
-
memo.nextPhase,
|
|
5130
|
-
memo.status,
|
|
5131
|
-
memo.senderAddress,
|
|
5132
|
-
memo.signedReason,
|
|
5133
|
-
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
5134
|
-
memo.payableDetails,
|
|
5135
|
-
memo.txHash,
|
|
5136
|
-
memo.signedTxHash,
|
|
5137
|
-
memo.state
|
|
5138
|
-
)
|
|
5139
|
-
);
|
|
5140
|
-
return new acpJob_default(
|
|
5141
|
-
this,
|
|
5142
|
-
job.id,
|
|
5143
|
-
job.clientAddress,
|
|
5144
|
-
job.providerAddress,
|
|
5145
|
-
job.evaluatorAddress,
|
|
5146
|
-
job.price,
|
|
5147
|
-
job.priceTokenAddress,
|
|
5148
|
-
memos,
|
|
5149
|
-
job.phase,
|
|
5150
|
-
job.context,
|
|
5151
|
-
job.contractAddress,
|
|
5152
|
-
job.netPayableAmount
|
|
5153
|
-
);
|
|
5154
|
-
} catch (err) {
|
|
5155
|
-
throw new acpError_default(`Failed to hydrate job ${jobId}`, err);
|
|
4886
|
+
return null;
|
|
5156
4887
|
}
|
|
4888
|
+
return this._hydrateJob(job);
|
|
5157
4889
|
}
|
|
5158
4890
|
async getMemoById(jobId, memoId) {
|
|
5159
|
-
const
|
|
5160
|
-
|
|
5161
|
-
|
|
5162
|
-
response = await fetch(url, {
|
|
5163
|
-
headers: {
|
|
5164
|
-
"wallet-address": this.walletAddress
|
|
5165
|
-
}
|
|
5166
|
-
});
|
|
5167
|
-
} catch (err) {
|
|
5168
|
-
throw new acpError_default("Failed to fetch memo by id (network error)", err);
|
|
5169
|
-
}
|
|
5170
|
-
let data;
|
|
5171
|
-
try {
|
|
5172
|
-
data = await response.json();
|
|
5173
|
-
} catch (err) {
|
|
5174
|
-
throw new acpError_default("Failed to parse memo by id response", err);
|
|
5175
|
-
}
|
|
5176
|
-
if (data.error) {
|
|
5177
|
-
throw new acpError_default(data.error.message);
|
|
5178
|
-
}
|
|
5179
|
-
const memo = data.data;
|
|
4891
|
+
const memo = await this._fetch(
|
|
4892
|
+
`/jobs/${jobId}/memos/${memoId}`
|
|
4893
|
+
);
|
|
5180
4894
|
if (!memo) {
|
|
5181
|
-
return
|
|
5182
|
-
}
|
|
5183
|
-
try {
|
|
5184
|
-
return new acpMemo_default(
|
|
5185
|
-
this.contractClientByAddress(memo.contractAddress),
|
|
5186
|
-
memo.id,
|
|
5187
|
-
memo.memoType,
|
|
5188
|
-
memo.content,
|
|
5189
|
-
memo.nextPhase,
|
|
5190
|
-
memo.status,
|
|
5191
|
-
memo.senderAddress,
|
|
5192
|
-
memo.signedReason,
|
|
5193
|
-
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
5194
|
-
memo.payableDetails,
|
|
5195
|
-
memo.txHash,
|
|
5196
|
-
memo.signedTxHash,
|
|
5197
|
-
memo.state
|
|
5198
|
-
);
|
|
5199
|
-
} catch (err) {
|
|
5200
|
-
throw new acpError_default(
|
|
5201
|
-
`Failed to hydrate memo ${memoId} for job ${jobId}`,
|
|
5202
|
-
err
|
|
5203
|
-
);
|
|
4895
|
+
return null;
|
|
5204
4896
|
}
|
|
4897
|
+
return this._hydrateMemo(
|
|
4898
|
+
memo,
|
|
4899
|
+
this.contractClientByAddress(memo.contractAddress)
|
|
4900
|
+
);
|
|
5205
4901
|
}
|
|
5206
|
-
async getAgent(walletAddress) {
|
|
5207
|
-
const
|
|
5208
|
-
|
|
5209
|
-
|
|
5210
|
-
const
|
|
5211
|
-
if (
|
|
5212
|
-
|
|
4902
|
+
async getAgent(walletAddress, options = {}) {
|
|
4903
|
+
const params = {
|
|
4904
|
+
"filters[walletAddress]": walletAddress
|
|
4905
|
+
};
|
|
4906
|
+
const { showHiddenOfferings } = options;
|
|
4907
|
+
if (showHiddenOfferings) {
|
|
4908
|
+
params.showHiddenOfferings = true;
|
|
4909
|
+
}
|
|
4910
|
+
const agentsResponse = await this.noAuthAcpClient.get("/agents", {
|
|
4911
|
+
params
|
|
4912
|
+
});
|
|
4913
|
+
if (!agentsResponse.data) {
|
|
4914
|
+
return null;
|
|
5213
4915
|
}
|
|
5214
|
-
return
|
|
4916
|
+
return this._hydrateAgent(agentsResponse.data.data[0]);
|
|
5215
4917
|
}
|
|
5216
4918
|
async getAccountByJobId(jobId, acpContractClient) {
|
|
5217
|
-
|
|
5218
|
-
|
|
5219
|
-
|
|
5220
|
-
const data = await response.json();
|
|
5221
|
-
if (!data.data) {
|
|
5222
|
-
return null;
|
|
5223
|
-
}
|
|
5224
|
-
return new AcpAccount(
|
|
5225
|
-
acpContractClient || this.contractClients[0],
|
|
5226
|
-
data.data.id,
|
|
5227
|
-
data.data.clientAddress,
|
|
5228
|
-
data.data.providerAddress,
|
|
5229
|
-
data.data.metadata
|
|
5230
|
-
);
|
|
5231
|
-
} catch (error) {
|
|
5232
|
-
throw new acpError_default("Failed to get account by job id", error);
|
|
4919
|
+
const account = await this._fetch(`/accounts/job/${jobId}`);
|
|
4920
|
+
if (!account) {
|
|
4921
|
+
return null;
|
|
5233
4922
|
}
|
|
4923
|
+
return new AcpAccount(
|
|
4924
|
+
acpContractClient || this.contractClients[0],
|
|
4925
|
+
account.id,
|
|
4926
|
+
account.clientAddress,
|
|
4927
|
+
account.providerAddress,
|
|
4928
|
+
account.metadata
|
|
4929
|
+
);
|
|
5234
4930
|
}
|
|
5235
4931
|
async getByClientAndProvider(clientAddress, providerAddress, acpContractClient) {
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
4932
|
+
const response = await this._fetch(
|
|
4933
|
+
`/accounts/client/${clientAddress}/provider/${providerAddress}`,
|
|
4934
|
+
"GET",
|
|
4935
|
+
{},
|
|
4936
|
+
{},
|
|
4937
|
+
(err) => {
|
|
4938
|
+
if (err.response?.status === 404) {
|
|
4939
|
+
console.warn("Account not found by client and provider");
|
|
4940
|
+
return;
|
|
4941
|
+
}
|
|
4942
|
+
throw new acpError_default("Failed to get account by client and provider", err);
|
|
5242
4943
|
}
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
-
|
|
4944
|
+
);
|
|
4945
|
+
if (!response) {
|
|
4946
|
+
return null;
|
|
4947
|
+
}
|
|
4948
|
+
return new AcpAccount(
|
|
4949
|
+
acpContractClient || this.contractClients[0],
|
|
4950
|
+
response.id,
|
|
4951
|
+
response.clientAddress,
|
|
4952
|
+
response.providerAddress,
|
|
4953
|
+
response.metadata
|
|
4954
|
+
);
|
|
4955
|
+
}
|
|
4956
|
+
async createMemoContent(jobId, content) {
|
|
4957
|
+
const response = await this._fetch(
|
|
4958
|
+
`/memo-contents`,
|
|
4959
|
+
"POST",
|
|
4960
|
+
{},
|
|
4961
|
+
{
|
|
4962
|
+
data: {
|
|
4963
|
+
onChainJobId: jobId,
|
|
4964
|
+
content
|
|
4965
|
+
}
|
|
4966
|
+
}
|
|
4967
|
+
);
|
|
4968
|
+
if (!response) {
|
|
4969
|
+
throw new acpError_default("Failed to create memo content");
|
|
5252
4970
|
}
|
|
4971
|
+
return response;
|
|
4972
|
+
}
|
|
4973
|
+
async getTokenBalances() {
|
|
4974
|
+
const response = await this._fetch(
|
|
4975
|
+
`/chains/token-balances`,
|
|
4976
|
+
"GET"
|
|
4977
|
+
);
|
|
4978
|
+
return response;
|
|
5253
4979
|
}
|
|
5254
4980
|
};
|
|
5255
4981
|
var acpClient_default = AcpClient;
|
|
@@ -5258,10 +4984,10 @@ var acpClient_default = AcpClient;
|
|
|
5258
4984
|
var import_core = require("@aa-sdk/core");
|
|
5259
4985
|
var import_infra2 = require("@account-kit/infra");
|
|
5260
4986
|
var import_smart_contracts = require("@account-kit/smart-contracts");
|
|
5261
|
-
var
|
|
4987
|
+
var import_viem6 = require("viem");
|
|
5262
4988
|
|
|
5263
4989
|
// src/acpX402.ts
|
|
5264
|
-
var
|
|
4990
|
+
var import_viem5 = require("viem");
|
|
5265
4991
|
var import_crypto = require("crypto");
|
|
5266
4992
|
var AcpX402 = class {
|
|
5267
4993
|
constructor(config, sessionKeyClient, publicClient) {
|
|
@@ -5319,7 +5045,7 @@ var AcpX402 = class {
|
|
|
5319
5045
|
contracts: [
|
|
5320
5046
|
{
|
|
5321
5047
|
address: USDC_CONTRACT,
|
|
5322
|
-
abi:
|
|
5048
|
+
abi: import_viem5.erc20Abi,
|
|
5323
5049
|
functionName: "name"
|
|
5324
5050
|
},
|
|
5325
5051
|
{
|
|
@@ -5536,7 +5262,7 @@ var AcpContractClient = class _AcpContractClient extends baseAcpContractClient_d
|
|
|
5536
5262
|
const contractLogs = result.logs.filter((log) => {
|
|
5537
5263
|
return log.address.toLowerCase() === this.contractAddress.toLowerCase();
|
|
5538
5264
|
}).map(
|
|
5539
|
-
(log) => (0,
|
|
5265
|
+
(log) => (0, import_viem6.decodeEventLog)({
|
|
5540
5266
|
abi: this.abi,
|
|
5541
5267
|
data: log.data,
|
|
5542
5268
|
topics: log.topics
|
|
@@ -5552,7 +5278,7 @@ var AcpContractClient = class _AcpContractClient extends baseAcpContractClient_d
|
|
|
5552
5278
|
}
|
|
5553
5279
|
createJob(providerAddress, evaluatorAddress, expireAt, paymentTokenAddress, budgetBaseUnit, metadata, isX402Job) {
|
|
5554
5280
|
try {
|
|
5555
|
-
const data = (0,
|
|
5281
|
+
const data = (0, import_viem6.encodeFunctionData)({
|
|
5556
5282
|
abi: this.abi,
|
|
5557
5283
|
functionName: isX402Job ? "createJobWithX402" : "createJob",
|
|
5558
5284
|
args: [
|
|
@@ -5572,7 +5298,7 @@ var AcpContractClient = class _AcpContractClient extends baseAcpContractClient_d
|
|
|
5572
5298
|
}
|
|
5573
5299
|
setBudgetWithPaymentToken(jobId, budgetBaseUnit, paymentTokenAddress = this.config.baseFare.contractAddress) {
|
|
5574
5300
|
try {
|
|
5575
|
-
const data = (0,
|
|
5301
|
+
const data = (0, import_viem6.encodeFunctionData)({
|
|
5576
5302
|
abi: this.abi,
|
|
5577
5303
|
functionName: "setBudgetWithPaymentToken",
|
|
5578
5304
|
args: [jobId, budgetBaseUnit, paymentTokenAddress]
|
|
@@ -5588,7 +5314,7 @@ var AcpContractClient = class _AcpContractClient extends baseAcpContractClient_d
|
|
|
5588
5314
|
}
|
|
5589
5315
|
createPayableMemo(jobId, content, amountBaseUnit, recipient, feeAmountBaseUnit, feeType, nextPhase, type, expiredAt, token = this.config.baseFare.contractAddress, secured = true) {
|
|
5590
5316
|
try {
|
|
5591
|
-
const data = (0,
|
|
5317
|
+
const data = (0, import_viem6.encodeFunctionData)({
|
|
5592
5318
|
abi: this.abi,
|
|
5593
5319
|
functionName: "createPayableMemo",
|
|
5594
5320
|
args: [
|
|
@@ -5628,12 +5354,12 @@ var AcpContractClient = class _AcpContractClient extends baseAcpContractClient_d
|
|
|
5628
5354
|
async performX402Request(url, version2, budget, signature) {
|
|
5629
5355
|
return await this.acpX402.performRequest(url, version2, budget, signature);
|
|
5630
5356
|
}
|
|
5631
|
-
async getAssetManager() {
|
|
5632
|
-
throw new Error("Asset Manager not supported");
|
|
5633
|
-
}
|
|
5634
5357
|
getAcpVersion() {
|
|
5635
5358
|
return "1";
|
|
5636
5359
|
}
|
|
5360
|
+
signTypedData(typedData) {
|
|
5361
|
+
return this.sessionKeyClient.signTypedData({ typedData });
|
|
5362
|
+
}
|
|
5637
5363
|
};
|
|
5638
5364
|
var acpContractClient_default = AcpContractClient;
|
|
5639
5365
|
|
|
@@ -5641,7 +5367,7 @@ var acpContractClient_default = AcpContractClient;
|
|
|
5641
5367
|
var import_core2 = require("@aa-sdk/core");
|
|
5642
5368
|
var import_infra3 = require("@account-kit/infra");
|
|
5643
5369
|
var import_smart_contracts2 = require("@account-kit/smart-contracts");
|
|
5644
|
-
var
|
|
5370
|
+
var import_viem7 = require("viem");
|
|
5645
5371
|
|
|
5646
5372
|
// src/abis/jobManagerAbi.ts
|
|
5647
5373
|
var JOB_MANAGER_ABI = [
|
|
@@ -6345,1234 +6071,76 @@ var JOB_MANAGER_ABI = [
|
|
|
6345
6071
|
var jobManagerAbi_default = JOB_MANAGER_ABI;
|
|
6346
6072
|
|
|
6347
6073
|
// src/contractClients/acpContractClientV2.ts
|
|
6348
|
-
var
|
|
6349
|
-
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6355
|
-
|
|
6356
|
-
|
|
6357
|
-
|
|
6358
|
-
|
|
6359
|
-
|
|
6360
|
-
|
|
6361
|
-
|
|
6362
|
-
|
|
6363
|
-
|
|
6364
|
-
|
|
6365
|
-
|
|
6366
|
-
|
|
6367
|
-
|
|
6368
|
-
|
|
6369
|
-
|
|
6370
|
-
|
|
6371
|
-
|
|
6372
|
-
|
|
6373
|
-
|
|
6374
|
-
|
|
6375
|
-
|
|
6376
|
-
|
|
6377
|
-
|
|
6378
|
-
|
|
6379
|
-
|
|
6380
|
-
|
|
6381
|
-
|
|
6382
|
-
|
|
6383
|
-
|
|
6384
|
-
|
|
6385
|
-
|
|
6386
|
-
|
|
6387
|
-
|
|
6388
|
-
|
|
6389
|
-
|
|
6390
|
-
|
|
6391
|
-
|
|
6392
|
-
|
|
6393
|
-
|
|
6394
|
-
|
|
6395
|
-
|
|
6396
|
-
|
|
6397
|
-
|
|
6398
|
-
|
|
6399
|
-
|
|
6400
|
-
|
|
6401
|
-
|
|
6402
|
-
|
|
6403
|
-
|
|
6404
|
-
|
|
6405
|
-
|
|
6406
|
-
|
|
6407
|
-
|
|
6408
|
-
|
|
6409
|
-
|
|
6410
|
-
|
|
6411
|
-
|
|
6412
|
-
|
|
6413
|
-
|
|
6414
|
-
|
|
6415
|
-
|
|
6416
|
-
},
|
|
6417
|
-
{ inputs: [], name: "ZeroAcpContractAddress", type: "error" },
|
|
6418
|
-
{ inputs: [], name: "ZeroAddressRecipient", type: "error" },
|
|
6419
|
-
{ inputs: [], name: "ZeroAddressToken", type: "error" },
|
|
6420
|
-
{ inputs: [], name: "ZeroAssetManagerAddress", type: "error" },
|
|
6421
|
-
{ inputs: [], name: "ZeroJobManagerAddress", type: "error" },
|
|
6422
|
-
{
|
|
6423
|
-
anonymous: false,
|
|
6424
|
-
inputs: [
|
|
6425
|
-
{
|
|
6426
|
-
indexed: false,
|
|
6427
|
-
internalType: "uint64",
|
|
6428
|
-
name: "version",
|
|
6429
|
-
type: "uint64"
|
|
6430
|
-
}
|
|
6431
|
-
],
|
|
6432
|
-
name: "Initialized",
|
|
6433
|
-
type: "event"
|
|
6434
|
-
},
|
|
6435
|
-
{
|
|
6436
|
-
anonymous: false,
|
|
6437
|
-
inputs: [
|
|
6438
|
-
{
|
|
6439
|
-
indexed: true,
|
|
6440
|
-
internalType: "uint256",
|
|
6441
|
-
name: "memoId",
|
|
6442
|
-
type: "uint256"
|
|
6443
|
-
},
|
|
6444
|
-
{
|
|
6445
|
-
indexed: true,
|
|
6446
|
-
internalType: "address",
|
|
6447
|
-
name: "approver",
|
|
6448
|
-
type: "address"
|
|
6449
|
-
},
|
|
6450
|
-
{ indexed: false, internalType: "bool", name: "approved", type: "bool" },
|
|
6451
|
-
{
|
|
6452
|
-
indexed: false,
|
|
6453
|
-
internalType: "string",
|
|
6454
|
-
name: "reason",
|
|
6455
|
-
type: "string"
|
|
6456
|
-
}
|
|
6457
|
-
],
|
|
6458
|
-
name: "MemoSigned",
|
|
6459
|
-
type: "event"
|
|
6460
|
-
},
|
|
6461
|
-
{
|
|
6462
|
-
anonymous: false,
|
|
6463
|
-
inputs: [
|
|
6464
|
-
{
|
|
6465
|
-
indexed: true,
|
|
6466
|
-
internalType: "uint256",
|
|
6467
|
-
name: "memoId",
|
|
6468
|
-
type: "uint256"
|
|
6469
|
-
},
|
|
6470
|
-
{
|
|
6471
|
-
indexed: false,
|
|
6472
|
-
internalType: "enum ACPTypes.MemoState",
|
|
6473
|
-
name: "oldState",
|
|
6474
|
-
type: "uint8"
|
|
6475
|
-
},
|
|
6476
|
-
{
|
|
6477
|
-
indexed: false,
|
|
6478
|
-
internalType: "enum ACPTypes.MemoState",
|
|
6479
|
-
name: "newState",
|
|
6480
|
-
type: "uint8"
|
|
6481
|
-
}
|
|
6482
|
-
],
|
|
6483
|
-
name: "MemoStateUpdated",
|
|
6484
|
-
type: "event"
|
|
6485
|
-
},
|
|
6486
|
-
{
|
|
6487
|
-
anonymous: false,
|
|
6488
|
-
inputs: [
|
|
6489
|
-
{
|
|
6490
|
-
indexed: true,
|
|
6491
|
-
internalType: "uint256",
|
|
6492
|
-
name: "memoId",
|
|
6493
|
-
type: "uint256"
|
|
6494
|
-
},
|
|
6495
|
-
{
|
|
6496
|
-
indexed: true,
|
|
6497
|
-
internalType: "uint256",
|
|
6498
|
-
name: "jobId",
|
|
6499
|
-
type: "uint256"
|
|
6500
|
-
},
|
|
6501
|
-
{
|
|
6502
|
-
indexed: true,
|
|
6503
|
-
internalType: "address",
|
|
6504
|
-
name: "sender",
|
|
6505
|
-
type: "address"
|
|
6506
|
-
},
|
|
6507
|
-
{
|
|
6508
|
-
indexed: false,
|
|
6509
|
-
internalType: "enum ACPTypes.MemoType",
|
|
6510
|
-
name: "memoType",
|
|
6511
|
-
type: "uint8"
|
|
6512
|
-
},
|
|
6513
|
-
{
|
|
6514
|
-
indexed: false,
|
|
6515
|
-
internalType: "enum ACPTypes.JobPhase",
|
|
6516
|
-
name: "nextPhase",
|
|
6517
|
-
type: "uint8"
|
|
6518
|
-
},
|
|
6519
|
-
{
|
|
6520
|
-
indexed: false,
|
|
6521
|
-
internalType: "string",
|
|
6522
|
-
name: "content",
|
|
6523
|
-
type: "string"
|
|
6524
|
-
}
|
|
6525
|
-
],
|
|
6526
|
-
name: "NewMemo",
|
|
6527
|
-
type: "event"
|
|
6528
|
-
},
|
|
6529
|
-
{
|
|
6530
|
-
anonymous: false,
|
|
6531
|
-
inputs: [
|
|
6532
|
-
{
|
|
6533
|
-
indexed: true,
|
|
6534
|
-
internalType: "uint256",
|
|
6535
|
-
name: "jobId",
|
|
6536
|
-
type: "uint256"
|
|
6537
|
-
},
|
|
6538
|
-
{
|
|
6539
|
-
indexed: true,
|
|
6540
|
-
internalType: "uint256",
|
|
6541
|
-
name: "memoId",
|
|
6542
|
-
type: "uint256"
|
|
6543
|
-
},
|
|
6544
|
-
{
|
|
6545
|
-
indexed: true,
|
|
6546
|
-
internalType: "address",
|
|
6547
|
-
name: "sender",
|
|
6548
|
-
type: "address"
|
|
6549
|
-
},
|
|
6550
|
-
{
|
|
6551
|
-
indexed: false,
|
|
6552
|
-
internalType: "address",
|
|
6553
|
-
name: "token",
|
|
6554
|
-
type: "address"
|
|
6555
|
-
},
|
|
6556
|
-
{
|
|
6557
|
-
indexed: false,
|
|
6558
|
-
internalType: "uint256",
|
|
6559
|
-
name: "amount",
|
|
6560
|
-
type: "uint256"
|
|
6561
|
-
}
|
|
6562
|
-
],
|
|
6563
|
-
name: "PayableFeeRefunded",
|
|
6564
|
-
type: "event"
|
|
6565
|
-
},
|
|
6566
|
-
{
|
|
6567
|
-
anonymous: false,
|
|
6568
|
-
inputs: [
|
|
6569
|
-
{
|
|
6570
|
-
indexed: true,
|
|
6571
|
-
internalType: "uint256",
|
|
6572
|
-
name: "jobId",
|
|
6573
|
-
type: "uint256"
|
|
6574
|
-
},
|
|
6575
|
-
{
|
|
6576
|
-
indexed: true,
|
|
6577
|
-
internalType: "uint256",
|
|
6578
|
-
name: "memoId",
|
|
6579
|
-
type: "uint256"
|
|
6580
|
-
},
|
|
6581
|
-
{
|
|
6582
|
-
indexed: true,
|
|
6583
|
-
internalType: "address",
|
|
6584
|
-
name: "sender",
|
|
6585
|
-
type: "address"
|
|
6586
|
-
},
|
|
6587
|
-
{
|
|
6588
|
-
indexed: false,
|
|
6589
|
-
internalType: "address",
|
|
6590
|
-
name: "token",
|
|
6591
|
-
type: "address"
|
|
6592
|
-
},
|
|
6593
|
-
{
|
|
6594
|
-
indexed: false,
|
|
6595
|
-
internalType: "uint256",
|
|
6596
|
-
name: "amount",
|
|
6597
|
-
type: "uint256"
|
|
6598
|
-
}
|
|
6599
|
-
],
|
|
6600
|
-
name: "PayableFundsRefunded",
|
|
6601
|
-
type: "event"
|
|
6602
|
-
},
|
|
6603
|
-
{
|
|
6604
|
-
anonymous: false,
|
|
6605
|
-
inputs: [
|
|
6606
|
-
{
|
|
6607
|
-
indexed: true,
|
|
6608
|
-
internalType: "uint256",
|
|
6609
|
-
name: "memoId",
|
|
6610
|
-
type: "uint256"
|
|
6611
|
-
},
|
|
6612
|
-
{
|
|
6613
|
-
indexed: true,
|
|
6614
|
-
internalType: "uint256",
|
|
6615
|
-
name: "jobId",
|
|
6616
|
-
type: "uint256"
|
|
6617
|
-
},
|
|
6618
|
-
{
|
|
6619
|
-
indexed: true,
|
|
6620
|
-
internalType: "address",
|
|
6621
|
-
name: "executor",
|
|
6622
|
-
type: "address"
|
|
6623
|
-
},
|
|
6624
|
-
{
|
|
6625
|
-
indexed: false,
|
|
6626
|
-
internalType: "uint256",
|
|
6627
|
-
name: "amount",
|
|
6628
|
-
type: "uint256"
|
|
6629
|
-
}
|
|
6630
|
-
],
|
|
6631
|
-
name: "PayableMemoExecuted",
|
|
6632
|
-
type: "event"
|
|
6633
|
-
},
|
|
6634
|
-
{
|
|
6635
|
-
anonymous: false,
|
|
6636
|
-
inputs: [
|
|
6637
|
-
{ indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
|
|
6638
|
-
{
|
|
6639
|
-
indexed: true,
|
|
6640
|
-
internalType: "bytes32",
|
|
6641
|
-
name: "previousAdminRole",
|
|
6642
|
-
type: "bytes32"
|
|
6643
|
-
},
|
|
6644
|
-
{
|
|
6645
|
-
indexed: true,
|
|
6646
|
-
internalType: "bytes32",
|
|
6647
|
-
name: "newAdminRole",
|
|
6648
|
-
type: "bytes32"
|
|
6649
|
-
}
|
|
6650
|
-
],
|
|
6651
|
-
name: "RoleAdminChanged",
|
|
6652
|
-
type: "event"
|
|
6653
|
-
},
|
|
6654
|
-
{
|
|
6655
|
-
anonymous: false,
|
|
6656
|
-
inputs: [
|
|
6657
|
-
{ indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
|
|
6658
|
-
{
|
|
6659
|
-
indexed: true,
|
|
6660
|
-
internalType: "address",
|
|
6661
|
-
name: "account",
|
|
6662
|
-
type: "address"
|
|
6663
|
-
},
|
|
6664
|
-
{
|
|
6665
|
-
indexed: true,
|
|
6666
|
-
internalType: "address",
|
|
6667
|
-
name: "sender",
|
|
6668
|
-
type: "address"
|
|
6669
|
-
}
|
|
6670
|
-
],
|
|
6671
|
-
name: "RoleGranted",
|
|
6672
|
-
type: "event"
|
|
6673
|
-
},
|
|
6674
|
-
{
|
|
6675
|
-
anonymous: false,
|
|
6676
|
-
inputs: [
|
|
6677
|
-
{ indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
|
|
6678
|
-
{
|
|
6679
|
-
indexed: true,
|
|
6680
|
-
internalType: "address",
|
|
6681
|
-
name: "account",
|
|
6682
|
-
type: "address"
|
|
6683
|
-
},
|
|
6684
|
-
{
|
|
6685
|
-
indexed: true,
|
|
6686
|
-
internalType: "address",
|
|
6687
|
-
name: "sender",
|
|
6688
|
-
type: "address"
|
|
6689
|
-
}
|
|
6690
|
-
],
|
|
6691
|
-
name: "RoleRevoked",
|
|
6692
|
-
type: "event"
|
|
6693
|
-
},
|
|
6694
|
-
{
|
|
6695
|
-
anonymous: false,
|
|
6696
|
-
inputs: [
|
|
6697
|
-
{
|
|
6698
|
-
indexed: true,
|
|
6699
|
-
internalType: "address",
|
|
6700
|
-
name: "implementation",
|
|
6701
|
-
type: "address"
|
|
6702
|
-
}
|
|
6703
|
-
],
|
|
6704
|
-
name: "Upgraded",
|
|
6705
|
-
type: "event"
|
|
6706
|
-
},
|
|
6707
|
-
{
|
|
6708
|
-
inputs: [],
|
|
6709
|
-
name: "ACP_CONTRACT_ROLE",
|
|
6710
|
-
outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
|
|
6711
|
-
stateMutability: "view",
|
|
6712
|
-
type: "function"
|
|
6713
|
-
},
|
|
6714
|
-
{
|
|
6715
|
-
inputs: [],
|
|
6716
|
-
name: "ADMIN_ROLE",
|
|
6717
|
-
outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
|
|
6718
|
-
stateMutability: "view",
|
|
6719
|
-
type: "function"
|
|
6720
|
-
},
|
|
6721
|
-
{
|
|
6722
|
-
inputs: [],
|
|
6723
|
-
name: "DEFAULT_ADMIN_ROLE",
|
|
6724
|
-
outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
|
|
6725
|
-
stateMutability: "view",
|
|
6726
|
-
type: "function"
|
|
6727
|
-
},
|
|
6728
|
-
{
|
|
6729
|
-
inputs: [],
|
|
6730
|
-
name: "UPGRADE_INTERFACE_VERSION",
|
|
6731
|
-
outputs: [{ internalType: "string", name: "", type: "string" }],
|
|
6732
|
-
stateMutability: "view",
|
|
6733
|
-
type: "function"
|
|
6734
|
-
},
|
|
6735
|
-
{
|
|
6736
|
-
inputs: [],
|
|
6737
|
-
name: "acpContract",
|
|
6738
|
-
outputs: [{ internalType: "address", name: "", type: "address" }],
|
|
6739
|
-
stateMutability: "view",
|
|
6740
|
-
type: "function"
|
|
6741
|
-
},
|
|
6742
|
-
{
|
|
6743
|
-
inputs: [
|
|
6744
|
-
{ internalType: "uint256", name: "memoId", type: "uint256" },
|
|
6745
|
-
{ internalType: "address", name: "sender", type: "address" },
|
|
6746
|
-
{ internalType: "bool", name: "approved", type: "bool" },
|
|
6747
|
-
{ internalType: "string", name: "reason", type: "string" }
|
|
6748
|
-
],
|
|
6749
|
-
name: "approveMemo",
|
|
6750
|
-
outputs: [],
|
|
6751
|
-
stateMutability: "nonpayable",
|
|
6752
|
-
type: "function"
|
|
6753
|
-
},
|
|
6754
|
-
{
|
|
6755
|
-
inputs: [],
|
|
6756
|
-
name: "assetManager",
|
|
6757
|
-
outputs: [{ internalType: "address", name: "", type: "address" }],
|
|
6758
|
-
stateMutability: "view",
|
|
6759
|
-
type: "function"
|
|
6760
|
-
},
|
|
6761
|
-
{
|
|
6762
|
-
inputs: [
|
|
6763
|
-
{ internalType: "uint256[]", name: "memoIds", type: "uint256[]" },
|
|
6764
|
-
{ internalType: "bool", name: "approved", type: "bool" },
|
|
6765
|
-
{ internalType: "string", name: "reason", type: "string" }
|
|
6766
|
-
],
|
|
6767
|
-
name: "bulkApproveMemos",
|
|
6768
|
-
outputs: [],
|
|
6769
|
-
stateMutability: "nonpayable",
|
|
6770
|
-
type: "function"
|
|
6771
|
-
},
|
|
6772
|
-
{
|
|
6773
|
-
inputs: [
|
|
6774
|
-
{ internalType: "uint256", name: "memoId", type: "uint256" },
|
|
6775
|
-
{ internalType: "address", name: "user", type: "address" }
|
|
6776
|
-
],
|
|
6777
|
-
name: "canApproveMemo",
|
|
6778
|
-
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
6779
|
-
stateMutability: "view",
|
|
6780
|
-
type: "function"
|
|
6781
|
-
},
|
|
6782
|
-
{
|
|
6783
|
-
inputs: [
|
|
6784
|
-
{ internalType: "uint256", name: "jobId", type: "uint256" },
|
|
6785
|
-
{ internalType: "address", name: "sender", type: "address" },
|
|
6786
|
-
{ internalType: "string", name: "content", type: "string" },
|
|
6787
|
-
{
|
|
6788
|
-
internalType: "enum ACPTypes.MemoType",
|
|
6789
|
-
name: "memoType",
|
|
6790
|
-
type: "uint8"
|
|
6791
|
-
},
|
|
6792
|
-
{ internalType: "bool", name: "isSecured", type: "bool" },
|
|
6793
|
-
{
|
|
6794
|
-
internalType: "enum ACPTypes.JobPhase",
|
|
6795
|
-
name: "nextPhase",
|
|
6796
|
-
type: "uint8"
|
|
6797
|
-
},
|
|
6798
|
-
{ internalType: "string", name: "metadata", type: "string" }
|
|
6799
|
-
],
|
|
6800
|
-
name: "createMemo",
|
|
6801
|
-
outputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
|
|
6802
|
-
stateMutability: "nonpayable",
|
|
6803
|
-
type: "function"
|
|
6804
|
-
},
|
|
6805
|
-
{
|
|
6806
|
-
inputs: [
|
|
6807
|
-
{ internalType: "uint256", name: "jobId", type: "uint256" },
|
|
6808
|
-
{ internalType: "address", name: "sender", type: "address" },
|
|
6809
|
-
{ internalType: "string", name: "content", type: "string" },
|
|
6810
|
-
{
|
|
6811
|
-
internalType: "enum ACPTypes.MemoType",
|
|
6812
|
-
name: "memoType",
|
|
6813
|
-
type: "uint8"
|
|
6814
|
-
},
|
|
6815
|
-
{ internalType: "bool", name: "isSecured", type: "bool" },
|
|
6816
|
-
{
|
|
6817
|
-
internalType: "enum ACPTypes.JobPhase",
|
|
6818
|
-
name: "nextPhase",
|
|
6819
|
-
type: "uint8"
|
|
6820
|
-
},
|
|
6821
|
-
{
|
|
6822
|
-
components: [
|
|
6823
|
-
{ internalType: "address", name: "token", type: "address" },
|
|
6824
|
-
{ internalType: "uint256", name: "amount", type: "uint256" },
|
|
6825
|
-
{ internalType: "address", name: "recipient", type: "address" },
|
|
6826
|
-
{ internalType: "uint256", name: "feeAmount", type: "uint256" },
|
|
6827
|
-
{
|
|
6828
|
-
internalType: "enum ACPTypes.FeeType",
|
|
6829
|
-
name: "feeType",
|
|
6830
|
-
type: "uint8"
|
|
6831
|
-
},
|
|
6832
|
-
{ internalType: "bool", name: "isExecuted", type: "bool" },
|
|
6833
|
-
{ internalType: "uint256", name: "expiredAt", type: "uint256" },
|
|
6834
|
-
{ internalType: "uint32", name: "lzSrcEid", type: "uint32" },
|
|
6835
|
-
{ internalType: "uint32", name: "lzDstEid", type: "uint32" }
|
|
6836
|
-
],
|
|
6837
|
-
internalType: "struct ACPTypes.PayableDetails",
|
|
6838
|
-
name: "payableDetails_",
|
|
6839
|
-
type: "tuple"
|
|
6840
|
-
},
|
|
6841
|
-
{ internalType: "uint256", name: "expiredAt", type: "uint256" }
|
|
6842
|
-
],
|
|
6843
|
-
name: "createPayableMemo",
|
|
6844
|
-
outputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
|
|
6845
|
-
stateMutability: "nonpayable",
|
|
6846
|
-
type: "function"
|
|
6847
|
-
},
|
|
6848
|
-
{
|
|
6849
|
-
inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
|
|
6850
|
-
name: "emergencyApproveMemo",
|
|
6851
|
-
outputs: [],
|
|
6852
|
-
stateMutability: "nonpayable",
|
|
6853
|
-
type: "function"
|
|
6854
|
-
},
|
|
6855
|
-
{
|
|
6856
|
-
inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
|
|
6857
|
-
name: "executePayableMemo",
|
|
6858
|
-
outputs: [],
|
|
6859
|
-
stateMutability: "nonpayable",
|
|
6860
|
-
type: "function"
|
|
6861
|
-
},
|
|
6862
|
-
{
|
|
6863
|
-
inputs: [],
|
|
6864
|
-
name: "getAssetManager",
|
|
6865
|
-
outputs: [{ internalType: "address", name: "", type: "address" }],
|
|
6866
|
-
stateMutability: "view",
|
|
6867
|
-
type: "function"
|
|
6868
|
-
},
|
|
6869
|
-
{
|
|
6870
|
-
inputs: [
|
|
6871
|
-
{ internalType: "uint256", name: "jobId", type: "uint256" },
|
|
6872
|
-
{ internalType: "uint256", name: "offset", type: "uint256" },
|
|
6873
|
-
{ internalType: "uint256", name: "limit", type: "uint256" }
|
|
6874
|
-
],
|
|
6875
|
-
name: "getJobMemos",
|
|
6876
|
-
outputs: [
|
|
6877
|
-
{
|
|
6878
|
-
components: [
|
|
6879
|
-
{ internalType: "uint256", name: "id", type: "uint256" },
|
|
6880
|
-
{ internalType: "uint256", name: "jobId", type: "uint256" },
|
|
6881
|
-
{ internalType: "address", name: "sender", type: "address" },
|
|
6882
|
-
{ internalType: "string", name: "content", type: "string" },
|
|
6883
|
-
{
|
|
6884
|
-
internalType: "enum ACPTypes.MemoType",
|
|
6885
|
-
name: "memoType",
|
|
6886
|
-
type: "uint8"
|
|
6887
|
-
},
|
|
6888
|
-
{ internalType: "uint256", name: "createdAt", type: "uint256" },
|
|
6889
|
-
{ internalType: "bool", name: "isApproved", type: "bool" },
|
|
6890
|
-
{ internalType: "address", name: "approvedBy", type: "address" },
|
|
6891
|
-
{ internalType: "uint256", name: "approvedAt", type: "uint256" },
|
|
6892
|
-
{ internalType: "bool", name: "requiresApproval", type: "bool" },
|
|
6893
|
-
{ internalType: "string", name: "metadata", type: "string" },
|
|
6894
|
-
{ internalType: "bool", name: "isSecured", type: "bool" },
|
|
6895
|
-
{
|
|
6896
|
-
internalType: "enum ACPTypes.JobPhase",
|
|
6897
|
-
name: "nextPhase",
|
|
6898
|
-
type: "uint8"
|
|
6899
|
-
},
|
|
6900
|
-
{ internalType: "uint256", name: "expiredAt", type: "uint256" },
|
|
6901
|
-
{
|
|
6902
|
-
internalType: "enum ACPTypes.MemoState",
|
|
6903
|
-
name: "state",
|
|
6904
|
-
type: "uint8"
|
|
6905
|
-
}
|
|
6906
|
-
],
|
|
6907
|
-
internalType: "struct ACPTypes.Memo[]",
|
|
6908
|
-
name: "memoArray",
|
|
6909
|
-
type: "tuple[]"
|
|
6910
|
-
},
|
|
6911
|
-
{ internalType: "uint256", name: "total", type: "uint256" }
|
|
6912
|
-
],
|
|
6913
|
-
stateMutability: "view",
|
|
6914
|
-
type: "function"
|
|
6915
|
-
},
|
|
6916
|
-
{
|
|
6917
|
-
inputs: [
|
|
6918
|
-
{ internalType: "uint256", name: "jobId", type: "uint256" },
|
|
6919
|
-
{ internalType: "enum ACPTypes.JobPhase", name: "phase", type: "uint8" },
|
|
6920
|
-
{ internalType: "uint256", name: "offset", type: "uint256" },
|
|
6921
|
-
{ internalType: "uint256", name: "limit", type: "uint256" }
|
|
6922
|
-
],
|
|
6923
|
-
name: "getJobMemosByPhase",
|
|
6924
|
-
outputs: [
|
|
6925
|
-
{
|
|
6926
|
-
components: [
|
|
6927
|
-
{ internalType: "uint256", name: "id", type: "uint256" },
|
|
6928
|
-
{ internalType: "uint256", name: "jobId", type: "uint256" },
|
|
6929
|
-
{ internalType: "address", name: "sender", type: "address" },
|
|
6930
|
-
{ internalType: "string", name: "content", type: "string" },
|
|
6931
|
-
{
|
|
6932
|
-
internalType: "enum ACPTypes.MemoType",
|
|
6933
|
-
name: "memoType",
|
|
6934
|
-
type: "uint8"
|
|
6935
|
-
},
|
|
6936
|
-
{ internalType: "uint256", name: "createdAt", type: "uint256" },
|
|
6937
|
-
{ internalType: "bool", name: "isApproved", type: "bool" },
|
|
6938
|
-
{ internalType: "address", name: "approvedBy", type: "address" },
|
|
6939
|
-
{ internalType: "uint256", name: "approvedAt", type: "uint256" },
|
|
6940
|
-
{ internalType: "bool", name: "requiresApproval", type: "bool" },
|
|
6941
|
-
{ internalType: "string", name: "metadata", type: "string" },
|
|
6942
|
-
{ internalType: "bool", name: "isSecured", type: "bool" },
|
|
6943
|
-
{
|
|
6944
|
-
internalType: "enum ACPTypes.JobPhase",
|
|
6945
|
-
name: "nextPhase",
|
|
6946
|
-
type: "uint8"
|
|
6947
|
-
},
|
|
6948
|
-
{ internalType: "uint256", name: "expiredAt", type: "uint256" },
|
|
6949
|
-
{
|
|
6950
|
-
internalType: "enum ACPTypes.MemoState",
|
|
6951
|
-
name: "state",
|
|
6952
|
-
type: "uint8"
|
|
6953
|
-
}
|
|
6954
|
-
],
|
|
6955
|
-
internalType: "struct ACPTypes.Memo[]",
|
|
6956
|
-
name: "memoArray",
|
|
6957
|
-
type: "tuple[]"
|
|
6958
|
-
},
|
|
6959
|
-
{ internalType: "uint256", name: "total", type: "uint256" }
|
|
6960
|
-
],
|
|
6961
|
-
stateMutability: "view",
|
|
6962
|
-
type: "function"
|
|
6963
|
-
},
|
|
6964
|
-
{
|
|
6965
|
-
inputs: [
|
|
6966
|
-
{ internalType: "uint256", name: "jobId", type: "uint256" },
|
|
6967
|
-
{
|
|
6968
|
-
internalType: "enum ACPTypes.MemoType",
|
|
6969
|
-
name: "memoType",
|
|
6970
|
-
type: "uint8"
|
|
6971
|
-
},
|
|
6972
|
-
{ internalType: "uint256", name: "offset", type: "uint256" },
|
|
6973
|
-
{ internalType: "uint256", name: "limit", type: "uint256" }
|
|
6974
|
-
],
|
|
6975
|
-
name: "getJobMemosByType",
|
|
6976
|
-
outputs: [
|
|
6977
|
-
{
|
|
6978
|
-
components: [
|
|
6979
|
-
{ internalType: "uint256", name: "id", type: "uint256" },
|
|
6980
|
-
{ internalType: "uint256", name: "jobId", type: "uint256" },
|
|
6981
|
-
{ internalType: "address", name: "sender", type: "address" },
|
|
6982
|
-
{ internalType: "string", name: "content", type: "string" },
|
|
6983
|
-
{
|
|
6984
|
-
internalType: "enum ACPTypes.MemoType",
|
|
6985
|
-
name: "memoType",
|
|
6986
|
-
type: "uint8"
|
|
6987
|
-
},
|
|
6988
|
-
{ internalType: "uint256", name: "createdAt", type: "uint256" },
|
|
6989
|
-
{ internalType: "bool", name: "isApproved", type: "bool" },
|
|
6990
|
-
{ internalType: "address", name: "approvedBy", type: "address" },
|
|
6991
|
-
{ internalType: "uint256", name: "approvedAt", type: "uint256" },
|
|
6992
|
-
{ internalType: "bool", name: "requiresApproval", type: "bool" },
|
|
6993
|
-
{ internalType: "string", name: "metadata", type: "string" },
|
|
6994
|
-
{ internalType: "bool", name: "isSecured", type: "bool" },
|
|
6995
|
-
{
|
|
6996
|
-
internalType: "enum ACPTypes.JobPhase",
|
|
6997
|
-
name: "nextPhase",
|
|
6998
|
-
type: "uint8"
|
|
6999
|
-
},
|
|
7000
|
-
{ internalType: "uint256", name: "expiredAt", type: "uint256" },
|
|
7001
|
-
{
|
|
7002
|
-
internalType: "enum ACPTypes.MemoState",
|
|
7003
|
-
name: "state",
|
|
7004
|
-
type: "uint8"
|
|
7005
|
-
}
|
|
7006
|
-
],
|
|
7007
|
-
internalType: "struct ACPTypes.Memo[]",
|
|
7008
|
-
name: "memoArray",
|
|
7009
|
-
type: "tuple[]"
|
|
7010
|
-
},
|
|
7011
|
-
{ internalType: "uint256", name: "total", type: "uint256" }
|
|
7012
|
-
],
|
|
7013
|
-
stateMutability: "view",
|
|
7014
|
-
type: "function"
|
|
7015
|
-
},
|
|
7016
|
-
{
|
|
7017
|
-
inputs: [],
|
|
7018
|
-
name: "getLocalEid",
|
|
7019
|
-
outputs: [{ internalType: "uint32", name: "", type: "uint32" }],
|
|
7020
|
-
stateMutability: "view",
|
|
7021
|
-
type: "function"
|
|
7022
|
-
},
|
|
7023
|
-
{
|
|
7024
|
-
inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
|
|
7025
|
-
name: "getMemo",
|
|
7026
|
-
outputs: [
|
|
7027
|
-
{
|
|
7028
|
-
components: [
|
|
7029
|
-
{ internalType: "uint256", name: "id", type: "uint256" },
|
|
7030
|
-
{ internalType: "uint256", name: "jobId", type: "uint256" },
|
|
7031
|
-
{ internalType: "address", name: "sender", type: "address" },
|
|
7032
|
-
{ internalType: "string", name: "content", type: "string" },
|
|
7033
|
-
{
|
|
7034
|
-
internalType: "enum ACPTypes.MemoType",
|
|
7035
|
-
name: "memoType",
|
|
7036
|
-
type: "uint8"
|
|
7037
|
-
},
|
|
7038
|
-
{ internalType: "uint256", name: "createdAt", type: "uint256" },
|
|
7039
|
-
{ internalType: "bool", name: "isApproved", type: "bool" },
|
|
7040
|
-
{ internalType: "address", name: "approvedBy", type: "address" },
|
|
7041
|
-
{ internalType: "uint256", name: "approvedAt", type: "uint256" },
|
|
7042
|
-
{ internalType: "bool", name: "requiresApproval", type: "bool" },
|
|
7043
|
-
{ internalType: "string", name: "metadata", type: "string" },
|
|
7044
|
-
{ internalType: "bool", name: "isSecured", type: "bool" },
|
|
7045
|
-
{
|
|
7046
|
-
internalType: "enum ACPTypes.JobPhase",
|
|
7047
|
-
name: "nextPhase",
|
|
7048
|
-
type: "uint8"
|
|
7049
|
-
},
|
|
7050
|
-
{ internalType: "uint256", name: "expiredAt", type: "uint256" },
|
|
7051
|
-
{
|
|
7052
|
-
internalType: "enum ACPTypes.MemoState",
|
|
7053
|
-
name: "state",
|
|
7054
|
-
type: "uint8"
|
|
7055
|
-
}
|
|
7056
|
-
],
|
|
7057
|
-
internalType: "struct ACPTypes.Memo",
|
|
7058
|
-
name: "",
|
|
7059
|
-
type: "tuple"
|
|
7060
|
-
}
|
|
7061
|
-
],
|
|
7062
|
-
stateMutability: "view",
|
|
7063
|
-
type: "function"
|
|
7064
|
-
},
|
|
7065
|
-
{
|
|
7066
|
-
inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
|
|
7067
|
-
name: "getMemoApprovalStatus",
|
|
7068
|
-
outputs: [
|
|
7069
|
-
{ internalType: "bool", name: "isApproved", type: "bool" },
|
|
7070
|
-
{ internalType: "address", name: "approvedBy", type: "address" },
|
|
7071
|
-
{ internalType: "uint256", name: "approvedAt", type: "uint256" }
|
|
7072
|
-
],
|
|
7073
|
-
stateMutability: "view",
|
|
7074
|
-
type: "function"
|
|
7075
|
-
},
|
|
7076
|
-
{
|
|
7077
|
-
inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
|
|
7078
|
-
name: "getMemoWithPayableDetails",
|
|
7079
|
-
outputs: [
|
|
7080
|
-
{
|
|
7081
|
-
components: [
|
|
7082
|
-
{ internalType: "uint256", name: "id", type: "uint256" },
|
|
7083
|
-
{ internalType: "uint256", name: "jobId", type: "uint256" },
|
|
7084
|
-
{ internalType: "address", name: "sender", type: "address" },
|
|
7085
|
-
{ internalType: "string", name: "content", type: "string" },
|
|
7086
|
-
{
|
|
7087
|
-
internalType: "enum ACPTypes.MemoType",
|
|
7088
|
-
name: "memoType",
|
|
7089
|
-
type: "uint8"
|
|
7090
|
-
},
|
|
7091
|
-
{ internalType: "uint256", name: "createdAt", type: "uint256" },
|
|
7092
|
-
{ internalType: "bool", name: "isApproved", type: "bool" },
|
|
7093
|
-
{ internalType: "address", name: "approvedBy", type: "address" },
|
|
7094
|
-
{ internalType: "uint256", name: "approvedAt", type: "uint256" },
|
|
7095
|
-
{ internalType: "bool", name: "requiresApproval", type: "bool" },
|
|
7096
|
-
{ internalType: "string", name: "metadata", type: "string" },
|
|
7097
|
-
{ internalType: "bool", name: "isSecured", type: "bool" },
|
|
7098
|
-
{
|
|
7099
|
-
internalType: "enum ACPTypes.JobPhase",
|
|
7100
|
-
name: "nextPhase",
|
|
7101
|
-
type: "uint8"
|
|
7102
|
-
},
|
|
7103
|
-
{ internalType: "uint256", name: "expiredAt", type: "uint256" },
|
|
7104
|
-
{
|
|
7105
|
-
internalType: "enum ACPTypes.MemoState",
|
|
7106
|
-
name: "state",
|
|
7107
|
-
type: "uint8"
|
|
7108
|
-
}
|
|
7109
|
-
],
|
|
7110
|
-
internalType: "struct ACPTypes.Memo",
|
|
7111
|
-
name: "memo",
|
|
7112
|
-
type: "tuple"
|
|
7113
|
-
},
|
|
7114
|
-
{
|
|
7115
|
-
components: [
|
|
7116
|
-
{ internalType: "address", name: "token", type: "address" },
|
|
7117
|
-
{ internalType: "uint256", name: "amount", type: "uint256" },
|
|
7118
|
-
{ internalType: "address", name: "recipient", type: "address" },
|
|
7119
|
-
{ internalType: "uint256", name: "feeAmount", type: "uint256" },
|
|
7120
|
-
{
|
|
7121
|
-
internalType: "enum ACPTypes.FeeType",
|
|
7122
|
-
name: "feeType",
|
|
7123
|
-
type: "uint8"
|
|
7124
|
-
},
|
|
7125
|
-
{ internalType: "bool", name: "isExecuted", type: "bool" },
|
|
7126
|
-
{ internalType: "uint256", name: "expiredAt", type: "uint256" },
|
|
7127
|
-
{ internalType: "uint32", name: "lzSrcEid", type: "uint32" },
|
|
7128
|
-
{ internalType: "uint32", name: "lzDstEid", type: "uint32" }
|
|
7129
|
-
],
|
|
7130
|
-
internalType: "struct ACPTypes.PayableDetails",
|
|
7131
|
-
name: "details",
|
|
7132
|
-
type: "tuple"
|
|
7133
|
-
}
|
|
7134
|
-
],
|
|
7135
|
-
stateMutability: "view",
|
|
7136
|
-
type: "function"
|
|
7137
|
-
},
|
|
7138
|
-
{
|
|
7139
|
-
inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
|
|
7140
|
-
name: "getPayableDetails",
|
|
7141
|
-
outputs: [
|
|
7142
|
-
{
|
|
7143
|
-
components: [
|
|
7144
|
-
{ internalType: "address", name: "token", type: "address" },
|
|
7145
|
-
{ internalType: "uint256", name: "amount", type: "uint256" },
|
|
7146
|
-
{ internalType: "address", name: "recipient", type: "address" },
|
|
7147
|
-
{ internalType: "uint256", name: "feeAmount", type: "uint256" },
|
|
7148
|
-
{
|
|
7149
|
-
internalType: "enum ACPTypes.FeeType",
|
|
7150
|
-
name: "feeType",
|
|
7151
|
-
type: "uint8"
|
|
7152
|
-
},
|
|
7153
|
-
{ internalType: "bool", name: "isExecuted", type: "bool" },
|
|
7154
|
-
{ internalType: "uint256", name: "expiredAt", type: "uint256" },
|
|
7155
|
-
{ internalType: "uint32", name: "lzSrcEid", type: "uint32" },
|
|
7156
|
-
{ internalType: "uint32", name: "lzDstEid", type: "uint32" }
|
|
7157
|
-
],
|
|
7158
|
-
internalType: "struct ACPTypes.PayableDetails",
|
|
7159
|
-
name: "",
|
|
7160
|
-
type: "tuple"
|
|
7161
|
-
}
|
|
7162
|
-
],
|
|
7163
|
-
stateMutability: "view",
|
|
7164
|
-
type: "function"
|
|
7165
|
-
},
|
|
7166
|
-
{
|
|
7167
|
-
inputs: [{ internalType: "bytes32", name: "role", type: "bytes32" }],
|
|
7168
|
-
name: "getRoleAdmin",
|
|
7169
|
-
outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
|
|
7170
|
-
stateMutability: "view",
|
|
7171
|
-
type: "function"
|
|
7172
|
-
},
|
|
7173
|
-
{
|
|
7174
|
-
inputs: [
|
|
7175
|
-
{ internalType: "bytes32", name: "role", type: "bytes32" },
|
|
7176
|
-
{ internalType: "address", name: "account", type: "address" }
|
|
7177
|
-
],
|
|
7178
|
-
name: "grantRole",
|
|
7179
|
-
outputs: [],
|
|
7180
|
-
stateMutability: "nonpayable",
|
|
7181
|
-
type: "function"
|
|
7182
|
-
},
|
|
7183
|
-
{
|
|
7184
|
-
inputs: [
|
|
7185
|
-
{ internalType: "bytes32", name: "role", type: "bytes32" },
|
|
7186
|
-
{ internalType: "address", name: "account", type: "address" }
|
|
7187
|
-
],
|
|
7188
|
-
name: "hasRole",
|
|
7189
|
-
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
7190
|
-
stateMutability: "view",
|
|
7191
|
-
type: "function"
|
|
7192
|
-
},
|
|
7193
|
-
{
|
|
7194
|
-
inputs: [
|
|
7195
|
-
{ internalType: "address", name: "acpContract_", type: "address" },
|
|
7196
|
-
{ internalType: "address", name: "jobManager_", type: "address" },
|
|
7197
|
-
{ internalType: "address", name: "paymentManager_", type: "address" }
|
|
7198
|
-
],
|
|
7199
|
-
name: "initialize",
|
|
7200
|
-
outputs: [],
|
|
7201
|
-
stateMutability: "nonpayable",
|
|
7202
|
-
type: "function"
|
|
7203
|
-
},
|
|
7204
|
-
{
|
|
7205
|
-
inputs: [
|
|
7206
|
-
{ internalType: "uint256", name: "jobId", type: "uint256" },
|
|
7207
|
-
{ internalType: "address", name: "user", type: "address" }
|
|
7208
|
-
],
|
|
7209
|
-
name: "isJobEvaluator",
|
|
7210
|
-
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
7211
|
-
stateMutability: "view",
|
|
7212
|
-
type: "function"
|
|
7213
|
-
},
|
|
7214
|
-
{
|
|
7215
|
-
inputs: [
|
|
7216
|
-
{ internalType: "uint256", name: "memoId", type: "uint256" },
|
|
7217
|
-
{ internalType: "address", name: "user", type: "address" }
|
|
7218
|
-
],
|
|
7219
|
-
name: "isMemoSigner",
|
|
7220
|
-
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
7221
|
-
stateMutability: "view",
|
|
7222
|
-
type: "function"
|
|
7223
|
-
},
|
|
7224
|
-
{
|
|
7225
|
-
inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
|
|
7226
|
-
name: "isPayable",
|
|
7227
|
-
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
7228
|
-
stateMutability: "view",
|
|
7229
|
-
type: "function"
|
|
7230
|
-
},
|
|
7231
|
-
{
|
|
7232
|
-
inputs: [],
|
|
7233
|
-
name: "jobManager",
|
|
7234
|
-
outputs: [{ internalType: "address", name: "", type: "address" }],
|
|
7235
|
-
stateMutability: "view",
|
|
7236
|
-
type: "function"
|
|
7237
|
-
},
|
|
7238
|
-
{
|
|
7239
|
-
inputs: [
|
|
7240
|
-
{ internalType: "uint256", name: "", type: "uint256" },
|
|
7241
|
-
{ internalType: "uint256", name: "", type: "uint256" }
|
|
7242
|
-
],
|
|
7243
|
-
name: "jobMemos",
|
|
7244
|
-
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
7245
|
-
stateMutability: "view",
|
|
7246
|
-
type: "function"
|
|
7247
|
-
},
|
|
7248
|
-
{
|
|
7249
|
-
inputs: [
|
|
7250
|
-
{ internalType: "uint256", name: "", type: "uint256" },
|
|
7251
|
-
{ internalType: "enum ACPTypes.JobPhase", name: "", type: "uint8" },
|
|
7252
|
-
{ internalType: "uint256", name: "", type: "uint256" }
|
|
7253
|
-
],
|
|
7254
|
-
name: "jobMemosByPhase",
|
|
7255
|
-
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
7256
|
-
stateMutability: "view",
|
|
7257
|
-
type: "function"
|
|
7258
|
-
},
|
|
7259
|
-
{
|
|
7260
|
-
inputs: [
|
|
7261
|
-
{ internalType: "uint256", name: "", type: "uint256" },
|
|
7262
|
-
{ internalType: "enum ACPTypes.MemoType", name: "", type: "uint8" },
|
|
7263
|
-
{ internalType: "uint256", name: "", type: "uint256" }
|
|
7264
|
-
],
|
|
7265
|
-
name: "jobMemosByType",
|
|
7266
|
-
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
7267
|
-
stateMutability: "view",
|
|
7268
|
-
type: "function"
|
|
7269
|
-
},
|
|
7270
|
-
{
|
|
7271
|
-
inputs: [
|
|
7272
|
-
{ internalType: "uint256", name: "", type: "uint256" },
|
|
7273
|
-
{ internalType: "address", name: "", type: "address" }
|
|
7274
|
-
],
|
|
7275
|
-
name: "memoApprovals",
|
|
7276
|
-
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
7277
|
-
stateMutability: "view",
|
|
7278
|
-
type: "function"
|
|
7279
|
-
},
|
|
7280
|
-
{
|
|
7281
|
-
inputs: [],
|
|
7282
|
-
name: "memoCounter",
|
|
7283
|
-
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
7284
|
-
stateMutability: "view",
|
|
7285
|
-
type: "function"
|
|
7286
|
-
},
|
|
7287
|
-
{
|
|
7288
|
-
inputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
7289
|
-
name: "memos",
|
|
7290
|
-
outputs: [
|
|
7291
|
-
{ internalType: "uint256", name: "id", type: "uint256" },
|
|
7292
|
-
{ internalType: "uint256", name: "jobId", type: "uint256" },
|
|
7293
|
-
{ internalType: "address", name: "sender", type: "address" },
|
|
7294
|
-
{ internalType: "string", name: "content", type: "string" },
|
|
7295
|
-
{
|
|
7296
|
-
internalType: "enum ACPTypes.MemoType",
|
|
7297
|
-
name: "memoType",
|
|
7298
|
-
type: "uint8"
|
|
7299
|
-
},
|
|
7300
|
-
{ internalType: "uint256", name: "createdAt", type: "uint256" },
|
|
7301
|
-
{ internalType: "bool", name: "isApproved", type: "bool" },
|
|
7302
|
-
{ internalType: "address", name: "approvedBy", type: "address" },
|
|
7303
|
-
{ internalType: "uint256", name: "approvedAt", type: "uint256" },
|
|
7304
|
-
{ internalType: "bool", name: "requiresApproval", type: "bool" },
|
|
7305
|
-
{ internalType: "string", name: "metadata", type: "string" },
|
|
7306
|
-
{ internalType: "bool", name: "isSecured", type: "bool" },
|
|
7307
|
-
{
|
|
7308
|
-
internalType: "enum ACPTypes.JobPhase",
|
|
7309
|
-
name: "nextPhase",
|
|
7310
|
-
type: "uint8"
|
|
7311
|
-
},
|
|
7312
|
-
{ internalType: "uint256", name: "expiredAt", type: "uint256" },
|
|
7313
|
-
{ internalType: "enum ACPTypes.MemoState", name: "state", type: "uint8" }
|
|
7314
|
-
],
|
|
7315
|
-
stateMutability: "view",
|
|
7316
|
-
type: "function"
|
|
7317
|
-
},
|
|
7318
|
-
{
|
|
7319
|
-
inputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
7320
|
-
name: "payableDetails",
|
|
7321
|
-
outputs: [
|
|
7322
|
-
{ internalType: "address", name: "token", type: "address" },
|
|
7323
|
-
{ internalType: "uint256", name: "amount", type: "uint256" },
|
|
7324
|
-
{ internalType: "address", name: "recipient", type: "address" },
|
|
7325
|
-
{ internalType: "uint256", name: "feeAmount", type: "uint256" },
|
|
7326
|
-
{ internalType: "enum ACPTypes.FeeType", name: "feeType", type: "uint8" },
|
|
7327
|
-
{ internalType: "bool", name: "isExecuted", type: "bool" },
|
|
7328
|
-
{ internalType: "uint256", name: "expiredAt", type: "uint256" },
|
|
7329
|
-
{ internalType: "uint32", name: "lzSrcEid", type: "uint32" },
|
|
7330
|
-
{ internalType: "uint32", name: "lzDstEid", type: "uint32" }
|
|
7331
|
-
],
|
|
7332
|
-
stateMutability: "view",
|
|
7333
|
-
type: "function"
|
|
7334
|
-
},
|
|
7335
|
-
{
|
|
7336
|
-
inputs: [],
|
|
7337
|
-
name: "paymentManager",
|
|
7338
|
-
outputs: [{ internalType: "address", name: "", type: "address" }],
|
|
7339
|
-
stateMutability: "view",
|
|
7340
|
-
type: "function"
|
|
7341
|
-
},
|
|
7342
|
-
{
|
|
7343
|
-
inputs: [],
|
|
7344
|
-
name: "proxiableUUID",
|
|
7345
|
-
outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
|
|
7346
|
-
stateMutability: "view",
|
|
7347
|
-
type: "function"
|
|
7348
|
-
},
|
|
7349
|
-
{
|
|
7350
|
-
inputs: [
|
|
7351
|
-
{ internalType: "bytes32", name: "role", type: "bytes32" },
|
|
7352
|
-
{ internalType: "address", name: "callerConfirmation", type: "address" }
|
|
7353
|
-
],
|
|
7354
|
-
name: "renounceRole",
|
|
7355
|
-
outputs: [],
|
|
7356
|
-
stateMutability: "nonpayable",
|
|
7357
|
-
type: "function"
|
|
7358
|
-
},
|
|
7359
|
-
{
|
|
7360
|
-
inputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
7361
|
-
name: "requiredApprovals",
|
|
7362
|
-
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
7363
|
-
stateMutability: "view",
|
|
7364
|
-
type: "function"
|
|
7365
|
-
},
|
|
7366
|
-
{
|
|
7367
|
-
inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
|
|
7368
|
-
name: "requiresApproval",
|
|
7369
|
-
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
7370
|
-
stateMutability: "view",
|
|
7371
|
-
type: "function"
|
|
7372
|
-
},
|
|
7373
|
-
{
|
|
7374
|
-
inputs: [
|
|
7375
|
-
{ internalType: "bytes32", name: "role", type: "bytes32" },
|
|
7376
|
-
{ internalType: "address", name: "account", type: "address" }
|
|
7377
|
-
],
|
|
7378
|
-
name: "revokeRole",
|
|
7379
|
-
outputs: [],
|
|
7380
|
-
stateMutability: "nonpayable",
|
|
7381
|
-
type: "function"
|
|
7382
|
-
},
|
|
7383
|
-
{
|
|
7384
|
-
inputs: [
|
|
7385
|
-
{
|
|
7386
|
-
internalType: "enum ACPTypes.MemoType",
|
|
7387
|
-
name: "memoType",
|
|
7388
|
-
type: "uint8"
|
|
7389
|
-
},
|
|
7390
|
-
{ internalType: "uint256", name: "requiredApprovals_", type: "uint256" }
|
|
7391
|
-
],
|
|
7392
|
-
name: "setApprovalRequirements",
|
|
7393
|
-
outputs: [],
|
|
7394
|
-
stateMutability: "nonpayable",
|
|
7395
|
-
type: "function"
|
|
7396
|
-
},
|
|
7397
|
-
{
|
|
7398
|
-
inputs: [
|
|
7399
|
-
{ internalType: "address", name: "assetManager_", type: "address" }
|
|
7400
|
-
],
|
|
7401
|
-
name: "setAssetManager",
|
|
7402
|
-
outputs: [],
|
|
7403
|
-
stateMutability: "nonpayable",
|
|
7404
|
-
type: "function"
|
|
7405
|
-
},
|
|
7406
|
-
{
|
|
7407
|
-
inputs: [
|
|
7408
|
-
{ internalType: "uint256", name: "memoId", type: "uint256" },
|
|
7409
|
-
{ internalType: "address", name: "sender", type: "address" },
|
|
7410
|
-
{ internalType: "bool", name: "isApproved", type: "bool" },
|
|
7411
|
-
{ internalType: "string", name: "reason", type: "string" }
|
|
7412
|
-
],
|
|
7413
|
-
name: "signMemo",
|
|
7414
|
-
outputs: [{ internalType: "uint256", name: "jobId", type: "uint256" }],
|
|
7415
|
-
stateMutability: "nonpayable",
|
|
7416
|
-
type: "function"
|
|
7417
|
-
},
|
|
7418
|
-
{
|
|
7419
|
-
inputs: [{ internalType: "bytes4", name: "interfaceId", type: "bytes4" }],
|
|
7420
|
-
name: "supportsInterface",
|
|
7421
|
-
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
7422
|
-
stateMutability: "view",
|
|
7423
|
-
type: "function"
|
|
7424
|
-
},
|
|
7425
|
-
{
|
|
7426
|
-
inputs: [
|
|
7427
|
-
{ internalType: "address", name: "acpContract_", type: "address" },
|
|
7428
|
-
{ internalType: "address", name: "jobManager_", type: "address" },
|
|
7429
|
-
{ internalType: "address", name: "paymentManager_", type: "address" },
|
|
7430
|
-
{ internalType: "address", name: "assetManager_", type: "address" }
|
|
7431
|
-
],
|
|
7432
|
-
name: "updateContracts",
|
|
7433
|
-
outputs: [],
|
|
7434
|
-
stateMutability: "nonpayable",
|
|
7435
|
-
type: "function"
|
|
7436
|
-
},
|
|
7437
|
-
{
|
|
7438
|
-
inputs: [
|
|
7439
|
-
{ internalType: "uint256", name: "memoId", type: "uint256" },
|
|
7440
|
-
{ internalType: "string", name: "newContent", type: "string" }
|
|
7441
|
-
],
|
|
7442
|
-
name: "updateMemoContent",
|
|
7443
|
-
outputs: [],
|
|
7444
|
-
stateMutability: "nonpayable",
|
|
7445
|
-
type: "function"
|
|
7446
|
-
},
|
|
7447
|
-
{
|
|
7448
|
-
inputs: [
|
|
7449
|
-
{ internalType: "uint256", name: "memoId", type: "uint256" },
|
|
7450
|
-
{
|
|
7451
|
-
internalType: "enum ACPTypes.MemoState",
|
|
7452
|
-
name: "newMemoState",
|
|
7453
|
-
type: "uint8"
|
|
7454
|
-
}
|
|
7455
|
-
],
|
|
7456
|
-
name: "updateMemoState",
|
|
7457
|
-
outputs: [],
|
|
7458
|
-
stateMutability: "nonpayable",
|
|
7459
|
-
type: "function"
|
|
7460
|
-
},
|
|
7461
|
-
{
|
|
7462
|
-
inputs: [
|
|
7463
|
-
{ internalType: "address", name: "newImplementation", type: "address" },
|
|
7464
|
-
{ internalType: "bytes", name: "data", type: "bytes" }
|
|
7465
|
-
],
|
|
7466
|
-
name: "upgradeToAndCall",
|
|
7467
|
-
outputs: [],
|
|
7468
|
-
stateMutability: "payable",
|
|
7469
|
-
type: "function"
|
|
7470
|
-
},
|
|
7471
|
-
{
|
|
7472
|
-
inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
|
|
7473
|
-
name: "withdrawEscrowedFunds",
|
|
7474
|
-
outputs: [],
|
|
7475
|
-
stateMutability: "nonpayable",
|
|
7476
|
-
type: "function"
|
|
7477
|
-
}
|
|
7478
|
-
];
|
|
7479
|
-
var memoManagerAbi_default = MEMO_MANAGER_ABI;
|
|
7480
|
-
|
|
7481
|
-
// src/contractClients/acpContractClientV2.ts
|
|
7482
|
-
var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClient_default {
|
|
7483
|
-
constructor(jobManagerAddress, memoManagerAddress, accountManagerAddress, agentWalletAddress, config = baseAcpConfigV2) {
|
|
7484
|
-
super(agentWalletAddress, config);
|
|
7485
|
-
this.jobManagerAddress = jobManagerAddress;
|
|
7486
|
-
this.memoManagerAddress = memoManagerAddress;
|
|
7487
|
-
this.accountManagerAddress = accountManagerAddress;
|
|
7488
|
-
this.PRIORITY_FEE_MULTIPLIER = 2;
|
|
7489
|
-
this.MAX_FEE_PER_GAS = 2e7;
|
|
7490
|
-
this.MAX_PRIORITY_FEE_PER_GAS = 21e6;
|
|
7491
|
-
this.GAS_FEE_MULTIPLIER = 0.5;
|
|
7492
|
-
this.RETRY_CONFIG = {
|
|
7493
|
-
intervalMs: 200,
|
|
7494
|
-
multiplier: 1.1,
|
|
7495
|
-
maxRetries: 10
|
|
7496
|
-
};
|
|
7497
|
-
this._sessionKeyClients = {};
|
|
7498
|
-
}
|
|
7499
|
-
static async build(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfigV2) {
|
|
7500
|
-
const publicClients = {};
|
|
7501
|
-
for (const chain of config.chains) {
|
|
7502
|
-
publicClients[chain.chain.id] = (0, import_viem9.createPublicClient)({
|
|
7503
|
-
chain: chain.chain,
|
|
7504
|
-
transport: (0, import_viem9.http)(chain.rpcUrl)
|
|
7505
|
-
});
|
|
7506
|
-
}
|
|
7507
|
-
const publicClient = (0, import_viem9.createPublicClient)({
|
|
7508
|
-
chain: config.chain,
|
|
7509
|
-
transport: (0, import_viem9.http)(config.rpcEndpoint)
|
|
7510
|
-
});
|
|
7511
|
-
const [jobManagerAddress, memoManagerAddress, accountManagerAddress] = await publicClient.multicall({
|
|
7512
|
-
contracts: [
|
|
7513
|
-
{
|
|
7514
|
-
address: config.contractAddress,
|
|
7515
|
-
abi: config.abi,
|
|
7516
|
-
functionName: "jobManager"
|
|
7517
|
-
},
|
|
7518
|
-
{
|
|
7519
|
-
address: config.contractAddress,
|
|
7520
|
-
abi: config.abi,
|
|
7521
|
-
functionName: "memoManager"
|
|
7522
|
-
},
|
|
7523
|
-
{
|
|
7524
|
-
address: config.contractAddress,
|
|
7525
|
-
abi: config.abi,
|
|
7526
|
-
functionName: "accountManager"
|
|
7527
|
-
}
|
|
7528
|
-
]
|
|
7529
|
-
});
|
|
7530
|
-
if (!jobManagerAddress || !memoManagerAddress || !accountManagerAddress) {
|
|
7531
|
-
throw new acpError_default(
|
|
7532
|
-
"Failed to get job manager, memo manager, or account manager address"
|
|
7533
|
-
);
|
|
7534
|
-
}
|
|
7535
|
-
const acpContractClient = new _AcpContractClientV2(
|
|
7536
|
-
jobManagerAddress.result,
|
|
7537
|
-
memoManagerAddress.result,
|
|
7538
|
-
accountManagerAddress.result,
|
|
7539
|
-
agentWalletAddress,
|
|
7540
|
-
config
|
|
7541
|
-
);
|
|
7542
|
-
acpContractClient.publicClients = publicClients;
|
|
7543
|
-
await acpContractClient.init(walletPrivateKey, sessionEntityKeyId);
|
|
7544
|
-
return acpContractClient;
|
|
7545
|
-
}
|
|
7546
|
-
async init(privateKey, sessionEntityKeyId) {
|
|
7547
|
-
const sessionKeySigner = import_core2.LocalAccountSigner.privateKeyToAccountSigner(privateKey);
|
|
7548
|
-
this._sessionKeyClient = await (0, import_smart_contracts2.createModularAccountV2Client)({
|
|
7549
|
-
chain: this.chain,
|
|
7550
|
-
transport: (0, import_infra3.alchemy)({
|
|
7551
|
-
rpcUrl: this.config.alchemyRpcUrl
|
|
7552
|
-
}),
|
|
7553
|
-
signer: sessionKeySigner,
|
|
7554
|
-
policyId: "186aaa4a-5f57-4156-83fb-e456365a8820",
|
|
7555
|
-
accountAddress: this.agentWalletAddress,
|
|
7556
|
-
signerEntity: {
|
|
7557
|
-
entityId: sessionEntityKeyId,
|
|
7558
|
-
isGlobalValidation: true
|
|
6074
|
+
var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClient_default {
|
|
6075
|
+
constructor(jobManagerAddress, memoManagerAddress, accountManagerAddress, agentWalletAddress, config = baseAcpConfigV2) {
|
|
6076
|
+
super(agentWalletAddress, config);
|
|
6077
|
+
this.jobManagerAddress = jobManagerAddress;
|
|
6078
|
+
this.memoManagerAddress = memoManagerAddress;
|
|
6079
|
+
this.accountManagerAddress = accountManagerAddress;
|
|
6080
|
+
this.PRIORITY_FEE_MULTIPLIER = 2;
|
|
6081
|
+
this.MAX_FEE_PER_GAS = 2e7;
|
|
6082
|
+
this.MAX_PRIORITY_FEE_PER_GAS = 21e6;
|
|
6083
|
+
this.GAS_FEE_MULTIPLIER = 0.5;
|
|
6084
|
+
this.RETRY_CONFIG = {
|
|
6085
|
+
intervalMs: 200,
|
|
6086
|
+
multiplier: 1.1,
|
|
6087
|
+
maxRetries: 10
|
|
6088
|
+
};
|
|
6089
|
+
}
|
|
6090
|
+
static async build(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfigV2) {
|
|
6091
|
+
const publicClient = (0, import_viem7.createPublicClient)({
|
|
6092
|
+
chain: config.chain,
|
|
6093
|
+
transport: (0, import_viem7.http)(config.rpcEndpoint)
|
|
6094
|
+
});
|
|
6095
|
+
const [jobManagerAddress, memoManagerAddress, accountManagerAddress] = await publicClient.multicall({
|
|
6096
|
+
contracts: [
|
|
6097
|
+
{
|
|
6098
|
+
address: config.contractAddress,
|
|
6099
|
+
abi: config.abi,
|
|
6100
|
+
functionName: "jobManager"
|
|
6101
|
+
},
|
|
6102
|
+
{
|
|
6103
|
+
address: config.contractAddress,
|
|
6104
|
+
abi: config.abi,
|
|
6105
|
+
functionName: "memoManager"
|
|
6106
|
+
},
|
|
6107
|
+
{
|
|
6108
|
+
address: config.contractAddress,
|
|
6109
|
+
abi: config.abi,
|
|
6110
|
+
functionName: "accountManager"
|
|
6111
|
+
}
|
|
6112
|
+
]
|
|
6113
|
+
});
|
|
6114
|
+
if (!jobManagerAddress || !memoManagerAddress || !accountManagerAddress) {
|
|
6115
|
+
throw new acpError_default(
|
|
6116
|
+
"Failed to get job manager, memo manager, or account manager address"
|
|
6117
|
+
);
|
|
6118
|
+
}
|
|
6119
|
+
const acpContractClient = new _AcpContractClientV2(
|
|
6120
|
+
jobManagerAddress.result,
|
|
6121
|
+
memoManagerAddress.result,
|
|
6122
|
+
accountManagerAddress.result,
|
|
6123
|
+
agentWalletAddress,
|
|
6124
|
+
config
|
|
6125
|
+
);
|
|
6126
|
+
await acpContractClient.init(walletPrivateKey, sessionEntityKeyId);
|
|
6127
|
+
return acpContractClient;
|
|
6128
|
+
}
|
|
6129
|
+
async init(privateKey, sessionEntityKeyId) {
|
|
6130
|
+
const sessionKeySigner = import_core2.LocalAccountSigner.privateKeyToAccountSigner(privateKey);
|
|
6131
|
+
this._sessionKeyClient = await (0, import_smart_contracts2.createModularAccountV2Client)({
|
|
6132
|
+
chain: this.chain,
|
|
6133
|
+
transport: (0, import_infra3.alchemy)({
|
|
6134
|
+
rpcUrl: this.config.alchemyRpcUrl
|
|
6135
|
+
}),
|
|
6136
|
+
signer: sessionKeySigner,
|
|
6137
|
+
policyId: "186aaa4a-5f57-4156-83fb-e456365a8820",
|
|
6138
|
+
accountAddress: this.agentWalletAddress,
|
|
6139
|
+
signerEntity: {
|
|
6140
|
+
entityId: sessionEntityKeyId,
|
|
6141
|
+
isGlobalValidation: true
|
|
7559
6142
|
}
|
|
7560
6143
|
});
|
|
7561
|
-
for (const chain of this.config.chains) {
|
|
7562
|
-
this._sessionKeyClients[chain.chain.id] = await (0, import_smart_contracts2.createModularAccountV2Client)({
|
|
7563
|
-
chain: chain.chain,
|
|
7564
|
-
transport: (0, import_infra3.alchemy)({
|
|
7565
|
-
rpcUrl: `${this.config.alchemyRpcUrl}?chainId=${chain.chain.id}`
|
|
7566
|
-
}),
|
|
7567
|
-
signer: sessionKeySigner,
|
|
7568
|
-
policyId: "186aaa4a-5f57-4156-83fb-e456365a8820",
|
|
7569
|
-
accountAddress: this.agentWalletAddress,
|
|
7570
|
-
signerEntity: {
|
|
7571
|
-
entityId: sessionEntityKeyId,
|
|
7572
|
-
isGlobalValidation: true
|
|
7573
|
-
}
|
|
7574
|
-
});
|
|
7575
|
-
}
|
|
7576
6144
|
this._acpX402 = new AcpX402(
|
|
7577
6145
|
this.config,
|
|
7578
6146
|
this.sessionKeyClient,
|
|
@@ -7617,20 +6185,11 @@ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClie
|
|
|
7617
6185
|
}
|
|
7618
6186
|
return this._acpX402;
|
|
7619
6187
|
}
|
|
7620
|
-
async calculateGasFees(
|
|
7621
|
-
if (chainId) {
|
|
7622
|
-
const { maxFeePerGas } = await this.publicClients[chainId].estimateFeesPerGas();
|
|
7623
|
-
const increasedMaxFeePerGas = BigInt(maxFeePerGas) + BigInt(maxFeePerGas) * BigInt(this.GAS_FEE_MULTIPLIER * 100) / BigInt(100);
|
|
7624
|
-
return increasedMaxFeePerGas;
|
|
7625
|
-
}
|
|
6188
|
+
async calculateGasFees() {
|
|
7626
6189
|
const finalMaxFeePerGas = BigInt(this.MAX_FEE_PER_GAS) + BigInt(this.MAX_PRIORITY_FEE_PER_GAS) * BigInt(Math.max(0, this.PRIORITY_FEE_MULTIPLIER - 1));
|
|
7627
6190
|
return finalMaxFeePerGas;
|
|
7628
6191
|
}
|
|
7629
|
-
async handleOperation(operations
|
|
7630
|
-
const sessionKeyClient = chainId ? this._sessionKeyClients[chainId] : this.sessionKeyClient;
|
|
7631
|
-
if (!sessionKeyClient) {
|
|
7632
|
-
throw new acpError_default("Session key client not initialized");
|
|
7633
|
-
}
|
|
6192
|
+
async handleOperation(operations) {
|
|
7634
6193
|
const basePayload = {
|
|
7635
6194
|
uo: operations.map((operation) => ({
|
|
7636
6195
|
target: operation.contractAddress,
|
|
@@ -7655,17 +6214,12 @@ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClie
|
|
|
7655
6214
|
}
|
|
7656
6215
|
}
|
|
7657
6216
|
};
|
|
7658
|
-
const { hash } = await sessionKeyClient.sendUserOperation(payload);
|
|
7659
|
-
const
|
|
6217
|
+
const { hash } = await this.sessionKeyClient.sendUserOperation(payload);
|
|
6218
|
+
const txnHash = await this.sessionKeyClient.waitForUserOperationTransaction({
|
|
7660
6219
|
hash,
|
|
6220
|
+
tag: "pending",
|
|
7661
6221
|
retries: this.RETRY_CONFIG
|
|
7662
|
-
};
|
|
7663
|
-
if (!chainId || chainId === import_chains3.baseSepolia.id || chainId === import_chains3.base.id) {
|
|
7664
|
-
checkTransactionConfig["tag"] = "pending";
|
|
7665
|
-
}
|
|
7666
|
-
const txnHash = await sessionKeyClient.waitForUserOperationTransaction(
|
|
7667
|
-
checkTransactionConfig
|
|
7668
|
-
);
|
|
6222
|
+
});
|
|
7669
6223
|
return { userOpHash: hash, txnHash };
|
|
7670
6224
|
} catch (error) {
|
|
7671
6225
|
iteration++;
|
|
@@ -7689,7 +6243,7 @@ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClie
|
|
|
7689
6243
|
const contractLogs = result.logs.filter((log) => {
|
|
7690
6244
|
return log.address.toLowerCase() === this.jobManagerAddress.toLowerCase();
|
|
7691
6245
|
}).map(
|
|
7692
|
-
(log) => (0,
|
|
6246
|
+
(log) => (0, import_viem7.decodeEventLog)({
|
|
7693
6247
|
abi: jobManagerAbi_default,
|
|
7694
6248
|
data: log.data,
|
|
7695
6249
|
topics: log.topics
|
|
@@ -7728,16 +6282,12 @@ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClie
|
|
|
7728
6282
|
throw new acpError_default("Failed to get X402 payment details", error);
|
|
7729
6283
|
}
|
|
7730
6284
|
}
|
|
7731
|
-
async getAssetManager() {
|
|
7732
|
-
return await this.publicClient.readContract({
|
|
7733
|
-
address: this.memoManagerAddress,
|
|
7734
|
-
abi: memoManagerAbi_default,
|
|
7735
|
-
functionName: "assetManager"
|
|
7736
|
-
});
|
|
7737
|
-
}
|
|
7738
6285
|
getAcpVersion() {
|
|
7739
6286
|
return "2";
|
|
7740
6287
|
}
|
|
6288
|
+
async signTypedData(typedData) {
|
|
6289
|
+
return await this.sessionKeyClient.signTypedData({ typedData });
|
|
6290
|
+
}
|
|
7741
6291
|
};
|
|
7742
6292
|
var acpContractClientV2_default = AcpContractClientV2;
|
|
7743
6293
|
|
|
@@ -7746,6 +6296,7 @@ var index_default = acpClient_default;
|
|
|
7746
6296
|
// Annotate the CommonJS export names for ESM import in node:
|
|
7747
6297
|
0 && (module.exports = {
|
|
7748
6298
|
ACP_ABI,
|
|
6299
|
+
AcpAgent,
|
|
7749
6300
|
AcpAgentSort,
|
|
7750
6301
|
AcpContractClient,
|
|
7751
6302
|
AcpContractClientV2,
|
|
@@ -7755,7 +6306,6 @@ var index_default = acpClient_default;
|
|
|
7755
6306
|
AcpJob,
|
|
7756
6307
|
AcpJobPhases,
|
|
7757
6308
|
AcpMemo,
|
|
7758
|
-
AcpMemoState,
|
|
7759
6309
|
AcpMemoStatus,
|
|
7760
6310
|
AcpOnlineStatus,
|
|
7761
6311
|
BaseAcpContractClient,
|
|
@@ -7763,15 +6313,12 @@ var index_default = acpClient_default;
|
|
|
7763
6313
|
FareAmount,
|
|
7764
6314
|
FareBigInt,
|
|
7765
6315
|
MemoType,
|
|
7766
|
-
PayloadType,
|
|
7767
|
-
PositionDirection,
|
|
7768
6316
|
baseAcpConfig,
|
|
7769
6317
|
baseAcpConfigV2,
|
|
7770
6318
|
baseAcpX402Config,
|
|
7771
6319
|
baseAcpX402ConfigV2,
|
|
7772
6320
|
baseSepoliaAcpConfig,
|
|
7773
6321
|
baseSepoliaAcpConfigV2,
|
|
7774
|
-
baseSepoliaAcpX402ConfigV2,
|
|
7775
6322
|
ethFare,
|
|
7776
6323
|
preparePayload,
|
|
7777
6324
|
wethFare
|