@exodus/solana-api 2.5.33 → 3.0.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/package.json +3 -3
- package/src/account-state.js +37 -33
- package/src/index.js +1 -1
- package/src/tx-log/solana-monitor.js +4 -1
- package/src/tx-send.js +3 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/solana-api",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Exodus internal Solana asset API wrapper",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"files": [
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"@exodus/models": "^10.1.0",
|
|
30
30
|
"@exodus/nfts-core": "^0.5.0",
|
|
31
31
|
"@exodus/simple-retry": "^0.0.6",
|
|
32
|
-
"@exodus/solana-lib": "^
|
|
32
|
+
"@exodus/solana-lib": "^2.0.0",
|
|
33
33
|
"@exodus/solana-meta": "^1.0.7",
|
|
34
34
|
"bn.js": "^4.11.0",
|
|
35
35
|
"debug": "^4.1.1",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@exodus/assets-testing": "^1.0.0"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "44827e13fbd513ee9a0d7cec603d20fe89d0d80a"
|
|
48
48
|
}
|
package/src/account-state.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import assetsList, { asset, tokens } from '@exodus/solana-meta'
|
|
2
1
|
import { AccountState } from '@exodus/models'
|
|
3
2
|
import { assetsListToObject } from '@exodus/assets'
|
|
4
3
|
import { isString, reduce } from 'lodash'
|
|
@@ -7,41 +6,46 @@ import { isNumberUnit } from '@exodus/currency'
|
|
|
7
6
|
const parseBalance = (balance, asset) =>
|
|
8
7
|
!isNumberUnit(balance) && isString(balance) ? asset.currency.parse(balance) : balance
|
|
9
8
|
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
9
|
+
export const createAccountState = ({ assetList }) => {
|
|
10
|
+
const asset = assetList.find((asset) => asset.baseAssetName === asset.name)
|
|
11
|
+
const tokens = assetList.filter((asset) => asset.baseAssetName !== asset.name)
|
|
12
|
+
|
|
13
|
+
return class SolanaAccountState extends AccountState {
|
|
14
|
+
static defaults = {
|
|
15
|
+
cursor: '',
|
|
16
|
+
balance: asset.currency.ZERO,
|
|
17
|
+
tokenBalances: {},
|
|
18
|
+
mem: {
|
|
19
|
+
loaded: false,
|
|
20
|
+
staking: {
|
|
21
|
+
// remote-config data
|
|
22
|
+
enabled: true,
|
|
23
|
+
pool: null,
|
|
24
|
+
},
|
|
25
|
+
isDelegating: false,
|
|
26
|
+
locked: asset.currency.defaultUnit(0),
|
|
27
|
+
withdrawable: asset.currency.defaultUnit(0),
|
|
28
|
+
pending: asset.currency.defaultUnit(0),
|
|
29
|
+
earned: asset.currency.defaultUnit(0),
|
|
30
|
+
accounts: {}, // stake accounts
|
|
21
31
|
},
|
|
22
|
-
|
|
23
|
-
locked: asset.currency.defaultUnit(0),
|
|
24
|
-
withdrawable: asset.currency.defaultUnit(0),
|
|
25
|
-
pending: asset.currency.defaultUnit(0),
|
|
26
|
-
earned: asset.currency.defaultUnit(0),
|
|
27
|
-
accounts: {}, // stake accounts
|
|
28
|
-
},
|
|
29
|
-
}
|
|
32
|
+
}
|
|
30
33
|
|
|
31
|
-
|
|
34
|
+
static _tokens = [asset, ...tokens] // deprecated - will be removed
|
|
32
35
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
36
|
+
static _postParse(data) {
|
|
37
|
+
const assets = assetsListToObject(assetList)
|
|
38
|
+
return {
|
|
39
|
+
...data,
|
|
40
|
+
tokenBalances: reduce(
|
|
41
|
+
data.tokenBalances,
|
|
42
|
+
(r, tokenBalance, assetName) =>
|
|
43
|
+
assets[assetName]
|
|
44
|
+
? Object.assign(r, { [assetName]: parseBalance(tokenBalance, assets[assetName]) })
|
|
45
|
+
: r,
|
|
46
|
+
{}
|
|
47
|
+
),
|
|
48
|
+
}
|
|
45
49
|
}
|
|
46
50
|
}
|
|
47
51
|
}
|
package/src/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Api } from './api'
|
|
|
6
6
|
|
|
7
7
|
export { default as SolanaFeeMonitor } from './fee-monitor'
|
|
8
8
|
export { SolanaMonitor } from './tx-log'
|
|
9
|
-
export {
|
|
9
|
+
export { createAccountState } from './account-state'
|
|
10
10
|
export { getSolStakedFee, getStakingInfo, getUnstakingFee } from './staking-utils'
|
|
11
11
|
export {
|
|
12
12
|
isSolanaStaking,
|
|
@@ -21,6 +21,7 @@ export class SolanaMonitor extends BaseMonitor {
|
|
|
21
21
|
includeUnparsed = false,
|
|
22
22
|
ticksBetweenHistoryFetches = TICKS_BETWEEN_HISTORY_FETCHES,
|
|
23
23
|
ticksBetweenStakeFetches = TICKS_BETWEEN_STAKE_FETCHES,
|
|
24
|
+
txsLimit,
|
|
24
25
|
...args
|
|
25
26
|
}) {
|
|
26
27
|
super(args)
|
|
@@ -32,6 +33,7 @@ export class SolanaMonitor extends BaseMonitor {
|
|
|
32
33
|
this.ticksBetweenStakeFetches = ticksBetweenStakeFetches
|
|
33
34
|
this.ticksBetweenHistoryFetches = ticksBetweenHistoryFetches
|
|
34
35
|
this.includeUnparsed = includeUnparsed
|
|
36
|
+
this.txsLimit = txsLimit
|
|
35
37
|
this.addHook('before-stop', (...args) => this.beforeStop(...args))
|
|
36
38
|
}
|
|
37
39
|
|
|
@@ -114,7 +116,7 @@ export class SolanaMonitor extends BaseMonitor {
|
|
|
114
116
|
)
|
|
115
117
|
}
|
|
116
118
|
|
|
117
|
-
async markStaleTransactions({ walletAccount, logItemsByAsset =
|
|
119
|
+
async markStaleTransactions({ walletAccount, logItemsByAsset = Object.create(null) }) {
|
|
118
120
|
// mark stale txs as dropped in logItemsByAsset
|
|
119
121
|
const clearedLogItems = logItemsByAsset
|
|
120
122
|
const tokenNames = [...this.api.tokens.values()].map(({ name }) => name)
|
|
@@ -195,6 +197,7 @@ export class SolanaMonitor extends BaseMonitor {
|
|
|
195
197
|
const { transactions, newCursor } = await this.api.getTransactions(address, {
|
|
196
198
|
cursor,
|
|
197
199
|
includeUnparsed: this.includeUnparsed,
|
|
200
|
+
limit: this.txsLimit,
|
|
198
201
|
})
|
|
199
202
|
|
|
200
203
|
const mappedTransactions = []
|
package/src/tx-send.js
CHANGED
|
@@ -60,6 +60,8 @@ export const createAndBroadcastTXFactory =
|
|
|
60
60
|
|
|
61
61
|
const recentBlockhash = options.recentBlockhash || (await api.getRecentBlockHash())
|
|
62
62
|
|
|
63
|
+
const feeData = await assetClientInterface.getFeeData({ assetName })
|
|
64
|
+
|
|
63
65
|
let tokenParams = Object.create(null)
|
|
64
66
|
if (isToken || customMintAddress) {
|
|
65
67
|
const tokenMintAddress = customMintAddress || asset.mintAddress
|
|
@@ -113,6 +115,7 @@ export const createAndBroadcastTXFactory =
|
|
|
113
115
|
amount,
|
|
114
116
|
fee: feeAmount,
|
|
115
117
|
recentBlockhash,
|
|
118
|
+
feeData,
|
|
116
119
|
reference,
|
|
117
120
|
memo,
|
|
118
121
|
...tokenParams,
|