@exodus/solana-api 3.5.0 → 3.6.1
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/solana-api",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.1",
|
|
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": "^3.
|
|
32
|
+
"@exodus/solana-lib": "^3.4.2",
|
|
33
33
|
"@exodus/solana-meta": "^1.0.7",
|
|
34
34
|
"bn.js": "^4.11.0",
|
|
35
35
|
"debug": "^4.1.1",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"@exodus/assets-testing": "^1.0.0",
|
|
46
46
|
"@solana/web3.js": "^1.91.8"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "9d24eb58422692fc1acdcb834061d02b2632801d"
|
|
49
49
|
}
|
package/src/account-state.js
CHANGED
|
@@ -6,6 +6,8 @@ import { isNumberUnit } from '@exodus/currency'
|
|
|
6
6
|
const parseBalance = (balance, asset) =>
|
|
7
7
|
!isNumberUnit(balance) && isString(balance) ? asset.currency.parse(balance) : balance
|
|
8
8
|
|
|
9
|
+
export const DEFAULT_POOL_ADDRESS = '9QU2QSxhb24FUX3Tu2FpczXjpK3VYrvRudywSZaM29mF' // Everstake
|
|
10
|
+
|
|
9
11
|
export const createAccountState = ({ assetList }) => {
|
|
10
12
|
const asset = assetList.find((asset) => asset.baseAssetName === asset.name)
|
|
11
13
|
const tokens = assetList.filter((asset) => asset.baseAssetName !== asset.name)
|
|
@@ -20,7 +22,7 @@ export const createAccountState = ({ assetList }) => {
|
|
|
20
22
|
staking: {
|
|
21
23
|
// remote-config data
|
|
22
24
|
enabled: true,
|
|
23
|
-
pool:
|
|
25
|
+
pool: DEFAULT_POOL_ADDRESS,
|
|
24
26
|
},
|
|
25
27
|
isDelegating: false,
|
|
26
28
|
locked: asset.currency.defaultUnit(0),
|
package/src/index.js
CHANGED
|
@@ -16,6 +16,7 @@ export {
|
|
|
16
16
|
} from './txs-utils'
|
|
17
17
|
export { createAndBroadcastTXFactory } from './tx-send'
|
|
18
18
|
export { getBalancesFactory } from './get-balances'
|
|
19
|
+
export { stakingProviderClientFactory } from './staking-provider-client'
|
|
19
20
|
|
|
20
21
|
// These are not the same asset objects as the wallet creates, so they should never be returned to the wallet.
|
|
21
22
|
// Initially this may be violated by the Solana code until the first monitor tick updates assets with setTokens()
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import assert from 'minimalistic-assert'
|
|
2
|
+
import { fetchival } from '@exodus/fetch'
|
|
3
|
+
import ms from 'ms'
|
|
4
|
+
|
|
5
|
+
const DEFAULT_STAKING_URL = 'https://staking.a.exodus.io'
|
|
6
|
+
const HTTP_POST_TIMEOUT = ms('30s')
|
|
7
|
+
|
|
8
|
+
const SOLANA_VALIDATOR = '9QU2QSxhb24FUX3Tu2FpczXjpK3VYrvRudywSZaM29mF' // Everstake
|
|
9
|
+
|
|
10
|
+
export const stakingProviderClientFactory = (
|
|
11
|
+
{ defaultStakingUrl = DEFAULT_STAKING_URL } = Object.create(null)
|
|
12
|
+
) => {
|
|
13
|
+
assert(defaultStakingUrl, 'defaultStakingUrl must be provided')
|
|
14
|
+
let stakingUrl = defaultStakingUrl
|
|
15
|
+
|
|
16
|
+
const setStakingUrl = (newStakingUrl) => {
|
|
17
|
+
stakingUrl = new URL(newStakingUrl || defaultStakingUrl)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const stakingRequest = ({ asset: assetName, data }) => {
|
|
21
|
+
return fetchival(stakingUrl, {
|
|
22
|
+
timeout: HTTP_POST_TIMEOUT,
|
|
23
|
+
})(assetName)('stake').post(data)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const notifyActionFactory = ({ type }) => {
|
|
27
|
+
assert(type, '"type" is required')
|
|
28
|
+
return async ({ asset: assetName, txId, delegator, amount, error }) => {
|
|
29
|
+
assert(assetName, '"asset" must be provided')
|
|
30
|
+
assert(SOLANA_VALIDATOR, '"invalid" validator')
|
|
31
|
+
assert(txId, '"txId" is required')
|
|
32
|
+
assert(delegator, '"delegator" is required')
|
|
33
|
+
assert(amount, '"amount" is required')
|
|
34
|
+
|
|
35
|
+
const stakingData = {
|
|
36
|
+
asset: assetName,
|
|
37
|
+
data: {
|
|
38
|
+
delegator,
|
|
39
|
+
actions: [
|
|
40
|
+
{
|
|
41
|
+
type,
|
|
42
|
+
validator: SOLANA_VALIDATOR,
|
|
43
|
+
amount,
|
|
44
|
+
txId,
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
}
|
|
49
|
+
return stakingRequest(stakingData)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const notifyStaking = notifyActionFactory({
|
|
54
|
+
type: 'start',
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
const notifyWithdraw = notifyActionFactory({
|
|
58
|
+
type: 'stop',
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
setStakingUrl,
|
|
63
|
+
notifyStaking,
|
|
64
|
+
notifyWithdraw,
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -3,7 +3,7 @@ import _ from 'lodash'
|
|
|
3
3
|
import assert from 'minimalistic-assert'
|
|
4
4
|
import ms from 'ms'
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
import { DEFAULT_POOL_ADDRESS } from '../account-state'
|
|
7
7
|
|
|
8
8
|
const DEFAULT_REMOTE_CONFIG = {
|
|
9
9
|
rpcs: [],
|
|
@@ -148,7 +148,7 @@ export class SolanaMonitor extends BaseMonitor {
|
|
|
148
148
|
const fetchStakingInfo = this.tickCount[walletAccount] % this.ticksBetweenStakeFetches === 0
|
|
149
149
|
const staking = fetchStakingInfo
|
|
150
150
|
? await this.getStakingInfo({ address, stakingAddresses })
|
|
151
|
-
: accountState.mem
|
|
151
|
+
: { ...accountState.mem, staking: this.staking }
|
|
152
152
|
|
|
153
153
|
const tokenAccounts = await this.api.getTokenAccountsByOwner(address)
|
|
154
154
|
const account = await this.getAccount({ address, staking, tokenAccounts })
|