@exodus/ethereum-api 8.64.7 → 8.66.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 +30 -0
- package/package.json +4 -3
- package/src/create-asset-utils.js +70 -1
- package/src/create-asset.js +8 -0
- package/src/fee-utils.js +32 -30
- package/src/index.js +2 -0
- package/src/tx-log/clarity-monitor-v2.js +10 -1
- package/src/tx-log/clarity-monitor.js +3 -1
- package/src/tx-log/ethereum-no-history-monitor.js +3 -1
- package/src/tx-log/monitor-utils/get-current-eip7702-delegation.js +40 -10
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,36 @@
|
|
|
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
|
+
## [8.66.0](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.64.5...@exodus/ethereum-api@8.66.0) (2026-03-04)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
* feat: add USDT blacklist status APIs for ETH and TRX and expose TRX raw account (#7444)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
* fix: avoid race conditions resulting in a `tipGasPrice` of `0` where possible (#7458)
|
|
19
|
+
|
|
20
|
+
* fix: harden EthlikeError and improve error handling in tx-send (#7308)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
## [8.65.0](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.64.5...@exodus/ethereum-api@8.65.0) (2026-03-03)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Features
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
* feat: encode per-network support flag, fix stale delegation state, eip7702 whitelist (#7477)
|
|
31
|
+
|
|
32
|
+
* feat: gas price bump for evm (#7500)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
6
36
|
## [8.64.7](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.64.5...@exodus/ethereum-api@8.64.7) (2026-02-24)
|
|
7
37
|
|
|
8
38
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/ethereum-api",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.66.0",
|
|
4
4
|
"description": "Transaction monitors, fee monitors, RPC with the blockchain node, and other networking code for Ethereum and EVM-based blockchains",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@exodus/asset": "^2.0.4",
|
|
26
|
-
"@exodus/asset-lib": "^5.
|
|
26
|
+
"@exodus/asset-lib": "^5.8.0",
|
|
27
27
|
"@exodus/assets": "^11.4.0",
|
|
28
28
|
"@exodus/basic-utils": "^3.0.1",
|
|
29
29
|
"@exodus/bip44-constants": "^195.0.0",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"@exodus/ethereum-meta": "^2.9.1",
|
|
34
34
|
"@exodus/ethereumholesky-meta": "^2.0.5",
|
|
35
35
|
"@exodus/ethereumjs": "^1.8.0",
|
|
36
|
+
"@exodus/ethersproject-abi": "^5.4.2-exodus.2",
|
|
36
37
|
"@exodus/fetch": "^1.3.0",
|
|
37
38
|
"@exodus/models": "^12.13.0",
|
|
38
39
|
"@exodus/safe-string": "^1.4.0",
|
|
@@ -68,5 +69,5 @@
|
|
|
68
69
|
"type": "git",
|
|
69
70
|
"url": "git+https://github.com/ExodusMovement/assets.git"
|
|
70
71
|
},
|
|
71
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "c715aabef7146610ab562c184a971c675f6d088f"
|
|
72
73
|
}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
+
import { BlacklistCheckTypes } from '@exodus/asset-lib'
|
|
2
|
+
import { defaultAbiCoder } from '@exodus/ethersproject-abi'
|
|
3
|
+
import { safeString } from '@exodus/safe-string'
|
|
1
4
|
import assert from 'minimalistic-assert'
|
|
2
5
|
import ms from 'ms'
|
|
3
6
|
|
|
7
|
+
import { EVM_ERROR_REASONS, withErrorReason } from './error-wrapper.js'
|
|
4
8
|
import { createEvmServer, createWsGateway, ValidMonitorTypes } from './exodus-eth-server/index.js'
|
|
5
9
|
import { createEthereumHooks } from './hooks/index.js'
|
|
6
10
|
import { ClarityMonitor } from './tx-log/clarity-monitor.js'
|
|
7
11
|
import { ClarityMonitorV2 } from './tx-log/clarity-monitor-v2.js'
|
|
8
12
|
import { EthereumMonitor } from './tx-log/ethereum-monitor.js'
|
|
9
13
|
import { EthereumNoHistoryMonitor } from './tx-log/ethereum-no-history-monitor.js'
|
|
10
|
-
import { BLOCK_TAG_PENDING, resolveNonce } from './tx-send/nonce-utils.js'
|
|
14
|
+
import { BLOCK_TAG_LATEST, BLOCK_TAG_PENDING, resolveNonce } from './tx-send/nonce-utils.js'
|
|
11
15
|
|
|
12
16
|
// Determines the appropriate `monitorType`, `serverUrl` and `monitorInterval`
|
|
13
17
|
// to use for a given config.
|
|
@@ -141,6 +145,7 @@ export const createHistoryMonitorFactory = ({
|
|
|
141
145
|
stakingAssetNames,
|
|
142
146
|
rpcBalanceAssetNames,
|
|
143
147
|
wsGatewayUri,
|
|
148
|
+
eip7702Supported,
|
|
144
149
|
}) => {
|
|
145
150
|
assert(assetName, 'expected assetName')
|
|
146
151
|
assert(assetClientInterface, 'expected assetClientInterface')
|
|
@@ -158,6 +163,7 @@ export const createHistoryMonitorFactory = ({
|
|
|
158
163
|
interval: ms(monitorInterval || '5m'),
|
|
159
164
|
server,
|
|
160
165
|
rpcBalanceAssetNames,
|
|
166
|
+
eip7702Supported,
|
|
161
167
|
...args,
|
|
162
168
|
})
|
|
163
169
|
break
|
|
@@ -168,6 +174,7 @@ export const createHistoryMonitorFactory = ({
|
|
|
168
174
|
server,
|
|
169
175
|
rpcBalanceAssetNames,
|
|
170
176
|
wsGatewayClient: createWsGateway({ uri: wsGatewayUri }),
|
|
177
|
+
eip7702Supported,
|
|
171
178
|
...args,
|
|
172
179
|
})
|
|
173
180
|
break
|
|
@@ -176,6 +183,7 @@ export const createHistoryMonitorFactory = ({
|
|
|
176
183
|
assetClientInterface,
|
|
177
184
|
interval: ms(monitorInterval || '15s'),
|
|
178
185
|
server,
|
|
186
|
+
eip7702Supported,
|
|
179
187
|
...args,
|
|
180
188
|
})
|
|
181
189
|
break
|
|
@@ -241,3 +249,64 @@ export const getNonceFactory = ({ assetClientInterface, useAbsoluteBalanceAndNon
|
|
|
241
249
|
|
|
242
250
|
return { getNonce }
|
|
243
251
|
}
|
|
252
|
+
|
|
253
|
+
// Creates a contract-based blacklist check function.
|
|
254
|
+
// async ({ address }) => boolean
|
|
255
|
+
export const createContractBlackListCheck = ({ contractAddress, selector, server }) => {
|
|
256
|
+
assert(contractAddress, 'expected contractAddress')
|
|
257
|
+
assert(selector, 'expected selector')
|
|
258
|
+
assert(server, 'expected server')
|
|
259
|
+
|
|
260
|
+
return async ({ address }) => {
|
|
261
|
+
const tag = BLOCK_TAG_LATEST
|
|
262
|
+
const encodedAddress = address.slice(2).toLowerCase().padStart(64, '0')
|
|
263
|
+
const data = selector + encodedAddress
|
|
264
|
+
const result = await withErrorReason({
|
|
265
|
+
promise: server.ethCall({ to: contractAddress, data }, tag),
|
|
266
|
+
errorReasonInfo: EVM_ERROR_REASONS.ethCallErc20Failed,
|
|
267
|
+
hint: safeString`getBlackListStatus:ethCall`,
|
|
268
|
+
baseAssetName: server.baseAssetName,
|
|
269
|
+
})
|
|
270
|
+
|
|
271
|
+
if (typeof result !== 'string' || result.length === 0) {
|
|
272
|
+
throw new Error('getBlackListStatus got invalid ethCall response')
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
let isBlacklisted
|
|
276
|
+
try {
|
|
277
|
+
;[isBlacklisted] = defaultAbiCoder.decode(['bool'], result)
|
|
278
|
+
} catch (err) {
|
|
279
|
+
throw new Error(`getBlackListStatus got invalid ABI bool result: ${err.message}`)
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
return isBlacklisted
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// Composes blacklist check factories into a single getBlackListStatus.
|
|
287
|
+
// Returns undefined if no checks are provided.
|
|
288
|
+
// Returns { isBlacklisted: true } if ANY check returns true.
|
|
289
|
+
// NOTE: blacklistChecks defaults to [] as a convenience, but it is the asset's responsibility
|
|
290
|
+
// to be properly configured with the appropriate checks. An empty array means no blacklist
|
|
291
|
+
// checks are run, which implies EIP-7702 is effectively enabled on that network with no whitelist.
|
|
292
|
+
export const createGetBlackListStatus = ({ address: addressApi, blacklistChecks = [], server }) => {
|
|
293
|
+
if (blacklistChecks.length === 0) return
|
|
294
|
+
|
|
295
|
+
assert(addressApi, 'expected address')
|
|
296
|
+
|
|
297
|
+
// Extend here to support additional blacklist sources (e.g. an internal database query).
|
|
298
|
+
const checks = blacklistChecks.map((factory) => {
|
|
299
|
+
if (factory.type === BlacklistCheckTypes.CONTRACT_CALL) {
|
|
300
|
+
assert(server, 'expected server for CONTRACT_CALL blacklist check')
|
|
301
|
+
return factory({ server })
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
throw new Error(`Unknown blacklist check type: ${factory.type}`)
|
|
305
|
+
})
|
|
306
|
+
|
|
307
|
+
return async ({ address }) => {
|
|
308
|
+
assert(addressApi.validate(address), 'getBlackListStatus requires a valid Ethereum address')
|
|
309
|
+
const results = await Promise.all(checks.map((check) => check({ address })))
|
|
310
|
+
return { isBlacklisted: results.some(Boolean) }
|
|
311
|
+
}
|
|
312
|
+
}
|
package/src/create-asset.js
CHANGED
|
@@ -22,6 +22,7 @@ import assert from 'minimalistic-assert'
|
|
|
22
22
|
|
|
23
23
|
import { addressHasHistoryFactory } from './address-has-history.js'
|
|
24
24
|
import {
|
|
25
|
+
createGetBlackListStatus,
|
|
25
26
|
createHistoryMonitorFactory,
|
|
26
27
|
createTransactionPrivacyFactory,
|
|
27
28
|
getNonceFactory,
|
|
@@ -68,11 +69,13 @@ export const createAssetFactory = ({
|
|
|
68
69
|
useEip1191ChainIdChecksum = false,
|
|
69
70
|
forceGasLimitEstimation = false,
|
|
70
71
|
rpcBalanceAssetNames = [],
|
|
72
|
+
blacklistChecks = [],
|
|
71
73
|
supportsCustomFees: defaultSupportsCustomFees = false,
|
|
72
74
|
useAbsoluteBalanceAndNonce = false,
|
|
73
75
|
delisted = false,
|
|
74
76
|
privacyRpcUrl: defaultPrivacyRpcUrl,
|
|
75
77
|
wsGatewayUri: defaultWsGatewayUri,
|
|
78
|
+
eip7702Supported,
|
|
76
79
|
}) => {
|
|
77
80
|
assert(assetsList, 'assetsList is required')
|
|
78
81
|
assert(providedFeeData || feeDataConfig, 'feeData or feeDataConfig is required')
|
|
@@ -233,6 +236,7 @@ export const createAssetFactory = ({
|
|
|
233
236
|
stakingAssetNames,
|
|
234
237
|
rpcBalanceAssetNames,
|
|
235
238
|
wsGatewayUri,
|
|
239
|
+
eip7702Supported,
|
|
236
240
|
})
|
|
237
241
|
|
|
238
242
|
const defaultAddressPath = 'm/0/0'
|
|
@@ -262,6 +266,8 @@ export const createAssetFactory = ({
|
|
|
262
266
|
|
|
263
267
|
const { getNonce } = getNonceFactory({ assetClientInterface, useAbsoluteBalanceAndNonce })
|
|
264
268
|
|
|
269
|
+
const getBlackListStatus = createGetBlackListStatus({ server, address, blacklistChecks })
|
|
270
|
+
|
|
265
271
|
const api = {
|
|
266
272
|
addressHasHistory,
|
|
267
273
|
broadcastTx: (...args) => server.sendRawTransaction(...args),
|
|
@@ -277,6 +283,7 @@ export const createAssetFactory = ({
|
|
|
277
283
|
getActivityTxs,
|
|
278
284
|
getBalances,
|
|
279
285
|
getBalanceForAddress: createGetBalanceForAddress({ asset, server }),
|
|
286
|
+
...(getBlackListStatus && { getBlackListStatus }),
|
|
280
287
|
getConfirmationsNumber: () => confirmationsNumber,
|
|
281
288
|
getDefaultAddressPath: () => defaultAddressPath,
|
|
282
289
|
getFeeAsync: createTx, // createTx alias, remove me when possible
|
|
@@ -326,6 +333,7 @@ export const createAssetFactory = ({
|
|
|
326
333
|
broadcastPrivateBundle,
|
|
327
334
|
broadcastPrivateTx,
|
|
328
335
|
forceGasLimitEstimation,
|
|
336
|
+
eip7702Supported,
|
|
329
337
|
getEIP7702Delegation: (addr) => getEIP7702Delegation({ address: addr, server }),
|
|
330
338
|
getNonce,
|
|
331
339
|
privacyServer,
|
package/src/fee-utils.js
CHANGED
|
@@ -1,34 +1,40 @@
|
|
|
1
1
|
import assert from 'minimalistic-assert'
|
|
2
2
|
|
|
3
|
-
export const applyMultiplierToPrice = ({ feeAsset, gasPriceMultiplier, price }) => {
|
|
4
|
-
assert(typeof price === 'string', 'price should be a string')
|
|
5
|
-
return feeAsset.currency
|
|
6
|
-
.parse(price)
|
|
7
|
-
.mul(gasPriceMultiplier || 1)
|
|
8
|
-
.toBaseString({ unit: true })
|
|
9
|
-
}
|
|
10
|
-
|
|
11
3
|
/**
|
|
12
4
|
* Returns augmented `feeConfig` values manipulated using the `feeData`,
|
|
13
5
|
* for example, like multiplying the `gasPrice`. This helps us to apply
|
|
14
6
|
* modifications to values before presenting them to the consumer.
|
|
15
|
-
*
|
|
16
|
-
* TODO: We shouldn't actually do this, lol. The closer we are to
|
|
17
|
-
* the node, the better!
|
|
18
7
|
*/
|
|
19
|
-
export const
|
|
8
|
+
export const refineFeeConfig = ({ feeAsset, feeConfig, gasPriceBump, gasPriceMultiplier }) => {
|
|
9
|
+
const fromString = (str) => {
|
|
10
|
+
assert(typeof str === 'string', 'expected string')
|
|
11
|
+
return feeAsset.currency.parse(str)
|
|
12
|
+
}
|
|
13
|
+
|
|
20
14
|
try {
|
|
21
|
-
const { gasPrice, baseFeePerGas, ...extras } = feeConfig
|
|
15
|
+
const { gasPrice, baseFeePerGas, tipGasPrice, ...extras } = feeConfig
|
|
16
|
+
|
|
17
|
+
gasPriceMultiplier ||= 1
|
|
18
|
+
gasPriceBump ||= feeAsset.currency.ZERO
|
|
19
|
+
|
|
20
|
+
if (!baseFeePerGas) {
|
|
21
|
+
const nextGasPrice = fromString(gasPrice).mul(gasPriceMultiplier).add(gasPriceBump)
|
|
22
|
+
return {
|
|
23
|
+
...extras,
|
|
24
|
+
gasPrice: nextGasPrice.toBaseString({ unit: true }),
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const nextBaseFeePerGas = fromString(baseFeePerGas).mul(gasPriceMultiplier)
|
|
29
|
+
const nextTipGasPrice = tipGasPrice
|
|
30
|
+
? fromString(tipGasPrice).mul(gasPriceMultiplier).add(gasPriceBump)
|
|
31
|
+
: gasPriceBump
|
|
32
|
+
|
|
22
33
|
return {
|
|
23
34
|
...extras,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
price: gasPrice,
|
|
28
|
-
}) /* required */,
|
|
29
|
-
baseFeePerGas: baseFeePerGas
|
|
30
|
-
? applyMultiplierToPrice({ feeAsset, gasPriceMultiplier, price: baseFeePerGas })
|
|
31
|
-
: undefined,
|
|
35
|
+
baseFeePerGas: nextBaseFeePerGas.toBaseString({ unit: true }),
|
|
36
|
+
tipGasPrice: nextTipGasPrice.toBaseString({ unit: true }),
|
|
37
|
+
gasPrice: nextBaseFeePerGas.add(nextTipGasPrice).toBaseString({ unit: true }),
|
|
32
38
|
}
|
|
33
39
|
} catch (e) {
|
|
34
40
|
console.error(
|
|
@@ -148,9 +154,10 @@ export const calculateEthLikeFeeMonitorUpdate = async ({
|
|
|
148
154
|
|
|
149
155
|
// Depending on whether `eip1559Enabled` on the client, we
|
|
150
156
|
// can choose to return different properties.
|
|
151
|
-
const { eip1559Enabled, gasPriceMultiplier } =
|
|
152
|
-
|
|
153
|
-
|
|
157
|
+
const { eip1559Enabled, gasPriceBump, gasPriceMultiplier } =
|
|
158
|
+
await assetClientInterface.getFeeConfig({
|
|
159
|
+
assetName: feeAsset.name,
|
|
160
|
+
})
|
|
154
161
|
|
|
155
162
|
// NOTE: The `gasPrice` is a required value for all EVM networks.
|
|
156
163
|
const gasPrice = ensureBigInt(fetchedGasPrices.gasPrice)
|
|
@@ -159,12 +166,7 @@ export const calculateEthLikeFeeMonitorUpdate = async ({
|
|
|
159
166
|
? calculateEthLikeFeeMonitorUpdateEip1559({ gasPrice, feeAsset, fetchedGasPrices })
|
|
160
167
|
: calculateEthLikeFeeMonitorUpdateNonEip1559({ gasPrice }))
|
|
161
168
|
|
|
162
|
-
|
|
163
|
-
// to our `gasPrice` and `baseFeePerGas` values. Once we're
|
|
164
|
-
// feeling confident, we should be safe to skip doing this for
|
|
165
|
-
// `eip1559Enabled` chains, since we should be able to guarantee
|
|
166
|
-
// next block inclusion with accuracy.
|
|
167
|
-
return rewriteFeeConfig({ feeAsset, feeConfig, gasPriceMultiplier })
|
|
169
|
+
return refineFeeConfig({ feeAsset, feeConfig, gasPriceBump, gasPriceMultiplier })
|
|
168
170
|
}
|
|
169
171
|
|
|
170
172
|
/**
|
package/src/index.js
CHANGED
|
@@ -100,6 +100,8 @@ export { txSendFactory } from './tx-send/index.js'
|
|
|
100
100
|
|
|
101
101
|
export { createAssetFactory } from './create-asset.js'
|
|
102
102
|
|
|
103
|
+
export { createContractBlackListCheck } from './create-asset-utils.js'
|
|
104
|
+
|
|
103
105
|
export {
|
|
104
106
|
createAssetPluginFactory,
|
|
105
107
|
fromAddEthereumChainParameterToFactoryParams,
|
|
@@ -28,7 +28,14 @@ export class ClarityMonitorV2 extends BaseMonitor {
|
|
|
28
28
|
#walletAccountByAddress = new Map()
|
|
29
29
|
#walletAccountInfo = new Map()
|
|
30
30
|
#rpcBalanceAssetNames = []
|
|
31
|
-
constructor({
|
|
31
|
+
constructor({
|
|
32
|
+
server,
|
|
33
|
+
wsGatewayClient,
|
|
34
|
+
rpcBalanceAssetNames,
|
|
35
|
+
eip7702Supported,
|
|
36
|
+
config,
|
|
37
|
+
...args
|
|
38
|
+
} = {}) {
|
|
32
39
|
super(args)
|
|
33
40
|
assert(wsGatewayClient instanceof WsGateway, 'expected WsGateway wsGatewayClient')
|
|
34
41
|
|
|
@@ -36,6 +43,7 @@ export class ClarityMonitorV2 extends BaseMonitor {
|
|
|
36
43
|
this.server = server
|
|
37
44
|
this.#wsClient = wsGatewayClient
|
|
38
45
|
this.#rpcBalanceAssetNames = rpcBalanceAssetNames
|
|
46
|
+
this.eip7702Supported = eip7702Supported
|
|
39
47
|
this.getAllLogItemsByAsset = getAllLogItemsByAsset
|
|
40
48
|
this.deriveDataNeededForTick = getDeriveDataNeededForTick(this.aci)
|
|
41
49
|
this.deriveTransactionsToCheck = getDeriveTransactionsToCheck({
|
|
@@ -227,6 +235,7 @@ export class ClarityMonitorV2 extends BaseMonitor {
|
|
|
227
235
|
const eip7702Delegation = await getCurrentEIP7702Delegation({
|
|
228
236
|
server: this.server,
|
|
229
237
|
address: derivedData.ourWalletAddress,
|
|
238
|
+
eip7702Supported: this.eip7702Supported,
|
|
230
239
|
currentDelegation: derivedData.currentAccountState?.eip7702Delegation,
|
|
231
240
|
logger: this.logger,
|
|
232
241
|
})
|
|
@@ -23,11 +23,12 @@ import {
|
|
|
23
23
|
const { isEmpty } = lodash
|
|
24
24
|
|
|
25
25
|
export class ClarityMonitor extends BaseMonitor {
|
|
26
|
-
constructor({ server, config, rpcBalanceAssetNames, ...args }) {
|
|
26
|
+
constructor({ server, config, rpcBalanceAssetNames, eip7702Supported, ...args }) {
|
|
27
27
|
super(args)
|
|
28
28
|
this.config = { GAS_PRICE_FROM_WEBSOCKET: true, ...config }
|
|
29
29
|
this.server = server
|
|
30
30
|
this.rpcBalanceAssetNames = rpcBalanceAssetNames
|
|
31
|
+
this.eip7702Supported = eip7702Supported
|
|
31
32
|
this.getAllLogItemsByAsset = getAllLogItemsByAsset
|
|
32
33
|
this.deriveDataNeededForTick = getDeriveDataNeededForTick(this.aci)
|
|
33
34
|
this.deriveTransactionsToCheck = getDeriveTransactionsToCheck({
|
|
@@ -191,6 +192,7 @@ export class ClarityMonitor extends BaseMonitor {
|
|
|
191
192
|
const eip7702Delegation = await getCurrentEIP7702Delegation({
|
|
192
193
|
server: this.server,
|
|
193
194
|
address: derivedData.ourWalletAddress,
|
|
195
|
+
eip7702Supported: this.eip7702Supported,
|
|
194
196
|
currentDelegation: derivedData.currentAccountState?.eip7702Delegation,
|
|
195
197
|
logger: this.logger,
|
|
196
198
|
})
|
|
@@ -17,10 +17,11 @@ const { isEmpty, unionBy, zipObject } = lodash
|
|
|
17
17
|
// The base ethereum monitor no history class handles listening for assets with no history
|
|
18
18
|
|
|
19
19
|
export class EthereumNoHistoryMonitor extends BaseMonitor {
|
|
20
|
-
constructor({ server, config, ...args }) {
|
|
20
|
+
constructor({ server, config, eip7702Supported, ...args }) {
|
|
21
21
|
super(args)
|
|
22
22
|
this.server = server
|
|
23
23
|
this.config = { ...config }
|
|
24
|
+
this.eip7702Supported = eip7702Supported
|
|
24
25
|
this.deriveDataNeededForTick = getDeriveDataNeededForTick(this.aci)
|
|
25
26
|
this.deriveTransactionsToCheck = getDeriveTransactionsToCheck({
|
|
26
27
|
getTxLog: (...args) => this.aci.getTxLog(...args),
|
|
@@ -190,6 +191,7 @@ export class EthereumNoHistoryMonitor extends BaseMonitor {
|
|
|
190
191
|
const eip7702Delegation = await getCurrentEIP7702Delegation({
|
|
191
192
|
server: this.server,
|
|
192
193
|
address: ourWalletAddress,
|
|
194
|
+
eip7702Supported: this.eip7702Supported,
|
|
193
195
|
currentDelegation: currentAccountState?.eip7702Delegation,
|
|
194
196
|
logger: this.logger,
|
|
195
197
|
})
|
|
@@ -1,38 +1,68 @@
|
|
|
1
1
|
import { getEIP7702Delegation } from '../../eth-like-util.js'
|
|
2
2
|
|
|
3
|
+
const NOT_DELEGATED = { isDelegated: false, delegatedAddress: null, isWhitelisted: null }
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* Checks if the address has an EIP-7702 delegation and returns the delegation state.
|
|
5
7
|
* Returns the new state if changed, or the current state if unchanged.
|
|
6
|
-
* On error, returns
|
|
8
|
+
* On error, conservatively returns { isDelegated: false } to avoid showing stale delegation
|
|
9
|
+
* state that may no longer be accurate.
|
|
7
10
|
*
|
|
8
11
|
* @param {Object} params
|
|
9
12
|
* @param {Object} params.server - The server instance to use for getCode
|
|
10
13
|
* @param {string} params.address - The wallet address to check
|
|
14
|
+
* @param {Array<{address: string, name: string}>} [params.eip7702Supported] - Whitelist of trusted delegation targets.
|
|
15
|
+
* If not an array, the check is skipped entirely (chain does not support EIP-7702).
|
|
16
|
+
* An empty array means the check runs but every delegation will be isWhitelisted: false.
|
|
11
17
|
* @param {Object} [params.currentDelegation] - The current delegation state from accountState
|
|
12
18
|
* @param {Object} [params.logger] - Optional logger for warnings
|
|
13
19
|
* @returns {Promise<Object|undefined>} The delegation state to use
|
|
14
20
|
*/
|
|
15
|
-
export async function getCurrentEIP7702Delegation({
|
|
21
|
+
export async function getCurrentEIP7702Delegation({
|
|
22
|
+
server,
|
|
23
|
+
address,
|
|
24
|
+
eip7702Supported,
|
|
25
|
+
currentDelegation,
|
|
26
|
+
logger,
|
|
27
|
+
}) {
|
|
28
|
+
// Non-array (undefined, false, etc.) → chain doesn't support EIP-7702, skip entirely
|
|
29
|
+
if (!Array.isArray(eip7702Supported)) return NOT_DELEGATED
|
|
30
|
+
|
|
16
31
|
try {
|
|
17
32
|
const result = await getEIP7702Delegation({ address, server })
|
|
18
33
|
|
|
19
|
-
|
|
34
|
+
if (!result.isDelegated) return NOT_DELEGATED
|
|
35
|
+
|
|
36
|
+
// [] → check runs but nothing is trusted; populated array → whitelist check
|
|
37
|
+
const isWhitelisted = eip7702Supported.some(
|
|
38
|
+
({ address }) => address.toLowerCase() === result.delegatedAddress.toLowerCase()
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
const newDelegation = {
|
|
42
|
+
isDelegated: true,
|
|
43
|
+
delegatedAddress: result.delegatedAddress,
|
|
44
|
+
isWhitelisted,
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Return new state only if something changed
|
|
20
48
|
if (
|
|
21
|
-
currentDelegation?.isDelegated !==
|
|
22
|
-
currentDelegation?.delegatedAddress !==
|
|
49
|
+
currentDelegation?.isDelegated !== newDelegation.isDelegated ||
|
|
50
|
+
currentDelegation?.delegatedAddress !== newDelegation.delegatedAddress ||
|
|
51
|
+
currentDelegation?.isWhitelisted !== newDelegation.isWhitelisted
|
|
23
52
|
) {
|
|
24
|
-
return
|
|
25
|
-
isDelegated: result.isDelegated,
|
|
26
|
-
delegatedAddress: result.delegatedAddress,
|
|
27
|
-
}
|
|
53
|
+
return newDelegation
|
|
28
54
|
}
|
|
29
55
|
} catch (error) {
|
|
30
56
|
if (logger) {
|
|
31
57
|
logger.warn('Failed to check EIP-7702 delegation:', error)
|
|
32
58
|
}
|
|
59
|
+
|
|
60
|
+
// On error, conservatively clear delegation state — only hard RPC confirmation
|
|
61
|
+
// should result in isDelegated: true being shown to the user.
|
|
62
|
+
return NOT_DELEGATED
|
|
33
63
|
}
|
|
34
64
|
|
|
35
|
-
// Return current state if unchanged
|
|
65
|
+
// Return current state if unchanged
|
|
36
66
|
return currentDelegation
|
|
37
67
|
}
|
|
38
68
|
|