@agether/sdk 2.2.0 → 2.3.0

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/cli.js CHANGED
@@ -1280,7 +1280,9 @@ var init_MorphoClient = __esm({
1280
1280
  */
1281
1281
  async _submitUserOp(callData) {
1282
1282
  const sender = await this.getAccountAddress();
1283
- const nonce = await this.entryPoint.getNonce(sender, 0);
1283
+ const validatorAddr = this.config.contracts.erc8004ValidationModule;
1284
+ const nonceKey = BigInt(validatorAddr) << 32n;
1285
+ const nonce = await this.entryPoint.getNonce(sender, nonceKey);
1284
1286
  const feeData = await this.provider.getFeeData();
1285
1287
  const maxFeePerGas = feeData.maxFeePerGas ?? import_ethers.ethers.parseUnits("0.5", "gwei");
1286
1288
  const maxPriorityFeePerGas = feeData.maxPriorityFeePerGas ?? import_ethers.ethers.parseUnits("0.1", "gwei");
@@ -1289,6 +1291,18 @@ var init_MorphoClient = __esm({
1289
1291
  const preVerificationGas = 100000n;
1290
1292
  const accountGasLimits = this._packUint128(verificationGasLimit, callGasLimit);
1291
1293
  const gasFees = this._packUint128(maxPriorityFeePerGas, maxFeePerGas);
1294
+ const requiredPrefund = (verificationGasLimit + callGasLimit + preVerificationGas) * maxFeePerGas;
1295
+ const accountBalance = await this.provider.getBalance(sender);
1296
+ if (accountBalance < requiredPrefund) {
1297
+ const topUp = requiredPrefund - accountBalance;
1298
+ const topUpWithBuffer = topUp * 120n / 100n;
1299
+ const fundTx = await this._signer.sendTransaction({
1300
+ to: sender,
1301
+ value: topUpWithBuffer
1302
+ });
1303
+ await fundTx.wait();
1304
+ this._refreshSigner();
1305
+ }
1292
1306
  const userOp = {
1293
1307
  sender,
1294
1308
  nonce,
package/dist/index.js CHANGED
@@ -1529,7 +1529,9 @@ var MorphoClient = class {
1529
1529
  */
1530
1530
  async _submitUserOp(callData) {
1531
1531
  const sender = await this.getAccountAddress();
1532
- const nonce = await this.entryPoint.getNonce(sender, 0);
1532
+ const validatorAddr = this.config.contracts.erc8004ValidationModule;
1533
+ const nonceKey = BigInt(validatorAddr) << 32n;
1534
+ const nonce = await this.entryPoint.getNonce(sender, nonceKey);
1533
1535
  const feeData = await this.provider.getFeeData();
1534
1536
  const maxFeePerGas = feeData.maxFeePerGas ?? import_ethers2.ethers.parseUnits("0.5", "gwei");
1535
1537
  const maxPriorityFeePerGas = feeData.maxPriorityFeePerGas ?? import_ethers2.ethers.parseUnits("0.1", "gwei");
@@ -1538,6 +1540,18 @@ var MorphoClient = class {
1538
1540
  const preVerificationGas = 100000n;
1539
1541
  const accountGasLimits = this._packUint128(verificationGasLimit, callGasLimit);
1540
1542
  const gasFees = this._packUint128(maxPriorityFeePerGas, maxFeePerGas);
1543
+ const requiredPrefund = (verificationGasLimit + callGasLimit + preVerificationGas) * maxFeePerGas;
1544
+ const accountBalance = await this.provider.getBalance(sender);
1545
+ if (accountBalance < requiredPrefund) {
1546
+ const topUp = requiredPrefund - accountBalance;
1547
+ const topUpWithBuffer = topUp * 120n / 100n;
1548
+ const fundTx = await this._signer.sendTransaction({
1549
+ to: sender,
1550
+ value: topUpWithBuffer
1551
+ });
1552
+ await fundTx.wait();
1553
+ this._refreshSigner();
1554
+ }
1541
1555
  const userOp = {
1542
1556
  sender,
1543
1557
  nonce,
package/dist/index.mjs CHANGED
@@ -1457,7 +1457,9 @@ var MorphoClient = class {
1457
1457
  */
1458
1458
  async _submitUserOp(callData) {
1459
1459
  const sender = await this.getAccountAddress();
1460
- const nonce = await this.entryPoint.getNonce(sender, 0);
1460
+ const validatorAddr = this.config.contracts.erc8004ValidationModule;
1461
+ const nonceKey = BigInt(validatorAddr) << 32n;
1462
+ const nonce = await this.entryPoint.getNonce(sender, nonceKey);
1461
1463
  const feeData = await this.provider.getFeeData();
1462
1464
  const maxFeePerGas = feeData.maxFeePerGas ?? ethers2.parseUnits("0.5", "gwei");
1463
1465
  const maxPriorityFeePerGas = feeData.maxPriorityFeePerGas ?? ethers2.parseUnits("0.1", "gwei");
@@ -1466,6 +1468,18 @@ var MorphoClient = class {
1466
1468
  const preVerificationGas = 100000n;
1467
1469
  const accountGasLimits = this._packUint128(verificationGasLimit, callGasLimit);
1468
1470
  const gasFees = this._packUint128(maxPriorityFeePerGas, maxFeePerGas);
1471
+ const requiredPrefund = (verificationGasLimit + callGasLimit + preVerificationGas) * maxFeePerGas;
1472
+ const accountBalance = await this.provider.getBalance(sender);
1473
+ if (accountBalance < requiredPrefund) {
1474
+ const topUp = requiredPrefund - accountBalance;
1475
+ const topUpWithBuffer = topUp * 120n / 100n;
1476
+ const fundTx = await this._signer.sendTransaction({
1477
+ to: sender,
1478
+ value: topUpWithBuffer
1479
+ });
1480
+ await fundTx.wait();
1481
+ this._refreshSigner();
1482
+ }
1469
1483
  const userOp = {
1470
1484
  sender,
1471
1485
  nonce,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agether/sdk",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "description": "TypeScript SDK for Agether - autonomous credit for AI agents on Base",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",