@exodus/solana-api 2.5.34 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/solana-api",
3
- "version": "2.5.34",
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": "^1.7.5",
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": "9da341db0c5c18d52690699d241675c1f7392d71"
47
+ "gitHead": "44827e13fbd513ee9a0d7cec603d20fe89d0d80a"
48
48
  }
@@ -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 class SolanaAccountState extends AccountState {
11
- static defaults = {
12
- cursor: '',
13
- balance: asset.currency.ZERO,
14
- tokenBalances: {},
15
- mem: {
16
- loaded: false,
17
- staking: {
18
- // remote-config data
19
- enabled: true,
20
- pool: null,
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
- isDelegating: false,
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
- static _tokens = [asset, ...tokens] // deprecated - will be removed
34
+ static _tokens = [asset, ...tokens] // deprecated - will be removed
32
35
 
33
- static _postParse(data) {
34
- const assets = assetsListToObject(assetsList)
35
- return {
36
- ...data,
37
- tokenBalances: reduce(
38
- data.tokenBalances,
39
- (r, tokenBalance, assetName) =>
40
- assets[assetName]
41
- ? Object.assign(r, { [assetName]: parseBalance(tokenBalance, assets[assetName]) })
42
- : r,
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 { SolanaAccountState } from './account-state'
9
+ export { createAccountState } from './account-state'
10
10
  export { getSolStakedFee, getStakingInfo, getUnstakingFee } from './staking-utils'
11
11
  export {
12
12
  isSolanaStaking,
@@ -116,7 +116,7 @@ export class SolanaMonitor extends BaseMonitor {
116
116
  )
117
117
  }
118
118
 
119
- async markStaleTransactions({ walletAccount, logItemsByAsset = {} }) {
119
+ async markStaleTransactions({ walletAccount, logItemsByAsset = Object.create(null) }) {
120
120
  // mark stale txs as dropped in logItemsByAsset
121
121
  const clearedLogItems = logItemsByAsset
122
122
  const tokenNames = [...this.api.tokens.values()].map(({ name }) => name)
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,