@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.mjs CHANGED
@@ -8,7 +8,7 @@ var require_package = __commonJS({
8
8
  "package.json"(exports, module) {
9
9
  module.exports = {
10
10
  name: "@virtuals-protocol/acp-node",
11
- version: "0.3.0-beta.26",
11
+ version: "0.3.0-beta.28",
12
12
  main: "./dist/index.js",
13
13
  module: "./dist/index.mjs",
14
14
  types: "./dist/index.d.ts",
@@ -1242,7 +1242,18 @@ import {
1242
1242
  } from "viem";
1243
1243
 
1244
1244
  // src/configs/acpConfigs.ts
1245
- import { baseSepolia, base } from "@account-kit/infra";
1245
+ import {
1246
+ baseSepolia,
1247
+ base,
1248
+ bscTestnet,
1249
+ bsc,
1250
+ mainnet,
1251
+ sepolia,
1252
+ polygon,
1253
+ polygonAmoy,
1254
+ arbitrum,
1255
+ arbitrumSepolia
1256
+ } from "@account-kit/infra";
1246
1257
 
1247
1258
  // src/acpFare.ts
1248
1259
  import {
@@ -1270,27 +1281,42 @@ var acpError_default = AcpError;
1270
1281
 
1271
1282
  // src/acpFare.ts
1272
1283
  var Fare = class _Fare {
1273
- constructor(contractAddress, decimals) {
1284
+ constructor(contractAddress, decimals, chainId) {
1274
1285
  this.contractAddress = contractAddress;
1275
1286
  this.decimals = decimals;
1287
+ this.chainId = chainId;
1276
1288
  }
1277
1289
  formatAmount(amount) {
1278
1290
  return parseUnits(amount.toString(), this.decimals);
1279
1291
  }
1280
- static async fromContractAddress(contractAddress, config = baseAcpConfig) {
1292
+ static async fromContractAddress(contractAddress, config = baseAcpConfig, chainId = config.chain.id) {
1281
1293
  if (contractAddress === config.baseFare.contractAddress) {
1282
1294
  return config.baseFare;
1283
1295
  }
1296
+ let chainConfig = config.chain;
1297
+ let rpcUrl = config.rpcEndpoint;
1298
+ if (chainId !== config.chain.id) {
1299
+ const selectedChainConfig = config.chains.find(
1300
+ (chain) => chain.id === chainId
1301
+ );
1302
+ if (!selectedChainConfig) {
1303
+ throw new acpError_default(
1304
+ `Chain configuration for chainId ${chainId} not found.`
1305
+ );
1306
+ }
1307
+ chainConfig = selectedChainConfig;
1308
+ rpcUrl = `${config.alchemyRpcUrl}?chainId=${chainId}`;
1309
+ }
1284
1310
  const publicClient = createPublicClient({
1285
- chain: config.chain,
1286
- transport: http(config.rpcEndpoint)
1311
+ chain: chainConfig,
1312
+ transport: http(rpcUrl)
1287
1313
  });
1288
1314
  const decimals = await publicClient.readContract({
1289
1315
  address: contractAddress,
1290
1316
  abi: erc20Abi,
1291
1317
  functionName: "decimals"
1292
1318
  });
1293
- return new _Fare(contractAddress, decimals);
1319
+ return new _Fare(contractAddress, decimals, chainId);
1294
1320
  }
1295
1321
  };
1296
1322
  var FareAmountBase = class {
@@ -1709,6 +1735,34 @@ var ACP_V2_ABI = [
1709
1735
  stateMutability: "nonpayable",
1710
1736
  type: "function"
1711
1737
  },
1738
+ {
1739
+ inputs: [
1740
+ { internalType: "uint256", name: "jobId", type: "uint256" },
1741
+ { internalType: "string", name: "content", type: "string" },
1742
+ { internalType: "address", name: "token", type: "address" },
1743
+ { internalType: "uint256", name: "amount", type: "uint256" },
1744
+ { internalType: "address", name: "recipient", type: "address" },
1745
+ { internalType: "uint256", name: "feeAmount", type: "uint256" },
1746
+ { internalType: "enum ACPTypes.FeeType", name: "feeType", type: "uint8" },
1747
+ {
1748
+ internalType: "enum ACPTypes.MemoType",
1749
+ name: "memoType",
1750
+ type: "uint8"
1751
+ },
1752
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
1753
+ { internalType: "bool", name: "isSecured", type: "bool" },
1754
+ {
1755
+ internalType: "enum ACPTypes.JobPhase",
1756
+ name: "nextPhase",
1757
+ type: "uint8"
1758
+ },
1759
+ { internalType: "uint32", name: "lzDstEid", type: "uint32" }
1760
+ ],
1761
+ name: "createCrossChainPayableMemo",
1762
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
1763
+ stateMutability: "nonpayable",
1764
+ type: "function"
1765
+ },
1712
1766
  {
1713
1767
  inputs: [
1714
1768
  { internalType: "address", name: "provider", type: "address" },
@@ -1893,7 +1947,12 @@ var ACP_V2_ABI = [
1893
1947
  name: "nextPhase",
1894
1948
  type: "uint8"
1895
1949
  },
1896
- { internalType: "uint256", name: "expiredAt", type: "uint256" }
1950
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
1951
+ {
1952
+ internalType: "enum ACPTypes.MemoState",
1953
+ name: "state",
1954
+ type: "uint8"
1955
+ }
1897
1956
  ],
1898
1957
  internalType: "struct ACPTypes.Memo[]",
1899
1958
  name: "memos",
@@ -1940,7 +1999,12 @@ var ACP_V2_ABI = [
1940
1999
  name: "nextPhase",
1941
2000
  type: "uint8"
1942
2001
  },
1943
- { internalType: "uint256", name: "expiredAt", type: "uint256" }
2002
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
2003
+ {
2004
+ internalType: "enum ACPTypes.MemoState",
2005
+ name: "state",
2006
+ type: "uint8"
2007
+ }
1944
2008
  ],
1945
2009
  internalType: "struct ACPTypes.Memo[]",
1946
2010
  name: "memos",
@@ -1983,7 +2047,12 @@ var ACP_V2_ABI = [
1983
2047
  name: "nextPhase",
1984
2048
  type: "uint8"
1985
2049
  },
1986
- { internalType: "uint256", name: "expiredAt", type: "uint256" }
2050
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
2051
+ {
2052
+ internalType: "enum ACPTypes.MemoState",
2053
+ name: "state",
2054
+ type: "uint8"
2055
+ }
1987
2056
  ],
1988
2057
  internalType: "struct ACPTypes.Memo[]",
1989
2058
  name: "memos",
@@ -2238,8 +2307,27 @@ var acpAbiV2_default = ACP_V2_ABI;
2238
2307
  // src/configs/acpConfigs.ts
2239
2308
  var V1_MAX_RETRIES = 10;
2240
2309
  var V2_MAX_RETRIES = 3;
2310
+ var TESTNET_CHAINS = [
2311
+ baseSepolia,
2312
+ sepolia,
2313
+ polygonAmoy,
2314
+ arbitrumSepolia,
2315
+ bscTestnet
2316
+ ];
2317
+ var MAINNET_CHAINS = [
2318
+ base,
2319
+ mainnet,
2320
+ polygon,
2321
+ arbitrum,
2322
+ bsc
2323
+ ];
2324
+ var DEFAULT_RETRY_CONFIG = {
2325
+ intervalMs: 200,
2326
+ multiplier: 1.1,
2327
+ maxRetries: 10
2328
+ };
2241
2329
  var AcpContractConfig2 = class {
2242
- constructor(chain, contractAddress, baseFare, alchemyRpcUrl, acpUrl, abi, maxRetries, rpcEndpoint, x402Config, retryConfig) {
2330
+ constructor(chain, contractAddress, baseFare, alchemyRpcUrl, acpUrl, abi, maxRetries, rpcEndpoint, x402Config, retryConfig, chains = []) {
2243
2331
  this.chain = chain;
2244
2332
  this.contractAddress = contractAddress;
2245
2333
  this.baseFare = baseFare;
@@ -2250,6 +2338,7 @@ var AcpContractConfig2 = class {
2250
2338
  this.rpcEndpoint = rpcEndpoint;
2251
2339
  this.x402Config = x402Config;
2252
2340
  this.retryConfig = retryConfig;
2341
+ this.chains = chains;
2253
2342
  }
2254
2343
  };
2255
2344
  var baseSepoliaAcpConfig = new AcpContractConfig2(
@@ -2261,7 +2350,9 @@ var baseSepoliaAcpConfig = new AcpContractConfig2(
2261
2350
  acpAbi_default,
2262
2351
  V1_MAX_RETRIES,
2263
2352
  void 0,
2264
- void 0
2353
+ void 0,
2354
+ DEFAULT_RETRY_CONFIG,
2355
+ TESTNET_CHAINS
2265
2356
  );
2266
2357
  var baseSepoliaAcpX402Config = new AcpContractConfig2(
2267
2358
  baseSepolia,
@@ -2274,7 +2365,9 @@ var baseSepoliaAcpX402Config = new AcpContractConfig2(
2274
2365
  void 0,
2275
2366
  {
2276
2367
  url: "https://dev-acp-x402.virtuals.io"
2277
- }
2368
+ },
2369
+ DEFAULT_RETRY_CONFIG,
2370
+ TESTNET_CHAINS
2278
2371
  );
2279
2372
  var baseSepoliaAcpConfigV2 = new AcpContractConfig2(
2280
2373
  baseSepolia,
@@ -2285,7 +2378,9 @@ var baseSepoliaAcpConfigV2 = new AcpContractConfig2(
2285
2378
  acpAbiV2_default,
2286
2379
  V2_MAX_RETRIES,
2287
2380
  void 0,
2288
- void 0
2381
+ void 0,
2382
+ DEFAULT_RETRY_CONFIG,
2383
+ TESTNET_CHAINS
2289
2384
  );
2290
2385
  var baseSepoliaAcpX402ConfigV2 = new AcpContractConfig2(
2291
2386
  baseSepolia,
@@ -2298,7 +2393,9 @@ var baseSepoliaAcpX402ConfigV2 = new AcpContractConfig2(
2298
2393
  void 0,
2299
2394
  {
2300
2395
  url: "https://dev-acp-x402.virtuals.io"
2301
- }
2396
+ },
2397
+ DEFAULT_RETRY_CONFIG,
2398
+ TESTNET_CHAINS
2302
2399
  );
2303
2400
  var baseAcpConfig = new AcpContractConfig2(
2304
2401
  base,
@@ -2309,7 +2406,9 @@ var baseAcpConfig = new AcpContractConfig2(
2309
2406
  acpAbi_default,
2310
2407
  V1_MAX_RETRIES,
2311
2408
  void 0,
2312
- void 0
2409
+ void 0,
2410
+ DEFAULT_RETRY_CONFIG,
2411
+ MAINNET_CHAINS
2313
2412
  );
2314
2413
  var baseAcpX402Config = new AcpContractConfig2(
2315
2414
  base,
@@ -2322,7 +2421,9 @@ var baseAcpX402Config = new AcpContractConfig2(
2322
2421
  void 0,
2323
2422
  {
2324
2423
  url: "https://acp-x402.virtuals.io"
2325
- }
2424
+ },
2425
+ DEFAULT_RETRY_CONFIG,
2426
+ MAINNET_CHAINS
2326
2427
  );
2327
2428
  var baseAcpConfigV2 = new AcpContractConfig2(
2328
2429
  base,
@@ -2333,7 +2434,9 @@ var baseAcpConfigV2 = new AcpContractConfig2(
2333
2434
  acpAbiV2_default,
2334
2435
  V2_MAX_RETRIES,
2335
2436
  void 0,
2336
- void 0
2437
+ void 0,
2438
+ DEFAULT_RETRY_CONFIG,
2439
+ MAINNET_CHAINS
2337
2440
  );
2338
2441
  var baseAcpX402ConfigV2 = new AcpContractConfig2(
2339
2442
  base,
@@ -2346,7 +2449,9 @@ var baseAcpX402ConfigV2 = new AcpContractConfig2(
2346
2449
  void 0,
2347
2450
  {
2348
2451
  url: "https://acp-x402.virtuals.io"
2349
- }
2452
+ },
2453
+ DEFAULT_RETRY_CONFIG,
2454
+ MAINNET_CHAINS
2350
2455
  );
2351
2456
 
2352
2457
  // src/abis/wethAbi.ts
@@ -3477,7 +3582,10 @@ var SINGLE_SIGNER_VALIDATION_MODULE_ABI = [
3477
3582
  var singleSignerValidationModuleAbi_default = SINGLE_SIGNER_VALIDATION_MODULE_ABI;
3478
3583
 
3479
3584
  // src/constants.ts
3480
- import { base as base2, baseSepolia as baseSepolia2 } from "viem/chains";
3585
+ import {
3586
+ base as base2,
3587
+ baseSepolia as baseSepolia2
3588
+ } from "viem/chains";
3481
3589
  var USDC_TOKEN_ADDRESS = {
3482
3590
  [baseSepolia2.id]: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
3483
3591
  [base2.id]: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
@@ -3525,6 +3633,7 @@ var BaseAcpContractClient = class {
3525
3633
  constructor(agentWalletAddress, config = baseAcpConfig) {
3526
3634
  this.agentWalletAddress = agentWalletAddress;
3527
3635
  this.config = config;
3636
+ this.publicClients = {};
3528
3637
  this.chain = config.chain;
3529
3638
  this.abi = config.abi;
3530
3639
  this.contractAddress = config.contractAddress;
@@ -3624,12 +3733,12 @@ ${JSON.stringify(
3624
3733
  throw new acpError_default("Failed to create job", error);
3625
3734
  }
3626
3735
  }
3627
- approveAllowance(amountBaseUnit, paymentTokenAddress = this.config.baseFare.contractAddress) {
3736
+ approveAllowance(amountBaseUnit, paymentTokenAddress = this.config.baseFare.contractAddress, targetAddress) {
3628
3737
  try {
3629
3738
  const data = encodeFunctionData({
3630
3739
  abi: erc20Abi2,
3631
3740
  functionName: "approve",
3632
- args: [this.contractAddress, amountBaseUnit]
3741
+ args: [targetAddress ?? this.contractAddress, amountBaseUnit]
3633
3742
  });
3634
3743
  const payload = {
3635
3744
  data,
@@ -3668,6 +3777,35 @@ ${JSON.stringify(
3668
3777
  throw new acpError_default("Failed to create payable memo", error);
3669
3778
  }
3670
3779
  }
3780
+ createCrossChainPayableMemo(jobId, content, token, amountBaseUnit, recipient, feeAmountBaseUnit, feeType, type, expiredAt, nextPhase, destinationEid, secured = true) {
3781
+ try {
3782
+ const data = encodeFunctionData({
3783
+ abi: this.abi,
3784
+ functionName: "createCrossChainPayableMemo",
3785
+ args: [
3786
+ jobId,
3787
+ content,
3788
+ token,
3789
+ amountBaseUnit,
3790
+ recipient,
3791
+ feeAmountBaseUnit,
3792
+ feeType,
3793
+ type,
3794
+ Math.floor(expiredAt.getTime() / 1e3),
3795
+ secured,
3796
+ nextPhase,
3797
+ destinationEid
3798
+ ]
3799
+ });
3800
+ const payload = {
3801
+ data,
3802
+ contractAddress: this.contractAddress
3803
+ };
3804
+ return payload;
3805
+ } catch (error) {
3806
+ throw new acpError_default("Failed to create cross chain payable memo", error);
3807
+ }
3808
+ }
3671
3809
  createMemo(jobId, content, type, isSecured, nextPhase) {
3672
3810
  try {
3673
3811
  const data = encodeFunctionData({
@@ -3684,6 +3822,22 @@ ${JSON.stringify(
3684
3822
  throw new acpError_default("Failed to create memo", error);
3685
3823
  }
3686
3824
  }
3825
+ createMemoWithMetadata(jobId, content, type, isSecured, nextPhase, metadata) {
3826
+ try {
3827
+ const data = encodeFunctionData({
3828
+ abi: this.abi,
3829
+ functionName: "createMemoWithMetadata",
3830
+ args: [jobId, content, type, isSecured, nextPhase, metadata]
3831
+ });
3832
+ const payload = {
3833
+ data,
3834
+ contractAddress: this.contractAddress
3835
+ };
3836
+ return payload;
3837
+ } catch (error) {
3838
+ throw new acpError_default("Failed to create memo with metadata", error);
3839
+ }
3840
+ }
3687
3841
  signMemo(memoId, isApproved, reason) {
3688
3842
  try {
3689
3843
  const data = encodeFunctionData({
@@ -3769,9 +3923,58 @@ ${JSON.stringify(
3769
3923
  throw new acpError_default("Failed to submit TransferWithAuthorization", error);
3770
3924
  }
3771
3925
  }
3926
+ async getERC20Balance(chainId, tokenAddress, walletAddress) {
3927
+ const publicClient = this.publicClients[chainId];
3928
+ if (!publicClient) {
3929
+ throw new acpError_default(`Public client for chainId ${chainId} not found`);
3930
+ }
3931
+ return await publicClient.readContract({
3932
+ address: tokenAddress,
3933
+ abi: erc20Abi2,
3934
+ functionName: "balanceOf",
3935
+ args: [walletAddress]
3936
+ });
3937
+ }
3938
+ async getERC20Allowance(chainId, tokenAddress, walletAddress, spenderAddress) {
3939
+ const publicClient = this.publicClients[chainId];
3940
+ if (!publicClient) {
3941
+ throw new acpError_default(`Public client for chainId ${chainId} not found`);
3942
+ }
3943
+ return await publicClient.readContract({
3944
+ address: tokenAddress,
3945
+ abi: erc20Abi2,
3946
+ functionName: "allowance",
3947
+ args: [walletAddress, spenderAddress]
3948
+ });
3949
+ }
3950
+ async getERC20Symbol(chainId, tokenAddress) {
3951
+ const publicClient = this.publicClients[chainId];
3952
+ if (!publicClient) {
3953
+ throw new acpError_default(`Public client for chainId ${chainId} not found`);
3954
+ }
3955
+ return await publicClient.readContract({
3956
+ address: tokenAddress,
3957
+ abi: erc20Abi2,
3958
+ functionName: "symbol"
3959
+ });
3960
+ }
3961
+ async getERC20Decimals(chainId, tokenAddress) {
3962
+ const publicClient = this.publicClients[chainId];
3963
+ if (!publicClient) {
3964
+ throw new acpError_default(`Public client for chainId ${chainId} not found`);
3965
+ }
3966
+ return await publicClient.readContract({
3967
+ address: tokenAddress,
3968
+ abi: erc20Abi2,
3969
+ functionName: "decimals"
3970
+ });
3971
+ }
3772
3972
  };
3773
3973
  var baseAcpContractClient_default = BaseAcpContractClient;
3774
3974
 
3975
+ // src/acpJob.ts
3976
+ import { formatUnits } from "viem";
3977
+
3775
3978
  // src/interfaces.ts
3776
3979
  var AcpMemoStatus = /* @__PURE__ */ ((AcpMemoStatus2) => {
3777
3980
  AcpMemoStatus2["PENDING"] = "PENDING";
@@ -3779,6 +3982,14 @@ var AcpMemoStatus = /* @__PURE__ */ ((AcpMemoStatus2) => {
3779
3982
  AcpMemoStatus2["REJECTED"] = "REJECTED";
3780
3983
  return AcpMemoStatus2;
3781
3984
  })(AcpMemoStatus || {});
3985
+ var AcpMemoState = /* @__PURE__ */ ((AcpMemoState2) => {
3986
+ AcpMemoState2[AcpMemoState2["NONE"] = 0] = "NONE";
3987
+ AcpMemoState2[AcpMemoState2["PENDING"] = 1] = "PENDING";
3988
+ AcpMemoState2[AcpMemoState2["IN_PROGRESS"] = 2] = "IN_PROGRESS";
3989
+ AcpMemoState2[AcpMemoState2["FAILED"] = 3] = "FAILED";
3990
+ AcpMemoState2[AcpMemoState2["COMPLETED"] = 4] = "COMPLETED";
3991
+ return AcpMemoState2;
3992
+ })(AcpMemoState || {});
3782
3993
  var AcpAgentSort = /* @__PURE__ */ ((AcpAgentSort2) => {
3783
3994
  AcpAgentSort2["SUCCESSFUL_JOB_COUNT"] = "successfulJobCount";
3784
3995
  AcpAgentSort2["SUCCESS_RATE"] = "successRate";
@@ -3800,6 +4011,19 @@ var AcpOnlineStatus = /* @__PURE__ */ ((AcpOnlineStatus2) => {
3800
4011
  })(AcpOnlineStatus || {});
3801
4012
 
3802
4013
  // src/utils.ts
4014
+ import { decodeAbiParameters, encodeAbiParameters } from "viem";
4015
+ import {
4016
+ arbitrum as arbitrum3,
4017
+ arbitrumSepolia as arbitrumSepolia3,
4018
+ base as base3,
4019
+ baseSepolia as baseSepolia3,
4020
+ bsc as bsc3,
4021
+ bscTestnet as bscTestnet3,
4022
+ mainnet as mainnet3,
4023
+ polygon as polygon3,
4024
+ polygonAmoy as polygonAmoy3,
4025
+ sepolia as sepolia3
4026
+ } from "viem/chains";
3803
4027
  function tryParseJson(content) {
3804
4028
  try {
3805
4029
  return JSON.parse(content);
@@ -3816,6 +4040,56 @@ function safeBase64Encode(data) {
3816
4040
  }
3817
4041
  return Buffer.from(data).toString("base64");
3818
4042
  }
4043
+ function getDestinationEndpointId(chainId) {
4044
+ switch (chainId) {
4045
+ case baseSepolia3.id:
4046
+ return 40245;
4047
+ case sepolia3.id:
4048
+ return 40161;
4049
+ case polygonAmoy3.id:
4050
+ return 40267;
4051
+ case arbitrumSepolia3.id:
4052
+ return 40231;
4053
+ case bscTestnet3.id:
4054
+ return 40102;
4055
+ case base3.id:
4056
+ return 30184;
4057
+ case mainnet3.id:
4058
+ return 30101;
4059
+ case polygon3.id:
4060
+ return 30109;
4061
+ case arbitrum3.id:
4062
+ return 30110;
4063
+ case bsc3.id:
4064
+ return 30102;
4065
+ }
4066
+ throw new Error(`Unsupported chain ID: ${chainId}`);
4067
+ }
4068
+ function getDestinationChainId(endpointId) {
4069
+ switch (endpointId) {
4070
+ case 40245:
4071
+ return baseSepolia3.id;
4072
+ case 40161:
4073
+ return sepolia3.id;
4074
+ case 40267:
4075
+ return polygonAmoy3.id;
4076
+ case 40231:
4077
+ return arbitrumSepolia3.id;
4078
+ case 40102:
4079
+ return bscTestnet3.id;
4080
+ case 30184:
4081
+ return base3.id;
4082
+ case 30101:
4083
+ return mainnet3.id;
4084
+ case 30109:
4085
+ return polygon3.id;
4086
+ case 30110:
4087
+ return arbitrum3.id;
4088
+ case 30102:
4089
+ return bsc3.id;
4090
+ }
4091
+ throw new Error(`Unsupported endpoint ID: ${endpointId}`);
4092
+ }
3819
4093
 
3820
4094
  // src/acpJobOffering.ts
3821
4095
  import { zeroAddress as zeroAddress2 } from "viem";
@@ -4023,29 +4297,50 @@ var AcpJob = class {
4023
4297
  }
4024
4298
  const feeAmount = new FareAmount(0, this.acpContractClient.config.baseFare);
4025
4299
  const isPercentagePricing = this.priceType === "percentage" /* PERCENTAGE */;
4026
- operations.push(
4027
- this.acpContractClient.createPayableMemo(
4028
- this.id,
4029
- content,
4030
- amount.amount,
4031
- recipient,
4032
- isPercentagePricing ? BigInt(Math.round(this.priceValue * 1e4)) : feeAmount.amount,
4033
- isPercentagePricing ? 3 /* PERCENTAGE_FEE */ : 0 /* NO_FEE */,
4034
- 2 /* TRANSACTION */,
4035
- type,
4036
- expiredAt,
4037
- amount.fare.contractAddress
4038
- )
4039
- );
4300
+ if (amount.fare.chainId && amount.fare.chainId !== this.acpContractClient.config.chain.id) {
4301
+ operations.push(
4302
+ this.acpContractClient.createCrossChainPayableMemo(
4303
+ this.id,
4304
+ content,
4305
+ amount.fare.contractAddress,
4306
+ amount.amount,
4307
+ recipient,
4308
+ isPercentagePricing ? BigInt(Math.round(this.priceValue * 1e4)) : feeAmount.amount,
4309
+ isPercentagePricing ? 3 /* PERCENTAGE_FEE */ : 0 /* NO_FEE */,
4310
+ type,
4311
+ expiredAt,
4312
+ 2 /* TRANSACTION */,
4313
+ getDestinationEndpointId(amount.fare.chainId)
4314
+ )
4315
+ );
4316
+ } else {
4317
+ operations.push(
4318
+ this.acpContractClient.createPayableMemo(
4319
+ this.id,
4320
+ content,
4321
+ amount.amount,
4322
+ recipient,
4323
+ isPercentagePricing ? BigInt(Math.round(this.priceValue * 1e4)) : feeAmount.amount,
4324
+ isPercentagePricing ? 3 /* PERCENTAGE_FEE */ : 0 /* NO_FEE */,
4325
+ 2 /* TRANSACTION */,
4326
+ type,
4327
+ expiredAt,
4328
+ amount.fare.contractAddress
4329
+ )
4330
+ );
4331
+ }
4040
4332
  return await this.acpContractClient.handleOperation(operations);
4041
4333
  }
4042
4334
  async payAndAcceptRequirement(reason) {
4043
4335
  const memo = this.memos.find(
4044
- (m) => m.nextPhase === 2 /* TRANSACTION */
4336
+ (m) => m.nextPhase === 2 /* TRANSACTION */ || m.nextPhase === 4 /* COMPLETED */
4045
4337
  );
4046
4338
  if (!memo) {
4047
4339
  throw new acpError_default("No notification memo found");
4048
4340
  }
4341
+ if (memo.type === 6 /* PAYABLE_REQUEST */ && memo.state !== 1 /* PENDING */ && memo.payableDetails?.lzDstEid !== void 0 && memo.payableDetails?.lzDstEid !== 0) {
4342
+ return;
4343
+ }
4049
4344
  const operations = [];
4050
4345
  const baseFareAmount = new FareAmount(this.price, this.baseFare);
4051
4346
  const transferAmount = memo.payableDetails ? await FareAmountBase.fromContractAddress(
@@ -4078,6 +4373,53 @@ var AcpJob = class {
4078
4373
  3 /* EVALUATION */
4079
4374
  )
4080
4375
  );
4376
+ if (memo.payableDetails) {
4377
+ const destinationChainId = memo.payableDetails.lzDstEid ? getDestinationChainId(memo.payableDetails.lzDstEid) : this.config.chain.id;
4378
+ if (destinationChainId !== this.config.chain.id) {
4379
+ if (memo.type === 6 /* PAYABLE_REQUEST */) {
4380
+ const tokenBalance = await this.acpContractClient.getERC20Balance(
4381
+ destinationChainId,
4382
+ memo.payableDetails.token,
4383
+ this.acpContractClient.agentWalletAddress
4384
+ );
4385
+ if (tokenBalance < memo.payableDetails.amount) {
4386
+ const tokenDecimals = await this.acpContractClient.getERC20Decimals(
4387
+ destinationChainId,
4388
+ memo.payableDetails.token
4389
+ );
4390
+ const tokenSymbol = await this.acpContractClient.getERC20Symbol(
4391
+ destinationChainId,
4392
+ memo.payableDetails.token
4393
+ );
4394
+ throw new Error(
4395
+ `You do not have enough funds to pay for the job which costs ${formatUnits(
4396
+ memo.payableDetails.amount,
4397
+ tokenDecimals
4398
+ )} ${tokenSymbol} on chainId ${destinationChainId}`
4399
+ );
4400
+ }
4401
+ const assetManagerAddress = await this.acpContractClient.getAssetManager();
4402
+ const allowance = await this.acpContractClient.getERC20Allowance(
4403
+ destinationChainId,
4404
+ memo.payableDetails.token,
4405
+ this.acpContractClient.agentWalletAddress,
4406
+ assetManagerAddress
4407
+ );
4408
+ const destinationChainOperations = [];
4409
+ destinationChainOperations.push(
4410
+ this.acpContractClient.approveAllowance(
4411
+ memo.payableDetails.amount + allowance,
4412
+ memo.payableDetails.token,
4413
+ assetManagerAddress
4414
+ )
4415
+ );
4416
+ await this.acpContractClient.handleOperation(
4417
+ destinationChainOperations,
4418
+ destinationChainId
4419
+ );
4420
+ }
4421
+ }
4422
+ }
4081
4423
  if (this.price > 0) {
4082
4424
  const x402PaymentDetails = await this.acpContractClient.getX402PaymentDetails(this.id);
4083
4425
  if (x402PaymentDetails.isX402) {
@@ -4150,9 +4492,6 @@ var AcpJob = class {
4150
4492
  return await this.acpContractClient.handleOperation(operations);
4151
4493
  }
4152
4494
  async deliver(deliverable) {
4153
- if (this.phase !== 2 /* TRANSACTION */) {
4154
- throw new acpError_default("Job is not in transaction phase");
4155
- }
4156
4495
  const operations = [];
4157
4496
  operations.push(
4158
4497
  this.acpContractClient.createMemo(
@@ -4166,8 +4505,13 @@ var AcpJob = class {
4166
4505
  return await this.acpContractClient.handleOperation(operations);
4167
4506
  }
4168
4507
  async deliverPayable(deliverable, amount, skipFee = false, expiredAt = new Date(Date.now() + 1e3 * 60 * 5)) {
4169
- if (this.latestMemo?.nextPhase !== 3 /* EVALUATION */) {
4170
- throw new acpError_default("No transaction memo found");
4508
+ if (amount.fare.chainId !== this.acpContractClient.config.chain.id) {
4509
+ return await this.deliverCrossChainPayable(
4510
+ this.clientAddress,
4511
+ preparePayload(deliverable),
4512
+ amount,
4513
+ skipFee
4514
+ );
4171
4515
  }
4172
4516
  const operations = [];
4173
4517
  operations.push(
@@ -4181,7 +4525,6 @@ var AcpJob = class {
4181
4525
  operations.push(
4182
4526
  this.acpContractClient.createPayableMemo(
4183
4527
  this.id,
4184
- // memoContent.url,
4185
4528
  preparePayload(deliverable),
4186
4529
  amount.amount,
4187
4530
  this.clientAddress,
@@ -4300,6 +4643,56 @@ var AcpJob = class {
4300
4643
  waitMs = Math.min(waitMs * 2, maxWaitMs);
4301
4644
  }
4302
4645
  }
4646
+ async deliverCrossChainPayable(recipient, content, amount, skipFee = false) {
4647
+ if (!amount.fare.chainId) {
4648
+ throw new acpError_default("Chain ID is required for cross chain payable");
4649
+ }
4650
+ const chainId = amount.fare.chainId;
4651
+ const assetManagerAddress = await this.acpContractClient.getAssetManager();
4652
+ const tokenBalance = await this.acpContractClient.getERC20Balance(
4653
+ chainId,
4654
+ amount.fare.contractAddress,
4655
+ this.acpContractClient.agentWalletAddress
4656
+ );
4657
+ if (tokenBalance < amount.amount) {
4658
+ throw new acpError_default("Insufficient token balance for cross chain payable");
4659
+ }
4660
+ const currentAllowance = await this.acpContractClient.getERC20Allowance(
4661
+ chainId,
4662
+ amount.fare.contractAddress,
4663
+ this.acpContractClient.agentWalletAddress,
4664
+ assetManagerAddress
4665
+ );
4666
+ const approveAllowanceOperation = this.acpContractClient.approveAllowance(
4667
+ amount.amount + currentAllowance,
4668
+ amount.fare.contractAddress,
4669
+ assetManagerAddress
4670
+ );
4671
+ await this.acpContractClient.handleOperation(
4672
+ [approveAllowanceOperation],
4673
+ chainId
4674
+ );
4675
+ const tokenSymbol = await this.acpContractClient.getERC20Symbol(
4676
+ chainId,
4677
+ amount.fare.contractAddress
4678
+ );
4679
+ const feeAmount = new FareAmount(0, this.acpContractClient.config.baseFare);
4680
+ const isPercentagePricing = this.priceType === "percentage" /* PERCENTAGE */ && !skipFee;
4681
+ const createMemoOperation = this.acpContractClient.createCrossChainPayableMemo(
4682
+ this.id,
4683
+ content,
4684
+ amount.fare.contractAddress,
4685
+ amount.amount,
4686
+ recipient,
4687
+ isPercentagePricing ? BigInt(Math.round(this.priceValue * 1e4)) : feeAmount.amount,
4688
+ isPercentagePricing ? 3 /* PERCENTAGE_FEE */ : 0 /* NO_FEE */,
4689
+ 7 /* PAYABLE_TRANSFER */,
4690
+ new Date(Date.now() + 1e3 * 60 * 5),
4691
+ 4 /* COMPLETED */,
4692
+ getDestinationEndpointId(chainId)
4693
+ );
4694
+ await this.acpContractClient.handleOperation([createMemoOperation]);
4695
+ }
4303
4696
  [util.inspect.custom]() {
4304
4697
  return {
4305
4698
  id: this.id,
@@ -4323,7 +4716,7 @@ var acpJob_default = AcpJob;
4323
4716
  // src/acpMemo.ts
4324
4717
  import util2 from "util";
4325
4718
  var AcpMemo = class {
4326
- constructor(contractClient, id, type, content, nextPhase, status, senderAddress, signedReason, expiry, payableDetails, txHash, signedTxHash) {
4719
+ constructor(contractClient, id, type, content, nextPhase, status, senderAddress, signedReason, expiry, payableDetails, txHash, signedTxHash, state) {
4327
4720
  this.contractClient = contractClient;
4328
4721
  this.id = id;
4329
4722
  this.type = type;
@@ -4336,6 +4729,7 @@ var AcpMemo = class {
4336
4729
  this.payableDetails = payableDetails;
4337
4730
  this.txHash = txHash;
4338
4731
  this.signedTxHash = signedTxHash;
4732
+ this.state = state;
4339
4733
  if (this.payableDetails) {
4340
4734
  this.payableDetails.amount = BigInt(this.payableDetails.amount);
4341
4735
  this.payableDetails.feeAmount = BigInt(this.payableDetails.feeAmount);
@@ -4618,7 +5012,8 @@ var AcpClient = class {
4618
5012
  memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
4619
5013
  memo.payableDetails,
4620
5014
  memo.txHash,
4621
- memo.signedTxHash
5015
+ memo.signedTxHash,
5016
+ memo.state
4622
5017
  );
4623
5018
  } catch (err) {
4624
5019
  throw new acpError_default(`Failed to hydrate memo ${memo.id}`, err);
@@ -4694,6 +5089,8 @@ var AcpClient = class {
4694
5089
  cluster,
4695
5090
  sortBy,
4696
5091
  topK = 5,
5092
+ sort_by,
5093
+ top_k = 5,
4697
5094
  graduationStatus,
4698
5095
  onlineStatus,
4699
5096
  showHiddenOfferings
@@ -4701,10 +5098,11 @@ var AcpClient = class {
4701
5098
  const params = {
4702
5099
  search: keyword
4703
5100
  };
4704
- params.top_k = topK;
5101
+ params.top_k = topK || top_k;
4705
5102
  params.walletAddressesToExclude = this.walletAddress;
4706
- if (sortBy && sortBy.length > 0) {
4707
- params.sortBy = sortBy.join(",");
5103
+ const sortByArray = sortBy || sort_by;
5104
+ if (sortByArray && sortByArray.length > 0) {
5105
+ params.sortBy = sortByArray.join(",");
4708
5106
  }
4709
5107
  if (cluster) {
4710
5108
  params.cluster = cluster;
@@ -5314,6 +5712,9 @@ var AcpContractClient = class _AcpContractClient extends baseAcpContractClient_d
5314
5712
  async performX402Request(url, version2, budget, signature) {
5315
5713
  return await this.acpX402.performRequest(url, version2, budget, signature);
5316
5714
  }
5715
+ async getAssetManager() {
5716
+ throw new Error("Asset Manager not supported");
5717
+ }
5317
5718
  getAcpVersion() {
5318
5719
  return "1";
5319
5720
  }
@@ -6037,91 +6438,1249 @@ var JOB_MANAGER_ABI = [
6037
6438
  var jobManagerAbi_default = JOB_MANAGER_ABI;
6038
6439
 
6039
6440
  // src/contractClients/acpContractClientV2.ts
6040
- var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClient_default {
6041
- constructor(jobManagerAddress, memoManagerAddress, accountManagerAddress, agentWalletAddress, config = baseAcpConfigV2) {
6042
- super(agentWalletAddress, config);
6043
- this.jobManagerAddress = jobManagerAddress;
6044
- this.memoManagerAddress = memoManagerAddress;
6045
- this.accountManagerAddress = accountManagerAddress;
6046
- this.PRIORITY_FEE_MULTIPLIER = 2;
6047
- this.MAX_FEE_PER_GAS = 2e7;
6048
- this.MAX_PRIORITY_FEE_PER_GAS = 21e6;
6049
- this.GAS_FEE_MULTIPLIER = 0.5;
6050
- this.RETRY_CONFIG = {
6051
- intervalMs: 200,
6052
- multiplier: 1.1,
6053
- maxRetries: 10
6054
- };
6055
- }
6056
- static async build(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfigV2) {
6057
- const publicClient = createPublicClient4({
6058
- chain: config.chain,
6059
- transport: http3(config.rpcEndpoint)
6060
- });
6061
- const [jobManagerAddress, memoManagerAddress, accountManagerAddress] = await publicClient.multicall({
6062
- contracts: [
6063
- {
6064
- address: config.contractAddress,
6065
- abi: config.abi,
6066
- functionName: "jobManager"
6067
- },
6068
- {
6069
- address: config.contractAddress,
6070
- abi: config.abi,
6071
- functionName: "memoManager"
6072
- },
6073
- {
6074
- address: config.contractAddress,
6075
- abi: config.abi,
6076
- functionName: "accountManager"
6077
- }
6078
- ]
6079
- });
6080
- if (!jobManagerAddress || !memoManagerAddress || !accountManagerAddress) {
6081
- throw new acpError_default(
6082
- "Failed to get job manager, memo manager, or account manager address"
6083
- );
6084
- }
6085
- const acpContractClient = new _AcpContractClientV2(
6086
- jobManagerAddress.result,
6087
- memoManagerAddress.result,
6088
- accountManagerAddress.result,
6089
- agentWalletAddress,
6090
- config
6091
- );
6092
- await acpContractClient.init(walletPrivateKey, sessionEntityKeyId);
6093
- return acpContractClient;
6094
- }
6095
- async init(privateKey, sessionEntityKeyId) {
6096
- const sessionKeySigner = LocalAccountSigner2.privateKeyToAccountSigner(privateKey);
6097
- this._sessionKeyClient = await createModularAccountV2Client2({
6098
- chain: this.chain,
6099
- transport: alchemy2({
6100
- rpcUrl: this.config.alchemyRpcUrl
6101
- }),
6102
- signer: sessionKeySigner,
6103
- policyId: "186aaa4a-5f57-4156-83fb-e456365a8820",
6104
- accountAddress: this.agentWalletAddress,
6105
- signerEntity: {
6106
- entityId: sessionEntityKeyId,
6107
- isGlobalValidation: true
6108
- }
6109
- });
6110
- this._acpX402 = new AcpX402(
6111
- this.config,
6112
- this.sessionKeyClient,
6113
- this.publicClient
6114
- );
6115
- const account = this.sessionKeyClient.account;
6116
- const sessionSignerAddress = await account.getSigner().getAddress();
6117
- if (!await account.isAccountDeployed()) {
6118
- throw new acpError_default(
6119
- `ACP Contract Client validation failed: agent account ${this.agentWalletAddress} is not deployed on-chain`
6120
- );
6121
- }
6122
- await this.validateSessionKeyOnChain(
6123
- sessionSignerAddress,
6124
- sessionEntityKeyId
6441
+ import { base as base4, baseSepolia as baseSepolia4 } from "viem/chains";
6442
+
6443
+ // src/abis/memoManagerAbi.ts
6444
+ var MEMO_MANAGER_ABI = [
6445
+ { inputs: [], stateMutability: "nonpayable", type: "constructor" },
6446
+ { inputs: [], name: "AccessControlBadConfirmation", type: "error" },
6447
+ {
6448
+ inputs: [
6449
+ { internalType: "address", name: "account", type: "address" },
6450
+ { internalType: "bytes32", name: "neededRole", type: "bytes32" }
6451
+ ],
6452
+ name: "AccessControlUnauthorizedAccount",
6453
+ type: "error"
6454
+ },
6455
+ {
6456
+ inputs: [{ internalType: "address", name: "target", type: "address" }],
6457
+ name: "AddressEmptyCode",
6458
+ type: "error"
6459
+ },
6460
+ { inputs: [], name: "AlreadyVoted", type: "error" },
6461
+ { inputs: [], name: "CannotApproveMemo", type: "error" },
6462
+ { inputs: [], name: "CannotUpdateApprovedMemo", type: "error" },
6463
+ { inputs: [], name: "CannotUpdateMemo", type: "error" },
6464
+ { inputs: [], name: "CannotWithdrawYet", type: "error" },
6465
+ { inputs: [], name: "DestinationChainNotConfigured", type: "error" },
6466
+ {
6467
+ inputs: [
6468
+ { internalType: "address", name: "implementation", type: "address" }
6469
+ ],
6470
+ name: "ERC1967InvalidImplementation",
6471
+ type: "error"
6472
+ },
6473
+ { inputs: [], name: "ERC1967NonPayable", type: "error" },
6474
+ { inputs: [], name: "EmptyContent", type: "error" },
6475
+ { inputs: [], name: "FailedInnerCall", type: "error" },
6476
+ { inputs: [], name: "InvalidInitialization", type: "error" },
6477
+ { inputs: [], name: "InvalidMemoState", type: "error" },
6478
+ { inputs: [], name: "InvalidMemoStateTransition", type: "error" },
6479
+ { inputs: [], name: "InvalidMemoType", type: "error" },
6480
+ { inputs: [], name: "JobAlreadyCompleted", type: "error" },
6481
+ { inputs: [], name: "JobDoesNotExist", type: "error" },
6482
+ { inputs: [], name: "MemoAlreadyApproved", type: "error" },
6483
+ { inputs: [], name: "MemoAlreadyExecuted", type: "error" },
6484
+ { inputs: [], name: "MemoAlreadySigned", type: "error" },
6485
+ { inputs: [], name: "MemoCannotBeSigned", type: "error" },
6486
+ { inputs: [], name: "MemoDoesNotExist", type: "error" },
6487
+ { inputs: [], name: "MemoDoesNotRequireApproval", type: "error" },
6488
+ { inputs: [], name: "MemoExpired", type: "error" },
6489
+ { inputs: [], name: "MemoNotApproved", type: "error" },
6490
+ { inputs: [], name: "MemoNotReadyToBeSigned", type: "error" },
6491
+ { inputs: [], name: "MemoStateUnchanged", type: "error" },
6492
+ { inputs: [], name: "NoAmountToTransfer", type: "error" },
6493
+ { inputs: [], name: "NoPaymentAmount", type: "error" },
6494
+ { inputs: [], name: "NotEscrowTransferMemoType", type: "error" },
6495
+ { inputs: [], name: "NotInitializing", type: "error" },
6496
+ { inputs: [], name: "NotPayableMemoType", type: "error" },
6497
+ { inputs: [], name: "OnlyACPContract", type: "error" },
6498
+ { inputs: [], name: "OnlyAssetManager", type: "error" },
6499
+ { inputs: [], name: "OnlyClientOrProvider", type: "error" },
6500
+ { inputs: [], name: "OnlyCounterParty", type: "error" },
6501
+ { inputs: [], name: "OnlyEvaluator", type: "error" },
6502
+ { inputs: [], name: "OnlyMemoSender", type: "error" },
6503
+ { inputs: [], name: "ReentrancyGuardReentrantCall", type: "error" },
6504
+ { inputs: [], name: "UUPSUnauthorizedCallContext", type: "error" },
6505
+ {
6506
+ inputs: [{ internalType: "bytes32", name: "slot", type: "bytes32" }],
6507
+ name: "UUPSUnsupportedProxiableUUID",
6508
+ type: "error"
6509
+ },
6510
+ { inputs: [], name: "ZeroAcpContractAddress", type: "error" },
6511
+ { inputs: [], name: "ZeroAddressRecipient", type: "error" },
6512
+ { inputs: [], name: "ZeroAddressToken", type: "error" },
6513
+ { inputs: [], name: "ZeroAssetManagerAddress", type: "error" },
6514
+ { inputs: [], name: "ZeroJobManagerAddress", type: "error" },
6515
+ {
6516
+ anonymous: false,
6517
+ inputs: [
6518
+ {
6519
+ indexed: false,
6520
+ internalType: "uint64",
6521
+ name: "version",
6522
+ type: "uint64"
6523
+ }
6524
+ ],
6525
+ name: "Initialized",
6526
+ type: "event"
6527
+ },
6528
+ {
6529
+ anonymous: false,
6530
+ inputs: [
6531
+ {
6532
+ indexed: true,
6533
+ internalType: "uint256",
6534
+ name: "memoId",
6535
+ type: "uint256"
6536
+ },
6537
+ {
6538
+ indexed: true,
6539
+ internalType: "address",
6540
+ name: "approver",
6541
+ type: "address"
6542
+ },
6543
+ { indexed: false, internalType: "bool", name: "approved", type: "bool" },
6544
+ {
6545
+ indexed: false,
6546
+ internalType: "string",
6547
+ name: "reason",
6548
+ type: "string"
6549
+ }
6550
+ ],
6551
+ name: "MemoSigned",
6552
+ type: "event"
6553
+ },
6554
+ {
6555
+ anonymous: false,
6556
+ inputs: [
6557
+ {
6558
+ indexed: true,
6559
+ internalType: "uint256",
6560
+ name: "memoId",
6561
+ type: "uint256"
6562
+ },
6563
+ {
6564
+ indexed: false,
6565
+ internalType: "enum ACPTypes.MemoState",
6566
+ name: "oldState",
6567
+ type: "uint8"
6568
+ },
6569
+ {
6570
+ indexed: false,
6571
+ internalType: "enum ACPTypes.MemoState",
6572
+ name: "newState",
6573
+ type: "uint8"
6574
+ }
6575
+ ],
6576
+ name: "MemoStateUpdated",
6577
+ type: "event"
6578
+ },
6579
+ {
6580
+ anonymous: false,
6581
+ inputs: [
6582
+ {
6583
+ indexed: true,
6584
+ internalType: "uint256",
6585
+ name: "memoId",
6586
+ type: "uint256"
6587
+ },
6588
+ {
6589
+ indexed: true,
6590
+ internalType: "uint256",
6591
+ name: "jobId",
6592
+ type: "uint256"
6593
+ },
6594
+ {
6595
+ indexed: true,
6596
+ internalType: "address",
6597
+ name: "sender",
6598
+ type: "address"
6599
+ },
6600
+ {
6601
+ indexed: false,
6602
+ internalType: "enum ACPTypes.MemoType",
6603
+ name: "memoType",
6604
+ type: "uint8"
6605
+ },
6606
+ {
6607
+ indexed: false,
6608
+ internalType: "enum ACPTypes.JobPhase",
6609
+ name: "nextPhase",
6610
+ type: "uint8"
6611
+ },
6612
+ {
6613
+ indexed: false,
6614
+ internalType: "string",
6615
+ name: "content",
6616
+ type: "string"
6617
+ }
6618
+ ],
6619
+ name: "NewMemo",
6620
+ type: "event"
6621
+ },
6622
+ {
6623
+ anonymous: false,
6624
+ inputs: [
6625
+ {
6626
+ indexed: true,
6627
+ internalType: "uint256",
6628
+ name: "jobId",
6629
+ type: "uint256"
6630
+ },
6631
+ {
6632
+ indexed: true,
6633
+ internalType: "uint256",
6634
+ name: "memoId",
6635
+ type: "uint256"
6636
+ },
6637
+ {
6638
+ indexed: true,
6639
+ internalType: "address",
6640
+ name: "sender",
6641
+ type: "address"
6642
+ },
6643
+ {
6644
+ indexed: false,
6645
+ internalType: "address",
6646
+ name: "token",
6647
+ type: "address"
6648
+ },
6649
+ {
6650
+ indexed: false,
6651
+ internalType: "uint256",
6652
+ name: "amount",
6653
+ type: "uint256"
6654
+ }
6655
+ ],
6656
+ name: "PayableFeeRefunded",
6657
+ type: "event"
6658
+ },
6659
+ {
6660
+ anonymous: false,
6661
+ inputs: [
6662
+ {
6663
+ indexed: true,
6664
+ internalType: "uint256",
6665
+ name: "jobId",
6666
+ type: "uint256"
6667
+ },
6668
+ {
6669
+ indexed: true,
6670
+ internalType: "uint256",
6671
+ name: "memoId",
6672
+ type: "uint256"
6673
+ },
6674
+ {
6675
+ indexed: true,
6676
+ internalType: "address",
6677
+ name: "sender",
6678
+ type: "address"
6679
+ },
6680
+ {
6681
+ indexed: false,
6682
+ internalType: "address",
6683
+ name: "token",
6684
+ type: "address"
6685
+ },
6686
+ {
6687
+ indexed: false,
6688
+ internalType: "uint256",
6689
+ name: "amount",
6690
+ type: "uint256"
6691
+ }
6692
+ ],
6693
+ name: "PayableFundsRefunded",
6694
+ type: "event"
6695
+ },
6696
+ {
6697
+ anonymous: false,
6698
+ inputs: [
6699
+ {
6700
+ indexed: true,
6701
+ internalType: "uint256",
6702
+ name: "memoId",
6703
+ type: "uint256"
6704
+ },
6705
+ {
6706
+ indexed: true,
6707
+ internalType: "uint256",
6708
+ name: "jobId",
6709
+ type: "uint256"
6710
+ },
6711
+ {
6712
+ indexed: true,
6713
+ internalType: "address",
6714
+ name: "executor",
6715
+ type: "address"
6716
+ },
6717
+ {
6718
+ indexed: false,
6719
+ internalType: "uint256",
6720
+ name: "amount",
6721
+ type: "uint256"
6722
+ }
6723
+ ],
6724
+ name: "PayableMemoExecuted",
6725
+ type: "event"
6726
+ },
6727
+ {
6728
+ anonymous: false,
6729
+ inputs: [
6730
+ { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
6731
+ {
6732
+ indexed: true,
6733
+ internalType: "bytes32",
6734
+ name: "previousAdminRole",
6735
+ type: "bytes32"
6736
+ },
6737
+ {
6738
+ indexed: true,
6739
+ internalType: "bytes32",
6740
+ name: "newAdminRole",
6741
+ type: "bytes32"
6742
+ }
6743
+ ],
6744
+ name: "RoleAdminChanged",
6745
+ type: "event"
6746
+ },
6747
+ {
6748
+ anonymous: false,
6749
+ inputs: [
6750
+ { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
6751
+ {
6752
+ indexed: true,
6753
+ internalType: "address",
6754
+ name: "account",
6755
+ type: "address"
6756
+ },
6757
+ {
6758
+ indexed: true,
6759
+ internalType: "address",
6760
+ name: "sender",
6761
+ type: "address"
6762
+ }
6763
+ ],
6764
+ name: "RoleGranted",
6765
+ type: "event"
6766
+ },
6767
+ {
6768
+ anonymous: false,
6769
+ inputs: [
6770
+ { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
6771
+ {
6772
+ indexed: true,
6773
+ internalType: "address",
6774
+ name: "account",
6775
+ type: "address"
6776
+ },
6777
+ {
6778
+ indexed: true,
6779
+ internalType: "address",
6780
+ name: "sender",
6781
+ type: "address"
6782
+ }
6783
+ ],
6784
+ name: "RoleRevoked",
6785
+ type: "event"
6786
+ },
6787
+ {
6788
+ anonymous: false,
6789
+ inputs: [
6790
+ {
6791
+ indexed: true,
6792
+ internalType: "address",
6793
+ name: "implementation",
6794
+ type: "address"
6795
+ }
6796
+ ],
6797
+ name: "Upgraded",
6798
+ type: "event"
6799
+ },
6800
+ {
6801
+ inputs: [],
6802
+ name: "ACP_CONTRACT_ROLE",
6803
+ outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
6804
+ stateMutability: "view",
6805
+ type: "function"
6806
+ },
6807
+ {
6808
+ inputs: [],
6809
+ name: "ADMIN_ROLE",
6810
+ outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
6811
+ stateMutability: "view",
6812
+ type: "function"
6813
+ },
6814
+ {
6815
+ inputs: [],
6816
+ name: "DEFAULT_ADMIN_ROLE",
6817
+ outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
6818
+ stateMutability: "view",
6819
+ type: "function"
6820
+ },
6821
+ {
6822
+ inputs: [],
6823
+ name: "UPGRADE_INTERFACE_VERSION",
6824
+ outputs: [{ internalType: "string", name: "", type: "string" }],
6825
+ stateMutability: "view",
6826
+ type: "function"
6827
+ },
6828
+ {
6829
+ inputs: [],
6830
+ name: "acpContract",
6831
+ outputs: [{ internalType: "address", name: "", type: "address" }],
6832
+ stateMutability: "view",
6833
+ type: "function"
6834
+ },
6835
+ {
6836
+ inputs: [
6837
+ { internalType: "uint256", name: "memoId", type: "uint256" },
6838
+ { internalType: "address", name: "sender", type: "address" },
6839
+ { internalType: "bool", name: "approved", type: "bool" },
6840
+ { internalType: "string", name: "reason", type: "string" }
6841
+ ],
6842
+ name: "approveMemo",
6843
+ outputs: [],
6844
+ stateMutability: "nonpayable",
6845
+ type: "function"
6846
+ },
6847
+ {
6848
+ inputs: [],
6849
+ name: "assetManager",
6850
+ outputs: [{ internalType: "address", name: "", type: "address" }],
6851
+ stateMutability: "view",
6852
+ type: "function"
6853
+ },
6854
+ {
6855
+ inputs: [
6856
+ { internalType: "uint256[]", name: "memoIds", type: "uint256[]" },
6857
+ { internalType: "bool", name: "approved", type: "bool" },
6858
+ { internalType: "string", name: "reason", type: "string" }
6859
+ ],
6860
+ name: "bulkApproveMemos",
6861
+ outputs: [],
6862
+ stateMutability: "nonpayable",
6863
+ type: "function"
6864
+ },
6865
+ {
6866
+ inputs: [
6867
+ { internalType: "uint256", name: "memoId", type: "uint256" },
6868
+ { internalType: "address", name: "user", type: "address" }
6869
+ ],
6870
+ name: "canApproveMemo",
6871
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
6872
+ stateMutability: "view",
6873
+ type: "function"
6874
+ },
6875
+ {
6876
+ inputs: [
6877
+ { internalType: "uint256", name: "jobId", type: "uint256" },
6878
+ { internalType: "address", name: "sender", type: "address" },
6879
+ { internalType: "string", name: "content", type: "string" },
6880
+ {
6881
+ internalType: "enum ACPTypes.MemoType",
6882
+ name: "memoType",
6883
+ type: "uint8"
6884
+ },
6885
+ { internalType: "bool", name: "isSecured", type: "bool" },
6886
+ {
6887
+ internalType: "enum ACPTypes.JobPhase",
6888
+ name: "nextPhase",
6889
+ type: "uint8"
6890
+ },
6891
+ { internalType: "string", name: "metadata", type: "string" }
6892
+ ],
6893
+ name: "createMemo",
6894
+ outputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
6895
+ stateMutability: "nonpayable",
6896
+ type: "function"
6897
+ },
6898
+ {
6899
+ inputs: [
6900
+ { internalType: "uint256", name: "jobId", type: "uint256" },
6901
+ { internalType: "address", name: "sender", type: "address" },
6902
+ { internalType: "string", name: "content", type: "string" },
6903
+ {
6904
+ internalType: "enum ACPTypes.MemoType",
6905
+ name: "memoType",
6906
+ type: "uint8"
6907
+ },
6908
+ { internalType: "bool", name: "isSecured", type: "bool" },
6909
+ {
6910
+ internalType: "enum ACPTypes.JobPhase",
6911
+ name: "nextPhase",
6912
+ type: "uint8"
6913
+ },
6914
+ {
6915
+ components: [
6916
+ { internalType: "address", name: "token", type: "address" },
6917
+ { internalType: "uint256", name: "amount", type: "uint256" },
6918
+ { internalType: "address", name: "recipient", type: "address" },
6919
+ { internalType: "uint256", name: "feeAmount", type: "uint256" },
6920
+ {
6921
+ internalType: "enum ACPTypes.FeeType",
6922
+ name: "feeType",
6923
+ type: "uint8"
6924
+ },
6925
+ { internalType: "bool", name: "isExecuted", type: "bool" },
6926
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
6927
+ { internalType: "uint32", name: "lzSrcEid", type: "uint32" },
6928
+ { internalType: "uint32", name: "lzDstEid", type: "uint32" }
6929
+ ],
6930
+ internalType: "struct ACPTypes.PayableDetails",
6931
+ name: "payableDetails_",
6932
+ type: "tuple"
6933
+ },
6934
+ { internalType: "uint256", name: "expiredAt", type: "uint256" }
6935
+ ],
6936
+ name: "createPayableMemo",
6937
+ outputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
6938
+ stateMutability: "nonpayable",
6939
+ type: "function"
6940
+ },
6941
+ {
6942
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
6943
+ name: "emergencyApproveMemo",
6944
+ outputs: [],
6945
+ stateMutability: "nonpayable",
6946
+ type: "function"
6947
+ },
6948
+ {
6949
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
6950
+ name: "executePayableMemo",
6951
+ outputs: [],
6952
+ stateMutability: "nonpayable",
6953
+ type: "function"
6954
+ },
6955
+ {
6956
+ inputs: [],
6957
+ name: "getAssetManager",
6958
+ outputs: [{ internalType: "address", name: "", type: "address" }],
6959
+ stateMutability: "view",
6960
+ type: "function"
6961
+ },
6962
+ {
6963
+ inputs: [
6964
+ { internalType: "uint256", name: "jobId", type: "uint256" },
6965
+ { internalType: "uint256", name: "offset", type: "uint256" },
6966
+ { internalType: "uint256", name: "limit", type: "uint256" }
6967
+ ],
6968
+ name: "getJobMemos",
6969
+ outputs: [
6970
+ {
6971
+ components: [
6972
+ { internalType: "uint256", name: "id", type: "uint256" },
6973
+ { internalType: "uint256", name: "jobId", type: "uint256" },
6974
+ { internalType: "address", name: "sender", type: "address" },
6975
+ { internalType: "string", name: "content", type: "string" },
6976
+ {
6977
+ internalType: "enum ACPTypes.MemoType",
6978
+ name: "memoType",
6979
+ type: "uint8"
6980
+ },
6981
+ { internalType: "uint256", name: "createdAt", type: "uint256" },
6982
+ { internalType: "bool", name: "isApproved", type: "bool" },
6983
+ { internalType: "address", name: "approvedBy", type: "address" },
6984
+ { internalType: "uint256", name: "approvedAt", type: "uint256" },
6985
+ { internalType: "bool", name: "requiresApproval", type: "bool" },
6986
+ { internalType: "string", name: "metadata", type: "string" },
6987
+ { internalType: "bool", name: "isSecured", type: "bool" },
6988
+ {
6989
+ internalType: "enum ACPTypes.JobPhase",
6990
+ name: "nextPhase",
6991
+ type: "uint8"
6992
+ },
6993
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
6994
+ {
6995
+ internalType: "enum ACPTypes.MemoState",
6996
+ name: "state",
6997
+ type: "uint8"
6998
+ }
6999
+ ],
7000
+ internalType: "struct ACPTypes.Memo[]",
7001
+ name: "memoArray",
7002
+ type: "tuple[]"
7003
+ },
7004
+ { internalType: "uint256", name: "total", type: "uint256" }
7005
+ ],
7006
+ stateMutability: "view",
7007
+ type: "function"
7008
+ },
7009
+ {
7010
+ inputs: [
7011
+ { internalType: "uint256", name: "jobId", type: "uint256" },
7012
+ { internalType: "enum ACPTypes.JobPhase", name: "phase", type: "uint8" },
7013
+ { internalType: "uint256", name: "offset", type: "uint256" },
7014
+ { internalType: "uint256", name: "limit", type: "uint256" }
7015
+ ],
7016
+ name: "getJobMemosByPhase",
7017
+ outputs: [
7018
+ {
7019
+ components: [
7020
+ { internalType: "uint256", name: "id", type: "uint256" },
7021
+ { internalType: "uint256", name: "jobId", type: "uint256" },
7022
+ { internalType: "address", name: "sender", type: "address" },
7023
+ { internalType: "string", name: "content", type: "string" },
7024
+ {
7025
+ internalType: "enum ACPTypes.MemoType",
7026
+ name: "memoType",
7027
+ type: "uint8"
7028
+ },
7029
+ { internalType: "uint256", name: "createdAt", type: "uint256" },
7030
+ { internalType: "bool", name: "isApproved", type: "bool" },
7031
+ { internalType: "address", name: "approvedBy", type: "address" },
7032
+ { internalType: "uint256", name: "approvedAt", type: "uint256" },
7033
+ { internalType: "bool", name: "requiresApproval", type: "bool" },
7034
+ { internalType: "string", name: "metadata", type: "string" },
7035
+ { internalType: "bool", name: "isSecured", type: "bool" },
7036
+ {
7037
+ internalType: "enum ACPTypes.JobPhase",
7038
+ name: "nextPhase",
7039
+ type: "uint8"
7040
+ },
7041
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
7042
+ {
7043
+ internalType: "enum ACPTypes.MemoState",
7044
+ name: "state",
7045
+ type: "uint8"
7046
+ }
7047
+ ],
7048
+ internalType: "struct ACPTypes.Memo[]",
7049
+ name: "memoArray",
7050
+ type: "tuple[]"
7051
+ },
7052
+ { internalType: "uint256", name: "total", type: "uint256" }
7053
+ ],
7054
+ stateMutability: "view",
7055
+ type: "function"
7056
+ },
7057
+ {
7058
+ inputs: [
7059
+ { internalType: "uint256", name: "jobId", type: "uint256" },
7060
+ {
7061
+ internalType: "enum ACPTypes.MemoType",
7062
+ name: "memoType",
7063
+ type: "uint8"
7064
+ },
7065
+ { internalType: "uint256", name: "offset", type: "uint256" },
7066
+ { internalType: "uint256", name: "limit", type: "uint256" }
7067
+ ],
7068
+ name: "getJobMemosByType",
7069
+ outputs: [
7070
+ {
7071
+ components: [
7072
+ { internalType: "uint256", name: "id", type: "uint256" },
7073
+ { internalType: "uint256", name: "jobId", type: "uint256" },
7074
+ { internalType: "address", name: "sender", type: "address" },
7075
+ { internalType: "string", name: "content", type: "string" },
7076
+ {
7077
+ internalType: "enum ACPTypes.MemoType",
7078
+ name: "memoType",
7079
+ type: "uint8"
7080
+ },
7081
+ { internalType: "uint256", name: "createdAt", type: "uint256" },
7082
+ { internalType: "bool", name: "isApproved", type: "bool" },
7083
+ { internalType: "address", name: "approvedBy", type: "address" },
7084
+ { internalType: "uint256", name: "approvedAt", type: "uint256" },
7085
+ { internalType: "bool", name: "requiresApproval", type: "bool" },
7086
+ { internalType: "string", name: "metadata", type: "string" },
7087
+ { internalType: "bool", name: "isSecured", type: "bool" },
7088
+ {
7089
+ internalType: "enum ACPTypes.JobPhase",
7090
+ name: "nextPhase",
7091
+ type: "uint8"
7092
+ },
7093
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
7094
+ {
7095
+ internalType: "enum ACPTypes.MemoState",
7096
+ name: "state",
7097
+ type: "uint8"
7098
+ }
7099
+ ],
7100
+ internalType: "struct ACPTypes.Memo[]",
7101
+ name: "memoArray",
7102
+ type: "tuple[]"
7103
+ },
7104
+ { internalType: "uint256", name: "total", type: "uint256" }
7105
+ ],
7106
+ stateMutability: "view",
7107
+ type: "function"
7108
+ },
7109
+ {
7110
+ inputs: [],
7111
+ name: "getLocalEid",
7112
+ outputs: [{ internalType: "uint32", name: "", type: "uint32" }],
7113
+ stateMutability: "view",
7114
+ type: "function"
7115
+ },
7116
+ {
7117
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
7118
+ name: "getMemo",
7119
+ outputs: [
7120
+ {
7121
+ components: [
7122
+ { internalType: "uint256", name: "id", type: "uint256" },
7123
+ { internalType: "uint256", name: "jobId", type: "uint256" },
7124
+ { internalType: "address", name: "sender", type: "address" },
7125
+ { internalType: "string", name: "content", type: "string" },
7126
+ {
7127
+ internalType: "enum ACPTypes.MemoType",
7128
+ name: "memoType",
7129
+ type: "uint8"
7130
+ },
7131
+ { internalType: "uint256", name: "createdAt", type: "uint256" },
7132
+ { internalType: "bool", name: "isApproved", type: "bool" },
7133
+ { internalType: "address", name: "approvedBy", type: "address" },
7134
+ { internalType: "uint256", name: "approvedAt", type: "uint256" },
7135
+ { internalType: "bool", name: "requiresApproval", type: "bool" },
7136
+ { internalType: "string", name: "metadata", type: "string" },
7137
+ { internalType: "bool", name: "isSecured", type: "bool" },
7138
+ {
7139
+ internalType: "enum ACPTypes.JobPhase",
7140
+ name: "nextPhase",
7141
+ type: "uint8"
7142
+ },
7143
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
7144
+ {
7145
+ internalType: "enum ACPTypes.MemoState",
7146
+ name: "state",
7147
+ type: "uint8"
7148
+ }
7149
+ ],
7150
+ internalType: "struct ACPTypes.Memo",
7151
+ name: "",
7152
+ type: "tuple"
7153
+ }
7154
+ ],
7155
+ stateMutability: "view",
7156
+ type: "function"
7157
+ },
7158
+ {
7159
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
7160
+ name: "getMemoApprovalStatus",
7161
+ outputs: [
7162
+ { internalType: "bool", name: "isApproved", type: "bool" },
7163
+ { internalType: "address", name: "approvedBy", type: "address" },
7164
+ { internalType: "uint256", name: "approvedAt", type: "uint256" }
7165
+ ],
7166
+ stateMutability: "view",
7167
+ type: "function"
7168
+ },
7169
+ {
7170
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
7171
+ name: "getMemoWithPayableDetails",
7172
+ outputs: [
7173
+ {
7174
+ components: [
7175
+ { internalType: "uint256", name: "id", type: "uint256" },
7176
+ { internalType: "uint256", name: "jobId", type: "uint256" },
7177
+ { internalType: "address", name: "sender", type: "address" },
7178
+ { internalType: "string", name: "content", type: "string" },
7179
+ {
7180
+ internalType: "enum ACPTypes.MemoType",
7181
+ name: "memoType",
7182
+ type: "uint8"
7183
+ },
7184
+ { internalType: "uint256", name: "createdAt", type: "uint256" },
7185
+ { internalType: "bool", name: "isApproved", type: "bool" },
7186
+ { internalType: "address", name: "approvedBy", type: "address" },
7187
+ { internalType: "uint256", name: "approvedAt", type: "uint256" },
7188
+ { internalType: "bool", name: "requiresApproval", type: "bool" },
7189
+ { internalType: "string", name: "metadata", type: "string" },
7190
+ { internalType: "bool", name: "isSecured", type: "bool" },
7191
+ {
7192
+ internalType: "enum ACPTypes.JobPhase",
7193
+ name: "nextPhase",
7194
+ type: "uint8"
7195
+ },
7196
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
7197
+ {
7198
+ internalType: "enum ACPTypes.MemoState",
7199
+ name: "state",
7200
+ type: "uint8"
7201
+ }
7202
+ ],
7203
+ internalType: "struct ACPTypes.Memo",
7204
+ name: "memo",
7205
+ type: "tuple"
7206
+ },
7207
+ {
7208
+ components: [
7209
+ { internalType: "address", name: "token", type: "address" },
7210
+ { internalType: "uint256", name: "amount", type: "uint256" },
7211
+ { internalType: "address", name: "recipient", type: "address" },
7212
+ { internalType: "uint256", name: "feeAmount", type: "uint256" },
7213
+ {
7214
+ internalType: "enum ACPTypes.FeeType",
7215
+ name: "feeType",
7216
+ type: "uint8"
7217
+ },
7218
+ { internalType: "bool", name: "isExecuted", type: "bool" },
7219
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
7220
+ { internalType: "uint32", name: "lzSrcEid", type: "uint32" },
7221
+ { internalType: "uint32", name: "lzDstEid", type: "uint32" }
7222
+ ],
7223
+ internalType: "struct ACPTypes.PayableDetails",
7224
+ name: "details",
7225
+ type: "tuple"
7226
+ }
7227
+ ],
7228
+ stateMutability: "view",
7229
+ type: "function"
7230
+ },
7231
+ {
7232
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
7233
+ name: "getPayableDetails",
7234
+ outputs: [
7235
+ {
7236
+ components: [
7237
+ { internalType: "address", name: "token", type: "address" },
7238
+ { internalType: "uint256", name: "amount", type: "uint256" },
7239
+ { internalType: "address", name: "recipient", type: "address" },
7240
+ { internalType: "uint256", name: "feeAmount", type: "uint256" },
7241
+ {
7242
+ internalType: "enum ACPTypes.FeeType",
7243
+ name: "feeType",
7244
+ type: "uint8"
7245
+ },
7246
+ { internalType: "bool", name: "isExecuted", type: "bool" },
7247
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
7248
+ { internalType: "uint32", name: "lzSrcEid", type: "uint32" },
7249
+ { internalType: "uint32", name: "lzDstEid", type: "uint32" }
7250
+ ],
7251
+ internalType: "struct ACPTypes.PayableDetails",
7252
+ name: "",
7253
+ type: "tuple"
7254
+ }
7255
+ ],
7256
+ stateMutability: "view",
7257
+ type: "function"
7258
+ },
7259
+ {
7260
+ inputs: [{ internalType: "bytes32", name: "role", type: "bytes32" }],
7261
+ name: "getRoleAdmin",
7262
+ outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
7263
+ stateMutability: "view",
7264
+ type: "function"
7265
+ },
7266
+ {
7267
+ inputs: [
7268
+ { internalType: "bytes32", name: "role", type: "bytes32" },
7269
+ { internalType: "address", name: "account", type: "address" }
7270
+ ],
7271
+ name: "grantRole",
7272
+ outputs: [],
7273
+ stateMutability: "nonpayable",
7274
+ type: "function"
7275
+ },
7276
+ {
7277
+ inputs: [
7278
+ { internalType: "bytes32", name: "role", type: "bytes32" },
7279
+ { internalType: "address", name: "account", type: "address" }
7280
+ ],
7281
+ name: "hasRole",
7282
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
7283
+ stateMutability: "view",
7284
+ type: "function"
7285
+ },
7286
+ {
7287
+ inputs: [
7288
+ { internalType: "address", name: "acpContract_", type: "address" },
7289
+ { internalType: "address", name: "jobManager_", type: "address" },
7290
+ { internalType: "address", name: "paymentManager_", type: "address" }
7291
+ ],
7292
+ name: "initialize",
7293
+ outputs: [],
7294
+ stateMutability: "nonpayable",
7295
+ type: "function"
7296
+ },
7297
+ {
7298
+ inputs: [
7299
+ { internalType: "uint256", name: "jobId", type: "uint256" },
7300
+ { internalType: "address", name: "user", type: "address" }
7301
+ ],
7302
+ name: "isJobEvaluator",
7303
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
7304
+ stateMutability: "view",
7305
+ type: "function"
7306
+ },
7307
+ {
7308
+ inputs: [
7309
+ { internalType: "uint256", name: "memoId", type: "uint256" },
7310
+ { internalType: "address", name: "user", type: "address" }
7311
+ ],
7312
+ name: "isMemoSigner",
7313
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
7314
+ stateMutability: "view",
7315
+ type: "function"
7316
+ },
7317
+ {
7318
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
7319
+ name: "isPayable",
7320
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
7321
+ stateMutability: "view",
7322
+ type: "function"
7323
+ },
7324
+ {
7325
+ inputs: [],
7326
+ name: "jobManager",
7327
+ outputs: [{ internalType: "address", name: "", type: "address" }],
7328
+ stateMutability: "view",
7329
+ type: "function"
7330
+ },
7331
+ {
7332
+ inputs: [
7333
+ { internalType: "uint256", name: "", type: "uint256" },
7334
+ { internalType: "uint256", name: "", type: "uint256" }
7335
+ ],
7336
+ name: "jobMemos",
7337
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7338
+ stateMutability: "view",
7339
+ type: "function"
7340
+ },
7341
+ {
7342
+ inputs: [
7343
+ { internalType: "uint256", name: "", type: "uint256" },
7344
+ { internalType: "enum ACPTypes.JobPhase", name: "", type: "uint8" },
7345
+ { internalType: "uint256", name: "", type: "uint256" }
7346
+ ],
7347
+ name: "jobMemosByPhase",
7348
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7349
+ stateMutability: "view",
7350
+ type: "function"
7351
+ },
7352
+ {
7353
+ inputs: [
7354
+ { internalType: "uint256", name: "", type: "uint256" },
7355
+ { internalType: "enum ACPTypes.MemoType", name: "", type: "uint8" },
7356
+ { internalType: "uint256", name: "", type: "uint256" }
7357
+ ],
7358
+ name: "jobMemosByType",
7359
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7360
+ stateMutability: "view",
7361
+ type: "function"
7362
+ },
7363
+ {
7364
+ inputs: [
7365
+ { internalType: "uint256", name: "", type: "uint256" },
7366
+ { internalType: "address", name: "", type: "address" }
7367
+ ],
7368
+ name: "memoApprovals",
7369
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
7370
+ stateMutability: "view",
7371
+ type: "function"
7372
+ },
7373
+ {
7374
+ inputs: [],
7375
+ name: "memoCounter",
7376
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7377
+ stateMutability: "view",
7378
+ type: "function"
7379
+ },
7380
+ {
7381
+ inputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7382
+ name: "memos",
7383
+ outputs: [
7384
+ { internalType: "uint256", name: "id", type: "uint256" },
7385
+ { internalType: "uint256", name: "jobId", type: "uint256" },
7386
+ { internalType: "address", name: "sender", type: "address" },
7387
+ { internalType: "string", name: "content", type: "string" },
7388
+ {
7389
+ internalType: "enum ACPTypes.MemoType",
7390
+ name: "memoType",
7391
+ type: "uint8"
7392
+ },
7393
+ { internalType: "uint256", name: "createdAt", type: "uint256" },
7394
+ { internalType: "bool", name: "isApproved", type: "bool" },
7395
+ { internalType: "address", name: "approvedBy", type: "address" },
7396
+ { internalType: "uint256", name: "approvedAt", type: "uint256" },
7397
+ { internalType: "bool", name: "requiresApproval", type: "bool" },
7398
+ { internalType: "string", name: "metadata", type: "string" },
7399
+ { internalType: "bool", name: "isSecured", type: "bool" },
7400
+ {
7401
+ internalType: "enum ACPTypes.JobPhase",
7402
+ name: "nextPhase",
7403
+ type: "uint8"
7404
+ },
7405
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
7406
+ { internalType: "enum ACPTypes.MemoState", name: "state", type: "uint8" }
7407
+ ],
7408
+ stateMutability: "view",
7409
+ type: "function"
7410
+ },
7411
+ {
7412
+ inputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7413
+ name: "payableDetails",
7414
+ outputs: [
7415
+ { internalType: "address", name: "token", type: "address" },
7416
+ { internalType: "uint256", name: "amount", type: "uint256" },
7417
+ { internalType: "address", name: "recipient", type: "address" },
7418
+ { internalType: "uint256", name: "feeAmount", type: "uint256" },
7419
+ { internalType: "enum ACPTypes.FeeType", name: "feeType", type: "uint8" },
7420
+ { internalType: "bool", name: "isExecuted", type: "bool" },
7421
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
7422
+ { internalType: "uint32", name: "lzSrcEid", type: "uint32" },
7423
+ { internalType: "uint32", name: "lzDstEid", type: "uint32" }
7424
+ ],
7425
+ stateMutability: "view",
7426
+ type: "function"
7427
+ },
7428
+ {
7429
+ inputs: [],
7430
+ name: "paymentManager",
7431
+ outputs: [{ internalType: "address", name: "", type: "address" }],
7432
+ stateMutability: "view",
7433
+ type: "function"
7434
+ },
7435
+ {
7436
+ inputs: [],
7437
+ name: "proxiableUUID",
7438
+ outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
7439
+ stateMutability: "view",
7440
+ type: "function"
7441
+ },
7442
+ {
7443
+ inputs: [
7444
+ { internalType: "bytes32", name: "role", type: "bytes32" },
7445
+ { internalType: "address", name: "callerConfirmation", type: "address" }
7446
+ ],
7447
+ name: "renounceRole",
7448
+ outputs: [],
7449
+ stateMutability: "nonpayable",
7450
+ type: "function"
7451
+ },
7452
+ {
7453
+ inputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7454
+ name: "requiredApprovals",
7455
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7456
+ stateMutability: "view",
7457
+ type: "function"
7458
+ },
7459
+ {
7460
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
7461
+ name: "requiresApproval",
7462
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
7463
+ stateMutability: "view",
7464
+ type: "function"
7465
+ },
7466
+ {
7467
+ inputs: [
7468
+ { internalType: "bytes32", name: "role", type: "bytes32" },
7469
+ { internalType: "address", name: "account", type: "address" }
7470
+ ],
7471
+ name: "revokeRole",
7472
+ outputs: [],
7473
+ stateMutability: "nonpayable",
7474
+ type: "function"
7475
+ },
7476
+ {
7477
+ inputs: [
7478
+ {
7479
+ internalType: "enum ACPTypes.MemoType",
7480
+ name: "memoType",
7481
+ type: "uint8"
7482
+ },
7483
+ { internalType: "uint256", name: "requiredApprovals_", type: "uint256" }
7484
+ ],
7485
+ name: "setApprovalRequirements",
7486
+ outputs: [],
7487
+ stateMutability: "nonpayable",
7488
+ type: "function"
7489
+ },
7490
+ {
7491
+ inputs: [
7492
+ { internalType: "address", name: "assetManager_", type: "address" }
7493
+ ],
7494
+ name: "setAssetManager",
7495
+ outputs: [],
7496
+ stateMutability: "nonpayable",
7497
+ type: "function"
7498
+ },
7499
+ {
7500
+ inputs: [
7501
+ { internalType: "uint256", name: "memoId", type: "uint256" },
7502
+ { internalType: "address", name: "sender", type: "address" },
7503
+ { internalType: "bool", name: "isApproved", type: "bool" },
7504
+ { internalType: "string", name: "reason", type: "string" }
7505
+ ],
7506
+ name: "signMemo",
7507
+ outputs: [{ internalType: "uint256", name: "jobId", type: "uint256" }],
7508
+ stateMutability: "nonpayable",
7509
+ type: "function"
7510
+ },
7511
+ {
7512
+ inputs: [{ internalType: "bytes4", name: "interfaceId", type: "bytes4" }],
7513
+ name: "supportsInterface",
7514
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
7515
+ stateMutability: "view",
7516
+ type: "function"
7517
+ },
7518
+ {
7519
+ inputs: [
7520
+ { internalType: "address", name: "acpContract_", type: "address" },
7521
+ { internalType: "address", name: "jobManager_", type: "address" },
7522
+ { internalType: "address", name: "paymentManager_", type: "address" },
7523
+ { internalType: "address", name: "assetManager_", type: "address" }
7524
+ ],
7525
+ name: "updateContracts",
7526
+ outputs: [],
7527
+ stateMutability: "nonpayable",
7528
+ type: "function"
7529
+ },
7530
+ {
7531
+ inputs: [
7532
+ { internalType: "uint256", name: "memoId", type: "uint256" },
7533
+ { internalType: "string", name: "newContent", type: "string" }
7534
+ ],
7535
+ name: "updateMemoContent",
7536
+ outputs: [],
7537
+ stateMutability: "nonpayable",
7538
+ type: "function"
7539
+ },
7540
+ {
7541
+ inputs: [
7542
+ { internalType: "uint256", name: "memoId", type: "uint256" },
7543
+ {
7544
+ internalType: "enum ACPTypes.MemoState",
7545
+ name: "newMemoState",
7546
+ type: "uint8"
7547
+ }
7548
+ ],
7549
+ name: "updateMemoState",
7550
+ outputs: [],
7551
+ stateMutability: "nonpayable",
7552
+ type: "function"
7553
+ },
7554
+ {
7555
+ inputs: [
7556
+ { internalType: "address", name: "newImplementation", type: "address" },
7557
+ { internalType: "bytes", name: "data", type: "bytes" }
7558
+ ],
7559
+ name: "upgradeToAndCall",
7560
+ outputs: [],
7561
+ stateMutability: "payable",
7562
+ type: "function"
7563
+ },
7564
+ {
7565
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
7566
+ name: "withdrawEscrowedFunds",
7567
+ outputs: [],
7568
+ stateMutability: "nonpayable",
7569
+ type: "function"
7570
+ }
7571
+ ];
7572
+ var memoManagerAbi_default = MEMO_MANAGER_ABI;
7573
+
7574
+ // src/contractClients/acpContractClientV2.ts
7575
+ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClient_default {
7576
+ constructor(jobManagerAddress, memoManagerAddress, accountManagerAddress, agentWalletAddress, config = baseAcpConfigV2) {
7577
+ super(agentWalletAddress, config);
7578
+ this.jobManagerAddress = jobManagerAddress;
7579
+ this.memoManagerAddress = memoManagerAddress;
7580
+ this.accountManagerAddress = accountManagerAddress;
7581
+ this.PRIORITY_FEE_MULTIPLIER = 2;
7582
+ this.MAX_FEE_PER_GAS = 2e7;
7583
+ this.MAX_PRIORITY_FEE_PER_GAS = 21e6;
7584
+ this.GAS_FEE_MULTIPLIER = 0.5;
7585
+ this.RETRY_CONFIG = {
7586
+ intervalMs: 200,
7587
+ multiplier: 1.1,
7588
+ maxRetries: 10
7589
+ };
7590
+ this._sessionKeyClients = {};
7591
+ }
7592
+ static async build(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfigV2) {
7593
+ const publicClients = {};
7594
+ for (const chain of config.chains) {
7595
+ publicClients[chain.id] = createPublicClient4({
7596
+ chain,
7597
+ transport: http3(`${config.alchemyRpcUrl}?chainId=${chain.id}`)
7598
+ });
7599
+ }
7600
+ const publicClient = createPublicClient4({
7601
+ chain: config.chain,
7602
+ transport: http3(config.rpcEndpoint)
7603
+ });
7604
+ const [jobManagerAddress, memoManagerAddress, accountManagerAddress] = await publicClient.multicall({
7605
+ contracts: [
7606
+ {
7607
+ address: config.contractAddress,
7608
+ abi: config.abi,
7609
+ functionName: "jobManager"
7610
+ },
7611
+ {
7612
+ address: config.contractAddress,
7613
+ abi: config.abi,
7614
+ functionName: "memoManager"
7615
+ },
7616
+ {
7617
+ address: config.contractAddress,
7618
+ abi: config.abi,
7619
+ functionName: "accountManager"
7620
+ }
7621
+ ]
7622
+ });
7623
+ if (!jobManagerAddress || !memoManagerAddress || !accountManagerAddress) {
7624
+ throw new acpError_default(
7625
+ "Failed to get job manager, memo manager, or account manager address"
7626
+ );
7627
+ }
7628
+ const acpContractClient = new _AcpContractClientV2(
7629
+ jobManagerAddress.result,
7630
+ memoManagerAddress.result,
7631
+ accountManagerAddress.result,
7632
+ agentWalletAddress,
7633
+ config
7634
+ );
7635
+ acpContractClient.publicClients = publicClients;
7636
+ await acpContractClient.init(walletPrivateKey, sessionEntityKeyId);
7637
+ return acpContractClient;
7638
+ }
7639
+ async init(privateKey, sessionEntityKeyId) {
7640
+ const sessionKeySigner = LocalAccountSigner2.privateKeyToAccountSigner(privateKey);
7641
+ this._sessionKeyClient = await createModularAccountV2Client2({
7642
+ chain: this.chain,
7643
+ transport: alchemy2({
7644
+ rpcUrl: this.config.alchemyRpcUrl
7645
+ }),
7646
+ signer: sessionKeySigner,
7647
+ policyId: "186aaa4a-5f57-4156-83fb-e456365a8820",
7648
+ accountAddress: this.agentWalletAddress,
7649
+ signerEntity: {
7650
+ entityId: sessionEntityKeyId,
7651
+ isGlobalValidation: true
7652
+ }
7653
+ });
7654
+ for (const chain of this.config.chains) {
7655
+ this._sessionKeyClients[chain.id] = await createModularAccountV2Client2({
7656
+ chain,
7657
+ transport: alchemy2({
7658
+ rpcUrl: `${this.config.alchemyRpcUrl}?chainId=${chain.id}`
7659
+ }),
7660
+ signer: sessionKeySigner,
7661
+ policyId: "186aaa4a-5f57-4156-83fb-e456365a8820",
7662
+ accountAddress: this.agentWalletAddress,
7663
+ signerEntity: {
7664
+ entityId: sessionEntityKeyId,
7665
+ isGlobalValidation: true
7666
+ }
7667
+ });
7668
+ }
7669
+ this._acpX402 = new AcpX402(
7670
+ this.config,
7671
+ this.sessionKeyClient,
7672
+ this.publicClient
7673
+ );
7674
+ const account = this.sessionKeyClient.account;
7675
+ const sessionSignerAddress = await account.getSigner().getAddress();
7676
+ if (!await account.isAccountDeployed()) {
7677
+ throw new acpError_default(
7678
+ `ACP Contract Client validation failed: agent account ${this.agentWalletAddress} is not deployed on-chain`
7679
+ );
7680
+ }
7681
+ await this.validateSessionKeyOnChain(
7682
+ sessionSignerAddress,
7683
+ sessionEntityKeyId
6125
7684
  );
6126
7685
  this.RETRY_CONFIG = this.config.retryConfig || this.RETRY_CONFIG;
6127
7686
  console.log("Connected to ACP:", {
@@ -6151,11 +7710,20 @@ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClie
6151
7710
  }
6152
7711
  return this._acpX402;
6153
7712
  }
6154
- async calculateGasFees() {
7713
+ async calculateGasFees(chainId) {
7714
+ if (chainId) {
7715
+ const { maxFeePerGas } = await this.publicClients[chainId].estimateFeesPerGas();
7716
+ const increasedMaxFeePerGas = BigInt(maxFeePerGas) + BigInt(maxFeePerGas) * BigInt(this.GAS_FEE_MULTIPLIER * 100) / BigInt(100);
7717
+ return increasedMaxFeePerGas;
7718
+ }
6155
7719
  const finalMaxFeePerGas = BigInt(this.MAX_FEE_PER_GAS) + BigInt(this.MAX_PRIORITY_FEE_PER_GAS) * BigInt(Math.max(0, this.PRIORITY_FEE_MULTIPLIER - 1));
6156
7720
  return finalMaxFeePerGas;
6157
7721
  }
6158
- async handleOperation(operations) {
7722
+ async handleOperation(operations, chainId) {
7723
+ const sessionKeyClient = chainId ? this._sessionKeyClients[chainId] : this.sessionKeyClient;
7724
+ if (!sessionKeyClient) {
7725
+ throw new acpError_default("Session key client not initialized");
7726
+ }
6159
7727
  const basePayload = {
6160
7728
  uo: operations.map((operation) => ({
6161
7729
  target: operation.contractAddress,
@@ -6180,12 +7748,17 @@ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClie
6180
7748
  }
6181
7749
  }
6182
7750
  };
6183
- const { hash } = await this.sessionKeyClient.sendUserOperation(payload);
6184
- const txnHash = await this.sessionKeyClient.waitForUserOperationTransaction({
7751
+ const { hash } = await sessionKeyClient.sendUserOperation(payload);
7752
+ const checkTransactionConfig = {
6185
7753
  hash,
6186
- tag: "pending",
6187
7754
  retries: this.RETRY_CONFIG
6188
- });
7755
+ };
7756
+ if (!chainId || chainId === baseSepolia4.id || chainId === base4.id) {
7757
+ checkTransactionConfig["tag"] = "pending";
7758
+ }
7759
+ const txnHash = await sessionKeyClient.waitForUserOperationTransaction(
7760
+ checkTransactionConfig
7761
+ );
6189
7762
  return { userOpHash: hash, txnHash };
6190
7763
  } catch (error) {
6191
7764
  iteration++;
@@ -6248,6 +7821,13 @@ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClie
6248
7821
  throw new acpError_default("Failed to get X402 payment details", error);
6249
7822
  }
6250
7823
  }
7824
+ async getAssetManager() {
7825
+ return await this.publicClient.readContract({
7826
+ address: this.memoManagerAddress,
7827
+ abi: memoManagerAbi_default,
7828
+ functionName: "assetManager"
7829
+ });
7830
+ }
6251
7831
  getAcpVersion() {
6252
7832
  return "2";
6253
7833
  }
@@ -6271,6 +7851,7 @@ export {
6271
7851
  acpJob_default as AcpJob,
6272
7852
  AcpJobPhases,
6273
7853
  acpMemo_default as AcpMemo,
7854
+ AcpMemoState,
6274
7855
  AcpMemoStatus,
6275
7856
  AcpOnlineStatus,
6276
7857
  baseAcpContractClient_default as BaseAcpContractClient,
@@ -6284,6 +7865,7 @@ export {
6284
7865
  baseAcpX402ConfigV2,
6285
7866
  baseSepoliaAcpConfig,
6286
7867
  baseSepoliaAcpConfigV2,
7868
+ baseSepoliaAcpX402ConfigV2,
6287
7869
  index_default as default,
6288
7870
  ethFare,
6289
7871
  preparePayload,