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