@exodus/solana-api 2.5.25 → 2.5.27
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 +4 -4
- package/src/tx-log/solana-monitor.js +23 -20
- package/src/tx-send.js +5 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/solana-api",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.27",
|
|
4
4
|
"description": "Exodus internal Solana asset API wrapper",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"files": [
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"@exodus/models": "^10.1.0",
|
|
24
24
|
"@exodus/nfts-core": "^0.5.0",
|
|
25
25
|
"@exodus/simple-retry": "^0.0.6",
|
|
26
|
-
"@exodus/solana-lib": "^1.7.
|
|
27
|
-
"@exodus/solana-meta": "^1.0.
|
|
26
|
+
"@exodus/solana-lib": "^1.7.4",
|
|
27
|
+
"@exodus/solana-meta": "^1.0.5",
|
|
28
28
|
"bn.js": "^4.11.0",
|
|
29
29
|
"debug": "^4.1.1",
|
|
30
30
|
"lodash": "^4.17.11",
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@exodus/assets-testing": "file:../../../__testing__"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "9e93c3846854f6c64b0bdd5abe103ec5ff980596"
|
|
38
38
|
}
|
|
@@ -111,20 +111,24 @@ export class SolanaMonitor extends BaseMonitor {
|
|
|
111
111
|
refresh,
|
|
112
112
|
})
|
|
113
113
|
|
|
114
|
-
let staking = accountState.mem
|
|
115
|
-
|
|
116
114
|
const cursorChanged = this.hasNewCursor({ walletAccount, cursorState })
|
|
117
|
-
if (refresh || cursorChanged) {
|
|
118
|
-
staking = await this.updateStakingInfo({ walletAccount, address, stakingAddresses })
|
|
119
|
-
this.cursors[walletAccount] = cursorState.cursor
|
|
120
|
-
}
|
|
121
115
|
|
|
122
|
-
await this.updateTxLogByAsset({ walletAccount, logItemsByAsset, refresh })
|
|
123
116
|
if (refresh || hasNewTxs || cursorChanged) {
|
|
117
|
+
const staking =
|
|
118
|
+
refresh || cursorChanged
|
|
119
|
+
? await this.getStakingInfo({ address, stakingAddresses })
|
|
120
|
+
: accountState.mem
|
|
121
|
+
|
|
124
122
|
const tokenAccounts = await this.api.getTokenAccountsByOwner(address)
|
|
125
|
-
await this.emitUnknownTokensEvent({ tokenAccounts })
|
|
126
123
|
const account = await this.getAccount({ address, staking, tokenAccounts })
|
|
127
|
-
|
|
124
|
+
|
|
125
|
+
// update all state at once
|
|
126
|
+
await this.emitUnknownTokensEvent({ tokenAccounts })
|
|
127
|
+
await this.updateTxLogByAsset({ walletAccount, logItemsByAsset, refresh })
|
|
128
|
+
await this.updateState({ account, cursorState, walletAccount, staking })
|
|
129
|
+
if (refresh || cursorChanged) {
|
|
130
|
+
this.cursors[walletAccount] = cursorState.cursor
|
|
131
|
+
}
|
|
128
132
|
}
|
|
129
133
|
}
|
|
130
134
|
|
|
@@ -144,6 +148,7 @@ export class SolanaMonitor extends BaseMonitor {
|
|
|
144
148
|
if (assetName === 'unknown' || !asset) continue // skip unknown tokens
|
|
145
149
|
const feeAsset = asset.feeAsset
|
|
146
150
|
|
|
151
|
+
// TODO: remove all uses of toDefault()
|
|
147
152
|
const coinAmount = asset.currency.baseUnit(tx.amount).toDefault()
|
|
148
153
|
|
|
149
154
|
const item = {
|
|
@@ -209,15 +214,15 @@ export class SolanaMonitor extends BaseMonitor {
|
|
|
209
214
|
this.api.getTokensBalance({ address, filterByTokens: tokens, tokenAccounts }),
|
|
210
215
|
])
|
|
211
216
|
|
|
212
|
-
const stakedBalance = this.asset.currency.baseUnit(staking.locked)
|
|
213
|
-
const withdrawableBalance = this.asset.currency.baseUnit(staking.withdrawable)
|
|
214
|
-
const pendingBalance = this.asset.currency.baseUnit(staking.pending)
|
|
217
|
+
const stakedBalance = this.asset.currency.baseUnit(staking.locked)
|
|
218
|
+
const withdrawableBalance = this.asset.currency.baseUnit(staking.withdrawable)
|
|
219
|
+
const pendingBalance = this.asset.currency.baseUnit(staking.pending)
|
|
215
220
|
const balance = this.asset.currency
|
|
216
221
|
.baseUnit(solBalance)
|
|
217
|
-
.toDefault()
|
|
218
222
|
.add(stakedBalance)
|
|
219
223
|
.add(withdrawableBalance)
|
|
220
224
|
.add(pendingBalance)
|
|
225
|
+
.toDefault()
|
|
221
226
|
|
|
222
227
|
const tokenBalances = _.mapValues(splBalances, (balance, name) =>
|
|
223
228
|
this.assets[name].currency.baseUnit(balance).toDefault()
|
|
@@ -229,18 +234,19 @@ export class SolanaMonitor extends BaseMonitor {
|
|
|
229
234
|
}
|
|
230
235
|
}
|
|
231
236
|
|
|
232
|
-
async updateState({ account, cursorState, walletAccount }) {
|
|
237
|
+
async updateState({ account, cursorState, walletAccount, staking }) {
|
|
233
238
|
const { balance, tokenBalances } = account
|
|
234
|
-
const newData = { balance, tokenBalances, ...cursorState }
|
|
239
|
+
const newData = { balance, tokenBalances, mem: staking, ...cursorState }
|
|
235
240
|
return this.updateAccountState({ newData, walletAccount })
|
|
236
241
|
}
|
|
237
242
|
|
|
238
|
-
async
|
|
243
|
+
async getStakingInfo({ address, stakingAddresses = [] }) {
|
|
239
244
|
const stakingInfo = await this.api.getStakeAccountsInfo(address)
|
|
240
245
|
// merge current and old staking addresses
|
|
241
246
|
const allStakingAddresses = _.uniq([...Object.keys(stakingInfo.accounts), ...stakingAddresses])
|
|
242
247
|
const rewards = await this.api.getRewards(allStakingAddresses)
|
|
243
|
-
|
|
248
|
+
|
|
249
|
+
return {
|
|
244
250
|
loaded: true,
|
|
245
251
|
staking: this.staking,
|
|
246
252
|
isDelegating: Object.values(stakingInfo.accounts).some(({ state }) =>
|
|
@@ -252,8 +258,5 @@ export class SolanaMonitor extends BaseMonitor {
|
|
|
252
258
|
earned: this.asset.currency.baseUnit(rewards).toDefault(),
|
|
253
259
|
accounts: stakingInfo.accounts, // Obj
|
|
254
260
|
}
|
|
255
|
-
|
|
256
|
-
await this.updateAccountState({ walletAccount, newData: { mem } })
|
|
257
|
-
return mem
|
|
258
261
|
}
|
|
259
262
|
}
|
package/src/tx-send.js
CHANGED
|
@@ -196,7 +196,11 @@ export const createAndBroadcastTXFactory = (api) => async (
|
|
|
196
196
|
Object.assign(changes, { mem: stakingData })
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
-
await assetClientInterface.updateAccountState({
|
|
199
|
+
await assetClientInterface.updateAccountState({
|
|
200
|
+
assetName: baseAsset.name,
|
|
201
|
+
walletAccount,
|
|
202
|
+
newData: changes,
|
|
203
|
+
})
|
|
200
204
|
|
|
201
205
|
return { txId }
|
|
202
206
|
}
|