@exodus/ethereum-api 7.0.17 → 7.1.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.
Files changed (40) hide show
  1. package/package.json +3 -3
  2. package/src/allowance/constants.js +3 -2
  3. package/src/allowance/index.js +90 -84
  4. package/src/ens/addresses.js +3 -1
  5. package/src/eth-like-util.js +2 -2
  6. package/src/etherscan/account.js +2 -2
  7. package/src/etherscan/index.js +15 -35
  8. package/src/etherscan/proxy.js +3 -3
  9. package/src/etherscan/request.js +1 -1
  10. package/src/etherscan/ws.js +2 -2
  11. package/src/exodus-eth-server/api-coin-nodes.js +4 -3
  12. package/src/exodus-eth-server/api.js +6 -4
  13. package/src/exodus-eth-server/clarity.js +10 -3
  14. package/src/exodus-eth-server/ws.js +13 -1
  15. package/src/fee-monitor/ethereumarbnova.js +4 -1
  16. package/src/fee-monitor/ethereumarbone.js +4 -1
  17. package/src/fee-monitor/optimism.js +4 -1
  18. package/src/gas-estimation.js +3 -1
  19. package/src/get-balances.js +1 -0
  20. package/src/simulate-tx/simulate-eth-tx.js +4 -3
  21. package/src/staking/ethereum/api.js +8 -8
  22. package/src/staking/ethereum/service.js +31 -33
  23. package/src/staking/ethereum/staking-utils.js +3 -5
  24. package/src/staking/fantom-staking.js +2 -2
  25. package/src/staking/matic/api.js +2 -3
  26. package/src/staking/matic/service.js +32 -40
  27. package/src/tx-log/clarity-monitor.js +14 -9
  28. package/src/tx-log/clarity-utils/get-derive-data-needed-for-tick.js +1 -1
  29. package/src/tx-log/clarity-utils/get-log-items-from-server-tx.js +4 -1
  30. package/src/tx-log/ethereum-monitor.js +8 -11
  31. package/src/tx-log/ethereum-no-history-monitor.js +13 -11
  32. package/src/tx-log/monitor-utils/check-pending-transactions.js +2 -0
  33. package/src/tx-log/monitor-utils/exclude-unchanged-token-balances.js +2 -3
  34. package/src/tx-log/monitor-utils/get-derive-data-needed-for-tick.js +1 -1
  35. package/src/tx-log/monitor-utils/get-derive-transactions-to-check.js +2 -1
  36. package/src/tx-log/monitor-utils/get-log-items-from-server-tx.js +5 -2
  37. package/src/tx-log/ws-updates.js +1 -1
  38. package/src/websocket/index.js +5 -4
  39. package/LICENSE.md +0 -0
  40. package/src/tx-log/monitor-utils/types.js +0 -0
@@ -1,13 +1,12 @@
1
1
  export function excludeUnchangedTokenBalances(currentTokenBalances, newTokenBalancePairs) {
2
2
  const newTokenBalances = Object.fromEntries(newTokenBalancePairs)
3
3
 
4
- const tokenBalances = newTokenBalancePairs.reduce((tokenBalancesAcc, [token, balance]) => {
4
+ return newTokenBalancePairs.reduce((tokenBalancesAcc, [token, balance]) => {
5
5
  const currentBalance = currentTokenBalances[token]
6
6
  if (!newTokenBalances[token].isZero || (currentBalance && !currentBalance.isZero)) {
7
7
  tokenBalancesAcc[token] = balance
8
8
  }
9
+
9
10
  return tokenBalancesAcc
10
11
  }, {})
11
-
12
- return tokenBalances
13
12
  }
@@ -1,7 +1,7 @@
1
1
  // A super-selector that returns all the current data needed for a tick of the ETH monitor.
2
2
 
3
3
  export default function getDeriveDataNeededForTick(aci) {
4
- return async function({ assetName, walletAccount }) {
4
+ return async function ({ assetName, walletAccount }) {
5
5
  const receiveAddress = await aci.getReceiveAddress({ assetName, walletAccount, useCache: true })
6
6
  const currentAccountState = await aci.getAccountState({ assetName, walletAccount })
7
7
  const minimumConfirmations = await aci.getConfirmationsNumber({ assetName })
@@ -3,7 +3,7 @@ import getSenderNonceKey from './get-sender-nonce-key'
3
3
 
4
4
  export const UNCONFIRMED_TX_LIMIT = ms('5m')
5
5
 
6
- const mapToObject = (map) => Object.fromEntries([...map.entries()]) // only for string keys
6
+ const mapToObject = (map) => Object.fromEntries(map.entries()) // only for string keys
7
7
 
8
8
  export default function getDeriveTransactionsToCheck({ getTxLog }) {
9
9
  return async ({ assetName: _assetName, walletAccount, tokens, ourWalletAddress }) => {
@@ -23,6 +23,7 @@ export default function getDeriveTransactionsToCheck({ getTxLog }) {
23
23
  ) {
24
24
  pendingTransactionsToCheck.set(tx.txId, { tx, assetName })
25
25
  }
26
+
26
27
  if (tx.meta.simulated) simulatedTransactions.set(tx.txId, tx)
27
28
 
28
29
  const senderNonceKey = getSenderNonceKey(tx, ourWalletAddress)
@@ -28,7 +28,9 @@ export default function getLogItemsFromServerTx({
28
28
  const toAddress = tryFindExternalRecipient(ethereumTransfers, ourWalletAddress)
29
29
  const ourWalletWasSender = serverTx.from === ourWalletAddress
30
30
  const METHOD_ID_LENGTH = 10
31
- const methodId = serverTx.data && { methodId: serverTx.data.substring(0, METHOD_ID_LENGTH) }
31
+ const methodId = serverTx.data && {
32
+ methodId: serverTx.data.slice(0, Math.max(0, METHOD_ID_LENGTH)),
33
+ }
32
34
  const data = serverTx.data || '0x'
33
35
  const logItemCommonProperties = {
34
36
  confirmations,
@@ -83,6 +85,7 @@ export default function getLogItemsFromServerTx({
83
85
  ])
84
86
  }
85
87
  }
88
+
86
89
  // handle erc20
87
90
  Object.entries(tokenTransfersByTokenName).forEach(([tokenName, tokenTransfers]) => {
88
91
  const sendingTransferPresent = tokenTransfers.some(({ from }) => from === ourWalletAddress)
@@ -154,7 +157,7 @@ function isSelfSendTx({
154
157
  }
155
158
 
156
159
  function isNftTransfer({ serverTx, ourWalletAddress }) {
157
- if (!Array.isArray(serverTx.erc721) || serverTx.erc721.length < 1) return false
160
+ if (!Array.isArray(serverTx.erc721) || serverTx.erc721.length === 0) return false
158
161
 
159
162
  return serverTx.erc721.some(
160
163
  (transfer) => transfer.to === ourWalletAddress || transfer.from === ourWalletAddress
@@ -11,7 +11,7 @@ export function subscribeToWSNotifications({
11
11
  beforeStart = false,
12
12
  }) {
13
13
  Object.entries(addressesByWalletAccount).forEach(([walletAccount, addresses]) => {
14
- const address = String(Array.from(addresses)[0]).toLowerCase() // Only check m/0/0
14
+ const address = String([...addresses][0]).toLowerCase() // Only check m/0/0
15
15
  const mapKey = `${server.getURL()}:${address}` // different chains might have the same addresses
16
16
  if (subscribedToAddressNotificationsMap.has(mapKey)) return
17
17
 
@@ -11,10 +11,11 @@ if (typeof process !== 'undefined' && (process.type === 'renderer' || process.ty
11
11
  } else {
12
12
  module.exports = require('ws')
13
13
  }
14
- } else if (typeof WebSocket !== 'undefined') {
15
- // THIS IS FOR BE
16
- module.exports = globalThis.WebSocket
17
- } else {
14
+ // eslint-disable-next-line no-undef
15
+ } else if (typeof WebSocket === 'undefined') {
18
16
  // THIS IS FOR UNIT TESTING.
19
17
  module.exports = require('ws')
18
+ } else {
19
+ // THIS IS FOR BE
20
+ module.exports = globalThis.WebSocket
20
21
  }
package/LICENSE.md DELETED
File without changes
File without changes