@exodus/ethereum-api 3.1.0 → 3.2.2

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.1.0",
3
+ "version": "3.2.2",
4
4
  "description": "Ethereum Api",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -16,11 +16,11 @@
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.22.2",
19
+ "@exodus/ethereum-lib": "^2.23.1",
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
- "@exodus/solidity-contract": "^1.0.1",
23
+ "@exodus/solidity-contract": "^1.1.3",
24
24
  "events": "^1.1.1",
25
25
  "idna-uts46-hx": "^2.3.1",
26
26
  "js-sha3": "^0.8.0",
@@ -34,5 +34,5 @@
34
34
  "devDependencies": {
35
35
  "@exodus/models": "^8.10.4"
36
36
  },
37
- "gitHead": "d97519a8bacb8f2d9700248b2d7723fef284c56c"
37
+ "gitHead": "1377dedb12a5a4bf64f860f041ff73d722ffa308"
38
38
  }
@@ -38,6 +38,14 @@ export async function getBalance({ asset, address }) {
38
38
  return balances?.confirmed?.value || '0'
39
39
  }
40
40
 
41
+ // Only base assets, not tokens
42
+ export async function getBalanceProxied({ asset, address, tag = 'latest' }) {
43
+ if (!isEthereumLikeAsset(asset)) throw new Error(`unsupported asset ${asset.name}`)
44
+ const server = getServer(asset)
45
+ const balanceHex = await server.getBalanceProxied(address, tag)
46
+ return parseInt(balanceHex, 16)
47
+ }
48
+
41
49
  // Only ETH-like assets with token support
42
50
  export async function getTokenBalance({ asset, address }) {
43
51
  if (!isEthereumLikeToken(asset)) throw new Error(`unsupported ETH-like token ${asset.name}`)
@@ -85,7 +85,14 @@ export default function createWebSocket(getURL) {
85
85
  ws.onmessage = null
86
86
  ws.onopen = null
87
87
  ws.onclose = null
88
- ws.close()
88
+ try {
89
+ ws.close()
90
+ } catch (e) {
91
+ if (!/WebSocket was closed before the connection was established/.test(e.message)) {
92
+ throw e
93
+ }
94
+ }
95
+
89
96
  ws = null
90
97
  clearPing()
91
98
  events.emit('close')
@@ -61,9 +61,7 @@ export async function fetchGasLimit({
61
61
 
62
62
  const _isToken = isToken(asset)
63
63
  if (_isToken) {
64
- txInput = ethUtil.bufferToHex(
65
- asset.contract.transfer.build(toAddress, amount.toBase().toString({ unit: false }))
66
- )
64
+ txInput = ethUtil.bufferToHex(asset.contract.transfer.build(toAddress, amount.toBaseString()))
67
65
  amount = asset.baseAsset.currency.ZERO
68
66
  toAddress = asset.contract.address
69
67
  } else if (!isContract) {