@exodus/ethereum-lib 4.2.1 → 4.2.3

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": "4.2.1",
3
+ "version": "4.2.3",
4
4
  "description": "Ethereum Library",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -44,5 +44,5 @@
44
44
  "ms": "^2.1.1",
45
45
  "reselect": "~3.0.1"
46
46
  },
47
- "gitHead": "419d8b4d0d4f8617b8da97a5dd9d3e328a948ae6"
47
+ "gitHead": "932d009fbd44833d111c7b73142f62e671623ab3"
48
48
  }
@@ -1,12 +1,13 @@
1
1
  import { FeeData } from '@exodus/asset-lib'
2
2
  import { asset } from '@exodus/cronos-meta'
3
3
 
4
+ // https://cronoscan.com/chart/gasprice
4
5
  export default new FeeData({
5
6
  config: {
6
- gasPrice: '5100 Gwei',
7
- max: '5700 Gwei',
8
- min: '4700 Gwei',
9
- fuelThreshold: '4800 Gwei',
7
+ gasPrice: '11250 Gwei',
8
+ max: '250000 Gwei',
9
+ min: '10000 Gwei',
10
+ fuelThreshold: '10000 Gwei',
10
11
  gasPriceEconomicalRate: 0.8,
11
12
  gasPriceMinimumRate: 0.6,
12
13
  enableFeeDelegation: false,
@@ -1,47 +1,38 @@
1
- /* @flow */
2
1
  import { Transaction, FeeMarketEIP1559Transaction } from '@exodus/ethereumjs-tx'
3
- import Common from '@exodus/ethereumjs-common'
2
+ import Common, { Hardfork } from '@exodus/ethereumjs-common'
4
3
 
5
- import type { UnsignedTransaction } from '@exodus/models/lib/types'
6
- import { CUSTOM_CHAINS } from '../constants'
7
-
8
- export default function createEthereumJsTx(unsignedTx: UnsignedTransaction) {
4
+ export default function createEthereumJsTx(unsignedTx) {
9
5
  const {
10
- txData: { gasPrice, tipGasPrice: maxPriorityFeePerGas, chainId: chain, ...txData },
6
+ txData: { chainId, ...txData },
11
7
  txMeta: { eip1559Enabled },
12
8
  } = unsignedTx
9
+ const { gasPrice, tipGasPrice } = txData
13
10
 
14
- let tx
15
11
  /*
16
- To assemble an EIP 1559 tx,
17
- both `tipGasPrice` and `eip` must have been set in the input object used to build `unsignedTx`.
18
- Whether bsc will support EIP 1559 is unknown.
19
- So we must prevent building accidentally an EIP1559 tx on bsc if tipGasPrice is set
20
- `eip` will be set with s corresponding feature flag in the wallet
12
+ EIP1559 is not supported by all ethereum-like assets.
13
+ e.g BSC does not support EIP1559 at the moment, prevent building an EIP1559 transaction
14
+ if `tipGasPrice` or `maxPriorityFeePerGas` is set.
21
15
  */
22
- if (maxPriorityFeePerGas && eip1559Enabled) {
23
- tx = FeeMarketEIP1559Transaction.fromTxData(
16
+ const isEip1559Tx = !!(unsignedTx.txData.tipGasPrice || unsignedTx.txData.maxPriorityFeePerGas)
17
+ if (eip1559Enabled && isEip1559Tx) {
18
+ return FeeMarketEIP1559Transaction.fromTxData(
24
19
  {
25
20
  maxFeePerGas: gasPrice,
26
- maxPriorityFeePerGas,
27
- type: '0x02', // https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/tx#gas-fee-market-transactions-eip-1559,
21
+ maxPriorityFeePerGas: tipGasPrice,
22
+ // `maxPriorityFeePerGas`, `maxFeePerGas` set in `txData` below take precedence over ^.
28
23
  ...txData,
29
24
  },
30
25
  {
31
- common: new Common({
32
- chain,
33
- hardfork: 'london',
34
- customChains: CUSTOM_CHAINS,
35
- eips: [1559],
36
- }),
26
+ common: Common.custom(
27
+ {
28
+ chainId,
29
+ },
30
+ { hardfork: Hardfork.London }
31
+ ),
37
32
  }
38
33
  )
39
34
  } else {
40
35
  // Legacy tx
41
- tx = Transaction.fromTxData(
42
- { gasPrice, ...txData },
43
- { common: Common.custom({ chainId: chain }) }
44
- )
36
+ return Transaction.fromTxData(txData, { common: Common.custom({ chainId }) })
45
37
  }
46
- return tx
47
38
  }