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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -579,8 +579,17 @@ declare class AcpContractConfig {
579
579
  maxRetries: number;
580
580
  rpcEndpoint?: string | undefined;
581
581
  x402Config?: X402Config | undefined;
582
+ retryConfig?: {
583
+ intervalMs: number;
584
+ multiplier: number;
585
+ maxRetries: number;
586
+ } | undefined;
582
587
  chains: ChainConfig[];
583
- 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, chains?: ChainConfig[]);
588
+ 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?: {
589
+ intervalMs: number;
590
+ multiplier: number;
591
+ maxRetries: number;
592
+ } | undefined, chains?: ChainConfig[]);
584
593
  }
585
594
  declare const baseSepoliaAcpConfig: AcpContractConfig;
586
595
  declare const baseSepoliaAcpConfigV2: AcpContractConfig;
@@ -737,6 +746,7 @@ declare class AcpContractClient extends BaseAcpContractClient {
737
746
  protected PRIORITY_FEE_MULTIPLIER: number;
738
747
  protected MAX_FEE_PER_GAS: number;
739
748
  protected MAX_PRIORITY_FEE_PER_GAS: number;
749
+ private RETRY_CONFIG;
740
750
  private _sessionKeyClient;
741
751
  private _acpX402;
742
752
  constructor(agentWalletAddress: Address$1, config?: AcpContractConfig);
@@ -9023,6 +9033,7 @@ declare class AcpContractClientV2 extends BaseAcpContractClient {
9023
9033
  private MAX_FEE_PER_GAS;
9024
9034
  private MAX_PRIORITY_FEE_PER_GAS;
9025
9035
  private GAS_FEE_MULTIPLIER;
9036
+ private RETRY_CONFIG;
9026
9037
  private _sessionKeyClient;
9027
9038
  private _sessionKeyClients;
9028
9039
  private _acpX402;
package/dist/index.d.ts CHANGED
@@ -579,8 +579,17 @@ declare class AcpContractConfig {
579
579
  maxRetries: number;
580
580
  rpcEndpoint?: string | undefined;
581
581
  x402Config?: X402Config | undefined;
582
+ retryConfig?: {
583
+ intervalMs: number;
584
+ multiplier: number;
585
+ maxRetries: number;
586
+ } | undefined;
582
587
  chains: ChainConfig[];
583
- 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, chains?: ChainConfig[]);
588
+ 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?: {
589
+ intervalMs: number;
590
+ multiplier: number;
591
+ maxRetries: number;
592
+ } | undefined, chains?: ChainConfig[]);
584
593
  }
585
594
  declare const baseSepoliaAcpConfig: AcpContractConfig;
586
595
  declare const baseSepoliaAcpConfigV2: AcpContractConfig;
@@ -737,6 +746,7 @@ declare class AcpContractClient extends BaseAcpContractClient {
737
746
  protected PRIORITY_FEE_MULTIPLIER: number;
738
747
  protected MAX_FEE_PER_GAS: number;
739
748
  protected MAX_PRIORITY_FEE_PER_GAS: number;
749
+ private RETRY_CONFIG;
740
750
  private _sessionKeyClient;
741
751
  private _acpX402;
742
752
  constructor(agentWalletAddress: Address$1, config?: AcpContractConfig);
@@ -9023,6 +9033,7 @@ declare class AcpContractClientV2 extends BaseAcpContractClient {
9023
9033
  private MAX_FEE_PER_GAS;
9024
9034
  private MAX_PRIORITY_FEE_PER_GAS;
9025
9035
  private GAS_FEE_MULTIPLIER;
9036
+ private RETRY_CONFIG;
9026
9037
  private _sessionKeyClient;
9027
9038
  private _sessionKeyClients;
9028
9039
  private _acpX402;
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.23",
39
39
  main: "./dist/index.js",
40
40
  module: "./dist/index.mjs",
41
41
  types: "./dist/index.d.ts",
@@ -2343,7 +2343,7 @@ var acpAbiV2_default = ACP_V2_ABI;
2343
2343
  var V1_MAX_RETRIES = 10;
2344
2344
  var V2_MAX_RETRIES = 3;
2345
2345
  var AcpContractConfig2 = class {
2346
- constructor(chain, contractAddress, baseFare, alchemyRpcUrl, acpUrl, abi, maxRetries, rpcEndpoint, x402Config, chains = []) {
2346
+ constructor(chain, contractAddress, baseFare, alchemyRpcUrl, acpUrl, abi, maxRetries, rpcEndpoint, x402Config, retryConfig, chains = []) {
2347
2347
  this.chain = chain;
2348
2348
  this.contractAddress = contractAddress;
2349
2349
  this.baseFare = baseFare;
@@ -2353,6 +2353,7 @@ var AcpContractConfig2 = class {
2353
2353
  this.maxRetries = maxRetries;
2354
2354
  this.rpcEndpoint = rpcEndpoint;
2355
2355
  this.x402Config = x402Config;
2356
+ this.retryConfig = retryConfig;
2356
2357
  this.chains = chains;
2357
2358
  }
2358
2359
  };
@@ -5408,6 +5409,11 @@ var AcpContractClient = class _AcpContractClient extends baseAcpContractClient_d
5408
5409
  this.PRIORITY_FEE_MULTIPLIER = 2;
5409
5410
  this.MAX_FEE_PER_GAS = 2e7;
5410
5411
  this.MAX_PRIORITY_FEE_PER_GAS = 21e6;
5412
+ this.RETRY_CONFIG = {
5413
+ intervalMs: 200,
5414
+ multiplier: 1.1,
5415
+ maxRetries: 10
5416
+ };
5411
5417
  }
5412
5418
  static async build(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfig) {
5413
5419
  const acpContractClient = new _AcpContractClient(agentWalletAddress, config);
@@ -5445,6 +5451,7 @@ var AcpContractClient = class _AcpContractClient extends baseAcpContractClient_d
5445
5451
  sessionSignerAddress,
5446
5452
  sessionEntityKeyId
5447
5453
  );
5454
+ this.RETRY_CONFIG = this.config.retryConfig || this.RETRY_CONFIG;
5448
5455
  console.log("Connected to ACP with v1 Contract Client (Legacy):", {
5449
5456
  agentWalletAddress: this.agentWalletAddress,
5450
5457
  whitelistedWalletAddress: sessionSignerAddress,
@@ -5477,38 +5484,44 @@ var AcpContractClient = class _AcpContractClient extends baseAcpContractClient_d
5477
5484
  return finalMaxFeePerGas;
5478
5485
  }
5479
5486
  async handleOperation(operations) {
5480
- const payload = {
5487
+ const basePayload = {
5481
5488
  uo: operations.map((op) => ({
5482
5489
  target: op.contractAddress,
5483
5490
  data: op.data,
5484
5491
  value: op.value
5485
- })),
5486
- overrides: {
5487
- nonceKey: this.getRandomNonce()
5488
- }
5492
+ }))
5489
5493
  };
5490
- let retries = this.config.maxRetries;
5494
+ let iteration = 0;
5491
5495
  let finalError;
5492
- while (retries > 0) {
5496
+ while (iteration < this.config.maxRetries) {
5493
5497
  try {
5494
- if (this.config.maxRetries > retries) {
5495
- const gasFees = await this.calculateGasFees();
5496
- payload["overrides"] = {
5497
- maxFeePerGas: `0x${gasFees.toString(16)}`
5498
- };
5499
- }
5498
+ const currentMultiplier = 1 + 0.1 * (iteration + 1);
5499
+ const payload = {
5500
+ ...basePayload,
5501
+ overrides: {
5502
+ nonceKey: this.getRandomNonce(),
5503
+ maxFeePerGas: {
5504
+ multiplier: currentMultiplier
5505
+ },
5506
+ maxPriorityFeePerGas: {
5507
+ multiplier: currentMultiplier
5508
+ }
5509
+ }
5510
+ };
5500
5511
  const { hash } = await this.sessionKeyClient.sendUserOperation(payload);
5501
5512
  const txnHash = await this.sessionKeyClient.waitForUserOperationTransaction({
5502
- hash
5513
+ hash,
5514
+ tag: "pending",
5515
+ retries: this.RETRY_CONFIG
5503
5516
  });
5504
5517
  return { userOpHash: hash, txnHash };
5505
5518
  } catch (error) {
5506
- retries -= 1;
5507
- if (retries === 0) {
5519
+ iteration++;
5520
+ if (iteration === this.config.maxRetries) {
5508
5521
  finalError = error;
5509
5522
  break;
5510
5523
  }
5511
- await new Promise((resolve) => setTimeout(resolve, 2e3 * retries));
5524
+ await new Promise((resolve) => setTimeout(resolve, 2e3 * iteration));
5512
5525
  }
5513
5526
  }
5514
5527
  throw new acpError_default(`Failed to send user operation`, finalError);
@@ -7476,6 +7489,11 @@ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClie
7476
7489
  this.MAX_FEE_PER_GAS = 2e7;
7477
7490
  this.MAX_PRIORITY_FEE_PER_GAS = 21e6;
7478
7491
  this.GAS_FEE_MULTIPLIER = 0.5;
7492
+ this.RETRY_CONFIG = {
7493
+ intervalMs: 200,
7494
+ multiplier: 1.1,
7495
+ maxRetries: 10
7496
+ };
7479
7497
  this._sessionKeyClients = {};
7480
7498
  }
7481
7499
  static async build(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfigV2) {
@@ -7571,6 +7589,7 @@ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClie
7571
7589
  sessionSignerAddress,
7572
7590
  sessionEntityKeyId
7573
7591
  );
7592
+ this.RETRY_CONFIG = this.config.retryConfig || this.RETRY_CONFIG;
7574
7593
  console.log("Connected to ACP:", {
7575
7594
  agentWalletAddress: this.agentWalletAddress,
7576
7595
  whitelistedWalletAddress: sessionSignerAddress,
@@ -7612,34 +7631,34 @@ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClie
7612
7631
  if (!sessionKeyClient) {
7613
7632
  throw new acpError_default("Session key client not initialized");
7614
7633
  }
7615
- const payload = {
7634
+ const basePayload = {
7616
7635
  uo: operations.map((operation) => ({
7617
7636
  target: operation.contractAddress,
7618
7637
  data: operation.data,
7619
7638
  value: operation.value
7620
- })),
7621
- overrides: {
7622
- nonceKey: this.getRandomNonce()
7623
- }
7639
+ }))
7624
7640
  };
7625
- let retries = this.config.maxRetries;
7641
+ let iteration = 0;
7626
7642
  let finalError;
7627
- while (retries > 0) {
7643
+ while (iteration < this.config.maxRetries) {
7628
7644
  try {
7629
- if (this.config.maxRetries > retries) {
7630
- const gasFees = await this.calculateGasFees();
7631
- payload["overrides"] = {
7632
- maxFeePerGas: `0x${gasFees.toString(16)}`
7633
- };
7634
- }
7645
+ const currentMultiplier = 1 + 0.1 * (iteration + 1);
7646
+ const payload = {
7647
+ ...basePayload,
7648
+ overrides: {
7649
+ nonceKey: this.getRandomNonce(),
7650
+ maxFeePerGas: {
7651
+ multiplier: currentMultiplier
7652
+ },
7653
+ maxPriorityFeePerGas: {
7654
+ multiplier: currentMultiplier
7655
+ }
7656
+ }
7657
+ };
7635
7658
  const { hash } = await sessionKeyClient.sendUserOperation(payload);
7636
7659
  const checkTransactionConfig = {
7637
7660
  hash,
7638
- retries: {
7639
- intervalMs: 200,
7640
- multiplier: 1.1,
7641
- maxRetries: 10
7642
- }
7661
+ retries: this.RETRY_CONFIG
7643
7662
  };
7644
7663
  if (!chainId || chainId === import_chains3.baseSepolia.id || chainId === import_chains3.base.id) {
7645
7664
  checkTransactionConfig["tag"] = "pending";
@@ -7649,12 +7668,12 @@ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClie
7649
7668
  );
7650
7669
  return { userOpHash: hash, txnHash };
7651
7670
  } catch (error) {
7652
- retries -= 1;
7653
- if (retries === 0) {
7671
+ iteration++;
7672
+ if (iteration === this.config.maxRetries) {
7654
7673
  finalError = error;
7655
7674
  break;
7656
7675
  }
7657
- await new Promise((resolve) => setTimeout(resolve, 2e3 * retries));
7676
+ await new Promise((resolve) => setTimeout(resolve, 2e3 * iteration));
7658
7677
  }
7659
7678
  }
7660
7679
  throw new acpError_default(`Failed to send user operation`, finalError);
package/dist/index.mjs CHANGED
@@ -8,7 +8,7 @@ var require_package = __commonJS({
8
8
  "package.json"(exports, module) {
9
9
  module.exports = {
10
10
  name: "@virtuals-protocol/acp-node",
11
- version: "0.3.0-beta.21",
11
+ version: "0.3.0-beta.23",
12
12
  main: "./dist/index.js",
13
13
  module: "./dist/index.mjs",
14
14
  types: "./dist/index.d.ts",
@@ -2297,7 +2297,7 @@ var acpAbiV2_default = ACP_V2_ABI;
2297
2297
  var V1_MAX_RETRIES = 10;
2298
2298
  var V2_MAX_RETRIES = 3;
2299
2299
  var AcpContractConfig2 = class {
2300
- constructor(chain, contractAddress, baseFare, alchemyRpcUrl, acpUrl, abi, maxRetries, rpcEndpoint, x402Config, chains = []) {
2300
+ constructor(chain, contractAddress, baseFare, alchemyRpcUrl, acpUrl, abi, maxRetries, rpcEndpoint, x402Config, retryConfig, chains = []) {
2301
2301
  this.chain = chain;
2302
2302
  this.contractAddress = contractAddress;
2303
2303
  this.baseFare = baseFare;
@@ -2307,6 +2307,7 @@ var AcpContractConfig2 = class {
2307
2307
  this.maxRetries = maxRetries;
2308
2308
  this.rpcEndpoint = rpcEndpoint;
2309
2309
  this.x402Config = x402Config;
2310
+ this.retryConfig = retryConfig;
2310
2311
  this.chains = chains;
2311
2312
  }
2312
2313
  };
@@ -5380,6 +5381,11 @@ var AcpContractClient = class _AcpContractClient extends baseAcpContractClient_d
5380
5381
  this.PRIORITY_FEE_MULTIPLIER = 2;
5381
5382
  this.MAX_FEE_PER_GAS = 2e7;
5382
5383
  this.MAX_PRIORITY_FEE_PER_GAS = 21e6;
5384
+ this.RETRY_CONFIG = {
5385
+ intervalMs: 200,
5386
+ multiplier: 1.1,
5387
+ maxRetries: 10
5388
+ };
5383
5389
  }
5384
5390
  static async build(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfig) {
5385
5391
  const acpContractClient = new _AcpContractClient(agentWalletAddress, config);
@@ -5417,6 +5423,7 @@ var AcpContractClient = class _AcpContractClient extends baseAcpContractClient_d
5417
5423
  sessionSignerAddress,
5418
5424
  sessionEntityKeyId
5419
5425
  );
5426
+ this.RETRY_CONFIG = this.config.retryConfig || this.RETRY_CONFIG;
5420
5427
  console.log("Connected to ACP with v1 Contract Client (Legacy):", {
5421
5428
  agentWalletAddress: this.agentWalletAddress,
5422
5429
  whitelistedWalletAddress: sessionSignerAddress,
@@ -5449,38 +5456,44 @@ var AcpContractClient = class _AcpContractClient extends baseAcpContractClient_d
5449
5456
  return finalMaxFeePerGas;
5450
5457
  }
5451
5458
  async handleOperation(operations) {
5452
- const payload = {
5459
+ const basePayload = {
5453
5460
  uo: operations.map((op) => ({
5454
5461
  target: op.contractAddress,
5455
5462
  data: op.data,
5456
5463
  value: op.value
5457
- })),
5458
- overrides: {
5459
- nonceKey: this.getRandomNonce()
5460
- }
5464
+ }))
5461
5465
  };
5462
- let retries = this.config.maxRetries;
5466
+ let iteration = 0;
5463
5467
  let finalError;
5464
- while (retries > 0) {
5468
+ while (iteration < this.config.maxRetries) {
5465
5469
  try {
5466
- if (this.config.maxRetries > retries) {
5467
- const gasFees = await this.calculateGasFees();
5468
- payload["overrides"] = {
5469
- maxFeePerGas: `0x${gasFees.toString(16)}`
5470
- };
5471
- }
5470
+ const currentMultiplier = 1 + 0.1 * (iteration + 1);
5471
+ const payload = {
5472
+ ...basePayload,
5473
+ overrides: {
5474
+ nonceKey: this.getRandomNonce(),
5475
+ maxFeePerGas: {
5476
+ multiplier: currentMultiplier
5477
+ },
5478
+ maxPriorityFeePerGas: {
5479
+ multiplier: currentMultiplier
5480
+ }
5481
+ }
5482
+ };
5472
5483
  const { hash } = await this.sessionKeyClient.sendUserOperation(payload);
5473
5484
  const txnHash = await this.sessionKeyClient.waitForUserOperationTransaction({
5474
- hash
5485
+ hash,
5486
+ tag: "pending",
5487
+ retries: this.RETRY_CONFIG
5475
5488
  });
5476
5489
  return { userOpHash: hash, txnHash };
5477
5490
  } catch (error) {
5478
- retries -= 1;
5479
- if (retries === 0) {
5491
+ iteration++;
5492
+ if (iteration === this.config.maxRetries) {
5480
5493
  finalError = error;
5481
5494
  break;
5482
5495
  }
5483
- await new Promise((resolve) => setTimeout(resolve, 2e3 * retries));
5496
+ await new Promise((resolve) => setTimeout(resolve, 2e3 * iteration));
5484
5497
  }
5485
5498
  }
5486
5499
  throw new acpError_default(`Failed to send user operation`, finalError);
@@ -7450,6 +7463,11 @@ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClie
7450
7463
  this.MAX_FEE_PER_GAS = 2e7;
7451
7464
  this.MAX_PRIORITY_FEE_PER_GAS = 21e6;
7452
7465
  this.GAS_FEE_MULTIPLIER = 0.5;
7466
+ this.RETRY_CONFIG = {
7467
+ intervalMs: 200,
7468
+ multiplier: 1.1,
7469
+ maxRetries: 10
7470
+ };
7453
7471
  this._sessionKeyClients = {};
7454
7472
  }
7455
7473
  static async build(walletPrivateKey, sessionEntityKeyId, agentWalletAddress, config = baseAcpConfigV2) {
@@ -7545,6 +7563,7 @@ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClie
7545
7563
  sessionSignerAddress,
7546
7564
  sessionEntityKeyId
7547
7565
  );
7566
+ this.RETRY_CONFIG = this.config.retryConfig || this.RETRY_CONFIG;
7548
7567
  console.log("Connected to ACP:", {
7549
7568
  agentWalletAddress: this.agentWalletAddress,
7550
7569
  whitelistedWalletAddress: sessionSignerAddress,
@@ -7586,34 +7605,34 @@ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClie
7586
7605
  if (!sessionKeyClient) {
7587
7606
  throw new acpError_default("Session key client not initialized");
7588
7607
  }
7589
- const payload = {
7608
+ const basePayload = {
7590
7609
  uo: operations.map((operation) => ({
7591
7610
  target: operation.contractAddress,
7592
7611
  data: operation.data,
7593
7612
  value: operation.value
7594
- })),
7595
- overrides: {
7596
- nonceKey: this.getRandomNonce()
7597
- }
7613
+ }))
7598
7614
  };
7599
- let retries = this.config.maxRetries;
7615
+ let iteration = 0;
7600
7616
  let finalError;
7601
- while (retries > 0) {
7617
+ while (iteration < this.config.maxRetries) {
7602
7618
  try {
7603
- if (this.config.maxRetries > retries) {
7604
- const gasFees = await this.calculateGasFees();
7605
- payload["overrides"] = {
7606
- maxFeePerGas: `0x${gasFees.toString(16)}`
7607
- };
7608
- }
7619
+ const currentMultiplier = 1 + 0.1 * (iteration + 1);
7620
+ const payload = {
7621
+ ...basePayload,
7622
+ overrides: {
7623
+ nonceKey: this.getRandomNonce(),
7624
+ maxFeePerGas: {
7625
+ multiplier: currentMultiplier
7626
+ },
7627
+ maxPriorityFeePerGas: {
7628
+ multiplier: currentMultiplier
7629
+ }
7630
+ }
7631
+ };
7609
7632
  const { hash } = await sessionKeyClient.sendUserOperation(payload);
7610
7633
  const checkTransactionConfig = {
7611
7634
  hash,
7612
- retries: {
7613
- intervalMs: 200,
7614
- multiplier: 1.1,
7615
- maxRetries: 10
7616
- }
7635
+ retries: this.RETRY_CONFIG
7617
7636
  };
7618
7637
  if (!chainId || chainId === baseSepolia4.id || chainId === base4.id) {
7619
7638
  checkTransactionConfig["tag"] = "pending";
@@ -7623,12 +7642,12 @@ var AcpContractClientV2 = class _AcpContractClientV2 extends baseAcpContractClie
7623
7642
  );
7624
7643
  return { userOpHash: hash, txnHash };
7625
7644
  } catch (error) {
7626
- retries -= 1;
7627
- if (retries === 0) {
7645
+ iteration++;
7646
+ if (iteration === this.config.maxRetries) {
7628
7647
  finalError = error;
7629
7648
  break;
7630
7649
  }
7631
- await new Promise((resolve) => setTimeout(resolve, 2e3 * retries));
7650
+ await new Promise((resolve) => setTimeout(resolve, 2e3 * iteration));
7632
7651
  }
7633
7652
  }
7634
7653
  throw new acpError_default(`Failed to send user operation`, finalError);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@virtuals-protocol/acp-node",
3
- "version": "0.3.0-beta.21",
3
+ "version": "0.3.0-beta.23",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",