anymal-protocol 1.0.116 → 1.0.118

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
@@ -1268,34 +1268,38 @@ var ORGANIZATION_IMPL_ABI = [
1268
1268
  var import_react10 = require("react");
1269
1269
 
1270
1270
  // src/helpers/GasEstimateHelper.tsx
1271
- function applyBundlerGasEstimator(account, bundlerClient, options) {
1271
+ async function applyBundlerGasEstimator(account, bundlerClient, options) {
1272
1272
  const {
1273
1273
  callGasMultiplier = 1.2,
1274
1274
  verificationGasMultiplier = 1.2,
1275
1275
  preVerificationGasMultiplier = 2,
1276
+ maxCallGasPercentOfBlock = 0.1,
1277
+ // 10% for now?
1276
1278
  debug = true
1277
1279
  } = options || {};
1280
+ const publicClient = bundlerClient.client;
1281
+ const blockGasLimit = (await publicClient.getBlock()).gasLimit;
1282
+ const dynamicCallGasCap = blockGasLimit * BigInt(Math.floor(maxCallGasPercentOfBlock * 100)) / 100n;
1278
1283
  account.userOperation = {
1279
1284
  estimateGas: async (userOp) => {
1280
1285
  const estimate = await bundlerClient.estimateUserOperationGas(userOp);
1281
- const paddedCallGasLimit = BigInt(
1282
- estimate.callGasLimit * BigInt(Math.ceil(callGasMultiplier * 100)) / 100n
1283
- );
1284
- const paddedVerificationGasLimit = BigInt(
1285
- estimate.verificationGasLimit * BigInt(Math.ceil(verificationGasMultiplier * 100)) / 100n
1286
- );
1287
- const paddedPreVerificationGas = BigInt(
1288
- estimate.preVerificationGas * BigInt(Math.ceil(preVerificationGasMultiplier * 100)) / 100n
1289
- );
1286
+ const paddedCallGasLimit = estimate.callGasLimit * BigInt(Math.ceil(callGasMultiplier * 100)) / 100n;
1287
+ const cappedCallGasLimit = paddedCallGasLimit > dynamicCallGasCap ? dynamicCallGasCap : paddedCallGasLimit;
1288
+ const paddedVerificationGasLimit = estimate.verificationGasLimit * BigInt(Math.ceil(verificationGasMultiplier * 100)) / 100n;
1289
+ const paddedPreVerificationGas = estimate.preVerificationGas * BigInt(Math.ceil(preVerificationGasMultiplier * 100)) / 100n;
1290
1290
  if (debug) {
1291
1291
  console.log("\u{1F4E6} Bundler Gas Estimates:");
1292
- console.log(" callGasLimit:", paddedCallGasLimit.toString());
1292
+ console.log(" blockGasLimit:", blockGasLimit.toString());
1293
+ console.log(" maxCallGasLimit (% cap):", dynamicCallGasCap.toString());
1294
+ console.log(" original callGasLimit:", estimate.callGasLimit.toString());
1295
+ console.log(" padded callGasLimit:", paddedCallGasLimit.toString());
1296
+ console.log(" capped callGasLimit:", cappedCallGasLimit.toString());
1293
1297
  console.log(" verificationGasLimit:", paddedVerificationGasLimit.toString());
1294
1298
  console.log(" preVerificationGas:", paddedPreVerificationGas.toString());
1295
1299
  }
1296
1300
  return {
1297
1301
  ...estimate,
1298
- callGasLimit: paddedCallGasLimit,
1302
+ callGasLimit: cappedCallGasLimit,
1299
1303
  verificationGasLimit: paddedVerificationGasLimit,
1300
1304
  preVerificationGas: paddedPreVerificationGas
1301
1305
  };
@@ -1324,7 +1328,7 @@ function useMintAnymalNFT() {
1324
1328
  anymalTxId
1325
1329
  ]
1326
1330
  });
1327
- applyBundlerGasEstimator(smartAccount, bundlerClient);
1331
+ await applyBundlerGasEstimator(smartAccount, bundlerClient);
1328
1332
  const userOpHash = await bundlerClient.sendUserOperation({
1329
1333
  account: smartAccount,
1330
1334
  calls: [
@@ -1753,7 +1757,7 @@ function useProcessPartialKibblePayment() {
1753
1757
  functionName: "partialPay",
1754
1758
  args
1755
1759
  });
1756
- applyBundlerGasEstimator(smartAccount, bundlerClient);
1760
+ await applyBundlerGasEstimator(smartAccount, bundlerClient);
1757
1761
  const userOpHash = await bundlerClient.sendUserOperation({
1758
1762
  account: smartAccount,
1759
1763
  calls: [
@@ -1799,7 +1803,7 @@ function useApproveKibbleToken() {
1799
1803
  // amount to approve
1800
1804
  ]
1801
1805
  });
1802
- applyBundlerGasEstimator(smartAccount, bundlerClient);
1806
+ await applyBundlerGasEstimator(smartAccount, bundlerClient);
1803
1807
  const userOpHash = await bundlerClient.sendUserOperation({
1804
1808
  account: smartAccount,
1805
1809
  calls: [
@@ -1860,7 +1864,7 @@ function useCreateOrganizationBase() {
1860
1864
  functionName: "createOrganizationProxy",
1861
1865
  args: [ownerAddress, orgName, orgPid]
1862
1866
  });
1863
- applyBundlerGasEstimator(adminSmartAccount, bundlerClient);
1867
+ await applyBundlerGasEstimator(adminSmartAccount, bundlerClient);
1864
1868
  const userOpHash = await bundlerClient.sendUserOperation({
1865
1869
  account: adminSmartAccount,
1866
1870
  calls: [
@@ -1943,7 +1947,7 @@ function useApproveOrgPartialPayment() {
1943
1947
  functionName: "executeCall",
1944
1948
  args: [kibbleTokenAddress, approveCalldata]
1945
1949
  });
1946
- applyBundlerGasEstimator(managerSmartAccount, bundlerClient);
1950
+ await applyBundlerGasEstimator(managerSmartAccount, bundlerClient);
1947
1951
  const userOpApproveHash = await bundlerClient.sendUserOperation({
1948
1952
  account: managerSmartAccount,
1949
1953
  calls: [
@@ -2002,7 +2006,7 @@ function useProcessOrgPartialKibblePayment() {
2002
2006
  functionName: "executeCall",
2003
2007
  args: [partialPaymentModuleAddress, partialPayCalldata]
2004
2008
  });
2005
- applyBundlerGasEstimator(managerSmartAccount, bundlerClient);
2009
+ await applyBundlerGasEstimator(managerSmartAccount, bundlerClient);
2006
2010
  const userOpPartialPayHash = await bundlerClient.sendUserOperation({
2007
2011
  account: managerSmartAccount,
2008
2012
  calls: [
@@ -2465,7 +2469,7 @@ function useClaimActionReward() {
2465
2469
  functionName: "claimByIndex",
2466
2470
  args: [actionId, claimIndex]
2467
2471
  });
2468
- applyBundlerGasEstimator(smartAccount, bundlerClient);
2472
+ await applyBundlerGasEstimator(smartAccount, bundlerClient);
2469
2473
  const userOpHash = await bundlerClient.sendUserOperation({
2470
2474
  account: smartAccount,
2471
2475
  calls: [
@@ -2509,7 +2513,7 @@ function useClaimOrgActionReward() {
2509
2513
  functionName: "executeCall",
2510
2514
  args: [rewardableActionContractAddress, claimCallData]
2511
2515
  });
2512
- applyBundlerGasEstimator(smartAccount, bundlerClient);
2516
+ await applyBundlerGasEstimator(smartAccount, bundlerClient);
2513
2517
  const userOpHash = await bundlerClient.sendUserOperation({
2514
2518
  account: smartAccount,
2515
2519
  calls: [
package/dist/index.mjs CHANGED
@@ -1205,34 +1205,38 @@ var ORGANIZATION_IMPL_ABI = [
1205
1205
  import { useCallback as useCallback10 } from "react";
1206
1206
 
1207
1207
  // src/helpers/GasEstimateHelper.tsx
1208
- function applyBundlerGasEstimator(account, bundlerClient, options) {
1208
+ async function applyBundlerGasEstimator(account, bundlerClient, options) {
1209
1209
  const {
1210
1210
  callGasMultiplier = 1.2,
1211
1211
  verificationGasMultiplier = 1.2,
1212
1212
  preVerificationGasMultiplier = 2,
1213
+ maxCallGasPercentOfBlock = 0.1,
1214
+ // 10% for now?
1213
1215
  debug = true
1214
1216
  } = options || {};
1217
+ const publicClient = bundlerClient.client;
1218
+ const blockGasLimit = (await publicClient.getBlock()).gasLimit;
1219
+ const dynamicCallGasCap = blockGasLimit * BigInt(Math.floor(maxCallGasPercentOfBlock * 100)) / 100n;
1215
1220
  account.userOperation = {
1216
1221
  estimateGas: async (userOp) => {
1217
1222
  const estimate = await bundlerClient.estimateUserOperationGas(userOp);
1218
- const paddedCallGasLimit = BigInt(
1219
- estimate.callGasLimit * BigInt(Math.ceil(callGasMultiplier * 100)) / 100n
1220
- );
1221
- const paddedVerificationGasLimit = BigInt(
1222
- estimate.verificationGasLimit * BigInt(Math.ceil(verificationGasMultiplier * 100)) / 100n
1223
- );
1224
- const paddedPreVerificationGas = BigInt(
1225
- estimate.preVerificationGas * BigInt(Math.ceil(preVerificationGasMultiplier * 100)) / 100n
1226
- );
1223
+ const paddedCallGasLimit = estimate.callGasLimit * BigInt(Math.ceil(callGasMultiplier * 100)) / 100n;
1224
+ const cappedCallGasLimit = paddedCallGasLimit > dynamicCallGasCap ? dynamicCallGasCap : paddedCallGasLimit;
1225
+ const paddedVerificationGasLimit = estimate.verificationGasLimit * BigInt(Math.ceil(verificationGasMultiplier * 100)) / 100n;
1226
+ const paddedPreVerificationGas = estimate.preVerificationGas * BigInt(Math.ceil(preVerificationGasMultiplier * 100)) / 100n;
1227
1227
  if (debug) {
1228
1228
  console.log("\u{1F4E6} Bundler Gas Estimates:");
1229
- console.log(" callGasLimit:", paddedCallGasLimit.toString());
1229
+ console.log(" blockGasLimit:", blockGasLimit.toString());
1230
+ console.log(" maxCallGasLimit (% cap):", dynamicCallGasCap.toString());
1231
+ console.log(" original callGasLimit:", estimate.callGasLimit.toString());
1232
+ console.log(" padded callGasLimit:", paddedCallGasLimit.toString());
1233
+ console.log(" capped callGasLimit:", cappedCallGasLimit.toString());
1230
1234
  console.log(" verificationGasLimit:", paddedVerificationGasLimit.toString());
1231
1235
  console.log(" preVerificationGas:", paddedPreVerificationGas.toString());
1232
1236
  }
1233
1237
  return {
1234
1238
  ...estimate,
1235
- callGasLimit: paddedCallGasLimit,
1239
+ callGasLimit: cappedCallGasLimit,
1236
1240
  verificationGasLimit: paddedVerificationGasLimit,
1237
1241
  preVerificationGas: paddedPreVerificationGas
1238
1242
  };
@@ -1261,7 +1265,7 @@ function useMintAnymalNFT() {
1261
1265
  anymalTxId
1262
1266
  ]
1263
1267
  });
1264
- applyBundlerGasEstimator(smartAccount, bundlerClient);
1268
+ await applyBundlerGasEstimator(smartAccount, bundlerClient);
1265
1269
  const userOpHash = await bundlerClient.sendUserOperation({
1266
1270
  account: smartAccount,
1267
1271
  calls: [
@@ -1690,7 +1694,7 @@ function useProcessPartialKibblePayment() {
1690
1694
  functionName: "partialPay",
1691
1695
  args
1692
1696
  });
1693
- applyBundlerGasEstimator(smartAccount, bundlerClient);
1697
+ await applyBundlerGasEstimator(smartAccount, bundlerClient);
1694
1698
  const userOpHash = await bundlerClient.sendUserOperation({
1695
1699
  account: smartAccount,
1696
1700
  calls: [
@@ -1736,7 +1740,7 @@ function useApproveKibbleToken() {
1736
1740
  // amount to approve
1737
1741
  ]
1738
1742
  });
1739
- applyBundlerGasEstimator(smartAccount, bundlerClient);
1743
+ await applyBundlerGasEstimator(smartAccount, bundlerClient);
1740
1744
  const userOpHash = await bundlerClient.sendUserOperation({
1741
1745
  account: smartAccount,
1742
1746
  calls: [
@@ -1797,7 +1801,7 @@ function useCreateOrganizationBase() {
1797
1801
  functionName: "createOrganizationProxy",
1798
1802
  args: [ownerAddress, orgName, orgPid]
1799
1803
  });
1800
- applyBundlerGasEstimator(adminSmartAccount, bundlerClient);
1804
+ await applyBundlerGasEstimator(adminSmartAccount, bundlerClient);
1801
1805
  const userOpHash = await bundlerClient.sendUserOperation({
1802
1806
  account: adminSmartAccount,
1803
1807
  calls: [
@@ -1880,7 +1884,7 @@ function useApproveOrgPartialPayment() {
1880
1884
  functionName: "executeCall",
1881
1885
  args: [kibbleTokenAddress, approveCalldata]
1882
1886
  });
1883
- applyBundlerGasEstimator(managerSmartAccount, bundlerClient);
1887
+ await applyBundlerGasEstimator(managerSmartAccount, bundlerClient);
1884
1888
  const userOpApproveHash = await bundlerClient.sendUserOperation({
1885
1889
  account: managerSmartAccount,
1886
1890
  calls: [
@@ -1939,7 +1943,7 @@ function useProcessOrgPartialKibblePayment() {
1939
1943
  functionName: "executeCall",
1940
1944
  args: [partialPaymentModuleAddress, partialPayCalldata]
1941
1945
  });
1942
- applyBundlerGasEstimator(managerSmartAccount, bundlerClient);
1946
+ await applyBundlerGasEstimator(managerSmartAccount, bundlerClient);
1943
1947
  const userOpPartialPayHash = await bundlerClient.sendUserOperation({
1944
1948
  account: managerSmartAccount,
1945
1949
  calls: [
@@ -2322,7 +2326,7 @@ function useClaimActionReward() {
2322
2326
  functionName: "claimByIndex",
2323
2327
  args: [actionId, claimIndex]
2324
2328
  });
2325
- applyBundlerGasEstimator(smartAccount, bundlerClient);
2329
+ await applyBundlerGasEstimator(smartAccount, bundlerClient);
2326
2330
  const userOpHash = await bundlerClient.sendUserOperation({
2327
2331
  account: smartAccount,
2328
2332
  calls: [
@@ -2366,7 +2370,7 @@ function useClaimOrgActionReward() {
2366
2370
  functionName: "executeCall",
2367
2371
  args: [rewardableActionContractAddress, claimCallData]
2368
2372
  });
2369
- applyBundlerGasEstimator(smartAccount, bundlerClient);
2373
+ await applyBundlerGasEstimator(smartAccount, bundlerClient);
2370
2374
  const userOpHash = await bundlerClient.sendUserOperation({
2371
2375
  account: smartAccount,
2372
2376
  calls: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anymal-protocol",
3
- "version": "1.0.116",
3
+ "version": "1.0.118",
4
4
  "description": "A React/TypeScript-based utility library for reusable functions and hooks inside of the Anymal Ecosystem.",
5
5
  "main": "dist/index.js",
6
6
  "bin": {