@exodus/ethereum-lib 2.8.0 → 2.8.1
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 +2 -2
- package/src/utils/index.js +18 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/ethereum-lib",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.1",
|
|
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": "
|
|
27
|
+
"gitHead": "beb8b96a02d08dc9e32746e65d3c666cc77ed746"
|
|
28
28
|
}
|
package/src/utils/index.js
CHANGED
|
@@ -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
|
+
}
|