@exodus/ethereum-api 8.18.2 → 8.19.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,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
+ ## [8.19.0](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.18.3...@exodus/ethereum-api@8.19.0) (2024-09-26)
7
+
8
+
9
+ ### Features
10
+
11
+ * allow enable and disable custom tokens/nfts per wallet ([#4014](https://github.com/ExodusMovement/assets/issues/4014)) ([9c9864d](https://github.com/ExodusMovement/assets/commit/9c9864d4bfae5b4711704ba3442f1e7dc8231795))
12
+ * enable evm fee monitor clarity/magnifier ([#3954](https://github.com/ExodusMovement/assets/issues/3954)) ([2f64696](https://github.com/ExodusMovement/assets/commit/2f646966889b44b67fafd4f86f51f95d084fa1e2))
13
+
14
+
15
+
16
+ ## [8.18.3](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.18.2...@exodus/ethereum-api@8.18.3) (2024-09-17)
17
+
18
+
19
+ ### Bug Fixes
20
+
21
+ * **staking:** ETH unstake event ([#3552](https://github.com/ExodusMovement/assets/issues/3552)) ([116fa18](https://github.com/ExodusMovement/assets/commit/116fa18dd2d29e549e0aae30e8e849203f013a75))
22
+
23
+
24
+
6
25
  ## [8.18.2](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.18.1...@exodus/ethereum-api@8.18.2) (2024-09-17)
7
26
 
8
27
  **Note:** Version bump only for package @exodus/ethereum-api
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/ethereum-api",
3
- "version": "8.18.2",
3
+ "version": "8.19.0",
4
4
  "description": "Ethereum Api",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -65,5 +65,5 @@
65
65
  "type": "git",
66
66
  "url": "git+https://github.com/ExodusMovement/assets.git"
67
67
  },
68
- "gitHead": "ddeb04e25e5cb7dda81cc453c292e3aa6bfa25a1"
68
+ "gitHead": "5ed11ccb5d6268dad10582ffd1df7aeae6993f09"
69
69
  }
@@ -45,7 +45,7 @@ export const createAssetFactory = ({
45
45
  confirmationsNumber,
46
46
  customBip44,
47
47
  customCreateGetKeyIdentifier,
48
- customTokens = true,
48
+ customTokens: defaultCustomTokens = true,
49
49
  erc20FuelBuffer,
50
50
  feeData,
51
51
  feeMonitorInterval,
@@ -55,7 +55,7 @@ export const createAssetFactory = ({
55
55
  l1GasOracleAddress, // l1 extra fee for base and optostakingConfiguration = {},
56
56
  monitorInterval,
57
57
  monitorType = 'magnifier',
58
- nfts = false,
58
+ nfts: defaultNfts = false,
59
59
  serverUrl,
60
60
  stakingConfiguration = {},
61
61
  useEip1191ChainIdChecksum = false,
@@ -80,13 +80,15 @@ export const createAssetFactory = ({
80
80
  config = {
81
81
  allowMetaMaskCompat: false,
82
82
  supportsStaking: false,
83
+ nfts: defaultNfts,
84
+ customTokens: defaultCustomTokens,
83
85
  },
84
86
  overrideCallback = ({ asset }) => asset,
85
87
  } = Object.create(null)
86
88
  ) => {
87
89
  const assets = connectAssetsList(assetsList)
88
90
 
89
- const { allowMetaMaskCompat, supportsStaking } = config
91
+ const { allowMetaMaskCompat, supportsStaking, nfts, customTokens } = config
90
92
 
91
93
  const asset = assets[base.name]
92
94
 
@@ -121,11 +123,16 @@ export const createAssetFactory = ({
121
123
 
122
124
  const addressHasHistory = addressHasHistoryFactory({ server })
123
125
 
124
- const feeMonitor = monitorType === 'no-history'
126
+ const isWebSocket = monitorType !== 'no-history'
127
+
128
+ const resolvedFeeMonitorInterval =
129
+ config.feeMonitorInterval ||
130
+ feeMonitorInterval ||
131
+ (isWebSocket ? null : DEFAULT_FEE_MONITOR_INTERVAL) // null means do not start the timer
125
132
 
126
133
  const createFeeMonitor = serverBasedFeeMonitorFactoryFactory({
127
134
  assetName: base.name,
128
- interval: config.feeMonitorInterval || feeMonitorInterval || DEFAULT_FEE_MONITOR_INTERVAL,
135
+ interval: resolvedFeeMonitorInterval,
129
136
  eip1559Enabled: feeData.eip1559Enabled, // this is not updated via remote config. Should it be?
130
137
  server,
131
138
  })
@@ -133,7 +140,7 @@ export const createAssetFactory = ({
133
140
  const features = {
134
141
  accountState: true,
135
142
  customTokens,
136
- feeMonitor,
143
+ feeMonitor: true,
137
144
  feesApi: true,
138
145
  isMaxFeeAsset,
139
146
  isTestnet,
@@ -1,5 +1,4 @@
1
1
  import { FeeMonitor } from '@exodus/asset-lib'
2
- import { DEFAULT_FEE_MONITOR_INTERVAL } from '@exodus/ethereum-lib'
3
2
  import assert from 'minimalistic-assert'
4
3
 
5
4
  import { fromHexToString } from './number-utils.js'
@@ -20,7 +19,7 @@ import { fromHexToString } from './number-utils.js'
20
19
 
21
20
  export const serverBasedFeeMonitorFactoryFactory = ({
22
21
  assetName,
23
- interval = DEFAULT_FEE_MONITOR_INTERVAL,
22
+ interval,
24
23
  eip1559Enabled,
25
24
  server,
26
25
  }) => {
@@ -83,14 +83,7 @@ export function createEthereumStakingService({
83
83
  amount: inactiveAmountToUnstake,
84
84
  })
85
85
 
86
- let feeData
87
- try {
88
- // could revert and break the whole fee calculation
89
- feeData = await estimateTxFee(delegatorAddress, to, null, data)
90
- } catch {
91
- console.warn('ETH unstake pending estimation reverted')
92
- return Object.create(null)
93
- }
86
+ const feeData = await estimateTxFee(delegatorAddress, to, null, data)
94
87
 
95
88
  return { to, txData: data, ...feeData }
96
89
  }
@@ -98,7 +91,10 @@ export function createEthereumStakingService({
98
91
  async function getUndelegateData({ delegatorAddress, resquestedAmount, pendingAmount }) {
99
92
  const canUnstake = resquestedAmount.gt(pendingAmount)
100
93
 
101
- if (!canUnstake) return Object.create(null)
94
+ if (!canUnstake) {
95
+ console.warn('UnstakePending covered requested unstake. Nothing to unstake from validator')
96
+ return Object.create(null)
97
+ }
102
98
 
103
99
  const activeAmountToUnstake = resquestedAmount.sub(pendingAmount)
104
100
  const { to, data } = await staking.unstake({
@@ -124,12 +120,24 @@ export function createEthereumStakingService({
124
120
  const delegatorAddress = address.toLowerCase()
125
121
  const pendingAmount = await staking.pendingBalanceOf(delegatorAddress)
126
122
 
127
- const { fee: undelegatePendingFee = asset.currency.ZERO } = await getUndelegatePendingData({
128
- delegatorAddress,
129
- resquestedAmount,
130
- pendingAmount,
131
- minAmount,
132
- })
123
+ let undelegatePendingFee = asset.currency.ZERO
124
+
125
+ if (pendingAmount.isPositive) {
126
+ try {
127
+ // try to estimate unstakePending
128
+ const { fee } = await getUndelegatePendingData({
129
+ delegatorAddress,
130
+ resquestedAmount,
131
+ pendingAmount,
132
+ minAmount,
133
+ })
134
+ undelegatePendingFee = fee
135
+ } catch (err) {
136
+ // useful to debug fee calculation
137
+ console.warn('ETH unstake pending estimation failed, continuing with unstake', err)
138
+ }
139
+ }
140
+
133
141
  const { fee: undelegateFee = asset.currency.ZERO } = await getUndelegateData({
134
142
  delegatorAddress,
135
143
  resquestedAmount,
@@ -173,6 +181,7 @@ export function createEthereumStakingService({
173
181
  txId = await prepareAndSendTx({
174
182
  asset,
175
183
  walletAccount,
184
+ waitForConfirmation: true, // wait for tx confirmation in the client
176
185
  ...undelegatePendingData,
177
186
  })
178
187
  }
@@ -184,16 +193,16 @@ export function createEthereumStakingService({
184
193
  pendingAmount,
185
194
  })
186
195
 
187
- if (!undelegateData) return txId
188
-
189
- txId = await prepareAndSendTx({
190
- asset,
191
- walletAccount,
192
- ...undelegateData,
193
- })
196
+ if (undelegateData.fee) {
197
+ txId = await prepareAndSendTx({
198
+ asset,
199
+ walletAccount,
200
+ ...undelegateData,
201
+ })
202
+ }
194
203
 
195
204
  // Testnet assets do not support delegations tracking
196
- if (asset.name === 'ethereum')
205
+ if (txId && asset.name === 'ethereum')
197
206
  await stakingProvider.notifyUnstaking({
198
207
  txId,
199
208
  asset: asset.name,
@@ -297,9 +306,17 @@ export function createEthereumStakingService({
297
306
  }
298
307
 
299
308
  async function prepareAndSendTx(
300
- { asset, walletAccount, to, amount, txData: txInput, gasPrice, gasLimit, fee } = Object.create(
301
- null
302
- )
309
+ {
310
+ asset,
311
+ walletAccount,
312
+ to,
313
+ amount,
314
+ txData: txInput,
315
+ gasPrice,
316
+ gasLimit,
317
+ fee,
318
+ waitForConfirmation = false,
319
+ } = Object.create(null)
303
320
  ) {
304
321
  const sendTxArgs = {
305
322
  asset,
@@ -322,6 +339,7 @@ export function createEthereumStakingService({
322
339
  gasLimit,
323
340
  feeAmount: fee,
324
341
  },
342
+ waitForConfirmation,
325
343
  }
326
344
 
327
345
  console.log('sending staking tx:', sendTxArgs)