@requestnetwork/utils 0.36.1-next.1904 → 0.36.1-next.1906

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.
@@ -1,4 +1,5 @@
1
1
  import { BigNumber, providers } from 'ethers';
2
+ import { LogTypes } from '@requestnetwork/types';
2
3
  /**
3
4
  * The function estimates gas fee with EIP-1559.
4
5
  * @param provider Generic provider.
@@ -8,9 +9,9 @@ import { BigNumber, providers } from 'ethers';
8
9
  * maxFeePerGas = baseFeePerGas + maxPriorityFeePerGas
9
10
  * The baseFeePerGas depends on how full the previous blocks were.
10
11
  * - maxPriorityFeePerGas: The maximum priority fee per unit of gas for this transaction.
11
- * - gasPrice: Optional fallback: the gas price for this transaction.
12
12
  */
13
- declare function estimateGasFees({ provider, gasPriceMin, }: {
13
+ declare function estimateGasFees({ logger, provider, gasPriceMin, }: {
14
+ logger: LogTypes.ILogger;
14
15
  provider: providers.Provider | providers.JsonRpcProvider;
15
16
  gasPriceMin?: BigNumber;
16
17
  }): Promise<{
@@ -1 +1 @@
1
- {"version":3,"file":"estimate-gas-fees.d.ts","sourceRoot":"","sources":["../src/estimate-gas-fees.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAa,SAAS,EAAE,MAAM,QAAQ,CAAC;AAIzD;;;;;;;;;;GAUG;AACH,iBAAe,eAAe,CAAC,EAC7B,QAAQ,EACR,WAAW,GACZ,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC,QAAQ,GAAG,SAAS,CAAC,eAAe,CAAC;IACzD,WAAW,CAAC,EAAE,SAAS,CAAC;CACzB,GAAG,OAAO,CAAC;IACV,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,oBAAoB,CAAC,EAAE,SAAS,CAAC;CAClC,CAAC,CAmBD;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
1
+ {"version":3,"file":"estimate-gas-fees.d.ts","sourceRoot":"","sources":["../src/estimate-gas-fees.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAa,SAAS,EAAE,MAAM,QAAQ,CAAC;AAGzD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD;;;;;;;;;GASG;AACH,iBAAe,eAAe,CAAC,EAC7B,MAAM,EACN,QAAQ,EACR,WAAW,GACZ,EAAE;IACD,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC;IACzB,QAAQ,EAAE,SAAS,CAAC,QAAQ,GAAG,SAAS,CAAC,eAAe,CAAC;IACzD,WAAW,CAAC,EAAE,SAAS,CAAC;CACzB,GAAG,OAAO,CAAC;IACV,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,oBAAoB,CAAC,EAAE,SAAS,CAAC;CAClC,CAAC,CA2BD;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
@@ -14,21 +14,27 @@ const index_1 = require("./index");
14
14
  * maxFeePerGas = baseFeePerGas + maxPriorityFeePerGas
15
15
  * The baseFeePerGas depends on how full the previous blocks were.
16
16
  * - maxPriorityFeePerGas: The maximum priority fee per unit of gas for this transaction.
17
- * - gasPrice: Optional fallback: the gas price for this transaction.
18
17
  */
19
- function estimateGasFees({ provider, gasPriceMin, }) {
18
+ function estimateGasFees({ logger, provider, gasPriceMin, }) {
20
19
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
21
- const suggestedFee = yield (0, fee_suggestions_1.suggestFees)(provider);
22
- const baseFee = (0, index_1.maxBigNumber)(suggestedFee.baseFeeSuggestion, gasPriceMin || ethers_1.constants.Zero);
23
- const maxPriorityFeePerGas = (0, index_1.maxBigNumber)(suggestedFee.maxPriorityFeeSuggestions.urgent, gasPriceMin || ethers_1.constants.Zero);
24
- const maxFeePerGas = baseFee.add(maxPriorityFeePerGas);
25
- if (maxPriorityFeePerGas.eq(0) || maxFeePerGas.eq(0)) {
20
+ try {
21
+ const suggestedFee = yield (0, fee_suggestions_1.suggestFees)(provider);
22
+ const baseFee = (0, index_1.maxBigNumber)(suggestedFee.baseFeeSuggestion, gasPriceMin || ethers_1.constants.Zero);
23
+ const maxPriorityFeePerGas = (0, index_1.maxBigNumber)(suggestedFee.maxPriorityFeeSuggestions.urgent, gasPriceMin || ethers_1.constants.Zero);
24
+ const maxFeePerGas = baseFee.add(maxPriorityFeePerGas);
25
+ if (maxPriorityFeePerGas.eq(0) || maxFeePerGas.eq(0)) {
26
+ logger.warn(`estimateGasFees: maxPriorityFeePerGas or maxFeePerGas too low (maxPriorityFeePerGas: ${maxPriorityFeePerGas.toString()} / maxFeePerGas: ${maxFeePerGas.toString()})`);
27
+ return {};
28
+ }
29
+ return {
30
+ maxPriorityFeePerGas,
31
+ maxFeePerGas,
32
+ };
33
+ }
34
+ catch (e) {
35
+ logger.error(`estimateGasFees error: ${e}`);
26
36
  return {};
27
37
  }
28
- return {
29
- maxPriorityFeePerGas,
30
- maxFeePerGas,
31
- };
32
38
  });
33
39
  }
34
40
  exports.estimateGasFees = estimateGasFees;
@@ -1 +1 @@
1
- {"version":3,"file":"estimate-gas-fees.js","sourceRoot":"","sources":["../src/estimate-gas-fees.ts"],"names":[],"mappings":";;;;AAAA,mCAAyD;AACzD,iEAA0D;AAC1D,mCAAuC;AAEvC;;;;;;;;;;GAUG;AACH,SAAe,eAAe,CAAC,EAC7B,QAAQ,EACR,WAAW,GAIZ;;QAIC,MAAM,YAAY,GAAG,MAAM,IAAA,6BAAW,EAAC,QAAqC,CAAC,CAAC;QAE9E,MAAM,OAAO,GAAG,IAAA,oBAAY,EAAC,YAAY,CAAC,iBAAiB,EAAE,WAAW,IAAI,kBAAS,CAAC,IAAI,CAAC,CAAC;QAE5F,MAAM,oBAAoB,GAAG,IAAA,oBAAY,EACvC,YAAY,CAAC,yBAAyB,CAAC,MAAM,EAC7C,WAAW,IAAI,kBAAS,CAAC,IAAI,CAC9B,CAAC;QACF,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;QAEvD,IAAI,oBAAoB,CAAC,EA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CAAe"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@requestnetwork/utils",
3
- "version": "0.36.1-next.1904+411d2588",
3
+ "version": "0.36.1-next.1906+44bf9fbd",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -41,7 +41,7 @@
41
41
  },
42
42
  "dependencies": {
43
43
  "@rainbow-me/fee-suggestions": "2.1.0",
44
- "@requestnetwork/types": "0.36.1-next.1904+411d2588",
44
+ "@requestnetwork/types": "0.36.1-next.1906+44bf9fbd",
45
45
  "eccrypto": "1.1.6",
46
46
  "ethers": "5.5.1",
47
47
  "secp256k1": "4.0.2",
@@ -57,5 +57,5 @@
57
57
  "ts-node": "10.9.1",
58
58
  "typescript": "4.9.5"
59
59
  },
60
- "gitHead": "411d2588bf50ac1dfd8a36ee82406c77c2833d34"
60
+ "gitHead": "44bf9fbde237839321aeb80955160c7eab8b0fb5"
61
61
  }