@exodus/ethereum-lib 5.24.2 → 5.25.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/CHANGELOG.md +26 -0
- package/package.json +3 -3
- package/src/abi/index.js +2 -0
- package/src/abi/multicall3.js +236 -0
- package/src/unsigned-tx/create-unsigned-tx.js +1 -5
- package/src/unsigned-tx/sign-hardware.js +18 -2
- package/src/utils/index.js +17 -13
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,32 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [5.25.0](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-lib@5.24.3...@exodus/ethereum-lib@5.25.0) (2026-07-10)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
* feat: introduce multicall3 capability (#8243)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
* fix: lower ETH min staking amount (#8319)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## [5.24.3](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-lib@5.24.2...@exodus/ethereum-lib@5.24.3) (2026-06-11)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
* fix: Ledger clear-signing for EVM token approvals (#8207)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
6
32
|
## [5.24.2](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-lib@5.24.1...@exodus/ethereum-lib@5.24.2) (2026-05-13)
|
|
7
33
|
|
|
8
34
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/ethereum-lib",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.25.0",
|
|
4
4
|
"description": "Ethereum utils, such as for cryptography, address encoding/decoding, transaction building, etc.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -23,13 +23,13 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@exodus/basic-utils": "^3.0.1",
|
|
26
|
+
"@exodus/bytes": "^1.0.0-rc.5",
|
|
26
27
|
"@exodus/crypto": "^1.0.0-rc.18",
|
|
27
28
|
"@exodus/currency": "^6.0.1",
|
|
28
29
|
"@exodus/ethereumjs": "^1.6.0",
|
|
29
30
|
"@exodus/key-utils": "^3.7.0",
|
|
30
31
|
"@exodus/models": "^13.0.0",
|
|
31
32
|
"@exodus/solidity-contract": "^1.1.3",
|
|
32
|
-
"base-x": "^3.0.2",
|
|
33
33
|
"lodash": "^4.17.15",
|
|
34
34
|
"minimalistic-assert": "^1.0.1",
|
|
35
35
|
"ms": "^2.1.1",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"type": "git",
|
|
52
52
|
"url": "git+https://github.com/ExodusMovement/assets.git"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "c9b1bbede2e2e7b0f2359ec736e3e92f402b2eba"
|
|
55
55
|
}
|
package/src/abi/index.js
CHANGED
|
@@ -15,6 +15,7 @@ import loomv2Swap from './loomv2-swap.js'
|
|
|
15
15
|
import matic from './matic.js'
|
|
16
16
|
import maticStakingManager from './matic-staking-manager.js'
|
|
17
17
|
import maticValidatorShare from './matic-validator-share.js'
|
|
18
|
+
import multicall3 from './multicall3.js'
|
|
18
19
|
import optimismGasOracle from './optimism-gas-oracle.js'
|
|
19
20
|
import repv2 from './repv2.js'
|
|
20
21
|
import scdMcdMigration from './scd-mcd-migration.js'
|
|
@@ -36,6 +37,7 @@ const index = {
|
|
|
36
37
|
maticValidatorShare,
|
|
37
38
|
maticStakingManager,
|
|
38
39
|
matic,
|
|
40
|
+
multicall3,
|
|
39
41
|
fantomSfc,
|
|
40
42
|
ensRegistry,
|
|
41
43
|
ensResolver,
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
export default [
|
|
2
|
+
{
|
|
3
|
+
inputs: [
|
|
4
|
+
{
|
|
5
|
+
components: [
|
|
6
|
+
{ internalType: 'address', name: 'target', type: 'address' },
|
|
7
|
+
{ internalType: 'bytes', name: 'callData', type: 'bytes' },
|
|
8
|
+
],
|
|
9
|
+
internalType: 'struct Multicall3.Call[]',
|
|
10
|
+
name: 'calls',
|
|
11
|
+
type: 'tuple[]',
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
name: 'aggregate',
|
|
15
|
+
outputs: [
|
|
16
|
+
{ internalType: 'uint256', name: 'blockNumber', type: 'uint256' },
|
|
17
|
+
{ internalType: 'bytes[]', name: 'returnData', type: 'bytes[]' },
|
|
18
|
+
],
|
|
19
|
+
stateMutability: 'payable',
|
|
20
|
+
type: 'function',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
inputs: [
|
|
24
|
+
{
|
|
25
|
+
components: [
|
|
26
|
+
{ internalType: 'address', name: 'target', type: 'address' },
|
|
27
|
+
{ internalType: 'bool', name: 'allowFailure', type: 'bool' },
|
|
28
|
+
{ internalType: 'bytes', name: 'callData', type: 'bytes' },
|
|
29
|
+
],
|
|
30
|
+
internalType: 'struct Multicall3.Call3[]',
|
|
31
|
+
name: 'calls',
|
|
32
|
+
type: 'tuple[]',
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
name: 'aggregate3',
|
|
36
|
+
outputs: [
|
|
37
|
+
{
|
|
38
|
+
components: [
|
|
39
|
+
{ internalType: 'bool', name: 'success', type: 'bool' },
|
|
40
|
+
{ internalType: 'bytes', name: 'returnData', type: 'bytes' },
|
|
41
|
+
],
|
|
42
|
+
internalType: 'struct Multicall3.Result[]',
|
|
43
|
+
name: 'returnData',
|
|
44
|
+
type: 'tuple[]',
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
stateMutability: 'payable',
|
|
48
|
+
type: 'function',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
inputs: [
|
|
52
|
+
{
|
|
53
|
+
components: [
|
|
54
|
+
{ internalType: 'address', name: 'target', type: 'address' },
|
|
55
|
+
{ internalType: 'bool', name: 'allowFailure', type: 'bool' },
|
|
56
|
+
{ internalType: 'uint256', name: 'value', type: 'uint256' },
|
|
57
|
+
{ internalType: 'bytes', name: 'callData', type: 'bytes' },
|
|
58
|
+
],
|
|
59
|
+
internalType: 'struct Multicall3.Call3Value[]',
|
|
60
|
+
name: 'calls',
|
|
61
|
+
type: 'tuple[]',
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
name: 'aggregate3Value',
|
|
65
|
+
outputs: [
|
|
66
|
+
{
|
|
67
|
+
components: [
|
|
68
|
+
{ internalType: 'bool', name: 'success', type: 'bool' },
|
|
69
|
+
{ internalType: 'bytes', name: 'returnData', type: 'bytes' },
|
|
70
|
+
],
|
|
71
|
+
internalType: 'struct Multicall3.Result[]',
|
|
72
|
+
name: 'returnData',
|
|
73
|
+
type: 'tuple[]',
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
stateMutability: 'payable',
|
|
77
|
+
type: 'function',
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
inputs: [
|
|
81
|
+
{
|
|
82
|
+
components: [
|
|
83
|
+
{ internalType: 'address', name: 'target', type: 'address' },
|
|
84
|
+
{ internalType: 'bytes', name: 'callData', type: 'bytes' },
|
|
85
|
+
],
|
|
86
|
+
internalType: 'struct Multicall3.Call[]',
|
|
87
|
+
name: 'calls',
|
|
88
|
+
type: 'tuple[]',
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
name: 'blockAndAggregate',
|
|
92
|
+
outputs: [
|
|
93
|
+
{ internalType: 'uint256', name: 'blockNumber', type: 'uint256' },
|
|
94
|
+
{ internalType: 'bytes32', name: 'blockHash', type: 'bytes32' },
|
|
95
|
+
{
|
|
96
|
+
components: [
|
|
97
|
+
{ internalType: 'bool', name: 'success', type: 'bool' },
|
|
98
|
+
{ internalType: 'bytes', name: 'returnData', type: 'bytes' },
|
|
99
|
+
],
|
|
100
|
+
internalType: 'struct Multicall3.Result[]',
|
|
101
|
+
name: 'returnData',
|
|
102
|
+
type: 'tuple[]',
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
stateMutability: 'payable',
|
|
106
|
+
type: 'function',
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
inputs: [],
|
|
110
|
+
name: 'getBasefee',
|
|
111
|
+
outputs: [{ internalType: 'uint256', name: 'basefee', type: 'uint256' }],
|
|
112
|
+
stateMutability: 'view',
|
|
113
|
+
type: 'function',
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
inputs: [{ internalType: 'uint256', name: 'blockNumber', type: 'uint256' }],
|
|
117
|
+
name: 'getBlockHash',
|
|
118
|
+
outputs: [{ internalType: 'bytes32', name: 'blockHash', type: 'bytes32' }],
|
|
119
|
+
stateMutability: 'view',
|
|
120
|
+
type: 'function',
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
inputs: [],
|
|
124
|
+
name: 'getBlockNumber',
|
|
125
|
+
outputs: [{ internalType: 'uint256', name: 'blockNumber', type: 'uint256' }],
|
|
126
|
+
stateMutability: 'view',
|
|
127
|
+
type: 'function',
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
inputs: [],
|
|
131
|
+
name: 'getChainId',
|
|
132
|
+
outputs: [{ internalType: 'uint256', name: 'chainid', type: 'uint256' }],
|
|
133
|
+
stateMutability: 'view',
|
|
134
|
+
type: 'function',
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
inputs: [],
|
|
138
|
+
name: 'getCurrentBlockCoinbase',
|
|
139
|
+
outputs: [{ internalType: 'address', name: 'coinbase', type: 'address' }],
|
|
140
|
+
stateMutability: 'view',
|
|
141
|
+
type: 'function',
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
inputs: [],
|
|
145
|
+
name: 'getCurrentBlockDifficulty',
|
|
146
|
+
outputs: [{ internalType: 'uint256', name: 'difficulty', type: 'uint256' }],
|
|
147
|
+
stateMutability: 'view',
|
|
148
|
+
type: 'function',
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
inputs: [],
|
|
152
|
+
name: 'getCurrentBlockGasLimit',
|
|
153
|
+
outputs: [{ internalType: 'uint256', name: 'gaslimit', type: 'uint256' }],
|
|
154
|
+
stateMutability: 'view',
|
|
155
|
+
type: 'function',
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
inputs: [],
|
|
159
|
+
name: 'getCurrentBlockTimestamp',
|
|
160
|
+
outputs: [{ internalType: 'uint256', name: 'timestamp', type: 'uint256' }],
|
|
161
|
+
stateMutability: 'view',
|
|
162
|
+
type: 'function',
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
inputs: [{ internalType: 'address', name: 'addr', type: 'address' }],
|
|
166
|
+
name: 'getEthBalance',
|
|
167
|
+
outputs: [{ internalType: 'uint256', name: 'balance', type: 'uint256' }],
|
|
168
|
+
stateMutability: 'view',
|
|
169
|
+
type: 'function',
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
inputs: [],
|
|
173
|
+
name: 'getLastBlockHash',
|
|
174
|
+
outputs: [{ internalType: 'bytes32', name: 'blockHash', type: 'bytes32' }],
|
|
175
|
+
stateMutability: 'view',
|
|
176
|
+
type: 'function',
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
inputs: [
|
|
180
|
+
{ internalType: 'bool', name: 'requireSuccess', type: 'bool' },
|
|
181
|
+
{
|
|
182
|
+
components: [
|
|
183
|
+
{ internalType: 'address', name: 'target', type: 'address' },
|
|
184
|
+
{ internalType: 'bytes', name: 'callData', type: 'bytes' },
|
|
185
|
+
],
|
|
186
|
+
internalType: 'struct Multicall3.Call[]',
|
|
187
|
+
name: 'calls',
|
|
188
|
+
type: 'tuple[]',
|
|
189
|
+
},
|
|
190
|
+
],
|
|
191
|
+
name: 'tryAggregate',
|
|
192
|
+
outputs: [
|
|
193
|
+
{
|
|
194
|
+
components: [
|
|
195
|
+
{ internalType: 'bool', name: 'success', type: 'bool' },
|
|
196
|
+
{ internalType: 'bytes', name: 'returnData', type: 'bytes' },
|
|
197
|
+
],
|
|
198
|
+
internalType: 'struct Multicall3.Result[]',
|
|
199
|
+
name: 'returnData',
|
|
200
|
+
type: 'tuple[]',
|
|
201
|
+
},
|
|
202
|
+
],
|
|
203
|
+
stateMutability: 'payable',
|
|
204
|
+
type: 'function',
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
inputs: [
|
|
208
|
+
{ internalType: 'bool', name: 'requireSuccess', type: 'bool' },
|
|
209
|
+
{
|
|
210
|
+
components: [
|
|
211
|
+
{ internalType: 'address', name: 'target', type: 'address' },
|
|
212
|
+
{ internalType: 'bytes', name: 'callData', type: 'bytes' },
|
|
213
|
+
],
|
|
214
|
+
internalType: 'struct Multicall3.Call[]',
|
|
215
|
+
name: 'calls',
|
|
216
|
+
type: 'tuple[]',
|
|
217
|
+
},
|
|
218
|
+
],
|
|
219
|
+
name: 'tryBlockAndAggregate',
|
|
220
|
+
outputs: [
|
|
221
|
+
{ internalType: 'uint256', name: 'blockNumber', type: 'uint256' },
|
|
222
|
+
{ internalType: 'bytes32', name: 'blockHash', type: 'bytes32' },
|
|
223
|
+
{
|
|
224
|
+
components: [
|
|
225
|
+
{ internalType: 'bool', name: 'success', type: 'bool' },
|
|
226
|
+
{ internalType: 'bytes', name: 'returnData', type: 'bytes' },
|
|
227
|
+
],
|
|
228
|
+
internalType: 'struct Multicall3.Result[]',
|
|
229
|
+
name: 'returnData',
|
|
230
|
+
type: 'tuple[]',
|
|
231
|
+
},
|
|
232
|
+
],
|
|
233
|
+
stateMutability: 'payable',
|
|
234
|
+
type: 'function',
|
|
235
|
+
},
|
|
236
|
+
]
|
|
@@ -48,11 +48,7 @@ export default function createUnsignedTxFactory({ chainId }) {
|
|
|
48
48
|
|
|
49
49
|
const _isToken = isToken(asset)
|
|
50
50
|
const to = _isToken ? asset.contract.address : address
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
// TODO: check: present on desktop missing on mobile. This insures we never have a buffer specifying 0.
|
|
54
|
-
// In ETH, a buffer of zero length and a buffer specifying 0 imply different things
|
|
55
|
-
if (value.equals(Buffer.from([0]))) value = Buffer.alloc(0)
|
|
51
|
+
const value = currency2buffer(txValue)
|
|
56
52
|
|
|
57
53
|
assert(fromAddress, 'createTx: fromAddress is requied')
|
|
58
54
|
|
|
@@ -2,16 +2,31 @@ import assert from 'minimalistic-assert'
|
|
|
2
2
|
|
|
3
3
|
import createEthereumJsTx from './create-ethereumjs-tx.js'
|
|
4
4
|
|
|
5
|
+
// Resolves the Ledger `isNft` clear-signing hint for the contract this tx calls.
|
|
6
|
+
// Delegates the on-chain ERC-165 classification to the injected `getIsNft`; stays
|
|
7
|
+
// undefined when there's no contract method call to classify. The hint only drives
|
|
8
|
+
// the device's display resolution and never affects the signed bytes.
|
|
9
|
+
const resolveIsNft = async ({ tx, getIsNft }) => {
|
|
10
|
+
// Only txs with a target and calldata can be token/NFT operations; a plain
|
|
11
|
+
// value transfer has nothing for the device to clear-sign as one.
|
|
12
|
+
if (!tx.to || !tx.data?.length || typeof getIsNft !== 'function') return
|
|
13
|
+
|
|
14
|
+
return getIsNft({ address: tx.to.toString().toLowerCase() })
|
|
15
|
+
}
|
|
16
|
+
|
|
5
17
|
export const signHardwareFactory =
|
|
6
|
-
({ baseAssetName }) =>
|
|
18
|
+
({ baseAssetName, getIsNft }) =>
|
|
7
19
|
async ({ unsignedTx, hardwareDevice, accountIndex }) => {
|
|
8
20
|
const tx = createEthereumJsTx(unsignedTx)
|
|
9
21
|
|
|
22
|
+
const isNft = await resolveIsNft({ tx, getIsNft })
|
|
23
|
+
|
|
10
24
|
const signedTx = await signWithHardwareWallet({
|
|
11
25
|
baseAssetName,
|
|
12
26
|
tx,
|
|
13
27
|
hardwareDevice,
|
|
14
28
|
accountIndex,
|
|
29
|
+
isNft,
|
|
15
30
|
})
|
|
16
31
|
|
|
17
32
|
// serialize and get txId
|
|
@@ -20,12 +35,13 @@ export const signHardwareFactory =
|
|
|
20
35
|
return { rawTx, txId }
|
|
21
36
|
}
|
|
22
37
|
|
|
23
|
-
async function signWithHardwareWallet({ baseAssetName, tx, hardwareDevice, accountIndex }) {
|
|
38
|
+
async function signWithHardwareWallet({ baseAssetName, tx, hardwareDevice, accountIndex, isNft }) {
|
|
24
39
|
const rlpEncodedTx = tx.serialize()
|
|
25
40
|
const signatures = await hardwareDevice.signTransaction({
|
|
26
41
|
assetName: baseAssetName,
|
|
27
42
|
signableTransaction: rlpEncodedTx,
|
|
28
43
|
derivationPaths: [`m/44'/60'/${accountIndex}'/0/0`],
|
|
44
|
+
isNft,
|
|
29
45
|
})
|
|
30
46
|
|
|
31
47
|
const { signature } = signatures[0]
|
package/src/utils/index.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
+
import { fromHex, toHex } from '@exodus/bytes/hex.js'
|
|
1
2
|
import { FeeMarketEIP1559Transaction, Transaction } from '@exodus/ethereumjs/tx'
|
|
2
3
|
import { padToEven, toBuffer } from '@exodus/ethereumjs/util'
|
|
3
|
-
import baseX from 'base-x'
|
|
4
4
|
|
|
5
5
|
export { default as calculateExtraEth } from './calculate-extra-eth.js'
|
|
6
6
|
|
|
7
|
-
const base10 = baseX('0123456789')
|
|
8
|
-
const base16 = baseX('0123456789abcdef')
|
|
9
|
-
|
|
10
7
|
/* @deprecated */
|
|
11
8
|
export const isEthereumToken = (asset) => asset.assetType === 'ETHEREUM_ERC20'
|
|
12
9
|
/* @deprecated */
|
|
@@ -54,21 +51,28 @@ export const isEthereumLikeByName = (assetName) => {
|
|
|
54
51
|
}
|
|
55
52
|
|
|
56
53
|
export function buffer2currency({ asset, value }) {
|
|
57
|
-
return asset.currency.
|
|
54
|
+
if (value.length === 0) return asset.currency.ZERO
|
|
55
|
+
|
|
56
|
+
return asset.currency.baseUnit(`0x${toHex(value)}`)
|
|
58
57
|
}
|
|
59
58
|
|
|
60
59
|
export function currency2buffer(value) {
|
|
61
|
-
|
|
60
|
+
// In RLP, a big-endian interpretation of 0 consists of zeros -
|
|
61
|
+
// so after trimming, we should yield empty byte array.
|
|
62
|
+
//
|
|
63
|
+
// https://ethereum.stackexchange.com/a/61021
|
|
64
|
+
if (value.isZero) return Buffer.alloc(0)
|
|
62
65
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
throw new RangeError(`${value.toBaseString()} can not be converted to Buffer`)
|
|
66
|
+
const b10Value = value.toBaseString()
|
|
67
|
+
if (b10Value[0] === '-') throw new RangeError('Negative numbers can not be converted to Buffer')
|
|
68
|
+
if (b10Value.length > 1 && b10Value[0] === '0') {
|
|
69
|
+
// Number is not supposed to be telling us the width, we always convert to smallest buffer that fits it
|
|
70
|
+
throw new RangeError('Padded numbers can not be converted to Buffer')
|
|
69
71
|
}
|
|
70
72
|
|
|
71
|
-
|
|
73
|
+
// Desktop: const hexValue = new BN(value.toBaseString()).toString(16)
|
|
74
|
+
const hexValue = BigInt(b10Value).toString(16)
|
|
75
|
+
return fromHex(padToEven(hexValue), 'buffer')
|
|
72
76
|
}
|
|
73
77
|
|
|
74
78
|
export function normalizeTxId(txId) {
|