@exodus/ethereum-api 8.25.2 → 8.26.1
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 +22 -0
- package/package.json +2 -2
- package/src/get-balances.js +11 -7
- package/src/tx-log/clarity-monitor.js +2 -18
- package/src/tx-log/clarity-utils/get-log-items-from-server-tx.js +13 -0
- package/src/tx-log/clarity-utils/index.js +0 -1
- package/src/tx-log/monitor-utils/get-log-items-from-server-tx.js +13 -0
- package/src/tx-log/clarity-utils/get-derive-data-needed-for-tick.js +0 -12
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
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.26.1](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.26.0...@exodus/ethereum-api@8.26.1) (2025-01-22)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
* fix: remove additional derive data needed for tick (#4878)
|
|
13
|
+
|
|
14
|
+
* fix: unstaked, unstaking balances (#4874)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## [8.26.0](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.25.2...@exodus/ethereum-api@8.26.0) (2025-01-15)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Features
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
* feat: ETH internal send and sent in txLog (#4858)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
6
28
|
## [8.25.2](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.25.1...@exodus/ethereum-api@8.25.2) (2025-01-10)
|
|
7
29
|
|
|
8
30
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/ethereum-api",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.26.1",
|
|
4
4
|
"description": "Transaction monitors, fee monitors, RPC with the blockchain node, and other networking code for Ethereum and EVM-based blockchains",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"type": "git",
|
|
65
65
|
"url": "git+https://github.com/ExodusMovement/assets.git"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "c02457a2ad2142debd460a2b2263e84a2d8748a8"
|
|
68
68
|
}
|
package/src/get-balances.js
CHANGED
|
@@ -17,14 +17,13 @@ const getStaking = ({ accountState, asset }) => {
|
|
|
17
17
|
)
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
const
|
|
21
|
-
return accountState?.staking?.[asset.name]?.undelegatedBalance || asset.currency.ZERO
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const getUnstaked = ({ accountState, asset }) => {
|
|
20
|
+
const getUnclaimedUndelegatedBalance = ({ accountState, asset }) => {
|
|
25
21
|
return accountState?.staking?.[asset.name]?.unclaimedUndelegatedBalance || asset.currency.ZERO
|
|
26
22
|
}
|
|
27
23
|
|
|
24
|
+
const getCanClaimUndelegatedBalance = ({ accountState, asset }) =>
|
|
25
|
+
accountState?.staking?.[asset.name]?.canClaimUndelegatedBalance || false
|
|
26
|
+
|
|
28
27
|
/**
|
|
29
28
|
* Calculates amount received in staking txs from txLog
|
|
30
29
|
* Staking txs are counted based in the amount received in the tx (tx.coinAmount)
|
|
@@ -84,8 +83,13 @@ export const getBalancesFactory = ({ monitorType, config = Object.create(null) }
|
|
|
84
83
|
|
|
85
84
|
const staked = getStaked({ asset, accountState })
|
|
86
85
|
const staking = getStaking({ asset, accountState })
|
|
87
|
-
|
|
88
|
-
const
|
|
86
|
+
|
|
87
|
+
const canClaimUndelegatedBalance = getCanClaimUndelegatedBalance({ accountState, asset })
|
|
88
|
+
|
|
89
|
+
const unclaimedUndelegatedBalance = getUnclaimedUndelegatedBalance({ asset, accountState })
|
|
90
|
+
|
|
91
|
+
const unstaking = canClaimUndelegatedBalance ? asset.currency.ZERO : unclaimedUndelegatedBalance
|
|
92
|
+
const unstaked = canClaimUndelegatedBalance ? unclaimedUndelegatedBalance : asset.currency.ZERO
|
|
89
93
|
|
|
90
94
|
let total
|
|
91
95
|
let spendable
|
|
@@ -3,15 +3,12 @@ import { getAssetAddresses, isRpcBalanceAsset } from '@exodus/ethereum-lib'
|
|
|
3
3
|
import lodash from 'lodash'
|
|
4
4
|
|
|
5
5
|
import { fromHexToString } from '../number-utils.js'
|
|
6
|
-
import {
|
|
7
|
-
filterEffects,
|
|
8
|
-
getDeriveDataNeededForTick,
|
|
9
|
-
getLogItemsFromServerTx,
|
|
10
|
-
} from './clarity-utils/index.js'
|
|
6
|
+
import { filterEffects, getLogItemsFromServerTx } from './clarity-utils/index.js'
|
|
11
7
|
import {
|
|
12
8
|
checkPendingTransactions,
|
|
13
9
|
excludeUnchangedTokenBalances,
|
|
14
10
|
getAllLogItemsByAsset,
|
|
11
|
+
getDeriveDataNeededForTick,
|
|
15
12
|
getDeriveTransactionsToCheck,
|
|
16
13
|
} from './monitor-utils/index.js'
|
|
17
14
|
|
|
@@ -176,19 +173,6 @@ export class ClarityMonitor extends BaseMonitor {
|
|
|
176
173
|
}
|
|
177
174
|
}
|
|
178
175
|
|
|
179
|
-
async deriveDataNeededForTick({ assetName, walletAccount }) {
|
|
180
|
-
const receiveAddress = await this.aci.getReceiveAddress({
|
|
181
|
-
assetName,
|
|
182
|
-
walletAccount,
|
|
183
|
-
useCache: true,
|
|
184
|
-
})
|
|
185
|
-
const currentAccountState = await this.aci.getAccountState({ assetName, walletAccount })
|
|
186
|
-
return {
|
|
187
|
-
ourWalletAddress: receiveAddress.toLowerCase(),
|
|
188
|
-
currentAccountState,
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
176
|
async getNewAccountState({ tokens, currentTokenBalances, ourWalletAddress }) {
|
|
193
177
|
const asset = this.asset
|
|
194
178
|
const newAccountState = {}
|
|
@@ -58,6 +58,18 @@ export default function getLogItemsFromServerTx({
|
|
|
58
58
|
sendingTransferPresent,
|
|
59
59
|
receivingTransferPresent,
|
|
60
60
|
})
|
|
61
|
+
let sent
|
|
62
|
+
if (sendingTransferPresent) {
|
|
63
|
+
sent = internalTransfers
|
|
64
|
+
.map(({ from, to, value }) => {
|
|
65
|
+
if (from === ourWalletAddress) {
|
|
66
|
+
const amount = asset.currency.baseUnit(value).toDefaultString({ unit: true })
|
|
67
|
+
return { address: to, amount }
|
|
68
|
+
}
|
|
69
|
+
})
|
|
70
|
+
.filter(Boolean)
|
|
71
|
+
}
|
|
72
|
+
|
|
61
73
|
logItemsForServerTxEntries.push([
|
|
62
74
|
asset.name,
|
|
63
75
|
{
|
|
@@ -69,6 +81,7 @@ export default function getLogItemsFromServerTx({
|
|
|
69
81
|
nonce,
|
|
70
82
|
gasLimit,
|
|
71
83
|
...methodId,
|
|
84
|
+
...(sent?.length > 0 ? { sent } : undefined),
|
|
72
85
|
},
|
|
73
86
|
...(ourWalletWasSender
|
|
74
87
|
? { from: [], to: toAddress, feeAmount, feeCoinName: asset.feeAsset.name }
|
|
@@ -56,6 +56,18 @@ export default function getLogItemsFromServerTx({
|
|
|
56
56
|
sendingTransferPresent,
|
|
57
57
|
receivingTransferPresent,
|
|
58
58
|
})
|
|
59
|
+
let sent
|
|
60
|
+
if (sendingTransferPresent) {
|
|
61
|
+
sent = serverTx.internal
|
|
62
|
+
.map(({ from, to, value }) => {
|
|
63
|
+
if (from === ourWalletAddress) {
|
|
64
|
+
const amount = asset.currency.baseUnit(value).toDefaultString({ unit: true })
|
|
65
|
+
return { address: to, amount }
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
.filter(Boolean)
|
|
69
|
+
}
|
|
70
|
+
|
|
59
71
|
logItemsForServerTxEntries.push([
|
|
60
72
|
asset.name,
|
|
61
73
|
{
|
|
@@ -67,6 +79,7 @@ export default function getLogItemsFromServerTx({
|
|
|
67
79
|
nonce,
|
|
68
80
|
gasLimit,
|
|
69
81
|
...methodId,
|
|
82
|
+
...(sent?.length > 0 ? { sent } : undefined),
|
|
70
83
|
},
|
|
71
84
|
...(ourWalletWasSender
|
|
72
85
|
? { from: [], to: toAddress, feeAmount, feeCoinName: asset.feeAsset.name }
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
// A super-selector that returns all the current data needed for a tick of the ETH monitor.
|
|
2
|
-
|
|
3
|
-
export default function getDeriveDataNeededForTick(aci) {
|
|
4
|
-
return async function ({ assetName, walletAccount }) {
|
|
5
|
-
const receiveAddress = await aci.getReceiveAddress({ assetName, walletAccount, useCache: true })
|
|
6
|
-
const currentAccountState = await aci.getAccountState({ assetName, walletAccount })
|
|
7
|
-
return {
|
|
8
|
-
ourWalletAddress: receiveAddress.toLowerCase(),
|
|
9
|
-
currentAccountState,
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
}
|