@exodus/ethereum-api 0.2.8 → 0.2.11
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 +3 -3
- package/src/gas-estimation.js +9 -9
- package/src/with-fallback.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/ethereum-api",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.11",
|
|
4
4
|
"description": "Ethereum Api",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"author": "Exodus Movement, Inc.",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"access": "restricted"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@exodus/ethereum-lib": "^0.2.
|
|
13
|
+
"@exodus/ethereum-lib": "^0.2.11",
|
|
14
14
|
"fetchival": "0.3.3",
|
|
15
15
|
"lodash": "^4.17.11",
|
|
16
16
|
"make-concurrent": "4.0.0",
|
|
@@ -19,5 +19,5 @@
|
|
|
19
19
|
"url-join": "4.0.0",
|
|
20
20
|
"ws": "6.1.0"
|
|
21
21
|
},
|
|
22
|
-
"gitHead": "
|
|
22
|
+
"gitHead": "b3be7ab2c2dfba90b30aaaea41027fadb27f3571"
|
|
23
23
|
}
|
package/src/gas-estimation.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import BN from 'bn.js'
|
|
2
2
|
import * as ethUtil from 'ethereumjs-util'
|
|
3
3
|
import { currency2buffer, isEthereumToken, getBaseAsset } from '@exodus/ethereum-lib'
|
|
4
|
-
import { estimateGas } from './with-fallback'
|
|
4
|
+
import { estimateGas, isContract as _isContract } from './with-fallback'
|
|
5
5
|
|
|
6
6
|
const EXTRA_PERCENTAGE = 20
|
|
7
7
|
|
|
8
|
-
async function estimateGasLimit(
|
|
8
|
+
export async function estimateGasLimit(
|
|
9
9
|
asset: Object,
|
|
10
10
|
fromAddress: string,
|
|
11
11
|
toAddress: string,
|
|
@@ -51,20 +51,20 @@ export async function fetchGasLimit({
|
|
|
51
51
|
throwOnError = true,
|
|
52
52
|
extraPercentage,
|
|
53
53
|
}) {
|
|
54
|
+
if (!amount) amount = asset.currency.ZERO
|
|
55
|
+
|
|
54
56
|
const isToken = isEthereumToken(asset)
|
|
55
57
|
if (isToken) {
|
|
56
|
-
txInput = ethUtil.bufferToHex(
|
|
58
|
+
txInput = ethUtil.bufferToHex(
|
|
59
|
+
asset.contract.transfer.build(toAddress, amount.toBase().toNumberString())
|
|
60
|
+
)
|
|
57
61
|
amount = getBaseAsset(asset).currency.ZERO
|
|
58
|
-
toAddress = asset.contract.
|
|
62
|
+
toAddress = asset.contract.address
|
|
59
63
|
} else if (!isContract) {
|
|
60
|
-
if (isContract === undefined) isContract = await asset.
|
|
64
|
+
if (isContract === undefined) isContract = await _isContract(asset.name, toAddress)
|
|
61
65
|
if (!isContract) return asset.gasLimit
|
|
62
66
|
}
|
|
63
67
|
|
|
64
|
-
if (!amount) {
|
|
65
|
-
amount = asset.currency.ZERO
|
|
66
|
-
}
|
|
67
|
-
|
|
68
68
|
let gasPrice = ethUtil.bufferToHex(currency2buffer(feeData.gasPrice))
|
|
69
69
|
|
|
70
70
|
if (bip70 && bip70.bitpay) {
|
package/src/with-fallback.js
CHANGED
|
@@ -75,7 +75,7 @@ export async function getTokenBalance({ asset, address }) {
|
|
|
75
75
|
etherscan.tokenBalance
|
|
76
76
|
)
|
|
77
77
|
|
|
78
|
-
const contractAddress = asset.contract.
|
|
78
|
+
const contractAddress = asset.contract.address.toLowerCase()
|
|
79
79
|
return _getTokenBalance(contractAddress, address)
|
|
80
80
|
}
|
|
81
81
|
|