@exodus/ethereum-api 2.21.5 → 2.21.6
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 +7 -3
- package/src/ens/index.js +5 -6
- package/src/eth-like-util.js +2 -4
- package/src/exodus-eth-server/api.js +2 -2
- package/src/exodus-eth-server/index.js +12 -3
- package/src/fee-monitor/avalanchec.js +5 -3
- package/src/fee-monitor/bsc.js +5 -3
- package/src/fee-monitor/ethereum.js +5 -3
- package/src/fee-monitor/ethereumclassic.js +5 -3
- package/src/fee-monitor/fantom.js +5 -3
- package/src/fee-monitor/harmony.js +5 -3
- package/src/fee-monitor/polygon.js +5 -3
- package/src/staking/matic-staking.js +3 -1
package/package.json
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/ethereum-api",
|
|
3
|
-
"version": "2.21.
|
|
3
|
+
"version": "2.21.6",
|
|
4
4
|
"description": "Ethereum Api",
|
|
5
5
|
"main": "src/index.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"src",
|
|
8
|
+
"!src/**/__tests__"
|
|
9
|
+
],
|
|
6
10
|
"author": "Exodus Movement, Inc.",
|
|
7
11
|
"license": "UNLICENSED",
|
|
8
12
|
"homepage": "https://github.com/ExodusMovement/ethereum#readme",
|
|
@@ -13,7 +17,7 @@
|
|
|
13
17
|
"@ensdomains/eth-ens-namehash": "^2.0.15",
|
|
14
18
|
"@exodus/asset-lib": "^3.5.4",
|
|
15
19
|
"@exodus/crypto": "^1.0.0-rc.0",
|
|
16
|
-
"@exodus/ethereum-lib": "^2.19.
|
|
20
|
+
"@exodus/ethereum-lib": "^2.19.4",
|
|
17
21
|
"@exodus/ethereumjs-util": "^7.1.0-exodus.6",
|
|
18
22
|
"@exodus/simple-retry": "^0.0.6",
|
|
19
23
|
"@exodus/solidity-contract": "^1.0.1",
|
|
@@ -30,5 +34,5 @@
|
|
|
30
34
|
"@exodus/assets-base": "^8.0.136",
|
|
31
35
|
"@exodus/models": "^8.7.2"
|
|
32
36
|
},
|
|
33
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "f5f2bd5dcde6504d06ba68f01385d8215c82d224"
|
|
34
38
|
}
|
package/src/ens/index.js
CHANGED
|
@@ -2,7 +2,6 @@ import { hash } from '@ensdomains/eth-ens-namehash'
|
|
|
2
2
|
import SolidityContract from '@exodus/solidity-contract'
|
|
3
3
|
import { ABI } from '@exodus/ethereum-lib'
|
|
4
4
|
|
|
5
|
-
import { eth as server } from '../exodus-eth-server'
|
|
6
5
|
import ENS_REGISTRY_ADDRESSES from './addresses'
|
|
7
6
|
|
|
8
7
|
const registry = new SolidityContract(ABI.ensRegistry)
|
|
@@ -11,7 +10,7 @@ const resolver = new SolidityContract(ABI.ensResolver)
|
|
|
11
10
|
// ENS only available on mainnet atm
|
|
12
11
|
const ENS_REGISTRY_ADDRESS = ENS_REGISTRY_ADDRESSES['ethereum']
|
|
13
12
|
|
|
14
|
-
const getResolverAddress = async (name: string) =>
|
|
13
|
+
const getResolverAddress = async (name: string, server: Object) =>
|
|
15
14
|
server
|
|
16
15
|
.ethCall({
|
|
17
16
|
to: ENS_REGISTRY_ADDRESS,
|
|
@@ -19,8 +18,8 @@ const getResolverAddress = async (name: string) =>
|
|
|
19
18
|
})
|
|
20
19
|
.then((result) => '0x' + result.slice(26))
|
|
21
20
|
|
|
22
|
-
const resolveEnsName = async (name: string) => {
|
|
23
|
-
const resolverAddress = await getResolverAddress(name)
|
|
21
|
+
const resolveEnsName = async (name: string, server: Object) => {
|
|
22
|
+
const resolverAddress = await getResolverAddress(name, server)
|
|
24
23
|
const hex = await server.ethCall({
|
|
25
24
|
to: resolverAddress,
|
|
26
25
|
data: resolver.addr.methodId + hash(name).slice(2),
|
|
@@ -28,10 +27,10 @@ const resolveEnsName = async (name: string) => {
|
|
|
28
27
|
return '0x' + hex.slice(26)
|
|
29
28
|
}
|
|
30
29
|
|
|
31
|
-
const resolveEnsAddress = async (address: string) => {
|
|
30
|
+
const resolveEnsAddress = async (address: string, server: Object) => {
|
|
32
31
|
const name = `${address.slice(2)}.addr.reverse`
|
|
33
32
|
|
|
34
|
-
const resolverAddress = await getResolverAddress(name)
|
|
33
|
+
const resolverAddress = await getResolverAddress(name, server)
|
|
35
34
|
|
|
36
35
|
const data = await server.ethCall({
|
|
37
36
|
to: resolverAddress,
|
package/src/eth-like-util.js
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { normalizeTxId, isEthereumLikeAsset, isEthereumLikeToken, ABI } from '@exodus/ethereum-lib'
|
|
2
|
-
import {
|
|
2
|
+
import { getServerByName, getServer } from './exodus-eth-server'
|
|
3
3
|
import { memoizeLruCache } from '@exodus/asset-lib'
|
|
4
4
|
import assets from '@exodus/assets'
|
|
5
5
|
import SolidityContract from '@exodus/solidity-contract'
|
|
6
6
|
|
|
7
7
|
// Mobile only.
|
|
8
|
-
// Behavior is buggy, because the default server used is ethereum.
|
|
9
8
|
// We should refactor mobile to pass 'asset' instead of 'assetName' so that we can use 'isContractAddress'. But that would touch many assets.
|
|
10
9
|
export async function isContract(baseAssetName, address) {
|
|
11
|
-
|
|
12
|
-
return server.isContract(address)
|
|
10
|
+
return getServerByName(baseAssetName).isContract(address)
|
|
13
11
|
}
|
|
14
12
|
|
|
15
13
|
export async function isContractAddress({ asset, address }) {
|
|
@@ -245,8 +245,8 @@ export function create(defaultURL, ensAssetName) {
|
|
|
245
245
|
return ensAssetName === 'ethereum'
|
|
246
246
|
? {
|
|
247
247
|
...api,
|
|
248
|
-
resolveEnsName,
|
|
249
|
-
resolveEnsAddress,
|
|
248
|
+
resolveEnsName: (name) => resolveEnsName(name, api),
|
|
249
|
+
resolveEnsAddress: (address) => resolveEnsAddress(address, api),
|
|
250
250
|
}
|
|
251
251
|
: api
|
|
252
252
|
}
|
|
@@ -2,8 +2,7 @@ import { DEFAULT_SERVER_URLS, ETHEREUM_LIKE_ASSETS } from '@exodus/ethereum-lib'
|
|
|
2
2
|
|
|
3
3
|
import { create } from './api'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
export const serverMap = Object.fromEntries(
|
|
5
|
+
const serverMap = Object.fromEntries(
|
|
7
6
|
ETHEREUM_LIKE_ASSETS.map((assetName) => [
|
|
8
7
|
assetName,
|
|
9
8
|
create(DEFAULT_SERVER_URLS[assetName], assetName),
|
|
@@ -12,16 +11,26 @@ export const serverMap = Object.fromEntries(
|
|
|
12
11
|
|
|
13
12
|
// allow self-signed certs
|
|
14
13
|
// process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'
|
|
14
|
+
// @deprecated Use getServer or getServerbyName instead
|
|
15
15
|
export const eth = serverMap['ethereum']
|
|
16
|
+
// @deprecated Use getServer or getServerbyName instead
|
|
16
17
|
export const etc = serverMap['ethereumclassic']
|
|
18
|
+
// @deprecated Use getServer or getServerbyName instead
|
|
17
19
|
export const bsc = serverMap['bsc']
|
|
20
|
+
// @deprecated Use getServer or getServerbyName instead
|
|
18
21
|
export const polygon = serverMap['matic']
|
|
22
|
+
// @deprecated Use getServer or getServerbyName instead
|
|
19
23
|
export const avaxc = serverMap['avalanchec']
|
|
24
|
+
// @deprecated Use getServer or getServerbyName instead
|
|
20
25
|
export const ftm = serverMap['fantommainnet']
|
|
26
|
+
// @deprecated Use getServer or getServerbyName instead
|
|
21
27
|
export const harmony = serverMap['harmonymainnet']
|
|
22
28
|
|
|
23
29
|
export function getServer(asset) {
|
|
24
|
-
|
|
30
|
+
return getServerByName(asset.baseAsset.name)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function getServerByName(baseAssetName) {
|
|
25
34
|
const server = serverMap[baseAssetName]
|
|
26
35
|
if (!server) throw new Error(`unsupported base asset ${baseAssetName}`)
|
|
27
36
|
return server
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { EthereumLikeFeeMonitor } from '@exodus/ethereum-lib'
|
|
2
|
-
import {
|
|
2
|
+
import { getServerByName } from '../exodus-eth-server'
|
|
3
|
+
|
|
4
|
+
const assetName = 'avalanchec'
|
|
3
5
|
|
|
4
6
|
export class AvalancheFeeMonitor extends EthereumLikeFeeMonitor {
|
|
5
7
|
constructor({ updateFee }) {
|
|
6
8
|
super({
|
|
7
9
|
updateFee,
|
|
8
|
-
assetName
|
|
9
|
-
getGasPrice:
|
|
10
|
+
assetName,
|
|
11
|
+
getGasPrice: getServerByName(assetName).gasPrice,
|
|
10
12
|
})
|
|
11
13
|
}
|
|
12
14
|
}
|
package/src/fee-monitor/bsc.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { EthereumLikeFeeMonitor } from '@exodus/ethereum-lib'
|
|
2
|
-
import {
|
|
2
|
+
import { getServerByName } from '../exodus-eth-server'
|
|
3
|
+
|
|
4
|
+
const assetName = 'bsc'
|
|
3
5
|
|
|
4
6
|
export class BscFeeMonitor extends EthereumLikeFeeMonitor {
|
|
5
7
|
constructor({ updateFee }) {
|
|
6
8
|
super({
|
|
7
9
|
updateFee,
|
|
8
|
-
assetName
|
|
9
|
-
getGasPrice:
|
|
10
|
+
assetName,
|
|
11
|
+
getGasPrice: getServerByName(assetName).gasPrice,
|
|
10
12
|
})
|
|
11
13
|
}
|
|
12
14
|
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { EthereumLikeFeeMonitor } from '@exodus/ethereum-lib'
|
|
2
|
-
import {
|
|
2
|
+
import { getServerByName } from '../exodus-eth-server'
|
|
3
|
+
|
|
4
|
+
const assetName = 'ethereum'
|
|
3
5
|
|
|
4
6
|
export class EthereumFeeMonitor extends EthereumLikeFeeMonitor {
|
|
5
7
|
constructor({ updateFee, interval }) {
|
|
6
8
|
super({
|
|
7
9
|
updateFee,
|
|
8
|
-
assetName
|
|
9
|
-
getGasPrice:
|
|
10
|
+
assetName,
|
|
11
|
+
getGasPrice: getServerByName(assetName).gasPrice,
|
|
10
12
|
interval,
|
|
11
13
|
})
|
|
12
14
|
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { EthereumLikeFeeMonitor } from '@exodus/ethereum-lib'
|
|
2
|
-
import {
|
|
2
|
+
import { getServerByName } from '../exodus-eth-server'
|
|
3
|
+
|
|
4
|
+
const assetName = 'ethereumclassic'
|
|
3
5
|
|
|
4
6
|
export class EthereumClassicFeeMonitor extends EthereumLikeFeeMonitor {
|
|
5
7
|
constructor({ updateFee }) {
|
|
6
8
|
super({
|
|
7
9
|
updateFee,
|
|
8
|
-
assetName
|
|
9
|
-
getGasPrice:
|
|
10
|
+
assetName,
|
|
11
|
+
getGasPrice: getServerByName(assetName).gasPrice,
|
|
10
12
|
})
|
|
11
13
|
}
|
|
12
14
|
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { EthereumLikeFeeMonitor } from '@exodus/ethereum-lib'
|
|
2
|
-
import {
|
|
2
|
+
import { getServerByName } from '../exodus-eth-server'
|
|
3
|
+
|
|
4
|
+
const assetName = 'fantommainnet'
|
|
3
5
|
|
|
4
6
|
export class FantomFeeMonitor extends EthereumLikeFeeMonitor {
|
|
5
7
|
constructor({ updateFee }) {
|
|
6
8
|
super({
|
|
7
9
|
updateFee,
|
|
8
|
-
assetName
|
|
9
|
-
getGasPrice:
|
|
10
|
+
assetName,
|
|
11
|
+
getGasPrice: getServerByName(assetName).gasPrice,
|
|
10
12
|
})
|
|
11
13
|
}
|
|
12
14
|
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { EthereumLikeFeeMonitor } from '@exodus/ethereum-lib'
|
|
2
|
-
import {
|
|
2
|
+
import { getServerByName } from '../exodus-eth-server'
|
|
3
|
+
|
|
4
|
+
const assetName = 'harmonymainnet'
|
|
3
5
|
|
|
4
6
|
export class HarmonyFeeMonitor extends EthereumLikeFeeMonitor {
|
|
5
7
|
constructor({ updateFee }) {
|
|
6
8
|
super({
|
|
7
9
|
updateFee,
|
|
8
|
-
assetName
|
|
9
|
-
getGasPrice:
|
|
10
|
+
assetName,
|
|
11
|
+
getGasPrice: getServerByName(assetName).gasPrice,
|
|
10
12
|
})
|
|
11
13
|
}
|
|
12
14
|
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { EthereumLikeFeeMonitor } from '@exodus/ethereum-lib'
|
|
2
|
-
import {
|
|
2
|
+
import { getServerByName } from '../exodus-eth-server'
|
|
3
|
+
|
|
4
|
+
const assetName = 'matic'
|
|
3
5
|
|
|
4
6
|
export class PolygonFeeMonitor extends EthereumLikeFeeMonitor {
|
|
5
7
|
constructor({ updateFee }) {
|
|
6
8
|
super({
|
|
7
9
|
updateFee,
|
|
8
|
-
assetName
|
|
9
|
-
getGasPrice:
|
|
10
|
+
assetName,
|
|
11
|
+
getGasPrice: getServerByName(assetName).gasPrice,
|
|
10
12
|
})
|
|
11
13
|
}
|
|
12
14
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createContract } from '@exodus/ethereum-lib'
|
|
2
|
-
import {
|
|
2
|
+
import { getServerByName } from '../exodus-eth-server'
|
|
3
3
|
import { retry } from '@exodus/simple-retry'
|
|
4
4
|
import { bufferToHex } from '@exodus/ethereumjs-util'
|
|
5
5
|
|
|
@@ -27,6 +27,8 @@ export class MaticStaking {
|
|
|
27
27
|
tag: 'latest',
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
// TODO: why 'ethereum' if this is matic staking?
|
|
31
|
+
const eth = getServerByName('ethereum')
|
|
30
32
|
return retry(eth.ethCall, { delayTimesMs: RETRY_DELAYS })(data)
|
|
31
33
|
}
|
|
32
34
|
|