@toruslabs/ethereum-controllers 8.6.0 → 8.6.2

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.
@@ -15,7 +15,7 @@ class MetamaskSmartAccount {
15
15
  this.options = options;
16
16
  }
17
17
  async getSmartAccount(input) {
18
- var _this$options, _this$options2, _this$options3, _this$options4, _this$options5, _this$options6, _this$options7, _this$options$multiSi, _this$options8, _this$options9, _this$options$deployS, _this$options10, _this$options$impleme, _this$options11;
18
+ var _this$options, _this$options2, _this$options3, _this$options4, _this$options5, _this$options6, _this$options7, _this$options$multiSi, _this$options8, _this$options9, _this$options$deployS, _this$options0, _this$options$impleme, _this$options1;
19
19
  const hybridSignatory = {
20
20
  walletClient: input.walletClient,
21
21
  webAuthnAccount: (_this$options = this.options) === null || _this$options === void 0 || (_this$options = _this$options.hybridParams) === null || _this$options === void 0 ? void 0 : _this$options.webAuthnAccount,
@@ -31,9 +31,9 @@ class MetamaskSmartAccount {
31
31
  const multiSigDeployParams = [[eoaAddress, ...(((_this$options7 = this.options) === null || _this$options7 === void 0 || (_this$options7 = _this$options7.multiSigParams) === null || _this$options7 === void 0 ? void 0 : _this$options7.additionalSignerAddresses) || [])], (_this$options$multiSi = (_this$options8 = this.options) === null || _this$options8 === void 0 || (_this$options8 = _this$options8.multiSigParams) === null || _this$options8 === void 0 ? void 0 : _this$options8.threshold) !== null && _this$options$multiSi !== void 0 ? _this$options$multiSi : BigInt(1 + (((_this$options9 = this.options) === null || _this$options9 === void 0 || (_this$options9 = _this$options9.multiSigParams) === null || _this$options9 === void 0 || (_this$options9 = _this$options9.additionalSignerWalletClients) === null || _this$options9 === void 0 ? void 0 : _this$options9.length) || 0))];
32
32
  const baseParams = {
33
33
  client: input.client,
34
- deploySalt: (_this$options$deployS = (_this$options10 = this.options) === null || _this$options10 === void 0 ? void 0 : _this$options10.deploySalt) !== null && _this$options$deployS !== void 0 ? _this$options$deployS : "0x0"
34
+ deploySalt: (_this$options$deployS = (_this$options0 = this.options) === null || _this$options0 === void 0 ? void 0 : _this$options0.deploySalt) !== null && _this$options$deployS !== void 0 ? _this$options$deployS : "0x0"
35
35
  };
36
- const implementation = (_this$options$impleme = (_this$options11 = this.options) === null || _this$options11 === void 0 ? void 0 : _this$options11.implementation) !== null && _this$options$impleme !== void 0 ? _this$options$impleme : delegationToolkit.Implementation.Hybrid;
36
+ const implementation = (_this$options$impleme = (_this$options1 = this.options) === null || _this$options1 === void 0 ? void 0 : _this$options1.implementation) !== null && _this$options$impleme !== void 0 ? _this$options$impleme : delegationToolkit.Implementation.Hybrid;
37
37
  if (isImplementationHybrid(implementation)) {
38
38
  const params = _objectSpread(_objectSpread({}, baseParams), {}, {
39
39
  implementation,
@@ -43,18 +43,34 @@ async function fetchGasEstimatesViaEthFeeHistory(provider) {
43
43
  const finalBaseFeePerGas = feeHistory.baseFeePerGas[feeHistory.baseFeePerGas.length - 1];
44
44
  // this is in hex wei
45
45
  const rewardList = feeHistory.reward.filter(reward => reward[0] !== "0x0" || reward[1] !== "0x0" || reward[2] !== "0x0");
46
- const numberOfRewards = rewardList.length || 1;
47
- const priorityFeeCalcs = rewardList.reduce((acc, curr) => {
48
- return {
49
- slow: acc.slow.plus(new bignumber_js.BigNumber(curr[0], 16)),
50
- average: acc.average.plus(new bignumber_js.BigNumber(curr[1], 16)),
51
- fast: acc.fast.plus(new bignumber_js.BigNumber(curr[2], 16))
46
+ let priorityFeeCalcs;
47
+ let numberOfRewards;
48
+ if (rewardList.length > 0) {
49
+ priorityFeeCalcs = rewardList.reduce((acc, curr) => {
50
+ return {
51
+ slow: acc.slow.plus(new bignumber_js.BigNumber(curr[0], 16)),
52
+ average: acc.average.plus(new bignumber_js.BigNumber(curr[1], 16)),
53
+ fast: acc.fast.plus(new bignumber_js.BigNumber(curr[2], 16))
54
+ };
55
+ }, {
56
+ slow: new bignumber_js.BigNumber(0),
57
+ average: new bignumber_js.BigNumber(0),
58
+ fast: new bignumber_js.BigNumber(0)
59
+ });
60
+ numberOfRewards = rewardList.length;
61
+ } else {
62
+ // fallback to eth_maxPriorityFeePerGas if there are no rewards
63
+ const maxPriorityFeePerGasResult = await provider.request({
64
+ method: "eth_maxPriorityFeePerGas"
65
+ });
66
+ const maxPriorityFeePerGas = new bignumber_js.BigNumber(maxPriorityFeePerGasResult, 16);
67
+ priorityFeeCalcs = {
68
+ slow: maxPriorityFeePerGas,
69
+ average: maxPriorityFeePerGas.multipliedBy(1.1),
70
+ fast: maxPriorityFeePerGas.multipliedBy(1.5)
52
71
  };
53
- }, {
54
- slow: new bignumber_js.BigNumber(0),
55
- average: new bignumber_js.BigNumber(0),
56
- fast: new bignumber_js.BigNumber(0)
57
- });
72
+ numberOfRewards = 1;
73
+ }
58
74
  return {
59
75
  estimatedBaseFee: conversionUtils.hexWEIToDecGWEI(finalBaseFeePerGas).toString(10),
60
76
  high: {
@@ -188,8 +188,8 @@ const conversionGTE = (_ref7, _ref8) => {
188
188
  const secondValue = converter(_objectSpread({}, secondProps));
189
189
  return firstValue.isGreaterThanOrEqualTo(secondValue);
190
190
  };
191
- const conversionLTE = (_ref9, _ref10) => {
192
- let secondProps = Object.assign({}, (_objectDestructuringEmpty(_ref10), _ref10));
191
+ const conversionLTE = (_ref9, _ref0) => {
192
+ let secondProps = Object.assign({}, (_objectDestructuringEmpty(_ref0), _ref0));
193
193
  let firstProps = Object.assign({}, (_objectDestructuringEmpty(_ref9), _ref9));
194
194
  const firstValue = converter(_objectSpread({}, firstProps));
195
195
  const secondValue = converter(_objectSpread({}, secondProps));
@@ -13,7 +13,7 @@ class MetamaskSmartAccount {
13
13
  this.options = options;
14
14
  }
15
15
  async getSmartAccount(input) {
16
- var _this$options, _this$options2, _this$options3, _this$options4, _this$options5, _this$options6, _this$options7, _this$options$multiSi, _this$options8, _this$options9, _this$options$deployS, _this$options10, _this$options$impleme, _this$options11;
16
+ var _this$options, _this$options2, _this$options3, _this$options4, _this$options5, _this$options6, _this$options7, _this$options$multiSi, _this$options8, _this$options9, _this$options$deployS, _this$options0, _this$options$impleme, _this$options1;
17
17
  const hybridSignatory = {
18
18
  walletClient: input.walletClient,
19
19
  webAuthnAccount: (_this$options = this.options) === null || _this$options === void 0 || (_this$options = _this$options.hybridParams) === null || _this$options === void 0 ? void 0 : _this$options.webAuthnAccount,
@@ -29,9 +29,9 @@ class MetamaskSmartAccount {
29
29
  const multiSigDeployParams = [[eoaAddress, ...(((_this$options7 = this.options) === null || _this$options7 === void 0 || (_this$options7 = _this$options7.multiSigParams) === null || _this$options7 === void 0 ? void 0 : _this$options7.additionalSignerAddresses) || [])], (_this$options$multiSi = (_this$options8 = this.options) === null || _this$options8 === void 0 || (_this$options8 = _this$options8.multiSigParams) === null || _this$options8 === void 0 ? void 0 : _this$options8.threshold) !== null && _this$options$multiSi !== void 0 ? _this$options$multiSi : BigInt(1 + (((_this$options9 = this.options) === null || _this$options9 === void 0 || (_this$options9 = _this$options9.multiSigParams) === null || _this$options9 === void 0 || (_this$options9 = _this$options9.additionalSignerWalletClients) === null || _this$options9 === void 0 ? void 0 : _this$options9.length) || 0))];
30
30
  const baseParams = {
31
31
  client: input.client,
32
- deploySalt: (_this$options$deployS = (_this$options10 = this.options) === null || _this$options10 === void 0 ? void 0 : _this$options10.deploySalt) !== null && _this$options$deployS !== void 0 ? _this$options$deployS : "0x0"
32
+ deploySalt: (_this$options$deployS = (_this$options0 = this.options) === null || _this$options0 === void 0 ? void 0 : _this$options0.deploySalt) !== null && _this$options$deployS !== void 0 ? _this$options$deployS : "0x0"
33
33
  };
34
- const implementation = (_this$options$impleme = (_this$options11 = this.options) === null || _this$options11 === void 0 ? void 0 : _this$options11.implementation) !== null && _this$options$impleme !== void 0 ? _this$options$impleme : Implementation.Hybrid;
34
+ const implementation = (_this$options$impleme = (_this$options1 = this.options) === null || _this$options1 === void 0 ? void 0 : _this$options1.implementation) !== null && _this$options$impleme !== void 0 ? _this$options$impleme : Implementation.Hybrid;
35
35
  if (isImplementationHybrid(implementation)) {
36
36
  const params = _objectSpread(_objectSpread({}, baseParams), {}, {
37
37
  implementation,
@@ -41,18 +41,34 @@ async function fetchGasEstimatesViaEthFeeHistory(provider) {
41
41
  const finalBaseFeePerGas = feeHistory.baseFeePerGas[feeHistory.baseFeePerGas.length - 1];
42
42
  // this is in hex wei
43
43
  const rewardList = feeHistory.reward.filter(reward => reward[0] !== "0x0" || reward[1] !== "0x0" || reward[2] !== "0x0");
44
- const numberOfRewards = rewardList.length || 1;
45
- const priorityFeeCalcs = rewardList.reduce((acc, curr) => {
46
- return {
47
- slow: acc.slow.plus(new BigNumber(curr[0], 16)),
48
- average: acc.average.plus(new BigNumber(curr[1], 16)),
49
- fast: acc.fast.plus(new BigNumber(curr[2], 16))
44
+ let priorityFeeCalcs;
45
+ let numberOfRewards;
46
+ if (rewardList.length > 0) {
47
+ priorityFeeCalcs = rewardList.reduce((acc, curr) => {
48
+ return {
49
+ slow: acc.slow.plus(new BigNumber(curr[0], 16)),
50
+ average: acc.average.plus(new BigNumber(curr[1], 16)),
51
+ fast: acc.fast.plus(new BigNumber(curr[2], 16))
52
+ };
53
+ }, {
54
+ slow: new BigNumber(0),
55
+ average: new BigNumber(0),
56
+ fast: new BigNumber(0)
57
+ });
58
+ numberOfRewards = rewardList.length;
59
+ } else {
60
+ // fallback to eth_maxPriorityFeePerGas if there are no rewards
61
+ const maxPriorityFeePerGasResult = await provider.request({
62
+ method: "eth_maxPriorityFeePerGas"
63
+ });
64
+ const maxPriorityFeePerGas = new BigNumber(maxPriorityFeePerGasResult, 16);
65
+ priorityFeeCalcs = {
66
+ slow: maxPriorityFeePerGas,
67
+ average: maxPriorityFeePerGas.multipliedBy(1.1),
68
+ fast: maxPriorityFeePerGas.multipliedBy(1.5)
50
69
  };
51
- }, {
52
- slow: new BigNumber(0),
53
- average: new BigNumber(0),
54
- fast: new BigNumber(0)
55
- });
70
+ numberOfRewards = 1;
71
+ }
56
72
  return {
57
73
  estimatedBaseFee: hexWEIToDecGWEI(finalBaseFeePerGas).toString(10),
58
74
  high: {
@@ -190,8 +190,8 @@ const conversionGTE = (_ref7, _ref8) => {
190
190
  const secondValue = converter(_objectSpread({}, secondProps));
191
191
  return firstValue.isGreaterThanOrEqualTo(secondValue);
192
192
  };
193
- const conversionLTE = (_ref9, _ref10) => {
194
- let secondProps = Object.assign({}, (_objectDestructuringEmpty(_ref10), _ref10));
193
+ const conversionLTE = (_ref9, _ref0) => {
194
+ let secondProps = Object.assign({}, (_objectDestructuringEmpty(_ref0), _ref0));
195
195
  let firstProps = Object.assign({}, (_objectDestructuringEmpty(_ref9), _ref9));
196
196
  const firstValue = converter(_objectSpread({}, firstProps));
197
197
  const secondValue = converter(_objectSpread({}, secondProps));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toruslabs/ethereum-controllers",
3
- "version": "8.6.0",
3
+ "version": "8.6.2",
4
4
  "homepage": "https://github.com/torusresearch/controllers#readme",
5
5
  "license": "ISC",
6
6
  "sideEffects": false,
@@ -20,20 +20,20 @@
20
20
  },
21
21
  "dependencies": {
22
22
  "@ethereumjs/util": "^9.1.0",
23
- "@metamask/delegation-toolkit": "^0.11.0",
24
- "@toruslabs/base-controllers": "^8.6.0",
23
+ "@metamask/delegation-toolkit": "~0.11.0",
24
+ "@toruslabs/base-controllers": "^8.6.1",
25
25
  "@toruslabs/http-helpers": "^8.1.1",
26
26
  "@web3auth/auth": "^10.5.0",
27
27
  "async-mutex": "^0.5.0",
28
- "bignumber.js": "^9.3.0",
28
+ "bignumber.js": "^9.3.1",
29
29
  "bn.js": "^5.2.2",
30
30
  "deepmerge": "^4.3.1",
31
- "ethers": "^6.14.4",
31
+ "ethers": "^6.15.0",
32
32
  "fast-json-patch": "^3.1.1",
33
33
  "fast-safe-stringify": "^2.1.1",
34
34
  "jsonschema": "^1.5.0",
35
35
  "loglevel": "^1.9.2",
36
- "permissionless": "^0.2.47"
36
+ "permissionless": "^0.2.51"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "@babel/runtime": "7.x",
@@ -63,7 +63,7 @@
63
63
  "publishConfig": {
64
64
  "access": "public"
65
65
  },
66
- "gitHead": "5b75c7f687ad06d956fb50edced471c37d62b343",
66
+ "gitHead": "beebbf356d173fa11937386e597a632b92282217",
67
67
  "devDependencies": {
68
68
  "@typechain/ethers-v6": "^0.5.1",
69
69
  "typechain": "^8.3.2"