@virtuals-protocol/acp-node 0.3.0-beta.17 → 0.3.0-beta.19

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.js CHANGED
@@ -35,12 +35,13 @@ 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.17",
38
+ version: "0.3.0-beta.19",
39
39
  main: "./dist/index.js",
40
40
  module: "./dist/index.mjs",
41
41
  types: "./dist/index.d.ts",
42
42
  scripts: {
43
43
  test: "jest",
44
+ "test:ci": "jest --ci --reporters=default --reporters=jest-junit",
44
45
  "test:watch": "jest --watch",
45
46
  "test:coverage": "jest --coverage",
46
47
  tsup: "tsup src/index.ts --dts --format cjs,esm --out-dir dist"
@@ -56,6 +57,7 @@ var require_package = __commonJS({
56
57
  "babel-jest": "^30.2.0",
57
58
  dotenv: "^17.2.3",
58
59
  jest: "^30.2.0",
60
+ "jest-junit": "^16.0.0",
59
61
  "ts-jest": "^29.4.5",
60
62
  typescript: "^5.8.3"
61
63
  },
@@ -89,6 +91,7 @@ __export(index_exports, {
89
91
  AcpJob: () => acpJob_default,
90
92
  AcpJobPhases: () => AcpJobPhases,
91
93
  AcpMemo: () => acpMemo_default,
94
+ AcpMemoState: () => AcpMemoState,
92
95
  AcpMemoStatus: () => AcpMemoStatus,
93
96
  AcpOnlineStatus: () => AcpOnlineStatus,
94
97
  BaseAcpContractClient: () => baseAcpContractClient_default,
@@ -104,6 +107,7 @@ __export(index_exports, {
104
107
  baseAcpX402ConfigV2: () => baseAcpX402ConfigV2,
105
108
  baseSepoliaAcpConfig: () => baseSepoliaAcpConfig,
106
109
  baseSepoliaAcpConfigV2: () => baseSepoliaAcpConfigV2,
110
+ baseSepoliaAcpX402ConfigV2: () => baseSepoliaAcpX402ConfigV2,
107
111
  default: () => index_default,
108
112
  ethFare: () => ethFare,
109
113
  preparePayload: () => preparePayload,
@@ -1282,7 +1286,7 @@ var ACP_ABI = [
1282
1286
  var acpAbi_default = ACP_ABI;
1283
1287
 
1284
1288
  // src/acpClient.ts
1285
- var import_viem4 = require("viem");
1289
+ var import_viem6 = require("viem");
1286
1290
  var import_socket = require("socket.io-client");
1287
1291
 
1288
1292
  // src/contractClients/baseAcpContractClient.ts
@@ -1311,27 +1315,42 @@ var acpError_default = AcpError;
1311
1315
 
1312
1316
  // src/acpFare.ts
1313
1317
  var Fare = class _Fare {
1314
- constructor(contractAddress, decimals) {
1318
+ constructor(contractAddress, decimals, chainId) {
1315
1319
  this.contractAddress = contractAddress;
1316
1320
  this.decimals = decimals;
1321
+ this.chainId = chainId;
1317
1322
  }
1318
1323
  formatAmount(amount) {
1319
1324
  return (0, import_viem.parseUnits)(amount.toString(), this.decimals);
1320
1325
  }
1321
- static async fromContractAddress(contractAddress, config = baseAcpConfig) {
1326
+ static async fromContractAddress(contractAddress, config = baseAcpConfig, chainId = config.chain.id) {
1322
1327
  if (contractAddress === config.baseFare.contractAddress) {
1323
1328
  return config.baseFare;
1324
1329
  }
1330
+ let chainConfig = config.chain;
1331
+ let rpcUrl = config.rpcEndpoint;
1332
+ if (chainId !== config.chain.id) {
1333
+ const selectedConfig = config.chains?.find(
1334
+ (chain) => chain.chain.id === chainId
1335
+ );
1336
+ if (!selectedConfig) {
1337
+ throw new acpError_default(
1338
+ `Chain configuration for chainId ${chainId} not found.`
1339
+ );
1340
+ }
1341
+ chainConfig = selectedConfig.chain;
1342
+ rpcUrl = selectedConfig.rpcUrl;
1343
+ }
1325
1344
  const publicClient = (0, import_viem.createPublicClient)({
1326
- chain: config.chain,
1327
- transport: (0, import_viem.http)(config.rpcEndpoint)
1345
+ chain: chainConfig,
1346
+ transport: (0, import_viem.http)(rpcUrl)
1328
1347
  });
1329
1348
  const decimals = await publicClient.readContract({
1330
1349
  address: contractAddress,
1331
1350
  abi: import_viem.erc20Abi,
1332
1351
  functionName: "decimals"
1333
1352
  });
1334
- return new _Fare(contractAddress, decimals);
1353
+ return new _Fare(contractAddress, decimals, chainId);
1335
1354
  }
1336
1355
  };
1337
1356
  var FareAmountBase = class {
@@ -1750,6 +1769,34 @@ var ACP_V2_ABI = [
1750
1769
  stateMutability: "nonpayable",
1751
1770
  type: "function"
1752
1771
  },
1772
+ {
1773
+ inputs: [
1774
+ { internalType: "uint256", name: "jobId", type: "uint256" },
1775
+ { internalType: "string", name: "content", type: "string" },
1776
+ { internalType: "address", name: "token", type: "address" },
1777
+ { internalType: "uint256", name: "amount", type: "uint256" },
1778
+ { internalType: "address", name: "recipient", type: "address" },
1779
+ { internalType: "uint256", name: "feeAmount", type: "uint256" },
1780
+ { internalType: "enum ACPTypes.FeeType", name: "feeType", type: "uint8" },
1781
+ {
1782
+ internalType: "enum ACPTypes.MemoType",
1783
+ name: "memoType",
1784
+ type: "uint8"
1785
+ },
1786
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
1787
+ { internalType: "bool", name: "isSecured", type: "bool" },
1788
+ {
1789
+ internalType: "enum ACPTypes.JobPhase",
1790
+ name: "nextPhase",
1791
+ type: "uint8"
1792
+ },
1793
+ { internalType: "uint32", name: "lzDstEid", type: "uint32" }
1794
+ ],
1795
+ name: "createCrossChainPayableMemo",
1796
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
1797
+ stateMutability: "nonpayable",
1798
+ type: "function"
1799
+ },
1753
1800
  {
1754
1801
  inputs: [
1755
1802
  { internalType: "address", name: "provider", type: "address" },
@@ -1934,7 +1981,12 @@ var ACP_V2_ABI = [
1934
1981
  name: "nextPhase",
1935
1982
  type: "uint8"
1936
1983
  },
1937
- { internalType: "uint256", name: "expiredAt", type: "uint256" }
1984
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
1985
+ {
1986
+ internalType: "enum ACPTypes.MemoState",
1987
+ name: "state",
1988
+ type: "uint8"
1989
+ }
1938
1990
  ],
1939
1991
  internalType: "struct ACPTypes.Memo[]",
1940
1992
  name: "memos",
@@ -1981,7 +2033,12 @@ var ACP_V2_ABI = [
1981
2033
  name: "nextPhase",
1982
2034
  type: "uint8"
1983
2035
  },
1984
- { internalType: "uint256", name: "expiredAt", type: "uint256" }
2036
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
2037
+ {
2038
+ internalType: "enum ACPTypes.MemoState",
2039
+ name: "state",
2040
+ type: "uint8"
2041
+ }
1985
2042
  ],
1986
2043
  internalType: "struct ACPTypes.Memo[]",
1987
2044
  name: "memos",
@@ -2024,7 +2081,12 @@ var ACP_V2_ABI = [
2024
2081
  name: "nextPhase",
2025
2082
  type: "uint8"
2026
2083
  },
2027
- { internalType: "uint256", name: "expiredAt", type: "uint256" }
2084
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
2085
+ {
2086
+ internalType: "enum ACPTypes.MemoState",
2087
+ name: "state",
2088
+ type: "uint8"
2089
+ }
2028
2090
  ],
2029
2091
  internalType: "struct ACPTypes.Memo[]",
2030
2092
  name: "memos",
@@ -2280,7 +2342,7 @@ var acpAbiV2_default = ACP_V2_ABI;
2280
2342
  var V1_MAX_RETRIES = 10;
2281
2343
  var V2_MAX_RETRIES = 3;
2282
2344
  var AcpContractConfig2 = class {
2283
- constructor(chain, contractAddress, baseFare, alchemyRpcUrl, acpUrl, abi, maxRetries, rpcEndpoint, x402Config) {
2345
+ constructor(chain, contractAddress, baseFare, alchemyRpcUrl, acpUrl, abi, maxRetries, rpcEndpoint, x402Config, chains = []) {
2284
2346
  this.chain = chain;
2285
2347
  this.contractAddress = contractAddress;
2286
2348
  this.baseFare = baseFare;
@@ -2290,6 +2352,7 @@ var AcpContractConfig2 = class {
2290
2352
  this.maxRetries = maxRetries;
2291
2353
  this.rpcEndpoint = rpcEndpoint;
2292
2354
  this.x402Config = x402Config;
2355
+ this.chains = chains;
2293
2356
  }
2294
2357
  };
2295
2358
  var baseSepoliaAcpConfig = new AcpContractConfig2(
@@ -3565,6 +3628,7 @@ var BaseAcpContractClient = class {
3565
3628
  constructor(agentWalletAddress, config = baseAcpConfig) {
3566
3629
  this.agentWalletAddress = agentWalletAddress;
3567
3630
  this.config = config;
3631
+ this.publicClients = {};
3568
3632
  this.chain = config.chain;
3569
3633
  this.abi = config.abi;
3570
3634
  this.contractAddress = config.contractAddress;
@@ -3664,12 +3728,12 @@ ${JSON.stringify(
3664
3728
  throw new acpError_default("Failed to create job", error);
3665
3729
  }
3666
3730
  }
3667
- approveAllowance(amountBaseUnit, paymentTokenAddress = this.config.baseFare.contractAddress) {
3731
+ approveAllowance(amountBaseUnit, paymentTokenAddress = this.config.baseFare.contractAddress, targetAddress) {
3668
3732
  try {
3669
3733
  const data = (0, import_viem2.encodeFunctionData)({
3670
3734
  abi: import_viem2.erc20Abi,
3671
3735
  functionName: "approve",
3672
- args: [this.contractAddress, amountBaseUnit]
3736
+ args: [targetAddress ?? this.contractAddress, amountBaseUnit]
3673
3737
  });
3674
3738
  const payload = {
3675
3739
  data,
@@ -3708,6 +3772,35 @@ ${JSON.stringify(
3708
3772
  throw new acpError_default("Failed to create payable memo", error);
3709
3773
  }
3710
3774
  }
3775
+ createCrossChainPayableMemo(jobId, content, token, amountBaseUnit, recipient, feeAmountBaseUnit, feeType, type, expiredAt, nextPhase, destinationEid, secured = true) {
3776
+ try {
3777
+ const data = (0, import_viem2.encodeFunctionData)({
3778
+ abi: this.abi,
3779
+ functionName: "createCrossChainPayableMemo",
3780
+ args: [
3781
+ jobId,
3782
+ content,
3783
+ token,
3784
+ amountBaseUnit,
3785
+ recipient,
3786
+ feeAmountBaseUnit,
3787
+ feeType,
3788
+ type,
3789
+ expiredAt,
3790
+ secured,
3791
+ nextPhase,
3792
+ destinationEid
3793
+ ]
3794
+ });
3795
+ const payload = {
3796
+ data,
3797
+ contractAddress: this.contractAddress
3798
+ };
3799
+ return payload;
3800
+ } catch (error) {
3801
+ throw new acpError_default("Failed to create cross chain payable memo", error);
3802
+ }
3803
+ }
3711
3804
  createMemo(jobId, content, type, isSecured, nextPhase) {
3712
3805
  try {
3713
3806
  const data = (0, import_viem2.encodeFunctionData)({
@@ -3724,6 +3817,22 @@ ${JSON.stringify(
3724
3817
  throw new acpError_default("Failed to create memo", error);
3725
3818
  }
3726
3819
  }
3820
+ createMemoWithMetadata(jobId, content, type, isSecured, nextPhase, metadata) {
3821
+ try {
3822
+ const data = (0, import_viem2.encodeFunctionData)({
3823
+ abi: this.abi,
3824
+ functionName: "createMemoWithMetadata",
3825
+ args: [jobId, content, type, isSecured, nextPhase, metadata]
3826
+ });
3827
+ const payload = {
3828
+ data,
3829
+ contractAddress: this.contractAddress
3830
+ };
3831
+ return payload;
3832
+ } catch (error) {
3833
+ throw new acpError_default("Failed to create memo with metadata", error);
3834
+ }
3835
+ }
3727
3836
  signMemo(memoId, isApproved, reason) {
3728
3837
  try {
3729
3838
  const data = (0, import_viem2.encodeFunctionData)({
@@ -3809,9 +3918,47 @@ ${JSON.stringify(
3809
3918
  throw new acpError_default("Failed to submit TransferWithAuthorization", error);
3810
3919
  }
3811
3920
  }
3921
+ async getERC20Balance(chainId, tokenAddress, walletAddress) {
3922
+ const publicClient = this.publicClients[chainId];
3923
+ if (!publicClient) {
3924
+ throw new acpError_default(`Public client for chainId ${chainId} not found`);
3925
+ }
3926
+ return await publicClient.readContract({
3927
+ address: tokenAddress,
3928
+ abi: import_viem2.erc20Abi,
3929
+ functionName: "balanceOf",
3930
+ args: [walletAddress]
3931
+ });
3932
+ }
3933
+ async getERC20Allowance(chainId, tokenAddress, walletAddress, spenderAddress) {
3934
+ const publicClient = this.publicClients[chainId];
3935
+ if (!publicClient) {
3936
+ throw new acpError_default(`Public client for chainId ${chainId} not found`);
3937
+ }
3938
+ return await publicClient.readContract({
3939
+ address: tokenAddress,
3940
+ abi: import_viem2.erc20Abi,
3941
+ functionName: "allowance",
3942
+ args: [walletAddress, spenderAddress]
3943
+ });
3944
+ }
3945
+ async getERC20Symbol(chainId, tokenAddress) {
3946
+ const publicClient = this.publicClients[chainId];
3947
+ if (!publicClient) {
3948
+ throw new acpError_default(`Public client for chainId ${chainId} not found`);
3949
+ }
3950
+ return await publicClient.readContract({
3951
+ address: tokenAddress,
3952
+ abi: import_viem2.erc20Abi,
3953
+ functionName: "symbol"
3954
+ });
3955
+ }
3812
3956
  };
3813
3957
  var baseAcpContractClient_default = BaseAcpContractClient;
3814
3958
 
3959
+ // src/acpJob.ts
3960
+ var import_viem5 = require("viem");
3961
+
3815
3962
  // src/interfaces.ts
3816
3963
  var AcpMemoStatus = /* @__PURE__ */ ((AcpMemoStatus2) => {
3817
3964
  AcpMemoStatus2["PENDING"] = "PENDING";
@@ -3819,6 +3966,15 @@ var AcpMemoStatus = /* @__PURE__ */ ((AcpMemoStatus2) => {
3819
3966
  AcpMemoStatus2["REJECTED"] = "REJECTED";
3820
3967
  return AcpMemoStatus2;
3821
3968
  })(AcpMemoStatus || {});
3969
+ var AcpMemoState = /* @__PURE__ */ ((AcpMemoState2) => {
3970
+ AcpMemoState2[AcpMemoState2["NONE"] = 0] = "NONE";
3971
+ AcpMemoState2[AcpMemoState2["PENDING"] = 1] = "PENDING";
3972
+ AcpMemoState2[AcpMemoState2["IN_PROGRESS"] = 2] = "IN_PROGRESS";
3973
+ AcpMemoState2[AcpMemoState2["READY"] = 3] = "READY";
3974
+ AcpMemoState2[AcpMemoState2["COMPLETED"] = 4] = "COMPLETED";
3975
+ AcpMemoState2[AcpMemoState2["REJECTED"] = 5] = "REJECTED";
3976
+ return AcpMemoState2;
3977
+ })(AcpMemoState || {});
3822
3978
  var AcpAgentSort = /* @__PURE__ */ ((AcpAgentSort2) => {
3823
3979
  AcpAgentSort2["SUCCESSFUL_JOB_COUNT"] = "successfulJobCount";
3824
3980
  AcpAgentSort2["SUCCESS_RATE"] = "successRate";
@@ -3857,6 +4013,8 @@ var PositionDirection = /* @__PURE__ */ ((PositionDirection2) => {
3857
4013
  })(PositionDirection || {});
3858
4014
 
3859
4015
  // src/utils.ts
4016
+ var import_viem3 = require("viem");
4017
+ var import_chains2 = require("viem/chains");
3860
4018
  function tryParseJson(content) {
3861
4019
  try {
3862
4020
  return JSON.parse(content);
@@ -3873,9 +4031,34 @@ function safeBase64Encode(data) {
3873
4031
  }
3874
4032
  return Buffer.from(data).toString("base64");
3875
4033
  }
4034
+ function getDestinationEndpointId(chainId) {
4035
+ switch (chainId) {
4036
+ case import_chains2.baseSepolia.id:
4037
+ return 40245;
4038
+ case import_chains2.sepolia.id:
4039
+ return 40161;
4040
+ case import_chains2.polygonAmoy.id:
4041
+ return 40267;
4042
+ case import_chains2.arbitrumSepolia.id:
4043
+ return 40231;
4044
+ case import_chains2.bscTestnet.id:
4045
+ return 40102;
4046
+ case import_chains2.base.id:
4047
+ return 30184;
4048
+ case import_chains2.mainnet.id:
4049
+ return 30101;
4050
+ case import_chains2.polygon.id:
4051
+ return 30109;
4052
+ case import_chains2.arbitrum.id:
4053
+ return 30110;
4054
+ case import_chains2.bsc.id:
4055
+ return 30102;
4056
+ }
4057
+ throw new Error(`Unsupported chain ID: ${chainId}`);
4058
+ }
3876
4059
 
3877
4060
  // src/acpJobOffering.ts
3878
- var import_viem3 = require("viem");
4061
+ var import_viem4 = require("viem");
3879
4062
  var import_ajv = __toESM(require("ajv"));
3880
4063
  var AcpJobOffering = class {
3881
4064
  constructor(acpClient, acpContractClient, providerAddress, name, price, priceType = "fixed" /* FIXED */, requirement) {
@@ -3934,7 +4117,7 @@ var AcpJobOffering = class {
3934
4117
  } else {
3935
4118
  createJobPayload = this.acpContractClient.createJobWithAccount(
3936
4119
  account.id,
3937
- evaluatorAddress || import_viem3.zeroAddress,
4120
+ evaluatorAddress || import_viem4.zeroAddress,
3938
4121
  fareAmount.amount,
3939
4122
  fareAmount.fare.contractAddress,
3940
4123
  expiredAt,
@@ -4075,25 +4258,43 @@ var AcpJob = class {
4075
4258
  }
4076
4259
  const feeAmount = new FareAmount(0, this.acpContractClient.config.baseFare);
4077
4260
  const isPercentagePricing = this.priceType === "percentage" /* PERCENTAGE */;
4078
- operations.push(
4079
- this.acpContractClient.createPayableMemo(
4080
- this.id,
4081
- content,
4082
- amount.amount,
4083
- recipient,
4084
- isPercentagePricing ? BigInt(Math.round(this.priceValue * 1e4)) : feeAmount.amount,
4085
- isPercentagePricing ? 3 /* PERCENTAGE_FEE */ : 0 /* NO_FEE */,
4086
- 2 /* TRANSACTION */,
4087
- type,
4088
- expiredAt,
4089
- amount.fare.contractAddress
4090
- )
4091
- );
4261
+ if (amount.fare.chainId && amount.fare.chainId !== this.acpContractClient.config.chain.id) {
4262
+ operations.push(
4263
+ this.acpContractClient.createCrossChainPayableMemo(
4264
+ this.id,
4265
+ content,
4266
+ amount.fare.contractAddress,
4267
+ amount.amount,
4268
+ recipient,
4269
+ isPercentagePricing ? BigInt(Math.round(this.priceValue * 1e4)) : feeAmount.amount,
4270
+ isPercentagePricing ? 3 /* PERCENTAGE_FEE */ : 0 /* NO_FEE */,
4271
+ type,
4272
+ expiredAt,
4273
+ 2 /* TRANSACTION */,
4274
+ getDestinationEndpointId(amount.fare.chainId)
4275
+ )
4276
+ );
4277
+ } else {
4278
+ operations.push(
4279
+ this.acpContractClient.createPayableMemo(
4280
+ this.id,
4281
+ content,
4282
+ amount.amount,
4283
+ recipient,
4284
+ isPercentagePricing ? BigInt(Math.round(this.priceValue * 1e4)) : feeAmount.amount,
4285
+ isPercentagePricing ? 3 /* PERCENTAGE_FEE */ : 0 /* NO_FEE */,
4286
+ 2 /* TRANSACTION */,
4287
+ type,
4288
+ expiredAt,
4289
+ amount.fare.contractAddress
4290
+ )
4291
+ );
4292
+ }
4092
4293
  return await this.acpContractClient.handleOperation(operations);
4093
4294
  }
4094
4295
  async payAndAcceptRequirement(reason) {
4095
4296
  const memo = this.memos.find(
4096
- (m) => m.nextPhase === 2 /* TRANSACTION */
4297
+ (m) => m.nextPhase === 2 /* TRANSACTION */ || m.nextPhase === 4 /* COMPLETED */
4097
4298
  );
4098
4299
  if (!memo) {
4099
4300
  throw new acpError_default("No notification memo found");
@@ -4221,6 +4422,9 @@ var AcpJob = class {
4221
4422
  if (this.latestMemo?.nextPhase !== 3 /* EVALUATION */) {
4222
4423
  throw new acpError_default("No transaction memo found");
4223
4424
  }
4425
+ if (amount.fare.chainId !== this.acpContractClient.config.chain.id) {
4426
+ return await this.deliverCrossChainPayable(this.clientAddress, amount);
4427
+ }
4224
4428
  const operations = [];
4225
4429
  operations.push(
4226
4430
  this.acpContractClient.approveAllowance(
@@ -4351,6 +4555,57 @@ var AcpJob = class {
4351
4555
  waitMs = Math.min(waitMs * 2, maxWaitMs);
4352
4556
  }
4353
4557
  }
4558
+ async deliverCrossChainPayable(recipient, amount, isRequest = false) {
4559
+ if (!amount.fare.chainId) {
4560
+ throw new acpError_default("Chain ID is required for cross chain payable");
4561
+ }
4562
+ const chainId = amount.fare.chainId;
4563
+ const assetManagerAddress = await this.acpContractClient.getAssetManager();
4564
+ const tokenBalance = await this.acpContractClient.getERC20Balance(
4565
+ chainId,
4566
+ amount.fare.contractAddress,
4567
+ this.acpContractClient.agentWalletAddress
4568
+ );
4569
+ if (tokenBalance < amount.amount) {
4570
+ throw new acpError_default("Insufficient token balance for cross chain payable");
4571
+ }
4572
+ const currentAllowance = await this.acpContractClient.getERC20Allowance(
4573
+ chainId,
4574
+ amount.fare.contractAddress,
4575
+ this.acpContractClient.agentWalletAddress,
4576
+ assetManagerAddress
4577
+ );
4578
+ const approveAllowanceOperation = this.acpContractClient.approveAllowance(
4579
+ amount.amount + currentAllowance,
4580
+ amount.fare.contractAddress,
4581
+ assetManagerAddress
4582
+ );
4583
+ await this.acpContractClient.handleOperation(
4584
+ [approveAllowanceOperation],
4585
+ chainId
4586
+ );
4587
+ const tokenSymbol = await this.acpContractClient.getERC20Symbol(
4588
+ chainId,
4589
+ amount.fare.contractAddress
4590
+ );
4591
+ const createMemoOperation = this.acpContractClient.createCrossChainPayableMemo(
4592
+ this.id,
4593
+ `Performing cross chain payable transfer of ${(0, import_viem5.formatUnits)(
4594
+ amount.amount,
4595
+ amount.fare.decimals
4596
+ )} ${tokenSymbol} to ${recipient}`,
4597
+ amount.fare.contractAddress,
4598
+ amount.amount,
4599
+ recipient,
4600
+ BigInt(0),
4601
+ 0 /* NO_FEE */,
4602
+ isRequest ? 6 /* PAYABLE_REQUEST */ : 7 /* PAYABLE_TRANSFER */,
4603
+ new Date(Date.now() + 1e3 * 60 * 5),
4604
+ isRequest ? 2 /* TRANSACTION */ : 4 /* COMPLETED */,
4605
+ getDestinationEndpointId(chainId)
4606
+ );
4607
+ await this.acpContractClient.handleOperation([createMemoOperation]);
4608
+ }
4354
4609
  [util.inspect.custom]() {
4355
4610
  return {
4356
4611
  id: this.id,
@@ -4374,7 +4629,7 @@ var acpJob_default = AcpJob;
4374
4629
  // src/acpMemo.ts
4375
4630
  var import_util = __toESM(require("util"));
4376
4631
  var AcpMemo = class {
4377
- constructor(contractClient, id, type, content, nextPhase, status, senderAddress, signedReason, expiry, payableDetails, txHash, signedTxHash) {
4632
+ constructor(contractClient, id, type, content, nextPhase, status, senderAddress, signedReason, expiry, payableDetails, txHash, signedTxHash, state) {
4378
4633
  this.contractClient = contractClient;
4379
4634
  this.id = id;
4380
4635
  this.type = type;
@@ -4387,6 +4642,7 @@ var AcpMemo = class {
4387
4642
  this.payableDetails = payableDetails;
4388
4643
  this.txHash = txHash;
4389
4644
  this.signedTxHash = signedTxHash;
4645
+ this.state = state;
4390
4646
  if (this.payableDetails) {
4391
4647
  this.payableDetails.amount = BigInt(this.payableDetails.amount);
4392
4648
  this.payableDetails.feeAmount = BigInt(this.payableDetails.feeAmount);
@@ -4537,7 +4793,8 @@ var AcpClient = class {
4537
4793
  memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
4538
4794
  memo.payableDetails,
4539
4795
  memo.txHash,
4540
- memo.signedTxHash
4796
+ memo.signedTxHash,
4797
+ memo.state
4541
4798
  );
4542
4799
  }),
4543
4800
  data.phase,
@@ -4575,7 +4832,8 @@ var AcpClient = class {
4575
4832
  memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
4576
4833
  memo.payableDetails,
4577
4834
  memo.txHash,
4578
- memo.signedTxHash
4835
+ memo.signedTxHash,
4836
+ memo.state
4579
4837
  );
4580
4838
  }),
4581
4839
  data.phase,
@@ -4600,7 +4858,14 @@ var AcpClient = class {
4600
4858
  process.on("SIGTERM", cleanup);
4601
4859
  }
4602
4860
  async browseAgents(keyword, options) {
4603
- let { cluster, sort_by, top_k, graduationStatus, onlineStatus, showHiddenOfferings } = options;
4861
+ let {
4862
+ cluster,
4863
+ sort_by,
4864
+ top_k,
4865
+ graduationStatus,
4866
+ onlineStatus,
4867
+ showHiddenOfferings
4868
+ } = options;
4604
4869
  top_k = top_k ?? 5;
4605
4870
  let url = `${this.acpUrl}/api/agents/v4/search?search=${keyword}`;
4606
4871
  if (sort_by && sort_by.length > 0) {
@@ -4682,7 +4947,7 @@ var AcpClient = class {
4682
4947
  baseAcpConfig.contractAddress,
4683
4948
  baseAcpX402Config.contractAddress
4684
4949
  ].includes(this.acpContractClient.config.contractAddress);
4685
- const defaultEvaluatorAddress = isV1 && !evaluatorAddress ? this.walletAddress : import_viem4.zeroAddress;
4950
+ const defaultEvaluatorAddress = isV1 && !evaluatorAddress ? this.walletAddress : import_viem6.zeroAddress;
4686
4951
  const chainId = this.acpContractClient.config.chain.id;
4687
4952
  const isUsdcPaymentToken = USDC_TOKEN_ADDRESS[chainId].toLowerCase() === fareAmount.fare.contractAddress.toLowerCase();
4688
4953
  const isX402Job = this.acpContractClient.config.x402Config && isUsdcPaymentToken;
@@ -4791,7 +5056,8 @@ var AcpClient = class {
4791
5056
  memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
4792
5057
  memo.payableDetails,
4793
5058
  memo.txHash,
4794
- memo.signedTxHash
5059
+ memo.signedTxHash,
5060
+ memo.state
4795
5061
  )
4796
5062
  );
4797
5063
  jobs.push(
@@ -4865,7 +5131,8 @@ var AcpClient = class {
4865
5131
  memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
4866
5132
  memo.payableDetails,
4867
5133
  memo.txHash,
4868
- memo.signedTxHash
5134
+ memo.signedTxHash,
5135
+ memo.state
4869
5136
  )
4870
5137
  );
4871
5138
  return new acpJob_default(
@@ -4924,7 +5191,8 @@ var AcpClient = class {
4924
5191
  memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
4925
5192
  memo.payableDetails,
4926
5193
  memo.txHash,
4927
- memo.signedTxHash
5194
+ memo.signedTxHash,
5195
+ memo.state
4928
5196
  );
4929
5197
  } catch (err) {
4930
5198
  throw new acpError_default(
@@ -4988,10 +5256,10 @@ var acpClient_default = AcpClient;
4988
5256
  var import_core = require("@aa-sdk/core");
4989
5257
  var import_infra2 = require("@account-kit/infra");
4990
5258
  var import_smart_contracts = require("@account-kit/smart-contracts");
4991
- var import_viem6 = require("viem");
5259
+ var import_viem8 = require("viem");
4992
5260
 
4993
5261
  // src/acpX402.ts
4994
- var import_viem5 = require("viem");
5262
+ var import_viem7 = require("viem");
4995
5263
  var import_crypto = require("crypto");
4996
5264
  var AcpX402 = class {
4997
5265
  constructor(config, sessionKeyClient, publicClient) {
@@ -5033,6 +5301,9 @@ var AcpX402 = class {
5033
5301
  const acpJob = await response.json();
5034
5302
  return acpJob;
5035
5303
  } catch (error) {
5304
+ if (error instanceof acpError_default) {
5305
+ throw error;
5306
+ }
5036
5307
  throw new acpError_default("Failed to update job X402 nonce", error);
5037
5308
  }
5038
5309
  }
@@ -5046,7 +5317,7 @@ var AcpX402 = class {
5046
5317
  contracts: [
5047
5318
  {
5048
5319
  address: USDC_CONTRACT,
5049
- abi: import_viem5.erc20Abi,
5320
+ abi: import_viem7.erc20Abi,
5050
5321
  functionName: "name"
5051
5322
  },
5052
5323
  {
@@ -5121,6 +5392,9 @@ var AcpX402 = class {
5121
5392
  data
5122
5393
  };
5123
5394
  } catch (error) {
5395
+ if (error instanceof acpError_default) {
5396
+ throw error;
5397
+ }
5124
5398
  throw new acpError_default("Failed to perform X402 request", error);
5125
5399
  }
5126
5400
  }
@@ -5135,10 +5409,7 @@ var AcpContractClient = class _AcpContractClient extends baseAcpContractClient_d
5135
5409
  this.MAX_PRIORITY_FEE_PER_GAS = 21e6;
5136
5410
  }
5137
5411
  static async build(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfig) {
5138
- const acpContractClient = new _AcpContractClient(
5139
- agentWalletAddress,
5140
- config
5141
- );
5412
+ const acpContractClient = new _AcpContractClient(agentWalletAddress, config);
5142
5413
  await acpContractClient.init(walletPrivateKey, sessionEntityKeyId);
5143
5414
  return acpContractClient;
5144
5415
  }
@@ -5169,7 +5440,10 @@ var AcpContractClient = class _AcpContractClient extends baseAcpContractClient_d
5169
5440
  `ACP Contract Client validation failed: agent account ${this.agentWalletAddress} is not deployed on-chain`
5170
5441
  );
5171
5442
  }
5172
- await this.validateSessionKeyOnChain(sessionSignerAddress, sessionEntityKeyId);
5443
+ await this.validateSessionKeyOnChain(
5444
+ sessionSignerAddress,
5445
+ sessionEntityKeyId
5446
+ );
5173
5447
  console.log("Connected to ACP with v1 Contract Client (Legacy):", {
5174
5448
  agentWalletAddress: this.agentWalletAddress,
5175
5449
  whitelistedWalletAddress: sessionSignerAddress,
@@ -5239,14 +5513,16 @@ var AcpContractClient = class _AcpContractClient extends baseAcpContractClient_d
5239
5513
  throw new acpError_default(`Failed to send user operation`, finalError);
5240
5514
  }
5241
5515
  async getJobId(createJobUserOpHash, clientAddress, providerAddress) {
5242
- const result = await this.sessionKeyClient.getUserOperationReceipt(createJobUserOpHash);
5516
+ const result = await this.sessionKeyClient.getUserOperationReceipt(
5517
+ createJobUserOpHash
5518
+ );
5243
5519
  if (!result) {
5244
5520
  throw new acpError_default("Failed to get user operation receipt");
5245
5521
  }
5246
5522
  const contractLogs = result.logs.filter((log) => {
5247
5523
  return log.address.toLowerCase() === this.contractAddress.toLowerCase();
5248
5524
  }).map(
5249
- (log) => (0, import_viem6.decodeEventLog)({
5525
+ (log) => (0, import_viem8.decodeEventLog)({
5250
5526
  abi: this.abi,
5251
5527
  data: log.data,
5252
5528
  topics: log.topics
@@ -5262,7 +5538,7 @@ var AcpContractClient = class _AcpContractClient extends baseAcpContractClient_d
5262
5538
  }
5263
5539
  createJob(providerAddress, evaluatorAddress, expireAt, paymentTokenAddress, budgetBaseUnit, metadata, isX402Job) {
5264
5540
  try {
5265
- const data = (0, import_viem6.encodeFunctionData)({
5541
+ const data = (0, import_viem8.encodeFunctionData)({
5266
5542
  abi: this.abi,
5267
5543
  functionName: isX402Job ? "createJobWithX402" : "createJob",
5268
5544
  args: [
@@ -5282,7 +5558,7 @@ var AcpContractClient = class _AcpContractClient extends baseAcpContractClient_d
5282
5558
  }
5283
5559
  setBudgetWithPaymentToken(jobId, budgetBaseUnit, paymentTokenAddress = this.config.baseFare.contractAddress) {
5284
5560
  try {
5285
- const data = (0, import_viem6.encodeFunctionData)({
5561
+ const data = (0, import_viem8.encodeFunctionData)({
5286
5562
  abi: this.abi,
5287
5563
  functionName: "setBudgetWithPaymentToken",
5288
5564
  args: [jobId, budgetBaseUnit, paymentTokenAddress]
@@ -5298,7 +5574,7 @@ var AcpContractClient = class _AcpContractClient extends baseAcpContractClient_d
5298
5574
  }
5299
5575
  createPayableMemo(jobId, content, amountBaseUnit, recipient, feeAmountBaseUnit, feeType, nextPhase, type, expiredAt, token = this.config.baseFare.contractAddress, secured = true) {
5300
5576
  try {
5301
- const data = (0, import_viem6.encodeFunctionData)({
5577
+ const data = (0, import_viem8.encodeFunctionData)({
5302
5578
  abi: this.abi,
5303
5579
  functionName: "createPayableMemo",
5304
5580
  args: [
@@ -5338,6 +5614,9 @@ var AcpContractClient = class _AcpContractClient extends baseAcpContractClient_d
5338
5614
  async performX402Request(url, version2, budget, signature) {
5339
5615
  return await this.acpX402.performRequest(url, version2, budget, signature);
5340
5616
  }
5617
+ async getAssetManager() {
5618
+ throw new Error("Asset Manager not supported");
5619
+ }
5341
5620
  getAcpVersion() {
5342
5621
  return "1";
5343
5622
  }
@@ -5348,7 +5627,7 @@ var acpContractClient_default = AcpContractClient;
5348
5627
  var import_core2 = require("@aa-sdk/core");
5349
5628
  var import_infra3 = require("@account-kit/infra");
5350
5629
  var import_smart_contracts2 = require("@account-kit/smart-contracts");
5351
- var import_viem7 = require("viem");
5630
+ var import_viem9 = require("viem");
5352
5631
 
5353
5632
  // src/abis/jobManagerAbi.ts
5354
5633
  var JOB_MANAGER_ABI = [
@@ -6052,72 +6331,1231 @@ var JOB_MANAGER_ABI = [
6052
6331
  var jobManagerAbi_default = JOB_MANAGER_ABI;
6053
6332
 
6054
6333
  // src/contractClients/acpContractClientV2.ts
6055
- var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClient_default {
6056
- constructor(jobManagerAddress, memoManagerAddress, accountManagerAddress, agentWalletAddress, config = baseAcpConfigV2) {
6057
- super(agentWalletAddress, config);
6058
- this.jobManagerAddress = jobManagerAddress;
6059
- this.memoManagerAddress = memoManagerAddress;
6060
- this.accountManagerAddress = accountManagerAddress;
6061
- this.PRIORITY_FEE_MULTIPLIER = 2;
6062
- this.MAX_FEE_PER_GAS = 2e7;
6063
- this.MAX_PRIORITY_FEE_PER_GAS = 21e6;
6064
- }
6065
- static async build(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfigV2) {
6066
- const publicClient = (0, import_viem7.createPublicClient)({
6067
- chain: config.chain,
6068
- transport: (0, import_viem7.http)(config.rpcEndpoint)
6069
- });
6070
- const [jobManagerAddress, memoManagerAddress, accountManagerAddress] = await publicClient.multicall({
6071
- contracts: [
6072
- {
6073
- address: config.contractAddress,
6074
- abi: config.abi,
6075
- functionName: "jobManager"
6076
- },
6077
- {
6078
- address: config.contractAddress,
6079
- abi: config.abi,
6080
- functionName: "memoManager"
6081
- },
6082
- {
6083
- address: config.contractAddress,
6084
- abi: config.abi,
6085
- functionName: "accountManager"
6086
- }
6087
- ]
6088
- });
6089
- if (!jobManagerAddress || !memoManagerAddress || !accountManagerAddress) {
6090
- throw new acpError_default(
6091
- "Failed to get job manager, memo manager, or account manager address"
6092
- );
6093
- }
6094
- const acpContractClient = new _AcpContractClientV2(
6095
- jobManagerAddress.result,
6096
- memoManagerAddress.result,
6097
- accountManagerAddress.result,
6098
- agentWalletAddress,
6099
- config
6100
- );
6101
- await acpContractClient.init(walletPrivateKey, sessionEntityKeyId);
6102
- return acpContractClient;
6103
- }
6104
- async init(privateKey, sessionEntityKeyId) {
6105
- const sessionKeySigner = import_core2.LocalAccountSigner.privateKeyToAccountSigner(privateKey);
6106
- this._sessionKeyClient = await (0, import_smart_contracts2.createModularAccountV2Client)({
6107
- chain: this.chain,
6108
- transport: (0, import_infra3.alchemy)({
6109
- rpcUrl: this.config.alchemyRpcUrl
6110
- }),
6111
- signer: sessionKeySigner,
6112
- policyId: "186aaa4a-5f57-4156-83fb-e456365a8820",
6113
- accountAddress: this.agentWalletAddress,
6114
- signerEntity: {
6115
- entityId: sessionEntityKeyId,
6116
- isGlobalValidation: true
6334
+ var import_chains3 = require("viem/chains");
6335
+
6336
+ // src/abis/memoManagerAbi.ts
6337
+ var MEMO_MANAGER_ABI = [
6338
+ { inputs: [], stateMutability: "nonpayable", type: "constructor" },
6339
+ { inputs: [], name: "AccessControlBadConfirmation", type: "error" },
6340
+ {
6341
+ inputs: [
6342
+ { internalType: "address", name: "account", type: "address" },
6343
+ { internalType: "bytes32", name: "neededRole", type: "bytes32" }
6344
+ ],
6345
+ name: "AccessControlUnauthorizedAccount",
6346
+ type: "error"
6347
+ },
6348
+ {
6349
+ inputs: [{ internalType: "address", name: "target", type: "address" }],
6350
+ name: "AddressEmptyCode",
6351
+ type: "error"
6352
+ },
6353
+ { inputs: [], name: "AlreadyVoted", type: "error" },
6354
+ { inputs: [], name: "CannotApproveMemo", type: "error" },
6355
+ { inputs: [], name: "CannotUpdateApprovedMemo", type: "error" },
6356
+ { inputs: [], name: "CannotUpdateMemo", type: "error" },
6357
+ { inputs: [], name: "CannotWithdrawYet", type: "error" },
6358
+ { inputs: [], name: "DestinationChainNotConfigured", type: "error" },
6359
+ {
6360
+ inputs: [
6361
+ { internalType: "address", name: "implementation", type: "address" }
6362
+ ],
6363
+ name: "ERC1967InvalidImplementation",
6364
+ type: "error"
6365
+ },
6366
+ { inputs: [], name: "ERC1967NonPayable", type: "error" },
6367
+ { inputs: [], name: "EmptyContent", type: "error" },
6368
+ { inputs: [], name: "FailedInnerCall", type: "error" },
6369
+ { inputs: [], name: "InvalidInitialization", type: "error" },
6370
+ { inputs: [], name: "InvalidMemoState", type: "error" },
6371
+ { inputs: [], name: "InvalidMemoStateTransition", type: "error" },
6372
+ { inputs: [], name: "InvalidMemoType", type: "error" },
6373
+ { inputs: [], name: "JobAlreadyCompleted", type: "error" },
6374
+ { inputs: [], name: "JobDoesNotExist", type: "error" },
6375
+ { inputs: [], name: "MemoAlreadyApproved", type: "error" },
6376
+ { inputs: [], name: "MemoAlreadyExecuted", type: "error" },
6377
+ { inputs: [], name: "MemoAlreadySigned", type: "error" },
6378
+ { inputs: [], name: "MemoCannotBeSigned", type: "error" },
6379
+ { inputs: [], name: "MemoDoesNotExist", type: "error" },
6380
+ { inputs: [], name: "MemoDoesNotRequireApproval", type: "error" },
6381
+ { inputs: [], name: "MemoExpired", type: "error" },
6382
+ { inputs: [], name: "MemoNotApproved", type: "error" },
6383
+ { inputs: [], name: "MemoNotReadyToBeSigned", type: "error" },
6384
+ { inputs: [], name: "MemoStateUnchanged", type: "error" },
6385
+ { inputs: [], name: "NoAmountToTransfer", type: "error" },
6386
+ { inputs: [], name: "NoPaymentAmount", type: "error" },
6387
+ { inputs: [], name: "NotEscrowTransferMemoType", type: "error" },
6388
+ { inputs: [], name: "NotInitializing", type: "error" },
6389
+ { inputs: [], name: "NotPayableMemoType", type: "error" },
6390
+ { inputs: [], name: "OnlyACPContract", type: "error" },
6391
+ { inputs: [], name: "OnlyAssetManager", type: "error" },
6392
+ { inputs: [], name: "OnlyClientOrProvider", type: "error" },
6393
+ { inputs: [], name: "OnlyCounterParty", type: "error" },
6394
+ { inputs: [], name: "OnlyEvaluator", type: "error" },
6395
+ { inputs: [], name: "OnlyMemoSender", type: "error" },
6396
+ { inputs: [], name: "ReentrancyGuardReentrantCall", type: "error" },
6397
+ { inputs: [], name: "UUPSUnauthorizedCallContext", type: "error" },
6398
+ {
6399
+ inputs: [{ internalType: "bytes32", name: "slot", type: "bytes32" }],
6400
+ name: "UUPSUnsupportedProxiableUUID",
6401
+ type: "error"
6402
+ },
6403
+ { inputs: [], name: "ZeroAcpContractAddress", type: "error" },
6404
+ { inputs: [], name: "ZeroAddressRecipient", type: "error" },
6405
+ { inputs: [], name: "ZeroAddressToken", type: "error" },
6406
+ { inputs: [], name: "ZeroAssetManagerAddress", type: "error" },
6407
+ { inputs: [], name: "ZeroJobManagerAddress", type: "error" },
6408
+ {
6409
+ anonymous: false,
6410
+ inputs: [
6411
+ {
6412
+ indexed: false,
6413
+ internalType: "uint64",
6414
+ name: "version",
6415
+ type: "uint64"
6117
6416
  }
6118
- });
6119
- this._acpX402 = new AcpX402(
6120
- this.config,
6417
+ ],
6418
+ name: "Initialized",
6419
+ type: "event"
6420
+ },
6421
+ {
6422
+ anonymous: false,
6423
+ inputs: [
6424
+ {
6425
+ indexed: true,
6426
+ internalType: "uint256",
6427
+ name: "memoId",
6428
+ type: "uint256"
6429
+ },
6430
+ {
6431
+ indexed: true,
6432
+ internalType: "address",
6433
+ name: "approver",
6434
+ type: "address"
6435
+ },
6436
+ { indexed: false, internalType: "bool", name: "approved", type: "bool" },
6437
+ {
6438
+ indexed: false,
6439
+ internalType: "string",
6440
+ name: "reason",
6441
+ type: "string"
6442
+ }
6443
+ ],
6444
+ name: "MemoSigned",
6445
+ type: "event"
6446
+ },
6447
+ {
6448
+ anonymous: false,
6449
+ inputs: [
6450
+ {
6451
+ indexed: true,
6452
+ internalType: "uint256",
6453
+ name: "memoId",
6454
+ type: "uint256"
6455
+ },
6456
+ {
6457
+ indexed: false,
6458
+ internalType: "enum ACPTypes.MemoState",
6459
+ name: "oldState",
6460
+ type: "uint8"
6461
+ },
6462
+ {
6463
+ indexed: false,
6464
+ internalType: "enum ACPTypes.MemoState",
6465
+ name: "newState",
6466
+ type: "uint8"
6467
+ }
6468
+ ],
6469
+ name: "MemoStateUpdated",
6470
+ type: "event"
6471
+ },
6472
+ {
6473
+ anonymous: false,
6474
+ inputs: [
6475
+ {
6476
+ indexed: true,
6477
+ internalType: "uint256",
6478
+ name: "memoId",
6479
+ type: "uint256"
6480
+ },
6481
+ {
6482
+ indexed: true,
6483
+ internalType: "uint256",
6484
+ name: "jobId",
6485
+ type: "uint256"
6486
+ },
6487
+ {
6488
+ indexed: true,
6489
+ internalType: "address",
6490
+ name: "sender",
6491
+ type: "address"
6492
+ },
6493
+ {
6494
+ indexed: false,
6495
+ internalType: "enum ACPTypes.MemoType",
6496
+ name: "memoType",
6497
+ type: "uint8"
6498
+ },
6499
+ {
6500
+ indexed: false,
6501
+ internalType: "enum ACPTypes.JobPhase",
6502
+ name: "nextPhase",
6503
+ type: "uint8"
6504
+ },
6505
+ {
6506
+ indexed: false,
6507
+ internalType: "string",
6508
+ name: "content",
6509
+ type: "string"
6510
+ }
6511
+ ],
6512
+ name: "NewMemo",
6513
+ type: "event"
6514
+ },
6515
+ {
6516
+ anonymous: false,
6517
+ inputs: [
6518
+ {
6519
+ indexed: true,
6520
+ internalType: "uint256",
6521
+ name: "jobId",
6522
+ type: "uint256"
6523
+ },
6524
+ {
6525
+ indexed: true,
6526
+ internalType: "uint256",
6527
+ name: "memoId",
6528
+ type: "uint256"
6529
+ },
6530
+ {
6531
+ indexed: true,
6532
+ internalType: "address",
6533
+ name: "sender",
6534
+ type: "address"
6535
+ },
6536
+ {
6537
+ indexed: false,
6538
+ internalType: "address",
6539
+ name: "token",
6540
+ type: "address"
6541
+ },
6542
+ {
6543
+ indexed: false,
6544
+ internalType: "uint256",
6545
+ name: "amount",
6546
+ type: "uint256"
6547
+ }
6548
+ ],
6549
+ name: "PayableFeeRefunded",
6550
+ type: "event"
6551
+ },
6552
+ {
6553
+ anonymous: false,
6554
+ inputs: [
6555
+ {
6556
+ indexed: true,
6557
+ internalType: "uint256",
6558
+ name: "jobId",
6559
+ type: "uint256"
6560
+ },
6561
+ {
6562
+ indexed: true,
6563
+ internalType: "uint256",
6564
+ name: "memoId",
6565
+ type: "uint256"
6566
+ },
6567
+ {
6568
+ indexed: true,
6569
+ internalType: "address",
6570
+ name: "sender",
6571
+ type: "address"
6572
+ },
6573
+ {
6574
+ indexed: false,
6575
+ internalType: "address",
6576
+ name: "token",
6577
+ type: "address"
6578
+ },
6579
+ {
6580
+ indexed: false,
6581
+ internalType: "uint256",
6582
+ name: "amount",
6583
+ type: "uint256"
6584
+ }
6585
+ ],
6586
+ name: "PayableFundsRefunded",
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: "executor",
6608
+ type: "address"
6609
+ },
6610
+ {
6611
+ indexed: false,
6612
+ internalType: "uint256",
6613
+ name: "amount",
6614
+ type: "uint256"
6615
+ }
6616
+ ],
6617
+ name: "PayableMemoExecuted",
6618
+ type: "event"
6619
+ },
6620
+ {
6621
+ anonymous: false,
6622
+ inputs: [
6623
+ { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
6624
+ {
6625
+ indexed: true,
6626
+ internalType: "bytes32",
6627
+ name: "previousAdminRole",
6628
+ type: "bytes32"
6629
+ },
6630
+ {
6631
+ indexed: true,
6632
+ internalType: "bytes32",
6633
+ name: "newAdminRole",
6634
+ type: "bytes32"
6635
+ }
6636
+ ],
6637
+ name: "RoleAdminChanged",
6638
+ type: "event"
6639
+ },
6640
+ {
6641
+ anonymous: false,
6642
+ inputs: [
6643
+ { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
6644
+ {
6645
+ indexed: true,
6646
+ internalType: "address",
6647
+ name: "account",
6648
+ type: "address"
6649
+ },
6650
+ {
6651
+ indexed: true,
6652
+ internalType: "address",
6653
+ name: "sender",
6654
+ type: "address"
6655
+ }
6656
+ ],
6657
+ name: "RoleGranted",
6658
+ type: "event"
6659
+ },
6660
+ {
6661
+ anonymous: false,
6662
+ inputs: [
6663
+ { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
6664
+ {
6665
+ indexed: true,
6666
+ internalType: "address",
6667
+ name: "account",
6668
+ type: "address"
6669
+ },
6670
+ {
6671
+ indexed: true,
6672
+ internalType: "address",
6673
+ name: "sender",
6674
+ type: "address"
6675
+ }
6676
+ ],
6677
+ name: "RoleRevoked",
6678
+ type: "event"
6679
+ },
6680
+ {
6681
+ anonymous: false,
6682
+ inputs: [
6683
+ {
6684
+ indexed: true,
6685
+ internalType: "address",
6686
+ name: "implementation",
6687
+ type: "address"
6688
+ }
6689
+ ],
6690
+ name: "Upgraded",
6691
+ type: "event"
6692
+ },
6693
+ {
6694
+ inputs: [],
6695
+ name: "ACP_CONTRACT_ROLE",
6696
+ outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
6697
+ stateMutability: "view",
6698
+ type: "function"
6699
+ },
6700
+ {
6701
+ inputs: [],
6702
+ name: "ADMIN_ROLE",
6703
+ outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
6704
+ stateMutability: "view",
6705
+ type: "function"
6706
+ },
6707
+ {
6708
+ inputs: [],
6709
+ name: "DEFAULT_ADMIN_ROLE",
6710
+ outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
6711
+ stateMutability: "view",
6712
+ type: "function"
6713
+ },
6714
+ {
6715
+ inputs: [],
6716
+ name: "UPGRADE_INTERFACE_VERSION",
6717
+ outputs: [{ internalType: "string", name: "", type: "string" }],
6718
+ stateMutability: "view",
6719
+ type: "function"
6720
+ },
6721
+ {
6722
+ inputs: [],
6723
+ name: "acpContract",
6724
+ outputs: [{ internalType: "address", name: "", type: "address" }],
6725
+ stateMutability: "view",
6726
+ type: "function"
6727
+ },
6728
+ {
6729
+ inputs: [
6730
+ { internalType: "uint256", name: "memoId", type: "uint256" },
6731
+ { internalType: "address", name: "sender", type: "address" },
6732
+ { internalType: "bool", name: "approved", type: "bool" },
6733
+ { internalType: "string", name: "reason", type: "string" }
6734
+ ],
6735
+ name: "approveMemo",
6736
+ outputs: [],
6737
+ stateMutability: "nonpayable",
6738
+ type: "function"
6739
+ },
6740
+ {
6741
+ inputs: [],
6742
+ name: "assetManager",
6743
+ outputs: [{ internalType: "address", name: "", type: "address" }],
6744
+ stateMutability: "view",
6745
+ type: "function"
6746
+ },
6747
+ {
6748
+ inputs: [
6749
+ { internalType: "uint256[]", name: "memoIds", type: "uint256[]" },
6750
+ { internalType: "bool", name: "approved", type: "bool" },
6751
+ { internalType: "string", name: "reason", type: "string" }
6752
+ ],
6753
+ name: "bulkApproveMemos",
6754
+ outputs: [],
6755
+ stateMutability: "nonpayable",
6756
+ type: "function"
6757
+ },
6758
+ {
6759
+ inputs: [
6760
+ { internalType: "uint256", name: "memoId", type: "uint256" },
6761
+ { internalType: "address", name: "user", type: "address" }
6762
+ ],
6763
+ name: "canApproveMemo",
6764
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
6765
+ stateMutability: "view",
6766
+ type: "function"
6767
+ },
6768
+ {
6769
+ inputs: [
6770
+ { internalType: "uint256", name: "jobId", type: "uint256" },
6771
+ { internalType: "address", name: "sender", type: "address" },
6772
+ { internalType: "string", name: "content", type: "string" },
6773
+ {
6774
+ internalType: "enum ACPTypes.MemoType",
6775
+ name: "memoType",
6776
+ type: "uint8"
6777
+ },
6778
+ { internalType: "bool", name: "isSecured", type: "bool" },
6779
+ {
6780
+ internalType: "enum ACPTypes.JobPhase",
6781
+ name: "nextPhase",
6782
+ type: "uint8"
6783
+ },
6784
+ { internalType: "string", name: "metadata", type: "string" }
6785
+ ],
6786
+ name: "createMemo",
6787
+ outputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
6788
+ stateMutability: "nonpayable",
6789
+ type: "function"
6790
+ },
6791
+ {
6792
+ inputs: [
6793
+ { internalType: "uint256", name: "jobId", type: "uint256" },
6794
+ { internalType: "address", name: "sender", type: "address" },
6795
+ { internalType: "string", name: "content", type: "string" },
6796
+ {
6797
+ internalType: "enum ACPTypes.MemoType",
6798
+ name: "memoType",
6799
+ type: "uint8"
6800
+ },
6801
+ { internalType: "bool", name: "isSecured", type: "bool" },
6802
+ {
6803
+ internalType: "enum ACPTypes.JobPhase",
6804
+ name: "nextPhase",
6805
+ type: "uint8"
6806
+ },
6807
+ {
6808
+ components: [
6809
+ { internalType: "address", name: "token", type: "address" },
6810
+ { internalType: "uint256", name: "amount", type: "uint256" },
6811
+ { internalType: "address", name: "recipient", type: "address" },
6812
+ { internalType: "uint256", name: "feeAmount", type: "uint256" },
6813
+ {
6814
+ internalType: "enum ACPTypes.FeeType",
6815
+ name: "feeType",
6816
+ type: "uint8"
6817
+ },
6818
+ { internalType: "bool", name: "isExecuted", type: "bool" },
6819
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
6820
+ { internalType: "uint32", name: "lzSrcEid", type: "uint32" },
6821
+ { internalType: "uint32", name: "lzDstEid", type: "uint32" }
6822
+ ],
6823
+ internalType: "struct ACPTypes.PayableDetails",
6824
+ name: "payableDetails_",
6825
+ type: "tuple"
6826
+ },
6827
+ { internalType: "uint256", name: "expiredAt", type: "uint256" }
6828
+ ],
6829
+ name: "createPayableMemo",
6830
+ outputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
6831
+ stateMutability: "nonpayable",
6832
+ type: "function"
6833
+ },
6834
+ {
6835
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
6836
+ name: "emergencyApproveMemo",
6837
+ outputs: [],
6838
+ stateMutability: "nonpayable",
6839
+ type: "function"
6840
+ },
6841
+ {
6842
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
6843
+ name: "executePayableMemo",
6844
+ outputs: [],
6845
+ stateMutability: "nonpayable",
6846
+ type: "function"
6847
+ },
6848
+ {
6849
+ inputs: [],
6850
+ name: "getAssetManager",
6851
+ outputs: [{ internalType: "address", name: "", type: "address" }],
6852
+ stateMutability: "view",
6853
+ type: "function"
6854
+ },
6855
+ {
6856
+ inputs: [
6857
+ { internalType: "uint256", name: "jobId", type: "uint256" },
6858
+ { internalType: "uint256", name: "offset", type: "uint256" },
6859
+ { internalType: "uint256", name: "limit", type: "uint256" }
6860
+ ],
6861
+ name: "getJobMemos",
6862
+ outputs: [
6863
+ {
6864
+ components: [
6865
+ { internalType: "uint256", name: "id", type: "uint256" },
6866
+ { internalType: "uint256", name: "jobId", type: "uint256" },
6867
+ { internalType: "address", name: "sender", type: "address" },
6868
+ { internalType: "string", name: "content", type: "string" },
6869
+ {
6870
+ internalType: "enum ACPTypes.MemoType",
6871
+ name: "memoType",
6872
+ type: "uint8"
6873
+ },
6874
+ { internalType: "uint256", name: "createdAt", type: "uint256" },
6875
+ { internalType: "bool", name: "isApproved", type: "bool" },
6876
+ { internalType: "address", name: "approvedBy", type: "address" },
6877
+ { internalType: "uint256", name: "approvedAt", type: "uint256" },
6878
+ { internalType: "bool", name: "requiresApproval", type: "bool" },
6879
+ { internalType: "string", name: "metadata", type: "string" },
6880
+ { internalType: "bool", name: "isSecured", type: "bool" },
6881
+ {
6882
+ internalType: "enum ACPTypes.JobPhase",
6883
+ name: "nextPhase",
6884
+ type: "uint8"
6885
+ },
6886
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
6887
+ {
6888
+ internalType: "enum ACPTypes.MemoState",
6889
+ name: "state",
6890
+ type: "uint8"
6891
+ }
6892
+ ],
6893
+ internalType: "struct ACPTypes.Memo[]",
6894
+ name: "memoArray",
6895
+ type: "tuple[]"
6896
+ },
6897
+ { internalType: "uint256", name: "total", type: "uint256" }
6898
+ ],
6899
+ stateMutability: "view",
6900
+ type: "function"
6901
+ },
6902
+ {
6903
+ inputs: [
6904
+ { internalType: "uint256", name: "jobId", type: "uint256" },
6905
+ { internalType: "enum ACPTypes.JobPhase", name: "phase", type: "uint8" },
6906
+ { internalType: "uint256", name: "offset", type: "uint256" },
6907
+ { internalType: "uint256", name: "limit", type: "uint256" }
6908
+ ],
6909
+ name: "getJobMemosByPhase",
6910
+ outputs: [
6911
+ {
6912
+ components: [
6913
+ { internalType: "uint256", name: "id", type: "uint256" },
6914
+ { internalType: "uint256", name: "jobId", type: "uint256" },
6915
+ { internalType: "address", name: "sender", type: "address" },
6916
+ { internalType: "string", name: "content", type: "string" },
6917
+ {
6918
+ internalType: "enum ACPTypes.MemoType",
6919
+ name: "memoType",
6920
+ type: "uint8"
6921
+ },
6922
+ { internalType: "uint256", name: "createdAt", type: "uint256" },
6923
+ { internalType: "bool", name: "isApproved", type: "bool" },
6924
+ { internalType: "address", name: "approvedBy", type: "address" },
6925
+ { internalType: "uint256", name: "approvedAt", type: "uint256" },
6926
+ { internalType: "bool", name: "requiresApproval", type: "bool" },
6927
+ { internalType: "string", name: "metadata", type: "string" },
6928
+ { internalType: "bool", name: "isSecured", type: "bool" },
6929
+ {
6930
+ internalType: "enum ACPTypes.JobPhase",
6931
+ name: "nextPhase",
6932
+ type: "uint8"
6933
+ },
6934
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
6935
+ {
6936
+ internalType: "enum ACPTypes.MemoState",
6937
+ name: "state",
6938
+ type: "uint8"
6939
+ }
6940
+ ],
6941
+ internalType: "struct ACPTypes.Memo[]",
6942
+ name: "memoArray",
6943
+ type: "tuple[]"
6944
+ },
6945
+ { internalType: "uint256", name: "total", type: "uint256" }
6946
+ ],
6947
+ stateMutability: "view",
6948
+ type: "function"
6949
+ },
6950
+ {
6951
+ inputs: [
6952
+ { internalType: "uint256", name: "jobId", type: "uint256" },
6953
+ {
6954
+ internalType: "enum ACPTypes.MemoType",
6955
+ name: "memoType",
6956
+ type: "uint8"
6957
+ },
6958
+ { internalType: "uint256", name: "offset", type: "uint256" },
6959
+ { internalType: "uint256", name: "limit", type: "uint256" }
6960
+ ],
6961
+ name: "getJobMemosByType",
6962
+ outputs: [
6963
+ {
6964
+ components: [
6965
+ { internalType: "uint256", name: "id", type: "uint256" },
6966
+ { internalType: "uint256", name: "jobId", type: "uint256" },
6967
+ { internalType: "address", name: "sender", type: "address" },
6968
+ { internalType: "string", name: "content", type: "string" },
6969
+ {
6970
+ internalType: "enum ACPTypes.MemoType",
6971
+ name: "memoType",
6972
+ type: "uint8"
6973
+ },
6974
+ { internalType: "uint256", name: "createdAt", type: "uint256" },
6975
+ { internalType: "bool", name: "isApproved", type: "bool" },
6976
+ { internalType: "address", name: "approvedBy", type: "address" },
6977
+ { internalType: "uint256", name: "approvedAt", type: "uint256" },
6978
+ { internalType: "bool", name: "requiresApproval", type: "bool" },
6979
+ { internalType: "string", name: "metadata", type: "string" },
6980
+ { internalType: "bool", name: "isSecured", type: "bool" },
6981
+ {
6982
+ internalType: "enum ACPTypes.JobPhase",
6983
+ name: "nextPhase",
6984
+ type: "uint8"
6985
+ },
6986
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
6987
+ {
6988
+ internalType: "enum ACPTypes.MemoState",
6989
+ name: "state",
6990
+ type: "uint8"
6991
+ }
6992
+ ],
6993
+ internalType: "struct ACPTypes.Memo[]",
6994
+ name: "memoArray",
6995
+ type: "tuple[]"
6996
+ },
6997
+ { internalType: "uint256", name: "total", type: "uint256" }
6998
+ ],
6999
+ stateMutability: "view",
7000
+ type: "function"
7001
+ },
7002
+ {
7003
+ inputs: [],
7004
+ name: "getLocalEid",
7005
+ outputs: [{ internalType: "uint32", name: "", type: "uint32" }],
7006
+ stateMutability: "view",
7007
+ type: "function"
7008
+ },
7009
+ {
7010
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
7011
+ name: "getMemo",
7012
+ outputs: [
7013
+ {
7014
+ components: [
7015
+ { internalType: "uint256", name: "id", type: "uint256" },
7016
+ { internalType: "uint256", name: "jobId", type: "uint256" },
7017
+ { internalType: "address", name: "sender", type: "address" },
7018
+ { internalType: "string", name: "content", type: "string" },
7019
+ {
7020
+ internalType: "enum ACPTypes.MemoType",
7021
+ name: "memoType",
7022
+ type: "uint8"
7023
+ },
7024
+ { internalType: "uint256", name: "createdAt", type: "uint256" },
7025
+ { internalType: "bool", name: "isApproved", type: "bool" },
7026
+ { internalType: "address", name: "approvedBy", type: "address" },
7027
+ { internalType: "uint256", name: "approvedAt", type: "uint256" },
7028
+ { internalType: "bool", name: "requiresApproval", type: "bool" },
7029
+ { internalType: "string", name: "metadata", type: "string" },
7030
+ { internalType: "bool", name: "isSecured", type: "bool" },
7031
+ {
7032
+ internalType: "enum ACPTypes.JobPhase",
7033
+ name: "nextPhase",
7034
+ type: "uint8"
7035
+ },
7036
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
7037
+ {
7038
+ internalType: "enum ACPTypes.MemoState",
7039
+ name: "state",
7040
+ type: "uint8"
7041
+ }
7042
+ ],
7043
+ internalType: "struct ACPTypes.Memo",
7044
+ name: "",
7045
+ type: "tuple"
7046
+ }
7047
+ ],
7048
+ stateMutability: "view",
7049
+ type: "function"
7050
+ },
7051
+ {
7052
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
7053
+ name: "getMemoApprovalStatus",
7054
+ outputs: [
7055
+ { internalType: "bool", name: "isApproved", type: "bool" },
7056
+ { internalType: "address", name: "approvedBy", type: "address" },
7057
+ { internalType: "uint256", name: "approvedAt", type: "uint256" }
7058
+ ],
7059
+ stateMutability: "view",
7060
+ type: "function"
7061
+ },
7062
+ {
7063
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
7064
+ name: "getMemoWithPayableDetails",
7065
+ outputs: [
7066
+ {
7067
+ components: [
7068
+ { internalType: "uint256", name: "id", type: "uint256" },
7069
+ { internalType: "uint256", name: "jobId", type: "uint256" },
7070
+ { internalType: "address", name: "sender", type: "address" },
7071
+ { internalType: "string", name: "content", type: "string" },
7072
+ {
7073
+ internalType: "enum ACPTypes.MemoType",
7074
+ name: "memoType",
7075
+ type: "uint8"
7076
+ },
7077
+ { internalType: "uint256", name: "createdAt", type: "uint256" },
7078
+ { internalType: "bool", name: "isApproved", type: "bool" },
7079
+ { internalType: "address", name: "approvedBy", type: "address" },
7080
+ { internalType: "uint256", name: "approvedAt", type: "uint256" },
7081
+ { internalType: "bool", name: "requiresApproval", type: "bool" },
7082
+ { internalType: "string", name: "metadata", type: "string" },
7083
+ { internalType: "bool", name: "isSecured", type: "bool" },
7084
+ {
7085
+ internalType: "enum ACPTypes.JobPhase",
7086
+ name: "nextPhase",
7087
+ type: "uint8"
7088
+ },
7089
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
7090
+ {
7091
+ internalType: "enum ACPTypes.MemoState",
7092
+ name: "state",
7093
+ type: "uint8"
7094
+ }
7095
+ ],
7096
+ internalType: "struct ACPTypes.Memo",
7097
+ name: "memo",
7098
+ type: "tuple"
7099
+ },
7100
+ {
7101
+ components: [
7102
+ { internalType: "address", name: "token", type: "address" },
7103
+ { internalType: "uint256", name: "amount", type: "uint256" },
7104
+ { internalType: "address", name: "recipient", type: "address" },
7105
+ { internalType: "uint256", name: "feeAmount", type: "uint256" },
7106
+ {
7107
+ internalType: "enum ACPTypes.FeeType",
7108
+ name: "feeType",
7109
+ type: "uint8"
7110
+ },
7111
+ { internalType: "bool", name: "isExecuted", type: "bool" },
7112
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
7113
+ { internalType: "uint32", name: "lzSrcEid", type: "uint32" },
7114
+ { internalType: "uint32", name: "lzDstEid", type: "uint32" }
7115
+ ],
7116
+ internalType: "struct ACPTypes.PayableDetails",
7117
+ name: "details",
7118
+ type: "tuple"
7119
+ }
7120
+ ],
7121
+ stateMutability: "view",
7122
+ type: "function"
7123
+ },
7124
+ {
7125
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
7126
+ name: "getPayableDetails",
7127
+ outputs: [
7128
+ {
7129
+ components: [
7130
+ { internalType: "address", name: "token", type: "address" },
7131
+ { internalType: "uint256", name: "amount", type: "uint256" },
7132
+ { internalType: "address", name: "recipient", type: "address" },
7133
+ { internalType: "uint256", name: "feeAmount", type: "uint256" },
7134
+ {
7135
+ internalType: "enum ACPTypes.FeeType",
7136
+ name: "feeType",
7137
+ type: "uint8"
7138
+ },
7139
+ { internalType: "bool", name: "isExecuted", type: "bool" },
7140
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
7141
+ { internalType: "uint32", name: "lzSrcEid", type: "uint32" },
7142
+ { internalType: "uint32", name: "lzDstEid", type: "uint32" }
7143
+ ],
7144
+ internalType: "struct ACPTypes.PayableDetails",
7145
+ name: "",
7146
+ type: "tuple"
7147
+ }
7148
+ ],
7149
+ stateMutability: "view",
7150
+ type: "function"
7151
+ },
7152
+ {
7153
+ inputs: [{ internalType: "bytes32", name: "role", type: "bytes32" }],
7154
+ name: "getRoleAdmin",
7155
+ outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
7156
+ stateMutability: "view",
7157
+ type: "function"
7158
+ },
7159
+ {
7160
+ inputs: [
7161
+ { internalType: "bytes32", name: "role", type: "bytes32" },
7162
+ { internalType: "address", name: "account", type: "address" }
7163
+ ],
7164
+ name: "grantRole",
7165
+ outputs: [],
7166
+ stateMutability: "nonpayable",
7167
+ type: "function"
7168
+ },
7169
+ {
7170
+ inputs: [
7171
+ { internalType: "bytes32", name: "role", type: "bytes32" },
7172
+ { internalType: "address", name: "account", type: "address" }
7173
+ ],
7174
+ name: "hasRole",
7175
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
7176
+ stateMutability: "view",
7177
+ type: "function"
7178
+ },
7179
+ {
7180
+ inputs: [
7181
+ { internalType: "address", name: "acpContract_", type: "address" },
7182
+ { internalType: "address", name: "jobManager_", type: "address" },
7183
+ { internalType: "address", name: "paymentManager_", type: "address" }
7184
+ ],
7185
+ name: "initialize",
7186
+ outputs: [],
7187
+ stateMutability: "nonpayable",
7188
+ type: "function"
7189
+ },
7190
+ {
7191
+ inputs: [
7192
+ { internalType: "uint256", name: "jobId", type: "uint256" },
7193
+ { internalType: "address", name: "user", type: "address" }
7194
+ ],
7195
+ name: "isJobEvaluator",
7196
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
7197
+ stateMutability: "view",
7198
+ type: "function"
7199
+ },
7200
+ {
7201
+ inputs: [
7202
+ { internalType: "uint256", name: "memoId", type: "uint256" },
7203
+ { internalType: "address", name: "user", type: "address" }
7204
+ ],
7205
+ name: "isMemoSigner",
7206
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
7207
+ stateMutability: "view",
7208
+ type: "function"
7209
+ },
7210
+ {
7211
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
7212
+ name: "isPayable",
7213
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
7214
+ stateMutability: "view",
7215
+ type: "function"
7216
+ },
7217
+ {
7218
+ inputs: [],
7219
+ name: "jobManager",
7220
+ outputs: [{ internalType: "address", name: "", type: "address" }],
7221
+ stateMutability: "view",
7222
+ type: "function"
7223
+ },
7224
+ {
7225
+ inputs: [
7226
+ { internalType: "uint256", name: "", type: "uint256" },
7227
+ { internalType: "uint256", name: "", type: "uint256" }
7228
+ ],
7229
+ name: "jobMemos",
7230
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7231
+ stateMutability: "view",
7232
+ type: "function"
7233
+ },
7234
+ {
7235
+ inputs: [
7236
+ { internalType: "uint256", name: "", type: "uint256" },
7237
+ { internalType: "enum ACPTypes.JobPhase", name: "", type: "uint8" },
7238
+ { internalType: "uint256", name: "", type: "uint256" }
7239
+ ],
7240
+ name: "jobMemosByPhase",
7241
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7242
+ stateMutability: "view",
7243
+ type: "function"
7244
+ },
7245
+ {
7246
+ inputs: [
7247
+ { internalType: "uint256", name: "", type: "uint256" },
7248
+ { internalType: "enum ACPTypes.MemoType", name: "", type: "uint8" },
7249
+ { internalType: "uint256", name: "", type: "uint256" }
7250
+ ],
7251
+ name: "jobMemosByType",
7252
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7253
+ stateMutability: "view",
7254
+ type: "function"
7255
+ },
7256
+ {
7257
+ inputs: [
7258
+ { internalType: "uint256", name: "", type: "uint256" },
7259
+ { internalType: "address", name: "", type: "address" }
7260
+ ],
7261
+ name: "memoApprovals",
7262
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
7263
+ stateMutability: "view",
7264
+ type: "function"
7265
+ },
7266
+ {
7267
+ inputs: [],
7268
+ name: "memoCounter",
7269
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7270
+ stateMutability: "view",
7271
+ type: "function"
7272
+ },
7273
+ {
7274
+ inputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7275
+ name: "memos",
7276
+ outputs: [
7277
+ { internalType: "uint256", name: "id", type: "uint256" },
7278
+ { internalType: "uint256", name: "jobId", type: "uint256" },
7279
+ { internalType: "address", name: "sender", type: "address" },
7280
+ { internalType: "string", name: "content", type: "string" },
7281
+ {
7282
+ internalType: "enum ACPTypes.MemoType",
7283
+ name: "memoType",
7284
+ type: "uint8"
7285
+ },
7286
+ { internalType: "uint256", name: "createdAt", type: "uint256" },
7287
+ { internalType: "bool", name: "isApproved", type: "bool" },
7288
+ { internalType: "address", name: "approvedBy", type: "address" },
7289
+ { internalType: "uint256", name: "approvedAt", type: "uint256" },
7290
+ { internalType: "bool", name: "requiresApproval", type: "bool" },
7291
+ { internalType: "string", name: "metadata", type: "string" },
7292
+ { internalType: "bool", name: "isSecured", type: "bool" },
7293
+ {
7294
+ internalType: "enum ACPTypes.JobPhase",
7295
+ name: "nextPhase",
7296
+ type: "uint8"
7297
+ },
7298
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
7299
+ { internalType: "enum ACPTypes.MemoState", name: "state", type: "uint8" }
7300
+ ],
7301
+ stateMutability: "view",
7302
+ type: "function"
7303
+ },
7304
+ {
7305
+ inputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7306
+ name: "payableDetails",
7307
+ outputs: [
7308
+ { internalType: "address", name: "token", type: "address" },
7309
+ { internalType: "uint256", name: "amount", type: "uint256" },
7310
+ { internalType: "address", name: "recipient", type: "address" },
7311
+ { internalType: "uint256", name: "feeAmount", type: "uint256" },
7312
+ { internalType: "enum ACPTypes.FeeType", name: "feeType", type: "uint8" },
7313
+ { internalType: "bool", name: "isExecuted", type: "bool" },
7314
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
7315
+ { internalType: "uint32", name: "lzSrcEid", type: "uint32" },
7316
+ { internalType: "uint32", name: "lzDstEid", type: "uint32" }
7317
+ ],
7318
+ stateMutability: "view",
7319
+ type: "function"
7320
+ },
7321
+ {
7322
+ inputs: [],
7323
+ name: "paymentManager",
7324
+ outputs: [{ internalType: "address", name: "", type: "address" }],
7325
+ stateMutability: "view",
7326
+ type: "function"
7327
+ },
7328
+ {
7329
+ inputs: [],
7330
+ name: "proxiableUUID",
7331
+ outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
7332
+ stateMutability: "view",
7333
+ type: "function"
7334
+ },
7335
+ {
7336
+ inputs: [
7337
+ { internalType: "bytes32", name: "role", type: "bytes32" },
7338
+ { internalType: "address", name: "callerConfirmation", type: "address" }
7339
+ ],
7340
+ name: "renounceRole",
7341
+ outputs: [],
7342
+ stateMutability: "nonpayable",
7343
+ type: "function"
7344
+ },
7345
+ {
7346
+ inputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7347
+ name: "requiredApprovals",
7348
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7349
+ stateMutability: "view",
7350
+ type: "function"
7351
+ },
7352
+ {
7353
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
7354
+ name: "requiresApproval",
7355
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
7356
+ stateMutability: "view",
7357
+ type: "function"
7358
+ },
7359
+ {
7360
+ inputs: [
7361
+ { internalType: "bytes32", name: "role", type: "bytes32" },
7362
+ { internalType: "address", name: "account", type: "address" }
7363
+ ],
7364
+ name: "revokeRole",
7365
+ outputs: [],
7366
+ stateMutability: "nonpayable",
7367
+ type: "function"
7368
+ },
7369
+ {
7370
+ inputs: [
7371
+ {
7372
+ internalType: "enum ACPTypes.MemoType",
7373
+ name: "memoType",
7374
+ type: "uint8"
7375
+ },
7376
+ { internalType: "uint256", name: "requiredApprovals_", type: "uint256" }
7377
+ ],
7378
+ name: "setApprovalRequirements",
7379
+ outputs: [],
7380
+ stateMutability: "nonpayable",
7381
+ type: "function"
7382
+ },
7383
+ {
7384
+ inputs: [
7385
+ { internalType: "address", name: "assetManager_", type: "address" }
7386
+ ],
7387
+ name: "setAssetManager",
7388
+ outputs: [],
7389
+ stateMutability: "nonpayable",
7390
+ type: "function"
7391
+ },
7392
+ {
7393
+ inputs: [
7394
+ { internalType: "uint256", name: "memoId", type: "uint256" },
7395
+ { internalType: "address", name: "sender", type: "address" },
7396
+ { internalType: "bool", name: "isApproved", type: "bool" },
7397
+ { internalType: "string", name: "reason", type: "string" }
7398
+ ],
7399
+ name: "signMemo",
7400
+ outputs: [{ internalType: "uint256", name: "jobId", type: "uint256" }],
7401
+ stateMutability: "nonpayable",
7402
+ type: "function"
7403
+ },
7404
+ {
7405
+ inputs: [{ internalType: "bytes4", name: "interfaceId", type: "bytes4" }],
7406
+ name: "supportsInterface",
7407
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
7408
+ stateMutability: "view",
7409
+ type: "function"
7410
+ },
7411
+ {
7412
+ inputs: [
7413
+ { internalType: "address", name: "acpContract_", type: "address" },
7414
+ { internalType: "address", name: "jobManager_", type: "address" },
7415
+ { internalType: "address", name: "paymentManager_", type: "address" },
7416
+ { internalType: "address", name: "assetManager_", type: "address" }
7417
+ ],
7418
+ name: "updateContracts",
7419
+ outputs: [],
7420
+ stateMutability: "nonpayable",
7421
+ type: "function"
7422
+ },
7423
+ {
7424
+ inputs: [
7425
+ { internalType: "uint256", name: "memoId", type: "uint256" },
7426
+ { internalType: "string", name: "newContent", type: "string" }
7427
+ ],
7428
+ name: "updateMemoContent",
7429
+ outputs: [],
7430
+ stateMutability: "nonpayable",
7431
+ type: "function"
7432
+ },
7433
+ {
7434
+ inputs: [
7435
+ { internalType: "uint256", name: "memoId", type: "uint256" },
7436
+ {
7437
+ internalType: "enum ACPTypes.MemoState",
7438
+ name: "newMemoState",
7439
+ type: "uint8"
7440
+ }
7441
+ ],
7442
+ name: "updateMemoState",
7443
+ outputs: [],
7444
+ stateMutability: "nonpayable",
7445
+ type: "function"
7446
+ },
7447
+ {
7448
+ inputs: [
7449
+ { internalType: "address", name: "newImplementation", type: "address" },
7450
+ { internalType: "bytes", name: "data", type: "bytes" }
7451
+ ],
7452
+ name: "upgradeToAndCall",
7453
+ outputs: [],
7454
+ stateMutability: "payable",
7455
+ type: "function"
7456
+ },
7457
+ {
7458
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
7459
+ name: "withdrawEscrowedFunds",
7460
+ outputs: [],
7461
+ stateMutability: "nonpayable",
7462
+ type: "function"
7463
+ }
7464
+ ];
7465
+ var memoManagerAbi_default = MEMO_MANAGER_ABI;
7466
+
7467
+ // src/contractClients/acpContractClientV2.ts
7468
+ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClient_default {
7469
+ constructor(jobManagerAddress, memoManagerAddress, accountManagerAddress, agentWalletAddress, config = baseAcpConfigV2) {
7470
+ super(agentWalletAddress, config);
7471
+ this.jobManagerAddress = jobManagerAddress;
7472
+ this.memoManagerAddress = memoManagerAddress;
7473
+ this.accountManagerAddress = accountManagerAddress;
7474
+ this.PRIORITY_FEE_MULTIPLIER = 2;
7475
+ this.MAX_FEE_PER_GAS = 2e7;
7476
+ this.MAX_PRIORITY_FEE_PER_GAS = 21e6;
7477
+ this.GAS_FEE_MULTIPLIER = 0.5;
7478
+ this._sessionKeyClients = {};
7479
+ }
7480
+ static async build(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfigV2) {
7481
+ const publicClients = {};
7482
+ for (const chain of config.chains) {
7483
+ publicClients[chain.chain.id] = (0, import_viem9.createPublicClient)({
7484
+ chain: chain.chain,
7485
+ transport: (0, import_viem9.http)(chain.rpcUrl)
7486
+ });
7487
+ }
7488
+ const publicClient = (0, import_viem9.createPublicClient)({
7489
+ chain: config.chain,
7490
+ transport: (0, import_viem9.http)(config.rpcEndpoint)
7491
+ });
7492
+ const [jobManagerAddress, memoManagerAddress, accountManagerAddress] = await publicClient.multicall({
7493
+ contracts: [
7494
+ {
7495
+ address: config.contractAddress,
7496
+ abi: config.abi,
7497
+ functionName: "jobManager"
7498
+ },
7499
+ {
7500
+ address: config.contractAddress,
7501
+ abi: config.abi,
7502
+ functionName: "memoManager"
7503
+ },
7504
+ {
7505
+ address: config.contractAddress,
7506
+ abi: config.abi,
7507
+ functionName: "accountManager"
7508
+ }
7509
+ ]
7510
+ });
7511
+ if (!jobManagerAddress || !memoManagerAddress || !accountManagerAddress) {
7512
+ throw new acpError_default(
7513
+ "Failed to get job manager, memo manager, or account manager address"
7514
+ );
7515
+ }
7516
+ const acpContractClient = new _AcpContractClientV2(
7517
+ jobManagerAddress.result,
7518
+ memoManagerAddress.result,
7519
+ accountManagerAddress.result,
7520
+ agentWalletAddress,
7521
+ config
7522
+ );
7523
+ acpContractClient.publicClients = publicClients;
7524
+ await acpContractClient.init(walletPrivateKey, sessionEntityKeyId);
7525
+ return acpContractClient;
7526
+ }
7527
+ async init(privateKey, sessionEntityKeyId) {
7528
+ const sessionKeySigner = import_core2.LocalAccountSigner.privateKeyToAccountSigner(privateKey);
7529
+ this._sessionKeyClient = await (0, import_smart_contracts2.createModularAccountV2Client)({
7530
+ chain: this.chain,
7531
+ transport: (0, import_infra3.alchemy)({
7532
+ rpcUrl: this.config.alchemyRpcUrl
7533
+ }),
7534
+ signer: sessionKeySigner,
7535
+ policyId: "186aaa4a-5f57-4156-83fb-e456365a8820",
7536
+ accountAddress: this.agentWalletAddress,
7537
+ signerEntity: {
7538
+ entityId: sessionEntityKeyId,
7539
+ isGlobalValidation: true
7540
+ }
7541
+ });
7542
+ for (const chain of this.config.chains) {
7543
+ this._sessionKeyClients[chain.chain.id] = await (0, import_smart_contracts2.createModularAccountV2Client)({
7544
+ chain: chain.chain,
7545
+ transport: (0, import_infra3.alchemy)({
7546
+ rpcUrl: `${this.config.alchemyRpcUrl}?chainId=${chain.chain.id}`
7547
+ }),
7548
+ signer: sessionKeySigner,
7549
+ policyId: "186aaa4a-5f57-4156-83fb-e456365a8820",
7550
+ accountAddress: this.agentWalletAddress,
7551
+ signerEntity: {
7552
+ entityId: sessionEntityKeyId,
7553
+ isGlobalValidation: true
7554
+ }
7555
+ });
7556
+ }
7557
+ this._acpX402 = new AcpX402(
7558
+ this.config,
6121
7559
  this.sessionKeyClient,
6122
7560
  this.publicClient
6123
7561
  );
@@ -6128,7 +7566,10 @@ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClie
6128
7566
  `ACP Contract Client validation failed: agent account ${this.agentWalletAddress} is not deployed on-chain`
6129
7567
  );
6130
7568
  }
6131
- await this.validateSessionKeyOnChain(sessionSignerAddress, sessionEntityKeyId);
7569
+ await this.validateSessionKeyOnChain(
7570
+ sessionSignerAddress,
7571
+ sessionEntityKeyId
7572
+ );
6132
7573
  console.log("Connected to ACP:", {
6133
7574
  agentWalletAddress: this.agentWalletAddress,
6134
7575
  whitelistedWalletAddress: sessionSignerAddress,
@@ -6156,11 +7597,20 @@ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClie
6156
7597
  }
6157
7598
  return this._acpX402;
6158
7599
  }
6159
- async calculateGasFees() {
7600
+ async calculateGasFees(chainId) {
7601
+ if (chainId) {
7602
+ const { maxFeePerGas } = await this.publicClients[chainId].estimateFeesPerGas();
7603
+ const increasedMaxFeePerGas = BigInt(maxFeePerGas) + BigInt(maxFeePerGas) * BigInt(this.GAS_FEE_MULTIPLIER * 100) / BigInt(100);
7604
+ return increasedMaxFeePerGas;
7605
+ }
6160
7606
  const finalMaxFeePerGas = BigInt(this.MAX_FEE_PER_GAS) + BigInt(this.MAX_PRIORITY_FEE_PER_GAS) * BigInt(Math.max(0, this.PRIORITY_FEE_MULTIPLIER - 1));
6161
7607
  return finalMaxFeePerGas;
6162
7608
  }
6163
- async handleOperation(operations) {
7609
+ async handleOperation(operations, chainId) {
7610
+ const sessionKeyClient = chainId ? this._sessionKeyClients[chainId] : this.sessionKeyClient;
7611
+ if (!sessionKeyClient) {
7612
+ throw new acpError_default("Session key client not initialized");
7613
+ }
6164
7614
  const payload = {
6165
7615
  uo: operations.map((operation) => ({
6166
7616
  target: operation.contractAddress,
@@ -6181,16 +7631,21 @@ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClie
6181
7631
  maxFeePerGas: `0x${gasFees.toString(16)}`
6182
7632
  };
6183
7633
  }
6184
- const { hash } = await this.sessionKeyClient.sendUserOperation(payload);
6185
- const txnHash = await this.sessionKeyClient.waitForUserOperationTransaction({
7634
+ const { hash } = await sessionKeyClient.sendUserOperation(payload);
7635
+ const checkTransactionConfig = {
6186
7636
  hash,
6187
- tag: "pending",
6188
7637
  retries: {
6189
7638
  intervalMs: 200,
6190
7639
  multiplier: 1.1,
6191
7640
  maxRetries: 10
6192
7641
  }
6193
- });
7642
+ };
7643
+ if (!chainId || chainId === import_chains3.baseSepolia.id || chainId === import_chains3.base.id) {
7644
+ checkTransactionConfig["tag"] = "pending";
7645
+ }
7646
+ const txnHash = await sessionKeyClient.waitForUserOperationTransaction(
7647
+ checkTransactionConfig
7648
+ );
6194
7649
  return { userOpHash: hash, txnHash };
6195
7650
  } catch (error) {
6196
7651
  retries -= 1;
@@ -6214,7 +7669,7 @@ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClie
6214
7669
  const contractLogs = result.logs.filter((log) => {
6215
7670
  return log.address.toLowerCase() === this.jobManagerAddress.toLowerCase();
6216
7671
  }).map(
6217
- (log) => (0, import_viem7.decodeEventLog)({
7672
+ (log) => (0, import_viem9.decodeEventLog)({
6218
7673
  abi: jobManagerAbi_default,
6219
7674
  data: log.data,
6220
7675
  topics: log.topics
@@ -6253,6 +7708,13 @@ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClie
6253
7708
  throw new acpError_default("Failed to get X402 payment details", error);
6254
7709
  }
6255
7710
  }
7711
+ async getAssetManager() {
7712
+ return await this.publicClient.readContract({
7713
+ address: this.memoManagerAddress,
7714
+ abi: memoManagerAbi_default,
7715
+ functionName: "assetManager"
7716
+ });
7717
+ }
6256
7718
  getAcpVersion() {
6257
7719
  return "2";
6258
7720
  }
@@ -6273,6 +7735,7 @@ var index_default = acpClient_default;
6273
7735
  AcpJob,
6274
7736
  AcpJobPhases,
6275
7737
  AcpMemo,
7738
+ AcpMemoState,
6276
7739
  AcpMemoStatus,
6277
7740
  AcpOnlineStatus,
6278
7741
  BaseAcpContractClient,
@@ -6288,6 +7751,7 @@ var index_default = acpClient_default;
6288
7751
  baseAcpX402ConfigV2,
6289
7752
  baseSepoliaAcpConfig,
6290
7753
  baseSepoliaAcpConfigV2,
7754
+ baseSepoliaAcpX402ConfigV2,
6291
7755
  ethFare,
6292
7756
  preparePayload,
6293
7757
  wethFare