@exodus/ethereum-api 7.0.18 → 7.2.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/package.json +10 -6
- package/src/allowance/constants.js +3 -2
- package/src/allowance/index.js +90 -84
- package/src/ens/addresses.js +3 -1
- package/src/eth-like-util.js +6 -5
- package/src/etherscan/account.js +2 -2
- package/src/etherscan/index.js +15 -35
- package/src/etherscan/proxy.js +3 -3
- package/src/etherscan/request.js +1 -1
- package/src/etherscan/ws.js +2 -2
- package/src/exodus-eth-server/api-coin-nodes.js +4 -3
- package/src/exodus-eth-server/api.js +6 -4
- package/src/exodus-eth-server/clarity.js +10 -3
- package/src/exodus-eth-server/ws.js +13 -1
- package/src/fee-monitor/ethereumarbnova.js +4 -1
- package/src/fee-monitor/ethereumarbone.js +4 -1
- package/src/fee-monitor/ethereumsepolia.js +18 -0
- package/src/fee-monitor/index.js +1 -0
- package/src/fee-monitor/optimism.js +4 -1
- package/src/gas-estimation.js +3 -1
- package/src/get-balances.js +2 -1
- package/src/simulate-tx/simulate-eth-tx.js +4 -3
- package/src/staking/ethereum/api.js +8 -8
- package/src/staking/ethereum/service.js +33 -35
- package/src/staking/ethereum/staking-utils.js +3 -5
- package/src/staking/fantom-staking.js +2 -2
- package/src/staking/matic/api.js +2 -3
- package/src/staking/matic/service.js +34 -42
- package/src/staking/staking-provider-client.js +3 -3
- package/src/tx-log/clarity-monitor.js +14 -9
- package/src/tx-log/clarity-utils/get-derive-data-needed-for-tick.js +1 -1
- package/src/tx-log/clarity-utils/get-log-items-from-server-tx.js +4 -1
- package/src/tx-log/ethereum-monitor.js +8 -11
- package/src/tx-log/ethereum-no-history-monitor.js +13 -11
- package/src/tx-log/monitor-utils/check-pending-transactions.js +2 -0
- package/src/tx-log/monitor-utils/exclude-unchanged-token-balances.js +2 -3
- package/src/tx-log/monitor-utils/get-derive-data-needed-for-tick.js +1 -1
- package/src/tx-log/monitor-utils/get-derive-transactions-to-check.js +2 -1
- package/src/tx-log/monitor-utils/get-log-items-from-server-tx.js +5 -2
- package/src/tx-log/ws-updates.js +1 -1
- package/src/websocket/index.js +5 -4
- package/LICENSE.md +0 -0
- package/src/tx-log/monitor-utils/types.js +0 -0
|
@@ -49,11 +49,8 @@ export class EthereumMonitor extends BaseMonitor {
|
|
|
49
49
|
async deriveData({ assetSource, tokens }) {
|
|
50
50
|
const { asset: assetName, walletAccount } = assetSource
|
|
51
51
|
|
|
52
|
-
const {
|
|
53
|
-
|
|
54
|
-
currentAccountState,
|
|
55
|
-
minimumConfirmations,
|
|
56
|
-
} = await this.deriveDataNeededForTick({ assetName, walletAccount })
|
|
52
|
+
const { ourWalletAddress, currentAccountState, minimumConfirmations } =
|
|
53
|
+
await this.deriveDataNeededForTick({ assetName, walletAccount })
|
|
57
54
|
const transactionsToCheck = await this.deriveTransactionsToCheck({
|
|
58
55
|
assetName,
|
|
59
56
|
walletAccount,
|
|
@@ -71,10 +68,8 @@ export class EthereumMonitor extends BaseMonitor {
|
|
|
71
68
|
|
|
72
69
|
// eslint-disable-next-line no-undef
|
|
73
70
|
async checkPendingTransactions(params) {
|
|
74
|
-
const {
|
|
75
|
-
|
|
76
|
-
pendingTransactionsGroupedByAddressAndNonce,
|
|
77
|
-
} = checkPendingTransactions(params)
|
|
71
|
+
const { pendingTransactionsToCheck, pendingTransactionsGroupedByAddressAndNonce } =
|
|
72
|
+
checkPendingTransactions(params)
|
|
78
73
|
const txsToRemove = []
|
|
79
74
|
const {
|
|
80
75
|
assetSource: { walletAccount },
|
|
@@ -220,6 +215,7 @@ export class EthereumMonitor extends BaseMonitor {
|
|
|
220
215
|
const balance = new BN(hex, 'hex').toString()
|
|
221
216
|
newAccountState.balance = asset.currency.baseUnit(balance)
|
|
222
217
|
}
|
|
218
|
+
|
|
223
219
|
const tokenBalancePairs = await Promise.all(
|
|
224
220
|
tokens
|
|
225
221
|
.filter((token) => isRpcBalanceAsset(token) && token.contract.address)
|
|
@@ -245,6 +241,7 @@ export class EthereumMonitor extends BaseMonitor {
|
|
|
245
241
|
useCache: true,
|
|
246
242
|
})
|
|
247
243
|
}
|
|
244
|
+
|
|
248
245
|
return addressesByAccount
|
|
249
246
|
}
|
|
250
247
|
|
|
@@ -265,10 +262,10 @@ export class EthereumMonitor extends BaseMonitor {
|
|
|
265
262
|
if (!tokensByAddress.has(addr)) {
|
|
266
263
|
acc.add(addr)
|
|
267
264
|
}
|
|
268
|
-
}
|
|
265
|
+
})
|
|
269
266
|
return acc
|
|
270
267
|
}, new Set())
|
|
271
|
-
return
|
|
268
|
+
return [...set]
|
|
272
269
|
}
|
|
273
270
|
|
|
274
271
|
async beforeStart() {
|
|
@@ -33,6 +33,7 @@ export class EthereumNoHistoryMonitor extends BaseMonitor {
|
|
|
33
33
|
this.server.setURI(DEFAULT_SERVER_URLS[this.asset.name])
|
|
34
34
|
return
|
|
35
35
|
}
|
|
36
|
+
|
|
36
37
|
if (config.server === this.server.uri) return
|
|
37
38
|
this.server.setURI(config.server)
|
|
38
39
|
}
|
|
@@ -45,10 +46,12 @@ export class EthereumNoHistoryMonitor extends BaseMonitor {
|
|
|
45
46
|
const request = this.server.balanceOfRequest(ourWalletAddress, token.contract.address)
|
|
46
47
|
batch[token.name] = request
|
|
47
48
|
}
|
|
49
|
+
|
|
48
50
|
const pairs = Object.entries(batch)
|
|
49
|
-
if (
|
|
51
|
+
if (pairs.length === 0) {
|
|
50
52
|
return {}
|
|
51
53
|
}
|
|
54
|
+
|
|
52
55
|
const requests = pairs.map((pair) => pair[1])
|
|
53
56
|
const responses = await this.server.sendBatchRequest(requests)
|
|
54
57
|
const entries = pairs.map((pair, idx) => {
|
|
@@ -74,7 +77,7 @@ export class EthereumNoHistoryMonitor extends BaseMonitor {
|
|
|
74
77
|
const value = token.currency.baseUnit(pair[1] || 0)
|
|
75
78
|
return [token.name, value]
|
|
76
79
|
})
|
|
77
|
-
.filter(
|
|
80
|
+
.filter(Boolean)
|
|
78
81
|
|
|
79
82
|
const tokenBalances = excludeUnchangedTokenBalances(currentTokenBalances, tokenBalanceEntries)
|
|
80
83
|
if (!isEmpty(tokenBalances)) newAccountState.tokenBalances = tokenBalances
|
|
@@ -89,15 +92,13 @@ export class EthereumNoHistoryMonitor extends BaseMonitor {
|
|
|
89
92
|
walletAccount,
|
|
90
93
|
})
|
|
91
94
|
|
|
92
|
-
const {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
ourWalletAddress,
|
|
100
|
-
})
|
|
95
|
+
const { pendingTransactionsGroupedByAddressAndNonce, pendingTransactionsToCheck } =
|
|
96
|
+
await this.deriveTransactionsToCheck({
|
|
97
|
+
assetName,
|
|
98
|
+
walletAccount,
|
|
99
|
+
tokens,
|
|
100
|
+
ourWalletAddress,
|
|
101
|
+
})
|
|
101
102
|
|
|
102
103
|
const pendingTransactions = unionBy(
|
|
103
104
|
Object.values(pendingTransactionsGroupedByAddressAndNonce),
|
|
@@ -114,6 +115,7 @@ export class EthereumNoHistoryMonitor extends BaseMonitor {
|
|
|
114
115
|
const request = this.server.getTransactionByHashRequest(tx.txId)
|
|
115
116
|
batch.push(request)
|
|
116
117
|
}
|
|
118
|
+
|
|
117
119
|
const responses = await this.server.sendBatchRequest(batch)
|
|
118
120
|
const txIds = transactions.map(({ tx }) => tx.txId)
|
|
119
121
|
return zipObject(txIds, responses)
|
|
@@ -9,6 +9,7 @@ export default function checkPendingTransactions({
|
|
|
9
9
|
asset,
|
|
10
10
|
}) {
|
|
11
11
|
for (const tx of txlist) {
|
|
12
|
+
// eslint-disable-next-line @exodus/mutable/no-param-reassign-prop-only
|
|
12
13
|
delete pendingTransactionsToCheck[tx.txId || tx.hash] // Found this transaction, do not mark it as dropped
|
|
13
14
|
|
|
14
15
|
// check if this TX replaces another pending TX
|
|
@@ -23,6 +24,7 @@ export default function checkPendingTransactions({
|
|
|
23
24
|
) {
|
|
24
25
|
continue
|
|
25
26
|
}
|
|
27
|
+
|
|
26
28
|
replacedTx.replaced = true
|
|
27
29
|
}
|
|
28
30
|
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
export function excludeUnchangedTokenBalances(currentTokenBalances, newTokenBalancePairs) {
|
|
2
2
|
const newTokenBalances = Object.fromEntries(newTokenBalancePairs)
|
|
3
3
|
|
|
4
|
-
|
|
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(
|
|
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 && {
|
|
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
|
|
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
|
package/src/tx-log/ws-updates.js
CHANGED
|
@@ -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(
|
|
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
|
|
package/src/websocket/index.js
CHANGED
|
@@ -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
|
-
|
|
15
|
-
|
|
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
|