@railgun-community/shared-models 2.0.3 → 2.0.5

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,5 +1,6 @@
1
1
  import { BigNumber } from '@ethersproject/bignumber';
2
2
  import { TransactionGasDetails } from '../models/response-types';
3
3
  export declare const calculateGasLimit: (gasEstimate: BigNumber) => BigNumber;
4
+ export declare const calculateGasPrice: (gasDetails: TransactionGasDetails) => BigNumber;
4
5
  export declare const calculateTotalGas: (transactionGasDetails: TransactionGasDetails) => BigNumber;
5
6
  export declare const calculateMaximumGas: (transactionGasDetails: TransactionGasDetails) => BigNumber;
package/dist/utils/gas.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  exports.__esModule = true;
3
- exports.calculateMaximumGas = exports.calculateTotalGas = exports.calculateGasLimit = void 0;
3
+ exports.calculateMaximumGas = exports.calculateTotalGas = exports.calculateGasPrice = exports.calculateGasLimit = void 0;
4
4
  var network_config_1 = require("../models/network-config");
5
5
  var calculateGasLimit = function (gasEstimate) {
6
6
  // Gas Limit: Add 20% to gas estimate.
@@ -13,19 +13,19 @@ var calculateGasPrice = function (gasDetails) {
13
13
  return gasDetails.gasPrice;
14
14
  }
15
15
  case network_config_1.EVMGasType.Type2: {
16
- var maxFeePerGas = gasDetails.maxFeePerGas, maxPriorityFeePerGas = gasDetails.maxPriorityFeePerGas;
17
- return maxFeePerGas.add(maxPriorityFeePerGas);
16
+ return gasDetails.maxFeePerGas;
18
17
  }
19
18
  }
20
19
  };
20
+ exports.calculateGasPrice = calculateGasPrice;
21
21
  var calculateTotalGas = function (transactionGasDetails) {
22
- var gasPrice = calculateGasPrice(transactionGasDetails);
22
+ var gasPrice = (0, exports.calculateGasPrice)(transactionGasDetails);
23
23
  var gasEstimate = transactionGasDetails.gasEstimate;
24
24
  return gasEstimate.mul(gasPrice);
25
25
  };
26
26
  exports.calculateTotalGas = calculateTotalGas;
27
27
  var calculateMaximumGas = function (transactionGasDetails) {
28
- var gasPrice = calculateGasPrice(transactionGasDetails);
28
+ var gasPrice = (0, exports.calculateGasPrice)(transactionGasDetails);
29
29
  var gasEstimate = transactionGasDetails.gasEstimate;
30
30
  return (0, exports.calculateGasLimit)(gasEstimate).mul(gasPrice);
31
31
  };
@@ -1 +1 @@
1
- {"version":3,"file":"gas.js","sourceRoot":"","sources":["../../src/utils/gas.ts"],"names":[],"mappings":";;;AACA,2DAAsD;AAG/C,IAAM,iBAAiB,GAAG,UAAC,WAAsB;IACtD,sCAAsC;IACtC,OAAO,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AAC3C,CAAC,CAAC;AAHW,QAAA,iBAAiB,qBAG5B;AAEF,IAAM,iBAAiB,GAAG,UAAC,UAAiC;IAC1D,QAAQ,UAAU,CAAC,UAAU,EAAE;QAC7B,KAAK,2BAAU,CAAC,KAAK,CAAC,CAAC;YACrB,OAAO,UAAU,CAAC,QAAQ,CAAC;SAC5B;QACD,KAAK,2BAAU,CAAC,KAAK,CAAC,CAAC;YACb,IAAA,YAAY,GAA2B,UAAU,aAArC,EAAE,oBAAoB,GAAK,UAAU,qBAAf,CAAgB;YAC1D,OAAO,YAAY,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;SAC/C;KACF;AACH,CAAC,CAAC;AAEK,IAAM,iBAAiB,GAAG,UAC/B,qBAA4C;IAE5C,IAAM,QAAQ,GAAG,iBAAiB,CAAC,qBAAqB,CAAC,CAAC;IAClD,IAAA,WAAW,GAAK,qBAAqB,YAA1B,CAA2B;IAC9C,OAAO,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AACnC,CAAC,CAAC;AANW,QAAA,iBAAiB,qBAM5B;AAEK,IAAM,mBAAmB,GAAG,UACjC,qBAA4C;IAE5C,IAAM,QAAQ,GAAG,iBAAiB,CAAC,qBAAqB,CAAC,CAAC;IAClD,IAAA,WAAW,GAAK,qBAAqB,YAA1B,CAA2B;IAC9C,OAAO,IAAA,yBAAiB,EAAC,WAAW,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AACtD,CAAC,CAAC;AANW,QAAA,mBAAmB,uBAM9B","sourcesContent":["import { BigNumber } from '@ethersproject/bignumber';\nimport { EVMGasType } from '../models/network-config';\nimport { TransactionGasDetails } from '../models/response-types';\n\nexport const calculateGasLimit = (gasEstimate: BigNumber): BigNumber => {\n // Gas Limit: Add 20% to gas estimate.\n return gasEstimate.mul(12000).div(10000);\n};\n\nconst calculateGasPrice = (gasDetails: TransactionGasDetails) => {\n switch (gasDetails.evmGasType) {\n case EVMGasType.Type0: {\n return gasDetails.gasPrice;\n }\n case EVMGasType.Type2: {\n const { maxFeePerGas, maxPriorityFeePerGas } = gasDetails;\n return maxFeePerGas.add(maxPriorityFeePerGas);\n }\n }\n};\n\nexport const calculateTotalGas = (\n transactionGasDetails: TransactionGasDetails,\n) => {\n const gasPrice = calculateGasPrice(transactionGasDetails);\n const { gasEstimate } = transactionGasDetails;\n return gasEstimate.mul(gasPrice);\n};\n\nexport const calculateMaximumGas = (\n transactionGasDetails: TransactionGasDetails,\n): BigNumber => {\n const gasPrice = calculateGasPrice(transactionGasDetails);\n const { gasEstimate } = transactionGasDetails;\n return calculateGasLimit(gasEstimate).mul(gasPrice);\n};\n"]}
1
+ {"version":3,"file":"gas.js","sourceRoot":"","sources":["../../src/utils/gas.ts"],"names":[],"mappings":";;;AACA,2DAAsD;AAG/C,IAAM,iBAAiB,GAAG,UAAC,WAAsB;IACtD,sCAAsC;IACtC,OAAO,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AAC3C,CAAC,CAAC;AAHW,QAAA,iBAAiB,qBAG5B;AAEK,IAAM,iBAAiB,GAAG,UAAC,UAAiC;IACjE,QAAQ,UAAU,CAAC,UAAU,EAAE;QAC7B,KAAK,2BAAU,CAAC,KAAK,CAAC,CAAC;YACrB,OAAO,UAAU,CAAC,QAAQ,CAAC;SAC5B;QACD,KAAK,2BAAU,CAAC,KAAK,CAAC,CAAC;YACrB,OAAO,UAAU,CAAC,YAAY,CAAC;SAChC;KACF;AACH,CAAC,CAAC;AATW,QAAA,iBAAiB,qBAS5B;AAEK,IAAM,iBAAiB,GAAG,UAC/B,qBAA4C;IAE5C,IAAM,QAAQ,GAAG,IAAA,yBAAiB,EAAC,qBAAqB,CAAC,CAAC;IAClD,IAAA,WAAW,GAAK,qBAAqB,YAA1B,CAA2B;IAC9C,OAAO,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AACnC,CAAC,CAAC;AANW,QAAA,iBAAiB,qBAM5B;AAEK,IAAM,mBAAmB,GAAG,UACjC,qBAA4C;IAE5C,IAAM,QAAQ,GAAG,IAAA,yBAAiB,EAAC,qBAAqB,CAAC,CAAC;IAClD,IAAA,WAAW,GAAK,qBAAqB,YAA1B,CAA2B;IAC9C,OAAO,IAAA,yBAAiB,EAAC,WAAW,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AACtD,CAAC,CAAC;AANW,QAAA,mBAAmB,uBAM9B","sourcesContent":["import { BigNumber } from '@ethersproject/bignumber';\nimport { EVMGasType } from '../models/network-config';\nimport { TransactionGasDetails } from '../models/response-types';\n\nexport const calculateGasLimit = (gasEstimate: BigNumber): BigNumber => {\n // Gas Limit: Add 20% to gas estimate.\n return gasEstimate.mul(12000).div(10000);\n};\n\nexport const calculateGasPrice = (gasDetails: TransactionGasDetails) => {\n switch (gasDetails.evmGasType) {\n case EVMGasType.Type0: {\n return gasDetails.gasPrice;\n }\n case EVMGasType.Type2: {\n return gasDetails.maxFeePerGas;\n }\n }\n};\n\nexport const calculateTotalGas = (\n transactionGasDetails: TransactionGasDetails,\n) => {\n const gasPrice = calculateGasPrice(transactionGasDetails);\n const { gasEstimate } = transactionGasDetails;\n return gasEstimate.mul(gasPrice);\n};\n\nexport const calculateMaximumGas = (\n transactionGasDetails: TransactionGasDetails,\n): BigNumber => {\n const gasPrice = calculateGasPrice(transactionGasDetails);\n const { gasEstimate } = transactionGasDetails;\n return calculateGasLimit(gasEstimate).mul(gasPrice);\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@railgun-community/shared-models",
3
- "version": "2.0.3",
3
+ "version": "2.0.5",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "files": [