@exodus/ethereum-lib 2.7.1 → 2.7.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": "2.7.
|
|
3
|
+
"version": "2.7.3",
|
|
4
4
|
"description": "Ethereum Library",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"author": "Exodus Movement, Inc.",
|
|
@@ -23,5 +23,5 @@
|
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"@exodus/assets": "8.0.x"
|
|
25
25
|
},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "c9ae40c620c5f8378550977516ffd4f4d03663a8"
|
|
27
27
|
}
|
package/src/fee-data/bsc.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ethUtil from 'ethereumjs-util'
|
|
2
|
-
import {
|
|
2
|
+
import { isToken, currency2buffer } from '../utils'
|
|
3
3
|
import { CHAIN_IDS } from '../constants'
|
|
4
4
|
|
|
5
5
|
import type { UnsignedTransaction } from '#/app-models'
|
|
@@ -25,9 +25,9 @@ export default function createUnsignedTx({
|
|
|
25
25
|
const baseAsset = asset.baseAsset
|
|
26
26
|
if (!chainId) chainId = CHAIN_IDS[baseAsset.name] // mainnet
|
|
27
27
|
|
|
28
|
-
const
|
|
29
|
-
const to =
|
|
30
|
-
let value = currency2buffer(
|
|
28
|
+
const _isToken = isToken(asset)
|
|
29
|
+
const to = _isToken ? asset.contract.address : address
|
|
30
|
+
let value = currency2buffer(_isToken ? baseAsset.currency.ZERO : amount)
|
|
31
31
|
|
|
32
32
|
// TODO: check: present on desktop missing on mobile. This insures we never have a buffer specifying 0.
|
|
33
33
|
// In ETH, a buffer of zero length and a buffer specifying 0 imply different things
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* @flow */
|
|
2
2
|
import * as ethUtil from 'ethereumjs-util'
|
|
3
|
-
import {
|
|
3
|
+
import { isToken, buffer2currency } from '../utils'
|
|
4
4
|
import { CHAIN_IDS } from '../constants'
|
|
5
5
|
|
|
6
6
|
import type { UnsignedTransaction, ParsedTransaction } from '@exodus/models/lib/types'
|
|
@@ -10,7 +10,7 @@ export default function parseUnsignedTx(
|
|
|
10
10
|
unsignedTx: UnsignedTransaction
|
|
11
11
|
): ParsedTransaction {
|
|
12
12
|
const { txData } = unsignedTx
|
|
13
|
-
const
|
|
13
|
+
const _isToken = isToken(asset)
|
|
14
14
|
const baseAsset = asset.baseAsset
|
|
15
15
|
const gasPrice = buffer2currency({ asset: baseAsset, value: txData.gasPrice })
|
|
16
16
|
const gasLimit = ethUtil.bufferToInt(txData.gasLimit)
|
|
@@ -18,7 +18,7 @@ export default function parseUnsignedTx(
|
|
|
18
18
|
let { to, chainId, data } = txData
|
|
19
19
|
let amount
|
|
20
20
|
const fee = gasPrice.mul(gasLimit)
|
|
21
|
-
if (
|
|
21
|
+
if (_isToken) {
|
|
22
22
|
const { method, values } = asset.contract.decodeInput(data)
|
|
23
23
|
if (method === 'transfer' || method === 'approve') {
|
|
24
24
|
to = values[0]
|
|
@@ -2,12 +2,16 @@ import baseX from 'base-x'
|
|
|
2
2
|
import * as ethUtil from 'ethereumjs-util'
|
|
3
3
|
import assets from '@exodus/assets'
|
|
4
4
|
|
|
5
|
+
export { default as calculateExtraEth } from './calculate-extra-eth'
|
|
6
|
+
|
|
5
7
|
const base10 = baseX('0123456789')
|
|
6
8
|
const base16 = baseX('0123456789abcdef')
|
|
7
9
|
|
|
8
10
|
export const isEthereumToken = (asset) => asset.assetType === 'ETHEREUM_ERC20'
|
|
9
11
|
export const isBscToken = (asset) => asset.assetType === 'BSC_BEP20'
|
|
10
12
|
export const isQuorumToken = (asset) => asset.assetType === 'QUORUM_ERC20'
|
|
13
|
+
export const isToken = (asset) =>
|
|
14
|
+
isEthereumToken(asset) || isBscToken(asset) || isQuorumToken(asset)
|
|
11
15
|
|
|
12
16
|
export function buffer2currency({ asset, value }) {
|
|
13
17
|
return asset.currency.baseUnit(base10.encode(value)).toDefault()
|