@exodus/ethereum-api 2.2.1 → 2.3.1

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": "2.2.1",
3
+ "version": "2.3.1",
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": "^2.4.1",
13
+ "@exodus/ethereum-lib": "^2.5.0",
14
14
  "@exodus/simple-retry": "^0.0.6",
15
15
  "fetchival": "0.3.3",
16
16
  "lodash": "^4.17.11",
@@ -20,5 +20,5 @@
20
20
  "url-join": "4.0.0",
21
21
  "ws": "6.1.0"
22
22
  },
23
- "gitHead": "124d585074d888dda100311f7fa15063fae3357d"
23
+ "gitHead": "a0c65f06da8e0b2f653db7d52bc0e5b66f894c76"
24
24
  }
@@ -32,18 +32,18 @@ export async function estimateGas({ asset, ...args }) {
32
32
  return getServer(asset).estimateGas(args)
33
33
  }
34
34
 
35
- // Only Ethereum and Ethereumclassic, not ERC20
35
+ // Only base assets, not tokens
36
36
  export async function getBalance({ asset, address }) {
37
- if (!['ethereum', 'ethereumclassic', 'quorum'].includes(asset.name))
37
+ if (!['ethereum', 'ethereumclassic', 'quorum', 'bsc'].includes(asset.name))
38
38
  throw new Error(`unsupported asset ${asset.name}`)
39
39
  const server = getServer(asset)
40
40
  const balances = await server.getBalance(address)
41
41
  return get(balances, ['confirmed', 'value'], '0')
42
42
  }
43
43
 
44
- // Only Ethereum ERC20, not Ethereumclassic
44
+ // Only ETH-like assets with token support
45
45
  export async function getTokenBalance({ asset, address }) {
46
- if (!['ethereum', 'quorum'].includes(asset.baseAsset.name))
46
+ if (!['ethereum', 'quorum', 'bsc'].includes(asset.baseAsset.name))
47
47
  throw new Error(`unsupported base asset ${asset.baseAsset.name}`)
48
48
  const server = getServer(asset)
49
49
  const balances = await server.getBalance(address)
@@ -44,6 +44,8 @@ export function create(defaultURL) {
44
44
  },
45
45
 
46
46
  setURL(newURL) {
47
+ if (newURL === API_URL) return // prevents useless WS reconnections
48
+
47
49
  API_URL = newURL || defaultURL
48
50
 
49
51
  if (ws.isCreated()) {
@@ -2,19 +2,22 @@ import { create } from './api'
2
2
 
3
3
  const EXODUS_ETH_SERVER_URL = 'https://geth.a.exodus.io/wallet/v1/'
4
4
  const EXODUS_ETC_SERVER_URL = 'https://getc.a.exodus.io/wallet/v1/'
5
- const EXODUS_QUORUM_SERVER_URL = 'https://geth-quorum.a.exodus.io/wallet/v1'
5
+ const EXODUS_QUORUM_SERVER_URL = 'https://geth-quorum.a.exodus.io/wallet/v1/'
6
+ const EXODUS_BSC_SERVER_URL = 'https://bsc.a.exodus.io/wallet/v1/'
6
7
 
7
8
  // allow self-signed certs
8
9
  // process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'
9
10
  export const eth = create(EXODUS_ETH_SERVER_URL)
10
11
  export const etc = create(EXODUS_ETC_SERVER_URL)
11
12
  export const quorum = create(EXODUS_QUORUM_SERVER_URL)
13
+ export const bsc = create(EXODUS_BSC_SERVER_URL)
12
14
 
13
15
  // exported for in-library use only.
14
16
  export const serverMap = {
15
17
  ethereum: eth,
16
18
  ethereumclassic: etc,
17
19
  quorum,
20
+ bsc,
18
21
  }
19
22
 
20
23
  export function getServer(asset) {
@@ -0,0 +1,12 @@
1
+ import { EthereumLikeFeeMonitor } from '@exodus/ethereum-lib'
2
+ import { bsc } from '../exodus-eth-server'
3
+
4
+ export class BscFeeMonitor extends EthereumLikeFeeMonitor {
5
+ constructor({ updateFee }) {
6
+ super({
7
+ updateFee,
8
+ assetName: 'bsc',
9
+ getGasPrice: bsc.gasPrice,
10
+ })
11
+ }
12
+ }
@@ -1,2 +1,3 @@
1
1
  export * from './ethereum'
2
2
  export * from './ethereumclassic'
3
+ export * from './bsc'