@exodus/solana-api 3.19.0 → 3.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/CHANGELOG.md CHANGED
@@ -3,6 +3,16 @@
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
+ ## [3.20.0](https://github.com/ExodusMovement/assets/compare/@exodus/solana-api@3.19.0...@exodus/solana-api@3.20.0) (2025-06-11)
7
+
8
+
9
+ ### Features
10
+
11
+
12
+ * feat(solana): implement unconfirmedSent/unconfirmedReceived in solana balances (#5802)
13
+
14
+
15
+
6
16
  ## [3.19.0](https://github.com/ExodusMovement/assets/compare/@exodus/solana-api@3.18.2...@exodus/solana-api@3.19.0) (2025-06-10)
7
17
 
8
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/solana-api",
3
- "version": "3.19.0",
3
+ "version": "3.20.0",
4
4
  "description": "Transaction monitors, fee monitors, RPC with the blockchain node, and other networking code for Solana",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -46,7 +46,7 @@
46
46
  "@exodus/assets-testing": "^1.0.0",
47
47
  "@exodus/solana-web3.js": "^1.63.1-exodus.9-rc3"
48
48
  },
49
- "gitHead": "86087d4d05ab6aa603b936c24723e5999f826424",
49
+ "gitHead": "a11096f37c71032ca704876059c11b2e55cc592a",
50
50
  "bugs": {
51
51
  "url": "https://github.com/ExodusMovement/assets/issues?q=is%3Aissue+is%3Aopen+label%3Asolana-api"
52
52
  },
@@ -8,7 +8,15 @@ export const getBalancesFactory =
8
8
  ({ asset, accountState, txLog }) => {
9
9
  const zero = asset.currency.ZERO
10
10
 
11
- const { balance, locked, activating, withdrawable, pending } = fixBalances({
11
+ const {
12
+ balance,
13
+ locked,
14
+ activating,
15
+ withdrawable,
16
+ pending,
17
+ unconfirmedSent,
18
+ unconfirmedReceived,
19
+ } = fixBalances({
12
20
  txLog,
13
21
  balance: getBalanceFromAccountState({ asset, accountState }),
14
22
  locked: accountState.stakingInfo?.locked || zero,
@@ -16,6 +24,8 @@ export const getBalancesFactory =
16
24
  activating: accountState.stakingInfo?.activating || zero,
17
25
  pending: accountState.stakingInfo?.pending || zero,
18
26
  asset,
27
+ unconfirmedSent: zero,
28
+ unconfirmedReceived: zero,
19
29
  })
20
30
  if (asset.baseAsset.name !== asset.name) {
21
31
  return {
@@ -70,6 +80,8 @@ export const getBalancesFactory =
70
80
  unstaking,
71
81
  networkReserve,
72
82
  walletReserve: zero,
83
+ unconfirmedSent,
84
+ unconfirmedReceived,
73
85
  }
74
86
  }
75
87
 
@@ -81,41 +93,56 @@ const fixBalances = ({
81
93
  activating,
82
94
  pending,
83
95
  asset,
96
+ unconfirmedSent,
97
+ unconfirmedReceived,
84
98
  }) => {
85
99
  for (const tx of txLog) {
86
- if ((tx.sent || tx.data.staking) && tx.pending && !tx.error) {
100
+ if (!tx.pending || tx.error) {
101
+ continue
102
+ }
103
+
104
+ if (tx.data.staking) {
105
+ if (tx.coinAmount.unitType.equals(tx.feeAmount.unitType)) {
106
+ unconfirmedSent = unconfirmedSent.add(tx.feeAmount)
107
+ }
108
+
109
+ // staking tx
110
+ switch (tx.data.staking?.method) {
111
+ case 'delegate':
112
+ activating = activating.add(tx.coinAmount.abs())
113
+ break
114
+ case 'withdraw':
115
+ withdrawable = asset.currency.ZERO
116
+ break
117
+ case 'undelegate':
118
+ pending = pending.add(locked).add(activating)
119
+ locked = asset.currency.ZERO
120
+ activating = asset.currency.ZERO
121
+ break
122
+ }
123
+ } else if (tx.sent) {
87
124
  if (tx.coinAmount.unitType.equals(tx.feeAmount.unitType)) {
88
- balance = balance.sub(tx.feeAmount)
125
+ unconfirmedSent = unconfirmedSent.add(tx.feeAmount)
89
126
  }
90
127
 
91
- if (tx.data.staking) {
92
- // staking tx
93
- switch (tx.data.staking?.method) {
94
- case 'delegate':
95
- activating = activating.add(tx.coinAmount.abs())
96
- break
97
- case 'withdraw':
98
- withdrawable = asset.currency.ZERO
99
- break
100
- case 'undelegate':
101
- pending = pending.add(locked).add(activating)
102
- locked = asset.currency.ZERO
103
- activating = asset.currency.ZERO
104
- break
105
- }
106
- } else {
107
- // coinAmount is negative for sent tx
108
- balance = balance.sub(tx.coinAmount.abs())
128
+ unconfirmedSent = unconfirmedSent.add(tx.coinAmount.abs())
129
+ } else if (tx.received) {
130
+ if (tx.coinAmount.unitType.equals(tx.feeAmount.unitType)) {
131
+ unconfirmedReceived = unconfirmedReceived.sub(tx.feeAmount)
109
132
  }
133
+
134
+ unconfirmedReceived = unconfirmedReceived.add(tx.coinAmount.abs())
110
135
  }
111
136
  }
112
137
 
113
138
  return {
114
- balance: balance.clampLowerZero(),
139
+ balance: balance.sub(unconfirmedSent).clampLowerZero(),
115
140
  locked: locked.clampLowerZero(),
116
141
  withdrawable: withdrawable.clampLowerZero(),
117
142
  activating: activating.clampLowerZero(),
118
143
  pending: pending.clampLowerZero(),
144
+ unconfirmedSent,
145
+ unconfirmedReceived,
119
146
  }
120
147
  }
121
148