@exodus/solana-api 3.9.4 → 3.10.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/CHANGELOG.md +23 -0
- package/package.json +6 -6
- package/src/tx-log/me-flagr.js +0 -18
- package/src/tx-log/me-solana-monitor.js +0 -134
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,29 @@
|
|
|
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.10.1](https://github.com/ExodusMovement/assets/compare/@exodus/solana-api@3.10.0...@exodus/solana-api@3.10.1) (2024-08-26)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* update exodus/timer ([#3134](https://github.com/ExodusMovement/assets/issues/3134)) ([e977be5](https://github.com/ExodusMovement/assets/commit/e977be5280c214c1b814409d9461ce6628bb19be))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## [3.10.0](https://github.com/ExodusMovement/assets/compare/@exodus/solana-api@3.9.4...@exodus/solana-api@3.10.0) (2024-08-08)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* move ME solana monitor to the ME codebase ([#3117](https://github.com/ExodusMovement/assets/issues/3117)) ([6e2b25c](https://github.com/ExodusMovement/assets/commit/6e2b25c15d5c43a775b0ab53792882f69aa5c30d))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Reverts
|
|
24
|
+
|
|
25
|
+
* Revert "chore: skip ws test" (#3078) ([072f542](https://github.com/ExodusMovement/assets/commit/072f542dbe1adca57703da680508bbf21b412e3a)), closes [#3078](https://github.com/ExodusMovement/assets/issues/3078)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
6
29
|
## [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
30
|
|
|
8
31
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/solana-api",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.10.1",
|
|
4
4
|
"description": "Exodus internal Solana asset API wrapper",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"files": [
|
|
@@ -23,16 +23,16 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@exodus/asset-json-rpc": "^1.0.0",
|
|
25
25
|
"@exodus/asset-lib": "^4.1.0",
|
|
26
|
-
"@exodus/assets": "^
|
|
26
|
+
"@exodus/assets": "^11.0.0",
|
|
27
27
|
"@exodus/basic-utils": "^2.1.0",
|
|
28
28
|
"@exodus/currency": "^2.3.2",
|
|
29
29
|
"@exodus/fetch": "^1.2.0",
|
|
30
30
|
"@exodus/models": "^10.1.0",
|
|
31
31
|
"@exodus/nfts-core": "^0.5.0",
|
|
32
32
|
"@exodus/simple-retry": "^0.0.6",
|
|
33
|
-
"@exodus/solana-lib": "^3.
|
|
33
|
+
"@exodus/solana-lib": "^3.5.1",
|
|
34
34
|
"@exodus/solana-meta": "^1.0.7",
|
|
35
|
-
"@exodus/timer": "^1.
|
|
35
|
+
"@exodus/timer": "^1.1.1",
|
|
36
36
|
"bn.js": "^4.11.0",
|
|
37
37
|
"debug": "^4.1.1",
|
|
38
38
|
"delay": "^4.0.1",
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@exodus/assets-testing": "^1.0.0",
|
|
48
|
-
"@solana
|
|
48
|
+
"@exodus/solana-web3.js": "^1.63.1-exodus.9-rc1"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "31e84436880a97a8cc17043ccd319e376578d7f4",
|
|
51
51
|
"bugs": {
|
|
52
52
|
"url": "https://github.com/ExodusMovement/assets/issues?q=is%3Aissue+is%3Aopen+label%3Asolana-api"
|
|
53
53
|
},
|
package/src/tx-log/me-flagr.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import urljoin from 'url-join'
|
|
2
|
-
import wretch from 'wretch'
|
|
3
|
-
|
|
4
|
-
const FLAGR_URL = 'https://flagr-w.magiceden.io/api/v1/evaluation'
|
|
5
|
-
|
|
6
|
-
const fetchFlagrEvaluation = async (wallet, flagKey) => {
|
|
7
|
-
const url = urljoin(FLAGR_URL)
|
|
8
|
-
const entityContext = { wallet }
|
|
9
|
-
|
|
10
|
-
try {
|
|
11
|
-
return await wretch(url).post({ entityContext, flagKey }).json()
|
|
12
|
-
} catch (error) {
|
|
13
|
-
console.error('Error fetching flagr:', error)
|
|
14
|
-
throw error
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export default fetchFlagrEvaluation
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import urljoin from 'url-join'
|
|
2
|
-
import wretch from 'wretch'
|
|
3
|
-
|
|
4
|
-
import fetchFlagrEvaluation from './me-flagr'
|
|
5
|
-
import { SolanaMonitor } from './solana-monitor'
|
|
6
|
-
|
|
7
|
-
const FLAGR_KEY = 'sol-balance-api'
|
|
8
|
-
const SOL_NATIVE = '11111111111111111111111111111111'
|
|
9
|
-
|
|
10
|
-
export class MeSolanaMonitor extends SolanaMonitor {
|
|
11
|
-
#extraHeaders
|
|
12
|
-
|
|
13
|
-
constructor(args) {
|
|
14
|
-
super(args)
|
|
15
|
-
this.useMeMonitor = false
|
|
16
|
-
this.#extraHeaders = args.extraHeaders
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
async startListener({ walletAccount }) {
|
|
20
|
-
const address = await this.aci.getReceiveAddress({
|
|
21
|
-
assetName: this.asset.name,
|
|
22
|
-
walletAccount,
|
|
23
|
-
useCache: true,
|
|
24
|
-
})
|
|
25
|
-
await this.initFlagr(address)
|
|
26
|
-
return super.startListener({ walletAccount })
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
request(path, contentType = 'application/json') {
|
|
30
|
-
return wretch(urljoin('https://api-mainnet.magiceden.io', path)).headers({
|
|
31
|
-
'Content-Type': contentType,
|
|
32
|
-
...this.#extraHeaders,
|
|
33
|
-
})
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
async initFlagr(address) {
|
|
37
|
-
// If one of the user's SOL addresses is whitelisted, use the ME API
|
|
38
|
-
if (this.useMeMonitor) return
|
|
39
|
-
try {
|
|
40
|
-
const response = await fetchFlagrEvaluation(address, FLAGR_KEY)
|
|
41
|
-
if (response.variantKey === 'on') {
|
|
42
|
-
this.useMeMonitor = true
|
|
43
|
-
}
|
|
44
|
-
} catch (error) {
|
|
45
|
-
console.error('Failed to fetch useMeMonitor config:', error)
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
getTokens() {
|
|
50
|
-
return this.api.tokens
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
isStakingEnabled() {
|
|
54
|
-
return !this.useMeMonitor
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
async getAccountsAndBalances({ refresh, address, accountState, walletAccount }) {
|
|
58
|
-
if (!this.useMeMonitor) {
|
|
59
|
-
return super.getAccountsAndBalances({ refresh, address, accountState, walletAccount })
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const tokens = this.getTokens()
|
|
63
|
-
const body = [
|
|
64
|
-
{
|
|
65
|
-
address,
|
|
66
|
-
chain: 'solana',
|
|
67
|
-
},
|
|
68
|
-
]
|
|
69
|
-
|
|
70
|
-
const { balances } = await this.request('v1/wallet/balances/fungible').post(body).json()
|
|
71
|
-
const metadata = new Map()
|
|
72
|
-
|
|
73
|
-
const account = {
|
|
74
|
-
balance: this.asset.currency.ZERO,
|
|
75
|
-
tokenBalances: Object.create(null),
|
|
76
|
-
}
|
|
77
|
-
const tokenAccounts = []
|
|
78
|
-
|
|
79
|
-
balances.forEach((assetBalance) => {
|
|
80
|
-
const { asset: assetData, balance } = assetBalance
|
|
81
|
-
const mintAddress = assetData.mintAddress
|
|
82
|
-
|
|
83
|
-
if (assetBalance.asset?.id) {
|
|
84
|
-
metadata.set(assetBalance.asset.id, { imageURL: assetBalance.image })
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (mintAddress === SOL_NATIVE) {
|
|
88
|
-
// SOL balance
|
|
89
|
-
account.balance = this.asset.currency.baseUnit(balance.rawBalance)
|
|
90
|
-
} else {
|
|
91
|
-
// Fungible token balances
|
|
92
|
-
const token = tokens.get(mintAddress) || {
|
|
93
|
-
// name here is the exodus unique identifier not the display name
|
|
94
|
-
name: 'unknown',
|
|
95
|
-
ticker: assetData.symbol,
|
|
96
|
-
decimals: balance.decimals,
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (tokens.get(mintAddress)) {
|
|
100
|
-
const tokenKey = token.name
|
|
101
|
-
Object.defineProperty(account.tokenBalances, tokenKey, {
|
|
102
|
-
__proto__: null,
|
|
103
|
-
enumerable: true,
|
|
104
|
-
value: token.currency.baseUnit(balance.rawBalance),
|
|
105
|
-
})
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const tokenAccount = {
|
|
109
|
-
tokenAccountAddress: assetData.tokenAccount,
|
|
110
|
-
owner: assetBalance.owner,
|
|
111
|
-
tokenName: token.name,
|
|
112
|
-
ticker: token.ticker,
|
|
113
|
-
balance: assetBalance.balance.rawBalance,
|
|
114
|
-
mintAddress,
|
|
115
|
-
tokenProgram: assetData.tokenProgram,
|
|
116
|
-
decimals: token.decimals,
|
|
117
|
-
feeBasisPoints: assetData.feeBasisPoints ?? 0,
|
|
118
|
-
maximumFee: assetData.maximumFee ?? 0,
|
|
119
|
-
}
|
|
120
|
-
tokenAccounts.push(tokenAccount)
|
|
121
|
-
}
|
|
122
|
-
})
|
|
123
|
-
this.emit('token-metadata', { source: 'solana', metadata })
|
|
124
|
-
|
|
125
|
-
const fetchStakingInfo =
|
|
126
|
-
refresh || this.tickCount[walletAccount] % this.ticksBetweenStakeFetches === 0
|
|
127
|
-
const staking =
|
|
128
|
-
this.isStakingEnabled() && fetchStakingInfo
|
|
129
|
-
? await this.getStakingInfo({ address, walletAccount })
|
|
130
|
-
: { ...accountState.stakingInfo, staking: this.staking }
|
|
131
|
-
|
|
132
|
-
return { account, tokenAccounts, staking }
|
|
133
|
-
}
|
|
134
|
-
}
|