@exodus/solana-api 3.9.2 → 3.9.4
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 +18 -0
- package/package.json +3 -3
- package/src/account-state.js +3 -3
- package/src/connection.js +3 -3
- package/src/get-balances.js +3 -3
- package/src/index.js +1 -1
- package/src/staking-provider-client.js +1 -1
- package/src/staking-utils.js +11 -11
- package/src/tx-log/me-flagr.js +1 -1
- package/src/tx-log/me-solana-monitor.js +3 -1
- package/src/tx-log/solana-auto-withdraw-monitor.js +4 -4
- package/src/tx-log/solana-monitor.js +2 -2
- package/src/tx-send.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,24 @@
|
|
|
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.9.4](https://github.com/ExodusMovement/assets/compare/@exodus/solana-api@3.9.3...@exodus/solana-api@3.9.4) (2024-08-01)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* revert object.defineProperty usage ([#3056](https://github.com/ExodusMovement/assets/issues/3056)) ([493a486](https://github.com/ExodusMovement/assets/commit/493a4865ed07c816167b96a5d01ba0f154b077c8))
|
|
12
|
+
* SOL lint ([#2953](https://github.com/ExodusMovement/assets/issues/2953)) ([3f1b3b8](https://github.com/ExodusMovement/assets/commit/3f1b3b8c9a1544ca7d41ac883c06e465d6928b32))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## [3.9.3](https://github.com/ExodusMovement/assets/compare/@exodus/solana-api@3.9.2...@exodus/solana-api@3.9.3) (2024-07-23)
|
|
17
|
+
|
|
18
|
+
**Note:** Version bump only for package @exodus/solana-api
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
6
24
|
## [3.9.2](https://github.com/ExodusMovement/assets/compare/@exodus/solana-api@3.9.1...@exodus/solana-api@3.9.2) (2024-07-18)
|
|
7
25
|
|
|
8
26
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/solana-api",
|
|
3
|
-
"version": "3.9.
|
|
3
|
+
"version": "3.9.4",
|
|
4
4
|
"description": "Exodus internal Solana asset API wrapper",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"files": [
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"access": "restricted"
|
|
17
17
|
},
|
|
18
18
|
"scripts": {
|
|
19
|
-
"test": "run -T jest",
|
|
19
|
+
"test": "run -T exodus-test --jest --esbuild",
|
|
20
20
|
"lint": "run -T eslint .",
|
|
21
21
|
"lint:fix": "yarn lint --fix"
|
|
22
22
|
},
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@exodus/assets-testing": "^1.0.0",
|
|
48
48
|
"@solana/web3.js": "^1.91.8"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "5fcab5458c8c985876fab348a3403931940eb3c2",
|
|
51
51
|
"bugs": {
|
|
52
52
|
"url": "https://github.com/ExodusMovement/assets/issues?q=is%3Aissue+is%3Aopen+label%3Asolana-api"
|
|
53
53
|
},
|
package/src/account-state.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { AccountState } from '@exodus/models'
|
|
2
1
|
import { assetsListToObject } from '@exodus/assets'
|
|
3
|
-
import { isString, reduce } from 'lodash'
|
|
4
2
|
import { isNumberUnit } from '@exodus/currency'
|
|
3
|
+
import { AccountState } from '@exodus/models'
|
|
4
|
+
import { isString, reduce } from 'lodash'
|
|
5
5
|
|
|
6
6
|
const parseBalance = (balance, asset) =>
|
|
7
7
|
!isNumberUnit(balance) && isString(balance) ? asset.currency.parse(balance) : balance
|
|
@@ -17,7 +17,7 @@ export const createAccountState = ({ assetList }) => {
|
|
|
17
17
|
cursor: '',
|
|
18
18
|
balance: asset.currency.ZERO,
|
|
19
19
|
tokenBalances: Object.create(null),
|
|
20
|
-
|
|
20
|
+
stakingInfo: {
|
|
21
21
|
loaded: false,
|
|
22
22
|
staking: {
|
|
23
23
|
// remote-config data
|
package/src/connection.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { WebSocket } from '@exodus/fetch'
|
|
2
|
+
import debugLogger from 'debug'
|
|
2
3
|
import delay from 'delay'
|
|
3
4
|
import lodash from 'lodash'
|
|
4
|
-
import debugLogger from 'debug'
|
|
5
|
-
import { WebSocket } from '@exodus/fetch'
|
|
6
5
|
import makeConcurrent from 'make-concurrent'
|
|
6
|
+
import ms from 'ms'
|
|
7
7
|
|
|
8
8
|
// WS subscriptions: https://docs.solana.com/developing/clients/jsonrpc-api#subscription-websocket
|
|
9
9
|
|
package/src/get-balances.js
CHANGED
|
@@ -10,9 +10,9 @@ export const getBalancesFactory =
|
|
|
10
10
|
const { balance, locked, withdrawable, pending } = fixBalances({
|
|
11
11
|
txLog,
|
|
12
12
|
balance: getBalanceFromAccountState({ asset, accountState }),
|
|
13
|
-
locked: accountState.
|
|
14
|
-
withdrawable: accountState.
|
|
15
|
-
pending: accountState.
|
|
13
|
+
locked: accountState.stakingInfo?.locked || zero,
|
|
14
|
+
withdrawable: accountState.stakingInfo?.withdrawable || zero,
|
|
15
|
+
pending: accountState.stakingInfo?.pending || zero,
|
|
16
16
|
asset,
|
|
17
17
|
})
|
|
18
18
|
if (asset.baseAsset.name !== asset.name) {
|
package/src/index.js
CHANGED
package/src/staking-utils.js
CHANGED
|
@@ -12,21 +12,21 @@ export const getSolStakedFee = ({ asset, stakingInfo, fee }) => {
|
|
|
12
12
|
return allPending > 0 ? fee.mul(allPending) : currency.ZERO
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export const getStakingInfo = (
|
|
15
|
+
export const getStakingInfo = (stakingInfo) => {
|
|
16
16
|
return {
|
|
17
|
-
loaded:
|
|
18
|
-
staking:
|
|
19
|
-
isDelegating:
|
|
20
|
-
locked:
|
|
21
|
-
activating:
|
|
22
|
-
withdrawable:
|
|
23
|
-
pending:
|
|
24
|
-
accounts:
|
|
25
|
-
earned:
|
|
17
|
+
loaded: stakingInfo.loaded,
|
|
18
|
+
staking: stakingInfo.staking,
|
|
19
|
+
isDelegating: stakingInfo.isDelegating,
|
|
20
|
+
locked: stakingInfo.locked,
|
|
21
|
+
activating: stakingInfo.activating,
|
|
22
|
+
withdrawable: stakingInfo.withdrawable,
|
|
23
|
+
pending: stakingInfo.pending,
|
|
24
|
+
accounts: stakingInfo.accounts,
|
|
25
|
+
earned: stakingInfo.earned,
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
export const getUnstakingFee = ({ asset, fee, accountState }) => {
|
|
30
|
-
const stakingInfo = getStakingInfo(accountState.
|
|
30
|
+
const stakingInfo = getStakingInfo(accountState.stakingInfo ?? {})
|
|
31
31
|
return getSolStakedFee({ asset, stakingInfo, fee })
|
|
32
32
|
}
|
package/src/tx-log/me-flagr.js
CHANGED
|
@@ -99,6 +99,8 @@ export class MeSolanaMonitor extends SolanaMonitor {
|
|
|
99
99
|
if (tokens.get(mintAddress)) {
|
|
100
100
|
const tokenKey = token.name
|
|
101
101
|
Object.defineProperty(account.tokenBalances, tokenKey, {
|
|
102
|
+
__proto__: null,
|
|
103
|
+
enumerable: true,
|
|
102
104
|
value: token.currency.baseUnit(balance.rawBalance),
|
|
103
105
|
})
|
|
104
106
|
}
|
|
@@ -125,7 +127,7 @@ export class MeSolanaMonitor extends SolanaMonitor {
|
|
|
125
127
|
const staking =
|
|
126
128
|
this.isStakingEnabled() && fetchStakingInfo
|
|
127
129
|
? await this.getStakingInfo({ address, walletAccount })
|
|
128
|
-
: { ...accountState.
|
|
130
|
+
: { ...accountState.stakingInfo, staking: this.staking }
|
|
129
131
|
|
|
130
132
|
return { account, tokenAccounts, staking }
|
|
131
133
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Timer } from '@exodus/timer'
|
|
2
|
+
import assert from 'assert'
|
|
2
3
|
import { get } from 'lodash'
|
|
3
4
|
import ms from 'ms'
|
|
4
|
-
import assert from 'assert'
|
|
5
5
|
|
|
6
6
|
const INTERVAL = ms('30s')
|
|
7
7
|
|
|
@@ -31,8 +31,8 @@ export class SolanaAutoWithdrawMonitor {
|
|
|
31
31
|
assetName: this.assetName,
|
|
32
32
|
walletAccount,
|
|
33
33
|
})
|
|
34
|
-
const { cursor,
|
|
35
|
-
const { loaded, withdrawable } =
|
|
34
|
+
const { cursor, stakingInfo } = accountState
|
|
35
|
+
const { loaded, withdrawable } = stakingInfo
|
|
36
36
|
|
|
37
37
|
if (!Array.isArray(this.cursors[walletAccount])) this.cursors[walletAccount] = []
|
|
38
38
|
const cursorChanged = !this.cursors[walletAccount].includes(cursor)
|
|
@@ -49,7 +49,7 @@ export class SolanaAutoWithdrawMonitor {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
async tryWithdraw({ accountState, walletAccount }) {
|
|
52
|
-
const stakingInfo = accountState.
|
|
52
|
+
const stakingInfo = accountState.stakingInfo
|
|
53
53
|
const feeData = await this.aci.getFeeData({ assetName: this.assetName })
|
|
54
54
|
const fee = get(feeData, 'fee', this.asset.currency.ZERO)
|
|
55
55
|
|
|
@@ -309,7 +309,7 @@ export class SolanaMonitor extends BaseMonitor {
|
|
|
309
309
|
const staking =
|
|
310
310
|
this.isStakingEnabled() && fetchStakingInfo
|
|
311
311
|
? await this.getStakingInfo({ address, walletAccount })
|
|
312
|
-
: { ...accountState.
|
|
312
|
+
: { ...accountState.stakingInfo, staking: this.staking }
|
|
313
313
|
|
|
314
314
|
const stakedBalance = this.asset.currency.baseUnit(staking.locked)
|
|
315
315
|
const withdrawableBalance = this.asset.currency.baseUnit(staking.withdrawable)
|
|
@@ -332,7 +332,7 @@ export class SolanaMonitor extends BaseMonitor {
|
|
|
332
332
|
|
|
333
333
|
async updateState({ account, cursorState, walletAccount, staking }) {
|
|
334
334
|
const { balance, tokenBalances } = account
|
|
335
|
-
const newData = { balance, tokenBalances,
|
|
335
|
+
const newData = { balance, tokenBalances, stakingInfo: staking, ...cursorState }
|
|
336
336
|
return this.updateAccountState({ newData, walletAccount })
|
|
337
337
|
}
|
|
338
338
|
|
package/src/tx-send.js
CHANGED
|
@@ -2,8 +2,8 @@ import {
|
|
|
2
2
|
createUnsignedTx,
|
|
3
3
|
findAssociatedTokenAddress,
|
|
4
4
|
prepareForSigning,
|
|
5
|
-
TOKEN_PROGRAM_ID,
|
|
6
5
|
TOKEN_2022_PROGRAM_ID,
|
|
6
|
+
TOKEN_PROGRAM_ID,
|
|
7
7
|
} from '@exodus/solana-lib'
|
|
8
8
|
import { transactionToBase58 } from '@exodus/solana-lib/src/tx/common'
|
|
9
9
|
import assert from 'minimalistic-assert'
|