@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.mjs CHANGED
@@ -8,12 +8,13 @@ var require_package = __commonJS({
8
8
  "package.json"(exports, module) {
9
9
  module.exports = {
10
10
  name: "@virtuals-protocol/acp-node",
11
- version: "0.3.0-beta.17",
11
+ version: "0.3.0-beta.19",
12
12
  main: "./dist/index.js",
13
13
  module: "./dist/index.mjs",
14
14
  types: "./dist/index.d.ts",
15
15
  scripts: {
16
16
  test: "jest",
17
+ "test:ci": "jest --ci --reporters=default --reporters=jest-junit",
17
18
  "test:watch": "jest --watch",
18
19
  "test:coverage": "jest --coverage",
19
20
  tsup: "tsup src/index.ts --dts --format cjs,esm --out-dir dist"
@@ -29,6 +30,7 @@ var require_package = __commonJS({
29
30
  "babel-jest": "^30.2.0",
30
31
  dotenv: "^17.2.3",
31
32
  jest: "^30.2.0",
33
+ "jest-junit": "^16.0.0",
32
34
  "ts-jest": "^29.4.5",
33
35
  typescript: "^5.8.3"
34
36
  },
@@ -1236,7 +1238,10 @@ import {
1236
1238
  } from "viem";
1237
1239
 
1238
1240
  // src/configs/acpConfigs.ts
1239
- import { baseSepolia, base } from "@account-kit/infra";
1241
+ import {
1242
+ baseSepolia,
1243
+ base
1244
+ } from "@account-kit/infra";
1240
1245
 
1241
1246
  // src/acpFare.ts
1242
1247
  import {
@@ -1264,27 +1269,42 @@ var acpError_default = AcpError;
1264
1269
 
1265
1270
  // src/acpFare.ts
1266
1271
  var Fare = class _Fare {
1267
- constructor(contractAddress, decimals) {
1272
+ constructor(contractAddress, decimals, chainId) {
1268
1273
  this.contractAddress = contractAddress;
1269
1274
  this.decimals = decimals;
1275
+ this.chainId = chainId;
1270
1276
  }
1271
1277
  formatAmount(amount) {
1272
1278
  return parseUnits(amount.toString(), this.decimals);
1273
1279
  }
1274
- static async fromContractAddress(contractAddress, config = baseAcpConfig) {
1280
+ static async fromContractAddress(contractAddress, config = baseAcpConfig, chainId = config.chain.id) {
1275
1281
  if (contractAddress === config.baseFare.contractAddress) {
1276
1282
  return config.baseFare;
1277
1283
  }
1284
+ let chainConfig = config.chain;
1285
+ let rpcUrl = config.rpcEndpoint;
1286
+ if (chainId !== config.chain.id) {
1287
+ const selectedConfig = config.chains?.find(
1288
+ (chain) => chain.chain.id === chainId
1289
+ );
1290
+ if (!selectedConfig) {
1291
+ throw new acpError_default(
1292
+ `Chain configuration for chainId ${chainId} not found.`
1293
+ );
1294
+ }
1295
+ chainConfig = selectedConfig.chain;
1296
+ rpcUrl = selectedConfig.rpcUrl;
1297
+ }
1278
1298
  const publicClient = createPublicClient({
1279
- chain: config.chain,
1280
- transport: http(config.rpcEndpoint)
1299
+ chain: chainConfig,
1300
+ transport: http(rpcUrl)
1281
1301
  });
1282
1302
  const decimals = await publicClient.readContract({
1283
1303
  address: contractAddress,
1284
1304
  abi: erc20Abi,
1285
1305
  functionName: "decimals"
1286
1306
  });
1287
- return new _Fare(contractAddress, decimals);
1307
+ return new _Fare(contractAddress, decimals, chainId);
1288
1308
  }
1289
1309
  };
1290
1310
  var FareAmountBase = class {
@@ -1703,6 +1723,34 @@ var ACP_V2_ABI = [
1703
1723
  stateMutability: "nonpayable",
1704
1724
  type: "function"
1705
1725
  },
1726
+ {
1727
+ inputs: [
1728
+ { internalType: "uint256", name: "jobId", type: "uint256" },
1729
+ { internalType: "string", name: "content", type: "string" },
1730
+ { internalType: "address", name: "token", type: "address" },
1731
+ { internalType: "uint256", name: "amount", type: "uint256" },
1732
+ { internalType: "address", name: "recipient", type: "address" },
1733
+ { internalType: "uint256", name: "feeAmount", type: "uint256" },
1734
+ { internalType: "enum ACPTypes.FeeType", name: "feeType", type: "uint8" },
1735
+ {
1736
+ internalType: "enum ACPTypes.MemoType",
1737
+ name: "memoType",
1738
+ type: "uint8"
1739
+ },
1740
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
1741
+ { internalType: "bool", name: "isSecured", type: "bool" },
1742
+ {
1743
+ internalType: "enum ACPTypes.JobPhase",
1744
+ name: "nextPhase",
1745
+ type: "uint8"
1746
+ },
1747
+ { internalType: "uint32", name: "lzDstEid", type: "uint32" }
1748
+ ],
1749
+ name: "createCrossChainPayableMemo",
1750
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
1751
+ stateMutability: "nonpayable",
1752
+ type: "function"
1753
+ },
1706
1754
  {
1707
1755
  inputs: [
1708
1756
  { internalType: "address", name: "provider", type: "address" },
@@ -1887,7 +1935,12 @@ var ACP_V2_ABI = [
1887
1935
  name: "nextPhase",
1888
1936
  type: "uint8"
1889
1937
  },
1890
- { internalType: "uint256", name: "expiredAt", type: "uint256" }
1938
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
1939
+ {
1940
+ internalType: "enum ACPTypes.MemoState",
1941
+ name: "state",
1942
+ type: "uint8"
1943
+ }
1891
1944
  ],
1892
1945
  internalType: "struct ACPTypes.Memo[]",
1893
1946
  name: "memos",
@@ -1934,7 +1987,12 @@ var ACP_V2_ABI = [
1934
1987
  name: "nextPhase",
1935
1988
  type: "uint8"
1936
1989
  },
1937
- { internalType: "uint256", name: "expiredAt", type: "uint256" }
1990
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
1991
+ {
1992
+ internalType: "enum ACPTypes.MemoState",
1993
+ name: "state",
1994
+ type: "uint8"
1995
+ }
1938
1996
  ],
1939
1997
  internalType: "struct ACPTypes.Memo[]",
1940
1998
  name: "memos",
@@ -1977,7 +2035,12 @@ var ACP_V2_ABI = [
1977
2035
  name: "nextPhase",
1978
2036
  type: "uint8"
1979
2037
  },
1980
- { internalType: "uint256", name: "expiredAt", type: "uint256" }
2038
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
2039
+ {
2040
+ internalType: "enum ACPTypes.MemoState",
2041
+ name: "state",
2042
+ type: "uint8"
2043
+ }
1981
2044
  ],
1982
2045
  internalType: "struct ACPTypes.Memo[]",
1983
2046
  name: "memos",
@@ -2233,7 +2296,7 @@ var acpAbiV2_default = ACP_V2_ABI;
2233
2296
  var V1_MAX_RETRIES = 10;
2234
2297
  var V2_MAX_RETRIES = 3;
2235
2298
  var AcpContractConfig2 = class {
2236
- constructor(chain, contractAddress, baseFare, alchemyRpcUrl, acpUrl, abi, maxRetries, rpcEndpoint, x402Config) {
2299
+ constructor(chain, contractAddress, baseFare, alchemyRpcUrl, acpUrl, abi, maxRetries, rpcEndpoint, x402Config, chains = []) {
2237
2300
  this.chain = chain;
2238
2301
  this.contractAddress = contractAddress;
2239
2302
  this.baseFare = baseFare;
@@ -2243,6 +2306,7 @@ var AcpContractConfig2 = class {
2243
2306
  this.maxRetries = maxRetries;
2244
2307
  this.rpcEndpoint = rpcEndpoint;
2245
2308
  this.x402Config = x402Config;
2309
+ this.chains = chains;
2246
2310
  }
2247
2311
  };
2248
2312
  var baseSepoliaAcpConfig = new AcpContractConfig2(
@@ -3470,7 +3534,10 @@ var SINGLE_SIGNER_VALIDATION_MODULE_ABI = [
3470
3534
  var singleSignerValidationModuleAbi_default = SINGLE_SIGNER_VALIDATION_MODULE_ABI;
3471
3535
 
3472
3536
  // src/constants.ts
3473
- import { base as base2, baseSepolia as baseSepolia2 } from "viem/chains";
3537
+ import {
3538
+ base as base2,
3539
+ baseSepolia as baseSepolia2
3540
+ } from "viem/chains";
3474
3541
  var USDC_TOKEN_ADDRESS = {
3475
3542
  [baseSepolia2.id]: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
3476
3543
  [base2.id]: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
@@ -3518,6 +3585,7 @@ var BaseAcpContractClient = class {
3518
3585
  constructor(agentWalletAddress, config = baseAcpConfig) {
3519
3586
  this.agentWalletAddress = agentWalletAddress;
3520
3587
  this.config = config;
3588
+ this.publicClients = {};
3521
3589
  this.chain = config.chain;
3522
3590
  this.abi = config.abi;
3523
3591
  this.contractAddress = config.contractAddress;
@@ -3617,12 +3685,12 @@ ${JSON.stringify(
3617
3685
  throw new acpError_default("Failed to create job", error);
3618
3686
  }
3619
3687
  }
3620
- approveAllowance(amountBaseUnit, paymentTokenAddress = this.config.baseFare.contractAddress) {
3688
+ approveAllowance(amountBaseUnit, paymentTokenAddress = this.config.baseFare.contractAddress, targetAddress) {
3621
3689
  try {
3622
3690
  const data = encodeFunctionData({
3623
3691
  abi: erc20Abi2,
3624
3692
  functionName: "approve",
3625
- args: [this.contractAddress, amountBaseUnit]
3693
+ args: [targetAddress ?? this.contractAddress, amountBaseUnit]
3626
3694
  });
3627
3695
  const payload = {
3628
3696
  data,
@@ -3661,6 +3729,35 @@ ${JSON.stringify(
3661
3729
  throw new acpError_default("Failed to create payable memo", error);
3662
3730
  }
3663
3731
  }
3732
+ createCrossChainPayableMemo(jobId, content, token, amountBaseUnit, recipient, feeAmountBaseUnit, feeType, type, expiredAt, nextPhase, destinationEid, secured = true) {
3733
+ try {
3734
+ const data = encodeFunctionData({
3735
+ abi: this.abi,
3736
+ functionName: "createCrossChainPayableMemo",
3737
+ args: [
3738
+ jobId,
3739
+ content,
3740
+ token,
3741
+ amountBaseUnit,
3742
+ recipient,
3743
+ feeAmountBaseUnit,
3744
+ feeType,
3745
+ type,
3746
+ expiredAt,
3747
+ secured,
3748
+ nextPhase,
3749
+ destinationEid
3750
+ ]
3751
+ });
3752
+ const payload = {
3753
+ data,
3754
+ contractAddress: this.contractAddress
3755
+ };
3756
+ return payload;
3757
+ } catch (error) {
3758
+ throw new acpError_default("Failed to create cross chain payable memo", error);
3759
+ }
3760
+ }
3664
3761
  createMemo(jobId, content, type, isSecured, nextPhase) {
3665
3762
  try {
3666
3763
  const data = encodeFunctionData({
@@ -3677,6 +3774,22 @@ ${JSON.stringify(
3677
3774
  throw new acpError_default("Failed to create memo", error);
3678
3775
  }
3679
3776
  }
3777
+ createMemoWithMetadata(jobId, content, type, isSecured, nextPhase, metadata) {
3778
+ try {
3779
+ const data = encodeFunctionData({
3780
+ abi: this.abi,
3781
+ functionName: "createMemoWithMetadata",
3782
+ args: [jobId, content, type, isSecured, nextPhase, metadata]
3783
+ });
3784
+ const payload = {
3785
+ data,
3786
+ contractAddress: this.contractAddress
3787
+ };
3788
+ return payload;
3789
+ } catch (error) {
3790
+ throw new acpError_default("Failed to create memo with metadata", error);
3791
+ }
3792
+ }
3680
3793
  signMemo(memoId, isApproved, reason) {
3681
3794
  try {
3682
3795
  const data = encodeFunctionData({
@@ -3762,9 +3875,47 @@ ${JSON.stringify(
3762
3875
  throw new acpError_default("Failed to submit TransferWithAuthorization", error);
3763
3876
  }
3764
3877
  }
3878
+ async getERC20Balance(chainId, tokenAddress, walletAddress) {
3879
+ const publicClient = this.publicClients[chainId];
3880
+ if (!publicClient) {
3881
+ throw new acpError_default(`Public client for chainId ${chainId} not found`);
3882
+ }
3883
+ return await publicClient.readContract({
3884
+ address: tokenAddress,
3885
+ abi: erc20Abi2,
3886
+ functionName: "balanceOf",
3887
+ args: [walletAddress]
3888
+ });
3889
+ }
3890
+ async getERC20Allowance(chainId, tokenAddress, walletAddress, spenderAddress) {
3891
+ const publicClient = this.publicClients[chainId];
3892
+ if (!publicClient) {
3893
+ throw new acpError_default(`Public client for chainId ${chainId} not found`);
3894
+ }
3895
+ return await publicClient.readContract({
3896
+ address: tokenAddress,
3897
+ abi: erc20Abi2,
3898
+ functionName: "allowance",
3899
+ args: [walletAddress, spenderAddress]
3900
+ });
3901
+ }
3902
+ async getERC20Symbol(chainId, tokenAddress) {
3903
+ const publicClient = this.publicClients[chainId];
3904
+ if (!publicClient) {
3905
+ throw new acpError_default(`Public client for chainId ${chainId} not found`);
3906
+ }
3907
+ return await publicClient.readContract({
3908
+ address: tokenAddress,
3909
+ abi: erc20Abi2,
3910
+ functionName: "symbol"
3911
+ });
3912
+ }
3765
3913
  };
3766
3914
  var baseAcpContractClient_default = BaseAcpContractClient;
3767
3915
 
3916
+ // src/acpJob.ts
3917
+ import { formatUnits } from "viem";
3918
+
3768
3919
  // src/interfaces.ts
3769
3920
  var AcpMemoStatus = /* @__PURE__ */ ((AcpMemoStatus2) => {
3770
3921
  AcpMemoStatus2["PENDING"] = "PENDING";
@@ -3772,6 +3923,15 @@ var AcpMemoStatus = /* @__PURE__ */ ((AcpMemoStatus2) => {
3772
3923
  AcpMemoStatus2["REJECTED"] = "REJECTED";
3773
3924
  return AcpMemoStatus2;
3774
3925
  })(AcpMemoStatus || {});
3926
+ var AcpMemoState = /* @__PURE__ */ ((AcpMemoState2) => {
3927
+ AcpMemoState2[AcpMemoState2["NONE"] = 0] = "NONE";
3928
+ AcpMemoState2[AcpMemoState2["PENDING"] = 1] = "PENDING";
3929
+ AcpMemoState2[AcpMemoState2["IN_PROGRESS"] = 2] = "IN_PROGRESS";
3930
+ AcpMemoState2[AcpMemoState2["READY"] = 3] = "READY";
3931
+ AcpMemoState2[AcpMemoState2["COMPLETED"] = 4] = "COMPLETED";
3932
+ AcpMemoState2[AcpMemoState2["REJECTED"] = 5] = "REJECTED";
3933
+ return AcpMemoState2;
3934
+ })(AcpMemoState || {});
3775
3935
  var AcpAgentSort = /* @__PURE__ */ ((AcpAgentSort2) => {
3776
3936
  AcpAgentSort2["SUCCESSFUL_JOB_COUNT"] = "successfulJobCount";
3777
3937
  AcpAgentSort2["SUCCESS_RATE"] = "successRate";
@@ -3810,6 +3970,19 @@ var PositionDirection = /* @__PURE__ */ ((PositionDirection2) => {
3810
3970
  })(PositionDirection || {});
3811
3971
 
3812
3972
  // src/utils.ts
3973
+ import { decodeAbiParameters, encodeAbiParameters } from "viem";
3974
+ import {
3975
+ arbitrum as arbitrum3,
3976
+ arbitrumSepolia as arbitrumSepolia3,
3977
+ base as base3,
3978
+ baseSepolia as baseSepolia3,
3979
+ bsc as bsc3,
3980
+ bscTestnet as bscTestnet3,
3981
+ mainnet as mainnet3,
3982
+ polygon as polygon3,
3983
+ polygonAmoy as polygonAmoy3,
3984
+ sepolia as sepolia3
3985
+ } from "viem/chains";
3813
3986
  function tryParseJson(content) {
3814
3987
  try {
3815
3988
  return JSON.parse(content);
@@ -3826,6 +3999,31 @@ function safeBase64Encode(data) {
3826
3999
  }
3827
4000
  return Buffer.from(data).toString("base64");
3828
4001
  }
4002
+ function getDestinationEndpointId(chainId) {
4003
+ switch (chainId) {
4004
+ case baseSepolia3.id:
4005
+ return 40245;
4006
+ case sepolia3.id:
4007
+ return 40161;
4008
+ case polygonAmoy3.id:
4009
+ return 40267;
4010
+ case arbitrumSepolia3.id:
4011
+ return 40231;
4012
+ case bscTestnet3.id:
4013
+ return 40102;
4014
+ case base3.id:
4015
+ return 30184;
4016
+ case mainnet3.id:
4017
+ return 30101;
4018
+ case polygon3.id:
4019
+ return 30109;
4020
+ case arbitrum3.id:
4021
+ return 30110;
4022
+ case bsc3.id:
4023
+ return 30102;
4024
+ }
4025
+ throw new Error(`Unsupported chain ID: ${chainId}`);
4026
+ }
3829
4027
 
3830
4028
  // src/acpJobOffering.ts
3831
4029
  import { zeroAddress as zeroAddress2 } from "viem";
@@ -4028,25 +4226,43 @@ var AcpJob = class {
4028
4226
  }
4029
4227
  const feeAmount = new FareAmount(0, this.acpContractClient.config.baseFare);
4030
4228
  const isPercentagePricing = this.priceType === "percentage" /* PERCENTAGE */;
4031
- operations.push(
4032
- this.acpContractClient.createPayableMemo(
4033
- this.id,
4034
- content,
4035
- amount.amount,
4036
- recipient,
4037
- isPercentagePricing ? BigInt(Math.round(this.priceValue * 1e4)) : feeAmount.amount,
4038
- isPercentagePricing ? 3 /* PERCENTAGE_FEE */ : 0 /* NO_FEE */,
4039
- 2 /* TRANSACTION */,
4040
- type,
4041
- expiredAt,
4042
- amount.fare.contractAddress
4043
- )
4044
- );
4229
+ if (amount.fare.chainId && amount.fare.chainId !== this.acpContractClient.config.chain.id) {
4230
+ operations.push(
4231
+ this.acpContractClient.createCrossChainPayableMemo(
4232
+ this.id,
4233
+ content,
4234
+ amount.fare.contractAddress,
4235
+ amount.amount,
4236
+ recipient,
4237
+ isPercentagePricing ? BigInt(Math.round(this.priceValue * 1e4)) : feeAmount.amount,
4238
+ isPercentagePricing ? 3 /* PERCENTAGE_FEE */ : 0 /* NO_FEE */,
4239
+ type,
4240
+ expiredAt,
4241
+ 2 /* TRANSACTION */,
4242
+ getDestinationEndpointId(amount.fare.chainId)
4243
+ )
4244
+ );
4245
+ } else {
4246
+ operations.push(
4247
+ this.acpContractClient.createPayableMemo(
4248
+ this.id,
4249
+ content,
4250
+ amount.amount,
4251
+ recipient,
4252
+ isPercentagePricing ? BigInt(Math.round(this.priceValue * 1e4)) : feeAmount.amount,
4253
+ isPercentagePricing ? 3 /* PERCENTAGE_FEE */ : 0 /* NO_FEE */,
4254
+ 2 /* TRANSACTION */,
4255
+ type,
4256
+ expiredAt,
4257
+ amount.fare.contractAddress
4258
+ )
4259
+ );
4260
+ }
4045
4261
  return await this.acpContractClient.handleOperation(operations);
4046
4262
  }
4047
4263
  async payAndAcceptRequirement(reason) {
4048
4264
  const memo = this.memos.find(
4049
- (m) => m.nextPhase === 2 /* TRANSACTION */
4265
+ (m) => m.nextPhase === 2 /* TRANSACTION */ || m.nextPhase === 4 /* COMPLETED */
4050
4266
  );
4051
4267
  if (!memo) {
4052
4268
  throw new acpError_default("No notification memo found");
@@ -4174,6 +4390,9 @@ var AcpJob = class {
4174
4390
  if (this.latestMemo?.nextPhase !== 3 /* EVALUATION */) {
4175
4391
  throw new acpError_default("No transaction memo found");
4176
4392
  }
4393
+ if (amount.fare.chainId !== this.acpContractClient.config.chain.id) {
4394
+ return await this.deliverCrossChainPayable(this.clientAddress, amount);
4395
+ }
4177
4396
  const operations = [];
4178
4397
  operations.push(
4179
4398
  this.acpContractClient.approveAllowance(
@@ -4304,6 +4523,57 @@ var AcpJob = class {
4304
4523
  waitMs = Math.min(waitMs * 2, maxWaitMs);
4305
4524
  }
4306
4525
  }
4526
+ async deliverCrossChainPayable(recipient, amount, isRequest = false) {
4527
+ if (!amount.fare.chainId) {
4528
+ throw new acpError_default("Chain ID is required for cross chain payable");
4529
+ }
4530
+ const chainId = amount.fare.chainId;
4531
+ const assetManagerAddress = await this.acpContractClient.getAssetManager();
4532
+ const tokenBalance = await this.acpContractClient.getERC20Balance(
4533
+ chainId,
4534
+ amount.fare.contractAddress,
4535
+ this.acpContractClient.agentWalletAddress
4536
+ );
4537
+ if (tokenBalance < amount.amount) {
4538
+ throw new acpError_default("Insufficient token balance for cross chain payable");
4539
+ }
4540
+ const currentAllowance = await this.acpContractClient.getERC20Allowance(
4541
+ chainId,
4542
+ amount.fare.contractAddress,
4543
+ this.acpContractClient.agentWalletAddress,
4544
+ assetManagerAddress
4545
+ );
4546
+ const approveAllowanceOperation = this.acpContractClient.approveAllowance(
4547
+ amount.amount + currentAllowance,
4548
+ amount.fare.contractAddress,
4549
+ assetManagerAddress
4550
+ );
4551
+ await this.acpContractClient.handleOperation(
4552
+ [approveAllowanceOperation],
4553
+ chainId
4554
+ );
4555
+ const tokenSymbol = await this.acpContractClient.getERC20Symbol(
4556
+ chainId,
4557
+ amount.fare.contractAddress
4558
+ );
4559
+ const createMemoOperation = this.acpContractClient.createCrossChainPayableMemo(
4560
+ this.id,
4561
+ `Performing cross chain payable transfer of ${formatUnits(
4562
+ amount.amount,
4563
+ amount.fare.decimals
4564
+ )} ${tokenSymbol} to ${recipient}`,
4565
+ amount.fare.contractAddress,
4566
+ amount.amount,
4567
+ recipient,
4568
+ BigInt(0),
4569
+ 0 /* NO_FEE */,
4570
+ isRequest ? 6 /* PAYABLE_REQUEST */ : 7 /* PAYABLE_TRANSFER */,
4571
+ new Date(Date.now() + 1e3 * 60 * 5),
4572
+ isRequest ? 2 /* TRANSACTION */ : 4 /* COMPLETED */,
4573
+ getDestinationEndpointId(chainId)
4574
+ );
4575
+ await this.acpContractClient.handleOperation([createMemoOperation]);
4576
+ }
4307
4577
  [util.inspect.custom]() {
4308
4578
  return {
4309
4579
  id: this.id,
@@ -4327,7 +4597,7 @@ var acpJob_default = AcpJob;
4327
4597
  // src/acpMemo.ts
4328
4598
  import util2 from "util";
4329
4599
  var AcpMemo = class {
4330
- constructor(contractClient, id, type, content, nextPhase, status, senderAddress, signedReason, expiry, payableDetails, txHash, signedTxHash) {
4600
+ constructor(contractClient, id, type, content, nextPhase, status, senderAddress, signedReason, expiry, payableDetails, txHash, signedTxHash, state) {
4331
4601
  this.contractClient = contractClient;
4332
4602
  this.id = id;
4333
4603
  this.type = type;
@@ -4340,6 +4610,7 @@ var AcpMemo = class {
4340
4610
  this.payableDetails = payableDetails;
4341
4611
  this.txHash = txHash;
4342
4612
  this.signedTxHash = signedTxHash;
4613
+ this.state = state;
4343
4614
  if (this.payableDetails) {
4344
4615
  this.payableDetails.amount = BigInt(this.payableDetails.amount);
4345
4616
  this.payableDetails.feeAmount = BigInt(this.payableDetails.feeAmount);
@@ -4490,7 +4761,8 @@ var AcpClient = class {
4490
4761
  memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
4491
4762
  memo.payableDetails,
4492
4763
  memo.txHash,
4493
- memo.signedTxHash
4764
+ memo.signedTxHash,
4765
+ memo.state
4494
4766
  );
4495
4767
  }),
4496
4768
  data.phase,
@@ -4528,7 +4800,8 @@ var AcpClient = class {
4528
4800
  memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
4529
4801
  memo.payableDetails,
4530
4802
  memo.txHash,
4531
- memo.signedTxHash
4803
+ memo.signedTxHash,
4804
+ memo.state
4532
4805
  );
4533
4806
  }),
4534
4807
  data.phase,
@@ -4553,7 +4826,14 @@ var AcpClient = class {
4553
4826
  process.on("SIGTERM", cleanup);
4554
4827
  }
4555
4828
  async browseAgents(keyword, options) {
4556
- let { cluster, sort_by, top_k, graduationStatus, onlineStatus, showHiddenOfferings } = options;
4829
+ let {
4830
+ cluster,
4831
+ sort_by,
4832
+ top_k,
4833
+ graduationStatus,
4834
+ onlineStatus,
4835
+ showHiddenOfferings
4836
+ } = options;
4557
4837
  top_k = top_k ?? 5;
4558
4838
  let url = `${this.acpUrl}/api/agents/v4/search?search=${keyword}`;
4559
4839
  if (sort_by && sort_by.length > 0) {
@@ -4744,7 +5024,8 @@ var AcpClient = class {
4744
5024
  memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
4745
5025
  memo.payableDetails,
4746
5026
  memo.txHash,
4747
- memo.signedTxHash
5027
+ memo.signedTxHash,
5028
+ memo.state
4748
5029
  )
4749
5030
  );
4750
5031
  jobs.push(
@@ -4818,7 +5099,8 @@ var AcpClient = class {
4818
5099
  memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
4819
5100
  memo.payableDetails,
4820
5101
  memo.txHash,
4821
- memo.signedTxHash
5102
+ memo.signedTxHash,
5103
+ memo.state
4822
5104
  )
4823
5105
  );
4824
5106
  return new acpJob_default(
@@ -4877,7 +5159,8 @@ var AcpClient = class {
4877
5159
  memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
4878
5160
  memo.payableDetails,
4879
5161
  memo.txHash,
4880
- memo.signedTxHash
5162
+ memo.signedTxHash,
5163
+ memo.state
4881
5164
  );
4882
5165
  } catch (err) {
4883
5166
  throw new acpError_default(
@@ -4990,6 +5273,9 @@ var AcpX402 = class {
4990
5273
  const acpJob = await response.json();
4991
5274
  return acpJob;
4992
5275
  } catch (error) {
5276
+ if (error instanceof acpError_default) {
5277
+ throw error;
5278
+ }
4993
5279
  throw new acpError_default("Failed to update job X402 nonce", error);
4994
5280
  }
4995
5281
  }
@@ -5078,6 +5364,9 @@ var AcpX402 = class {
5078
5364
  data
5079
5365
  };
5080
5366
  } catch (error) {
5367
+ if (error instanceof acpError_default) {
5368
+ throw error;
5369
+ }
5081
5370
  throw new acpError_default("Failed to perform X402 request", error);
5082
5371
  }
5083
5372
  }
@@ -5092,10 +5381,7 @@ var AcpContractClient = class _AcpContractClient extends baseAcpContractClient_d
5092
5381
  this.MAX_PRIORITY_FEE_PER_GAS = 21e6;
5093
5382
  }
5094
5383
  static async build(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfig) {
5095
- const acpContractClient = new _AcpContractClient(
5096
- agentWalletAddress,
5097
- config
5098
- );
5384
+ const acpContractClient = new _AcpContractClient(agentWalletAddress, config);
5099
5385
  await acpContractClient.init(walletPrivateKey, sessionEntityKeyId);
5100
5386
  return acpContractClient;
5101
5387
  }
@@ -5126,7 +5412,10 @@ var AcpContractClient = class _AcpContractClient extends baseAcpContractClient_d
5126
5412
  `ACP Contract Client validation failed: agent account ${this.agentWalletAddress} is not deployed on-chain`
5127
5413
  );
5128
5414
  }
5129
- await this.validateSessionKeyOnChain(sessionSignerAddress, sessionEntityKeyId);
5415
+ await this.validateSessionKeyOnChain(
5416
+ sessionSignerAddress,
5417
+ sessionEntityKeyId
5418
+ );
5130
5419
  console.log("Connected to ACP with v1 Contract Client (Legacy):", {
5131
5420
  agentWalletAddress: this.agentWalletAddress,
5132
5421
  whitelistedWalletAddress: sessionSignerAddress,
@@ -5196,7 +5485,9 @@ var AcpContractClient = class _AcpContractClient extends baseAcpContractClient_d
5196
5485
  throw new acpError_default(`Failed to send user operation`, finalError);
5197
5486
  }
5198
5487
  async getJobId(createJobUserOpHash, clientAddress, providerAddress) {
5199
- const result = await this.sessionKeyClient.getUserOperationReceipt(createJobUserOpHash);
5488
+ const result = await this.sessionKeyClient.getUserOperationReceipt(
5489
+ createJobUserOpHash
5490
+ );
5200
5491
  if (!result) {
5201
5492
  throw new acpError_default("Failed to get user operation receipt");
5202
5493
  }
@@ -5295,6 +5586,9 @@ var AcpContractClient = class _AcpContractClient extends baseAcpContractClient_d
5295
5586
  async performX402Request(url, version2, budget, signature) {
5296
5587
  return await this.acpX402.performRequest(url, version2, budget, signature);
5297
5588
  }
5589
+ async getAssetManager() {
5590
+ throw new Error("Asset Manager not supported");
5591
+ }
5298
5592
  getAcpVersion() {
5299
5593
  return "1";
5300
5594
  }
@@ -6011,83 +6305,1245 @@ var JOB_MANAGER_ABI = [
6011
6305
  var jobManagerAbi_default = JOB_MANAGER_ABI;
6012
6306
 
6013
6307
  // src/contractClients/acpContractClientV2.ts
6014
- var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClient_default {
6015
- constructor(jobManagerAddress, memoManagerAddress, accountManagerAddress, agentWalletAddress, config = baseAcpConfigV2) {
6016
- super(agentWalletAddress, config);
6017
- this.jobManagerAddress = jobManagerAddress;
6018
- this.memoManagerAddress = memoManagerAddress;
6019
- this.accountManagerAddress = accountManagerAddress;
6020
- this.PRIORITY_FEE_MULTIPLIER = 2;
6021
- this.MAX_FEE_PER_GAS = 2e7;
6022
- this.MAX_PRIORITY_FEE_PER_GAS = 21e6;
6023
- }
6024
- static async build(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfigV2) {
6025
- const publicClient = createPublicClient4({
6026
- chain: config.chain,
6027
- transport: http3(config.rpcEndpoint)
6028
- });
6029
- const [jobManagerAddress, memoManagerAddress, accountManagerAddress] = await publicClient.multicall({
6030
- contracts: [
6031
- {
6032
- address: config.contractAddress,
6033
- abi: config.abi,
6034
- functionName: "jobManager"
6035
- },
6036
- {
6037
- address: config.contractAddress,
6038
- abi: config.abi,
6039
- functionName: "memoManager"
6040
- },
6041
- {
6042
- address: config.contractAddress,
6043
- abi: config.abi,
6044
- functionName: "accountManager"
6045
- }
6046
- ]
6047
- });
6048
- if (!jobManagerAddress || !memoManagerAddress || !accountManagerAddress) {
6049
- throw new acpError_default(
6050
- "Failed to get job manager, memo manager, or account manager address"
6051
- );
6052
- }
6053
- const acpContractClient = new _AcpContractClientV2(
6054
- jobManagerAddress.result,
6055
- memoManagerAddress.result,
6056
- accountManagerAddress.result,
6057
- agentWalletAddress,
6058
- config
6059
- );
6060
- await acpContractClient.init(walletPrivateKey, sessionEntityKeyId);
6061
- return acpContractClient;
6062
- }
6063
- async init(privateKey, sessionEntityKeyId) {
6064
- const sessionKeySigner = LocalAccountSigner2.privateKeyToAccountSigner(privateKey);
6065
- this._sessionKeyClient = await createModularAccountV2Client2({
6066
- chain: this.chain,
6067
- transport: alchemy2({
6068
- rpcUrl: this.config.alchemyRpcUrl
6069
- }),
6070
- signer: sessionKeySigner,
6071
- policyId: "186aaa4a-5f57-4156-83fb-e456365a8820",
6072
- accountAddress: this.agentWalletAddress,
6073
- signerEntity: {
6074
- entityId: sessionEntityKeyId,
6075
- isGlobalValidation: true
6308
+ import { base as base4, baseSepolia as baseSepolia4 } from "viem/chains";
6309
+
6310
+ // src/abis/memoManagerAbi.ts
6311
+ var MEMO_MANAGER_ABI = [
6312
+ { inputs: [], stateMutability: "nonpayable", type: "constructor" },
6313
+ { inputs: [], name: "AccessControlBadConfirmation", type: "error" },
6314
+ {
6315
+ inputs: [
6316
+ { internalType: "address", name: "account", type: "address" },
6317
+ { internalType: "bytes32", name: "neededRole", type: "bytes32" }
6318
+ ],
6319
+ name: "AccessControlUnauthorizedAccount",
6320
+ type: "error"
6321
+ },
6322
+ {
6323
+ inputs: [{ internalType: "address", name: "target", type: "address" }],
6324
+ name: "AddressEmptyCode",
6325
+ type: "error"
6326
+ },
6327
+ { inputs: [], name: "AlreadyVoted", type: "error" },
6328
+ { inputs: [], name: "CannotApproveMemo", type: "error" },
6329
+ { inputs: [], name: "CannotUpdateApprovedMemo", type: "error" },
6330
+ { inputs: [], name: "CannotUpdateMemo", type: "error" },
6331
+ { inputs: [], name: "CannotWithdrawYet", type: "error" },
6332
+ { inputs: [], name: "DestinationChainNotConfigured", type: "error" },
6333
+ {
6334
+ inputs: [
6335
+ { internalType: "address", name: "implementation", type: "address" }
6336
+ ],
6337
+ name: "ERC1967InvalidImplementation",
6338
+ type: "error"
6339
+ },
6340
+ { inputs: [], name: "ERC1967NonPayable", type: "error" },
6341
+ { inputs: [], name: "EmptyContent", type: "error" },
6342
+ { inputs: [], name: "FailedInnerCall", type: "error" },
6343
+ { inputs: [], name: "InvalidInitialization", type: "error" },
6344
+ { inputs: [], name: "InvalidMemoState", type: "error" },
6345
+ { inputs: [], name: "InvalidMemoStateTransition", type: "error" },
6346
+ { inputs: [], name: "InvalidMemoType", type: "error" },
6347
+ { inputs: [], name: "JobAlreadyCompleted", type: "error" },
6348
+ { inputs: [], name: "JobDoesNotExist", type: "error" },
6349
+ { inputs: [], name: "MemoAlreadyApproved", type: "error" },
6350
+ { inputs: [], name: "MemoAlreadyExecuted", type: "error" },
6351
+ { inputs: [], name: "MemoAlreadySigned", type: "error" },
6352
+ { inputs: [], name: "MemoCannotBeSigned", type: "error" },
6353
+ { inputs: [], name: "MemoDoesNotExist", type: "error" },
6354
+ { inputs: [], name: "MemoDoesNotRequireApproval", type: "error" },
6355
+ { inputs: [], name: "MemoExpired", type: "error" },
6356
+ { inputs: [], name: "MemoNotApproved", type: "error" },
6357
+ { inputs: [], name: "MemoNotReadyToBeSigned", type: "error" },
6358
+ { inputs: [], name: "MemoStateUnchanged", type: "error" },
6359
+ { inputs: [], name: "NoAmountToTransfer", type: "error" },
6360
+ { inputs: [], name: "NoPaymentAmount", type: "error" },
6361
+ { inputs: [], name: "NotEscrowTransferMemoType", type: "error" },
6362
+ { inputs: [], name: "NotInitializing", type: "error" },
6363
+ { inputs: [], name: "NotPayableMemoType", type: "error" },
6364
+ { inputs: [], name: "OnlyACPContract", type: "error" },
6365
+ { inputs: [], name: "OnlyAssetManager", type: "error" },
6366
+ { inputs: [], name: "OnlyClientOrProvider", type: "error" },
6367
+ { inputs: [], name: "OnlyCounterParty", type: "error" },
6368
+ { inputs: [], name: "OnlyEvaluator", type: "error" },
6369
+ { inputs: [], name: "OnlyMemoSender", type: "error" },
6370
+ { inputs: [], name: "ReentrancyGuardReentrantCall", type: "error" },
6371
+ { inputs: [], name: "UUPSUnauthorizedCallContext", type: "error" },
6372
+ {
6373
+ inputs: [{ internalType: "bytes32", name: "slot", type: "bytes32" }],
6374
+ name: "UUPSUnsupportedProxiableUUID",
6375
+ type: "error"
6376
+ },
6377
+ { inputs: [], name: "ZeroAcpContractAddress", type: "error" },
6378
+ { inputs: [], name: "ZeroAddressRecipient", type: "error" },
6379
+ { inputs: [], name: "ZeroAddressToken", type: "error" },
6380
+ { inputs: [], name: "ZeroAssetManagerAddress", type: "error" },
6381
+ { inputs: [], name: "ZeroJobManagerAddress", type: "error" },
6382
+ {
6383
+ anonymous: false,
6384
+ inputs: [
6385
+ {
6386
+ indexed: false,
6387
+ internalType: "uint64",
6388
+ name: "version",
6389
+ type: "uint64"
6076
6390
  }
6077
- });
6078
- this._acpX402 = new AcpX402(
6079
- this.config,
6080
- this.sessionKeyClient,
6081
- this.publicClient
6082
- );
6083
- const account = this.sessionKeyClient.account;
6391
+ ],
6392
+ name: "Initialized",
6393
+ type: "event"
6394
+ },
6395
+ {
6396
+ anonymous: false,
6397
+ inputs: [
6398
+ {
6399
+ indexed: true,
6400
+ internalType: "uint256",
6401
+ name: "memoId",
6402
+ type: "uint256"
6403
+ },
6404
+ {
6405
+ indexed: true,
6406
+ internalType: "address",
6407
+ name: "approver",
6408
+ type: "address"
6409
+ },
6410
+ { indexed: false, internalType: "bool", name: "approved", type: "bool" },
6411
+ {
6412
+ indexed: false,
6413
+ internalType: "string",
6414
+ name: "reason",
6415
+ type: "string"
6416
+ }
6417
+ ],
6418
+ name: "MemoSigned",
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: false,
6432
+ internalType: "enum ACPTypes.MemoState",
6433
+ name: "oldState",
6434
+ type: "uint8"
6435
+ },
6436
+ {
6437
+ indexed: false,
6438
+ internalType: "enum ACPTypes.MemoState",
6439
+ name: "newState",
6440
+ type: "uint8"
6441
+ }
6442
+ ],
6443
+ name: "MemoStateUpdated",
6444
+ type: "event"
6445
+ },
6446
+ {
6447
+ anonymous: false,
6448
+ inputs: [
6449
+ {
6450
+ indexed: true,
6451
+ internalType: "uint256",
6452
+ name: "memoId",
6453
+ type: "uint256"
6454
+ },
6455
+ {
6456
+ indexed: true,
6457
+ internalType: "uint256",
6458
+ name: "jobId",
6459
+ type: "uint256"
6460
+ },
6461
+ {
6462
+ indexed: true,
6463
+ internalType: "address",
6464
+ name: "sender",
6465
+ type: "address"
6466
+ },
6467
+ {
6468
+ indexed: false,
6469
+ internalType: "enum ACPTypes.MemoType",
6470
+ name: "memoType",
6471
+ type: "uint8"
6472
+ },
6473
+ {
6474
+ indexed: false,
6475
+ internalType: "enum ACPTypes.JobPhase",
6476
+ name: "nextPhase",
6477
+ type: "uint8"
6478
+ },
6479
+ {
6480
+ indexed: false,
6481
+ internalType: "string",
6482
+ name: "content",
6483
+ type: "string"
6484
+ }
6485
+ ],
6486
+ name: "NewMemo",
6487
+ type: "event"
6488
+ },
6489
+ {
6490
+ anonymous: false,
6491
+ inputs: [
6492
+ {
6493
+ indexed: true,
6494
+ internalType: "uint256",
6495
+ name: "jobId",
6496
+ type: "uint256"
6497
+ },
6498
+ {
6499
+ indexed: true,
6500
+ internalType: "uint256",
6501
+ name: "memoId",
6502
+ type: "uint256"
6503
+ },
6504
+ {
6505
+ indexed: true,
6506
+ internalType: "address",
6507
+ name: "sender",
6508
+ type: "address"
6509
+ },
6510
+ {
6511
+ indexed: false,
6512
+ internalType: "address",
6513
+ name: "token",
6514
+ type: "address"
6515
+ },
6516
+ {
6517
+ indexed: false,
6518
+ internalType: "uint256",
6519
+ name: "amount",
6520
+ type: "uint256"
6521
+ }
6522
+ ],
6523
+ name: "PayableFeeRefunded",
6524
+ type: "event"
6525
+ },
6526
+ {
6527
+ anonymous: false,
6528
+ inputs: [
6529
+ {
6530
+ indexed: true,
6531
+ internalType: "uint256",
6532
+ name: "jobId",
6533
+ type: "uint256"
6534
+ },
6535
+ {
6536
+ indexed: true,
6537
+ internalType: "uint256",
6538
+ name: "memoId",
6539
+ type: "uint256"
6540
+ },
6541
+ {
6542
+ indexed: true,
6543
+ internalType: "address",
6544
+ name: "sender",
6545
+ type: "address"
6546
+ },
6547
+ {
6548
+ indexed: false,
6549
+ internalType: "address",
6550
+ name: "token",
6551
+ type: "address"
6552
+ },
6553
+ {
6554
+ indexed: false,
6555
+ internalType: "uint256",
6556
+ name: "amount",
6557
+ type: "uint256"
6558
+ }
6559
+ ],
6560
+ name: "PayableFundsRefunded",
6561
+ type: "event"
6562
+ },
6563
+ {
6564
+ anonymous: false,
6565
+ inputs: [
6566
+ {
6567
+ indexed: true,
6568
+ internalType: "uint256",
6569
+ name: "memoId",
6570
+ type: "uint256"
6571
+ },
6572
+ {
6573
+ indexed: true,
6574
+ internalType: "uint256",
6575
+ name: "jobId",
6576
+ type: "uint256"
6577
+ },
6578
+ {
6579
+ indexed: true,
6580
+ internalType: "address",
6581
+ name: "executor",
6582
+ type: "address"
6583
+ },
6584
+ {
6585
+ indexed: false,
6586
+ internalType: "uint256",
6587
+ name: "amount",
6588
+ type: "uint256"
6589
+ }
6590
+ ],
6591
+ name: "PayableMemoExecuted",
6592
+ type: "event"
6593
+ },
6594
+ {
6595
+ anonymous: false,
6596
+ inputs: [
6597
+ { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
6598
+ {
6599
+ indexed: true,
6600
+ internalType: "bytes32",
6601
+ name: "previousAdminRole",
6602
+ type: "bytes32"
6603
+ },
6604
+ {
6605
+ indexed: true,
6606
+ internalType: "bytes32",
6607
+ name: "newAdminRole",
6608
+ type: "bytes32"
6609
+ }
6610
+ ],
6611
+ name: "RoleAdminChanged",
6612
+ type: "event"
6613
+ },
6614
+ {
6615
+ anonymous: false,
6616
+ inputs: [
6617
+ { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
6618
+ {
6619
+ indexed: true,
6620
+ internalType: "address",
6621
+ name: "account",
6622
+ type: "address"
6623
+ },
6624
+ {
6625
+ indexed: true,
6626
+ internalType: "address",
6627
+ name: "sender",
6628
+ type: "address"
6629
+ }
6630
+ ],
6631
+ name: "RoleGranted",
6632
+ type: "event"
6633
+ },
6634
+ {
6635
+ anonymous: false,
6636
+ inputs: [
6637
+ { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
6638
+ {
6639
+ indexed: true,
6640
+ internalType: "address",
6641
+ name: "account",
6642
+ type: "address"
6643
+ },
6644
+ {
6645
+ indexed: true,
6646
+ internalType: "address",
6647
+ name: "sender",
6648
+ type: "address"
6649
+ }
6650
+ ],
6651
+ name: "RoleRevoked",
6652
+ type: "event"
6653
+ },
6654
+ {
6655
+ anonymous: false,
6656
+ inputs: [
6657
+ {
6658
+ indexed: true,
6659
+ internalType: "address",
6660
+ name: "implementation",
6661
+ type: "address"
6662
+ }
6663
+ ],
6664
+ name: "Upgraded",
6665
+ type: "event"
6666
+ },
6667
+ {
6668
+ inputs: [],
6669
+ name: "ACP_CONTRACT_ROLE",
6670
+ outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
6671
+ stateMutability: "view",
6672
+ type: "function"
6673
+ },
6674
+ {
6675
+ inputs: [],
6676
+ name: "ADMIN_ROLE",
6677
+ outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
6678
+ stateMutability: "view",
6679
+ type: "function"
6680
+ },
6681
+ {
6682
+ inputs: [],
6683
+ name: "DEFAULT_ADMIN_ROLE",
6684
+ outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
6685
+ stateMutability: "view",
6686
+ type: "function"
6687
+ },
6688
+ {
6689
+ inputs: [],
6690
+ name: "UPGRADE_INTERFACE_VERSION",
6691
+ outputs: [{ internalType: "string", name: "", type: "string" }],
6692
+ stateMutability: "view",
6693
+ type: "function"
6694
+ },
6695
+ {
6696
+ inputs: [],
6697
+ name: "acpContract",
6698
+ outputs: [{ internalType: "address", name: "", type: "address" }],
6699
+ stateMutability: "view",
6700
+ type: "function"
6701
+ },
6702
+ {
6703
+ inputs: [
6704
+ { internalType: "uint256", name: "memoId", type: "uint256" },
6705
+ { internalType: "address", name: "sender", type: "address" },
6706
+ { internalType: "bool", name: "approved", type: "bool" },
6707
+ { internalType: "string", name: "reason", type: "string" }
6708
+ ],
6709
+ name: "approveMemo",
6710
+ outputs: [],
6711
+ stateMutability: "nonpayable",
6712
+ type: "function"
6713
+ },
6714
+ {
6715
+ inputs: [],
6716
+ name: "assetManager",
6717
+ outputs: [{ internalType: "address", name: "", type: "address" }],
6718
+ stateMutability: "view",
6719
+ type: "function"
6720
+ },
6721
+ {
6722
+ inputs: [
6723
+ { internalType: "uint256[]", name: "memoIds", type: "uint256[]" },
6724
+ { internalType: "bool", name: "approved", type: "bool" },
6725
+ { internalType: "string", name: "reason", type: "string" }
6726
+ ],
6727
+ name: "bulkApproveMemos",
6728
+ outputs: [],
6729
+ stateMutability: "nonpayable",
6730
+ type: "function"
6731
+ },
6732
+ {
6733
+ inputs: [
6734
+ { internalType: "uint256", name: "memoId", type: "uint256" },
6735
+ { internalType: "address", name: "user", type: "address" }
6736
+ ],
6737
+ name: "canApproveMemo",
6738
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
6739
+ stateMutability: "view",
6740
+ type: "function"
6741
+ },
6742
+ {
6743
+ inputs: [
6744
+ { internalType: "uint256", name: "jobId", type: "uint256" },
6745
+ { internalType: "address", name: "sender", type: "address" },
6746
+ { internalType: "string", name: "content", type: "string" },
6747
+ {
6748
+ internalType: "enum ACPTypes.MemoType",
6749
+ name: "memoType",
6750
+ type: "uint8"
6751
+ },
6752
+ { internalType: "bool", name: "isSecured", type: "bool" },
6753
+ {
6754
+ internalType: "enum ACPTypes.JobPhase",
6755
+ name: "nextPhase",
6756
+ type: "uint8"
6757
+ },
6758
+ { internalType: "string", name: "metadata", type: "string" }
6759
+ ],
6760
+ name: "createMemo",
6761
+ outputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
6762
+ stateMutability: "nonpayable",
6763
+ type: "function"
6764
+ },
6765
+ {
6766
+ inputs: [
6767
+ { internalType: "uint256", name: "jobId", type: "uint256" },
6768
+ { internalType: "address", name: "sender", type: "address" },
6769
+ { internalType: "string", name: "content", type: "string" },
6770
+ {
6771
+ internalType: "enum ACPTypes.MemoType",
6772
+ name: "memoType",
6773
+ type: "uint8"
6774
+ },
6775
+ { internalType: "bool", name: "isSecured", type: "bool" },
6776
+ {
6777
+ internalType: "enum ACPTypes.JobPhase",
6778
+ name: "nextPhase",
6779
+ type: "uint8"
6780
+ },
6781
+ {
6782
+ components: [
6783
+ { internalType: "address", name: "token", type: "address" },
6784
+ { internalType: "uint256", name: "amount", type: "uint256" },
6785
+ { internalType: "address", name: "recipient", type: "address" },
6786
+ { internalType: "uint256", name: "feeAmount", type: "uint256" },
6787
+ {
6788
+ internalType: "enum ACPTypes.FeeType",
6789
+ name: "feeType",
6790
+ type: "uint8"
6791
+ },
6792
+ { internalType: "bool", name: "isExecuted", type: "bool" },
6793
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
6794
+ { internalType: "uint32", name: "lzSrcEid", type: "uint32" },
6795
+ { internalType: "uint32", name: "lzDstEid", type: "uint32" }
6796
+ ],
6797
+ internalType: "struct ACPTypes.PayableDetails",
6798
+ name: "payableDetails_",
6799
+ type: "tuple"
6800
+ },
6801
+ { internalType: "uint256", name: "expiredAt", type: "uint256" }
6802
+ ],
6803
+ name: "createPayableMemo",
6804
+ outputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
6805
+ stateMutability: "nonpayable",
6806
+ type: "function"
6807
+ },
6808
+ {
6809
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
6810
+ name: "emergencyApproveMemo",
6811
+ outputs: [],
6812
+ stateMutability: "nonpayable",
6813
+ type: "function"
6814
+ },
6815
+ {
6816
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
6817
+ name: "executePayableMemo",
6818
+ outputs: [],
6819
+ stateMutability: "nonpayable",
6820
+ type: "function"
6821
+ },
6822
+ {
6823
+ inputs: [],
6824
+ name: "getAssetManager",
6825
+ outputs: [{ internalType: "address", name: "", type: "address" }],
6826
+ stateMutability: "view",
6827
+ type: "function"
6828
+ },
6829
+ {
6830
+ inputs: [
6831
+ { internalType: "uint256", name: "jobId", type: "uint256" },
6832
+ { internalType: "uint256", name: "offset", type: "uint256" },
6833
+ { internalType: "uint256", name: "limit", type: "uint256" }
6834
+ ],
6835
+ name: "getJobMemos",
6836
+ outputs: [
6837
+ {
6838
+ components: [
6839
+ { internalType: "uint256", name: "id", type: "uint256" },
6840
+ { internalType: "uint256", name: "jobId", type: "uint256" },
6841
+ { internalType: "address", name: "sender", type: "address" },
6842
+ { internalType: "string", name: "content", type: "string" },
6843
+ {
6844
+ internalType: "enum ACPTypes.MemoType",
6845
+ name: "memoType",
6846
+ type: "uint8"
6847
+ },
6848
+ { internalType: "uint256", name: "createdAt", type: "uint256" },
6849
+ { internalType: "bool", name: "isApproved", type: "bool" },
6850
+ { internalType: "address", name: "approvedBy", type: "address" },
6851
+ { internalType: "uint256", name: "approvedAt", type: "uint256" },
6852
+ { internalType: "bool", name: "requiresApproval", type: "bool" },
6853
+ { internalType: "string", name: "metadata", type: "string" },
6854
+ { internalType: "bool", name: "isSecured", type: "bool" },
6855
+ {
6856
+ internalType: "enum ACPTypes.JobPhase",
6857
+ name: "nextPhase",
6858
+ type: "uint8"
6859
+ },
6860
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
6861
+ {
6862
+ internalType: "enum ACPTypes.MemoState",
6863
+ name: "state",
6864
+ type: "uint8"
6865
+ }
6866
+ ],
6867
+ internalType: "struct ACPTypes.Memo[]",
6868
+ name: "memoArray",
6869
+ type: "tuple[]"
6870
+ },
6871
+ { internalType: "uint256", name: "total", type: "uint256" }
6872
+ ],
6873
+ stateMutability: "view",
6874
+ type: "function"
6875
+ },
6876
+ {
6877
+ inputs: [
6878
+ { internalType: "uint256", name: "jobId", type: "uint256" },
6879
+ { internalType: "enum ACPTypes.JobPhase", name: "phase", type: "uint8" },
6880
+ { internalType: "uint256", name: "offset", type: "uint256" },
6881
+ { internalType: "uint256", name: "limit", type: "uint256" }
6882
+ ],
6883
+ name: "getJobMemosByPhase",
6884
+ outputs: [
6885
+ {
6886
+ components: [
6887
+ { internalType: "uint256", name: "id", type: "uint256" },
6888
+ { internalType: "uint256", name: "jobId", type: "uint256" },
6889
+ { internalType: "address", name: "sender", type: "address" },
6890
+ { internalType: "string", name: "content", type: "string" },
6891
+ {
6892
+ internalType: "enum ACPTypes.MemoType",
6893
+ name: "memoType",
6894
+ type: "uint8"
6895
+ },
6896
+ { internalType: "uint256", name: "createdAt", type: "uint256" },
6897
+ { internalType: "bool", name: "isApproved", type: "bool" },
6898
+ { internalType: "address", name: "approvedBy", type: "address" },
6899
+ { internalType: "uint256", name: "approvedAt", type: "uint256" },
6900
+ { internalType: "bool", name: "requiresApproval", type: "bool" },
6901
+ { internalType: "string", name: "metadata", type: "string" },
6902
+ { internalType: "bool", name: "isSecured", type: "bool" },
6903
+ {
6904
+ internalType: "enum ACPTypes.JobPhase",
6905
+ name: "nextPhase",
6906
+ type: "uint8"
6907
+ },
6908
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
6909
+ {
6910
+ internalType: "enum ACPTypes.MemoState",
6911
+ name: "state",
6912
+ type: "uint8"
6913
+ }
6914
+ ],
6915
+ internalType: "struct ACPTypes.Memo[]",
6916
+ name: "memoArray",
6917
+ type: "tuple[]"
6918
+ },
6919
+ { internalType: "uint256", name: "total", type: "uint256" }
6920
+ ],
6921
+ stateMutability: "view",
6922
+ type: "function"
6923
+ },
6924
+ {
6925
+ inputs: [
6926
+ { internalType: "uint256", name: "jobId", type: "uint256" },
6927
+ {
6928
+ internalType: "enum ACPTypes.MemoType",
6929
+ name: "memoType",
6930
+ type: "uint8"
6931
+ },
6932
+ { internalType: "uint256", name: "offset", type: "uint256" },
6933
+ { internalType: "uint256", name: "limit", type: "uint256" }
6934
+ ],
6935
+ name: "getJobMemosByType",
6936
+ outputs: [
6937
+ {
6938
+ components: [
6939
+ { internalType: "uint256", name: "id", type: "uint256" },
6940
+ { internalType: "uint256", name: "jobId", type: "uint256" },
6941
+ { internalType: "address", name: "sender", type: "address" },
6942
+ { internalType: "string", name: "content", type: "string" },
6943
+ {
6944
+ internalType: "enum ACPTypes.MemoType",
6945
+ name: "memoType",
6946
+ type: "uint8"
6947
+ },
6948
+ { internalType: "uint256", name: "createdAt", type: "uint256" },
6949
+ { internalType: "bool", name: "isApproved", type: "bool" },
6950
+ { internalType: "address", name: "approvedBy", type: "address" },
6951
+ { internalType: "uint256", name: "approvedAt", type: "uint256" },
6952
+ { internalType: "bool", name: "requiresApproval", type: "bool" },
6953
+ { internalType: "string", name: "metadata", type: "string" },
6954
+ { internalType: "bool", name: "isSecured", type: "bool" },
6955
+ {
6956
+ internalType: "enum ACPTypes.JobPhase",
6957
+ name: "nextPhase",
6958
+ type: "uint8"
6959
+ },
6960
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
6961
+ {
6962
+ internalType: "enum ACPTypes.MemoState",
6963
+ name: "state",
6964
+ type: "uint8"
6965
+ }
6966
+ ],
6967
+ internalType: "struct ACPTypes.Memo[]",
6968
+ name: "memoArray",
6969
+ type: "tuple[]"
6970
+ },
6971
+ { internalType: "uint256", name: "total", type: "uint256" }
6972
+ ],
6973
+ stateMutability: "view",
6974
+ type: "function"
6975
+ },
6976
+ {
6977
+ inputs: [],
6978
+ name: "getLocalEid",
6979
+ outputs: [{ internalType: "uint32", name: "", type: "uint32" }],
6980
+ stateMutability: "view",
6981
+ type: "function"
6982
+ },
6983
+ {
6984
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
6985
+ name: "getMemo",
6986
+ outputs: [
6987
+ {
6988
+ components: [
6989
+ { internalType: "uint256", name: "id", type: "uint256" },
6990
+ { internalType: "uint256", name: "jobId", type: "uint256" },
6991
+ { internalType: "address", name: "sender", type: "address" },
6992
+ { internalType: "string", name: "content", type: "string" },
6993
+ {
6994
+ internalType: "enum ACPTypes.MemoType",
6995
+ name: "memoType",
6996
+ type: "uint8"
6997
+ },
6998
+ { internalType: "uint256", name: "createdAt", type: "uint256" },
6999
+ { internalType: "bool", name: "isApproved", type: "bool" },
7000
+ { internalType: "address", name: "approvedBy", type: "address" },
7001
+ { internalType: "uint256", name: "approvedAt", type: "uint256" },
7002
+ { internalType: "bool", name: "requiresApproval", type: "bool" },
7003
+ { internalType: "string", name: "metadata", type: "string" },
7004
+ { internalType: "bool", name: "isSecured", type: "bool" },
7005
+ {
7006
+ internalType: "enum ACPTypes.JobPhase",
7007
+ name: "nextPhase",
7008
+ type: "uint8"
7009
+ },
7010
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
7011
+ {
7012
+ internalType: "enum ACPTypes.MemoState",
7013
+ name: "state",
7014
+ type: "uint8"
7015
+ }
7016
+ ],
7017
+ internalType: "struct ACPTypes.Memo",
7018
+ name: "",
7019
+ type: "tuple"
7020
+ }
7021
+ ],
7022
+ stateMutability: "view",
7023
+ type: "function"
7024
+ },
7025
+ {
7026
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
7027
+ name: "getMemoApprovalStatus",
7028
+ outputs: [
7029
+ { internalType: "bool", name: "isApproved", type: "bool" },
7030
+ { internalType: "address", name: "approvedBy", type: "address" },
7031
+ { internalType: "uint256", name: "approvedAt", type: "uint256" }
7032
+ ],
7033
+ stateMutability: "view",
7034
+ type: "function"
7035
+ },
7036
+ {
7037
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
7038
+ name: "getMemoWithPayableDetails",
7039
+ outputs: [
7040
+ {
7041
+ components: [
7042
+ { internalType: "uint256", name: "id", type: "uint256" },
7043
+ { internalType: "uint256", name: "jobId", type: "uint256" },
7044
+ { internalType: "address", name: "sender", type: "address" },
7045
+ { internalType: "string", name: "content", type: "string" },
7046
+ {
7047
+ internalType: "enum ACPTypes.MemoType",
7048
+ name: "memoType",
7049
+ type: "uint8"
7050
+ },
7051
+ { internalType: "uint256", name: "createdAt", type: "uint256" },
7052
+ { internalType: "bool", name: "isApproved", type: "bool" },
7053
+ { internalType: "address", name: "approvedBy", type: "address" },
7054
+ { internalType: "uint256", name: "approvedAt", type: "uint256" },
7055
+ { internalType: "bool", name: "requiresApproval", type: "bool" },
7056
+ { internalType: "string", name: "metadata", type: "string" },
7057
+ { internalType: "bool", name: "isSecured", type: "bool" },
7058
+ {
7059
+ internalType: "enum ACPTypes.JobPhase",
7060
+ name: "nextPhase",
7061
+ type: "uint8"
7062
+ },
7063
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
7064
+ {
7065
+ internalType: "enum ACPTypes.MemoState",
7066
+ name: "state",
7067
+ type: "uint8"
7068
+ }
7069
+ ],
7070
+ internalType: "struct ACPTypes.Memo",
7071
+ name: "memo",
7072
+ type: "tuple"
7073
+ },
7074
+ {
7075
+ components: [
7076
+ { internalType: "address", name: "token", type: "address" },
7077
+ { internalType: "uint256", name: "amount", type: "uint256" },
7078
+ { internalType: "address", name: "recipient", type: "address" },
7079
+ { internalType: "uint256", name: "feeAmount", type: "uint256" },
7080
+ {
7081
+ internalType: "enum ACPTypes.FeeType",
7082
+ name: "feeType",
7083
+ type: "uint8"
7084
+ },
7085
+ { internalType: "bool", name: "isExecuted", type: "bool" },
7086
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
7087
+ { internalType: "uint32", name: "lzSrcEid", type: "uint32" },
7088
+ { internalType: "uint32", name: "lzDstEid", type: "uint32" }
7089
+ ],
7090
+ internalType: "struct ACPTypes.PayableDetails",
7091
+ name: "details",
7092
+ type: "tuple"
7093
+ }
7094
+ ],
7095
+ stateMutability: "view",
7096
+ type: "function"
7097
+ },
7098
+ {
7099
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
7100
+ name: "getPayableDetails",
7101
+ outputs: [
7102
+ {
7103
+ components: [
7104
+ { internalType: "address", name: "token", type: "address" },
7105
+ { internalType: "uint256", name: "amount", type: "uint256" },
7106
+ { internalType: "address", name: "recipient", type: "address" },
7107
+ { internalType: "uint256", name: "feeAmount", type: "uint256" },
7108
+ {
7109
+ internalType: "enum ACPTypes.FeeType",
7110
+ name: "feeType",
7111
+ type: "uint8"
7112
+ },
7113
+ { internalType: "bool", name: "isExecuted", type: "bool" },
7114
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
7115
+ { internalType: "uint32", name: "lzSrcEid", type: "uint32" },
7116
+ { internalType: "uint32", name: "lzDstEid", type: "uint32" }
7117
+ ],
7118
+ internalType: "struct ACPTypes.PayableDetails",
7119
+ name: "",
7120
+ type: "tuple"
7121
+ }
7122
+ ],
7123
+ stateMutability: "view",
7124
+ type: "function"
7125
+ },
7126
+ {
7127
+ inputs: [{ internalType: "bytes32", name: "role", type: "bytes32" }],
7128
+ name: "getRoleAdmin",
7129
+ outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
7130
+ stateMutability: "view",
7131
+ type: "function"
7132
+ },
7133
+ {
7134
+ inputs: [
7135
+ { internalType: "bytes32", name: "role", type: "bytes32" },
7136
+ { internalType: "address", name: "account", type: "address" }
7137
+ ],
7138
+ name: "grantRole",
7139
+ outputs: [],
7140
+ stateMutability: "nonpayable",
7141
+ type: "function"
7142
+ },
7143
+ {
7144
+ inputs: [
7145
+ { internalType: "bytes32", name: "role", type: "bytes32" },
7146
+ { internalType: "address", name: "account", type: "address" }
7147
+ ],
7148
+ name: "hasRole",
7149
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
7150
+ stateMutability: "view",
7151
+ type: "function"
7152
+ },
7153
+ {
7154
+ inputs: [
7155
+ { internalType: "address", name: "acpContract_", type: "address" },
7156
+ { internalType: "address", name: "jobManager_", type: "address" },
7157
+ { internalType: "address", name: "paymentManager_", type: "address" }
7158
+ ],
7159
+ name: "initialize",
7160
+ outputs: [],
7161
+ stateMutability: "nonpayable",
7162
+ type: "function"
7163
+ },
7164
+ {
7165
+ inputs: [
7166
+ { internalType: "uint256", name: "jobId", type: "uint256" },
7167
+ { internalType: "address", name: "user", type: "address" }
7168
+ ],
7169
+ name: "isJobEvaluator",
7170
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
7171
+ stateMutability: "view",
7172
+ type: "function"
7173
+ },
7174
+ {
7175
+ inputs: [
7176
+ { internalType: "uint256", name: "memoId", type: "uint256" },
7177
+ { internalType: "address", name: "user", type: "address" }
7178
+ ],
7179
+ name: "isMemoSigner",
7180
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
7181
+ stateMutability: "view",
7182
+ type: "function"
7183
+ },
7184
+ {
7185
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
7186
+ name: "isPayable",
7187
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
7188
+ stateMutability: "view",
7189
+ type: "function"
7190
+ },
7191
+ {
7192
+ inputs: [],
7193
+ name: "jobManager",
7194
+ outputs: [{ internalType: "address", name: "", type: "address" }],
7195
+ stateMutability: "view",
7196
+ type: "function"
7197
+ },
7198
+ {
7199
+ inputs: [
7200
+ { internalType: "uint256", name: "", type: "uint256" },
7201
+ { internalType: "uint256", name: "", type: "uint256" }
7202
+ ],
7203
+ name: "jobMemos",
7204
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7205
+ stateMutability: "view",
7206
+ type: "function"
7207
+ },
7208
+ {
7209
+ inputs: [
7210
+ { internalType: "uint256", name: "", type: "uint256" },
7211
+ { internalType: "enum ACPTypes.JobPhase", name: "", type: "uint8" },
7212
+ { internalType: "uint256", name: "", type: "uint256" }
7213
+ ],
7214
+ name: "jobMemosByPhase",
7215
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7216
+ stateMutability: "view",
7217
+ type: "function"
7218
+ },
7219
+ {
7220
+ inputs: [
7221
+ { internalType: "uint256", name: "", type: "uint256" },
7222
+ { internalType: "enum ACPTypes.MemoType", name: "", type: "uint8" },
7223
+ { internalType: "uint256", name: "", type: "uint256" }
7224
+ ],
7225
+ name: "jobMemosByType",
7226
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7227
+ stateMutability: "view",
7228
+ type: "function"
7229
+ },
7230
+ {
7231
+ inputs: [
7232
+ { internalType: "uint256", name: "", type: "uint256" },
7233
+ { internalType: "address", name: "", type: "address" }
7234
+ ],
7235
+ name: "memoApprovals",
7236
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
7237
+ stateMutability: "view",
7238
+ type: "function"
7239
+ },
7240
+ {
7241
+ inputs: [],
7242
+ name: "memoCounter",
7243
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7244
+ stateMutability: "view",
7245
+ type: "function"
7246
+ },
7247
+ {
7248
+ inputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7249
+ name: "memos",
7250
+ outputs: [
7251
+ { internalType: "uint256", name: "id", type: "uint256" },
7252
+ { internalType: "uint256", name: "jobId", type: "uint256" },
7253
+ { internalType: "address", name: "sender", type: "address" },
7254
+ { internalType: "string", name: "content", type: "string" },
7255
+ {
7256
+ internalType: "enum ACPTypes.MemoType",
7257
+ name: "memoType",
7258
+ type: "uint8"
7259
+ },
7260
+ { internalType: "uint256", name: "createdAt", type: "uint256" },
7261
+ { internalType: "bool", name: "isApproved", type: "bool" },
7262
+ { internalType: "address", name: "approvedBy", type: "address" },
7263
+ { internalType: "uint256", name: "approvedAt", type: "uint256" },
7264
+ { internalType: "bool", name: "requiresApproval", type: "bool" },
7265
+ { internalType: "string", name: "metadata", type: "string" },
7266
+ { internalType: "bool", name: "isSecured", type: "bool" },
7267
+ {
7268
+ internalType: "enum ACPTypes.JobPhase",
7269
+ name: "nextPhase",
7270
+ type: "uint8"
7271
+ },
7272
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
7273
+ { internalType: "enum ACPTypes.MemoState", name: "state", type: "uint8" }
7274
+ ],
7275
+ stateMutability: "view",
7276
+ type: "function"
7277
+ },
7278
+ {
7279
+ inputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7280
+ name: "payableDetails",
7281
+ outputs: [
7282
+ { internalType: "address", name: "token", type: "address" },
7283
+ { internalType: "uint256", name: "amount", type: "uint256" },
7284
+ { internalType: "address", name: "recipient", type: "address" },
7285
+ { internalType: "uint256", name: "feeAmount", type: "uint256" },
7286
+ { internalType: "enum ACPTypes.FeeType", name: "feeType", type: "uint8" },
7287
+ { internalType: "bool", name: "isExecuted", type: "bool" },
7288
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
7289
+ { internalType: "uint32", name: "lzSrcEid", type: "uint32" },
7290
+ { internalType: "uint32", name: "lzDstEid", type: "uint32" }
7291
+ ],
7292
+ stateMutability: "view",
7293
+ type: "function"
7294
+ },
7295
+ {
7296
+ inputs: [],
7297
+ name: "paymentManager",
7298
+ outputs: [{ internalType: "address", name: "", type: "address" }],
7299
+ stateMutability: "view",
7300
+ type: "function"
7301
+ },
7302
+ {
7303
+ inputs: [],
7304
+ name: "proxiableUUID",
7305
+ outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
7306
+ stateMutability: "view",
7307
+ type: "function"
7308
+ },
7309
+ {
7310
+ inputs: [
7311
+ { internalType: "bytes32", name: "role", type: "bytes32" },
7312
+ { internalType: "address", name: "callerConfirmation", type: "address" }
7313
+ ],
7314
+ name: "renounceRole",
7315
+ outputs: [],
7316
+ stateMutability: "nonpayable",
7317
+ type: "function"
7318
+ },
7319
+ {
7320
+ inputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7321
+ name: "requiredApprovals",
7322
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7323
+ stateMutability: "view",
7324
+ type: "function"
7325
+ },
7326
+ {
7327
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
7328
+ name: "requiresApproval",
7329
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
7330
+ stateMutability: "view",
7331
+ type: "function"
7332
+ },
7333
+ {
7334
+ inputs: [
7335
+ { internalType: "bytes32", name: "role", type: "bytes32" },
7336
+ { internalType: "address", name: "account", type: "address" }
7337
+ ],
7338
+ name: "revokeRole",
7339
+ outputs: [],
7340
+ stateMutability: "nonpayable",
7341
+ type: "function"
7342
+ },
7343
+ {
7344
+ inputs: [
7345
+ {
7346
+ internalType: "enum ACPTypes.MemoType",
7347
+ name: "memoType",
7348
+ type: "uint8"
7349
+ },
7350
+ { internalType: "uint256", name: "requiredApprovals_", type: "uint256" }
7351
+ ],
7352
+ name: "setApprovalRequirements",
7353
+ outputs: [],
7354
+ stateMutability: "nonpayable",
7355
+ type: "function"
7356
+ },
7357
+ {
7358
+ inputs: [
7359
+ { internalType: "address", name: "assetManager_", type: "address" }
7360
+ ],
7361
+ name: "setAssetManager",
7362
+ outputs: [],
7363
+ stateMutability: "nonpayable",
7364
+ type: "function"
7365
+ },
7366
+ {
7367
+ inputs: [
7368
+ { internalType: "uint256", name: "memoId", type: "uint256" },
7369
+ { internalType: "address", name: "sender", type: "address" },
7370
+ { internalType: "bool", name: "isApproved", type: "bool" },
7371
+ { internalType: "string", name: "reason", type: "string" }
7372
+ ],
7373
+ name: "signMemo",
7374
+ outputs: [{ internalType: "uint256", name: "jobId", type: "uint256" }],
7375
+ stateMutability: "nonpayable",
7376
+ type: "function"
7377
+ },
7378
+ {
7379
+ inputs: [{ internalType: "bytes4", name: "interfaceId", type: "bytes4" }],
7380
+ name: "supportsInterface",
7381
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
7382
+ stateMutability: "view",
7383
+ type: "function"
7384
+ },
7385
+ {
7386
+ inputs: [
7387
+ { internalType: "address", name: "acpContract_", type: "address" },
7388
+ { internalType: "address", name: "jobManager_", type: "address" },
7389
+ { internalType: "address", name: "paymentManager_", type: "address" },
7390
+ { internalType: "address", name: "assetManager_", type: "address" }
7391
+ ],
7392
+ name: "updateContracts",
7393
+ outputs: [],
7394
+ stateMutability: "nonpayable",
7395
+ type: "function"
7396
+ },
7397
+ {
7398
+ inputs: [
7399
+ { internalType: "uint256", name: "memoId", type: "uint256" },
7400
+ { internalType: "string", name: "newContent", type: "string" }
7401
+ ],
7402
+ name: "updateMemoContent",
7403
+ outputs: [],
7404
+ stateMutability: "nonpayable",
7405
+ type: "function"
7406
+ },
7407
+ {
7408
+ inputs: [
7409
+ { internalType: "uint256", name: "memoId", type: "uint256" },
7410
+ {
7411
+ internalType: "enum ACPTypes.MemoState",
7412
+ name: "newMemoState",
7413
+ type: "uint8"
7414
+ }
7415
+ ],
7416
+ name: "updateMemoState",
7417
+ outputs: [],
7418
+ stateMutability: "nonpayable",
7419
+ type: "function"
7420
+ },
7421
+ {
7422
+ inputs: [
7423
+ { internalType: "address", name: "newImplementation", type: "address" },
7424
+ { internalType: "bytes", name: "data", type: "bytes" }
7425
+ ],
7426
+ name: "upgradeToAndCall",
7427
+ outputs: [],
7428
+ stateMutability: "payable",
7429
+ type: "function"
7430
+ },
7431
+ {
7432
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
7433
+ name: "withdrawEscrowedFunds",
7434
+ outputs: [],
7435
+ stateMutability: "nonpayable",
7436
+ type: "function"
7437
+ }
7438
+ ];
7439
+ var memoManagerAbi_default = MEMO_MANAGER_ABI;
7440
+
7441
+ // src/contractClients/acpContractClientV2.ts
7442
+ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClient_default {
7443
+ constructor(jobManagerAddress, memoManagerAddress, accountManagerAddress, agentWalletAddress, config = baseAcpConfigV2) {
7444
+ super(agentWalletAddress, config);
7445
+ this.jobManagerAddress = jobManagerAddress;
7446
+ this.memoManagerAddress = memoManagerAddress;
7447
+ this.accountManagerAddress = accountManagerAddress;
7448
+ this.PRIORITY_FEE_MULTIPLIER = 2;
7449
+ this.MAX_FEE_PER_GAS = 2e7;
7450
+ this.MAX_PRIORITY_FEE_PER_GAS = 21e6;
7451
+ this.GAS_FEE_MULTIPLIER = 0.5;
7452
+ this._sessionKeyClients = {};
7453
+ }
7454
+ static async build(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfigV2) {
7455
+ const publicClients = {};
7456
+ for (const chain of config.chains) {
7457
+ publicClients[chain.chain.id] = createPublicClient4({
7458
+ chain: chain.chain,
7459
+ transport: http3(chain.rpcUrl)
7460
+ });
7461
+ }
7462
+ const publicClient = createPublicClient4({
7463
+ chain: config.chain,
7464
+ transport: http3(config.rpcEndpoint)
7465
+ });
7466
+ const [jobManagerAddress, memoManagerAddress, accountManagerAddress] = await publicClient.multicall({
7467
+ contracts: [
7468
+ {
7469
+ address: config.contractAddress,
7470
+ abi: config.abi,
7471
+ functionName: "jobManager"
7472
+ },
7473
+ {
7474
+ address: config.contractAddress,
7475
+ abi: config.abi,
7476
+ functionName: "memoManager"
7477
+ },
7478
+ {
7479
+ address: config.contractAddress,
7480
+ abi: config.abi,
7481
+ functionName: "accountManager"
7482
+ }
7483
+ ]
7484
+ });
7485
+ if (!jobManagerAddress || !memoManagerAddress || !accountManagerAddress) {
7486
+ throw new acpError_default(
7487
+ "Failed to get job manager, memo manager, or account manager address"
7488
+ );
7489
+ }
7490
+ const acpContractClient = new _AcpContractClientV2(
7491
+ jobManagerAddress.result,
7492
+ memoManagerAddress.result,
7493
+ accountManagerAddress.result,
7494
+ agentWalletAddress,
7495
+ config
7496
+ );
7497
+ acpContractClient.publicClients = publicClients;
7498
+ await acpContractClient.init(walletPrivateKey, sessionEntityKeyId);
7499
+ return acpContractClient;
7500
+ }
7501
+ async init(privateKey, sessionEntityKeyId) {
7502
+ const sessionKeySigner = LocalAccountSigner2.privateKeyToAccountSigner(privateKey);
7503
+ this._sessionKeyClient = await createModularAccountV2Client2({
7504
+ chain: this.chain,
7505
+ transport: alchemy2({
7506
+ rpcUrl: this.config.alchemyRpcUrl
7507
+ }),
7508
+ signer: sessionKeySigner,
7509
+ policyId: "186aaa4a-5f57-4156-83fb-e456365a8820",
7510
+ accountAddress: this.agentWalletAddress,
7511
+ signerEntity: {
7512
+ entityId: sessionEntityKeyId,
7513
+ isGlobalValidation: true
7514
+ }
7515
+ });
7516
+ for (const chain of this.config.chains) {
7517
+ this._sessionKeyClients[chain.chain.id] = await createModularAccountV2Client2({
7518
+ chain: chain.chain,
7519
+ transport: alchemy2({
7520
+ rpcUrl: `${this.config.alchemyRpcUrl}?chainId=${chain.chain.id}`
7521
+ }),
7522
+ signer: sessionKeySigner,
7523
+ policyId: "186aaa4a-5f57-4156-83fb-e456365a8820",
7524
+ accountAddress: this.agentWalletAddress,
7525
+ signerEntity: {
7526
+ entityId: sessionEntityKeyId,
7527
+ isGlobalValidation: true
7528
+ }
7529
+ });
7530
+ }
7531
+ this._acpX402 = new AcpX402(
7532
+ this.config,
7533
+ this.sessionKeyClient,
7534
+ this.publicClient
7535
+ );
7536
+ const account = this.sessionKeyClient.account;
6084
7537
  const sessionSignerAddress = await account.getSigner().getAddress();
6085
7538
  if (!await account.isAccountDeployed()) {
6086
7539
  throw new acpError_default(
6087
7540
  `ACP Contract Client validation failed: agent account ${this.agentWalletAddress} is not deployed on-chain`
6088
7541
  );
6089
7542
  }
6090
- await this.validateSessionKeyOnChain(sessionSignerAddress, sessionEntityKeyId);
7543
+ await this.validateSessionKeyOnChain(
7544
+ sessionSignerAddress,
7545
+ sessionEntityKeyId
7546
+ );
6091
7547
  console.log("Connected to ACP:", {
6092
7548
  agentWalletAddress: this.agentWalletAddress,
6093
7549
  whitelistedWalletAddress: sessionSignerAddress,
@@ -6115,11 +7571,20 @@ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClie
6115
7571
  }
6116
7572
  return this._acpX402;
6117
7573
  }
6118
- async calculateGasFees() {
7574
+ async calculateGasFees(chainId) {
7575
+ if (chainId) {
7576
+ const { maxFeePerGas } = await this.publicClients[chainId].estimateFeesPerGas();
7577
+ const increasedMaxFeePerGas = BigInt(maxFeePerGas) + BigInt(maxFeePerGas) * BigInt(this.GAS_FEE_MULTIPLIER * 100) / BigInt(100);
7578
+ return increasedMaxFeePerGas;
7579
+ }
6119
7580
  const finalMaxFeePerGas = BigInt(this.MAX_FEE_PER_GAS) + BigInt(this.MAX_PRIORITY_FEE_PER_GAS) * BigInt(Math.max(0, this.PRIORITY_FEE_MULTIPLIER - 1));
6120
7581
  return finalMaxFeePerGas;
6121
7582
  }
6122
- async handleOperation(operations) {
7583
+ async handleOperation(operations, chainId) {
7584
+ const sessionKeyClient = chainId ? this._sessionKeyClients[chainId] : this.sessionKeyClient;
7585
+ if (!sessionKeyClient) {
7586
+ throw new acpError_default("Session key client not initialized");
7587
+ }
6123
7588
  const payload = {
6124
7589
  uo: operations.map((operation) => ({
6125
7590
  target: operation.contractAddress,
@@ -6140,16 +7605,21 @@ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClie
6140
7605
  maxFeePerGas: `0x${gasFees.toString(16)}`
6141
7606
  };
6142
7607
  }
6143
- const { hash } = await this.sessionKeyClient.sendUserOperation(payload);
6144
- const txnHash = await this.sessionKeyClient.waitForUserOperationTransaction({
7608
+ const { hash } = await sessionKeyClient.sendUserOperation(payload);
7609
+ const checkTransactionConfig = {
6145
7610
  hash,
6146
- tag: "pending",
6147
7611
  retries: {
6148
7612
  intervalMs: 200,
6149
7613
  multiplier: 1.1,
6150
7614
  maxRetries: 10
6151
7615
  }
6152
- });
7616
+ };
7617
+ if (!chainId || chainId === baseSepolia4.id || chainId === base4.id) {
7618
+ checkTransactionConfig["tag"] = "pending";
7619
+ }
7620
+ const txnHash = await sessionKeyClient.waitForUserOperationTransaction(
7621
+ checkTransactionConfig
7622
+ );
6153
7623
  return { userOpHash: hash, txnHash };
6154
7624
  } catch (error) {
6155
7625
  retries -= 1;
@@ -6212,6 +7682,13 @@ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClie
6212
7682
  throw new acpError_default("Failed to get X402 payment details", error);
6213
7683
  }
6214
7684
  }
7685
+ async getAssetManager() {
7686
+ return await this.publicClient.readContract({
7687
+ address: this.memoManagerAddress,
7688
+ abi: memoManagerAbi_default,
7689
+ functionName: "assetManager"
7690
+ });
7691
+ }
6215
7692
  getAcpVersion() {
6216
7693
  return "2";
6217
7694
  }
@@ -6231,6 +7708,7 @@ export {
6231
7708
  acpJob_default as AcpJob,
6232
7709
  AcpJobPhases,
6233
7710
  acpMemo_default as AcpMemo,
7711
+ AcpMemoState,
6234
7712
  AcpMemoStatus,
6235
7713
  AcpOnlineStatus,
6236
7714
  baseAcpContractClient_default as BaseAcpContractClient,
@@ -6246,6 +7724,7 @@ export {
6246
7724
  baseAcpX402ConfigV2,
6247
7725
  baseSepoliaAcpConfig,
6248
7726
  baseSepoliaAcpConfigV2,
7727
+ baseSepoliaAcpX402ConfigV2,
6249
7728
  index_default as default,
6250
7729
  ethFare,
6251
7730
  preparePayload,