@exodus/ethereum-api 10.1.1 → 10.1.3

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 CHANGED
@@ -3,6 +3,25 @@
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
+ ## [10.1.3](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@10.1.2...@exodus/ethereum-api@10.1.3) (2026-10-17)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **ethereum-api:** parse clarity nonces as decimal in sender nonce key ([#8993](https://github.com/ExodusMovement/assets/issues/8993)) ([c3cc0e8](https://github.com/ExodusMovement/assets/commit/c3cc0e8898bd63c3838f217388d08c5b295696aa))
12
+
13
+
14
+
15
+ ## [10.1.2](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@10.1.1...@exodus/ethereum-api@10.1.2) (2026-10-17)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * **ethereum-api:** do not block ETH unstake when simulation is unavailable ([#8956](https://github.com/ExodusMovement/assets/issues/8956)) ([fee54b6](https://github.com/ExodusMovement/assets/commit/fee54b64b771ba67ba2f8671d545b265c732a5d1)), closes [ExodusMovement/exodus#47093](https://github.com/ExodusMovement/exodus/issues/47093)
21
+ * **ethereum-api:** keep unowned staking snapshot when staking read fails ([#8954](https://github.com/ExodusMovement/assets/issues/8954)) ([9d2a4bd](https://github.com/ExodusMovement/assets/commit/9d2a4bd36ddcc5180f3724354d2a71488d37c22b))
22
+
23
+
24
+
6
25
  ## [10.1.1](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@10.1.0...@exodus/ethereum-api@10.1.1) (2026-10-09)
7
26
 
8
27
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/ethereum-api",
3
- "version": "10.1.1",
3
+ "version": "10.1.3",
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",
@@ -44,7 +44,6 @@
44
44
  "events": "^1.1.1",
45
45
  "idna-uts46-hx": "^2.3.1",
46
46
  "lodash": "^4.17.15",
47
- "make-concurrent": "^4.0.0",
48
47
  "minimalistic-assert": "^1.0.1",
49
48
  "ms": "^2.1.1",
50
49
  "socket.io-client": "^2.1.1"
@@ -66,5 +65,5 @@
66
65
  "type": "git",
67
66
  "url": "git+https://github.com/ExodusMovement/assets.git"
68
67
  },
69
- "gitHead": "41e6c1bb6a3d919f08cc3ee38068159259b335be"
68
+ "gitHead": "52edb548f19b12c0dab06e436330b9f1363e9055"
70
69
  }
@@ -241,6 +241,27 @@ export const getStakingHistoryBalance = ({ asset, txLog }) => {
241
241
  return stakingHistoryBalance
242
242
  }
243
243
 
244
+ /**
245
+ * Pending stakes debited through `tx.data.txAmount` instead of `tx.coinAmount`.
246
+ * The staking processor zeroes `coinAmount` on stake rows, pending ones included,
247
+ * so neither `getUnconfirmedSentBalance` nor the tx-log mutations see the debit.
248
+ * `getStakingHistoryBalance` only picks it up once the tx confirms.
249
+ */
250
+ const getPendingStakingSent = ({ asset, txLog }) => {
251
+ let pendingStakingSent = asset.currency.ZERO
252
+ for (const tx of txLog) {
253
+ if (tx.failed || !tx.pending || !tx.coinAmount.isZero) continue
254
+
255
+ const { txAmount } = tx.data
256
+ if (!txAmount) continue
257
+
258
+ const amount = asset.currency.defaultUnit(txAmount)
259
+ if (amount.isNegative) pendingStakingSent = pendingStakingSent.add(amount.abs())
260
+ }
261
+
262
+ return pendingStakingSent
263
+ }
264
+
244
265
  const getSpendable = ({ asset, balance, txLog, unconfirmedReceived }) => {
245
266
  const stakingHistoryBalance = getStakingHistoryBalance({ asset, txLog })
246
267
  return balance.add(stakingHistoryBalance).sub(unconfirmedReceived)
@@ -258,7 +279,8 @@ export const getBalancesFactory = ({ monitorType, useAbsoluteBalance, rpcBalance
258
279
  assert(monitorType, 'monitorType is required')
259
280
  return ({ asset, txLog, accountState }) => {
260
281
  const unconfirmedReceived = getUnconfirmedReceivedBalance({ asset, txLog })
261
- const unconfirmedSent = getUnconfirmedSentBalance({ asset, txLog })
282
+ const pendingStakingSent = getPendingStakingSent({ asset, txLog })
283
+ const unconfirmedSent = getUnconfirmedSentBalance({ asset, txLog }).add(pendingStakingSent)
262
284
 
263
285
  const staked = getStaked({ asset, accountState })
264
286
  const staking = getStaking({ asset, accountState })
@@ -299,7 +321,7 @@ export const getBalancesFactory = ({ monitorType, useAbsoluteBalance, rpcBalance
299
321
  balance: getBalanceFromTxLog({ txLog, asset }),
300
322
  txLog,
301
323
  unconfirmedReceived,
302
- })
324
+ }).sub(pendingStakingSent)
303
325
  }
304
326
  }
305
327
 
@@ -150,6 +150,9 @@ export const createEthereumHooks = ({
150
150
  // deadlines. Unknown legacy owners cannot supply failed fields on restore.
151
151
  // Preserve only non-service host metadata when changing snapshot owners.
152
152
  for (const name of new Set([...stakingAssetNames, ...Object.keys(owners)])) {
153
+ // An ownerless legacy snapshot is only replaced once a read succeeds;
154
+ // keep it rather than zeroing staked balances that were never re-read.
155
+ if (!owners[name] && !patches[name]) continue
153
156
  if (owners[name]?.address !== address || owners[name]?.network !== assetName) {
154
157
  staking[name] = Object.fromEntries(
155
158
  Object.entries(staking[name] || {}).filter(([key]) => !STAKING_SNAPSHOT_FIELDS.has(key))
@@ -187,6 +187,11 @@ export const simulateTransactionsApi = async ({
187
187
  headers,
188
188
  })
189
189
  if (!response) {
190
+ // The service could not be reached (network error, timeout, non-2xx), so
191
+ // there is no verdict on these transactions. Callers that must tell an
192
+ // outage apart from a failed simulation check this flag.
193
+ // eslint-disable-next-line @exodus/hydra/no-param-reassign-prop-only
194
+ simulationResult.metadata.simulationUnavailable = true
190
195
  return {
191
196
  kind: 'error',
192
197
  error: SimulationErrorMessages.APICallFailed,
@@ -223,6 +223,18 @@ export async function simulateUndelegateTransactions({
223
223
  transactions,
224
224
  })
225
225
 
226
+ // An unreachable simulation service must not block unstaking: we have no
227
+ // verdict, so neither check below can tell us anything about the txs.
228
+ // `simulationUnavailable` is set only when the request to the service
229
+ // failed; a simulation that ran never carries it.
230
+ if (simulationResponse?.metadata?.simulationUnavailable === true) {
231
+ console.warn(
232
+ 'Simulation for ETH undelegate is unavailable, proceeding without it',
233
+ simulationResponse?.metadata?.humanReadableError
234
+ )
235
+ return
236
+ }
237
+
226
238
  if (simulationResponse?.warnings?.length || simulationResponse?.metadata?.humanReadableError) {
227
239
  if (revertOnSimulationError) {
228
240
  const err = new Error('StakingEthUndelegateSimulationError')
@@ -1,6 +1,7 @@
1
1
  import NumberUnit from '@exodus/currency'
2
2
  import { getMethodIdFromEthTx, isPendingTxInLog, parseUnsignedTx } from '@exodus/ethereum-lib'
3
3
  import assetsList, { asset as ethereum } from '@exodus/ethereum-meta'
4
+ import { bufferToHex } from '@exodus/ethereumjs/util'
4
5
  import { Tx } from '@exodus/models'
5
6
  import assert from 'minimalistic-assert'
6
7
 
@@ -170,9 +171,10 @@ export async function maticDelegateOptimisticSideEffectTxLogs({
170
171
  feeAmount,
171
172
  feeCoinName: asset.feeAsset.name,
172
173
  selfSend: false,
173
- to: MaticStakingApi.EVERSTAKE_VALIDATOR_CONTRACT_ADDR,
174
+ to: STAKING_MANAGER_CONTRACT,
174
175
  txId: delegateTxId,
175
176
  data: {
177
+ data: bufferToHex(transactionData),
176
178
  gasLimit: estimatedDelegateGasLimit,
177
179
  nonce,
178
180
  tipGasPrice: tipGasPrice ? tipGasPrice.toBaseString() : undefined,
@@ -18,8 +18,8 @@ export default function checkPendingTransactions({
18
18
  delete recentPendingTransactions[txId]
19
19
 
20
20
  // check if this TX replaces another pending TX
21
- const replacedTx =
22
- pendingTransactionsGroupedByAddressAndNonce[getSenderNonceKey(tx, ourWalletAddress)]
21
+ const senderNonceKey = getSenderNonceKey(tx, ourWalletAddress)
22
+ const replacedTx = senderNonceKey && pendingTransactionsGroupedByAddressAndNonce[senderNonceKey]
23
23
  if (replacedTx && tx.hash !== replacedTx.tx.txId) {
24
24
  // if a pending TX with lower fees comes from the server, don't add it
25
25
  if (
@@ -1,3 +1,11 @@
1
+ const HEX_PREFIX = '0x'
2
+
3
+ // Clarity sends nonces as decimal strings; Magnifier sends 0x-prefixed hex quantities.
4
+ const parseServerTxNonce = (nonce) =>
5
+ typeof nonce === 'string' && nonce.startsWith(HEX_PREFIX)
6
+ ? parseInt(nonce, 16)
7
+ : parseInt(nonce, 10)
8
+
1
9
  export default function getSenderNonceKey(tx, ourWalletAddress) {
2
10
  if (Array.isArray(tx.from)) {
3
11
  // Tx class. we don't define the 'from' address if our wallet was the sender.
@@ -5,7 +13,8 @@ export default function getSenderNonceKey(tx, ourWalletAddress) {
5
13
  return `${from}:${tx.data.nonce}`
6
14
  }
7
15
 
8
- // ethereum tx json object from magnifier
9
- const txnonce = parseInt(tx.nonce, 16)
10
- return `${tx.from}:${txnonce}`
16
+ const nonce = parseServerTxNonce(tx.nonce)
17
+ if (!Number.isSafeInteger(nonce)) return null
18
+
19
+ return `${tx.from}:${nonce}`
11
20
  }