@exodus/ethereum-api 2.6.15 → 2.7.0
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.
|
|
3
|
+
"version": "2.7.0",
|
|
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.
|
|
13
|
+
"@exodus/ethereum-lib": "^2.11.0",
|
|
14
14
|
"@exodus/ethereumjs-util": "^7.1.0-exodus.6",
|
|
15
15
|
"@exodus/simple-retry": "^0.0.6",
|
|
16
16
|
"fetchival": "0.3.3",
|
package/src/eth-like-util.js
CHANGED
|
@@ -48,6 +48,14 @@ export async function getTokenBalance({ asset, address }) {
|
|
|
48
48
|
return balances?.confirmed?.[contractAddress] || '0'
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
export async function getTokenBalanceFromNode({ asset, address }) {
|
|
52
|
+
if (!isEthereumLikeToken(asset)) throw new Error(`unsupported ETH-like token ${asset.name}`)
|
|
53
|
+
const server = getServer(asset)
|
|
54
|
+
const contractAddress = asset.contract.address.toLowerCase()
|
|
55
|
+
const balances = await server.balanceOf(address, contractAddress)
|
|
56
|
+
return balances?.confirmed?.[contractAddress] || '0'
|
|
57
|
+
}
|
|
58
|
+
|
|
51
59
|
// Returns function for supplied asset
|
|
52
60
|
export function sendRawTransaction(asset) {
|
|
53
61
|
return getServer(asset).sendRawTransaction
|
|
@@ -4,6 +4,8 @@ import fetchival from 'fetchival'
|
|
|
4
4
|
import ms from 'ms'
|
|
5
5
|
import createWebSocket from './ws'
|
|
6
6
|
import { retry } from '@exodus/simple-retry'
|
|
7
|
+
import { simpleErc20 } from '@exodus/solidity-contract'
|
|
8
|
+
import { bufferToHex } from '@exodus/ethereumjs-util'
|
|
7
9
|
|
|
8
10
|
const RETRY_DELAYS = ['10s']
|
|
9
11
|
|
|
@@ -61,6 +63,22 @@ export function create(defaultURL) {
|
|
|
61
63
|
return requestWithRetry('balance', { address, from: opts.startblock, to: opts.endblock })
|
|
62
64
|
},
|
|
63
65
|
|
|
66
|
+
async balanceOf(address, tokenAddress, tag = 'latest') {
|
|
67
|
+
const contract = simpleErc20(tokenAddress)
|
|
68
|
+
const callData = contract.balanceOf.build(address)
|
|
69
|
+
const data = {
|
|
70
|
+
data: bufferToHex(callData),
|
|
71
|
+
to: tokenAddress,
|
|
72
|
+
tag,
|
|
73
|
+
}
|
|
74
|
+
const result = await retry(this.ethCall, { delayTimesMs: RETRY_DELAYS })(data)
|
|
75
|
+
return {
|
|
76
|
+
confirmed: {
|
|
77
|
+
[tokenAddress]: parseInt(result, 16),
|
|
78
|
+
},
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
|
|
64
82
|
async getHistory(address, opts) {
|
|
65
83
|
opts = { startblock: 'earliest', endblock: 'pending', limit: 1000, ...opts }
|
|
66
84
|
return requestWithRetry('history', {
|
|
@@ -4,6 +4,7 @@ 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
5
|
const EXODUS_BSC_SERVER_URL = 'https://bsc.a.exodus.io/wallet/v1/'
|
|
6
6
|
const EXODUS_POLYGON_SERVER_URL = 'https://polygon.a.exodus.io/wallet/v1/'
|
|
7
|
+
const EXODUS_AVAX_C_SERVER_URL = 'https://avax-c.a.exodus.io/wallet/v1/'
|
|
7
8
|
|
|
8
9
|
// allow self-signed certs
|
|
9
10
|
// process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'
|
|
@@ -11,6 +12,7 @@ export const eth = create(EXODUS_ETH_SERVER_URL)
|
|
|
11
12
|
export const etc = create(EXODUS_ETC_SERVER_URL)
|
|
12
13
|
export const bsc = create(EXODUS_BSC_SERVER_URL)
|
|
13
14
|
export const polygon = create(EXODUS_POLYGON_SERVER_URL)
|
|
15
|
+
export const avaxc = create(EXODUS_AVAX_C_SERVER_URL)
|
|
14
16
|
|
|
15
17
|
// exported for in-library use only.
|
|
16
18
|
export const serverMap = {
|
|
@@ -18,6 +20,7 @@ export const serverMap = {
|
|
|
18
20
|
ethereumclassic: etc,
|
|
19
21
|
bsc,
|
|
20
22
|
matic: polygon,
|
|
23
|
+
avalanchec: avaxc,
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
export function getServer(asset) {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { EthereumLikeFeeMonitor } from '@exodus/ethereum-lib'
|
|
2
|
+
import { avaxc as avalancheServer } from '../exodus-eth-server'
|
|
3
|
+
|
|
4
|
+
export class AvalancheFeeMonitor extends EthereumLikeFeeMonitor {
|
|
5
|
+
constructor({ updateFee }) {
|
|
6
|
+
super({
|
|
7
|
+
updateFee,
|
|
8
|
+
assetName: 'avalanchec',
|
|
9
|
+
getGasPrice: avalancheServer.gasPrice,
|
|
10
|
+
})
|
|
11
|
+
}
|
|
12
|
+
}
|
package/src/fee-monitor/index.js
CHANGED