@virtuals-protocol/acp-node 0.3.0-beta.26 → 0.3.0-beta.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +77 -54
- package/dist/index.d.ts +77 -54
- package/dist/index.js +1706 -147
- package/dist/index.mjs +1721 -139
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -35,7 +35,7 @@ var require_package = __commonJS({
|
|
|
35
35
|
"package.json"(exports2, module2) {
|
|
36
36
|
module2.exports = {
|
|
37
37
|
name: "@virtuals-protocol/acp-node",
|
|
38
|
-
version: "0.3.0-beta.
|
|
38
|
+
version: "0.3.0-beta.28",
|
|
39
39
|
main: "./dist/index.js",
|
|
40
40
|
module: "./dist/index.mjs",
|
|
41
41
|
types: "./dist/index.d.ts",
|
|
@@ -95,6 +95,7 @@ __export(index_exports, {
|
|
|
95
95
|
AcpJob: () => acpJob_default,
|
|
96
96
|
AcpJobPhases: () => AcpJobPhases,
|
|
97
97
|
AcpMemo: () => acpMemo_default,
|
|
98
|
+
AcpMemoState: () => AcpMemoState,
|
|
98
99
|
AcpMemoStatus: () => AcpMemoStatus,
|
|
99
100
|
AcpOnlineStatus: () => AcpOnlineStatus,
|
|
100
101
|
BaseAcpContractClient: () => baseAcpContractClient_default,
|
|
@@ -108,6 +109,7 @@ __export(index_exports, {
|
|
|
108
109
|
baseAcpX402ConfigV2: () => baseAcpX402ConfigV2,
|
|
109
110
|
baseSepoliaAcpConfig: () => baseSepoliaAcpConfig,
|
|
110
111
|
baseSepoliaAcpConfigV2: () => baseSepoliaAcpConfigV2,
|
|
112
|
+
baseSepoliaAcpX402ConfigV2: () => baseSepoliaAcpX402ConfigV2,
|
|
111
113
|
default: () => index_default,
|
|
112
114
|
ethFare: () => ethFare,
|
|
113
115
|
preparePayload: () => preparePayload,
|
|
@@ -1286,7 +1288,7 @@ var ACP_ABI = [
|
|
|
1286
1288
|
var acpAbi_default = ACP_ABI;
|
|
1287
1289
|
|
|
1288
1290
|
// src/acpClient.ts
|
|
1289
|
-
var
|
|
1291
|
+
var import_viem6 = require("viem");
|
|
1290
1292
|
var import_socket = require("socket.io-client");
|
|
1291
1293
|
var import_jwt_decode = require("jwt-decode");
|
|
1292
1294
|
|
|
@@ -1316,27 +1318,42 @@ var acpError_default = AcpError;
|
|
|
1316
1318
|
|
|
1317
1319
|
// src/acpFare.ts
|
|
1318
1320
|
var Fare = class _Fare {
|
|
1319
|
-
constructor(contractAddress, decimals) {
|
|
1321
|
+
constructor(contractAddress, decimals, chainId) {
|
|
1320
1322
|
this.contractAddress = contractAddress;
|
|
1321
1323
|
this.decimals = decimals;
|
|
1324
|
+
this.chainId = chainId;
|
|
1322
1325
|
}
|
|
1323
1326
|
formatAmount(amount) {
|
|
1324
1327
|
return (0, import_viem.parseUnits)(amount.toString(), this.decimals);
|
|
1325
1328
|
}
|
|
1326
|
-
static async fromContractAddress(contractAddress, config = baseAcpConfig) {
|
|
1329
|
+
static async fromContractAddress(contractAddress, config = baseAcpConfig, chainId = config.chain.id) {
|
|
1327
1330
|
if (contractAddress === config.baseFare.contractAddress) {
|
|
1328
1331
|
return config.baseFare;
|
|
1329
1332
|
}
|
|
1333
|
+
let chainConfig = config.chain;
|
|
1334
|
+
let rpcUrl = config.rpcEndpoint;
|
|
1335
|
+
if (chainId !== config.chain.id) {
|
|
1336
|
+
const selectedChainConfig = config.chains.find(
|
|
1337
|
+
(chain) => chain.id === chainId
|
|
1338
|
+
);
|
|
1339
|
+
if (!selectedChainConfig) {
|
|
1340
|
+
throw new acpError_default(
|
|
1341
|
+
`Chain configuration for chainId ${chainId} not found.`
|
|
1342
|
+
);
|
|
1343
|
+
}
|
|
1344
|
+
chainConfig = selectedChainConfig;
|
|
1345
|
+
rpcUrl = `${config.alchemyRpcUrl}?chainId=${chainId}`;
|
|
1346
|
+
}
|
|
1330
1347
|
const publicClient = (0, import_viem.createPublicClient)({
|
|
1331
|
-
chain:
|
|
1332
|
-
transport: (0, import_viem.http)(
|
|
1348
|
+
chain: chainConfig,
|
|
1349
|
+
transport: (0, import_viem.http)(rpcUrl)
|
|
1333
1350
|
});
|
|
1334
1351
|
const decimals = await publicClient.readContract({
|
|
1335
1352
|
address: contractAddress,
|
|
1336
1353
|
abi: import_viem.erc20Abi,
|
|
1337
1354
|
functionName: "decimals"
|
|
1338
1355
|
});
|
|
1339
|
-
return new _Fare(contractAddress, decimals);
|
|
1356
|
+
return new _Fare(contractAddress, decimals, chainId);
|
|
1340
1357
|
}
|
|
1341
1358
|
};
|
|
1342
1359
|
var FareAmountBase = class {
|
|
@@ -1755,6 +1772,34 @@ var ACP_V2_ABI = [
|
|
|
1755
1772
|
stateMutability: "nonpayable",
|
|
1756
1773
|
type: "function"
|
|
1757
1774
|
},
|
|
1775
|
+
{
|
|
1776
|
+
inputs: [
|
|
1777
|
+
{ internalType: "uint256", name: "jobId", type: "uint256" },
|
|
1778
|
+
{ internalType: "string", name: "content", type: "string" },
|
|
1779
|
+
{ internalType: "address", name: "token", type: "address" },
|
|
1780
|
+
{ internalType: "uint256", name: "amount", type: "uint256" },
|
|
1781
|
+
{ internalType: "address", name: "recipient", type: "address" },
|
|
1782
|
+
{ internalType: "uint256", name: "feeAmount", type: "uint256" },
|
|
1783
|
+
{ internalType: "enum ACPTypes.FeeType", name: "feeType", type: "uint8" },
|
|
1784
|
+
{
|
|
1785
|
+
internalType: "enum ACPTypes.MemoType",
|
|
1786
|
+
name: "memoType",
|
|
1787
|
+
type: "uint8"
|
|
1788
|
+
},
|
|
1789
|
+
{ internalType: "uint256", name: "expiredAt", type: "uint256" },
|
|
1790
|
+
{ internalType: "bool", name: "isSecured", type: "bool" },
|
|
1791
|
+
{
|
|
1792
|
+
internalType: "enum ACPTypes.JobPhase",
|
|
1793
|
+
name: "nextPhase",
|
|
1794
|
+
type: "uint8"
|
|
1795
|
+
},
|
|
1796
|
+
{ internalType: "uint32", name: "lzDstEid", type: "uint32" }
|
|
1797
|
+
],
|
|
1798
|
+
name: "createCrossChainPayableMemo",
|
|
1799
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
1800
|
+
stateMutability: "nonpayable",
|
|
1801
|
+
type: "function"
|
|
1802
|
+
},
|
|
1758
1803
|
{
|
|
1759
1804
|
inputs: [
|
|
1760
1805
|
{ internalType: "address", name: "provider", type: "address" },
|
|
@@ -1939,7 +1984,12 @@ var ACP_V2_ABI = [
|
|
|
1939
1984
|
name: "nextPhase",
|
|
1940
1985
|
type: "uint8"
|
|
1941
1986
|
},
|
|
1942
|
-
{ internalType: "uint256", name: "expiredAt", type: "uint256" }
|
|
1987
|
+
{ internalType: "uint256", name: "expiredAt", type: "uint256" },
|
|
1988
|
+
{
|
|
1989
|
+
internalType: "enum ACPTypes.MemoState",
|
|
1990
|
+
name: "state",
|
|
1991
|
+
type: "uint8"
|
|
1992
|
+
}
|
|
1943
1993
|
],
|
|
1944
1994
|
internalType: "struct ACPTypes.Memo[]",
|
|
1945
1995
|
name: "memos",
|
|
@@ -1986,7 +2036,12 @@ var ACP_V2_ABI = [
|
|
|
1986
2036
|
name: "nextPhase",
|
|
1987
2037
|
type: "uint8"
|
|
1988
2038
|
},
|
|
1989
|
-
{ internalType: "uint256", name: "expiredAt", type: "uint256" }
|
|
2039
|
+
{ internalType: "uint256", name: "expiredAt", type: "uint256" },
|
|
2040
|
+
{
|
|
2041
|
+
internalType: "enum ACPTypes.MemoState",
|
|
2042
|
+
name: "state",
|
|
2043
|
+
type: "uint8"
|
|
2044
|
+
}
|
|
1990
2045
|
],
|
|
1991
2046
|
internalType: "struct ACPTypes.Memo[]",
|
|
1992
2047
|
name: "memos",
|
|
@@ -2029,7 +2084,12 @@ var ACP_V2_ABI = [
|
|
|
2029
2084
|
name: "nextPhase",
|
|
2030
2085
|
type: "uint8"
|
|
2031
2086
|
},
|
|
2032
|
-
{ internalType: "uint256", name: "expiredAt", type: "uint256" }
|
|
2087
|
+
{ internalType: "uint256", name: "expiredAt", type: "uint256" },
|
|
2088
|
+
{
|
|
2089
|
+
internalType: "enum ACPTypes.MemoState",
|
|
2090
|
+
name: "state",
|
|
2091
|
+
type: "uint8"
|
|
2092
|
+
}
|
|
2033
2093
|
],
|
|
2034
2094
|
internalType: "struct ACPTypes.Memo[]",
|
|
2035
2095
|
name: "memos",
|
|
@@ -2284,8 +2344,27 @@ var acpAbiV2_default = ACP_V2_ABI;
|
|
|
2284
2344
|
// src/configs/acpConfigs.ts
|
|
2285
2345
|
var V1_MAX_RETRIES = 10;
|
|
2286
2346
|
var V2_MAX_RETRIES = 3;
|
|
2347
|
+
var TESTNET_CHAINS = [
|
|
2348
|
+
import_infra.baseSepolia,
|
|
2349
|
+
import_infra.sepolia,
|
|
2350
|
+
import_infra.polygonAmoy,
|
|
2351
|
+
import_infra.arbitrumSepolia,
|
|
2352
|
+
import_infra.bscTestnet
|
|
2353
|
+
];
|
|
2354
|
+
var MAINNET_CHAINS = [
|
|
2355
|
+
import_infra.base,
|
|
2356
|
+
import_infra.mainnet,
|
|
2357
|
+
import_infra.polygon,
|
|
2358
|
+
import_infra.arbitrum,
|
|
2359
|
+
import_infra.bsc
|
|
2360
|
+
];
|
|
2361
|
+
var DEFAULT_RETRY_CONFIG = {
|
|
2362
|
+
intervalMs: 200,
|
|
2363
|
+
multiplier: 1.1,
|
|
2364
|
+
maxRetries: 10
|
|
2365
|
+
};
|
|
2287
2366
|
var AcpContractConfig2 = class {
|
|
2288
|
-
constructor(chain, contractAddress, baseFare, alchemyRpcUrl, acpUrl, abi, maxRetries, rpcEndpoint, x402Config, retryConfig) {
|
|
2367
|
+
constructor(chain, contractAddress, baseFare, alchemyRpcUrl, acpUrl, abi, maxRetries, rpcEndpoint, x402Config, retryConfig, chains = []) {
|
|
2289
2368
|
this.chain = chain;
|
|
2290
2369
|
this.contractAddress = contractAddress;
|
|
2291
2370
|
this.baseFare = baseFare;
|
|
@@ -2296,6 +2375,7 @@ var AcpContractConfig2 = class {
|
|
|
2296
2375
|
this.rpcEndpoint = rpcEndpoint;
|
|
2297
2376
|
this.x402Config = x402Config;
|
|
2298
2377
|
this.retryConfig = retryConfig;
|
|
2378
|
+
this.chains = chains;
|
|
2299
2379
|
}
|
|
2300
2380
|
};
|
|
2301
2381
|
var baseSepoliaAcpConfig = new AcpContractConfig2(
|
|
@@ -2307,7 +2387,9 @@ var baseSepoliaAcpConfig = new AcpContractConfig2(
|
|
|
2307
2387
|
acpAbi_default,
|
|
2308
2388
|
V1_MAX_RETRIES,
|
|
2309
2389
|
void 0,
|
|
2310
|
-
void 0
|
|
2390
|
+
void 0,
|
|
2391
|
+
DEFAULT_RETRY_CONFIG,
|
|
2392
|
+
TESTNET_CHAINS
|
|
2311
2393
|
);
|
|
2312
2394
|
var baseSepoliaAcpX402Config = new AcpContractConfig2(
|
|
2313
2395
|
import_infra.baseSepolia,
|
|
@@ -2320,7 +2402,9 @@ var baseSepoliaAcpX402Config = new AcpContractConfig2(
|
|
|
2320
2402
|
void 0,
|
|
2321
2403
|
{
|
|
2322
2404
|
url: "https://dev-acp-x402.virtuals.io"
|
|
2323
|
-
}
|
|
2405
|
+
},
|
|
2406
|
+
DEFAULT_RETRY_CONFIG,
|
|
2407
|
+
TESTNET_CHAINS
|
|
2324
2408
|
);
|
|
2325
2409
|
var baseSepoliaAcpConfigV2 = new AcpContractConfig2(
|
|
2326
2410
|
import_infra.baseSepolia,
|
|
@@ -2331,7 +2415,9 @@ var baseSepoliaAcpConfigV2 = new AcpContractConfig2(
|
|
|
2331
2415
|
acpAbiV2_default,
|
|
2332
2416
|
V2_MAX_RETRIES,
|
|
2333
2417
|
void 0,
|
|
2334
|
-
void 0
|
|
2418
|
+
void 0,
|
|
2419
|
+
DEFAULT_RETRY_CONFIG,
|
|
2420
|
+
TESTNET_CHAINS
|
|
2335
2421
|
);
|
|
2336
2422
|
var baseSepoliaAcpX402ConfigV2 = new AcpContractConfig2(
|
|
2337
2423
|
import_infra.baseSepolia,
|
|
@@ -2344,7 +2430,9 @@ var baseSepoliaAcpX402ConfigV2 = new AcpContractConfig2(
|
|
|
2344
2430
|
void 0,
|
|
2345
2431
|
{
|
|
2346
2432
|
url: "https://dev-acp-x402.virtuals.io"
|
|
2347
|
-
}
|
|
2433
|
+
},
|
|
2434
|
+
DEFAULT_RETRY_CONFIG,
|
|
2435
|
+
TESTNET_CHAINS
|
|
2348
2436
|
);
|
|
2349
2437
|
var baseAcpConfig = new AcpContractConfig2(
|
|
2350
2438
|
import_infra.base,
|
|
@@ -2355,7 +2443,9 @@ var baseAcpConfig = new AcpContractConfig2(
|
|
|
2355
2443
|
acpAbi_default,
|
|
2356
2444
|
V1_MAX_RETRIES,
|
|
2357
2445
|
void 0,
|
|
2358
|
-
void 0
|
|
2446
|
+
void 0,
|
|
2447
|
+
DEFAULT_RETRY_CONFIG,
|
|
2448
|
+
MAINNET_CHAINS
|
|
2359
2449
|
);
|
|
2360
2450
|
var baseAcpX402Config = new AcpContractConfig2(
|
|
2361
2451
|
import_infra.base,
|
|
@@ -2368,7 +2458,9 @@ var baseAcpX402Config = new AcpContractConfig2(
|
|
|
2368
2458
|
void 0,
|
|
2369
2459
|
{
|
|
2370
2460
|
url: "https://acp-x402.virtuals.io"
|
|
2371
|
-
}
|
|
2461
|
+
},
|
|
2462
|
+
DEFAULT_RETRY_CONFIG,
|
|
2463
|
+
MAINNET_CHAINS
|
|
2372
2464
|
);
|
|
2373
2465
|
var baseAcpConfigV2 = new AcpContractConfig2(
|
|
2374
2466
|
import_infra.base,
|
|
@@ -2379,7 +2471,9 @@ var baseAcpConfigV2 = new AcpContractConfig2(
|
|
|
2379
2471
|
acpAbiV2_default,
|
|
2380
2472
|
V2_MAX_RETRIES,
|
|
2381
2473
|
void 0,
|
|
2382
|
-
void 0
|
|
2474
|
+
void 0,
|
|
2475
|
+
DEFAULT_RETRY_CONFIG,
|
|
2476
|
+
MAINNET_CHAINS
|
|
2383
2477
|
);
|
|
2384
2478
|
var baseAcpX402ConfigV2 = new AcpContractConfig2(
|
|
2385
2479
|
import_infra.base,
|
|
@@ -2392,7 +2486,9 @@ var baseAcpX402ConfigV2 = new AcpContractConfig2(
|
|
|
2392
2486
|
void 0,
|
|
2393
2487
|
{
|
|
2394
2488
|
url: "https://acp-x402.virtuals.io"
|
|
2395
|
-
}
|
|
2489
|
+
},
|
|
2490
|
+
DEFAULT_RETRY_CONFIG,
|
|
2491
|
+
MAINNET_CHAINS
|
|
2396
2492
|
);
|
|
2397
2493
|
|
|
2398
2494
|
// src/abis/wethAbi.ts
|
|
@@ -3571,6 +3667,7 @@ var BaseAcpContractClient = class {
|
|
|
3571
3667
|
constructor(agentWalletAddress, config = baseAcpConfig) {
|
|
3572
3668
|
this.agentWalletAddress = agentWalletAddress;
|
|
3573
3669
|
this.config = config;
|
|
3670
|
+
this.publicClients = {};
|
|
3574
3671
|
this.chain = config.chain;
|
|
3575
3672
|
this.abi = config.abi;
|
|
3576
3673
|
this.contractAddress = config.contractAddress;
|
|
@@ -3670,12 +3767,12 @@ ${JSON.stringify(
|
|
|
3670
3767
|
throw new acpError_default("Failed to create job", error);
|
|
3671
3768
|
}
|
|
3672
3769
|
}
|
|
3673
|
-
approveAllowance(amountBaseUnit, paymentTokenAddress = this.config.baseFare.contractAddress) {
|
|
3770
|
+
approveAllowance(amountBaseUnit, paymentTokenAddress = this.config.baseFare.contractAddress, targetAddress) {
|
|
3674
3771
|
try {
|
|
3675
3772
|
const data = (0, import_viem2.encodeFunctionData)({
|
|
3676
3773
|
abi: import_viem2.erc20Abi,
|
|
3677
3774
|
functionName: "approve",
|
|
3678
|
-
args: [this.contractAddress, amountBaseUnit]
|
|
3775
|
+
args: [targetAddress ?? this.contractAddress, amountBaseUnit]
|
|
3679
3776
|
});
|
|
3680
3777
|
const payload = {
|
|
3681
3778
|
data,
|
|
@@ -3714,6 +3811,35 @@ ${JSON.stringify(
|
|
|
3714
3811
|
throw new acpError_default("Failed to create payable memo", error);
|
|
3715
3812
|
}
|
|
3716
3813
|
}
|
|
3814
|
+
createCrossChainPayableMemo(jobId, content, token, amountBaseUnit, recipient, feeAmountBaseUnit, feeType, type, expiredAt, nextPhase, destinationEid, secured = true) {
|
|
3815
|
+
try {
|
|
3816
|
+
const data = (0, import_viem2.encodeFunctionData)({
|
|
3817
|
+
abi: this.abi,
|
|
3818
|
+
functionName: "createCrossChainPayableMemo",
|
|
3819
|
+
args: [
|
|
3820
|
+
jobId,
|
|
3821
|
+
content,
|
|
3822
|
+
token,
|
|
3823
|
+
amountBaseUnit,
|
|
3824
|
+
recipient,
|
|
3825
|
+
feeAmountBaseUnit,
|
|
3826
|
+
feeType,
|
|
3827
|
+
type,
|
|
3828
|
+
Math.floor(expiredAt.getTime() / 1e3),
|
|
3829
|
+
secured,
|
|
3830
|
+
nextPhase,
|
|
3831
|
+
destinationEid
|
|
3832
|
+
]
|
|
3833
|
+
});
|
|
3834
|
+
const payload = {
|
|
3835
|
+
data,
|
|
3836
|
+
contractAddress: this.contractAddress
|
|
3837
|
+
};
|
|
3838
|
+
return payload;
|
|
3839
|
+
} catch (error) {
|
|
3840
|
+
throw new acpError_default("Failed to create cross chain payable memo", error);
|
|
3841
|
+
}
|
|
3842
|
+
}
|
|
3717
3843
|
createMemo(jobId, content, type, isSecured, nextPhase) {
|
|
3718
3844
|
try {
|
|
3719
3845
|
const data = (0, import_viem2.encodeFunctionData)({
|
|
@@ -3730,6 +3856,22 @@ ${JSON.stringify(
|
|
|
3730
3856
|
throw new acpError_default("Failed to create memo", error);
|
|
3731
3857
|
}
|
|
3732
3858
|
}
|
|
3859
|
+
createMemoWithMetadata(jobId, content, type, isSecured, nextPhase, metadata) {
|
|
3860
|
+
try {
|
|
3861
|
+
const data = (0, import_viem2.encodeFunctionData)({
|
|
3862
|
+
abi: this.abi,
|
|
3863
|
+
functionName: "createMemoWithMetadata",
|
|
3864
|
+
args: [jobId, content, type, isSecured, nextPhase, metadata]
|
|
3865
|
+
});
|
|
3866
|
+
const payload = {
|
|
3867
|
+
data,
|
|
3868
|
+
contractAddress: this.contractAddress
|
|
3869
|
+
};
|
|
3870
|
+
return payload;
|
|
3871
|
+
} catch (error) {
|
|
3872
|
+
throw new acpError_default("Failed to create memo with metadata", error);
|
|
3873
|
+
}
|
|
3874
|
+
}
|
|
3733
3875
|
signMemo(memoId, isApproved, reason) {
|
|
3734
3876
|
try {
|
|
3735
3877
|
const data = (0, import_viem2.encodeFunctionData)({
|
|
@@ -3815,9 +3957,58 @@ ${JSON.stringify(
|
|
|
3815
3957
|
throw new acpError_default("Failed to submit TransferWithAuthorization", error);
|
|
3816
3958
|
}
|
|
3817
3959
|
}
|
|
3960
|
+
async getERC20Balance(chainId, tokenAddress, walletAddress) {
|
|
3961
|
+
const publicClient = this.publicClients[chainId];
|
|
3962
|
+
if (!publicClient) {
|
|
3963
|
+
throw new acpError_default(`Public client for chainId ${chainId} not found`);
|
|
3964
|
+
}
|
|
3965
|
+
return await publicClient.readContract({
|
|
3966
|
+
address: tokenAddress,
|
|
3967
|
+
abi: import_viem2.erc20Abi,
|
|
3968
|
+
functionName: "balanceOf",
|
|
3969
|
+
args: [walletAddress]
|
|
3970
|
+
});
|
|
3971
|
+
}
|
|
3972
|
+
async getERC20Allowance(chainId, tokenAddress, walletAddress, spenderAddress) {
|
|
3973
|
+
const publicClient = this.publicClients[chainId];
|
|
3974
|
+
if (!publicClient) {
|
|
3975
|
+
throw new acpError_default(`Public client for chainId ${chainId} not found`);
|
|
3976
|
+
}
|
|
3977
|
+
return await publicClient.readContract({
|
|
3978
|
+
address: tokenAddress,
|
|
3979
|
+
abi: import_viem2.erc20Abi,
|
|
3980
|
+
functionName: "allowance",
|
|
3981
|
+
args: [walletAddress, spenderAddress]
|
|
3982
|
+
});
|
|
3983
|
+
}
|
|
3984
|
+
async getERC20Symbol(chainId, tokenAddress) {
|
|
3985
|
+
const publicClient = this.publicClients[chainId];
|
|
3986
|
+
if (!publicClient) {
|
|
3987
|
+
throw new acpError_default(`Public client for chainId ${chainId} not found`);
|
|
3988
|
+
}
|
|
3989
|
+
return await publicClient.readContract({
|
|
3990
|
+
address: tokenAddress,
|
|
3991
|
+
abi: import_viem2.erc20Abi,
|
|
3992
|
+
functionName: "symbol"
|
|
3993
|
+
});
|
|
3994
|
+
}
|
|
3995
|
+
async getERC20Decimals(chainId, tokenAddress) {
|
|
3996
|
+
const publicClient = this.publicClients[chainId];
|
|
3997
|
+
if (!publicClient) {
|
|
3998
|
+
throw new acpError_default(`Public client for chainId ${chainId} not found`);
|
|
3999
|
+
}
|
|
4000
|
+
return await publicClient.readContract({
|
|
4001
|
+
address: tokenAddress,
|
|
4002
|
+
abi: import_viem2.erc20Abi,
|
|
4003
|
+
functionName: "decimals"
|
|
4004
|
+
});
|
|
4005
|
+
}
|
|
3818
4006
|
};
|
|
3819
4007
|
var baseAcpContractClient_default = BaseAcpContractClient;
|
|
3820
4008
|
|
|
4009
|
+
// src/acpJob.ts
|
|
4010
|
+
var import_viem5 = require("viem");
|
|
4011
|
+
|
|
3821
4012
|
// src/interfaces.ts
|
|
3822
4013
|
var AcpMemoStatus = /* @__PURE__ */ ((AcpMemoStatus2) => {
|
|
3823
4014
|
AcpMemoStatus2["PENDING"] = "PENDING";
|
|
@@ -3825,6 +4016,14 @@ var AcpMemoStatus = /* @__PURE__ */ ((AcpMemoStatus2) => {
|
|
|
3825
4016
|
AcpMemoStatus2["REJECTED"] = "REJECTED";
|
|
3826
4017
|
return AcpMemoStatus2;
|
|
3827
4018
|
})(AcpMemoStatus || {});
|
|
4019
|
+
var AcpMemoState = /* @__PURE__ */ ((AcpMemoState2) => {
|
|
4020
|
+
AcpMemoState2[AcpMemoState2["NONE"] = 0] = "NONE";
|
|
4021
|
+
AcpMemoState2[AcpMemoState2["PENDING"] = 1] = "PENDING";
|
|
4022
|
+
AcpMemoState2[AcpMemoState2["IN_PROGRESS"] = 2] = "IN_PROGRESS";
|
|
4023
|
+
AcpMemoState2[AcpMemoState2["FAILED"] = 3] = "FAILED";
|
|
4024
|
+
AcpMemoState2[AcpMemoState2["COMPLETED"] = 4] = "COMPLETED";
|
|
4025
|
+
return AcpMemoState2;
|
|
4026
|
+
})(AcpMemoState || {});
|
|
3828
4027
|
var AcpAgentSort = /* @__PURE__ */ ((AcpAgentSort2) => {
|
|
3829
4028
|
AcpAgentSort2["SUCCESSFUL_JOB_COUNT"] = "successfulJobCount";
|
|
3830
4029
|
AcpAgentSort2["SUCCESS_RATE"] = "successRate";
|
|
@@ -3846,6 +4045,8 @@ var AcpOnlineStatus = /* @__PURE__ */ ((AcpOnlineStatus2) => {
|
|
|
3846
4045
|
})(AcpOnlineStatus || {});
|
|
3847
4046
|
|
|
3848
4047
|
// src/utils.ts
|
|
4048
|
+
var import_viem3 = require("viem");
|
|
4049
|
+
var import_chains2 = require("viem/chains");
|
|
3849
4050
|
function tryParseJson(content) {
|
|
3850
4051
|
try {
|
|
3851
4052
|
return JSON.parse(content);
|
|
@@ -3862,9 +4063,59 @@ function safeBase64Encode(data) {
|
|
|
3862
4063
|
}
|
|
3863
4064
|
return Buffer.from(data).toString("base64");
|
|
3864
4065
|
}
|
|
4066
|
+
function getDestinationEndpointId(chainId) {
|
|
4067
|
+
switch (chainId) {
|
|
4068
|
+
case import_chains2.baseSepolia.id:
|
|
4069
|
+
return 40245;
|
|
4070
|
+
case import_chains2.sepolia.id:
|
|
4071
|
+
return 40161;
|
|
4072
|
+
case import_chains2.polygonAmoy.id:
|
|
4073
|
+
return 40267;
|
|
4074
|
+
case import_chains2.arbitrumSepolia.id:
|
|
4075
|
+
return 40231;
|
|
4076
|
+
case import_chains2.bscTestnet.id:
|
|
4077
|
+
return 40102;
|
|
4078
|
+
case import_chains2.base.id:
|
|
4079
|
+
return 30184;
|
|
4080
|
+
case import_chains2.mainnet.id:
|
|
4081
|
+
return 30101;
|
|
4082
|
+
case import_chains2.polygon.id:
|
|
4083
|
+
return 30109;
|
|
4084
|
+
case import_chains2.arbitrum.id:
|
|
4085
|
+
return 30110;
|
|
4086
|
+
case import_chains2.bsc.id:
|
|
4087
|
+
return 30102;
|
|
4088
|
+
}
|
|
4089
|
+
throw new Error(`Unsupported chain ID: ${chainId}`);
|
|
4090
|
+
}
|
|
4091
|
+
function getDestinationChainId(endpointId) {
|
|
4092
|
+
switch (endpointId) {
|
|
4093
|
+
case 40245:
|
|
4094
|
+
return import_chains2.baseSepolia.id;
|
|
4095
|
+
case 40161:
|
|
4096
|
+
return import_chains2.sepolia.id;
|
|
4097
|
+
case 40267:
|
|
4098
|
+
return import_chains2.polygonAmoy.id;
|
|
4099
|
+
case 40231:
|
|
4100
|
+
return import_chains2.arbitrumSepolia.id;
|
|
4101
|
+
case 40102:
|
|
4102
|
+
return import_chains2.bscTestnet.id;
|
|
4103
|
+
case 30184:
|
|
4104
|
+
return import_chains2.base.id;
|
|
4105
|
+
case 30101:
|
|
4106
|
+
return import_chains2.mainnet.id;
|
|
4107
|
+
case 30109:
|
|
4108
|
+
return import_chains2.polygon.id;
|
|
4109
|
+
case 30110:
|
|
4110
|
+
return import_chains2.arbitrum.id;
|
|
4111
|
+
case 30102:
|
|
4112
|
+
return import_chains2.bsc.id;
|
|
4113
|
+
}
|
|
4114
|
+
throw new Error(`Unsupported endpoint ID: ${endpointId}`);
|
|
4115
|
+
}
|
|
3865
4116
|
|
|
3866
4117
|
// src/acpJobOffering.ts
|
|
3867
|
-
var
|
|
4118
|
+
var import_viem4 = require("viem");
|
|
3868
4119
|
var import_ajv = __toESM(require("ajv"));
|
|
3869
4120
|
var AcpJobOffering = class {
|
|
3870
4121
|
constructor(acpClient, acpContractClient, providerAddress, name, price, priceType = "fixed" /* FIXED */, requirement) {
|
|
@@ -3928,7 +4179,7 @@ var AcpJobOffering = class {
|
|
|
3928
4179
|
} else {
|
|
3929
4180
|
createJobPayload = this.acpContractClient.createJobWithAccount(
|
|
3930
4181
|
account.id,
|
|
3931
|
-
evaluatorAddress ||
|
|
4182
|
+
evaluatorAddress || import_viem4.zeroAddress,
|
|
3932
4183
|
fareAmount.amount,
|
|
3933
4184
|
fareAmount.fare.contractAddress,
|
|
3934
4185
|
expiredAt,
|
|
@@ -4069,29 +4320,50 @@ var AcpJob = class {
|
|
|
4069
4320
|
}
|
|
4070
4321
|
const feeAmount = new FareAmount(0, this.acpContractClient.config.baseFare);
|
|
4071
4322
|
const isPercentagePricing = this.priceType === "percentage" /* PERCENTAGE */;
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
this.
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
|
|
4323
|
+
if (amount.fare.chainId && amount.fare.chainId !== this.acpContractClient.config.chain.id) {
|
|
4324
|
+
operations.push(
|
|
4325
|
+
this.acpContractClient.createCrossChainPayableMemo(
|
|
4326
|
+
this.id,
|
|
4327
|
+
content,
|
|
4328
|
+
amount.fare.contractAddress,
|
|
4329
|
+
amount.amount,
|
|
4330
|
+
recipient,
|
|
4331
|
+
isPercentagePricing ? BigInt(Math.round(this.priceValue * 1e4)) : feeAmount.amount,
|
|
4332
|
+
isPercentagePricing ? 3 /* PERCENTAGE_FEE */ : 0 /* NO_FEE */,
|
|
4333
|
+
type,
|
|
4334
|
+
expiredAt,
|
|
4335
|
+
2 /* TRANSACTION */,
|
|
4336
|
+
getDestinationEndpointId(amount.fare.chainId)
|
|
4337
|
+
)
|
|
4338
|
+
);
|
|
4339
|
+
} else {
|
|
4340
|
+
operations.push(
|
|
4341
|
+
this.acpContractClient.createPayableMemo(
|
|
4342
|
+
this.id,
|
|
4343
|
+
content,
|
|
4344
|
+
amount.amount,
|
|
4345
|
+
recipient,
|
|
4346
|
+
isPercentagePricing ? BigInt(Math.round(this.priceValue * 1e4)) : feeAmount.amount,
|
|
4347
|
+
isPercentagePricing ? 3 /* PERCENTAGE_FEE */ : 0 /* NO_FEE */,
|
|
4348
|
+
2 /* TRANSACTION */,
|
|
4349
|
+
type,
|
|
4350
|
+
expiredAt,
|
|
4351
|
+
amount.fare.contractAddress
|
|
4352
|
+
)
|
|
4353
|
+
);
|
|
4354
|
+
}
|
|
4086
4355
|
return await this.acpContractClient.handleOperation(operations);
|
|
4087
4356
|
}
|
|
4088
4357
|
async payAndAcceptRequirement(reason) {
|
|
4089
4358
|
const memo = this.memos.find(
|
|
4090
|
-
(m) => m.nextPhase === 2 /* TRANSACTION */
|
|
4359
|
+
(m) => m.nextPhase === 2 /* TRANSACTION */ || m.nextPhase === 4 /* COMPLETED */
|
|
4091
4360
|
);
|
|
4092
4361
|
if (!memo) {
|
|
4093
4362
|
throw new acpError_default("No notification memo found");
|
|
4094
4363
|
}
|
|
4364
|
+
if (memo.type === 6 /* PAYABLE_REQUEST */ && memo.state !== 1 /* PENDING */ && memo.payableDetails?.lzDstEid !== void 0 && memo.payableDetails?.lzDstEid !== 0) {
|
|
4365
|
+
return;
|
|
4366
|
+
}
|
|
4095
4367
|
const operations = [];
|
|
4096
4368
|
const baseFareAmount = new FareAmount(this.price, this.baseFare);
|
|
4097
4369
|
const transferAmount = memo.payableDetails ? await FareAmountBase.fromContractAddress(
|
|
@@ -4124,6 +4396,53 @@ var AcpJob = class {
|
|
|
4124
4396
|
3 /* EVALUATION */
|
|
4125
4397
|
)
|
|
4126
4398
|
);
|
|
4399
|
+
if (memo.payableDetails) {
|
|
4400
|
+
const destinationChainId = memo.payableDetails.lzDstEid ? getDestinationChainId(memo.payableDetails.lzDstEid) : this.config.chain.id;
|
|
4401
|
+
if (destinationChainId !== this.config.chain.id) {
|
|
4402
|
+
if (memo.type === 6 /* PAYABLE_REQUEST */) {
|
|
4403
|
+
const tokenBalance = await this.acpContractClient.getERC20Balance(
|
|
4404
|
+
destinationChainId,
|
|
4405
|
+
memo.payableDetails.token,
|
|
4406
|
+
this.acpContractClient.agentWalletAddress
|
|
4407
|
+
);
|
|
4408
|
+
if (tokenBalance < memo.payableDetails.amount) {
|
|
4409
|
+
const tokenDecimals = await this.acpContractClient.getERC20Decimals(
|
|
4410
|
+
destinationChainId,
|
|
4411
|
+
memo.payableDetails.token
|
|
4412
|
+
);
|
|
4413
|
+
const tokenSymbol = await this.acpContractClient.getERC20Symbol(
|
|
4414
|
+
destinationChainId,
|
|
4415
|
+
memo.payableDetails.token
|
|
4416
|
+
);
|
|
4417
|
+
throw new Error(
|
|
4418
|
+
`You do not have enough funds to pay for the job which costs ${(0, import_viem5.formatUnits)(
|
|
4419
|
+
memo.payableDetails.amount,
|
|
4420
|
+
tokenDecimals
|
|
4421
|
+
)} ${tokenSymbol} on chainId ${destinationChainId}`
|
|
4422
|
+
);
|
|
4423
|
+
}
|
|
4424
|
+
const assetManagerAddress = await this.acpContractClient.getAssetManager();
|
|
4425
|
+
const allowance = await this.acpContractClient.getERC20Allowance(
|
|
4426
|
+
destinationChainId,
|
|
4427
|
+
memo.payableDetails.token,
|
|
4428
|
+
this.acpContractClient.agentWalletAddress,
|
|
4429
|
+
assetManagerAddress
|
|
4430
|
+
);
|
|
4431
|
+
const destinationChainOperations = [];
|
|
4432
|
+
destinationChainOperations.push(
|
|
4433
|
+
this.acpContractClient.approveAllowance(
|
|
4434
|
+
memo.payableDetails.amount + allowance,
|
|
4435
|
+
memo.payableDetails.token,
|
|
4436
|
+
assetManagerAddress
|
|
4437
|
+
)
|
|
4438
|
+
);
|
|
4439
|
+
await this.acpContractClient.handleOperation(
|
|
4440
|
+
destinationChainOperations,
|
|
4441
|
+
destinationChainId
|
|
4442
|
+
);
|
|
4443
|
+
}
|
|
4444
|
+
}
|
|
4445
|
+
}
|
|
4127
4446
|
if (this.price > 0) {
|
|
4128
4447
|
const x402PaymentDetails = await this.acpContractClient.getX402PaymentDetails(this.id);
|
|
4129
4448
|
if (x402PaymentDetails.isX402) {
|
|
@@ -4196,9 +4515,6 @@ var AcpJob = class {
|
|
|
4196
4515
|
return await this.acpContractClient.handleOperation(operations);
|
|
4197
4516
|
}
|
|
4198
4517
|
async deliver(deliverable) {
|
|
4199
|
-
if (this.phase !== 2 /* TRANSACTION */) {
|
|
4200
|
-
throw new acpError_default("Job is not in transaction phase");
|
|
4201
|
-
}
|
|
4202
4518
|
const operations = [];
|
|
4203
4519
|
operations.push(
|
|
4204
4520
|
this.acpContractClient.createMemo(
|
|
@@ -4212,8 +4528,13 @@ var AcpJob = class {
|
|
|
4212
4528
|
return await this.acpContractClient.handleOperation(operations);
|
|
4213
4529
|
}
|
|
4214
4530
|
async deliverPayable(deliverable, amount, skipFee = false, expiredAt = new Date(Date.now() + 1e3 * 60 * 5)) {
|
|
4215
|
-
if (
|
|
4216
|
-
|
|
4531
|
+
if (amount.fare.chainId !== this.acpContractClient.config.chain.id) {
|
|
4532
|
+
return await this.deliverCrossChainPayable(
|
|
4533
|
+
this.clientAddress,
|
|
4534
|
+
preparePayload(deliverable),
|
|
4535
|
+
amount,
|
|
4536
|
+
skipFee
|
|
4537
|
+
);
|
|
4217
4538
|
}
|
|
4218
4539
|
const operations = [];
|
|
4219
4540
|
operations.push(
|
|
@@ -4227,7 +4548,6 @@ var AcpJob = class {
|
|
|
4227
4548
|
operations.push(
|
|
4228
4549
|
this.acpContractClient.createPayableMemo(
|
|
4229
4550
|
this.id,
|
|
4230
|
-
// memoContent.url,
|
|
4231
4551
|
preparePayload(deliverable),
|
|
4232
4552
|
amount.amount,
|
|
4233
4553
|
this.clientAddress,
|
|
@@ -4346,6 +4666,56 @@ var AcpJob = class {
|
|
|
4346
4666
|
waitMs = Math.min(waitMs * 2, maxWaitMs);
|
|
4347
4667
|
}
|
|
4348
4668
|
}
|
|
4669
|
+
async deliverCrossChainPayable(recipient, content, amount, skipFee = false) {
|
|
4670
|
+
if (!amount.fare.chainId) {
|
|
4671
|
+
throw new acpError_default("Chain ID is required for cross chain payable");
|
|
4672
|
+
}
|
|
4673
|
+
const chainId = amount.fare.chainId;
|
|
4674
|
+
const assetManagerAddress = await this.acpContractClient.getAssetManager();
|
|
4675
|
+
const tokenBalance = await this.acpContractClient.getERC20Balance(
|
|
4676
|
+
chainId,
|
|
4677
|
+
amount.fare.contractAddress,
|
|
4678
|
+
this.acpContractClient.agentWalletAddress
|
|
4679
|
+
);
|
|
4680
|
+
if (tokenBalance < amount.amount) {
|
|
4681
|
+
throw new acpError_default("Insufficient token balance for cross chain payable");
|
|
4682
|
+
}
|
|
4683
|
+
const currentAllowance = await this.acpContractClient.getERC20Allowance(
|
|
4684
|
+
chainId,
|
|
4685
|
+
amount.fare.contractAddress,
|
|
4686
|
+
this.acpContractClient.agentWalletAddress,
|
|
4687
|
+
assetManagerAddress
|
|
4688
|
+
);
|
|
4689
|
+
const approveAllowanceOperation = this.acpContractClient.approveAllowance(
|
|
4690
|
+
amount.amount + currentAllowance,
|
|
4691
|
+
amount.fare.contractAddress,
|
|
4692
|
+
assetManagerAddress
|
|
4693
|
+
);
|
|
4694
|
+
await this.acpContractClient.handleOperation(
|
|
4695
|
+
[approveAllowanceOperation],
|
|
4696
|
+
chainId
|
|
4697
|
+
);
|
|
4698
|
+
const tokenSymbol = await this.acpContractClient.getERC20Symbol(
|
|
4699
|
+
chainId,
|
|
4700
|
+
amount.fare.contractAddress
|
|
4701
|
+
);
|
|
4702
|
+
const feeAmount = new FareAmount(0, this.acpContractClient.config.baseFare);
|
|
4703
|
+
const isPercentagePricing = this.priceType === "percentage" /* PERCENTAGE */ && !skipFee;
|
|
4704
|
+
const createMemoOperation = this.acpContractClient.createCrossChainPayableMemo(
|
|
4705
|
+
this.id,
|
|
4706
|
+
content,
|
|
4707
|
+
amount.fare.contractAddress,
|
|
4708
|
+
amount.amount,
|
|
4709
|
+
recipient,
|
|
4710
|
+
isPercentagePricing ? BigInt(Math.round(this.priceValue * 1e4)) : feeAmount.amount,
|
|
4711
|
+
isPercentagePricing ? 3 /* PERCENTAGE_FEE */ : 0 /* NO_FEE */,
|
|
4712
|
+
7 /* PAYABLE_TRANSFER */,
|
|
4713
|
+
new Date(Date.now() + 1e3 * 60 * 5),
|
|
4714
|
+
4 /* COMPLETED */,
|
|
4715
|
+
getDestinationEndpointId(chainId)
|
|
4716
|
+
);
|
|
4717
|
+
await this.acpContractClient.handleOperation([createMemoOperation]);
|
|
4718
|
+
}
|
|
4349
4719
|
[util.inspect.custom]() {
|
|
4350
4720
|
return {
|
|
4351
4721
|
id: this.id,
|
|
@@ -4369,7 +4739,7 @@ var acpJob_default = AcpJob;
|
|
|
4369
4739
|
// src/acpMemo.ts
|
|
4370
4740
|
var import_util = __toESM(require("util"));
|
|
4371
4741
|
var AcpMemo = class {
|
|
4372
|
-
constructor(contractClient, id, type, content, nextPhase, status, senderAddress, signedReason, expiry, payableDetails, txHash, signedTxHash) {
|
|
4742
|
+
constructor(contractClient, id, type, content, nextPhase, status, senderAddress, signedReason, expiry, payableDetails, txHash, signedTxHash, state) {
|
|
4373
4743
|
this.contractClient = contractClient;
|
|
4374
4744
|
this.id = id;
|
|
4375
4745
|
this.type = type;
|
|
@@ -4382,6 +4752,7 @@ var AcpMemo = class {
|
|
|
4382
4752
|
this.payableDetails = payableDetails;
|
|
4383
4753
|
this.txHash = txHash;
|
|
4384
4754
|
this.signedTxHash = signedTxHash;
|
|
4755
|
+
this.state = state;
|
|
4385
4756
|
if (this.payableDetails) {
|
|
4386
4757
|
this.payableDetails.amount = BigInt(this.payableDetails.amount);
|
|
4387
4758
|
this.payableDetails.feeAmount = BigInt(this.payableDetails.feeAmount);
|
|
@@ -4664,7 +5035,8 @@ var AcpClient = class {
|
|
|
4664
5035
|
memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
|
|
4665
5036
|
memo.payableDetails,
|
|
4666
5037
|
memo.txHash,
|
|
4667
|
-
memo.signedTxHash
|
|
5038
|
+
memo.signedTxHash,
|
|
5039
|
+
memo.state
|
|
4668
5040
|
);
|
|
4669
5041
|
} catch (err) {
|
|
4670
5042
|
throw new acpError_default(`Failed to hydrate memo ${memo.id}`, err);
|
|
@@ -4740,6 +5112,8 @@ var AcpClient = class {
|
|
|
4740
5112
|
cluster,
|
|
4741
5113
|
sortBy,
|
|
4742
5114
|
topK = 5,
|
|
5115
|
+
sort_by,
|
|
5116
|
+
top_k = 5,
|
|
4743
5117
|
graduationStatus,
|
|
4744
5118
|
onlineStatus,
|
|
4745
5119
|
showHiddenOfferings
|
|
@@ -4747,10 +5121,11 @@ var AcpClient = class {
|
|
|
4747
5121
|
const params = {
|
|
4748
5122
|
search: keyword
|
|
4749
5123
|
};
|
|
4750
|
-
params.top_k = topK;
|
|
5124
|
+
params.top_k = topK || top_k;
|
|
4751
5125
|
params.walletAddressesToExclude = this.walletAddress;
|
|
4752
|
-
|
|
4753
|
-
|
|
5126
|
+
const sortByArray = sortBy || sort_by;
|
|
5127
|
+
if (sortByArray && sortByArray.length > 0) {
|
|
5128
|
+
params.sortBy = sortByArray.join(",");
|
|
4754
5129
|
}
|
|
4755
5130
|
if (cluster) {
|
|
4756
5131
|
params.cluster = cluster;
|
|
@@ -4795,7 +5170,7 @@ var AcpClient = class {
|
|
|
4795
5170
|
baseAcpConfig.contractAddress,
|
|
4796
5171
|
baseAcpX402Config.contractAddress
|
|
4797
5172
|
].includes(this.acpContractClient.config.contractAddress);
|
|
4798
|
-
const defaultEvaluatorAddress = isV1 && !evaluatorAddress ? this.walletAddress :
|
|
5173
|
+
const defaultEvaluatorAddress = isV1 && !evaluatorAddress ? this.walletAddress : import_viem6.zeroAddress;
|
|
4799
5174
|
const chainId = this.acpContractClient.config.chain.id;
|
|
4800
5175
|
const isUsdcPaymentToken = USDC_TOKEN_ADDRESS[chainId].toLowerCase() === fareAmount.fare.contractAddress.toLowerCase();
|
|
4801
5176
|
const isX402Job = this.acpContractClient.config.x402Config && isUsdcPaymentToken;
|
|
@@ -4983,10 +5358,10 @@ var acpClient_default = AcpClient;
|
|
|
4983
5358
|
var import_core = require("@aa-sdk/core");
|
|
4984
5359
|
var import_infra2 = require("@account-kit/infra");
|
|
4985
5360
|
var import_smart_contracts = require("@account-kit/smart-contracts");
|
|
4986
|
-
var
|
|
5361
|
+
var import_viem8 = require("viem");
|
|
4987
5362
|
|
|
4988
5363
|
// src/acpX402.ts
|
|
4989
|
-
var
|
|
5364
|
+
var import_viem7 = require("viem");
|
|
4990
5365
|
var import_crypto = require("crypto");
|
|
4991
5366
|
var AcpX402 = class {
|
|
4992
5367
|
constructor(config, sessionKeyClient, publicClient) {
|
|
@@ -5044,7 +5419,7 @@ var AcpX402 = class {
|
|
|
5044
5419
|
contracts: [
|
|
5045
5420
|
{
|
|
5046
5421
|
address: USDC_CONTRACT,
|
|
5047
|
-
abi:
|
|
5422
|
+
abi: import_viem7.erc20Abi,
|
|
5048
5423
|
functionName: "name"
|
|
5049
5424
|
},
|
|
5050
5425
|
{
|
|
@@ -5261,7 +5636,7 @@ var AcpContractClient = class _AcpContractClient extends baseAcpContractClient_d
|
|
|
5261
5636
|
const contractLogs = result.logs.filter((log) => {
|
|
5262
5637
|
return log.address.toLowerCase() === this.contractAddress.toLowerCase();
|
|
5263
5638
|
}).map(
|
|
5264
|
-
(log) => (0,
|
|
5639
|
+
(log) => (0, import_viem8.decodeEventLog)({
|
|
5265
5640
|
abi: this.abi,
|
|
5266
5641
|
data: log.data,
|
|
5267
5642
|
topics: log.topics
|
|
@@ -5277,7 +5652,7 @@ var AcpContractClient = class _AcpContractClient extends baseAcpContractClient_d
|
|
|
5277
5652
|
}
|
|
5278
5653
|
createJob(providerAddress, evaluatorAddress, expireAt, paymentTokenAddress, budgetBaseUnit, metadata, isX402Job) {
|
|
5279
5654
|
try {
|
|
5280
|
-
const data = (0,
|
|
5655
|
+
const data = (0, import_viem8.encodeFunctionData)({
|
|
5281
5656
|
abi: this.abi,
|
|
5282
5657
|
functionName: isX402Job ? "createJobWithX402" : "createJob",
|
|
5283
5658
|
args: [
|
|
@@ -5297,7 +5672,7 @@ var AcpContractClient = class _AcpContractClient extends baseAcpContractClient_d
|
|
|
5297
5672
|
}
|
|
5298
5673
|
setBudgetWithPaymentToken(jobId, budgetBaseUnit, paymentTokenAddress = this.config.baseFare.contractAddress) {
|
|
5299
5674
|
try {
|
|
5300
|
-
const data = (0,
|
|
5675
|
+
const data = (0, import_viem8.encodeFunctionData)({
|
|
5301
5676
|
abi: this.abi,
|
|
5302
5677
|
functionName: "setBudgetWithPaymentToken",
|
|
5303
5678
|
args: [jobId, budgetBaseUnit, paymentTokenAddress]
|
|
@@ -5313,7 +5688,7 @@ var AcpContractClient = class _AcpContractClient extends baseAcpContractClient_d
|
|
|
5313
5688
|
}
|
|
5314
5689
|
createPayableMemo(jobId, content, amountBaseUnit, recipient, feeAmountBaseUnit, feeType, nextPhase, type, expiredAt, token = this.config.baseFare.contractAddress, secured = true) {
|
|
5315
5690
|
try {
|
|
5316
|
-
const data = (0,
|
|
5691
|
+
const data = (0, import_viem8.encodeFunctionData)({
|
|
5317
5692
|
abi: this.abi,
|
|
5318
5693
|
functionName: "createPayableMemo",
|
|
5319
5694
|
args: [
|
|
@@ -5353,6 +5728,9 @@ var AcpContractClient = class _AcpContractClient extends baseAcpContractClient_d
|
|
|
5353
5728
|
async performX402Request(url, version2, budget, signature) {
|
|
5354
5729
|
return await this.acpX402.performRequest(url, version2, budget, signature);
|
|
5355
5730
|
}
|
|
5731
|
+
async getAssetManager() {
|
|
5732
|
+
throw new Error("Asset Manager not supported");
|
|
5733
|
+
}
|
|
5356
5734
|
getAcpVersion() {
|
|
5357
5735
|
return "1";
|
|
5358
5736
|
}
|
|
@@ -5366,7 +5744,7 @@ var acpContractClient_default = AcpContractClient;
|
|
|
5366
5744
|
var import_core2 = require("@aa-sdk/core");
|
|
5367
5745
|
var import_infra3 = require("@account-kit/infra");
|
|
5368
5746
|
var import_smart_contracts2 = require("@account-kit/smart-contracts");
|
|
5369
|
-
var
|
|
5747
|
+
var import_viem9 = require("viem");
|
|
5370
5748
|
|
|
5371
5749
|
// src/abis/jobManagerAbi.ts
|
|
5372
5750
|
var JOB_MANAGER_ABI = [
|
|
@@ -6070,88 +6448,1246 @@ var JOB_MANAGER_ABI = [
|
|
|
6070
6448
|
var jobManagerAbi_default = JOB_MANAGER_ABI;
|
|
6071
6449
|
|
|
6072
6450
|
// src/contractClients/acpContractClientV2.ts
|
|
6073
|
-
var
|
|
6074
|
-
|
|
6075
|
-
|
|
6076
|
-
|
|
6077
|
-
|
|
6078
|
-
|
|
6079
|
-
|
|
6080
|
-
|
|
6081
|
-
|
|
6082
|
-
|
|
6083
|
-
|
|
6084
|
-
|
|
6085
|
-
|
|
6086
|
-
|
|
6087
|
-
|
|
6088
|
-
|
|
6089
|
-
|
|
6090
|
-
|
|
6091
|
-
|
|
6092
|
-
|
|
6093
|
-
|
|
6094
|
-
|
|
6095
|
-
|
|
6096
|
-
|
|
6097
|
-
|
|
6098
|
-
|
|
6099
|
-
|
|
6100
|
-
|
|
6101
|
-
|
|
6102
|
-
|
|
6103
|
-
|
|
6104
|
-
|
|
6105
|
-
|
|
6106
|
-
|
|
6107
|
-
|
|
6108
|
-
|
|
6109
|
-
|
|
6110
|
-
|
|
6111
|
-
|
|
6112
|
-
|
|
6113
|
-
|
|
6114
|
-
|
|
6115
|
-
|
|
6116
|
-
|
|
6117
|
-
|
|
6118
|
-
|
|
6119
|
-
|
|
6120
|
-
|
|
6121
|
-
|
|
6122
|
-
|
|
6123
|
-
|
|
6124
|
-
|
|
6125
|
-
|
|
6126
|
-
|
|
6127
|
-
}
|
|
6128
|
-
|
|
6129
|
-
|
|
6130
|
-
|
|
6131
|
-
|
|
6132
|
-
|
|
6133
|
-
|
|
6134
|
-
|
|
6135
|
-
|
|
6136
|
-
|
|
6137
|
-
|
|
6138
|
-
|
|
6139
|
-
|
|
6140
|
-
|
|
6141
|
-
|
|
6142
|
-
|
|
6143
|
-
|
|
6144
|
-
|
|
6145
|
-
|
|
6146
|
-
|
|
6147
|
-
|
|
6148
|
-
|
|
6149
|
-
|
|
6150
|
-
|
|
6151
|
-
|
|
6152
|
-
|
|
6153
|
-
|
|
6154
|
-
|
|
6451
|
+
var import_chains3 = require("viem/chains");
|
|
6452
|
+
|
|
6453
|
+
// src/abis/memoManagerAbi.ts
|
|
6454
|
+
var MEMO_MANAGER_ABI = [
|
|
6455
|
+
{ inputs: [], stateMutability: "nonpayable", type: "constructor" },
|
|
6456
|
+
{ inputs: [], name: "AccessControlBadConfirmation", type: "error" },
|
|
6457
|
+
{
|
|
6458
|
+
inputs: [
|
|
6459
|
+
{ internalType: "address", name: "account", type: "address" },
|
|
6460
|
+
{ internalType: "bytes32", name: "neededRole", type: "bytes32" }
|
|
6461
|
+
],
|
|
6462
|
+
name: "AccessControlUnauthorizedAccount",
|
|
6463
|
+
type: "error"
|
|
6464
|
+
},
|
|
6465
|
+
{
|
|
6466
|
+
inputs: [{ internalType: "address", name: "target", type: "address" }],
|
|
6467
|
+
name: "AddressEmptyCode",
|
|
6468
|
+
type: "error"
|
|
6469
|
+
},
|
|
6470
|
+
{ inputs: [], name: "AlreadyVoted", type: "error" },
|
|
6471
|
+
{ inputs: [], name: "CannotApproveMemo", type: "error" },
|
|
6472
|
+
{ inputs: [], name: "CannotUpdateApprovedMemo", type: "error" },
|
|
6473
|
+
{ inputs: [], name: "CannotUpdateMemo", type: "error" },
|
|
6474
|
+
{ inputs: [], name: "CannotWithdrawYet", type: "error" },
|
|
6475
|
+
{ inputs: [], name: "DestinationChainNotConfigured", type: "error" },
|
|
6476
|
+
{
|
|
6477
|
+
inputs: [
|
|
6478
|
+
{ internalType: "address", name: "implementation", type: "address" }
|
|
6479
|
+
],
|
|
6480
|
+
name: "ERC1967InvalidImplementation",
|
|
6481
|
+
type: "error"
|
|
6482
|
+
},
|
|
6483
|
+
{ inputs: [], name: "ERC1967NonPayable", type: "error" },
|
|
6484
|
+
{ inputs: [], name: "EmptyContent", type: "error" },
|
|
6485
|
+
{ inputs: [], name: "FailedInnerCall", type: "error" },
|
|
6486
|
+
{ inputs: [], name: "InvalidInitialization", type: "error" },
|
|
6487
|
+
{ inputs: [], name: "InvalidMemoState", type: "error" },
|
|
6488
|
+
{ inputs: [], name: "InvalidMemoStateTransition", type: "error" },
|
|
6489
|
+
{ inputs: [], name: "InvalidMemoType", type: "error" },
|
|
6490
|
+
{ inputs: [], name: "JobAlreadyCompleted", type: "error" },
|
|
6491
|
+
{ inputs: [], name: "JobDoesNotExist", type: "error" },
|
|
6492
|
+
{ inputs: [], name: "MemoAlreadyApproved", type: "error" },
|
|
6493
|
+
{ inputs: [], name: "MemoAlreadyExecuted", type: "error" },
|
|
6494
|
+
{ inputs: [], name: "MemoAlreadySigned", type: "error" },
|
|
6495
|
+
{ inputs: [], name: "MemoCannotBeSigned", type: "error" },
|
|
6496
|
+
{ inputs: [], name: "MemoDoesNotExist", type: "error" },
|
|
6497
|
+
{ inputs: [], name: "MemoDoesNotRequireApproval", type: "error" },
|
|
6498
|
+
{ inputs: [], name: "MemoExpired", type: "error" },
|
|
6499
|
+
{ inputs: [], name: "MemoNotApproved", type: "error" },
|
|
6500
|
+
{ inputs: [], name: "MemoNotReadyToBeSigned", type: "error" },
|
|
6501
|
+
{ inputs: [], name: "MemoStateUnchanged", type: "error" },
|
|
6502
|
+
{ inputs: [], name: "NoAmountToTransfer", type: "error" },
|
|
6503
|
+
{ inputs: [], name: "NoPaymentAmount", type: "error" },
|
|
6504
|
+
{ inputs: [], name: "NotEscrowTransferMemoType", type: "error" },
|
|
6505
|
+
{ inputs: [], name: "NotInitializing", type: "error" },
|
|
6506
|
+
{ inputs: [], name: "NotPayableMemoType", type: "error" },
|
|
6507
|
+
{ inputs: [], name: "OnlyACPContract", type: "error" },
|
|
6508
|
+
{ inputs: [], name: "OnlyAssetManager", type: "error" },
|
|
6509
|
+
{ inputs: [], name: "OnlyClientOrProvider", type: "error" },
|
|
6510
|
+
{ inputs: [], name: "OnlyCounterParty", type: "error" },
|
|
6511
|
+
{ inputs: [], name: "OnlyEvaluator", type: "error" },
|
|
6512
|
+
{ inputs: [], name: "OnlyMemoSender", type: "error" },
|
|
6513
|
+
{ inputs: [], name: "ReentrancyGuardReentrantCall", type: "error" },
|
|
6514
|
+
{ inputs: [], name: "UUPSUnauthorizedCallContext", type: "error" },
|
|
6515
|
+
{
|
|
6516
|
+
inputs: [{ internalType: "bytes32", name: "slot", type: "bytes32" }],
|
|
6517
|
+
name: "UUPSUnsupportedProxiableUUID",
|
|
6518
|
+
type: "error"
|
|
6519
|
+
},
|
|
6520
|
+
{ inputs: [], name: "ZeroAcpContractAddress", type: "error" },
|
|
6521
|
+
{ inputs: [], name: "ZeroAddressRecipient", type: "error" },
|
|
6522
|
+
{ inputs: [], name: "ZeroAddressToken", type: "error" },
|
|
6523
|
+
{ inputs: [], name: "ZeroAssetManagerAddress", type: "error" },
|
|
6524
|
+
{ inputs: [], name: "ZeroJobManagerAddress", type: "error" },
|
|
6525
|
+
{
|
|
6526
|
+
anonymous: false,
|
|
6527
|
+
inputs: [
|
|
6528
|
+
{
|
|
6529
|
+
indexed: false,
|
|
6530
|
+
internalType: "uint64",
|
|
6531
|
+
name: "version",
|
|
6532
|
+
type: "uint64"
|
|
6533
|
+
}
|
|
6534
|
+
],
|
|
6535
|
+
name: "Initialized",
|
|
6536
|
+
type: "event"
|
|
6537
|
+
},
|
|
6538
|
+
{
|
|
6539
|
+
anonymous: false,
|
|
6540
|
+
inputs: [
|
|
6541
|
+
{
|
|
6542
|
+
indexed: true,
|
|
6543
|
+
internalType: "uint256",
|
|
6544
|
+
name: "memoId",
|
|
6545
|
+
type: "uint256"
|
|
6546
|
+
},
|
|
6547
|
+
{
|
|
6548
|
+
indexed: true,
|
|
6549
|
+
internalType: "address",
|
|
6550
|
+
name: "approver",
|
|
6551
|
+
type: "address"
|
|
6552
|
+
},
|
|
6553
|
+
{ indexed: false, internalType: "bool", name: "approved", type: "bool" },
|
|
6554
|
+
{
|
|
6555
|
+
indexed: false,
|
|
6556
|
+
internalType: "string",
|
|
6557
|
+
name: "reason",
|
|
6558
|
+
type: "string"
|
|
6559
|
+
}
|
|
6560
|
+
],
|
|
6561
|
+
name: "MemoSigned",
|
|
6562
|
+
type: "event"
|
|
6563
|
+
},
|
|
6564
|
+
{
|
|
6565
|
+
anonymous: false,
|
|
6566
|
+
inputs: [
|
|
6567
|
+
{
|
|
6568
|
+
indexed: true,
|
|
6569
|
+
internalType: "uint256",
|
|
6570
|
+
name: "memoId",
|
|
6571
|
+
type: "uint256"
|
|
6572
|
+
},
|
|
6573
|
+
{
|
|
6574
|
+
indexed: false,
|
|
6575
|
+
internalType: "enum ACPTypes.MemoState",
|
|
6576
|
+
name: "oldState",
|
|
6577
|
+
type: "uint8"
|
|
6578
|
+
},
|
|
6579
|
+
{
|
|
6580
|
+
indexed: false,
|
|
6581
|
+
internalType: "enum ACPTypes.MemoState",
|
|
6582
|
+
name: "newState",
|
|
6583
|
+
type: "uint8"
|
|
6584
|
+
}
|
|
6585
|
+
],
|
|
6586
|
+
name: "MemoStateUpdated",
|
|
6587
|
+
type: "event"
|
|
6588
|
+
},
|
|
6589
|
+
{
|
|
6590
|
+
anonymous: false,
|
|
6591
|
+
inputs: [
|
|
6592
|
+
{
|
|
6593
|
+
indexed: true,
|
|
6594
|
+
internalType: "uint256",
|
|
6595
|
+
name: "memoId",
|
|
6596
|
+
type: "uint256"
|
|
6597
|
+
},
|
|
6598
|
+
{
|
|
6599
|
+
indexed: true,
|
|
6600
|
+
internalType: "uint256",
|
|
6601
|
+
name: "jobId",
|
|
6602
|
+
type: "uint256"
|
|
6603
|
+
},
|
|
6604
|
+
{
|
|
6605
|
+
indexed: true,
|
|
6606
|
+
internalType: "address",
|
|
6607
|
+
name: "sender",
|
|
6608
|
+
type: "address"
|
|
6609
|
+
},
|
|
6610
|
+
{
|
|
6611
|
+
indexed: false,
|
|
6612
|
+
internalType: "enum ACPTypes.MemoType",
|
|
6613
|
+
name: "memoType",
|
|
6614
|
+
type: "uint8"
|
|
6615
|
+
},
|
|
6616
|
+
{
|
|
6617
|
+
indexed: false,
|
|
6618
|
+
internalType: "enum ACPTypes.JobPhase",
|
|
6619
|
+
name: "nextPhase",
|
|
6620
|
+
type: "uint8"
|
|
6621
|
+
},
|
|
6622
|
+
{
|
|
6623
|
+
indexed: false,
|
|
6624
|
+
internalType: "string",
|
|
6625
|
+
name: "content",
|
|
6626
|
+
type: "string"
|
|
6627
|
+
}
|
|
6628
|
+
],
|
|
6629
|
+
name: "NewMemo",
|
|
6630
|
+
type: "event"
|
|
6631
|
+
},
|
|
6632
|
+
{
|
|
6633
|
+
anonymous: false,
|
|
6634
|
+
inputs: [
|
|
6635
|
+
{
|
|
6636
|
+
indexed: true,
|
|
6637
|
+
internalType: "uint256",
|
|
6638
|
+
name: "jobId",
|
|
6639
|
+
type: "uint256"
|
|
6640
|
+
},
|
|
6641
|
+
{
|
|
6642
|
+
indexed: true,
|
|
6643
|
+
internalType: "uint256",
|
|
6644
|
+
name: "memoId",
|
|
6645
|
+
type: "uint256"
|
|
6646
|
+
},
|
|
6647
|
+
{
|
|
6648
|
+
indexed: true,
|
|
6649
|
+
internalType: "address",
|
|
6650
|
+
name: "sender",
|
|
6651
|
+
type: "address"
|
|
6652
|
+
},
|
|
6653
|
+
{
|
|
6654
|
+
indexed: false,
|
|
6655
|
+
internalType: "address",
|
|
6656
|
+
name: "token",
|
|
6657
|
+
type: "address"
|
|
6658
|
+
},
|
|
6659
|
+
{
|
|
6660
|
+
indexed: false,
|
|
6661
|
+
internalType: "uint256",
|
|
6662
|
+
name: "amount",
|
|
6663
|
+
type: "uint256"
|
|
6664
|
+
}
|
|
6665
|
+
],
|
|
6666
|
+
name: "PayableFeeRefunded",
|
|
6667
|
+
type: "event"
|
|
6668
|
+
},
|
|
6669
|
+
{
|
|
6670
|
+
anonymous: false,
|
|
6671
|
+
inputs: [
|
|
6672
|
+
{
|
|
6673
|
+
indexed: true,
|
|
6674
|
+
internalType: "uint256",
|
|
6675
|
+
name: "jobId",
|
|
6676
|
+
type: "uint256"
|
|
6677
|
+
},
|
|
6678
|
+
{
|
|
6679
|
+
indexed: true,
|
|
6680
|
+
internalType: "uint256",
|
|
6681
|
+
name: "memoId",
|
|
6682
|
+
type: "uint256"
|
|
6683
|
+
},
|
|
6684
|
+
{
|
|
6685
|
+
indexed: true,
|
|
6686
|
+
internalType: "address",
|
|
6687
|
+
name: "sender",
|
|
6688
|
+
type: "address"
|
|
6689
|
+
},
|
|
6690
|
+
{
|
|
6691
|
+
indexed: false,
|
|
6692
|
+
internalType: "address",
|
|
6693
|
+
name: "token",
|
|
6694
|
+
type: "address"
|
|
6695
|
+
},
|
|
6696
|
+
{
|
|
6697
|
+
indexed: false,
|
|
6698
|
+
internalType: "uint256",
|
|
6699
|
+
name: "amount",
|
|
6700
|
+
type: "uint256"
|
|
6701
|
+
}
|
|
6702
|
+
],
|
|
6703
|
+
name: "PayableFundsRefunded",
|
|
6704
|
+
type: "event"
|
|
6705
|
+
},
|
|
6706
|
+
{
|
|
6707
|
+
anonymous: false,
|
|
6708
|
+
inputs: [
|
|
6709
|
+
{
|
|
6710
|
+
indexed: true,
|
|
6711
|
+
internalType: "uint256",
|
|
6712
|
+
name: "memoId",
|
|
6713
|
+
type: "uint256"
|
|
6714
|
+
},
|
|
6715
|
+
{
|
|
6716
|
+
indexed: true,
|
|
6717
|
+
internalType: "uint256",
|
|
6718
|
+
name: "jobId",
|
|
6719
|
+
type: "uint256"
|
|
6720
|
+
},
|
|
6721
|
+
{
|
|
6722
|
+
indexed: true,
|
|
6723
|
+
internalType: "address",
|
|
6724
|
+
name: "executor",
|
|
6725
|
+
type: "address"
|
|
6726
|
+
},
|
|
6727
|
+
{
|
|
6728
|
+
indexed: false,
|
|
6729
|
+
internalType: "uint256",
|
|
6730
|
+
name: "amount",
|
|
6731
|
+
type: "uint256"
|
|
6732
|
+
}
|
|
6733
|
+
],
|
|
6734
|
+
name: "PayableMemoExecuted",
|
|
6735
|
+
type: "event"
|
|
6736
|
+
},
|
|
6737
|
+
{
|
|
6738
|
+
anonymous: false,
|
|
6739
|
+
inputs: [
|
|
6740
|
+
{ indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
|
|
6741
|
+
{
|
|
6742
|
+
indexed: true,
|
|
6743
|
+
internalType: "bytes32",
|
|
6744
|
+
name: "previousAdminRole",
|
|
6745
|
+
type: "bytes32"
|
|
6746
|
+
},
|
|
6747
|
+
{
|
|
6748
|
+
indexed: true,
|
|
6749
|
+
internalType: "bytes32",
|
|
6750
|
+
name: "newAdminRole",
|
|
6751
|
+
type: "bytes32"
|
|
6752
|
+
}
|
|
6753
|
+
],
|
|
6754
|
+
name: "RoleAdminChanged",
|
|
6755
|
+
type: "event"
|
|
6756
|
+
},
|
|
6757
|
+
{
|
|
6758
|
+
anonymous: false,
|
|
6759
|
+
inputs: [
|
|
6760
|
+
{ indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
|
|
6761
|
+
{
|
|
6762
|
+
indexed: true,
|
|
6763
|
+
internalType: "address",
|
|
6764
|
+
name: "account",
|
|
6765
|
+
type: "address"
|
|
6766
|
+
},
|
|
6767
|
+
{
|
|
6768
|
+
indexed: true,
|
|
6769
|
+
internalType: "address",
|
|
6770
|
+
name: "sender",
|
|
6771
|
+
type: "address"
|
|
6772
|
+
}
|
|
6773
|
+
],
|
|
6774
|
+
name: "RoleGranted",
|
|
6775
|
+
type: "event"
|
|
6776
|
+
},
|
|
6777
|
+
{
|
|
6778
|
+
anonymous: false,
|
|
6779
|
+
inputs: [
|
|
6780
|
+
{ indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
|
|
6781
|
+
{
|
|
6782
|
+
indexed: true,
|
|
6783
|
+
internalType: "address",
|
|
6784
|
+
name: "account",
|
|
6785
|
+
type: "address"
|
|
6786
|
+
},
|
|
6787
|
+
{
|
|
6788
|
+
indexed: true,
|
|
6789
|
+
internalType: "address",
|
|
6790
|
+
name: "sender",
|
|
6791
|
+
type: "address"
|
|
6792
|
+
}
|
|
6793
|
+
],
|
|
6794
|
+
name: "RoleRevoked",
|
|
6795
|
+
type: "event"
|
|
6796
|
+
},
|
|
6797
|
+
{
|
|
6798
|
+
anonymous: false,
|
|
6799
|
+
inputs: [
|
|
6800
|
+
{
|
|
6801
|
+
indexed: true,
|
|
6802
|
+
internalType: "address",
|
|
6803
|
+
name: "implementation",
|
|
6804
|
+
type: "address"
|
|
6805
|
+
}
|
|
6806
|
+
],
|
|
6807
|
+
name: "Upgraded",
|
|
6808
|
+
type: "event"
|
|
6809
|
+
},
|
|
6810
|
+
{
|
|
6811
|
+
inputs: [],
|
|
6812
|
+
name: "ACP_CONTRACT_ROLE",
|
|
6813
|
+
outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
|
|
6814
|
+
stateMutability: "view",
|
|
6815
|
+
type: "function"
|
|
6816
|
+
},
|
|
6817
|
+
{
|
|
6818
|
+
inputs: [],
|
|
6819
|
+
name: "ADMIN_ROLE",
|
|
6820
|
+
outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
|
|
6821
|
+
stateMutability: "view",
|
|
6822
|
+
type: "function"
|
|
6823
|
+
},
|
|
6824
|
+
{
|
|
6825
|
+
inputs: [],
|
|
6826
|
+
name: "DEFAULT_ADMIN_ROLE",
|
|
6827
|
+
outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
|
|
6828
|
+
stateMutability: "view",
|
|
6829
|
+
type: "function"
|
|
6830
|
+
},
|
|
6831
|
+
{
|
|
6832
|
+
inputs: [],
|
|
6833
|
+
name: "UPGRADE_INTERFACE_VERSION",
|
|
6834
|
+
outputs: [{ internalType: "string", name: "", type: "string" }],
|
|
6835
|
+
stateMutability: "view",
|
|
6836
|
+
type: "function"
|
|
6837
|
+
},
|
|
6838
|
+
{
|
|
6839
|
+
inputs: [],
|
|
6840
|
+
name: "acpContract",
|
|
6841
|
+
outputs: [{ internalType: "address", name: "", type: "address" }],
|
|
6842
|
+
stateMutability: "view",
|
|
6843
|
+
type: "function"
|
|
6844
|
+
},
|
|
6845
|
+
{
|
|
6846
|
+
inputs: [
|
|
6847
|
+
{ internalType: "uint256", name: "memoId", type: "uint256" },
|
|
6848
|
+
{ internalType: "address", name: "sender", type: "address" },
|
|
6849
|
+
{ internalType: "bool", name: "approved", type: "bool" },
|
|
6850
|
+
{ internalType: "string", name: "reason", type: "string" }
|
|
6851
|
+
],
|
|
6852
|
+
name: "approveMemo",
|
|
6853
|
+
outputs: [],
|
|
6854
|
+
stateMutability: "nonpayable",
|
|
6855
|
+
type: "function"
|
|
6856
|
+
},
|
|
6857
|
+
{
|
|
6858
|
+
inputs: [],
|
|
6859
|
+
name: "assetManager",
|
|
6860
|
+
outputs: [{ internalType: "address", name: "", type: "address" }],
|
|
6861
|
+
stateMutability: "view",
|
|
6862
|
+
type: "function"
|
|
6863
|
+
},
|
|
6864
|
+
{
|
|
6865
|
+
inputs: [
|
|
6866
|
+
{ internalType: "uint256[]", name: "memoIds", type: "uint256[]" },
|
|
6867
|
+
{ internalType: "bool", name: "approved", type: "bool" },
|
|
6868
|
+
{ internalType: "string", name: "reason", type: "string" }
|
|
6869
|
+
],
|
|
6870
|
+
name: "bulkApproveMemos",
|
|
6871
|
+
outputs: [],
|
|
6872
|
+
stateMutability: "nonpayable",
|
|
6873
|
+
type: "function"
|
|
6874
|
+
},
|
|
6875
|
+
{
|
|
6876
|
+
inputs: [
|
|
6877
|
+
{ internalType: "uint256", name: "memoId", type: "uint256" },
|
|
6878
|
+
{ internalType: "address", name: "user", type: "address" }
|
|
6879
|
+
],
|
|
6880
|
+
name: "canApproveMemo",
|
|
6881
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
6882
|
+
stateMutability: "view",
|
|
6883
|
+
type: "function"
|
|
6884
|
+
},
|
|
6885
|
+
{
|
|
6886
|
+
inputs: [
|
|
6887
|
+
{ internalType: "uint256", name: "jobId", type: "uint256" },
|
|
6888
|
+
{ internalType: "address", name: "sender", type: "address" },
|
|
6889
|
+
{ internalType: "string", name: "content", type: "string" },
|
|
6890
|
+
{
|
|
6891
|
+
internalType: "enum ACPTypes.MemoType",
|
|
6892
|
+
name: "memoType",
|
|
6893
|
+
type: "uint8"
|
|
6894
|
+
},
|
|
6895
|
+
{ internalType: "bool", name: "isSecured", type: "bool" },
|
|
6896
|
+
{
|
|
6897
|
+
internalType: "enum ACPTypes.JobPhase",
|
|
6898
|
+
name: "nextPhase",
|
|
6899
|
+
type: "uint8"
|
|
6900
|
+
},
|
|
6901
|
+
{ internalType: "string", name: "metadata", type: "string" }
|
|
6902
|
+
],
|
|
6903
|
+
name: "createMemo",
|
|
6904
|
+
outputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
|
|
6905
|
+
stateMutability: "nonpayable",
|
|
6906
|
+
type: "function"
|
|
6907
|
+
},
|
|
6908
|
+
{
|
|
6909
|
+
inputs: [
|
|
6910
|
+
{ internalType: "uint256", name: "jobId", type: "uint256" },
|
|
6911
|
+
{ internalType: "address", name: "sender", type: "address" },
|
|
6912
|
+
{ internalType: "string", name: "content", type: "string" },
|
|
6913
|
+
{
|
|
6914
|
+
internalType: "enum ACPTypes.MemoType",
|
|
6915
|
+
name: "memoType",
|
|
6916
|
+
type: "uint8"
|
|
6917
|
+
},
|
|
6918
|
+
{ internalType: "bool", name: "isSecured", type: "bool" },
|
|
6919
|
+
{
|
|
6920
|
+
internalType: "enum ACPTypes.JobPhase",
|
|
6921
|
+
name: "nextPhase",
|
|
6922
|
+
type: "uint8"
|
|
6923
|
+
},
|
|
6924
|
+
{
|
|
6925
|
+
components: [
|
|
6926
|
+
{ internalType: "address", name: "token", type: "address" },
|
|
6927
|
+
{ internalType: "uint256", name: "amount", type: "uint256" },
|
|
6928
|
+
{ internalType: "address", name: "recipient", type: "address" },
|
|
6929
|
+
{ internalType: "uint256", name: "feeAmount", type: "uint256" },
|
|
6930
|
+
{
|
|
6931
|
+
internalType: "enum ACPTypes.FeeType",
|
|
6932
|
+
name: "feeType",
|
|
6933
|
+
type: "uint8"
|
|
6934
|
+
},
|
|
6935
|
+
{ internalType: "bool", name: "isExecuted", type: "bool" },
|
|
6936
|
+
{ internalType: "uint256", name: "expiredAt", type: "uint256" },
|
|
6937
|
+
{ internalType: "uint32", name: "lzSrcEid", type: "uint32" },
|
|
6938
|
+
{ internalType: "uint32", name: "lzDstEid", type: "uint32" }
|
|
6939
|
+
],
|
|
6940
|
+
internalType: "struct ACPTypes.PayableDetails",
|
|
6941
|
+
name: "payableDetails_",
|
|
6942
|
+
type: "tuple"
|
|
6943
|
+
},
|
|
6944
|
+
{ internalType: "uint256", name: "expiredAt", type: "uint256" }
|
|
6945
|
+
],
|
|
6946
|
+
name: "createPayableMemo",
|
|
6947
|
+
outputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
|
|
6948
|
+
stateMutability: "nonpayable",
|
|
6949
|
+
type: "function"
|
|
6950
|
+
},
|
|
6951
|
+
{
|
|
6952
|
+
inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
|
|
6953
|
+
name: "emergencyApproveMemo",
|
|
6954
|
+
outputs: [],
|
|
6955
|
+
stateMutability: "nonpayable",
|
|
6956
|
+
type: "function"
|
|
6957
|
+
},
|
|
6958
|
+
{
|
|
6959
|
+
inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
|
|
6960
|
+
name: "executePayableMemo",
|
|
6961
|
+
outputs: [],
|
|
6962
|
+
stateMutability: "nonpayable",
|
|
6963
|
+
type: "function"
|
|
6964
|
+
},
|
|
6965
|
+
{
|
|
6966
|
+
inputs: [],
|
|
6967
|
+
name: "getAssetManager",
|
|
6968
|
+
outputs: [{ internalType: "address", name: "", type: "address" }],
|
|
6969
|
+
stateMutability: "view",
|
|
6970
|
+
type: "function"
|
|
6971
|
+
},
|
|
6972
|
+
{
|
|
6973
|
+
inputs: [
|
|
6974
|
+
{ internalType: "uint256", name: "jobId", type: "uint256" },
|
|
6975
|
+
{ internalType: "uint256", name: "offset", type: "uint256" },
|
|
6976
|
+
{ internalType: "uint256", name: "limit", type: "uint256" }
|
|
6977
|
+
],
|
|
6978
|
+
name: "getJobMemos",
|
|
6979
|
+
outputs: [
|
|
6980
|
+
{
|
|
6981
|
+
components: [
|
|
6982
|
+
{ internalType: "uint256", name: "id", type: "uint256" },
|
|
6983
|
+
{ internalType: "uint256", name: "jobId", type: "uint256" },
|
|
6984
|
+
{ internalType: "address", name: "sender", type: "address" },
|
|
6985
|
+
{ internalType: "string", name: "content", type: "string" },
|
|
6986
|
+
{
|
|
6987
|
+
internalType: "enum ACPTypes.MemoType",
|
|
6988
|
+
name: "memoType",
|
|
6989
|
+
type: "uint8"
|
|
6990
|
+
},
|
|
6991
|
+
{ internalType: "uint256", name: "createdAt", type: "uint256" },
|
|
6992
|
+
{ internalType: "bool", name: "isApproved", type: "bool" },
|
|
6993
|
+
{ internalType: "address", name: "approvedBy", type: "address" },
|
|
6994
|
+
{ internalType: "uint256", name: "approvedAt", type: "uint256" },
|
|
6995
|
+
{ internalType: "bool", name: "requiresApproval", type: "bool" },
|
|
6996
|
+
{ internalType: "string", name: "metadata", type: "string" },
|
|
6997
|
+
{ internalType: "bool", name: "isSecured", type: "bool" },
|
|
6998
|
+
{
|
|
6999
|
+
internalType: "enum ACPTypes.JobPhase",
|
|
7000
|
+
name: "nextPhase",
|
|
7001
|
+
type: "uint8"
|
|
7002
|
+
},
|
|
7003
|
+
{ internalType: "uint256", name: "expiredAt", type: "uint256" },
|
|
7004
|
+
{
|
|
7005
|
+
internalType: "enum ACPTypes.MemoState",
|
|
7006
|
+
name: "state",
|
|
7007
|
+
type: "uint8"
|
|
7008
|
+
}
|
|
7009
|
+
],
|
|
7010
|
+
internalType: "struct ACPTypes.Memo[]",
|
|
7011
|
+
name: "memoArray",
|
|
7012
|
+
type: "tuple[]"
|
|
7013
|
+
},
|
|
7014
|
+
{ internalType: "uint256", name: "total", type: "uint256" }
|
|
7015
|
+
],
|
|
7016
|
+
stateMutability: "view",
|
|
7017
|
+
type: "function"
|
|
7018
|
+
},
|
|
7019
|
+
{
|
|
7020
|
+
inputs: [
|
|
7021
|
+
{ internalType: "uint256", name: "jobId", type: "uint256" },
|
|
7022
|
+
{ internalType: "enum ACPTypes.JobPhase", name: "phase", type: "uint8" },
|
|
7023
|
+
{ internalType: "uint256", name: "offset", type: "uint256" },
|
|
7024
|
+
{ internalType: "uint256", name: "limit", type: "uint256" }
|
|
7025
|
+
],
|
|
7026
|
+
name: "getJobMemosByPhase",
|
|
7027
|
+
outputs: [
|
|
7028
|
+
{
|
|
7029
|
+
components: [
|
|
7030
|
+
{ internalType: "uint256", name: "id", type: "uint256" },
|
|
7031
|
+
{ internalType: "uint256", name: "jobId", type: "uint256" },
|
|
7032
|
+
{ internalType: "address", name: "sender", type: "address" },
|
|
7033
|
+
{ internalType: "string", name: "content", type: "string" },
|
|
7034
|
+
{
|
|
7035
|
+
internalType: "enum ACPTypes.MemoType",
|
|
7036
|
+
name: "memoType",
|
|
7037
|
+
type: "uint8"
|
|
7038
|
+
},
|
|
7039
|
+
{ internalType: "uint256", name: "createdAt", type: "uint256" },
|
|
7040
|
+
{ internalType: "bool", name: "isApproved", type: "bool" },
|
|
7041
|
+
{ internalType: "address", name: "approvedBy", type: "address" },
|
|
7042
|
+
{ internalType: "uint256", name: "approvedAt", type: "uint256" },
|
|
7043
|
+
{ internalType: "bool", name: "requiresApproval", type: "bool" },
|
|
7044
|
+
{ internalType: "string", name: "metadata", type: "string" },
|
|
7045
|
+
{ internalType: "bool", name: "isSecured", type: "bool" },
|
|
7046
|
+
{
|
|
7047
|
+
internalType: "enum ACPTypes.JobPhase",
|
|
7048
|
+
name: "nextPhase",
|
|
7049
|
+
type: "uint8"
|
|
7050
|
+
},
|
|
7051
|
+
{ internalType: "uint256", name: "expiredAt", type: "uint256" },
|
|
7052
|
+
{
|
|
7053
|
+
internalType: "enum ACPTypes.MemoState",
|
|
7054
|
+
name: "state",
|
|
7055
|
+
type: "uint8"
|
|
7056
|
+
}
|
|
7057
|
+
],
|
|
7058
|
+
internalType: "struct ACPTypes.Memo[]",
|
|
7059
|
+
name: "memoArray",
|
|
7060
|
+
type: "tuple[]"
|
|
7061
|
+
},
|
|
7062
|
+
{ internalType: "uint256", name: "total", type: "uint256" }
|
|
7063
|
+
],
|
|
7064
|
+
stateMutability: "view",
|
|
7065
|
+
type: "function"
|
|
7066
|
+
},
|
|
7067
|
+
{
|
|
7068
|
+
inputs: [
|
|
7069
|
+
{ internalType: "uint256", name: "jobId", type: "uint256" },
|
|
7070
|
+
{
|
|
7071
|
+
internalType: "enum ACPTypes.MemoType",
|
|
7072
|
+
name: "memoType",
|
|
7073
|
+
type: "uint8"
|
|
7074
|
+
},
|
|
7075
|
+
{ internalType: "uint256", name: "offset", type: "uint256" },
|
|
7076
|
+
{ internalType: "uint256", name: "limit", type: "uint256" }
|
|
7077
|
+
],
|
|
7078
|
+
name: "getJobMemosByType",
|
|
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: "memoArray",
|
|
7112
|
+
type: "tuple[]"
|
|
7113
|
+
},
|
|
7114
|
+
{ internalType: "uint256", name: "total", type: "uint256" }
|
|
7115
|
+
],
|
|
7116
|
+
stateMutability: "view",
|
|
7117
|
+
type: "function"
|
|
7118
|
+
},
|
|
7119
|
+
{
|
|
7120
|
+
inputs: [],
|
|
7121
|
+
name: "getLocalEid",
|
|
7122
|
+
outputs: [{ internalType: "uint32", name: "", type: "uint32" }],
|
|
7123
|
+
stateMutability: "view",
|
|
7124
|
+
type: "function"
|
|
7125
|
+
},
|
|
7126
|
+
{
|
|
7127
|
+
inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
|
|
7128
|
+
name: "getMemo",
|
|
7129
|
+
outputs: [
|
|
7130
|
+
{
|
|
7131
|
+
components: [
|
|
7132
|
+
{ internalType: "uint256", name: "id", type: "uint256" },
|
|
7133
|
+
{ internalType: "uint256", name: "jobId", type: "uint256" },
|
|
7134
|
+
{ internalType: "address", name: "sender", type: "address" },
|
|
7135
|
+
{ internalType: "string", name: "content", type: "string" },
|
|
7136
|
+
{
|
|
7137
|
+
internalType: "enum ACPTypes.MemoType",
|
|
7138
|
+
name: "memoType",
|
|
7139
|
+
type: "uint8"
|
|
7140
|
+
},
|
|
7141
|
+
{ internalType: "uint256", name: "createdAt", type: "uint256" },
|
|
7142
|
+
{ internalType: "bool", name: "isApproved", type: "bool" },
|
|
7143
|
+
{ internalType: "address", name: "approvedBy", type: "address" },
|
|
7144
|
+
{ internalType: "uint256", name: "approvedAt", type: "uint256" },
|
|
7145
|
+
{ internalType: "bool", name: "requiresApproval", type: "bool" },
|
|
7146
|
+
{ internalType: "string", name: "metadata", type: "string" },
|
|
7147
|
+
{ internalType: "bool", name: "isSecured", type: "bool" },
|
|
7148
|
+
{
|
|
7149
|
+
internalType: "enum ACPTypes.JobPhase",
|
|
7150
|
+
name: "nextPhase",
|
|
7151
|
+
type: "uint8"
|
|
7152
|
+
},
|
|
7153
|
+
{ internalType: "uint256", name: "expiredAt", type: "uint256" },
|
|
7154
|
+
{
|
|
7155
|
+
internalType: "enum ACPTypes.MemoState",
|
|
7156
|
+
name: "state",
|
|
7157
|
+
type: "uint8"
|
|
7158
|
+
}
|
|
7159
|
+
],
|
|
7160
|
+
internalType: "struct ACPTypes.Memo",
|
|
7161
|
+
name: "",
|
|
7162
|
+
type: "tuple"
|
|
7163
|
+
}
|
|
7164
|
+
],
|
|
7165
|
+
stateMutability: "view",
|
|
7166
|
+
type: "function"
|
|
7167
|
+
},
|
|
7168
|
+
{
|
|
7169
|
+
inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
|
|
7170
|
+
name: "getMemoApprovalStatus",
|
|
7171
|
+
outputs: [
|
|
7172
|
+
{ internalType: "bool", name: "isApproved", type: "bool" },
|
|
7173
|
+
{ internalType: "address", name: "approvedBy", type: "address" },
|
|
7174
|
+
{ internalType: "uint256", name: "approvedAt", type: "uint256" }
|
|
7175
|
+
],
|
|
7176
|
+
stateMutability: "view",
|
|
7177
|
+
type: "function"
|
|
7178
|
+
},
|
|
7179
|
+
{
|
|
7180
|
+
inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
|
|
7181
|
+
name: "getMemoWithPayableDetails",
|
|
7182
|
+
outputs: [
|
|
7183
|
+
{
|
|
7184
|
+
components: [
|
|
7185
|
+
{ internalType: "uint256", name: "id", type: "uint256" },
|
|
7186
|
+
{ internalType: "uint256", name: "jobId", type: "uint256" },
|
|
7187
|
+
{ internalType: "address", name: "sender", type: "address" },
|
|
7188
|
+
{ internalType: "string", name: "content", type: "string" },
|
|
7189
|
+
{
|
|
7190
|
+
internalType: "enum ACPTypes.MemoType",
|
|
7191
|
+
name: "memoType",
|
|
7192
|
+
type: "uint8"
|
|
7193
|
+
},
|
|
7194
|
+
{ internalType: "uint256", name: "createdAt", type: "uint256" },
|
|
7195
|
+
{ internalType: "bool", name: "isApproved", type: "bool" },
|
|
7196
|
+
{ internalType: "address", name: "approvedBy", type: "address" },
|
|
7197
|
+
{ internalType: "uint256", name: "approvedAt", type: "uint256" },
|
|
7198
|
+
{ internalType: "bool", name: "requiresApproval", type: "bool" },
|
|
7199
|
+
{ internalType: "string", name: "metadata", type: "string" },
|
|
7200
|
+
{ internalType: "bool", name: "isSecured", type: "bool" },
|
|
7201
|
+
{
|
|
7202
|
+
internalType: "enum ACPTypes.JobPhase",
|
|
7203
|
+
name: "nextPhase",
|
|
7204
|
+
type: "uint8"
|
|
7205
|
+
},
|
|
7206
|
+
{ internalType: "uint256", name: "expiredAt", type: "uint256" },
|
|
7207
|
+
{
|
|
7208
|
+
internalType: "enum ACPTypes.MemoState",
|
|
7209
|
+
name: "state",
|
|
7210
|
+
type: "uint8"
|
|
7211
|
+
}
|
|
7212
|
+
],
|
|
7213
|
+
internalType: "struct ACPTypes.Memo",
|
|
7214
|
+
name: "memo",
|
|
7215
|
+
type: "tuple"
|
|
7216
|
+
},
|
|
7217
|
+
{
|
|
7218
|
+
components: [
|
|
7219
|
+
{ internalType: "address", name: "token", type: "address" },
|
|
7220
|
+
{ internalType: "uint256", name: "amount", type: "uint256" },
|
|
7221
|
+
{ internalType: "address", name: "recipient", type: "address" },
|
|
7222
|
+
{ internalType: "uint256", name: "feeAmount", type: "uint256" },
|
|
7223
|
+
{
|
|
7224
|
+
internalType: "enum ACPTypes.FeeType",
|
|
7225
|
+
name: "feeType",
|
|
7226
|
+
type: "uint8"
|
|
7227
|
+
},
|
|
7228
|
+
{ internalType: "bool", name: "isExecuted", type: "bool" },
|
|
7229
|
+
{ internalType: "uint256", name: "expiredAt", type: "uint256" },
|
|
7230
|
+
{ internalType: "uint32", name: "lzSrcEid", type: "uint32" },
|
|
7231
|
+
{ internalType: "uint32", name: "lzDstEid", type: "uint32" }
|
|
7232
|
+
],
|
|
7233
|
+
internalType: "struct ACPTypes.PayableDetails",
|
|
7234
|
+
name: "details",
|
|
7235
|
+
type: "tuple"
|
|
7236
|
+
}
|
|
7237
|
+
],
|
|
7238
|
+
stateMutability: "view",
|
|
7239
|
+
type: "function"
|
|
7240
|
+
},
|
|
7241
|
+
{
|
|
7242
|
+
inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
|
|
7243
|
+
name: "getPayableDetails",
|
|
7244
|
+
outputs: [
|
|
7245
|
+
{
|
|
7246
|
+
components: [
|
|
7247
|
+
{ internalType: "address", name: "token", type: "address" },
|
|
7248
|
+
{ internalType: "uint256", name: "amount", type: "uint256" },
|
|
7249
|
+
{ internalType: "address", name: "recipient", type: "address" },
|
|
7250
|
+
{ internalType: "uint256", name: "feeAmount", type: "uint256" },
|
|
7251
|
+
{
|
|
7252
|
+
internalType: "enum ACPTypes.FeeType",
|
|
7253
|
+
name: "feeType",
|
|
7254
|
+
type: "uint8"
|
|
7255
|
+
},
|
|
7256
|
+
{ internalType: "bool", name: "isExecuted", type: "bool" },
|
|
7257
|
+
{ internalType: "uint256", name: "expiredAt", type: "uint256" },
|
|
7258
|
+
{ internalType: "uint32", name: "lzSrcEid", type: "uint32" },
|
|
7259
|
+
{ internalType: "uint32", name: "lzDstEid", type: "uint32" }
|
|
7260
|
+
],
|
|
7261
|
+
internalType: "struct ACPTypes.PayableDetails",
|
|
7262
|
+
name: "",
|
|
7263
|
+
type: "tuple"
|
|
7264
|
+
}
|
|
7265
|
+
],
|
|
7266
|
+
stateMutability: "view",
|
|
7267
|
+
type: "function"
|
|
7268
|
+
},
|
|
7269
|
+
{
|
|
7270
|
+
inputs: [{ internalType: "bytes32", name: "role", type: "bytes32" }],
|
|
7271
|
+
name: "getRoleAdmin",
|
|
7272
|
+
outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
|
|
7273
|
+
stateMutability: "view",
|
|
7274
|
+
type: "function"
|
|
7275
|
+
},
|
|
7276
|
+
{
|
|
7277
|
+
inputs: [
|
|
7278
|
+
{ internalType: "bytes32", name: "role", type: "bytes32" },
|
|
7279
|
+
{ internalType: "address", name: "account", type: "address" }
|
|
7280
|
+
],
|
|
7281
|
+
name: "grantRole",
|
|
7282
|
+
outputs: [],
|
|
7283
|
+
stateMutability: "nonpayable",
|
|
7284
|
+
type: "function"
|
|
7285
|
+
},
|
|
7286
|
+
{
|
|
7287
|
+
inputs: [
|
|
7288
|
+
{ internalType: "bytes32", name: "role", type: "bytes32" },
|
|
7289
|
+
{ internalType: "address", name: "account", type: "address" }
|
|
7290
|
+
],
|
|
7291
|
+
name: "hasRole",
|
|
7292
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
7293
|
+
stateMutability: "view",
|
|
7294
|
+
type: "function"
|
|
7295
|
+
},
|
|
7296
|
+
{
|
|
7297
|
+
inputs: [
|
|
7298
|
+
{ internalType: "address", name: "acpContract_", type: "address" },
|
|
7299
|
+
{ internalType: "address", name: "jobManager_", type: "address" },
|
|
7300
|
+
{ internalType: "address", name: "paymentManager_", type: "address" }
|
|
7301
|
+
],
|
|
7302
|
+
name: "initialize",
|
|
7303
|
+
outputs: [],
|
|
7304
|
+
stateMutability: "nonpayable",
|
|
7305
|
+
type: "function"
|
|
7306
|
+
},
|
|
7307
|
+
{
|
|
7308
|
+
inputs: [
|
|
7309
|
+
{ internalType: "uint256", name: "jobId", type: "uint256" },
|
|
7310
|
+
{ internalType: "address", name: "user", type: "address" }
|
|
7311
|
+
],
|
|
7312
|
+
name: "isJobEvaluator",
|
|
7313
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
7314
|
+
stateMutability: "view",
|
|
7315
|
+
type: "function"
|
|
7316
|
+
},
|
|
7317
|
+
{
|
|
7318
|
+
inputs: [
|
|
7319
|
+
{ internalType: "uint256", name: "memoId", type: "uint256" },
|
|
7320
|
+
{ internalType: "address", name: "user", type: "address" }
|
|
7321
|
+
],
|
|
7322
|
+
name: "isMemoSigner",
|
|
7323
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
7324
|
+
stateMutability: "view",
|
|
7325
|
+
type: "function"
|
|
7326
|
+
},
|
|
7327
|
+
{
|
|
7328
|
+
inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
|
|
7329
|
+
name: "isPayable",
|
|
7330
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
7331
|
+
stateMutability: "view",
|
|
7332
|
+
type: "function"
|
|
7333
|
+
},
|
|
7334
|
+
{
|
|
7335
|
+
inputs: [],
|
|
7336
|
+
name: "jobManager",
|
|
7337
|
+
outputs: [{ internalType: "address", name: "", type: "address" }],
|
|
7338
|
+
stateMutability: "view",
|
|
7339
|
+
type: "function"
|
|
7340
|
+
},
|
|
7341
|
+
{
|
|
7342
|
+
inputs: [
|
|
7343
|
+
{ internalType: "uint256", name: "", type: "uint256" },
|
|
7344
|
+
{ internalType: "uint256", name: "", type: "uint256" }
|
|
7345
|
+
],
|
|
7346
|
+
name: "jobMemos",
|
|
7347
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
7348
|
+
stateMutability: "view",
|
|
7349
|
+
type: "function"
|
|
7350
|
+
},
|
|
7351
|
+
{
|
|
7352
|
+
inputs: [
|
|
7353
|
+
{ internalType: "uint256", name: "", type: "uint256" },
|
|
7354
|
+
{ internalType: "enum ACPTypes.JobPhase", name: "", type: "uint8" },
|
|
7355
|
+
{ internalType: "uint256", name: "", type: "uint256" }
|
|
7356
|
+
],
|
|
7357
|
+
name: "jobMemosByPhase",
|
|
7358
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
7359
|
+
stateMutability: "view",
|
|
7360
|
+
type: "function"
|
|
7361
|
+
},
|
|
7362
|
+
{
|
|
7363
|
+
inputs: [
|
|
7364
|
+
{ internalType: "uint256", name: "", type: "uint256" },
|
|
7365
|
+
{ internalType: "enum ACPTypes.MemoType", name: "", type: "uint8" },
|
|
7366
|
+
{ internalType: "uint256", name: "", type: "uint256" }
|
|
7367
|
+
],
|
|
7368
|
+
name: "jobMemosByType",
|
|
7369
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
7370
|
+
stateMutability: "view",
|
|
7371
|
+
type: "function"
|
|
7372
|
+
},
|
|
7373
|
+
{
|
|
7374
|
+
inputs: [
|
|
7375
|
+
{ internalType: "uint256", name: "", type: "uint256" },
|
|
7376
|
+
{ internalType: "address", name: "", type: "address" }
|
|
7377
|
+
],
|
|
7378
|
+
name: "memoApprovals",
|
|
7379
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
7380
|
+
stateMutability: "view",
|
|
7381
|
+
type: "function"
|
|
7382
|
+
},
|
|
7383
|
+
{
|
|
7384
|
+
inputs: [],
|
|
7385
|
+
name: "memoCounter",
|
|
7386
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
7387
|
+
stateMutability: "view",
|
|
7388
|
+
type: "function"
|
|
7389
|
+
},
|
|
7390
|
+
{
|
|
7391
|
+
inputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
7392
|
+
name: "memos",
|
|
7393
|
+
outputs: [
|
|
7394
|
+
{ internalType: "uint256", name: "id", type: "uint256" },
|
|
7395
|
+
{ internalType: "uint256", name: "jobId", type: "uint256" },
|
|
7396
|
+
{ internalType: "address", name: "sender", type: "address" },
|
|
7397
|
+
{ internalType: "string", name: "content", type: "string" },
|
|
7398
|
+
{
|
|
7399
|
+
internalType: "enum ACPTypes.MemoType",
|
|
7400
|
+
name: "memoType",
|
|
7401
|
+
type: "uint8"
|
|
7402
|
+
},
|
|
7403
|
+
{ internalType: "uint256", name: "createdAt", type: "uint256" },
|
|
7404
|
+
{ internalType: "bool", name: "isApproved", type: "bool" },
|
|
7405
|
+
{ internalType: "address", name: "approvedBy", type: "address" },
|
|
7406
|
+
{ internalType: "uint256", name: "approvedAt", type: "uint256" },
|
|
7407
|
+
{ internalType: "bool", name: "requiresApproval", type: "bool" },
|
|
7408
|
+
{ internalType: "string", name: "metadata", type: "string" },
|
|
7409
|
+
{ internalType: "bool", name: "isSecured", type: "bool" },
|
|
7410
|
+
{
|
|
7411
|
+
internalType: "enum ACPTypes.JobPhase",
|
|
7412
|
+
name: "nextPhase",
|
|
7413
|
+
type: "uint8"
|
|
7414
|
+
},
|
|
7415
|
+
{ internalType: "uint256", name: "expiredAt", type: "uint256" },
|
|
7416
|
+
{ internalType: "enum ACPTypes.MemoState", name: "state", type: "uint8" }
|
|
7417
|
+
],
|
|
7418
|
+
stateMutability: "view",
|
|
7419
|
+
type: "function"
|
|
7420
|
+
},
|
|
7421
|
+
{
|
|
7422
|
+
inputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
7423
|
+
name: "payableDetails",
|
|
7424
|
+
outputs: [
|
|
7425
|
+
{ internalType: "address", name: "token", type: "address" },
|
|
7426
|
+
{ internalType: "uint256", name: "amount", type: "uint256" },
|
|
7427
|
+
{ internalType: "address", name: "recipient", type: "address" },
|
|
7428
|
+
{ internalType: "uint256", name: "feeAmount", type: "uint256" },
|
|
7429
|
+
{ internalType: "enum ACPTypes.FeeType", name: "feeType", type: "uint8" },
|
|
7430
|
+
{ internalType: "bool", name: "isExecuted", type: "bool" },
|
|
7431
|
+
{ internalType: "uint256", name: "expiredAt", type: "uint256" },
|
|
7432
|
+
{ internalType: "uint32", name: "lzSrcEid", type: "uint32" },
|
|
7433
|
+
{ internalType: "uint32", name: "lzDstEid", type: "uint32" }
|
|
7434
|
+
],
|
|
7435
|
+
stateMutability: "view",
|
|
7436
|
+
type: "function"
|
|
7437
|
+
},
|
|
7438
|
+
{
|
|
7439
|
+
inputs: [],
|
|
7440
|
+
name: "paymentManager",
|
|
7441
|
+
outputs: [{ internalType: "address", name: "", type: "address" }],
|
|
7442
|
+
stateMutability: "view",
|
|
7443
|
+
type: "function"
|
|
7444
|
+
},
|
|
7445
|
+
{
|
|
7446
|
+
inputs: [],
|
|
7447
|
+
name: "proxiableUUID",
|
|
7448
|
+
outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
|
|
7449
|
+
stateMutability: "view",
|
|
7450
|
+
type: "function"
|
|
7451
|
+
},
|
|
7452
|
+
{
|
|
7453
|
+
inputs: [
|
|
7454
|
+
{ internalType: "bytes32", name: "role", type: "bytes32" },
|
|
7455
|
+
{ internalType: "address", name: "callerConfirmation", type: "address" }
|
|
7456
|
+
],
|
|
7457
|
+
name: "renounceRole",
|
|
7458
|
+
outputs: [],
|
|
7459
|
+
stateMutability: "nonpayable",
|
|
7460
|
+
type: "function"
|
|
7461
|
+
},
|
|
7462
|
+
{
|
|
7463
|
+
inputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
7464
|
+
name: "requiredApprovals",
|
|
7465
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
7466
|
+
stateMutability: "view",
|
|
7467
|
+
type: "function"
|
|
7468
|
+
},
|
|
7469
|
+
{
|
|
7470
|
+
inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
|
|
7471
|
+
name: "requiresApproval",
|
|
7472
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
7473
|
+
stateMutability: "view",
|
|
7474
|
+
type: "function"
|
|
7475
|
+
},
|
|
7476
|
+
{
|
|
7477
|
+
inputs: [
|
|
7478
|
+
{ internalType: "bytes32", name: "role", type: "bytes32" },
|
|
7479
|
+
{ internalType: "address", name: "account", type: "address" }
|
|
7480
|
+
],
|
|
7481
|
+
name: "revokeRole",
|
|
7482
|
+
outputs: [],
|
|
7483
|
+
stateMutability: "nonpayable",
|
|
7484
|
+
type: "function"
|
|
7485
|
+
},
|
|
7486
|
+
{
|
|
7487
|
+
inputs: [
|
|
7488
|
+
{
|
|
7489
|
+
internalType: "enum ACPTypes.MemoType",
|
|
7490
|
+
name: "memoType",
|
|
7491
|
+
type: "uint8"
|
|
7492
|
+
},
|
|
7493
|
+
{ internalType: "uint256", name: "requiredApprovals_", type: "uint256" }
|
|
7494
|
+
],
|
|
7495
|
+
name: "setApprovalRequirements",
|
|
7496
|
+
outputs: [],
|
|
7497
|
+
stateMutability: "nonpayable",
|
|
7498
|
+
type: "function"
|
|
7499
|
+
},
|
|
7500
|
+
{
|
|
7501
|
+
inputs: [
|
|
7502
|
+
{ internalType: "address", name: "assetManager_", type: "address" }
|
|
7503
|
+
],
|
|
7504
|
+
name: "setAssetManager",
|
|
7505
|
+
outputs: [],
|
|
7506
|
+
stateMutability: "nonpayable",
|
|
7507
|
+
type: "function"
|
|
7508
|
+
},
|
|
7509
|
+
{
|
|
7510
|
+
inputs: [
|
|
7511
|
+
{ internalType: "uint256", name: "memoId", type: "uint256" },
|
|
7512
|
+
{ internalType: "address", name: "sender", type: "address" },
|
|
7513
|
+
{ internalType: "bool", name: "isApproved", type: "bool" },
|
|
7514
|
+
{ internalType: "string", name: "reason", type: "string" }
|
|
7515
|
+
],
|
|
7516
|
+
name: "signMemo",
|
|
7517
|
+
outputs: [{ internalType: "uint256", name: "jobId", type: "uint256" }],
|
|
7518
|
+
stateMutability: "nonpayable",
|
|
7519
|
+
type: "function"
|
|
7520
|
+
},
|
|
7521
|
+
{
|
|
7522
|
+
inputs: [{ internalType: "bytes4", name: "interfaceId", type: "bytes4" }],
|
|
7523
|
+
name: "supportsInterface",
|
|
7524
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
7525
|
+
stateMutability: "view",
|
|
7526
|
+
type: "function"
|
|
7527
|
+
},
|
|
7528
|
+
{
|
|
7529
|
+
inputs: [
|
|
7530
|
+
{ internalType: "address", name: "acpContract_", type: "address" },
|
|
7531
|
+
{ internalType: "address", name: "jobManager_", type: "address" },
|
|
7532
|
+
{ internalType: "address", name: "paymentManager_", type: "address" },
|
|
7533
|
+
{ internalType: "address", name: "assetManager_", type: "address" }
|
|
7534
|
+
],
|
|
7535
|
+
name: "updateContracts",
|
|
7536
|
+
outputs: [],
|
|
7537
|
+
stateMutability: "nonpayable",
|
|
7538
|
+
type: "function"
|
|
7539
|
+
},
|
|
7540
|
+
{
|
|
7541
|
+
inputs: [
|
|
7542
|
+
{ internalType: "uint256", name: "memoId", type: "uint256" },
|
|
7543
|
+
{ internalType: "string", name: "newContent", type: "string" }
|
|
7544
|
+
],
|
|
7545
|
+
name: "updateMemoContent",
|
|
7546
|
+
outputs: [],
|
|
7547
|
+
stateMutability: "nonpayable",
|
|
7548
|
+
type: "function"
|
|
7549
|
+
},
|
|
7550
|
+
{
|
|
7551
|
+
inputs: [
|
|
7552
|
+
{ internalType: "uint256", name: "memoId", type: "uint256" },
|
|
7553
|
+
{
|
|
7554
|
+
internalType: "enum ACPTypes.MemoState",
|
|
7555
|
+
name: "newMemoState",
|
|
7556
|
+
type: "uint8"
|
|
7557
|
+
}
|
|
7558
|
+
],
|
|
7559
|
+
name: "updateMemoState",
|
|
7560
|
+
outputs: [],
|
|
7561
|
+
stateMutability: "nonpayable",
|
|
7562
|
+
type: "function"
|
|
7563
|
+
},
|
|
7564
|
+
{
|
|
7565
|
+
inputs: [
|
|
7566
|
+
{ internalType: "address", name: "newImplementation", type: "address" },
|
|
7567
|
+
{ internalType: "bytes", name: "data", type: "bytes" }
|
|
7568
|
+
],
|
|
7569
|
+
name: "upgradeToAndCall",
|
|
7570
|
+
outputs: [],
|
|
7571
|
+
stateMutability: "payable",
|
|
7572
|
+
type: "function"
|
|
7573
|
+
},
|
|
7574
|
+
{
|
|
7575
|
+
inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
|
|
7576
|
+
name: "withdrawEscrowedFunds",
|
|
7577
|
+
outputs: [],
|
|
7578
|
+
stateMutability: "nonpayable",
|
|
7579
|
+
type: "function"
|
|
7580
|
+
}
|
|
7581
|
+
];
|
|
7582
|
+
var memoManagerAbi_default = MEMO_MANAGER_ABI;
|
|
7583
|
+
|
|
7584
|
+
// src/contractClients/acpContractClientV2.ts
|
|
7585
|
+
var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClient_default {
|
|
7586
|
+
constructor(jobManagerAddress, memoManagerAddress, accountManagerAddress, agentWalletAddress, config = baseAcpConfigV2) {
|
|
7587
|
+
super(agentWalletAddress, config);
|
|
7588
|
+
this.jobManagerAddress = jobManagerAddress;
|
|
7589
|
+
this.memoManagerAddress = memoManagerAddress;
|
|
7590
|
+
this.accountManagerAddress = accountManagerAddress;
|
|
7591
|
+
this.PRIORITY_FEE_MULTIPLIER = 2;
|
|
7592
|
+
this.MAX_FEE_PER_GAS = 2e7;
|
|
7593
|
+
this.MAX_PRIORITY_FEE_PER_GAS = 21e6;
|
|
7594
|
+
this.GAS_FEE_MULTIPLIER = 0.5;
|
|
7595
|
+
this.RETRY_CONFIG = {
|
|
7596
|
+
intervalMs: 200,
|
|
7597
|
+
multiplier: 1.1,
|
|
7598
|
+
maxRetries: 10
|
|
7599
|
+
};
|
|
7600
|
+
this._sessionKeyClients = {};
|
|
7601
|
+
}
|
|
7602
|
+
static async build(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfigV2) {
|
|
7603
|
+
const publicClients = {};
|
|
7604
|
+
for (const chain of config.chains) {
|
|
7605
|
+
publicClients[chain.id] = (0, import_viem9.createPublicClient)({
|
|
7606
|
+
chain,
|
|
7607
|
+
transport: (0, import_viem9.http)(`${config.alchemyRpcUrl}?chainId=${chain.id}`)
|
|
7608
|
+
});
|
|
7609
|
+
}
|
|
7610
|
+
const publicClient = (0, import_viem9.createPublicClient)({
|
|
7611
|
+
chain: config.chain,
|
|
7612
|
+
transport: (0, import_viem9.http)(config.rpcEndpoint)
|
|
7613
|
+
});
|
|
7614
|
+
const [jobManagerAddress, memoManagerAddress, accountManagerAddress] = await publicClient.multicall({
|
|
7615
|
+
contracts: [
|
|
7616
|
+
{
|
|
7617
|
+
address: config.contractAddress,
|
|
7618
|
+
abi: config.abi,
|
|
7619
|
+
functionName: "jobManager"
|
|
7620
|
+
},
|
|
7621
|
+
{
|
|
7622
|
+
address: config.contractAddress,
|
|
7623
|
+
abi: config.abi,
|
|
7624
|
+
functionName: "memoManager"
|
|
7625
|
+
},
|
|
7626
|
+
{
|
|
7627
|
+
address: config.contractAddress,
|
|
7628
|
+
abi: config.abi,
|
|
7629
|
+
functionName: "accountManager"
|
|
7630
|
+
}
|
|
7631
|
+
]
|
|
7632
|
+
});
|
|
7633
|
+
if (!jobManagerAddress || !memoManagerAddress || !accountManagerAddress) {
|
|
7634
|
+
throw new acpError_default(
|
|
7635
|
+
"Failed to get job manager, memo manager, or account manager address"
|
|
7636
|
+
);
|
|
7637
|
+
}
|
|
7638
|
+
const acpContractClient = new _AcpContractClientV2(
|
|
7639
|
+
jobManagerAddress.result,
|
|
7640
|
+
memoManagerAddress.result,
|
|
7641
|
+
accountManagerAddress.result,
|
|
7642
|
+
agentWalletAddress,
|
|
7643
|
+
config
|
|
7644
|
+
);
|
|
7645
|
+
acpContractClient.publicClients = publicClients;
|
|
7646
|
+
await acpContractClient.init(walletPrivateKey, sessionEntityKeyId);
|
|
7647
|
+
return acpContractClient;
|
|
7648
|
+
}
|
|
7649
|
+
async init(privateKey, sessionEntityKeyId) {
|
|
7650
|
+
const sessionKeySigner = import_core2.LocalAccountSigner.privateKeyToAccountSigner(privateKey);
|
|
7651
|
+
this._sessionKeyClient = await (0, import_smart_contracts2.createModularAccountV2Client)({
|
|
7652
|
+
chain: this.chain,
|
|
7653
|
+
transport: (0, import_infra3.alchemy)({
|
|
7654
|
+
rpcUrl: this.config.alchemyRpcUrl
|
|
7655
|
+
}),
|
|
7656
|
+
signer: sessionKeySigner,
|
|
7657
|
+
policyId: "186aaa4a-5f57-4156-83fb-e456365a8820",
|
|
7658
|
+
accountAddress: this.agentWalletAddress,
|
|
7659
|
+
signerEntity: {
|
|
7660
|
+
entityId: sessionEntityKeyId,
|
|
7661
|
+
isGlobalValidation: true
|
|
7662
|
+
}
|
|
7663
|
+
});
|
|
7664
|
+
for (const chain of this.config.chains) {
|
|
7665
|
+
this._sessionKeyClients[chain.id] = await (0, import_smart_contracts2.createModularAccountV2Client)({
|
|
7666
|
+
chain,
|
|
7667
|
+
transport: (0, import_infra3.alchemy)({
|
|
7668
|
+
rpcUrl: `${this.config.alchemyRpcUrl}?chainId=${chain.id}`
|
|
7669
|
+
}),
|
|
7670
|
+
signer: sessionKeySigner,
|
|
7671
|
+
policyId: "186aaa4a-5f57-4156-83fb-e456365a8820",
|
|
7672
|
+
accountAddress: this.agentWalletAddress,
|
|
7673
|
+
signerEntity: {
|
|
7674
|
+
entityId: sessionEntityKeyId,
|
|
7675
|
+
isGlobalValidation: true
|
|
7676
|
+
}
|
|
7677
|
+
});
|
|
7678
|
+
}
|
|
7679
|
+
this._acpX402 = new AcpX402(
|
|
7680
|
+
this.config,
|
|
7681
|
+
this.sessionKeyClient,
|
|
7682
|
+
this.publicClient
|
|
7683
|
+
);
|
|
7684
|
+
const account = this.sessionKeyClient.account;
|
|
7685
|
+
const sessionSignerAddress = await account.getSigner().getAddress();
|
|
7686
|
+
if (!await account.isAccountDeployed()) {
|
|
7687
|
+
throw new acpError_default(
|
|
7688
|
+
`ACP Contract Client validation failed: agent account ${this.agentWalletAddress} is not deployed on-chain`
|
|
7689
|
+
);
|
|
7690
|
+
}
|
|
6155
7691
|
await this.validateSessionKeyOnChain(
|
|
6156
7692
|
sessionSignerAddress,
|
|
6157
7693
|
sessionEntityKeyId
|
|
@@ -6184,11 +7720,20 @@ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClie
|
|
|
6184
7720
|
}
|
|
6185
7721
|
return this._acpX402;
|
|
6186
7722
|
}
|
|
6187
|
-
async calculateGasFees() {
|
|
7723
|
+
async calculateGasFees(chainId) {
|
|
7724
|
+
if (chainId) {
|
|
7725
|
+
const { maxFeePerGas } = await this.publicClients[chainId].estimateFeesPerGas();
|
|
7726
|
+
const increasedMaxFeePerGas = BigInt(maxFeePerGas) + BigInt(maxFeePerGas) * BigInt(this.GAS_FEE_MULTIPLIER * 100) / BigInt(100);
|
|
7727
|
+
return increasedMaxFeePerGas;
|
|
7728
|
+
}
|
|
6188
7729
|
const finalMaxFeePerGas = BigInt(this.MAX_FEE_PER_GAS) + BigInt(this.MAX_PRIORITY_FEE_PER_GAS) * BigInt(Math.max(0, this.PRIORITY_FEE_MULTIPLIER - 1));
|
|
6189
7730
|
return finalMaxFeePerGas;
|
|
6190
7731
|
}
|
|
6191
|
-
async handleOperation(operations) {
|
|
7732
|
+
async handleOperation(operations, chainId) {
|
|
7733
|
+
const sessionKeyClient = chainId ? this._sessionKeyClients[chainId] : this.sessionKeyClient;
|
|
7734
|
+
if (!sessionKeyClient) {
|
|
7735
|
+
throw new acpError_default("Session key client not initialized");
|
|
7736
|
+
}
|
|
6192
7737
|
const basePayload = {
|
|
6193
7738
|
uo: operations.map((operation) => ({
|
|
6194
7739
|
target: operation.contractAddress,
|
|
@@ -6213,12 +7758,17 @@ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClie
|
|
|
6213
7758
|
}
|
|
6214
7759
|
}
|
|
6215
7760
|
};
|
|
6216
|
-
const { hash } = await
|
|
6217
|
-
const
|
|
7761
|
+
const { hash } = await sessionKeyClient.sendUserOperation(payload);
|
|
7762
|
+
const checkTransactionConfig = {
|
|
6218
7763
|
hash,
|
|
6219
|
-
tag: "pending",
|
|
6220
7764
|
retries: this.RETRY_CONFIG
|
|
6221
|
-
}
|
|
7765
|
+
};
|
|
7766
|
+
if (!chainId || chainId === import_chains3.baseSepolia.id || chainId === import_chains3.base.id) {
|
|
7767
|
+
checkTransactionConfig["tag"] = "pending";
|
|
7768
|
+
}
|
|
7769
|
+
const txnHash = await sessionKeyClient.waitForUserOperationTransaction(
|
|
7770
|
+
checkTransactionConfig
|
|
7771
|
+
);
|
|
6222
7772
|
return { userOpHash: hash, txnHash };
|
|
6223
7773
|
} catch (error) {
|
|
6224
7774
|
iteration++;
|
|
@@ -6242,7 +7792,7 @@ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClie
|
|
|
6242
7792
|
const contractLogs = result.logs.filter((log) => {
|
|
6243
7793
|
return log.address.toLowerCase() === this.jobManagerAddress.toLowerCase();
|
|
6244
7794
|
}).map(
|
|
6245
|
-
(log) => (0,
|
|
7795
|
+
(log) => (0, import_viem9.decodeEventLog)({
|
|
6246
7796
|
abi: jobManagerAbi_default,
|
|
6247
7797
|
data: log.data,
|
|
6248
7798
|
topics: log.topics
|
|
@@ -6281,6 +7831,13 @@ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClie
|
|
|
6281
7831
|
throw new acpError_default("Failed to get X402 payment details", error);
|
|
6282
7832
|
}
|
|
6283
7833
|
}
|
|
7834
|
+
async getAssetManager() {
|
|
7835
|
+
return await this.publicClient.readContract({
|
|
7836
|
+
address: this.memoManagerAddress,
|
|
7837
|
+
abi: memoManagerAbi_default,
|
|
7838
|
+
functionName: "assetManager"
|
|
7839
|
+
});
|
|
7840
|
+
}
|
|
6284
7841
|
getAcpVersion() {
|
|
6285
7842
|
return "2";
|
|
6286
7843
|
}
|
|
@@ -6305,6 +7862,7 @@ var index_default = acpClient_default;
|
|
|
6305
7862
|
AcpJob,
|
|
6306
7863
|
AcpJobPhases,
|
|
6307
7864
|
AcpMemo,
|
|
7865
|
+
AcpMemoState,
|
|
6308
7866
|
AcpMemoStatus,
|
|
6309
7867
|
AcpOnlineStatus,
|
|
6310
7868
|
BaseAcpContractClient,
|
|
@@ -6318,6 +7876,7 @@ var index_default = acpClient_default;
|
|
|
6318
7876
|
baseAcpX402ConfigV2,
|
|
6319
7877
|
baseSepoliaAcpConfig,
|
|
6320
7878
|
baseSepoliaAcpConfigV2,
|
|
7879
|
+
baseSepoliaAcpX402ConfigV2,
|
|
6321
7880
|
ethFare,
|
|
6322
7881
|
preparePayload,
|
|
6323
7882
|
wethFare
|