@exodus/solana-api 2.5.23 → 2.5.24
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 +3 -3
- package/src/account-state.js +19 -2
- package/src/get-balances.js +1 -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.24",
|
|
4
4
|
"description": "Exodus internal Solana asset API wrapper",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"files": [
|
|
@@ -23,7 +23,7 @@
|
|
|
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.
|
|
26
|
+
"@exodus/solana-lib": "^1.7.2",
|
|
27
27
|
"@exodus/solana-meta": "^1.0.3",
|
|
28
28
|
"bn.js": "^4.11.0",
|
|
29
29
|
"debug": "^4.1.1",
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@exodus/assets-testing": "file:../../../__testing__"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "107ccdaaaee35747ff1723be05723b734410bca6"
|
|
38
38
|
}
|
package/src/account-state.js
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import { asset, tokens } from '@exodus/solana-meta'
|
|
1
|
+
import assetsList, { asset, tokens } from '@exodus/solana-meta'
|
|
2
2
|
import { AccountState } from '@exodus/models'
|
|
3
|
+
import { assetsListToObject } from '@exodus/assets'
|
|
4
|
+
import { isString, reduce } from 'lodash'
|
|
5
|
+
import { isNumberUnit } from '@exodus/currency'
|
|
6
|
+
|
|
7
|
+
const parseBalance = (balance, asset) =>
|
|
8
|
+
!isNumberUnit(balance) && isString(balance) ? asset.currency.parse(balance) : balance
|
|
3
9
|
|
|
4
10
|
export class SolanaAccountState extends AccountState {
|
|
5
11
|
static defaults = {
|
|
@@ -24,6 +30,17 @@ export class SolanaAccountState extends AccountState {
|
|
|
24
30
|
static _tokens = [asset, ...tokens] // deprecated - will be removed
|
|
25
31
|
|
|
26
32
|
static _postParse(data) {
|
|
27
|
-
|
|
33
|
+
const assets = assetsListToObject(assetsList)
|
|
34
|
+
return {
|
|
35
|
+
...data,
|
|
36
|
+
tokenBalances: reduce(
|
|
37
|
+
data.tokenBalances,
|
|
38
|
+
(r, tokenBalance, assetName) =>
|
|
39
|
+
assets[assetName]
|
|
40
|
+
? Object.assign(r, { [assetName]: parseBalance(tokenBalance, assets[assetName]) })
|
|
41
|
+
: r,
|
|
42
|
+
{}
|
|
43
|
+
),
|
|
44
|
+
}
|
|
28
45
|
}
|
|
29
46
|
}
|
package/src/get-balances.js
CHANGED
|
@@ -10,7 +10,7 @@ export const getBalancesFactory = ({ stakingFeatureAvailable }) => ({ asset, acc
|
|
|
10
10
|
|
|
11
11
|
const balance = accountState.balance || zero
|
|
12
12
|
|
|
13
|
-
const { locked, withdrawable, pending } = accountState.mem ||
|
|
13
|
+
const { locked, withdrawable, pending } = accountState.mem || Object.create(null)
|
|
14
14
|
|
|
15
15
|
const balanceWithoutStaking = balance
|
|
16
16
|
.sub(locked || zero)
|