@virtuals-protocol/acp-node 0.3.0-beta.20 → 0.3.0-beta.21

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