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

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