@exodus/ethereum-lib 4.3.0 → 4.5.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 +4 -2
- package/src/balances/ethereum-balance.js +1 -0
- package/src/balances/index.js +1 -0
- package/src/balances/polygon-balance.js +1 -0
- package/src/constants.js +6 -0
- package/src/fee-data/basemainnet.js +1 -1
- package/src/fee-data/ethereumsepolia.js +20 -0
- package/src/fee-data/index.js +1 -0
- package/src/sign-message.js +47 -0
- package/src/utils/index.js +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/ethereum-lib",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0",
|
|
4
4
|
"description": "Ethereum Library",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"files": [
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"@exodus/ethereumjs-common": "^2.4.0-exodus.6",
|
|
37
37
|
"@exodus/ethereumjs-tx": "^3.3.0-exodus.7",
|
|
38
38
|
"@exodus/ethereumjs-util": "^7.1.0-exodus.7",
|
|
39
|
+
"@exodus/ethereumsepolia-meta": "^1.0.1",
|
|
39
40
|
"@exodus/fantommainnet-meta": "^1.0.5",
|
|
40
41
|
"@exodus/flare-meta": "^1.0.4",
|
|
41
42
|
"@exodus/harmonymainnet-meta": "^1.0.0",
|
|
@@ -45,6 +46,7 @@
|
|
|
45
46
|
"@exodus/optimism-meta": "^1.2.10",
|
|
46
47
|
"@exodus/rootstock-meta": "^1.0.5",
|
|
47
48
|
"@exodus/solidity-contract": "^1.1.3",
|
|
49
|
+
"@metamask/eth-sig-util": "^4.0.1",
|
|
48
50
|
"base-x": "^3.0.2",
|
|
49
51
|
"ethjs-util": "0.1.6",
|
|
50
52
|
"lodash": "^4.17.15",
|
|
@@ -58,5 +60,5 @@
|
|
|
58
60
|
"@exodus/bnbmainnet-meta": "^1.0.0",
|
|
59
61
|
"@exodus/elliptic": "^6.5.4-precomputed"
|
|
60
62
|
},
|
|
61
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "539b25e53db7092fab6a1645f6d0e0f3118fe75c"
|
|
62
64
|
}
|
package/src/balances/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import assets from '@exodus/ethereum-meta'
|
|
|
3
3
|
|
|
4
4
|
const polygon = assets.find(({ name: tokenName }) => tokenName === 'polygon')
|
|
5
5
|
|
|
6
|
+
// @deprecated to be removed. Use balances!
|
|
6
7
|
export const getPolygonBalances = ({ liquidBalance, accountState }) => {
|
|
7
8
|
const delegatedBalance = get(
|
|
8
9
|
accountState,
|
package/src/constants.js
CHANGED
|
@@ -25,6 +25,12 @@ const CHAIN_DATA = {
|
|
|
25
25
|
confirmationsNumber: 30,
|
|
26
26
|
tokenType: 'ETHEREUM_HOLESKY_ERC20',
|
|
27
27
|
},
|
|
28
|
+
ethereumsepolia: {
|
|
29
|
+
chainId: 11_155_111,
|
|
30
|
+
serverUrl: 'https://geth-sepolia-testnet-d.a.exodus.io/wallet/v1/',
|
|
31
|
+
confirmationsNumber: 30,
|
|
32
|
+
tokenType: 'ETHEREUM_SEPOLIA_ERC20',
|
|
33
|
+
},
|
|
28
34
|
bsc: {
|
|
29
35
|
chainId: 56,
|
|
30
36
|
serverUrl: 'https://bsc-clarity.a.exodus.io/',
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { FeeData } from '@exodus/asset-lib'
|
|
2
|
+
import { asset } from '@exodus/ethereumsepolia-meta'
|
|
3
|
+
|
|
4
|
+
export default new FeeData({
|
|
5
|
+
config: {
|
|
6
|
+
gasPrice: '75 Gwei',
|
|
7
|
+
baseFeePerGas: '50 Gwei',
|
|
8
|
+
max: '250 Gwei',
|
|
9
|
+
min: '1 Gwei',
|
|
10
|
+
fuelThreshold: '0.025 SETH',
|
|
11
|
+
swapFee: '0.05 SETH',
|
|
12
|
+
gasPriceEconomicalRate: 0.7,
|
|
13
|
+
gasPriceMinimumRate: 0.5,
|
|
14
|
+
enableFeeDelegation: false,
|
|
15
|
+
tipGasPrice: '2 Gwei',
|
|
16
|
+
eip1559Enabled: true,
|
|
17
|
+
},
|
|
18
|
+
mainKey: 'gasPrice',
|
|
19
|
+
currency: asset.currency,
|
|
20
|
+
})
|
package/src/fee-data/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export { default as ethereumarbone } from './ethereumarbone'
|
|
|
4
4
|
export { default as ethereumclassic } from './ethereumclassic'
|
|
5
5
|
export { default as ethereumgoerli } from './ethereumgoerli'
|
|
6
6
|
export { default as ethereumholesky } from './ethereumholesky'
|
|
7
|
+
export { default as ethereumsepolia } from './ethereumsepolia'
|
|
7
8
|
export { default as bsc } from './bsc'
|
|
8
9
|
export { default as matic } from './polygon'
|
|
9
10
|
export { default as avalanchec } from './avalanchec'
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import assert from 'minimalistic-assert'
|
|
2
|
+
import { SignTypedDataVersion, personalSign, signTypedData } from '@metamask/eth-sig-util'
|
|
3
|
+
|
|
4
|
+
function hex0xStringToBuffer(hex) {
|
|
5
|
+
// Remove the 0x
|
|
6
|
+
const hexWithout0x = hex.startsWith('0x') ? hex.slice(2) : hex
|
|
7
|
+
// Pad the value until even
|
|
8
|
+
const hexWithLeadingZeros = hexWithout0x.length % 2 === 0 ? hexWithout0x : '0' + hexWithout0x
|
|
9
|
+
// Finally return the buffer
|
|
10
|
+
return Buffer.from(hexWithLeadingZeros, 'hex')
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Converts a buffer to the 0xhex encoded value
|
|
15
|
+
* @param {Buffer} buf the buffer to convert to 0xHEXSTRING
|
|
16
|
+
* @returns the hex-encoded value prepended with 0x
|
|
17
|
+
*/
|
|
18
|
+
function bufferToHex0xString(buf) {
|
|
19
|
+
if (!Buffer.isBuffer(buf)) {
|
|
20
|
+
throw new TypeError('expected a buffer')
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const hex = buf.toString('hex')
|
|
24
|
+
|
|
25
|
+
if (typeof hex !== 'string') {
|
|
26
|
+
throw new TypeError('expected hex string')
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return '0x' + hex
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const signMessage = async ({ privateKey, message }) => {
|
|
33
|
+
const { rawMessage, EIP712Message } = message
|
|
34
|
+
|
|
35
|
+
// Exclusive OR (XOR)
|
|
36
|
+
assert(!!rawMessage !== !!EIP712Message, 'Need either rawMessage or EIP712Message')
|
|
37
|
+
|
|
38
|
+
if (rawMessage) {
|
|
39
|
+
return hex0xStringToBuffer(personalSign({ privateKey, data: bufferToHex0xString(rawMessage) }))
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (EIP712Message) {
|
|
43
|
+
const version = Array.isArray(EIP712Message) ? SignTypedDataVersion.V1 : SignTypedDataVersion.V4
|
|
44
|
+
|
|
45
|
+
return hex0xStringToBuffer(signTypedData({ privateKey, data: EIP712Message, version }))
|
|
46
|
+
}
|
|
47
|
+
}
|
package/src/utils/index.js
CHANGED
|
@@ -16,6 +16,7 @@ const base16 = baseX('0123456789abcdef')
|
|
|
16
16
|
export const isEthereumToken = (asset) => asset.assetType === 'ETHEREUM_ERC20'
|
|
17
17
|
export const isEthereumGoerliToken = (asset) => asset.assetType === 'ETHEREUM_GOERLI_ERC20'
|
|
18
18
|
export const isEthereumHoleskyToken = (asset) => asset.assetType === 'ETHEREUM_HOLESKY_ERC20'
|
|
19
|
+
export const isEthereumSepoliaToken = (asset) => asset.assetType === 'ETHEREUM_SEPOLIA_ERC20'
|
|
19
20
|
export const isBscToken = (asset) => asset.assetType === 'BSC_BEP20'
|
|
20
21
|
export const isPolygonToken = (asset) => asset.assetType === 'MATIC_ERC20'
|
|
21
22
|
export const isAvalancheToken = (asset) => asset.assetType === 'AVAX_ERC20'
|