@exodus/ethereum-api 8.9.3 → 8.10.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 CHANGED
@@ -3,6 +3,24 @@
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.10.0](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.9.4...@exodus/ethereum-api@8.10.0) (2024-07-16)
7
+
8
+
9
+ ### Features
10
+
11
+ * expose params to overrideCallback for transaction monitors ([#2790](https://github.com/ExodusMovement/assets/issues/2790)) ([66b85a6](https://github.com/ExodusMovement/assets/commit/66b85a61304bcc1e7b258762b6754243ac6aca90))
12
+
13
+
14
+
15
+ ## [8.9.4](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.9.3...@exodus/ethereum-api@8.9.4) (2024-07-09)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * **ethereum:** matic staking tx processing ([#2771](https://github.com/ExodusMovement/assets/issues/2771)) ([4caee9f](https://github.com/ExodusMovement/assets/commit/4caee9feb13d0c30d2f995abe2a974838893150d))
21
+
22
+
23
+
6
24
  ## [8.9.3](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.9.2...@exodus/ethereum-api@8.9.3) (2024-07-09)
7
25
 
8
26
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/ethereum-api",
3
- "version": "8.9.3",
3
+ "version": "8.10.0",
4
4
  "description": "Ethereum Api",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -66,5 +66,5 @@
66
66
  "type": "git",
67
67
  "url": "git+https://github.com/ExodusMovement/assets.git"
68
68
  },
69
- "gitHead": "719f0e01b420fdaa1722cc8b9df5c2d80763349a"
69
+ "gitHead": "00b2058d9dd0ed2c596a040a9df43a6ce0d77945"
70
70
  }
@@ -108,7 +108,10 @@ export const createAssetFactory = ({
108
108
  encodePublic: encodePublicFactory({ chainId, useEip1191ChainIdChecksum }),
109
109
  }
110
110
 
111
- const getBalances = getBalancesFactory({ monitorType })
111
+ const getBalances = getBalancesFactory({
112
+ monitorType,
113
+ config,
114
+ })
112
115
 
113
116
  const { createToken, getTokens } = createTokenFactory(
114
117
  { address, bip44, keys, getBalances },
@@ -262,6 +265,11 @@ export const createAssetFactory = ({
262
265
  ...(fuelThreshold && { fuelThreshold: asset.currency.defaultUnit(fuelThreshold) }),
263
266
  getEffectiveGasPrice,
264
267
  }
265
- return overrideCallback({ asset: fullAsset })
268
+ return overrideCallback({
269
+ asset: fullAsset,
270
+ stakingConfiguration,
271
+ assetClientInterface,
272
+ monitorInterval,
273
+ })
266
274
  }
267
275
  }
@@ -64,7 +64,9 @@ const getSpendable = ({ asset, balance, txLog, unconfirmedReceived }) => {
64
64
  * @param accountState the account state when the balance is loaded from RPC
65
65
  * @returns {{balance}|null} an object with the balance or null if the balance is unknown
66
66
  */
67
- export const getBalancesFactory = ({ monitorType }) => {
67
+ export const getBalancesFactory = ({ monitorType, config = Object.create(null) }) => {
68
+ const { useAccountStateBalanceOnly } = config
69
+
68
70
  assert(monitorType, 'monitorType is required')
69
71
  return ({ asset, txLog, accountState }) => {
70
72
  const unconfirmedReceived = getUnconfirmedReceivedBalance({ asset, txLog })
@@ -78,7 +80,7 @@ export const getBalancesFactory = ({ monitorType }) => {
78
80
  let spendable
79
81
 
80
82
  // Balance from accountState is considered total b/c is fetched from rpc
81
- if (isRpcBalanceAsset(asset) || monitorType === 'no-history') {
83
+ if (useAccountStateBalanceOnly || isRpcBalanceAsset(asset) || monitorType === 'no-history') {
82
84
  total = getBalanceFromAccountState({ asset, accountState }).sub(unconfirmedSent)
83
85
  spendable = total.sub(staked).sub(unstaking).sub(unstaked).sub(unconfirmedReceived)
84
86
  } else {
@@ -160,7 +160,7 @@ export class ClarityMonitor extends BaseMonitor {
160
160
  await this.removeFromTxLog(txsToRemove)
161
161
  await this.updateTxLogByAsset({ logItemsByAsset, walletAccount, refresh })
162
162
  if (refresh || hasNewTxs) {
163
- const unknownTokenAddresses = this._getUnknownTokenAddresses({
163
+ const unknownTokenAddresses = this.getUnknownTokenAddresses({
164
164
  transactions: allTxs,
165
165
  tokensByAddress,
166
166
  })
@@ -258,7 +258,7 @@ export class ClarityMonitor extends BaseMonitor {
258
258
  return Object.fromEntries(entries)
259
259
  }
260
260
 
261
- _getUnknownTokenAddresses({ transactions, tokensByAddress }) {
261
+ getUnknownTokenAddresses({ transactions, tokensByAddress }) {
262
262
  const set = transactions.reduce((acc, txn) => {
263
263
  const transfers = filterEffects(txn.effects, 'erc20') || []
264
264
  transfers.forEach((transfer) => {
@@ -188,7 +188,7 @@ export class EthereumMonitor extends BaseMonitor {
188
188
  await this.updateTxLogByAsset({ logItemsByAsset, walletAccount, refresh })
189
189
 
190
190
  if (refresh || hasNewIndex) {
191
- const unknownTokenAddresses = this._getUnknownTokenAddresses({
191
+ const unknownTokenAddresses = this.getUnknownTokenAddresses({
192
192
  transactions: allTransactionsFromServer,
193
193
  tokensByAddress,
194
194
  })
@@ -264,7 +264,7 @@ export class EthereumMonitor extends BaseMonitor {
264
264
  })
265
265
  }
266
266
 
267
- _getUnknownTokenAddresses({ transactions, tokensByAddress }) {
267
+ getUnknownTokenAddresses({ transactions, tokensByAddress }) {
268
268
  const set = transactions.reduce((acc, txn) => {
269
269
  const transfers = txn.erc20 || []
270
270
  transfers.forEach((transfer) => {
@@ -4,13 +4,11 @@ import {
4
4
  isEthereumUndelegate,
5
5
  isEthereumUndelegatePending,
6
6
  } from '../staking/ethereum/staking-utils'
7
-
8
7
  import { isPolygonClaimUndelegate, isPolygonDelegate, isPolygonUndelegate } from '../staking/matic'
9
-
10
8
  import {
11
- decodePolygonStakingTxInputAmount,
12
- decodeEthLikeStakingTxInputAmount,
13
9
  calculateRewardsFromStakeTx,
10
+ decodeEthLikeStakingTxInputAmount,
11
+ decodePolygonStakingTxInputAmount,
14
12
  } from './utils.js'
15
13
 
16
14
  const getEthereumStakingTxData = ({ tx, currency }) => {
@@ -53,7 +51,11 @@ const getEthereumStakingTxData = ({ tx, currency }) => {
53
51
  }
54
52
 
55
53
  const getPolygonStakingTxData = ({ tx, currency }) => {
56
- if (['delegate', 'undelegate', 'claimUndelegate'].some((stakeTx) => tx.data?.[stakeTx])) return
54
+ if (
55
+ ['delegate', 'undelegate', 'claimUndelegate'].some((stakeTx) => tx.data?.[stakeTx]) &&
56
+ tx.coinAmount.isZero
57
+ )
58
+ return
57
59
 
58
60
  const txAmount = tx.coinAmount.toDefaultString()
59
61
 
@@ -1,7 +1,8 @@
1
- import { EthereumStaking, isEthereumStakingTx, MaticStakingApi } from '../staking'
2
1
  import { asset as ethereum } from '@exodus/ethereum-meta'
3
2
  import { asset as ethereumholesky } from '@exodus/ethereumholesky-meta'
4
3
 
4
+ import { EthereumStaking, isEthereumStakingTx, MaticStakingApi } from '../staking'
5
+
5
6
  const polygonStakingApi = new MaticStakingApi()
6
7
  const ethereumStakingApi = new EthereumStaking(ethereum)
7
8
  const ethereumHoleskyStakingApi = new EthereumStaking(ethereumholesky)
@@ -35,7 +36,7 @@ export const calculateRewardsFromStakeTx = ({ tx, currency }) => {
35
36
  if (stakeTxContainsReward) {
36
37
  const txAmount = stakedAmount.sub(tx.coinAmount.abs()).abs()
37
38
  // eslint-disable-next-line @exodus/mutable/no-param-reassign-prop-only -- TODO: Fix this the next time the file is edited.
38
- return txAmount.toBaseString()
39
+ return txAmount.toDefaultString()
39
40
  }
40
41
  }
41
42