@exodus/ethereum-api 3.2.3 → 3.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/ethereum-api",
3
- "version": "3.2.3",
3
+ "version": "3.2.5",
4
4
  "description": "Ethereum Api",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -16,11 +16,12 @@
16
16
  "dependencies": {
17
17
  "@exodus/asset-lib": "^3.7.1",
18
18
  "@exodus/crypto": "^1.0.0-rc.0",
19
- "@exodus/ethereum-lib": "^2.23.1",
19
+ "@exodus/ethereum-lib": "^2.24.0",
20
20
  "@exodus/ethereumjs-util": "^7.1.0-exodus.6",
21
21
  "@exodus/fetch": "^1.2.1",
22
22
  "@exodus/simple-retry": "^0.0.6",
23
23
  "@exodus/solidity-contract": "^1.1.3",
24
+ "bn.js": "^5.2.1",
24
25
  "events": "^1.1.1",
25
26
  "idna-uts46-hx": "^2.3.1",
26
27
  "js-sha3": "^0.8.0",
@@ -34,5 +35,5 @@
34
35
  "devDependencies": {
35
36
  "@exodus/models": "^8.10.4"
36
37
  },
37
- "gitHead": "ee89f965a02a9580114c17a2ae059d92bd1b70d6"
38
+ "gitHead": "835e8e4b0197268cf458c971c38920de96e3b9f2"
38
39
  }
@@ -1,6 +1,7 @@
1
1
  import urlJoin from 'url-join'
2
2
  import url from 'url'
3
3
  import ms from 'ms'
4
+ import BN from 'bn.js'
4
5
  import createWebSocket from './ws'
5
6
  import { fetchival } from '@exodus/fetch'
6
7
  import { retry } from '@exodus/simple-retry'
@@ -83,9 +84,11 @@ export function create(defaultURL, ensAssetName) {
83
84
  tag,
84
85
  }
85
86
  const result = await retry(this.ethCall, { delayTimesMs: RETRY_DELAYS })(data)
87
+ const hex = result.startsWith('0x') ? result.slice(2) : result
88
+ const balance = new BN(hex, 'hex').toString()
86
89
  return {
87
90
  confirmed: {
88
- [tokenAddress]: parseInt(result, 16),
91
+ [tokenAddress]: balance,
89
92
  },
90
93
  }
91
94
  },
@@ -1,4 +1,5 @@
1
1
  /* @flow */
2
+ import BN from 'bn.js'
2
3
  import { getServer } from '@exodus/ethereum-api'
3
4
  import { isRpcBalanceAsset, getAssetAddresses } from '@exodus/ethereum-lib'
4
5
 
@@ -222,8 +223,9 @@ export class EthereumMonitor extends BaseMonitor {
222
223
  const newAccountState = {}
223
224
  const server = this.server
224
225
  if (isRpcBalanceAsset(asset)) {
225
- const balanceHex = await server.getBalanceProxied(ourWalletAddress)
226
- const balance = parseInt(balanceHex, 16)
226
+ const result = await server.getBalanceProxied(ourWalletAddress)
227
+ const hex = result.startsWith('0x') ? result.slice(2) : result
228
+ const balance = new BN(hex, 'hex').toString()
227
229
  newAccountState.balance = asset.currency.baseUnit(balance)
228
230
  }
229
231
  const tokenBalancePairs = await Promise.all(