@exodus/ethereum-api 8.64.0 → 8.64.1
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 +12 -0
- package/package.json +2 -2
- package/src/exodus-eth-server/clarity-v2.js +5 -4
- package/src/tx-log/clarity-monitor-v2.js +20 -2
- package/src/tx-log/clarity-monitor.js +20 -2
- package/src/tx-log/ethereum-monitor.js +18 -7
- package/src/tx-log/ethereum-no-history-monitor.js +1 -1
- package/src/tx-log/monitor-utils/index.js +1 -0
- package/src/tx-log/monitor-utils/verify-pending-tx-status-rpc.js +69 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
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.64.1](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.64.0...@exodus/ethereum-api@8.64.1) (2026-01-21)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
* fix: monitors should check rpc before dropping (#7277)
|
|
13
|
+
|
|
14
|
+
* fix: prevent transactions from being dropped from no history monitor whilst they are still served at the rpc (#7299)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
6
18
|
## [8.64.0](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.63.0...@exodus/ethereum-api@8.64.0) (2026-01-14)
|
|
7
19
|
|
|
8
20
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/ethereum-api",
|
|
3
|
-
"version": "8.64.
|
|
3
|
+
"version": "8.64.1",
|
|
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",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"type": "git",
|
|
68
68
|
"url": "git+https://github.com/ExodusMovement/assets.git"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "d828ba4e4dc9f986cfa563653101410e6e81685a"
|
|
71
71
|
}
|
|
@@ -175,11 +175,12 @@ export default class ClarityServerV2 extends ClarityServer {
|
|
|
175
175
|
const newCursor = Buffer.alloc(8)
|
|
176
176
|
newCursor.writeBigUInt64LE(BigInt(blockNumber), 0)
|
|
177
177
|
|
|
178
|
+
// Separate confirmed (has blockNumber) from pending (blockNumber is null)
|
|
179
|
+
const confirmed = transactions.filter((tx) => tx.blockNumber != null)
|
|
180
|
+
const pending = transactions.filter((tx) => tx.blockNumber == null)
|
|
181
|
+
|
|
178
182
|
return {
|
|
179
|
-
transactions: {
|
|
180
|
-
confirmed: transactions,
|
|
181
|
-
pending: [],
|
|
182
|
-
},
|
|
183
|
+
transactions: { confirmed, pending },
|
|
183
184
|
cursor: newCursor,
|
|
184
185
|
}
|
|
185
186
|
}
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
getCurrentEIP7702Delegation,
|
|
14
14
|
getDeriveDataNeededForTick,
|
|
15
15
|
getDeriveTransactionsToCheck,
|
|
16
|
+
verifyRpcPendingTxStatusBatch,
|
|
16
17
|
} from './monitor-utils/index.js'
|
|
17
18
|
|
|
18
19
|
const { isEmpty } = lodash
|
|
@@ -127,9 +128,26 @@ export class ClarityMonitorV2 extends BaseMonitor {
|
|
|
127
128
|
}
|
|
128
129
|
}
|
|
129
130
|
|
|
131
|
+
// Batch verify all pending txs with a single RPC call (skip if refresh)
|
|
132
|
+
const txIds = Object.keys(pendingTransactionsToCheck)
|
|
133
|
+
const statuses = params.refresh
|
|
134
|
+
? {}
|
|
135
|
+
: await verifyRpcPendingTxStatusBatch({
|
|
136
|
+
baseAsset: this.asset,
|
|
137
|
+
logger: this.logger,
|
|
138
|
+
txIds,
|
|
139
|
+
})
|
|
140
|
+
|
|
130
141
|
for (const { tx, assetName } of Object.values(pendingTransactionsToCheck)) {
|
|
131
|
-
if (params.refresh)
|
|
132
|
-
|
|
142
|
+
if (params.refresh) {
|
|
143
|
+
await updateTx(tx, assetName, { remove: true })
|
|
144
|
+
} else {
|
|
145
|
+
const txStatus = statuses[tx.txId]
|
|
146
|
+
if (txStatus?.status === 'dropped') {
|
|
147
|
+
await updateTx(tx, assetName, { error: 'Dropped' })
|
|
148
|
+
}
|
|
149
|
+
// status === 'confirmed' or 'pending' - tx is fine, wait for Clarity to confirm
|
|
150
|
+
}
|
|
133
151
|
}
|
|
134
152
|
|
|
135
153
|
return { txsToRemove }
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
getCurrentEIP7702Delegation,
|
|
14
14
|
getDeriveDataNeededForTick,
|
|
15
15
|
getDeriveTransactionsToCheck,
|
|
16
|
+
verifyRpcPendingTxStatusBatch,
|
|
16
17
|
} from './monitor-utils/index.js'
|
|
17
18
|
|
|
18
19
|
const { isEmpty } = lodash
|
|
@@ -111,9 +112,26 @@ export class ClarityMonitor extends BaseMonitor {
|
|
|
111
112
|
}
|
|
112
113
|
}
|
|
113
114
|
|
|
115
|
+
// Batch verify all pending txs with a single RPC call (skip if refresh)
|
|
116
|
+
const txIds = Object.keys(pendingTransactionsToCheck)
|
|
117
|
+
const statuses = params.refresh
|
|
118
|
+
? {}
|
|
119
|
+
: await verifyRpcPendingTxStatusBatch({
|
|
120
|
+
baseAsset: this.asset,
|
|
121
|
+
logger: this.logger,
|
|
122
|
+
txIds,
|
|
123
|
+
})
|
|
124
|
+
|
|
114
125
|
for (const { tx, assetName } of Object.values(pendingTransactionsToCheck)) {
|
|
115
|
-
if (params.refresh)
|
|
116
|
-
|
|
126
|
+
if (params.refresh) {
|
|
127
|
+
await updateTx(tx, assetName, { remove: true })
|
|
128
|
+
} else {
|
|
129
|
+
const txStatus = statuses[tx.txId]
|
|
130
|
+
if (txStatus?.status === 'dropped') {
|
|
131
|
+
await updateTx(tx, assetName, { error: 'Dropped' })
|
|
132
|
+
}
|
|
133
|
+
// status === 'confirmed' or 'pending' - tx is fine, wait for Clarity to confirm
|
|
134
|
+
}
|
|
117
135
|
}
|
|
118
136
|
|
|
119
137
|
return { txsToRemove }
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
getDeriveTransactionsToCheck,
|
|
13
13
|
getHistoryFromServer,
|
|
14
14
|
getLogItemsFromServerTx,
|
|
15
|
+
verifyRpcPendingTxStatusBatch,
|
|
15
16
|
} from './monitor-utils/index.js'
|
|
16
17
|
import {
|
|
17
18
|
enableWSUpdates,
|
|
@@ -118,17 +119,27 @@ export class EthereumMonitor extends BaseMonitor {
|
|
|
118
119
|
}
|
|
119
120
|
}
|
|
120
121
|
|
|
122
|
+
// Batch verify all pending txs with a single RPC call (skip if refresh)
|
|
123
|
+
const txIds = Object.keys(pendingTransactionsToCheck)
|
|
124
|
+
const statuses = params.refresh
|
|
125
|
+
? {}
|
|
126
|
+
: await verifyRpcPendingTxStatusBatch({
|
|
127
|
+
baseAsset: this.asset,
|
|
128
|
+
logger: this.logger,
|
|
129
|
+
txIds,
|
|
130
|
+
})
|
|
131
|
+
|
|
121
132
|
for (const { tx, assetName } of Object.values(pendingTransactionsToCheck)) {
|
|
122
133
|
if (params.refresh) {
|
|
123
134
|
await updateTx(tx, assetName, { remove: true })
|
|
124
135
|
} else {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
136
|
+
const txStatus = statuses[tx.txId]
|
|
137
|
+
if (txStatus?.status === 'confirmed') {
|
|
138
|
+
await updateTx(tx, assetName, { isTxConfirmed: true })
|
|
139
|
+
} else if (txStatus?.status === 'dropped') {
|
|
140
|
+
await updateTx(tx, assetName, { isTxConfirmed: false })
|
|
141
|
+
}
|
|
142
|
+
// status === 'pending' or missing - tx still in mempool, do nothing
|
|
132
143
|
}
|
|
133
144
|
}
|
|
134
145
|
|
|
@@ -135,7 +135,7 @@ export class EthereumNoHistoryMonitor extends BaseMonitor {
|
|
|
135
135
|
for (const { tx, assetName } of pendingTransactions) {
|
|
136
136
|
const txFromNode = pendingTxsFromNode[tx.txId]
|
|
137
137
|
const isConfirmed = Boolean(txFromNode?.blockHash)
|
|
138
|
-
if (now - tx.date.getTime() > UNCONFIRMED_TX_LIMIT && !
|
|
138
|
+
if (now - tx.date.getTime() > UNCONFIRMED_TX_LIMIT && !txFromNode) {
|
|
139
139
|
txsToRemove.push({
|
|
140
140
|
tx,
|
|
141
141
|
assetSource: { asset: assetName, walletAccount },
|
|
@@ -6,4 +6,5 @@ export { default as getHistoryFromServer } from './get-history-from-server.js'
|
|
|
6
6
|
export { default as checkPendingTransactions } from './check-pending-transactions.js'
|
|
7
7
|
export { default as getDeriveTransactionsToCheck } from './get-derive-transactions-to-check.js'
|
|
8
8
|
export { default as getCurrentEIP7702Delegation } from './get-current-eip7702-delegation.js'
|
|
9
|
+
export { default as verifyRpcPendingTxStatusBatch } from './verify-pending-tx-status-rpc.js'
|
|
9
10
|
export * from './exclude-unchanged-token-balances.js'
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Determines the status of an RPC transaction response.
|
|
3
|
+
*
|
|
4
|
+
* @param {Object|null} rpcTx - The RPC transaction response
|
|
5
|
+
* @returns {{status: 'confirmed' | 'pending' | 'dropped', blockNumber?: number}}
|
|
6
|
+
*/
|
|
7
|
+
function getTxStatus(rpcTx) {
|
|
8
|
+
if (rpcTx?.blockNumber) {
|
|
9
|
+
return { status: 'confirmed', blockNumber: parseInt(rpcTx.blockNumber, 16) }
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
if (rpcTx) {
|
|
13
|
+
return { status: 'pending' }
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return { status: 'dropped' }
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Batch verify pending transactions against the RPC node before marking them as dropped.
|
|
21
|
+
*
|
|
22
|
+
* Any lag in the Clarity indexer can cause confirmed transactions to be incorrectly
|
|
23
|
+
* flagged as dropped if Clarity hasn't indexed their block yet.
|
|
24
|
+
* By checking the RPC directly, we avoid this race condition.
|
|
25
|
+
*
|
|
26
|
+
* Uses a single batch RPC call for efficiency and graceful error handling.
|
|
27
|
+
*
|
|
28
|
+
* @param {Object} params
|
|
29
|
+
* @param {Object} params.baseAsset - The base asset to get the server from
|
|
30
|
+
* @param {Object} params.logger - Logger instance for info/debug output
|
|
31
|
+
* @param {string[]} params.txIds - Array of transaction IDs/hashes to verify
|
|
32
|
+
* @returns {Promise<Object<string, {status: 'confirmed' | 'pending' | 'dropped', blockNumber?: number}>>}
|
|
33
|
+
*/
|
|
34
|
+
export default async function verifyRpcPendingTxStatusBatch({ baseAsset, logger, txIds }) {
|
|
35
|
+
if (txIds.length === 0) return {}
|
|
36
|
+
|
|
37
|
+
const server = baseAsset.server
|
|
38
|
+
|
|
39
|
+
// Build batch request
|
|
40
|
+
const requests = txIds.map((txId) => server.getTransactionByHashRequest(txId))
|
|
41
|
+
|
|
42
|
+
let responses
|
|
43
|
+
try {
|
|
44
|
+
responses = await server.sendBatchRequest(requests)
|
|
45
|
+
} catch (error) {
|
|
46
|
+
// If batch request fails, skip all drop checks (safe default)
|
|
47
|
+
logger.warn('Batch RPC request failed, skipping drop checks', error)
|
|
48
|
+
return {}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Map responses to statuses
|
|
52
|
+
const results = {}
|
|
53
|
+
txIds.forEach((txId, idx) => {
|
|
54
|
+
const rpcTx = responses[idx]
|
|
55
|
+
const txStatus = getTxStatus(rpcTx)
|
|
56
|
+
results[txId] = txStatus
|
|
57
|
+
|
|
58
|
+
// Log each tx status
|
|
59
|
+
if (txStatus.status === 'confirmed') {
|
|
60
|
+
logger.info(`tx ${txId} is confirmed on-chain (block ${txStatus.blockNumber}), skipping drop`)
|
|
61
|
+
} else if (txStatus.status === 'pending') {
|
|
62
|
+
logger.info(`tx ${txId} is still in mempool, skipping drop`)
|
|
63
|
+
} else {
|
|
64
|
+
logger.info(`tx ${txId} not found on-chain, marking as dropped`)
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
return results
|
|
69
|
+
}
|