@exodus/ethereum-lib 2.19.3 → 2.20.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 +6 -2
- package/src/fee-data/avalanchec.js +1 -0
- package/src/fee-data/ethereum.js +1 -0
- package/src/fee-data/polygon.js +1 -0
- package/src/monitor-utils/get-all-log-items-by-asset.js +1 -4
- package/src/monitor-utils/get-derive-transactions-to-check.js +16 -12
- package/src/monitor-utils/get-log-items-from-server-tx.js +35 -30
package/package.json
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/ethereum-lib",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.20.0",
|
|
4
4
|
"description": "Ethereum Library",
|
|
5
5
|
"main": "src/index.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"src",
|
|
8
|
+
"!src/**/__tests__"
|
|
9
|
+
],
|
|
6
10
|
"author": "Exodus Movement, Inc.",
|
|
7
11
|
"license": "UNLICENSED",
|
|
8
12
|
"homepage": "https://github.com/ExodusMovement/ethereum#readme",
|
|
@@ -24,5 +28,5 @@
|
|
|
24
28
|
"peerDependencies": {
|
|
25
29
|
"@exodus/assets": "8.0.x"
|
|
26
30
|
},
|
|
27
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "57fae619663ea5193c733bd089c9031447f0d025"
|
|
28
32
|
}
|
package/src/fee-data/ethereum.js
CHANGED
package/src/fee-data/polygon.js
CHANGED
|
@@ -12,10 +12,7 @@ export default function getAllLogItemsByAsset({
|
|
|
12
12
|
assets,
|
|
13
13
|
}) {
|
|
14
14
|
const allAssets = [asset, ...tokensByAddress.values()]
|
|
15
|
-
const logItemsByAsset = allAssets.
|
|
16
|
-
allItems[asset.name] = []
|
|
17
|
-
return allItems
|
|
18
|
-
}, {})
|
|
15
|
+
const logItemsByAsset = Object.fromEntries(allAssets.map((asset) => [asset.name, []]))
|
|
19
16
|
|
|
20
17
|
allTransactionsFromServer.forEach((serverTx) => {
|
|
21
18
|
const logItemsByAssetForServerTx = getLogItemsFromServerTx({
|
|
@@ -3,11 +3,13 @@ import getSenderNonceKey from './get-sender-nonce-key'
|
|
|
3
3
|
|
|
4
4
|
const UNCONFIRMED_TX_LIMIT = ms('5m')
|
|
5
5
|
|
|
6
|
+
const mapToObject = (map) => Object.fromEntries([...map.entries()]) // only for string keys
|
|
7
|
+
|
|
6
8
|
export default function getDeriveTransactionsToCheck({ getTxLog }) {
|
|
7
9
|
return async ({ assetName: _assetName, walletAccount, tokens, ourWalletAddress }) => {
|
|
8
|
-
const pendingTransactionsToCheck =
|
|
9
|
-
const pendingTransactionsGroupedByAddressAndNonce =
|
|
10
|
-
const simulatedTransactions =
|
|
10
|
+
const pendingTransactionsToCheck = new Map()
|
|
11
|
+
const pendingTransactionsGroupedByAddressAndNonce = new Map()
|
|
12
|
+
const simulatedTransactions = new Map()
|
|
11
13
|
const now = Date.now()
|
|
12
14
|
|
|
13
15
|
for (const assetName of [_assetName, ...tokens.map(({ name }) => name)]) {
|
|
@@ -15,33 +17,35 @@ export default function getDeriveTransactionsToCheck({ getTxLog }) {
|
|
|
15
17
|
for (const tx of txSet) {
|
|
16
18
|
// ERC20 sends have an entry in ETH and one in the ERC20 log so we just want the ETH one
|
|
17
19
|
if (
|
|
18
|
-
!pendingTransactionsToCheck
|
|
20
|
+
!pendingTransactionsToCheck.has(tx.txId) &&
|
|
19
21
|
tx.pending &&
|
|
20
22
|
now - tx.date.getTime() > UNCONFIRMED_TX_LIMIT
|
|
21
23
|
) {
|
|
22
|
-
pendingTransactionsToCheck
|
|
24
|
+
pendingTransactionsToCheck.set(tx.txId, { tx, assetName })
|
|
23
25
|
}
|
|
24
|
-
if (tx.meta.simulated) simulatedTransactions
|
|
26
|
+
if (tx.meta.simulated) simulatedTransactions.set(tx.txId, tx)
|
|
25
27
|
|
|
26
28
|
const senderNonceKey = getSenderNonceKey(tx, ourWalletAddress)
|
|
27
29
|
if (
|
|
28
30
|
tx.pending &&
|
|
29
|
-
!pendingTransactionsGroupedByAddressAndNonce
|
|
31
|
+
!pendingTransactionsGroupedByAddressAndNonce.has(senderNonceKey) &&
|
|
30
32
|
!tx.dropped
|
|
31
33
|
) {
|
|
32
|
-
pendingTransactionsGroupedByAddressAndNonce
|
|
34
|
+
pendingTransactionsGroupedByAddressAndNonce.set(senderNonceKey, {
|
|
33
35
|
tx,
|
|
34
36
|
replaced: false,
|
|
35
37
|
assetName,
|
|
36
|
-
}
|
|
38
|
+
})
|
|
37
39
|
}
|
|
38
40
|
}
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
return {
|
|
42
|
-
pendingTransactionsToCheck,
|
|
43
|
-
pendingTransactionsGroupedByAddressAndNonce
|
|
44
|
-
|
|
44
|
+
pendingTransactionsToCheck: mapToObject(pendingTransactionsToCheck),
|
|
45
|
+
pendingTransactionsGroupedByAddressAndNonce: mapToObject(
|
|
46
|
+
pendingTransactionsGroupedByAddressAndNonce
|
|
47
|
+
),
|
|
48
|
+
simulatedTransactions: mapToObject(simulatedTransactions),
|
|
45
49
|
}
|
|
46
50
|
}
|
|
47
51
|
}
|
|
@@ -37,7 +37,7 @@ export default function getLogItemsFromServerTx({
|
|
|
37
37
|
dropped: false,
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
const
|
|
40
|
+
const logItemsForServerTxEntries = []
|
|
41
41
|
|
|
42
42
|
{
|
|
43
43
|
const sendingTransferPresent = ethereumTransfers.some(({ from }) => from === ourWalletAddress)
|
|
@@ -51,28 +51,30 @@ export default function getLogItemsFromServerTx({
|
|
|
51
51
|
sendingTransferPresent,
|
|
52
52
|
receivingTransferPresent,
|
|
53
53
|
})
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
54
|
+
logItemsForServerTxEntries.push([
|
|
55
|
+
asset.name,
|
|
56
|
+
{
|
|
57
|
+
...logItemCommonProperties,
|
|
58
|
+
coinAmount,
|
|
59
|
+
coinName: asset.name,
|
|
60
|
+
data: {
|
|
61
|
+
data: serverTx.data || '0x',
|
|
62
|
+
nonce,
|
|
63
|
+
gasLimit,
|
|
64
|
+
},
|
|
65
|
+
from: ourWalletWasSender ? [] : [serverTx.from],
|
|
66
|
+
to: ourWalletWasSender ? toAddress : undefined,
|
|
67
|
+
selfSend,
|
|
68
|
+
tokens: getNamesOfTokensTransferredByServerTx({
|
|
69
|
+
asset,
|
|
70
|
+
tokensByAddress,
|
|
71
|
+
serverTx,
|
|
72
|
+
ourWalletAddress,
|
|
73
|
+
}),
|
|
62
74
|
},
|
|
63
|
-
|
|
64
|
-
to: ourWalletWasSender ? toAddress : undefined,
|
|
65
|
-
selfSend,
|
|
66
|
-
tokens: getNamesOfTokensTransferredByServerTx({
|
|
67
|
-
asset,
|
|
68
|
-
tokensByAddress,
|
|
69
|
-
serverTx,
|
|
70
|
-
ourWalletAddress,
|
|
71
|
-
}),
|
|
72
|
-
}
|
|
75
|
+
])
|
|
73
76
|
}
|
|
74
77
|
}
|
|
75
|
-
|
|
76
78
|
// handle erc20
|
|
77
79
|
Object.entries(tokenTransfersByTokenName).forEach(([tokenName, tokenTransfers]) => {
|
|
78
80
|
const sendingTransferPresent = tokenTransfers.some(({ from }) => from === ourWalletAddress)
|
|
@@ -103,18 +105,21 @@ export default function getLogItemsFromServerTx({
|
|
|
103
105
|
receivingTransferPresent,
|
|
104
106
|
})
|
|
105
107
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
108
|
+
logItemsForServerTxEntries.push([
|
|
109
|
+
tokenName,
|
|
110
|
+
{
|
|
111
|
+
...logItemCommonProperties,
|
|
112
|
+
coinAmount,
|
|
113
|
+
coinName: tokenName,
|
|
114
|
+
data: { nonce, gasLimit },
|
|
115
|
+
from: isConsideredSent ? [] : tokenFromAddresses,
|
|
116
|
+
to: isConsideredSent ? tokenTransferToAddress : undefined,
|
|
117
|
+
selfSend,
|
|
118
|
+
},
|
|
119
|
+
])
|
|
115
120
|
})
|
|
116
121
|
|
|
117
|
-
return
|
|
122
|
+
return Object.fromEntries(logItemsForServerTxEntries)
|
|
118
123
|
}
|
|
119
124
|
|
|
120
125
|
const tryFindExternalRecipient = (transfers, ourWalletAddress) =>
|