@exodus/ethereum-lib 2.8.0 → 2.9.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/ethereum-lib",
3
- "version": "2.8.0",
3
+ "version": "2.9.0",
4
4
  "description": "Ethereum Library",
5
5
  "main": "src/index.js",
6
6
  "author": "Exodus Movement, Inc.",
@@ -24,5 +24,5 @@
24
24
  "peerDependencies": {
25
25
  "@exodus/assets": "8.0.x"
26
26
  },
27
- "gitHead": "a9971be6cc00557bc1581c6801c90ae8702b4712"
27
+ "gitHead": "ecc9107ae18540696fb91a30c84cc99158770826"
28
28
  }
package/src/constants.js CHANGED
@@ -1,10 +1,11 @@
1
- export const CHAIN_IDS = { ethereum: 1, ethereumclassic: 61, bsc: 56 }
1
+ export const CHAIN_IDS = { ethereum: 1, ethereumclassic: 61, bsc: 56, matic: 137 }
2
2
  export const MIN_GASPRICE = 1e9 // 1 gwei
3
3
  export const DEFAULT_FEE_MONITOR_INTERVAL = '1m'
4
4
  export const CONFIRMATIONS_NUMBER = {
5
5
  ethereum: 30,
6
6
  ethereumclassic: 5000,
7
7
  bsc: 15,
8
+ matic: 355,
8
9
  }
9
- export const ETHEREUM_LIKE_ASSETS = ['bsc', 'ethereum', 'ethereumclassic']
10
- export const ETHEREUM_LIKE_TOKEN_TYPES = ['ETHEREUM_ERC20', 'BSC_BEP20']
10
+ export const ETHEREUM_LIKE_ASSETS = ['bsc', 'ethereum', 'ethereumclassic', 'matic']
11
+ export const ETHEREUM_LIKE_TOKEN_TYPES = ['ETHEREUM_ERC20', 'BSC_BEP20', 'MATIC_ERC20']
@@ -1,3 +1,4 @@
1
1
  export { default as ethereum } from './ethereum'
2
2
  export { default as ethereumclassic } from './ethereumclassic'
3
3
  export { default as bsc } from './bsc'
4
+ export { default as matic } from './polygon'
@@ -0,0 +1,15 @@
1
+ import { FeeData } from '@exodus/asset-lib'
2
+
3
+ export default new FeeData(
4
+ {
5
+ // https://polygonscan.com/chart/gasprice
6
+ gasPrice: '5 Gwei',
7
+ max: '100 Gwei',
8
+ min: '1 Gwei',
9
+ erc20FuelThreshold: '2500000 Gwei',
10
+ gasPriceEconomicalRate: 0.8,
11
+ gasPriceMinimumRate: 0.6,
12
+ },
13
+ 'gasPrice',
14
+ 'matic'
15
+ )
@@ -2,6 +2,7 @@ import baseX from 'base-x'
2
2
  import * as ethUtil from 'ethereumjs-util'
3
3
  import assets from '@exodus/assets'
4
4
  import { ETHEREUM_LIKE_ASSETS, ETHEREUM_LIKE_TOKEN_TYPES } from '../constants'
5
+ import { FeeMarketEIP1559Transaction, Transaction } from '@ethereumjs/tx'
5
6
 
6
7
  export { default as calculateExtraEth } from './calculate-extra-eth'
7
8
 
@@ -48,3 +49,20 @@ export function getBaseAsset(asset) {
48
49
  console.log(`calling deprecated function getBaseAsset(${asset.name})`) // Apr. 9th 2021
49
50
  return isEthereumToken(asset) ? assets.ethereum : asset
50
51
  }
52
+
53
+ export function deserialize(hex) {
54
+ const buf = ethUtil.toBuffer(hex)
55
+ try {
56
+ return FeeMarketEIP1559Transaction.fromSerializedTx(buf)
57
+ } catch (error) {
58
+ return Transaction.fromSerializedTx(buf)
59
+ }
60
+ }
61
+
62
+ export function gasPriceFromFeeData(feeData) {
63
+ const { baseFeeMultiplier, baseFee, tipGasPrice, gasPrice, eip1559Enabled } = feeData
64
+
65
+ return eip1559Enabled
66
+ ? { gasPrice: baseFee.mul(baseFeeMultiplier).add(tipGasPrice), tipGasPrice }
67
+ : { gasPrice }
68
+ }