@virtuals-protocol/acp-node 0.3.0-beta.20 → 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.d.mts CHANGED
@@ -561,7 +561,16 @@ declare class AcpContractConfig {
561
561
  maxRetries: number;
562
562
  rpcEndpoint?: string | undefined;
563
563
  x402Config?: X402Config | undefined;
564
- constructor(chain: typeof baseSepolia | typeof base, contractAddress: Address$1, baseFare: Fare, alchemyRpcUrl: string, acpUrl: string, abi: typeof ACP_ABI | typeof ACP_V2_ABI, maxRetries: number, rpcEndpoint?: string | undefined, x402Config?: X402Config | undefined);
564
+ retryConfig?: {
565
+ intervalMs: number;
566
+ multiplier: number;
567
+ maxRetries: number;
568
+ } | undefined;
569
+ constructor(chain: typeof baseSepolia | typeof base, contractAddress: Address$1, baseFare: Fare, alchemyRpcUrl: string, acpUrl: string, abi: typeof ACP_ABI | typeof ACP_V2_ABI, maxRetries: number, rpcEndpoint?: string | undefined, x402Config?: X402Config | undefined, retryConfig?: {
570
+ intervalMs: number;
571
+ multiplier: number;
572
+ maxRetries: number;
573
+ } | undefined);
565
574
  }
566
575
  declare const baseSepoliaAcpConfig: AcpContractConfig;
567
576
  declare const baseSepoliaAcpConfigV2: AcpContractConfig;
@@ -710,6 +719,7 @@ declare class AcpContractClient extends BaseAcpContractClient {
710
719
  protected PRIORITY_FEE_MULTIPLIER: number;
711
720
  protected MAX_FEE_PER_GAS: number;
712
721
  protected MAX_PRIORITY_FEE_PER_GAS: number;
722
+ private RETRY_CONFIG;
713
723
  private _sessionKeyClient;
714
724
  private _acpX402;
715
725
  constructor(agentWalletAddress: Address$1, config?: AcpContractConfig);
@@ -8994,6 +9004,8 @@ declare class AcpContractClientV2 extends BaseAcpContractClient {
8994
9004
  private PRIORITY_FEE_MULTIPLIER;
8995
9005
  private MAX_FEE_PER_GAS;
8996
9006
  private MAX_PRIORITY_FEE_PER_GAS;
9007
+ private GAS_FEE_MULTIPLIER;
9008
+ private RETRY_CONFIG;
8997
9009
  private _sessionKeyClient;
8998
9010
  private _acpX402;
8999
9011
  constructor(jobManagerAddress: Address$1, memoManagerAddress: Address$1, accountManagerAddress: Address$1, agentWalletAddress: Address$1, config?: AcpContractConfig);
package/dist/index.d.ts CHANGED
@@ -561,7 +561,16 @@ declare class AcpContractConfig {
561
561
  maxRetries: number;
562
562
  rpcEndpoint?: string | undefined;
563
563
  x402Config?: X402Config | undefined;
564
- constructor(chain: typeof baseSepolia | typeof base, contractAddress: Address$1, baseFare: Fare, alchemyRpcUrl: string, acpUrl: string, abi: typeof ACP_ABI | typeof ACP_V2_ABI, maxRetries: number, rpcEndpoint?: string | undefined, x402Config?: X402Config | undefined);
564
+ retryConfig?: {
565
+ intervalMs: number;
566
+ multiplier: number;
567
+ maxRetries: number;
568
+ } | undefined;
569
+ constructor(chain: typeof baseSepolia | typeof base, contractAddress: Address$1, baseFare: Fare, alchemyRpcUrl: string, acpUrl: string, abi: typeof ACP_ABI | typeof ACP_V2_ABI, maxRetries: number, rpcEndpoint?: string | undefined, x402Config?: X402Config | undefined, retryConfig?: {
570
+ intervalMs: number;
571
+ multiplier: number;
572
+ maxRetries: number;
573
+ } | undefined);
565
574
  }
566
575
  declare const baseSepoliaAcpConfig: AcpContractConfig;
567
576
  declare const baseSepoliaAcpConfigV2: AcpContractConfig;
@@ -710,6 +719,7 @@ declare class AcpContractClient extends BaseAcpContractClient {
710
719
  protected PRIORITY_FEE_MULTIPLIER: number;
711
720
  protected MAX_FEE_PER_GAS: number;
712
721
  protected MAX_PRIORITY_FEE_PER_GAS: number;
722
+ private RETRY_CONFIG;
713
723
  private _sessionKeyClient;
714
724
  private _acpX402;
715
725
  constructor(agentWalletAddress: Address$1, config?: AcpContractConfig);
@@ -8994,6 +9004,8 @@ declare class AcpContractClientV2 extends BaseAcpContractClient {
8994
9004
  private PRIORITY_FEE_MULTIPLIER;
8995
9005
  private MAX_FEE_PER_GAS;
8996
9006
  private MAX_PRIORITY_FEE_PER_GAS;
9007
+ private GAS_FEE_MULTIPLIER;
9008
+ private RETRY_CONFIG;
8997
9009
  private _sessionKeyClient;
8998
9010
  private _acpX402;
8999
9011
  constructor(jobManagerAddress: Address$1, memoManagerAddress: Address$1, accountManagerAddress: Address$1, agentWalletAddress: Address$1, config?: AcpContractConfig);
package/dist/index.js CHANGED
@@ -35,12 +35,13 @@ var require_package = __commonJS({
35
35
  "package.json"(exports2, module2) {
36
36
  module2.exports = {
37
37
  name: "@virtuals-protocol/acp-node",
38
- version: "0.3.0-beta.20",
38
+ version: "0.3.0-beta.22",
39
39
  main: "./dist/index.js",
40
40
  module: "./dist/index.mjs",
41
41
  types: "./dist/index.d.ts",
42
42
  scripts: {
43
43
  test: "jest",
44
+ "test:unit": "jest test/unit test/component",
44
45
  "test:ci": "jest --ci --reporters=default --reporters=jest-junit",
45
46
  "test:watch": "jest --watch",
46
47
  "test:coverage": "jest --coverage",
@@ -2282,7 +2283,7 @@ var acpAbiV2_default = ACP_V2_ABI;
2282
2283
  var V1_MAX_RETRIES = 10;
2283
2284
  var V2_MAX_RETRIES = 3;
2284
2285
  var AcpContractConfig2 = class {
2285
- constructor(chain, contractAddress, baseFare, alchemyRpcUrl, acpUrl, abi, maxRetries, rpcEndpoint, x402Config) {
2286
+ constructor(chain, contractAddress, baseFare, alchemyRpcUrl, acpUrl, abi, maxRetries, rpcEndpoint, x402Config, retryConfig) {
2286
2287
  this.chain = chain;
2287
2288
  this.contractAddress = contractAddress;
2288
2289
  this.baseFare = baseFare;
@@ -2292,6 +2293,7 @@ var AcpContractConfig2 = class {
2292
2293
  this.maxRetries = maxRetries;
2293
2294
  this.rpcEndpoint = rpcEndpoint;
2294
2295
  this.x402Config = x402Config;
2296
+ this.retryConfig = retryConfig;
2295
2297
  }
2296
2298
  };
2297
2299
  var baseSepoliaAcpConfig = new AcpContractConfig2(
@@ -5141,12 +5143,14 @@ var AcpContractClient = class _AcpContractClient extends baseAcpContractClient_d
5141
5143
  this.PRIORITY_FEE_MULTIPLIER = 2;
5142
5144
  this.MAX_FEE_PER_GAS = 2e7;
5143
5145
  this.MAX_PRIORITY_FEE_PER_GAS = 21e6;
5146
+ this.RETRY_CONFIG = {
5147
+ intervalMs: 200,
5148
+ multiplier: 1.1,
5149
+ maxRetries: 10
5150
+ };
5144
5151
  }
5145
5152
  static async build(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfig) {
5146
- const acpContractClient = new _AcpContractClient(
5147
- agentWalletAddress,
5148
- config
5149
- );
5153
+ const acpContractClient = new _AcpContractClient(agentWalletAddress, config);
5150
5154
  await acpContractClient.init(walletPrivateKey, sessionEntityKeyId);
5151
5155
  return acpContractClient;
5152
5156
  }
@@ -5177,7 +5181,11 @@ var AcpContractClient = class _AcpContractClient extends baseAcpContractClient_d
5177
5181
  `ACP Contract Client validation failed: agent account ${this.agentWalletAddress} is not deployed on-chain`
5178
5182
  );
5179
5183
  }
5180
- await this.validateSessionKeyOnChain(sessionSignerAddress, sessionEntityKeyId);
5184
+ await this.validateSessionKeyOnChain(
5185
+ sessionSignerAddress,
5186
+ sessionEntityKeyId
5187
+ );
5188
+ this.RETRY_CONFIG = this.config.retryConfig || this.RETRY_CONFIG;
5181
5189
  console.log("Connected to ACP with v1 Contract Client (Legacy):", {
5182
5190
  agentWalletAddress: this.agentWalletAddress,
5183
5191
  whitelistedWalletAddress: sessionSignerAddress,
@@ -5210,44 +5218,52 @@ var AcpContractClient = class _AcpContractClient extends baseAcpContractClient_d
5210
5218
  return finalMaxFeePerGas;
5211
5219
  }
5212
5220
  async handleOperation(operations) {
5213
- const payload = {
5221
+ const basePayload = {
5214
5222
  uo: operations.map((op) => ({
5215
5223
  target: op.contractAddress,
5216
5224
  data: op.data,
5217
5225
  value: op.value
5218
- })),
5219
- overrides: {
5220
- nonceKey: this.getRandomNonce()
5221
- }
5226
+ }))
5222
5227
  };
5223
- let retries = this.config.maxRetries;
5228
+ let iteration = 0;
5224
5229
  let finalError;
5225
- while (retries > 0) {
5230
+ while (iteration < this.config.maxRetries) {
5226
5231
  try {
5227
- if (this.config.maxRetries > retries) {
5228
- const gasFees = await this.calculateGasFees();
5229
- payload["overrides"] = {
5230
- maxFeePerGas: `0x${gasFees.toString(16)}`
5231
- };
5232
- }
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
+ };
5233
5245
  const { hash } = await this.sessionKeyClient.sendUserOperation(payload);
5234
5246
  const txnHash = await this.sessionKeyClient.waitForUserOperationTransaction({
5235
- hash
5247
+ hash,
5248
+ tag: "pending",
5249
+ retries: this.RETRY_CONFIG
5236
5250
  });
5237
5251
  return { userOpHash: hash, txnHash };
5238
5252
  } catch (error) {
5239
- retries -= 1;
5240
- if (retries === 0) {
5253
+ iteration++;
5254
+ if (iteration === this.config.maxRetries) {
5241
5255
  finalError = error;
5242
5256
  break;
5243
5257
  }
5244
- await new Promise((resolve) => setTimeout(resolve, 2e3 * retries));
5258
+ await new Promise((resolve) => setTimeout(resolve, 2e3 * iteration));
5245
5259
  }
5246
5260
  }
5247
5261
  throw new acpError_default(`Failed to send user operation`, finalError);
5248
5262
  }
5249
5263
  async getJobId(createJobUserOpHash, clientAddress, providerAddress) {
5250
- const result = await this.sessionKeyClient.getUserOperationReceipt(createJobUserOpHash);
5264
+ const result = await this.sessionKeyClient.getUserOperationReceipt(
5265
+ createJobUserOpHash
5266
+ );
5251
5267
  if (!result) {
5252
5268
  throw new acpError_default("Failed to get user operation receipt");
5253
5269
  }
@@ -6069,6 +6085,12 @@ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClie
6069
6085
  this.PRIORITY_FEE_MULTIPLIER = 2;
6070
6086
  this.MAX_FEE_PER_GAS = 2e7;
6071
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
+ };
6072
6094
  }
6073
6095
  static async build(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfigV2) {
6074
6096
  const publicClient = (0, import_viem7.createPublicClient)({
@@ -6136,7 +6158,11 @@ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClie
6136
6158
  `ACP Contract Client validation failed: agent account ${this.agentWalletAddress} is not deployed on-chain`
6137
6159
  );
6138
6160
  }
6139
- await this.validateSessionKeyOnChain(sessionSignerAddress, sessionEntityKeyId);
6161
+ await this.validateSessionKeyOnChain(
6162
+ sessionSignerAddress,
6163
+ sessionEntityKeyId
6164
+ );
6165
+ this.RETRY_CONFIG = this.config.retryConfig || this.RETRY_CONFIG;
6140
6166
  console.log("Connected to ACP:", {
6141
6167
  agentWalletAddress: this.agentWalletAddress,
6142
6168
  whitelistedWalletAddress: sessionSignerAddress,
@@ -6169,44 +6195,44 @@ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClie
6169
6195
  return finalMaxFeePerGas;
6170
6196
  }
6171
6197
  async handleOperation(operations) {
6172
- const payload = {
6198
+ const basePayload = {
6173
6199
  uo: operations.map((operation) => ({
6174
6200
  target: operation.contractAddress,
6175
6201
  data: operation.data,
6176
6202
  value: operation.value
6177
- })),
6178
- overrides: {
6179
- nonceKey: this.getRandomNonce()
6180
- }
6203
+ }))
6181
6204
  };
6182
- let retries = this.config.maxRetries;
6205
+ let iteration = 0;
6183
6206
  let finalError;
6184
- while (retries > 0) {
6207
+ while (iteration < this.config.maxRetries) {
6185
6208
  try {
6186
- if (this.config.maxRetries > retries) {
6187
- const gasFees = await this.calculateGasFees();
6188
- payload["overrides"] = {
6189
- maxFeePerGas: `0x${gasFees.toString(16)}`
6190
- };
6191
- }
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
+ }
6220
+ }
6221
+ };
6192
6222
  const { hash } = await this.sessionKeyClient.sendUserOperation(payload);
6193
6223
  const txnHash = await this.sessionKeyClient.waitForUserOperationTransaction({
6194
6224
  hash,
6195
6225
  tag: "pending",
6196
- retries: {
6197
- intervalMs: 200,
6198
- multiplier: 1.1,
6199
- maxRetries: 10
6200
- }
6226
+ retries: this.RETRY_CONFIG
6201
6227
  });
6202
6228
  return { userOpHash: hash, txnHash };
6203
6229
  } catch (error) {
6204
- retries -= 1;
6205
- if (retries === 0) {
6230
+ iteration++;
6231
+ if (iteration === this.config.maxRetries) {
6206
6232
  finalError = error;
6207
6233
  break;
6208
6234
  }
6209
- await new Promise((resolve) => setTimeout(resolve, 2e3 * retries));
6235
+ await new Promise((resolve) => setTimeout(resolve, 2e3 * iteration));
6210
6236
  }
6211
6237
  }
6212
6238
  throw new acpError_default(`Failed to send user operation`, finalError);
package/dist/index.mjs CHANGED
@@ -8,12 +8,13 @@ var require_package = __commonJS({
8
8
  "package.json"(exports, module) {
9
9
  module.exports = {
10
10
  name: "@virtuals-protocol/acp-node",
11
- version: "0.3.0-beta.20",
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",
15
15
  scripts: {
16
16
  test: "jest",
17
+ "test:unit": "jest test/unit test/component",
17
18
  "test:ci": "jest --ci --reporters=default --reporters=jest-junit",
18
19
  "test:watch": "jest --watch",
19
20
  "test:coverage": "jest --coverage",
@@ -2235,7 +2236,7 @@ var acpAbiV2_default = ACP_V2_ABI;
2235
2236
  var V1_MAX_RETRIES = 10;
2236
2237
  var V2_MAX_RETRIES = 3;
2237
2238
  var AcpContractConfig2 = class {
2238
- constructor(chain, contractAddress, baseFare, alchemyRpcUrl, acpUrl, abi, maxRetries, rpcEndpoint, x402Config) {
2239
+ constructor(chain, contractAddress, baseFare, alchemyRpcUrl, acpUrl, abi, maxRetries, rpcEndpoint, x402Config, retryConfig) {
2239
2240
  this.chain = chain;
2240
2241
  this.contractAddress = contractAddress;
2241
2242
  this.baseFare = baseFare;
@@ -2245,6 +2246,7 @@ var AcpContractConfig2 = class {
2245
2246
  this.maxRetries = maxRetries;
2246
2247
  this.rpcEndpoint = rpcEndpoint;
2247
2248
  this.x402Config = x402Config;
2249
+ this.retryConfig = retryConfig;
2248
2250
  }
2249
2251
  };
2250
2252
  var baseSepoliaAcpConfig = new AcpContractConfig2(
@@ -5098,12 +5100,14 @@ var AcpContractClient = class _AcpContractClient extends baseAcpContractClient_d
5098
5100
  this.PRIORITY_FEE_MULTIPLIER = 2;
5099
5101
  this.MAX_FEE_PER_GAS = 2e7;
5100
5102
  this.MAX_PRIORITY_FEE_PER_GAS = 21e6;
5103
+ this.RETRY_CONFIG = {
5104
+ intervalMs: 200,
5105
+ multiplier: 1.1,
5106
+ maxRetries: 10
5107
+ };
5101
5108
  }
5102
5109
  static async build(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfig) {
5103
- const acpContractClient = new _AcpContractClient(
5104
- agentWalletAddress,
5105
- config
5106
- );
5110
+ const acpContractClient = new _AcpContractClient(agentWalletAddress, config);
5107
5111
  await acpContractClient.init(walletPrivateKey, sessionEntityKeyId);
5108
5112
  return acpContractClient;
5109
5113
  }
@@ -5134,7 +5138,11 @@ var AcpContractClient = class _AcpContractClient extends baseAcpContractClient_d
5134
5138
  `ACP Contract Client validation failed: agent account ${this.agentWalletAddress} is not deployed on-chain`
5135
5139
  );
5136
5140
  }
5137
- await this.validateSessionKeyOnChain(sessionSignerAddress, sessionEntityKeyId);
5141
+ await this.validateSessionKeyOnChain(
5142
+ sessionSignerAddress,
5143
+ sessionEntityKeyId
5144
+ );
5145
+ this.RETRY_CONFIG = this.config.retryConfig || this.RETRY_CONFIG;
5138
5146
  console.log("Connected to ACP with v1 Contract Client (Legacy):", {
5139
5147
  agentWalletAddress: this.agentWalletAddress,
5140
5148
  whitelistedWalletAddress: sessionSignerAddress,
@@ -5167,44 +5175,52 @@ var AcpContractClient = class _AcpContractClient extends baseAcpContractClient_d
5167
5175
  return finalMaxFeePerGas;
5168
5176
  }
5169
5177
  async handleOperation(operations) {
5170
- const payload = {
5178
+ const basePayload = {
5171
5179
  uo: operations.map((op) => ({
5172
5180
  target: op.contractAddress,
5173
5181
  data: op.data,
5174
5182
  value: op.value
5175
- })),
5176
- overrides: {
5177
- nonceKey: this.getRandomNonce()
5178
- }
5183
+ }))
5179
5184
  };
5180
- let retries = this.config.maxRetries;
5185
+ let iteration = 0;
5181
5186
  let finalError;
5182
- while (retries > 0) {
5187
+ while (iteration < this.config.maxRetries) {
5183
5188
  try {
5184
- if (this.config.maxRetries > retries) {
5185
- const gasFees = await this.calculateGasFees();
5186
- payload["overrides"] = {
5187
- maxFeePerGas: `0x${gasFees.toString(16)}`
5188
- };
5189
- }
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
+ };
5190
5202
  const { hash } = await this.sessionKeyClient.sendUserOperation(payload);
5191
5203
  const txnHash = await this.sessionKeyClient.waitForUserOperationTransaction({
5192
- hash
5204
+ hash,
5205
+ tag: "pending",
5206
+ retries: this.RETRY_CONFIG
5193
5207
  });
5194
5208
  return { userOpHash: hash, txnHash };
5195
5209
  } catch (error) {
5196
- retries -= 1;
5197
- if (retries === 0) {
5210
+ iteration++;
5211
+ if (iteration === this.config.maxRetries) {
5198
5212
  finalError = error;
5199
5213
  break;
5200
5214
  }
5201
- await new Promise((resolve) => setTimeout(resolve, 2e3 * retries));
5215
+ await new Promise((resolve) => setTimeout(resolve, 2e3 * iteration));
5202
5216
  }
5203
5217
  }
5204
5218
  throw new acpError_default(`Failed to send user operation`, finalError);
5205
5219
  }
5206
5220
  async getJobId(createJobUserOpHash, clientAddress, providerAddress) {
5207
- const result = await this.sessionKeyClient.getUserOperationReceipt(createJobUserOpHash);
5221
+ const result = await this.sessionKeyClient.getUserOperationReceipt(
5222
+ createJobUserOpHash
5223
+ );
5208
5224
  if (!result) {
5209
5225
  throw new acpError_default("Failed to get user operation receipt");
5210
5226
  }
@@ -6028,6 +6044,12 @@ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClie
6028
6044
  this.PRIORITY_FEE_MULTIPLIER = 2;
6029
6045
  this.MAX_FEE_PER_GAS = 2e7;
6030
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
+ };
6031
6053
  }
6032
6054
  static async build(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfigV2) {
6033
6055
  const publicClient = createPublicClient4({
@@ -6095,7 +6117,11 @@ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClie
6095
6117
  `ACP Contract Client validation failed: agent account ${this.agentWalletAddress} is not deployed on-chain`
6096
6118
  );
6097
6119
  }
6098
- await this.validateSessionKeyOnChain(sessionSignerAddress, sessionEntityKeyId);
6120
+ await this.validateSessionKeyOnChain(
6121
+ sessionSignerAddress,
6122
+ sessionEntityKeyId
6123
+ );
6124
+ this.RETRY_CONFIG = this.config.retryConfig || this.RETRY_CONFIG;
6099
6125
  console.log("Connected to ACP:", {
6100
6126
  agentWalletAddress: this.agentWalletAddress,
6101
6127
  whitelistedWalletAddress: sessionSignerAddress,
@@ -6128,44 +6154,44 @@ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClie
6128
6154
  return finalMaxFeePerGas;
6129
6155
  }
6130
6156
  async handleOperation(operations) {
6131
- const payload = {
6157
+ const basePayload = {
6132
6158
  uo: operations.map((operation) => ({
6133
6159
  target: operation.contractAddress,
6134
6160
  data: operation.data,
6135
6161
  value: operation.value
6136
- })),
6137
- overrides: {
6138
- nonceKey: this.getRandomNonce()
6139
- }
6162
+ }))
6140
6163
  };
6141
- let retries = this.config.maxRetries;
6164
+ let iteration = 0;
6142
6165
  let finalError;
6143
- while (retries > 0) {
6166
+ while (iteration < this.config.maxRetries) {
6144
6167
  try {
6145
- if (this.config.maxRetries > retries) {
6146
- const gasFees = await this.calculateGasFees();
6147
- payload["overrides"] = {
6148
- maxFeePerGas: `0x${gasFees.toString(16)}`
6149
- };
6150
- }
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
+ }
6179
+ }
6180
+ };
6151
6181
  const { hash } = await this.sessionKeyClient.sendUserOperation(payload);
6152
6182
  const txnHash = await this.sessionKeyClient.waitForUserOperationTransaction({
6153
6183
  hash,
6154
6184
  tag: "pending",
6155
- retries: {
6156
- intervalMs: 200,
6157
- multiplier: 1.1,
6158
- maxRetries: 10
6159
- }
6185
+ retries: this.RETRY_CONFIG
6160
6186
  });
6161
6187
  return { userOpHash: hash, txnHash };
6162
6188
  } catch (error) {
6163
- retries -= 1;
6164
- if (retries === 0) {
6189
+ iteration++;
6190
+ if (iteration === this.config.maxRetries) {
6165
6191
  finalError = error;
6166
6192
  break;
6167
6193
  }
6168
- await new Promise((resolve) => setTimeout(resolve, 2e3 * retries));
6194
+ await new Promise((resolve) => setTimeout(resolve, 2e3 * iteration));
6169
6195
  }
6170
6196
  }
6171
6197
  throw new acpError_default(`Failed to send user operation`, finalError);
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@virtuals-protocol/acp-node",
3
- "version": "0.3.0-beta.20",
3
+ "version": "0.3.0-beta.22",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
7
7
  "scripts": {
8
8
  "test": "jest",
9
+ "test:unit": "jest test/unit test/component",
9
10
  "test:ci": "jest --ci --reporters=default --reporters=jest-junit",
10
11
  "test:watch": "jest --watch",
11
12
  "test:coverage": "jest --coverage",