@virtuals-protocol/acp-node 0.3.0-beta.22 → 0.3.0-beta.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -8,7 +8,7 @@ var require_package = __commonJS({
8
8
  "package.json"(exports, module) {
9
9
  module.exports = {
10
10
  name: "@virtuals-protocol/acp-node",
11
- version: "0.3.0-beta.22",
11
+ version: "0.3.0-beta.23",
12
12
  main: "./dist/index.js",
13
13
  module: "./dist/index.mjs",
14
14
  types: "./dist/index.d.ts",
@@ -1239,7 +1239,10 @@ import {
1239
1239
  } from "viem";
1240
1240
 
1241
1241
  // src/configs/acpConfigs.ts
1242
- import { baseSepolia, base } from "@account-kit/infra";
1242
+ import {
1243
+ baseSepolia,
1244
+ base
1245
+ } from "@account-kit/infra";
1243
1246
 
1244
1247
  // src/acpFare.ts
1245
1248
  import {
@@ -1267,27 +1270,42 @@ var acpError_default = AcpError;
1267
1270
 
1268
1271
  // src/acpFare.ts
1269
1272
  var Fare = class _Fare {
1270
- constructor(contractAddress, decimals) {
1273
+ constructor(contractAddress, decimals, chainId) {
1271
1274
  this.contractAddress = contractAddress;
1272
1275
  this.decimals = decimals;
1276
+ this.chainId = chainId;
1273
1277
  }
1274
1278
  formatAmount(amount) {
1275
1279
  return parseUnits(amount.toString(), this.decimals);
1276
1280
  }
1277
- static async fromContractAddress(contractAddress, config = baseAcpConfig) {
1281
+ static async fromContractAddress(contractAddress, config = baseAcpConfig, chainId = config.chain.id) {
1278
1282
  if (contractAddress === config.baseFare.contractAddress) {
1279
1283
  return config.baseFare;
1280
1284
  }
1285
+ let chainConfig = config.chain;
1286
+ let rpcUrl = config.rpcEndpoint;
1287
+ if (chainId !== config.chain.id) {
1288
+ const selectedConfig = config.chains?.find(
1289
+ (chain) => chain.chain.id === chainId
1290
+ );
1291
+ if (!selectedConfig) {
1292
+ throw new acpError_default(
1293
+ `Chain configuration for chainId ${chainId} not found.`
1294
+ );
1295
+ }
1296
+ chainConfig = selectedConfig.chain;
1297
+ rpcUrl = selectedConfig.rpcUrl;
1298
+ }
1281
1299
  const publicClient = createPublicClient({
1282
- chain: config.chain,
1283
- transport: http(config.rpcEndpoint)
1300
+ chain: chainConfig,
1301
+ transport: http(rpcUrl)
1284
1302
  });
1285
1303
  const decimals = await publicClient.readContract({
1286
1304
  address: contractAddress,
1287
1305
  abi: erc20Abi,
1288
1306
  functionName: "decimals"
1289
1307
  });
1290
- return new _Fare(contractAddress, decimals);
1308
+ return new _Fare(contractAddress, decimals, chainId);
1291
1309
  }
1292
1310
  };
1293
1311
  var FareAmountBase = class {
@@ -1706,6 +1724,34 @@ var ACP_V2_ABI = [
1706
1724
  stateMutability: "nonpayable",
1707
1725
  type: "function"
1708
1726
  },
1727
+ {
1728
+ inputs: [
1729
+ { internalType: "uint256", name: "jobId", type: "uint256" },
1730
+ { internalType: "string", name: "content", type: "string" },
1731
+ { internalType: "address", name: "token", type: "address" },
1732
+ { internalType: "uint256", name: "amount", type: "uint256" },
1733
+ { internalType: "address", name: "recipient", type: "address" },
1734
+ { internalType: "uint256", name: "feeAmount", type: "uint256" },
1735
+ { internalType: "enum ACPTypes.FeeType", name: "feeType", type: "uint8" },
1736
+ {
1737
+ internalType: "enum ACPTypes.MemoType",
1738
+ name: "memoType",
1739
+ type: "uint8"
1740
+ },
1741
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
1742
+ { internalType: "bool", name: "isSecured", type: "bool" },
1743
+ {
1744
+ internalType: "enum ACPTypes.JobPhase",
1745
+ name: "nextPhase",
1746
+ type: "uint8"
1747
+ },
1748
+ { internalType: "uint32", name: "lzDstEid", type: "uint32" }
1749
+ ],
1750
+ name: "createCrossChainPayableMemo",
1751
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
1752
+ stateMutability: "nonpayable",
1753
+ type: "function"
1754
+ },
1709
1755
  {
1710
1756
  inputs: [
1711
1757
  { internalType: "address", name: "provider", type: "address" },
@@ -1890,7 +1936,12 @@ var ACP_V2_ABI = [
1890
1936
  name: "nextPhase",
1891
1937
  type: "uint8"
1892
1938
  },
1893
- { internalType: "uint256", name: "expiredAt", type: "uint256" }
1939
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
1940
+ {
1941
+ internalType: "enum ACPTypes.MemoState",
1942
+ name: "state",
1943
+ type: "uint8"
1944
+ }
1894
1945
  ],
1895
1946
  internalType: "struct ACPTypes.Memo[]",
1896
1947
  name: "memos",
@@ -1937,7 +1988,12 @@ var ACP_V2_ABI = [
1937
1988
  name: "nextPhase",
1938
1989
  type: "uint8"
1939
1990
  },
1940
- { internalType: "uint256", name: "expiredAt", type: "uint256" }
1991
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
1992
+ {
1993
+ internalType: "enum ACPTypes.MemoState",
1994
+ name: "state",
1995
+ type: "uint8"
1996
+ }
1941
1997
  ],
1942
1998
  internalType: "struct ACPTypes.Memo[]",
1943
1999
  name: "memos",
@@ -1980,7 +2036,12 @@ var ACP_V2_ABI = [
1980
2036
  name: "nextPhase",
1981
2037
  type: "uint8"
1982
2038
  },
1983
- { internalType: "uint256", name: "expiredAt", type: "uint256" }
2039
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
2040
+ {
2041
+ internalType: "enum ACPTypes.MemoState",
2042
+ name: "state",
2043
+ type: "uint8"
2044
+ }
1984
2045
  ],
1985
2046
  internalType: "struct ACPTypes.Memo[]",
1986
2047
  name: "memos",
@@ -2236,7 +2297,7 @@ var acpAbiV2_default = ACP_V2_ABI;
2236
2297
  var V1_MAX_RETRIES = 10;
2237
2298
  var V2_MAX_RETRIES = 3;
2238
2299
  var AcpContractConfig2 = class {
2239
- constructor(chain, contractAddress, baseFare, alchemyRpcUrl, acpUrl, abi, maxRetries, rpcEndpoint, x402Config, retryConfig) {
2300
+ constructor(chain, contractAddress, baseFare, alchemyRpcUrl, acpUrl, abi, maxRetries, rpcEndpoint, x402Config, retryConfig, chains = []) {
2240
2301
  this.chain = chain;
2241
2302
  this.contractAddress = contractAddress;
2242
2303
  this.baseFare = baseFare;
@@ -2247,6 +2308,7 @@ var AcpContractConfig2 = class {
2247
2308
  this.rpcEndpoint = rpcEndpoint;
2248
2309
  this.x402Config = x402Config;
2249
2310
  this.retryConfig = retryConfig;
2311
+ this.chains = chains;
2250
2312
  }
2251
2313
  };
2252
2314
  var baseSepoliaAcpConfig = new AcpContractConfig2(
@@ -3474,7 +3536,10 @@ var SINGLE_SIGNER_VALIDATION_MODULE_ABI = [
3474
3536
  var singleSignerValidationModuleAbi_default = SINGLE_SIGNER_VALIDATION_MODULE_ABI;
3475
3537
 
3476
3538
  // src/constants.ts
3477
- import { base as base2, baseSepolia as baseSepolia2 } from "viem/chains";
3539
+ import {
3540
+ base as base2,
3541
+ baseSepolia as baseSepolia2
3542
+ } from "viem/chains";
3478
3543
  var USDC_TOKEN_ADDRESS = {
3479
3544
  [baseSepolia2.id]: "0x036CbD53842c5426634e7929541eC2318f3dCF7e",
3480
3545
  [base2.id]: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
@@ -3522,6 +3587,7 @@ var BaseAcpContractClient = class {
3522
3587
  constructor(agentWalletAddress, config = baseAcpConfig) {
3523
3588
  this.agentWalletAddress = agentWalletAddress;
3524
3589
  this.config = config;
3590
+ this.publicClients = {};
3525
3591
  this.chain = config.chain;
3526
3592
  this.abi = config.abi;
3527
3593
  this.contractAddress = config.contractAddress;
@@ -3621,12 +3687,12 @@ ${JSON.stringify(
3621
3687
  throw new acpError_default("Failed to create job", error);
3622
3688
  }
3623
3689
  }
3624
- approveAllowance(amountBaseUnit, paymentTokenAddress = this.config.baseFare.contractAddress) {
3690
+ approveAllowance(amountBaseUnit, paymentTokenAddress = this.config.baseFare.contractAddress, targetAddress) {
3625
3691
  try {
3626
3692
  const data = encodeFunctionData({
3627
3693
  abi: erc20Abi2,
3628
3694
  functionName: "approve",
3629
- args: [this.contractAddress, amountBaseUnit]
3695
+ args: [targetAddress ?? this.contractAddress, amountBaseUnit]
3630
3696
  });
3631
3697
  const payload = {
3632
3698
  data,
@@ -3665,6 +3731,35 @@ ${JSON.stringify(
3665
3731
  throw new acpError_default("Failed to create payable memo", error);
3666
3732
  }
3667
3733
  }
3734
+ createCrossChainPayableMemo(jobId, content, token, amountBaseUnit, recipient, feeAmountBaseUnit, feeType, type, expiredAt, nextPhase, destinationEid, secured = true) {
3735
+ try {
3736
+ const data = encodeFunctionData({
3737
+ abi: this.abi,
3738
+ functionName: "createCrossChainPayableMemo",
3739
+ args: [
3740
+ jobId,
3741
+ content,
3742
+ token,
3743
+ amountBaseUnit,
3744
+ recipient,
3745
+ feeAmountBaseUnit,
3746
+ feeType,
3747
+ type,
3748
+ expiredAt,
3749
+ secured,
3750
+ nextPhase,
3751
+ destinationEid
3752
+ ]
3753
+ });
3754
+ const payload = {
3755
+ data,
3756
+ contractAddress: this.contractAddress
3757
+ };
3758
+ return payload;
3759
+ } catch (error) {
3760
+ throw new acpError_default("Failed to create cross chain payable memo", error);
3761
+ }
3762
+ }
3668
3763
  createMemo(jobId, content, type, isSecured, nextPhase) {
3669
3764
  try {
3670
3765
  const data = encodeFunctionData({
@@ -3681,6 +3776,22 @@ ${JSON.stringify(
3681
3776
  throw new acpError_default("Failed to create memo", error);
3682
3777
  }
3683
3778
  }
3779
+ createMemoWithMetadata(jobId, content, type, isSecured, nextPhase, metadata) {
3780
+ try {
3781
+ const data = encodeFunctionData({
3782
+ abi: this.abi,
3783
+ functionName: "createMemoWithMetadata",
3784
+ args: [jobId, content, type, isSecured, nextPhase, metadata]
3785
+ });
3786
+ const payload = {
3787
+ data,
3788
+ contractAddress: this.contractAddress
3789
+ };
3790
+ return payload;
3791
+ } catch (error) {
3792
+ throw new acpError_default("Failed to create memo with metadata", error);
3793
+ }
3794
+ }
3684
3795
  signMemo(memoId, isApproved, reason) {
3685
3796
  try {
3686
3797
  const data = encodeFunctionData({
@@ -3766,9 +3877,47 @@ ${JSON.stringify(
3766
3877
  throw new acpError_default("Failed to submit TransferWithAuthorization", error);
3767
3878
  }
3768
3879
  }
3880
+ async getERC20Balance(chainId, tokenAddress, walletAddress) {
3881
+ const publicClient = this.publicClients[chainId];
3882
+ if (!publicClient) {
3883
+ throw new acpError_default(`Public client for chainId ${chainId} not found`);
3884
+ }
3885
+ return await publicClient.readContract({
3886
+ address: tokenAddress,
3887
+ abi: erc20Abi2,
3888
+ functionName: "balanceOf",
3889
+ args: [walletAddress]
3890
+ });
3891
+ }
3892
+ async getERC20Allowance(chainId, tokenAddress, walletAddress, spenderAddress) {
3893
+ const publicClient = this.publicClients[chainId];
3894
+ if (!publicClient) {
3895
+ throw new acpError_default(`Public client for chainId ${chainId} not found`);
3896
+ }
3897
+ return await publicClient.readContract({
3898
+ address: tokenAddress,
3899
+ abi: erc20Abi2,
3900
+ functionName: "allowance",
3901
+ args: [walletAddress, spenderAddress]
3902
+ });
3903
+ }
3904
+ async getERC20Symbol(chainId, tokenAddress) {
3905
+ const publicClient = this.publicClients[chainId];
3906
+ if (!publicClient) {
3907
+ throw new acpError_default(`Public client for chainId ${chainId} not found`);
3908
+ }
3909
+ return await publicClient.readContract({
3910
+ address: tokenAddress,
3911
+ abi: erc20Abi2,
3912
+ functionName: "symbol"
3913
+ });
3914
+ }
3769
3915
  };
3770
3916
  var baseAcpContractClient_default = BaseAcpContractClient;
3771
3917
 
3918
+ // src/acpJob.ts
3919
+ import { formatUnits } from "viem";
3920
+
3772
3921
  // src/interfaces.ts
3773
3922
  var AcpMemoStatus = /* @__PURE__ */ ((AcpMemoStatus2) => {
3774
3923
  AcpMemoStatus2["PENDING"] = "PENDING";
@@ -3776,6 +3925,15 @@ var AcpMemoStatus = /* @__PURE__ */ ((AcpMemoStatus2) => {
3776
3925
  AcpMemoStatus2["REJECTED"] = "REJECTED";
3777
3926
  return AcpMemoStatus2;
3778
3927
  })(AcpMemoStatus || {});
3928
+ var AcpMemoState = /* @__PURE__ */ ((AcpMemoState2) => {
3929
+ AcpMemoState2[AcpMemoState2["NONE"] = 0] = "NONE";
3930
+ AcpMemoState2[AcpMemoState2["PENDING"] = 1] = "PENDING";
3931
+ AcpMemoState2[AcpMemoState2["IN_PROGRESS"] = 2] = "IN_PROGRESS";
3932
+ AcpMemoState2[AcpMemoState2["READY"] = 3] = "READY";
3933
+ AcpMemoState2[AcpMemoState2["COMPLETED"] = 4] = "COMPLETED";
3934
+ AcpMemoState2[AcpMemoState2["REJECTED"] = 5] = "REJECTED";
3935
+ return AcpMemoState2;
3936
+ })(AcpMemoState || {});
3779
3937
  var AcpAgentSort = /* @__PURE__ */ ((AcpAgentSort2) => {
3780
3938
  AcpAgentSort2["SUCCESSFUL_JOB_COUNT"] = "successfulJobCount";
3781
3939
  AcpAgentSort2["SUCCESS_RATE"] = "successRate";
@@ -3814,6 +3972,19 @@ var PositionDirection = /* @__PURE__ */ ((PositionDirection2) => {
3814
3972
  })(PositionDirection || {});
3815
3973
 
3816
3974
  // src/utils.ts
3975
+ import { decodeAbiParameters, encodeAbiParameters } from "viem";
3976
+ import {
3977
+ arbitrum as arbitrum3,
3978
+ arbitrumSepolia as arbitrumSepolia3,
3979
+ base as base3,
3980
+ baseSepolia as baseSepolia3,
3981
+ bsc as bsc3,
3982
+ bscTestnet as bscTestnet3,
3983
+ mainnet as mainnet3,
3984
+ polygon as polygon3,
3985
+ polygonAmoy as polygonAmoy3,
3986
+ sepolia as sepolia3
3987
+ } from "viem/chains";
3817
3988
  function tryParseJson(content) {
3818
3989
  try {
3819
3990
  return JSON.parse(content);
@@ -3830,6 +4001,31 @@ function safeBase64Encode(data) {
3830
4001
  }
3831
4002
  return Buffer.from(data).toString("base64");
3832
4003
  }
4004
+ function getDestinationEndpointId(chainId) {
4005
+ switch (chainId) {
4006
+ case baseSepolia3.id:
4007
+ return 40245;
4008
+ case sepolia3.id:
4009
+ return 40161;
4010
+ case polygonAmoy3.id:
4011
+ return 40267;
4012
+ case arbitrumSepolia3.id:
4013
+ return 40231;
4014
+ case bscTestnet3.id:
4015
+ return 40102;
4016
+ case base3.id:
4017
+ return 30184;
4018
+ case mainnet3.id:
4019
+ return 30101;
4020
+ case polygon3.id:
4021
+ return 30109;
4022
+ case arbitrum3.id:
4023
+ return 30110;
4024
+ case bsc3.id:
4025
+ return 30102;
4026
+ }
4027
+ throw new Error(`Unsupported chain ID: ${chainId}`);
4028
+ }
3833
4029
 
3834
4030
  // src/acpJobOffering.ts
3835
4031
  import { zeroAddress as zeroAddress2 } from "viem";
@@ -4032,25 +4228,43 @@ var AcpJob = class {
4032
4228
  }
4033
4229
  const feeAmount = new FareAmount(0, this.acpContractClient.config.baseFare);
4034
4230
  const isPercentagePricing = this.priceType === "percentage" /* PERCENTAGE */;
4035
- operations.push(
4036
- this.acpContractClient.createPayableMemo(
4037
- this.id,
4038
- content,
4039
- amount.amount,
4040
- recipient,
4041
- isPercentagePricing ? BigInt(Math.round(this.priceValue * 1e4)) : feeAmount.amount,
4042
- isPercentagePricing ? 3 /* PERCENTAGE_FEE */ : 0 /* NO_FEE */,
4043
- 2 /* TRANSACTION */,
4044
- type,
4045
- expiredAt,
4046
- amount.fare.contractAddress
4047
- )
4048
- );
4231
+ if (amount.fare.chainId && amount.fare.chainId !== this.acpContractClient.config.chain.id) {
4232
+ operations.push(
4233
+ this.acpContractClient.createCrossChainPayableMemo(
4234
+ this.id,
4235
+ content,
4236
+ amount.fare.contractAddress,
4237
+ amount.amount,
4238
+ recipient,
4239
+ isPercentagePricing ? BigInt(Math.round(this.priceValue * 1e4)) : feeAmount.amount,
4240
+ isPercentagePricing ? 3 /* PERCENTAGE_FEE */ : 0 /* NO_FEE */,
4241
+ type,
4242
+ expiredAt,
4243
+ 2 /* TRANSACTION */,
4244
+ getDestinationEndpointId(amount.fare.chainId)
4245
+ )
4246
+ );
4247
+ } else {
4248
+ operations.push(
4249
+ this.acpContractClient.createPayableMemo(
4250
+ this.id,
4251
+ content,
4252
+ amount.amount,
4253
+ recipient,
4254
+ isPercentagePricing ? BigInt(Math.round(this.priceValue * 1e4)) : feeAmount.amount,
4255
+ isPercentagePricing ? 3 /* PERCENTAGE_FEE */ : 0 /* NO_FEE */,
4256
+ 2 /* TRANSACTION */,
4257
+ type,
4258
+ expiredAt,
4259
+ amount.fare.contractAddress
4260
+ )
4261
+ );
4262
+ }
4049
4263
  return await this.acpContractClient.handleOperation(operations);
4050
4264
  }
4051
4265
  async payAndAcceptRequirement(reason) {
4052
4266
  const memo = this.memos.find(
4053
- (m) => m.nextPhase === 2 /* TRANSACTION */
4267
+ (m) => m.nextPhase === 2 /* TRANSACTION */ || m.nextPhase === 4 /* COMPLETED */
4054
4268
  );
4055
4269
  if (!memo) {
4056
4270
  throw new acpError_default("No notification memo found");
@@ -4178,6 +4392,9 @@ var AcpJob = class {
4178
4392
  if (this.latestMemo?.nextPhase !== 3 /* EVALUATION */) {
4179
4393
  throw new acpError_default("No transaction memo found");
4180
4394
  }
4395
+ if (amount.fare.chainId !== this.acpContractClient.config.chain.id) {
4396
+ return await this.deliverCrossChainPayable(this.clientAddress, amount);
4397
+ }
4181
4398
  const operations = [];
4182
4399
  operations.push(
4183
4400
  this.acpContractClient.approveAllowance(
@@ -4308,6 +4525,57 @@ var AcpJob = class {
4308
4525
  waitMs = Math.min(waitMs * 2, maxWaitMs);
4309
4526
  }
4310
4527
  }
4528
+ async deliverCrossChainPayable(recipient, amount, isRequest = false) {
4529
+ if (!amount.fare.chainId) {
4530
+ throw new acpError_default("Chain ID is required for cross chain payable");
4531
+ }
4532
+ const chainId = amount.fare.chainId;
4533
+ const assetManagerAddress = await this.acpContractClient.getAssetManager();
4534
+ const tokenBalance = await this.acpContractClient.getERC20Balance(
4535
+ chainId,
4536
+ amount.fare.contractAddress,
4537
+ this.acpContractClient.agentWalletAddress
4538
+ );
4539
+ if (tokenBalance < amount.amount) {
4540
+ throw new acpError_default("Insufficient token balance for cross chain payable");
4541
+ }
4542
+ const currentAllowance = await this.acpContractClient.getERC20Allowance(
4543
+ chainId,
4544
+ amount.fare.contractAddress,
4545
+ this.acpContractClient.agentWalletAddress,
4546
+ assetManagerAddress
4547
+ );
4548
+ const approveAllowanceOperation = this.acpContractClient.approveAllowance(
4549
+ amount.amount + currentAllowance,
4550
+ amount.fare.contractAddress,
4551
+ assetManagerAddress
4552
+ );
4553
+ await this.acpContractClient.handleOperation(
4554
+ [approveAllowanceOperation],
4555
+ chainId
4556
+ );
4557
+ const tokenSymbol = await this.acpContractClient.getERC20Symbol(
4558
+ chainId,
4559
+ amount.fare.contractAddress
4560
+ );
4561
+ const createMemoOperation = this.acpContractClient.createCrossChainPayableMemo(
4562
+ this.id,
4563
+ `Performing cross chain payable transfer of ${formatUnits(
4564
+ amount.amount,
4565
+ amount.fare.decimals
4566
+ )} ${tokenSymbol} to ${recipient}`,
4567
+ amount.fare.contractAddress,
4568
+ amount.amount,
4569
+ recipient,
4570
+ BigInt(0),
4571
+ 0 /* NO_FEE */,
4572
+ isRequest ? 6 /* PAYABLE_REQUEST */ : 7 /* PAYABLE_TRANSFER */,
4573
+ new Date(Date.now() + 1e3 * 60 * 5),
4574
+ isRequest ? 2 /* TRANSACTION */ : 4 /* COMPLETED */,
4575
+ getDestinationEndpointId(chainId)
4576
+ );
4577
+ await this.acpContractClient.handleOperation([createMemoOperation]);
4578
+ }
4311
4579
  [util.inspect.custom]() {
4312
4580
  return {
4313
4581
  id: this.id,
@@ -4331,7 +4599,7 @@ var acpJob_default = AcpJob;
4331
4599
  // src/acpMemo.ts
4332
4600
  import util2 from "util";
4333
4601
  var AcpMemo = class {
4334
- constructor(contractClient, id, type, content, nextPhase, status, senderAddress, signedReason, expiry, payableDetails, txHash, signedTxHash) {
4602
+ constructor(contractClient, id, type, content, nextPhase, status, senderAddress, signedReason, expiry, payableDetails, txHash, signedTxHash, state) {
4335
4603
  this.contractClient = contractClient;
4336
4604
  this.id = id;
4337
4605
  this.type = type;
@@ -4344,6 +4612,7 @@ var AcpMemo = class {
4344
4612
  this.payableDetails = payableDetails;
4345
4613
  this.txHash = txHash;
4346
4614
  this.signedTxHash = signedTxHash;
4615
+ this.state = state;
4347
4616
  if (this.payableDetails) {
4348
4617
  this.payableDetails.amount = BigInt(this.payableDetails.amount);
4349
4618
  this.payableDetails.feeAmount = BigInt(this.payableDetails.feeAmount);
@@ -4494,7 +4763,8 @@ var AcpClient = class {
4494
4763
  memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
4495
4764
  memo.payableDetails,
4496
4765
  memo.txHash,
4497
- memo.signedTxHash
4766
+ memo.signedTxHash,
4767
+ memo.state
4498
4768
  );
4499
4769
  }),
4500
4770
  data.phase,
@@ -4532,7 +4802,8 @@ var AcpClient = class {
4532
4802
  memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
4533
4803
  memo.payableDetails,
4534
4804
  memo.txHash,
4535
- memo.signedTxHash
4805
+ memo.signedTxHash,
4806
+ memo.state
4536
4807
  );
4537
4808
  }),
4538
4809
  data.phase,
@@ -4557,7 +4828,14 @@ var AcpClient = class {
4557
4828
  process.on("SIGTERM", cleanup);
4558
4829
  }
4559
4830
  async browseAgents(keyword, options) {
4560
- let { cluster, sort_by, top_k, graduationStatus, onlineStatus, showHiddenOfferings } = options;
4831
+ let {
4832
+ cluster,
4833
+ sort_by,
4834
+ top_k,
4835
+ graduationStatus,
4836
+ onlineStatus,
4837
+ showHiddenOfferings
4838
+ } = options;
4561
4839
  top_k = top_k ?? 5;
4562
4840
  let url = `${this.acpUrl}/api/agents/v4/search?search=${keyword}`;
4563
4841
  if (sort_by && sort_by.length > 0) {
@@ -4748,7 +5026,8 @@ var AcpClient = class {
4748
5026
  memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
4749
5027
  memo.payableDetails,
4750
5028
  memo.txHash,
4751
- memo.signedTxHash
5029
+ memo.signedTxHash,
5030
+ memo.state
4752
5031
  )
4753
5032
  );
4754
5033
  jobs.push(
@@ -4822,7 +5101,8 @@ var AcpClient = class {
4822
5101
  memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
4823
5102
  memo.payableDetails,
4824
5103
  memo.txHash,
4825
- memo.signedTxHash
5104
+ memo.signedTxHash,
5105
+ memo.state
4826
5106
  )
4827
5107
  );
4828
5108
  return new acpJob_default(
@@ -4881,7 +5161,8 @@ var AcpClient = class {
4881
5161
  memo.expiry ? new Date(parseInt(memo.expiry) * 1e3) : void 0,
4882
5162
  memo.payableDetails,
4883
5163
  memo.txHash,
4884
- memo.signedTxHash
5164
+ memo.signedTxHash,
5165
+ memo.state
4885
5166
  );
4886
5167
  } catch (err) {
4887
5168
  throw new acpError_default(
@@ -5319,6 +5600,9 @@ var AcpContractClient = class _AcpContractClient extends baseAcpContractClient_d
5319
5600
  async performX402Request(url, version2, budget, signature) {
5320
5601
  return await this.acpX402.performRequest(url, version2, budget, signature);
5321
5602
  }
5603
+ async getAssetManager() {
5604
+ throw new Error("Asset Manager not supported");
5605
+ }
5322
5606
  getAcpVersion() {
5323
5607
  return "1";
5324
5608
  }
@@ -6035,84 +6319,1242 @@ var JOB_MANAGER_ABI = [
6035
6319
  var jobManagerAbi_default = JOB_MANAGER_ABI;
6036
6320
 
6037
6321
  // src/contractClients/acpContractClientV2.ts
6038
- var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClient_default {
6039
- constructor(jobManagerAddress, memoManagerAddress, accountManagerAddress, agentWalletAddress, config = baseAcpConfigV2) {
6040
- super(agentWalletAddress, config);
6041
- this.jobManagerAddress = jobManagerAddress;
6042
- this.memoManagerAddress = memoManagerAddress;
6043
- this.accountManagerAddress = accountManagerAddress;
6044
- this.PRIORITY_FEE_MULTIPLIER = 2;
6045
- this.MAX_FEE_PER_GAS = 2e7;
6046
- this.MAX_PRIORITY_FEE_PER_GAS = 21e6;
6047
- this.GAS_FEE_MULTIPLIER = 0.5;
6048
- this.RETRY_CONFIG = {
6049
- intervalMs: 200,
6050
- multiplier: 1.1,
6051
- maxRetries: 10
6052
- };
6053
- }
6054
- static async build(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfigV2) {
6055
- const publicClient = createPublicClient4({
6056
- chain: config.chain,
6057
- transport: http3(config.rpcEndpoint)
6058
- });
6059
- const [jobManagerAddress, memoManagerAddress, accountManagerAddress] = await publicClient.multicall({
6060
- contracts: [
6061
- {
6062
- address: config.contractAddress,
6063
- abi: config.abi,
6064
- functionName: "jobManager"
6065
- },
6066
- {
6067
- address: config.contractAddress,
6068
- abi: config.abi,
6069
- functionName: "memoManager"
6070
- },
6071
- {
6072
- address: config.contractAddress,
6073
- abi: config.abi,
6074
- functionName: "accountManager"
6075
- }
6076
- ]
6077
- });
6078
- if (!jobManagerAddress || !memoManagerAddress || !accountManagerAddress) {
6079
- throw new acpError_default(
6080
- "Failed to get job manager, memo manager, or account manager address"
6081
- );
6082
- }
6083
- const acpContractClient = new _AcpContractClientV2(
6084
- jobManagerAddress.result,
6085
- memoManagerAddress.result,
6086
- accountManagerAddress.result,
6087
- agentWalletAddress,
6088
- config
6089
- );
6090
- await acpContractClient.init(walletPrivateKey, sessionEntityKeyId);
6091
- return acpContractClient;
6092
- }
6093
- async init(privateKey, sessionEntityKeyId) {
6094
- const sessionKeySigner = LocalAccountSigner2.privateKeyToAccountSigner(privateKey);
6095
- this._sessionKeyClient = await createModularAccountV2Client2({
6096
- chain: this.chain,
6097
- transport: alchemy2({
6098
- rpcUrl: this.config.alchemyRpcUrl
6099
- }),
6100
- signer: sessionKeySigner,
6101
- policyId: "186aaa4a-5f57-4156-83fb-e456365a8820",
6102
- accountAddress: this.agentWalletAddress,
6103
- signerEntity: {
6104
- entityId: sessionEntityKeyId,
6105
- isGlobalValidation: true
6322
+ import { base as base4, baseSepolia as baseSepolia4 } from "viem/chains";
6323
+
6324
+ // src/abis/memoManagerAbi.ts
6325
+ var MEMO_MANAGER_ABI = [
6326
+ { inputs: [], stateMutability: "nonpayable", type: "constructor" },
6327
+ { inputs: [], name: "AccessControlBadConfirmation", type: "error" },
6328
+ {
6329
+ inputs: [
6330
+ { internalType: "address", name: "account", type: "address" },
6331
+ { internalType: "bytes32", name: "neededRole", type: "bytes32" }
6332
+ ],
6333
+ name: "AccessControlUnauthorizedAccount",
6334
+ type: "error"
6335
+ },
6336
+ {
6337
+ inputs: [{ internalType: "address", name: "target", type: "address" }],
6338
+ name: "AddressEmptyCode",
6339
+ type: "error"
6340
+ },
6341
+ { inputs: [], name: "AlreadyVoted", type: "error" },
6342
+ { inputs: [], name: "CannotApproveMemo", type: "error" },
6343
+ { inputs: [], name: "CannotUpdateApprovedMemo", type: "error" },
6344
+ { inputs: [], name: "CannotUpdateMemo", type: "error" },
6345
+ { inputs: [], name: "CannotWithdrawYet", type: "error" },
6346
+ { inputs: [], name: "DestinationChainNotConfigured", type: "error" },
6347
+ {
6348
+ inputs: [
6349
+ { internalType: "address", name: "implementation", type: "address" }
6350
+ ],
6351
+ name: "ERC1967InvalidImplementation",
6352
+ type: "error"
6353
+ },
6354
+ { inputs: [], name: "ERC1967NonPayable", type: "error" },
6355
+ { inputs: [], name: "EmptyContent", type: "error" },
6356
+ { inputs: [], name: "FailedInnerCall", type: "error" },
6357
+ { inputs: [], name: "InvalidInitialization", type: "error" },
6358
+ { inputs: [], name: "InvalidMemoState", type: "error" },
6359
+ { inputs: [], name: "InvalidMemoStateTransition", type: "error" },
6360
+ { inputs: [], name: "InvalidMemoType", type: "error" },
6361
+ { inputs: [], name: "JobAlreadyCompleted", type: "error" },
6362
+ { inputs: [], name: "JobDoesNotExist", type: "error" },
6363
+ { inputs: [], name: "MemoAlreadyApproved", type: "error" },
6364
+ { inputs: [], name: "MemoAlreadyExecuted", type: "error" },
6365
+ { inputs: [], name: "MemoAlreadySigned", type: "error" },
6366
+ { inputs: [], name: "MemoCannotBeSigned", type: "error" },
6367
+ { inputs: [], name: "MemoDoesNotExist", type: "error" },
6368
+ { inputs: [], name: "MemoDoesNotRequireApproval", type: "error" },
6369
+ { inputs: [], name: "MemoExpired", type: "error" },
6370
+ { inputs: [], name: "MemoNotApproved", type: "error" },
6371
+ { inputs: [], name: "MemoNotReadyToBeSigned", type: "error" },
6372
+ { inputs: [], name: "MemoStateUnchanged", type: "error" },
6373
+ { inputs: [], name: "NoAmountToTransfer", type: "error" },
6374
+ { inputs: [], name: "NoPaymentAmount", type: "error" },
6375
+ { inputs: [], name: "NotEscrowTransferMemoType", type: "error" },
6376
+ { inputs: [], name: "NotInitializing", type: "error" },
6377
+ { inputs: [], name: "NotPayableMemoType", type: "error" },
6378
+ { inputs: [], name: "OnlyACPContract", type: "error" },
6379
+ { inputs: [], name: "OnlyAssetManager", type: "error" },
6380
+ { inputs: [], name: "OnlyClientOrProvider", type: "error" },
6381
+ { inputs: [], name: "OnlyCounterParty", type: "error" },
6382
+ { inputs: [], name: "OnlyEvaluator", type: "error" },
6383
+ { inputs: [], name: "OnlyMemoSender", type: "error" },
6384
+ { inputs: [], name: "ReentrancyGuardReentrantCall", type: "error" },
6385
+ { inputs: [], name: "UUPSUnauthorizedCallContext", type: "error" },
6386
+ {
6387
+ inputs: [{ internalType: "bytes32", name: "slot", type: "bytes32" }],
6388
+ name: "UUPSUnsupportedProxiableUUID",
6389
+ type: "error"
6390
+ },
6391
+ { inputs: [], name: "ZeroAcpContractAddress", type: "error" },
6392
+ { inputs: [], name: "ZeroAddressRecipient", type: "error" },
6393
+ { inputs: [], name: "ZeroAddressToken", type: "error" },
6394
+ { inputs: [], name: "ZeroAssetManagerAddress", type: "error" },
6395
+ { inputs: [], name: "ZeroJobManagerAddress", type: "error" },
6396
+ {
6397
+ anonymous: false,
6398
+ inputs: [
6399
+ {
6400
+ indexed: false,
6401
+ internalType: "uint64",
6402
+ name: "version",
6403
+ type: "uint64"
6106
6404
  }
6107
- });
6108
- this._acpX402 = new AcpX402(
6109
- this.config,
6110
- this.sessionKeyClient,
6111
- this.publicClient
6112
- );
6113
- const account = this.sessionKeyClient.account;
6114
- const sessionSignerAddress = await account.getSigner().getAddress();
6115
- if (!await account.isAccountDeployed()) {
6405
+ ],
6406
+ name: "Initialized",
6407
+ type: "event"
6408
+ },
6409
+ {
6410
+ anonymous: false,
6411
+ inputs: [
6412
+ {
6413
+ indexed: true,
6414
+ internalType: "uint256",
6415
+ name: "memoId",
6416
+ type: "uint256"
6417
+ },
6418
+ {
6419
+ indexed: true,
6420
+ internalType: "address",
6421
+ name: "approver",
6422
+ type: "address"
6423
+ },
6424
+ { indexed: false, internalType: "bool", name: "approved", type: "bool" },
6425
+ {
6426
+ indexed: false,
6427
+ internalType: "string",
6428
+ name: "reason",
6429
+ type: "string"
6430
+ }
6431
+ ],
6432
+ name: "MemoSigned",
6433
+ type: "event"
6434
+ },
6435
+ {
6436
+ anonymous: false,
6437
+ inputs: [
6438
+ {
6439
+ indexed: true,
6440
+ internalType: "uint256",
6441
+ name: "memoId",
6442
+ type: "uint256"
6443
+ },
6444
+ {
6445
+ indexed: false,
6446
+ internalType: "enum ACPTypes.MemoState",
6447
+ name: "oldState",
6448
+ type: "uint8"
6449
+ },
6450
+ {
6451
+ indexed: false,
6452
+ internalType: "enum ACPTypes.MemoState",
6453
+ name: "newState",
6454
+ type: "uint8"
6455
+ }
6456
+ ],
6457
+ name: "MemoStateUpdated",
6458
+ type: "event"
6459
+ },
6460
+ {
6461
+ anonymous: false,
6462
+ inputs: [
6463
+ {
6464
+ indexed: true,
6465
+ internalType: "uint256",
6466
+ name: "memoId",
6467
+ type: "uint256"
6468
+ },
6469
+ {
6470
+ indexed: true,
6471
+ internalType: "uint256",
6472
+ name: "jobId",
6473
+ type: "uint256"
6474
+ },
6475
+ {
6476
+ indexed: true,
6477
+ internalType: "address",
6478
+ name: "sender",
6479
+ type: "address"
6480
+ },
6481
+ {
6482
+ indexed: false,
6483
+ internalType: "enum ACPTypes.MemoType",
6484
+ name: "memoType",
6485
+ type: "uint8"
6486
+ },
6487
+ {
6488
+ indexed: false,
6489
+ internalType: "enum ACPTypes.JobPhase",
6490
+ name: "nextPhase",
6491
+ type: "uint8"
6492
+ },
6493
+ {
6494
+ indexed: false,
6495
+ internalType: "string",
6496
+ name: "content",
6497
+ type: "string"
6498
+ }
6499
+ ],
6500
+ name: "NewMemo",
6501
+ type: "event"
6502
+ },
6503
+ {
6504
+ anonymous: false,
6505
+ inputs: [
6506
+ {
6507
+ indexed: true,
6508
+ internalType: "uint256",
6509
+ name: "jobId",
6510
+ type: "uint256"
6511
+ },
6512
+ {
6513
+ indexed: true,
6514
+ internalType: "uint256",
6515
+ name: "memoId",
6516
+ type: "uint256"
6517
+ },
6518
+ {
6519
+ indexed: true,
6520
+ internalType: "address",
6521
+ name: "sender",
6522
+ type: "address"
6523
+ },
6524
+ {
6525
+ indexed: false,
6526
+ internalType: "address",
6527
+ name: "token",
6528
+ type: "address"
6529
+ },
6530
+ {
6531
+ indexed: false,
6532
+ internalType: "uint256",
6533
+ name: "amount",
6534
+ type: "uint256"
6535
+ }
6536
+ ],
6537
+ name: "PayableFeeRefunded",
6538
+ type: "event"
6539
+ },
6540
+ {
6541
+ anonymous: false,
6542
+ inputs: [
6543
+ {
6544
+ indexed: true,
6545
+ internalType: "uint256",
6546
+ name: "jobId",
6547
+ type: "uint256"
6548
+ },
6549
+ {
6550
+ indexed: true,
6551
+ internalType: "uint256",
6552
+ name: "memoId",
6553
+ type: "uint256"
6554
+ },
6555
+ {
6556
+ indexed: true,
6557
+ internalType: "address",
6558
+ name: "sender",
6559
+ type: "address"
6560
+ },
6561
+ {
6562
+ indexed: false,
6563
+ internalType: "address",
6564
+ name: "token",
6565
+ type: "address"
6566
+ },
6567
+ {
6568
+ indexed: false,
6569
+ internalType: "uint256",
6570
+ name: "amount",
6571
+ type: "uint256"
6572
+ }
6573
+ ],
6574
+ name: "PayableFundsRefunded",
6575
+ type: "event"
6576
+ },
6577
+ {
6578
+ anonymous: false,
6579
+ inputs: [
6580
+ {
6581
+ indexed: true,
6582
+ internalType: "uint256",
6583
+ name: "memoId",
6584
+ type: "uint256"
6585
+ },
6586
+ {
6587
+ indexed: true,
6588
+ internalType: "uint256",
6589
+ name: "jobId",
6590
+ type: "uint256"
6591
+ },
6592
+ {
6593
+ indexed: true,
6594
+ internalType: "address",
6595
+ name: "executor",
6596
+ type: "address"
6597
+ },
6598
+ {
6599
+ indexed: false,
6600
+ internalType: "uint256",
6601
+ name: "amount",
6602
+ type: "uint256"
6603
+ }
6604
+ ],
6605
+ name: "PayableMemoExecuted",
6606
+ type: "event"
6607
+ },
6608
+ {
6609
+ anonymous: false,
6610
+ inputs: [
6611
+ { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
6612
+ {
6613
+ indexed: true,
6614
+ internalType: "bytes32",
6615
+ name: "previousAdminRole",
6616
+ type: "bytes32"
6617
+ },
6618
+ {
6619
+ indexed: true,
6620
+ internalType: "bytes32",
6621
+ name: "newAdminRole",
6622
+ type: "bytes32"
6623
+ }
6624
+ ],
6625
+ name: "RoleAdminChanged",
6626
+ type: "event"
6627
+ },
6628
+ {
6629
+ anonymous: false,
6630
+ inputs: [
6631
+ { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
6632
+ {
6633
+ indexed: true,
6634
+ internalType: "address",
6635
+ name: "account",
6636
+ type: "address"
6637
+ },
6638
+ {
6639
+ indexed: true,
6640
+ internalType: "address",
6641
+ name: "sender",
6642
+ type: "address"
6643
+ }
6644
+ ],
6645
+ name: "RoleGranted",
6646
+ type: "event"
6647
+ },
6648
+ {
6649
+ anonymous: false,
6650
+ inputs: [
6651
+ { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" },
6652
+ {
6653
+ indexed: true,
6654
+ internalType: "address",
6655
+ name: "account",
6656
+ type: "address"
6657
+ },
6658
+ {
6659
+ indexed: true,
6660
+ internalType: "address",
6661
+ name: "sender",
6662
+ type: "address"
6663
+ }
6664
+ ],
6665
+ name: "RoleRevoked",
6666
+ type: "event"
6667
+ },
6668
+ {
6669
+ anonymous: false,
6670
+ inputs: [
6671
+ {
6672
+ indexed: true,
6673
+ internalType: "address",
6674
+ name: "implementation",
6675
+ type: "address"
6676
+ }
6677
+ ],
6678
+ name: "Upgraded",
6679
+ type: "event"
6680
+ },
6681
+ {
6682
+ inputs: [],
6683
+ name: "ACP_CONTRACT_ROLE",
6684
+ outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
6685
+ stateMutability: "view",
6686
+ type: "function"
6687
+ },
6688
+ {
6689
+ inputs: [],
6690
+ name: "ADMIN_ROLE",
6691
+ outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
6692
+ stateMutability: "view",
6693
+ type: "function"
6694
+ },
6695
+ {
6696
+ inputs: [],
6697
+ name: "DEFAULT_ADMIN_ROLE",
6698
+ outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
6699
+ stateMutability: "view",
6700
+ type: "function"
6701
+ },
6702
+ {
6703
+ inputs: [],
6704
+ name: "UPGRADE_INTERFACE_VERSION",
6705
+ outputs: [{ internalType: "string", name: "", type: "string" }],
6706
+ stateMutability: "view",
6707
+ type: "function"
6708
+ },
6709
+ {
6710
+ inputs: [],
6711
+ name: "acpContract",
6712
+ outputs: [{ internalType: "address", name: "", type: "address" }],
6713
+ stateMutability: "view",
6714
+ type: "function"
6715
+ },
6716
+ {
6717
+ inputs: [
6718
+ { internalType: "uint256", name: "memoId", type: "uint256" },
6719
+ { internalType: "address", name: "sender", type: "address" },
6720
+ { internalType: "bool", name: "approved", type: "bool" },
6721
+ { internalType: "string", name: "reason", type: "string" }
6722
+ ],
6723
+ name: "approveMemo",
6724
+ outputs: [],
6725
+ stateMutability: "nonpayable",
6726
+ type: "function"
6727
+ },
6728
+ {
6729
+ inputs: [],
6730
+ name: "assetManager",
6731
+ outputs: [{ internalType: "address", name: "", type: "address" }],
6732
+ stateMutability: "view",
6733
+ type: "function"
6734
+ },
6735
+ {
6736
+ inputs: [
6737
+ { internalType: "uint256[]", name: "memoIds", type: "uint256[]" },
6738
+ { internalType: "bool", name: "approved", type: "bool" },
6739
+ { internalType: "string", name: "reason", type: "string" }
6740
+ ],
6741
+ name: "bulkApproveMemos",
6742
+ outputs: [],
6743
+ stateMutability: "nonpayable",
6744
+ type: "function"
6745
+ },
6746
+ {
6747
+ inputs: [
6748
+ { internalType: "uint256", name: "memoId", type: "uint256" },
6749
+ { internalType: "address", name: "user", type: "address" }
6750
+ ],
6751
+ name: "canApproveMemo",
6752
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
6753
+ stateMutability: "view",
6754
+ type: "function"
6755
+ },
6756
+ {
6757
+ inputs: [
6758
+ { internalType: "uint256", name: "jobId", type: "uint256" },
6759
+ { internalType: "address", name: "sender", type: "address" },
6760
+ { internalType: "string", name: "content", type: "string" },
6761
+ {
6762
+ internalType: "enum ACPTypes.MemoType",
6763
+ name: "memoType",
6764
+ type: "uint8"
6765
+ },
6766
+ { internalType: "bool", name: "isSecured", type: "bool" },
6767
+ {
6768
+ internalType: "enum ACPTypes.JobPhase",
6769
+ name: "nextPhase",
6770
+ type: "uint8"
6771
+ },
6772
+ { internalType: "string", name: "metadata", type: "string" }
6773
+ ],
6774
+ name: "createMemo",
6775
+ outputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
6776
+ stateMutability: "nonpayable",
6777
+ type: "function"
6778
+ },
6779
+ {
6780
+ inputs: [
6781
+ { internalType: "uint256", name: "jobId", type: "uint256" },
6782
+ { internalType: "address", name: "sender", type: "address" },
6783
+ { internalType: "string", name: "content", type: "string" },
6784
+ {
6785
+ internalType: "enum ACPTypes.MemoType",
6786
+ name: "memoType",
6787
+ type: "uint8"
6788
+ },
6789
+ { internalType: "bool", name: "isSecured", type: "bool" },
6790
+ {
6791
+ internalType: "enum ACPTypes.JobPhase",
6792
+ name: "nextPhase",
6793
+ type: "uint8"
6794
+ },
6795
+ {
6796
+ components: [
6797
+ { internalType: "address", name: "token", type: "address" },
6798
+ { internalType: "uint256", name: "amount", type: "uint256" },
6799
+ { internalType: "address", name: "recipient", type: "address" },
6800
+ { internalType: "uint256", name: "feeAmount", type: "uint256" },
6801
+ {
6802
+ internalType: "enum ACPTypes.FeeType",
6803
+ name: "feeType",
6804
+ type: "uint8"
6805
+ },
6806
+ { internalType: "bool", name: "isExecuted", type: "bool" },
6807
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
6808
+ { internalType: "uint32", name: "lzSrcEid", type: "uint32" },
6809
+ { internalType: "uint32", name: "lzDstEid", type: "uint32" }
6810
+ ],
6811
+ internalType: "struct ACPTypes.PayableDetails",
6812
+ name: "payableDetails_",
6813
+ type: "tuple"
6814
+ },
6815
+ { internalType: "uint256", name: "expiredAt", type: "uint256" }
6816
+ ],
6817
+ name: "createPayableMemo",
6818
+ outputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
6819
+ stateMutability: "nonpayable",
6820
+ type: "function"
6821
+ },
6822
+ {
6823
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
6824
+ name: "emergencyApproveMemo",
6825
+ outputs: [],
6826
+ stateMutability: "nonpayable",
6827
+ type: "function"
6828
+ },
6829
+ {
6830
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
6831
+ name: "executePayableMemo",
6832
+ outputs: [],
6833
+ stateMutability: "nonpayable",
6834
+ type: "function"
6835
+ },
6836
+ {
6837
+ inputs: [],
6838
+ name: "getAssetManager",
6839
+ outputs: [{ internalType: "address", name: "", type: "address" }],
6840
+ stateMutability: "view",
6841
+ type: "function"
6842
+ },
6843
+ {
6844
+ inputs: [
6845
+ { internalType: "uint256", name: "jobId", type: "uint256" },
6846
+ { internalType: "uint256", name: "offset", type: "uint256" },
6847
+ { internalType: "uint256", name: "limit", type: "uint256" }
6848
+ ],
6849
+ name: "getJobMemos",
6850
+ outputs: [
6851
+ {
6852
+ components: [
6853
+ { internalType: "uint256", name: "id", type: "uint256" },
6854
+ { internalType: "uint256", name: "jobId", type: "uint256" },
6855
+ { internalType: "address", name: "sender", type: "address" },
6856
+ { internalType: "string", name: "content", type: "string" },
6857
+ {
6858
+ internalType: "enum ACPTypes.MemoType",
6859
+ name: "memoType",
6860
+ type: "uint8"
6861
+ },
6862
+ { internalType: "uint256", name: "createdAt", type: "uint256" },
6863
+ { internalType: "bool", name: "isApproved", type: "bool" },
6864
+ { internalType: "address", name: "approvedBy", type: "address" },
6865
+ { internalType: "uint256", name: "approvedAt", type: "uint256" },
6866
+ { internalType: "bool", name: "requiresApproval", type: "bool" },
6867
+ { internalType: "string", name: "metadata", type: "string" },
6868
+ { internalType: "bool", name: "isSecured", type: "bool" },
6869
+ {
6870
+ internalType: "enum ACPTypes.JobPhase",
6871
+ name: "nextPhase",
6872
+ type: "uint8"
6873
+ },
6874
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
6875
+ {
6876
+ internalType: "enum ACPTypes.MemoState",
6877
+ name: "state",
6878
+ type: "uint8"
6879
+ }
6880
+ ],
6881
+ internalType: "struct ACPTypes.Memo[]",
6882
+ name: "memoArray",
6883
+ type: "tuple[]"
6884
+ },
6885
+ { internalType: "uint256", name: "total", type: "uint256" }
6886
+ ],
6887
+ stateMutability: "view",
6888
+ type: "function"
6889
+ },
6890
+ {
6891
+ inputs: [
6892
+ { internalType: "uint256", name: "jobId", type: "uint256" },
6893
+ { internalType: "enum ACPTypes.JobPhase", name: "phase", type: "uint8" },
6894
+ { internalType: "uint256", name: "offset", type: "uint256" },
6895
+ { internalType: "uint256", name: "limit", type: "uint256" }
6896
+ ],
6897
+ name: "getJobMemosByPhase",
6898
+ outputs: [
6899
+ {
6900
+ components: [
6901
+ { internalType: "uint256", name: "id", type: "uint256" },
6902
+ { internalType: "uint256", name: "jobId", type: "uint256" },
6903
+ { internalType: "address", name: "sender", type: "address" },
6904
+ { internalType: "string", name: "content", type: "string" },
6905
+ {
6906
+ internalType: "enum ACPTypes.MemoType",
6907
+ name: "memoType",
6908
+ type: "uint8"
6909
+ },
6910
+ { internalType: "uint256", name: "createdAt", type: "uint256" },
6911
+ { internalType: "bool", name: "isApproved", type: "bool" },
6912
+ { internalType: "address", name: "approvedBy", type: "address" },
6913
+ { internalType: "uint256", name: "approvedAt", type: "uint256" },
6914
+ { internalType: "bool", name: "requiresApproval", type: "bool" },
6915
+ { internalType: "string", name: "metadata", type: "string" },
6916
+ { internalType: "bool", name: "isSecured", type: "bool" },
6917
+ {
6918
+ internalType: "enum ACPTypes.JobPhase",
6919
+ name: "nextPhase",
6920
+ type: "uint8"
6921
+ },
6922
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
6923
+ {
6924
+ internalType: "enum ACPTypes.MemoState",
6925
+ name: "state",
6926
+ type: "uint8"
6927
+ }
6928
+ ],
6929
+ internalType: "struct ACPTypes.Memo[]",
6930
+ name: "memoArray",
6931
+ type: "tuple[]"
6932
+ },
6933
+ { internalType: "uint256", name: "total", type: "uint256" }
6934
+ ],
6935
+ stateMutability: "view",
6936
+ type: "function"
6937
+ },
6938
+ {
6939
+ inputs: [
6940
+ { internalType: "uint256", name: "jobId", type: "uint256" },
6941
+ {
6942
+ internalType: "enum ACPTypes.MemoType",
6943
+ name: "memoType",
6944
+ type: "uint8"
6945
+ },
6946
+ { internalType: "uint256", name: "offset", type: "uint256" },
6947
+ { internalType: "uint256", name: "limit", type: "uint256" }
6948
+ ],
6949
+ name: "getJobMemosByType",
6950
+ outputs: [
6951
+ {
6952
+ components: [
6953
+ { internalType: "uint256", name: "id", type: "uint256" },
6954
+ { internalType: "uint256", name: "jobId", type: "uint256" },
6955
+ { internalType: "address", name: "sender", type: "address" },
6956
+ { internalType: "string", name: "content", type: "string" },
6957
+ {
6958
+ internalType: "enum ACPTypes.MemoType",
6959
+ name: "memoType",
6960
+ type: "uint8"
6961
+ },
6962
+ { internalType: "uint256", name: "createdAt", type: "uint256" },
6963
+ { internalType: "bool", name: "isApproved", type: "bool" },
6964
+ { internalType: "address", name: "approvedBy", type: "address" },
6965
+ { internalType: "uint256", name: "approvedAt", type: "uint256" },
6966
+ { internalType: "bool", name: "requiresApproval", type: "bool" },
6967
+ { internalType: "string", name: "metadata", type: "string" },
6968
+ { internalType: "bool", name: "isSecured", type: "bool" },
6969
+ {
6970
+ internalType: "enum ACPTypes.JobPhase",
6971
+ name: "nextPhase",
6972
+ type: "uint8"
6973
+ },
6974
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
6975
+ {
6976
+ internalType: "enum ACPTypes.MemoState",
6977
+ name: "state",
6978
+ type: "uint8"
6979
+ }
6980
+ ],
6981
+ internalType: "struct ACPTypes.Memo[]",
6982
+ name: "memoArray",
6983
+ type: "tuple[]"
6984
+ },
6985
+ { internalType: "uint256", name: "total", type: "uint256" }
6986
+ ],
6987
+ stateMutability: "view",
6988
+ type: "function"
6989
+ },
6990
+ {
6991
+ inputs: [],
6992
+ name: "getLocalEid",
6993
+ outputs: [{ internalType: "uint32", name: "", type: "uint32" }],
6994
+ stateMutability: "view",
6995
+ type: "function"
6996
+ },
6997
+ {
6998
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
6999
+ name: "getMemo",
7000
+ outputs: [
7001
+ {
7002
+ components: [
7003
+ { internalType: "uint256", name: "id", type: "uint256" },
7004
+ { internalType: "uint256", name: "jobId", type: "uint256" },
7005
+ { internalType: "address", name: "sender", type: "address" },
7006
+ { internalType: "string", name: "content", type: "string" },
7007
+ {
7008
+ internalType: "enum ACPTypes.MemoType",
7009
+ name: "memoType",
7010
+ type: "uint8"
7011
+ },
7012
+ { internalType: "uint256", name: "createdAt", type: "uint256" },
7013
+ { internalType: "bool", name: "isApproved", type: "bool" },
7014
+ { internalType: "address", name: "approvedBy", type: "address" },
7015
+ { internalType: "uint256", name: "approvedAt", type: "uint256" },
7016
+ { internalType: "bool", name: "requiresApproval", type: "bool" },
7017
+ { internalType: "string", name: "metadata", type: "string" },
7018
+ { internalType: "bool", name: "isSecured", type: "bool" },
7019
+ {
7020
+ internalType: "enum ACPTypes.JobPhase",
7021
+ name: "nextPhase",
7022
+ type: "uint8"
7023
+ },
7024
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
7025
+ {
7026
+ internalType: "enum ACPTypes.MemoState",
7027
+ name: "state",
7028
+ type: "uint8"
7029
+ }
7030
+ ],
7031
+ internalType: "struct ACPTypes.Memo",
7032
+ name: "",
7033
+ type: "tuple"
7034
+ }
7035
+ ],
7036
+ stateMutability: "view",
7037
+ type: "function"
7038
+ },
7039
+ {
7040
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
7041
+ name: "getMemoApprovalStatus",
7042
+ outputs: [
7043
+ { internalType: "bool", name: "isApproved", type: "bool" },
7044
+ { internalType: "address", name: "approvedBy", type: "address" },
7045
+ { internalType: "uint256", name: "approvedAt", type: "uint256" }
7046
+ ],
7047
+ stateMutability: "view",
7048
+ type: "function"
7049
+ },
7050
+ {
7051
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
7052
+ name: "getMemoWithPayableDetails",
7053
+ outputs: [
7054
+ {
7055
+ components: [
7056
+ { internalType: "uint256", name: "id", type: "uint256" },
7057
+ { internalType: "uint256", name: "jobId", type: "uint256" },
7058
+ { internalType: "address", name: "sender", type: "address" },
7059
+ { internalType: "string", name: "content", type: "string" },
7060
+ {
7061
+ internalType: "enum ACPTypes.MemoType",
7062
+ name: "memoType",
7063
+ type: "uint8"
7064
+ },
7065
+ { internalType: "uint256", name: "createdAt", type: "uint256" },
7066
+ { internalType: "bool", name: "isApproved", type: "bool" },
7067
+ { internalType: "address", name: "approvedBy", type: "address" },
7068
+ { internalType: "uint256", name: "approvedAt", type: "uint256" },
7069
+ { internalType: "bool", name: "requiresApproval", type: "bool" },
7070
+ { internalType: "string", name: "metadata", type: "string" },
7071
+ { internalType: "bool", name: "isSecured", type: "bool" },
7072
+ {
7073
+ internalType: "enum ACPTypes.JobPhase",
7074
+ name: "nextPhase",
7075
+ type: "uint8"
7076
+ },
7077
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
7078
+ {
7079
+ internalType: "enum ACPTypes.MemoState",
7080
+ name: "state",
7081
+ type: "uint8"
7082
+ }
7083
+ ],
7084
+ internalType: "struct ACPTypes.Memo",
7085
+ name: "memo",
7086
+ type: "tuple"
7087
+ },
7088
+ {
7089
+ components: [
7090
+ { internalType: "address", name: "token", type: "address" },
7091
+ { internalType: "uint256", name: "amount", type: "uint256" },
7092
+ { internalType: "address", name: "recipient", type: "address" },
7093
+ { internalType: "uint256", name: "feeAmount", type: "uint256" },
7094
+ {
7095
+ internalType: "enum ACPTypes.FeeType",
7096
+ name: "feeType",
7097
+ type: "uint8"
7098
+ },
7099
+ { internalType: "bool", name: "isExecuted", type: "bool" },
7100
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
7101
+ { internalType: "uint32", name: "lzSrcEid", type: "uint32" },
7102
+ { internalType: "uint32", name: "lzDstEid", type: "uint32" }
7103
+ ],
7104
+ internalType: "struct ACPTypes.PayableDetails",
7105
+ name: "details",
7106
+ type: "tuple"
7107
+ }
7108
+ ],
7109
+ stateMutability: "view",
7110
+ type: "function"
7111
+ },
7112
+ {
7113
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
7114
+ name: "getPayableDetails",
7115
+ outputs: [
7116
+ {
7117
+ components: [
7118
+ { internalType: "address", name: "token", type: "address" },
7119
+ { internalType: "uint256", name: "amount", type: "uint256" },
7120
+ { internalType: "address", name: "recipient", type: "address" },
7121
+ { internalType: "uint256", name: "feeAmount", type: "uint256" },
7122
+ {
7123
+ internalType: "enum ACPTypes.FeeType",
7124
+ name: "feeType",
7125
+ type: "uint8"
7126
+ },
7127
+ { internalType: "bool", name: "isExecuted", type: "bool" },
7128
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
7129
+ { internalType: "uint32", name: "lzSrcEid", type: "uint32" },
7130
+ { internalType: "uint32", name: "lzDstEid", type: "uint32" }
7131
+ ],
7132
+ internalType: "struct ACPTypes.PayableDetails",
7133
+ name: "",
7134
+ type: "tuple"
7135
+ }
7136
+ ],
7137
+ stateMutability: "view",
7138
+ type: "function"
7139
+ },
7140
+ {
7141
+ inputs: [{ internalType: "bytes32", name: "role", type: "bytes32" }],
7142
+ name: "getRoleAdmin",
7143
+ outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
7144
+ stateMutability: "view",
7145
+ type: "function"
7146
+ },
7147
+ {
7148
+ inputs: [
7149
+ { internalType: "bytes32", name: "role", type: "bytes32" },
7150
+ { internalType: "address", name: "account", type: "address" }
7151
+ ],
7152
+ name: "grantRole",
7153
+ outputs: [],
7154
+ stateMutability: "nonpayable",
7155
+ type: "function"
7156
+ },
7157
+ {
7158
+ inputs: [
7159
+ { internalType: "bytes32", name: "role", type: "bytes32" },
7160
+ { internalType: "address", name: "account", type: "address" }
7161
+ ],
7162
+ name: "hasRole",
7163
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
7164
+ stateMutability: "view",
7165
+ type: "function"
7166
+ },
7167
+ {
7168
+ inputs: [
7169
+ { internalType: "address", name: "acpContract_", type: "address" },
7170
+ { internalType: "address", name: "jobManager_", type: "address" },
7171
+ { internalType: "address", name: "paymentManager_", type: "address" }
7172
+ ],
7173
+ name: "initialize",
7174
+ outputs: [],
7175
+ stateMutability: "nonpayable",
7176
+ type: "function"
7177
+ },
7178
+ {
7179
+ inputs: [
7180
+ { internalType: "uint256", name: "jobId", type: "uint256" },
7181
+ { internalType: "address", name: "user", type: "address" }
7182
+ ],
7183
+ name: "isJobEvaluator",
7184
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
7185
+ stateMutability: "view",
7186
+ type: "function"
7187
+ },
7188
+ {
7189
+ inputs: [
7190
+ { internalType: "uint256", name: "memoId", type: "uint256" },
7191
+ { internalType: "address", name: "user", type: "address" }
7192
+ ],
7193
+ name: "isMemoSigner",
7194
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
7195
+ stateMutability: "view",
7196
+ type: "function"
7197
+ },
7198
+ {
7199
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
7200
+ name: "isPayable",
7201
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
7202
+ stateMutability: "view",
7203
+ type: "function"
7204
+ },
7205
+ {
7206
+ inputs: [],
7207
+ name: "jobManager",
7208
+ outputs: [{ internalType: "address", name: "", type: "address" }],
7209
+ stateMutability: "view",
7210
+ type: "function"
7211
+ },
7212
+ {
7213
+ inputs: [
7214
+ { internalType: "uint256", name: "", type: "uint256" },
7215
+ { internalType: "uint256", name: "", type: "uint256" }
7216
+ ],
7217
+ name: "jobMemos",
7218
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7219
+ stateMutability: "view",
7220
+ type: "function"
7221
+ },
7222
+ {
7223
+ inputs: [
7224
+ { internalType: "uint256", name: "", type: "uint256" },
7225
+ { internalType: "enum ACPTypes.JobPhase", name: "", type: "uint8" },
7226
+ { internalType: "uint256", name: "", type: "uint256" }
7227
+ ],
7228
+ name: "jobMemosByPhase",
7229
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7230
+ stateMutability: "view",
7231
+ type: "function"
7232
+ },
7233
+ {
7234
+ inputs: [
7235
+ { internalType: "uint256", name: "", type: "uint256" },
7236
+ { internalType: "enum ACPTypes.MemoType", name: "", type: "uint8" },
7237
+ { internalType: "uint256", name: "", type: "uint256" }
7238
+ ],
7239
+ name: "jobMemosByType",
7240
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7241
+ stateMutability: "view",
7242
+ type: "function"
7243
+ },
7244
+ {
7245
+ inputs: [
7246
+ { internalType: "uint256", name: "", type: "uint256" },
7247
+ { internalType: "address", name: "", type: "address" }
7248
+ ],
7249
+ name: "memoApprovals",
7250
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
7251
+ stateMutability: "view",
7252
+ type: "function"
7253
+ },
7254
+ {
7255
+ inputs: [],
7256
+ name: "memoCounter",
7257
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7258
+ stateMutability: "view",
7259
+ type: "function"
7260
+ },
7261
+ {
7262
+ inputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7263
+ name: "memos",
7264
+ outputs: [
7265
+ { internalType: "uint256", name: "id", type: "uint256" },
7266
+ { internalType: "uint256", name: "jobId", type: "uint256" },
7267
+ { internalType: "address", name: "sender", type: "address" },
7268
+ { internalType: "string", name: "content", type: "string" },
7269
+ {
7270
+ internalType: "enum ACPTypes.MemoType",
7271
+ name: "memoType",
7272
+ type: "uint8"
7273
+ },
7274
+ { internalType: "uint256", name: "createdAt", type: "uint256" },
7275
+ { internalType: "bool", name: "isApproved", type: "bool" },
7276
+ { internalType: "address", name: "approvedBy", type: "address" },
7277
+ { internalType: "uint256", name: "approvedAt", type: "uint256" },
7278
+ { internalType: "bool", name: "requiresApproval", type: "bool" },
7279
+ { internalType: "string", name: "metadata", type: "string" },
7280
+ { internalType: "bool", name: "isSecured", type: "bool" },
7281
+ {
7282
+ internalType: "enum ACPTypes.JobPhase",
7283
+ name: "nextPhase",
7284
+ type: "uint8"
7285
+ },
7286
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
7287
+ { internalType: "enum ACPTypes.MemoState", name: "state", type: "uint8" }
7288
+ ],
7289
+ stateMutability: "view",
7290
+ type: "function"
7291
+ },
7292
+ {
7293
+ inputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7294
+ name: "payableDetails",
7295
+ outputs: [
7296
+ { internalType: "address", name: "token", type: "address" },
7297
+ { internalType: "uint256", name: "amount", type: "uint256" },
7298
+ { internalType: "address", name: "recipient", type: "address" },
7299
+ { internalType: "uint256", name: "feeAmount", type: "uint256" },
7300
+ { internalType: "enum ACPTypes.FeeType", name: "feeType", type: "uint8" },
7301
+ { internalType: "bool", name: "isExecuted", type: "bool" },
7302
+ { internalType: "uint256", name: "expiredAt", type: "uint256" },
7303
+ { internalType: "uint32", name: "lzSrcEid", type: "uint32" },
7304
+ { internalType: "uint32", name: "lzDstEid", type: "uint32" }
7305
+ ],
7306
+ stateMutability: "view",
7307
+ type: "function"
7308
+ },
7309
+ {
7310
+ inputs: [],
7311
+ name: "paymentManager",
7312
+ outputs: [{ internalType: "address", name: "", type: "address" }],
7313
+ stateMutability: "view",
7314
+ type: "function"
7315
+ },
7316
+ {
7317
+ inputs: [],
7318
+ name: "proxiableUUID",
7319
+ outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
7320
+ stateMutability: "view",
7321
+ type: "function"
7322
+ },
7323
+ {
7324
+ inputs: [
7325
+ { internalType: "bytes32", name: "role", type: "bytes32" },
7326
+ { internalType: "address", name: "callerConfirmation", type: "address" }
7327
+ ],
7328
+ name: "renounceRole",
7329
+ outputs: [],
7330
+ stateMutability: "nonpayable",
7331
+ type: "function"
7332
+ },
7333
+ {
7334
+ inputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7335
+ name: "requiredApprovals",
7336
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
7337
+ stateMutability: "view",
7338
+ type: "function"
7339
+ },
7340
+ {
7341
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
7342
+ name: "requiresApproval",
7343
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
7344
+ stateMutability: "view",
7345
+ type: "function"
7346
+ },
7347
+ {
7348
+ inputs: [
7349
+ { internalType: "bytes32", name: "role", type: "bytes32" },
7350
+ { internalType: "address", name: "account", type: "address" }
7351
+ ],
7352
+ name: "revokeRole",
7353
+ outputs: [],
7354
+ stateMutability: "nonpayable",
7355
+ type: "function"
7356
+ },
7357
+ {
7358
+ inputs: [
7359
+ {
7360
+ internalType: "enum ACPTypes.MemoType",
7361
+ name: "memoType",
7362
+ type: "uint8"
7363
+ },
7364
+ { internalType: "uint256", name: "requiredApprovals_", type: "uint256" }
7365
+ ],
7366
+ name: "setApprovalRequirements",
7367
+ outputs: [],
7368
+ stateMutability: "nonpayable",
7369
+ type: "function"
7370
+ },
7371
+ {
7372
+ inputs: [
7373
+ { internalType: "address", name: "assetManager_", type: "address" }
7374
+ ],
7375
+ name: "setAssetManager",
7376
+ outputs: [],
7377
+ stateMutability: "nonpayable",
7378
+ type: "function"
7379
+ },
7380
+ {
7381
+ inputs: [
7382
+ { internalType: "uint256", name: "memoId", type: "uint256" },
7383
+ { internalType: "address", name: "sender", type: "address" },
7384
+ { internalType: "bool", name: "isApproved", type: "bool" },
7385
+ { internalType: "string", name: "reason", type: "string" }
7386
+ ],
7387
+ name: "signMemo",
7388
+ outputs: [{ internalType: "uint256", name: "jobId", type: "uint256" }],
7389
+ stateMutability: "nonpayable",
7390
+ type: "function"
7391
+ },
7392
+ {
7393
+ inputs: [{ internalType: "bytes4", name: "interfaceId", type: "bytes4" }],
7394
+ name: "supportsInterface",
7395
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
7396
+ stateMutability: "view",
7397
+ type: "function"
7398
+ },
7399
+ {
7400
+ inputs: [
7401
+ { internalType: "address", name: "acpContract_", type: "address" },
7402
+ { internalType: "address", name: "jobManager_", type: "address" },
7403
+ { internalType: "address", name: "paymentManager_", type: "address" },
7404
+ { internalType: "address", name: "assetManager_", type: "address" }
7405
+ ],
7406
+ name: "updateContracts",
7407
+ outputs: [],
7408
+ stateMutability: "nonpayable",
7409
+ type: "function"
7410
+ },
7411
+ {
7412
+ inputs: [
7413
+ { internalType: "uint256", name: "memoId", type: "uint256" },
7414
+ { internalType: "string", name: "newContent", type: "string" }
7415
+ ],
7416
+ name: "updateMemoContent",
7417
+ outputs: [],
7418
+ stateMutability: "nonpayable",
7419
+ type: "function"
7420
+ },
7421
+ {
7422
+ inputs: [
7423
+ { internalType: "uint256", name: "memoId", type: "uint256" },
7424
+ {
7425
+ internalType: "enum ACPTypes.MemoState",
7426
+ name: "newMemoState",
7427
+ type: "uint8"
7428
+ }
7429
+ ],
7430
+ name: "updateMemoState",
7431
+ outputs: [],
7432
+ stateMutability: "nonpayable",
7433
+ type: "function"
7434
+ },
7435
+ {
7436
+ inputs: [
7437
+ { internalType: "address", name: "newImplementation", type: "address" },
7438
+ { internalType: "bytes", name: "data", type: "bytes" }
7439
+ ],
7440
+ name: "upgradeToAndCall",
7441
+ outputs: [],
7442
+ stateMutability: "payable",
7443
+ type: "function"
7444
+ },
7445
+ {
7446
+ inputs: [{ internalType: "uint256", name: "memoId", type: "uint256" }],
7447
+ name: "withdrawEscrowedFunds",
7448
+ outputs: [],
7449
+ stateMutability: "nonpayable",
7450
+ type: "function"
7451
+ }
7452
+ ];
7453
+ var memoManagerAbi_default = MEMO_MANAGER_ABI;
7454
+
7455
+ // src/contractClients/acpContractClientV2.ts
7456
+ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClient_default {
7457
+ constructor(jobManagerAddress, memoManagerAddress, accountManagerAddress, agentWalletAddress, config = baseAcpConfigV2) {
7458
+ super(agentWalletAddress, config);
7459
+ this.jobManagerAddress = jobManagerAddress;
7460
+ this.memoManagerAddress = memoManagerAddress;
7461
+ this.accountManagerAddress = accountManagerAddress;
7462
+ this.PRIORITY_FEE_MULTIPLIER = 2;
7463
+ this.MAX_FEE_PER_GAS = 2e7;
7464
+ this.MAX_PRIORITY_FEE_PER_GAS = 21e6;
7465
+ this.GAS_FEE_MULTIPLIER = 0.5;
7466
+ this.RETRY_CONFIG = {
7467
+ intervalMs: 200,
7468
+ multiplier: 1.1,
7469
+ maxRetries: 10
7470
+ };
7471
+ this._sessionKeyClients = {};
7472
+ }
7473
+ static async build(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfigV2) {
7474
+ const publicClients = {};
7475
+ for (const chain of config.chains) {
7476
+ publicClients[chain.chain.id] = createPublicClient4({
7477
+ chain: chain.chain,
7478
+ transport: http3(chain.rpcUrl)
7479
+ });
7480
+ }
7481
+ const publicClient = createPublicClient4({
7482
+ chain: config.chain,
7483
+ transport: http3(config.rpcEndpoint)
7484
+ });
7485
+ const [jobManagerAddress, memoManagerAddress, accountManagerAddress] = await publicClient.multicall({
7486
+ contracts: [
7487
+ {
7488
+ address: config.contractAddress,
7489
+ abi: config.abi,
7490
+ functionName: "jobManager"
7491
+ },
7492
+ {
7493
+ address: config.contractAddress,
7494
+ abi: config.abi,
7495
+ functionName: "memoManager"
7496
+ },
7497
+ {
7498
+ address: config.contractAddress,
7499
+ abi: config.abi,
7500
+ functionName: "accountManager"
7501
+ }
7502
+ ]
7503
+ });
7504
+ if (!jobManagerAddress || !memoManagerAddress || !accountManagerAddress) {
7505
+ throw new acpError_default(
7506
+ "Failed to get job manager, memo manager, or account manager address"
7507
+ );
7508
+ }
7509
+ const acpContractClient = new _AcpContractClientV2(
7510
+ jobManagerAddress.result,
7511
+ memoManagerAddress.result,
7512
+ accountManagerAddress.result,
7513
+ agentWalletAddress,
7514
+ config
7515
+ );
7516
+ acpContractClient.publicClients = publicClients;
7517
+ await acpContractClient.init(walletPrivateKey, sessionEntityKeyId);
7518
+ return acpContractClient;
7519
+ }
7520
+ async init(privateKey, sessionEntityKeyId) {
7521
+ const sessionKeySigner = LocalAccountSigner2.privateKeyToAccountSigner(privateKey);
7522
+ this._sessionKeyClient = await createModularAccountV2Client2({
7523
+ chain: this.chain,
7524
+ transport: alchemy2({
7525
+ rpcUrl: this.config.alchemyRpcUrl
7526
+ }),
7527
+ signer: sessionKeySigner,
7528
+ policyId: "186aaa4a-5f57-4156-83fb-e456365a8820",
7529
+ accountAddress: this.agentWalletAddress,
7530
+ signerEntity: {
7531
+ entityId: sessionEntityKeyId,
7532
+ isGlobalValidation: true
7533
+ }
7534
+ });
7535
+ for (const chain of this.config.chains) {
7536
+ this._sessionKeyClients[chain.chain.id] = await createModularAccountV2Client2({
7537
+ chain: chain.chain,
7538
+ transport: alchemy2({
7539
+ rpcUrl: `${this.config.alchemyRpcUrl}?chainId=${chain.chain.id}`
7540
+ }),
7541
+ signer: sessionKeySigner,
7542
+ policyId: "186aaa4a-5f57-4156-83fb-e456365a8820",
7543
+ accountAddress: this.agentWalletAddress,
7544
+ signerEntity: {
7545
+ entityId: sessionEntityKeyId,
7546
+ isGlobalValidation: true
7547
+ }
7548
+ });
7549
+ }
7550
+ this._acpX402 = new AcpX402(
7551
+ this.config,
7552
+ this.sessionKeyClient,
7553
+ this.publicClient
7554
+ );
7555
+ const account = this.sessionKeyClient.account;
7556
+ const sessionSignerAddress = await account.getSigner().getAddress();
7557
+ if (!await account.isAccountDeployed()) {
6116
7558
  throw new acpError_default(
6117
7559
  `ACP Contract Client validation failed: agent account ${this.agentWalletAddress} is not deployed on-chain`
6118
7560
  );
@@ -6149,11 +7591,20 @@ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClie
6149
7591
  }
6150
7592
  return this._acpX402;
6151
7593
  }
6152
- async calculateGasFees() {
7594
+ async calculateGasFees(chainId) {
7595
+ if (chainId) {
7596
+ const { maxFeePerGas } = await this.publicClients[chainId].estimateFeesPerGas();
7597
+ const increasedMaxFeePerGas = BigInt(maxFeePerGas) + BigInt(maxFeePerGas) * BigInt(this.GAS_FEE_MULTIPLIER * 100) / BigInt(100);
7598
+ return increasedMaxFeePerGas;
7599
+ }
6153
7600
  const finalMaxFeePerGas = BigInt(this.MAX_FEE_PER_GAS) + BigInt(this.MAX_PRIORITY_FEE_PER_GAS) * BigInt(Math.max(0, this.PRIORITY_FEE_MULTIPLIER - 1));
6154
7601
  return finalMaxFeePerGas;
6155
7602
  }
6156
- async handleOperation(operations) {
7603
+ async handleOperation(operations, chainId) {
7604
+ const sessionKeyClient = chainId ? this._sessionKeyClients[chainId] : this.sessionKeyClient;
7605
+ if (!sessionKeyClient) {
7606
+ throw new acpError_default("Session key client not initialized");
7607
+ }
6157
7608
  const basePayload = {
6158
7609
  uo: operations.map((operation) => ({
6159
7610
  target: operation.contractAddress,
@@ -6178,12 +7629,17 @@ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClie
6178
7629
  }
6179
7630
  }
6180
7631
  };
6181
- const { hash } = await this.sessionKeyClient.sendUserOperation(payload);
6182
- const txnHash = await this.sessionKeyClient.waitForUserOperationTransaction({
7632
+ const { hash } = await sessionKeyClient.sendUserOperation(payload);
7633
+ const checkTransactionConfig = {
6183
7634
  hash,
6184
- tag: "pending",
6185
7635
  retries: this.RETRY_CONFIG
6186
- });
7636
+ };
7637
+ if (!chainId || chainId === baseSepolia4.id || chainId === base4.id) {
7638
+ checkTransactionConfig["tag"] = "pending";
7639
+ }
7640
+ const txnHash = await sessionKeyClient.waitForUserOperationTransaction(
7641
+ checkTransactionConfig
7642
+ );
6187
7643
  return { userOpHash: hash, txnHash };
6188
7644
  } catch (error) {
6189
7645
  iteration++;
@@ -6246,6 +7702,13 @@ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClie
6246
7702
  throw new acpError_default("Failed to get X402 payment details", error);
6247
7703
  }
6248
7704
  }
7705
+ async getAssetManager() {
7706
+ return await this.publicClient.readContract({
7707
+ address: this.memoManagerAddress,
7708
+ abi: memoManagerAbi_default,
7709
+ functionName: "assetManager"
7710
+ });
7711
+ }
6249
7712
  getAcpVersion() {
6250
7713
  return "2";
6251
7714
  }
@@ -6265,6 +7728,7 @@ export {
6265
7728
  acpJob_default as AcpJob,
6266
7729
  AcpJobPhases,
6267
7730
  acpMemo_default as AcpMemo,
7731
+ AcpMemoState,
6268
7732
  AcpMemoStatus,
6269
7733
  AcpOnlineStatus,
6270
7734
  baseAcpContractClient_default as BaseAcpContractClient,
@@ -6280,6 +7744,7 @@ export {
6280
7744
  baseAcpX402ConfigV2,
6281
7745
  baseSepoliaAcpConfig,
6282
7746
  baseSepoliaAcpConfigV2,
7747
+ baseSepoliaAcpX402ConfigV2,
6283
7748
  index_default as default,
6284
7749
  ethFare,
6285
7750
  preparePayload,