@exodus/ethereum-api 0.2.4 → 0.2.5
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 -2
- package/src/with-fallback.js +4 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/ethereum-api",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "Ethereum Api",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"author": "Exodus Movement, Inc.",
|
|
@@ -12,11 +12,12 @@
|
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@exodus/ethereum-lib": "^0.2.4",
|
|
14
14
|
"fetchival": "0.3.3",
|
|
15
|
+
"lodash": "^4.17.11",
|
|
15
16
|
"make-concurrent": "4.0.0",
|
|
16
17
|
"ms": "^2.1.1",
|
|
17
18
|
"url": "0.10.3",
|
|
18
19
|
"url-join": "4.0.0",
|
|
19
20
|
"ws": "6.1.0"
|
|
20
21
|
},
|
|
21
|
-
"gitHead": "
|
|
22
|
+
"gitHead": "1aea414dc06c16373e47e97110eba29e9cab479e"
|
|
22
23
|
}
|
package/src/with-fallback.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { get } from 'lodash'
|
|
1
2
|
import { _isEthereumToken } from '@exodus/ethereum-lib'
|
|
2
3
|
import { eth as ethServer, etc as etcServer } from './exodus-eth-server'
|
|
3
4
|
import * as etherscan from './etherscan'
|
|
@@ -39,12 +40,12 @@ export async function estimateGas({ asset, ...args }) {
|
|
|
39
40
|
export async function getBalance({ asset, address }) {
|
|
40
41
|
const fetchEthereumBalance = withFallback(async (address) => {
|
|
41
42
|
const balances = await ethServer.getBalance(address)
|
|
42
|
-
return balances
|
|
43
|
+
return get(balances, 'confirmed.value', '0')
|
|
43
44
|
}, etherscan.fetchBalance)
|
|
44
45
|
|
|
45
46
|
const fetchEthereumClassicBalance = async (address) => {
|
|
46
47
|
const balances = await etcServer.getBalance(address)
|
|
47
|
-
return balances
|
|
48
|
+
return get(balances, 'confirmed.value', '0')
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
return (asset.name === 'ethereum' ? fetchEthereumBalance : fetchEthereumClassicBalance)(address)
|
|
@@ -56,7 +57,7 @@ export async function getTokenBalance({ asset, address }) {
|
|
|
56
57
|
|
|
57
58
|
return withFallback(async (contractAddress, address) => {
|
|
58
59
|
const balances = await ethServer.getBalance(address)
|
|
59
|
-
return balances
|
|
60
|
+
return get(balances, ['confirmed', contractAddress], '0')
|
|
60
61
|
}, etherscan.tokenBalance)(contractAddress, address)
|
|
61
62
|
}
|
|
62
63
|
|