@exodus/solana-plugin 1.24.0 → 1.24.2

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 CHANGED
@@ -3,6 +3,28 @@
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
+ ## [1.24.2](https://github.com/ExodusMovement/assets/compare/@exodus/solana-plugin@1.24.1...@exodus/solana-plugin@1.24.2) (2025-09-15)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+
12
+ * fix: update Solana base asset name (#6466)
13
+
14
+
15
+
16
+ ## [1.24.1](https://github.com/ExodusMovement/assets/compare/@exodus/solana-plugin@1.24.0...@exodus/solana-plugin@1.24.1) (2025-09-15)
17
+
18
+
19
+ ### Bug Fixes
20
+
21
+
22
+ * fix: integration tests of SOL, THETA, DOT (#6166)
23
+
24
+ * fix: use toMatchObject to ignore extra keys in actual reports (#6260)
25
+
26
+
27
+
6
28
  ## [1.24.0](https://github.com/ExodusMovement/assets/compare/@exodus/solana-plugin@1.23.2...@exodus/solana-plugin@1.24.0) (2025-07-16)
7
29
 
8
30
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/solana-plugin",
3
- "version": "1.24.0",
3
+ "version": "1.24.2",
4
4
  "description": "Solana plugin for Exodus SDK powered wallets.",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -21,6 +21,7 @@
21
21
  "lint:fix": "yarn lint --fix"
22
22
  },
23
23
  "dependencies": {
24
+ "@exodus/asset-lib": "^5.0.0",
24
25
  "@exodus/assets": "^11.0.0",
25
26
  "@exodus/bip44-constants": "^195.0.0",
26
27
  "@exodus/i18n-dummy": "^1.0.0",
@@ -42,5 +43,5 @@
42
43
  "type": "git",
43
44
  "url": "git+https://github.com/ExodusMovement/assets.git"
44
45
  },
45
- "gitHead": "c12ad495a49f457bc0941e6b568b608e2a6a4250"
46
+ "gitHead": "c8b232eb144194f40066ec2586d4fb6d66955f70"
46
47
  }
@@ -24,7 +24,7 @@ import {
24
24
  import ms from 'ms'
25
25
 
26
26
  import { createGetBalanceForAddress } from './get-balance-for-address.js'
27
- import sendValidations from './send-validations.js'
27
+ import sendValidationsFactory from './send-validations.js'
28
28
  import { createWeb3API } from './web3/index.js'
29
29
 
30
30
  const DEFAULT_ACCOUNT_RESERVE = 0
@@ -54,8 +54,8 @@ export const createSolanaAssetFactory =
54
54
  } = {}) => {
55
55
  const assets = connectAssetsList(assetList)
56
56
 
57
- const baseName = assetList.find((asset) => asset.baseAssetName === asset.name)
58
- const base = assets[baseName]
57
+ const base = Object.values(assets).find((asset) => asset.baseAssetName === asset.name)
58
+ const baseAssetName = base.name
59
59
 
60
60
  const smallTxAmount = base.currency.defaultUnit('0.00005')
61
61
  const accountReserve = base.currency.defaultUnit(
@@ -152,6 +152,7 @@ export const createSolanaAssetFactory =
152
152
 
153
153
  const getFeeAsync = getFeeAsyncFactory({ api: serverApi })
154
154
 
155
+ const sendValidations = sendValidationsFactory({ api: serverApi, assetName: baseAssetName })
155
156
  const api = {
156
157
  getActivityTxs,
157
158
  addressHasHistory: (...args) => serverApi.getAccountInfo(...args).then((acc) => !!acc),
@@ -1,126 +1,181 @@
1
+ import { memoizeLruCache } from '@exodus/asset-lib'
1
2
  import { t } from '@exodus/i18n-dummy'
2
3
  import sendValidationModel from '@exodus/send-validation-model'
4
+ import ms from 'ms'
3
5
 
4
6
  const { createValidator, FIELDS, PRIORITY_LEVELS, VALIDATION_TYPES } = sendValidationModel
5
7
 
6
- // cannot send SOL to token Address
7
- const solanaAddressTypeValidator = createValidator({
8
- id: 'WRONG_ADDRESS_TYPE',
9
- type: VALIDATION_TYPES.ERROR,
10
- field: FIELDS.ADDRESS,
11
-
12
- isValid: ({ addressDetails }) => addressDetails && addressDetails.addressType !== 'token',
13
-
14
- priority: PRIORITY_LEVELS.BASE,
15
-
16
- shouldValidate: ({ asset }) => ['solana'].includes(asset.name),
17
- getMessage: () => t('Destination address is for a different token type.'),
18
- })
19
-
20
- // cannot send token X to a different target account address (token Y)
21
- const solanaMintAddressValidator = createValidator({
22
- id: 'ADDRESS_MINT_MISMATCH',
23
- type: VALIDATION_TYPES.ERROR,
24
- shouldValidate: ({ asset }) => ['SOLANA_TOKEN'].includes(asset.assetType),
25
-
26
- isValid: async ({ asset, addressDetails }) =>
27
- !addressDetails.targetMint || asset.mintAddress === addressDetails.targetMint,
28
- priority: PRIORITY_LEVELS.MIDDLE,
29
- getMessage: ({ asset }) =>
30
- t(`Destination Wallet is not a ${asset.baseAsset.displayName} ${asset.displayTicker} address.`),
31
- field: FIELDS.ADDRESS,
32
- })
33
-
34
- const solanaAddressValidator = createValidator({
35
- id: 'SOLANA_ADDRESS',
36
- type: VALIDATION_TYPES.ERROR,
37
- shouldValidate: ({ asset }) => asset.name === 'solana',
38
- isValid: async ({ addressDetails }) => {
39
- return addressDetails.addressType !== 'token'
40
- },
41
- priority: PRIORITY_LEVELS.MIDDLE,
42
- getMessage: () => t(`The Solana network doesn't allow sending SOL to a Token Account address.`),
43
- field: FIELDS.ADDRESS,
44
- })
45
-
46
- const solanaRentExemptAmountValidator = createValidator({
47
- id: 'SOL_RENT_EXEMPT_AMOUNT',
48
- type: VALIDATION_TYPES.ERROR,
49
- shouldValidate: ({ asset, sendAmount }) =>
50
- sendAmount && (asset.assetType === 'SOLANA_TOKEN' || asset.name === 'solana'),
51
- isValid: async ({ asset, destinationAddress, sendAmount, baseAssetBalance, feeAmount }) => {
52
- if (!destinationAddress || !sendAmount || sendAmount.isZero) {
53
- return true
54
- }
55
-
56
- const serverApi = asset.baseAsset.serverApi
57
- const rentExemptValue = await serverApi.getRentExemptionMinAmount(destinationAddress)
58
- const rentExemptAmount = asset.baseAsset.currency.baseUnit(rentExemptValue)
59
-
60
- // differentiate between SOL and Solana token
61
- let isEnoughForRent
62
- if (asset.name === asset.baseAsset.name) {
63
- // sending SOL
64
- isEnoughForRent = sendAmount.gte(rentExemptAmount)
65
- } else {
66
- // sending token
67
- isEnoughForRent = baseAssetBalance
68
- .sub(feeAmount || asset.feeAsset.currency.ZERO)
69
- .gte(rentExemptAmount)
70
- }
71
-
72
- return isEnoughForRent
73
- },
74
- priority: PRIORITY_LEVELS.MIDDLE,
75
-
76
- getMessage: () => t(`Amount too low. Send at least 0.002 SOL to cover network fees.`), // hardcoded rent exempt amount, will be refactored once we have a better solution to return async calls
77
-
78
- field: FIELDS.ADDRESS,
79
- })
80
-
81
- const solanaRentExemptAmountSenderValidator = {
82
- id: 'SOL_RENT_EXEMPT_AMOUNT_SENDER',
83
- type: VALIDATION_TYPES.ERROR,
84
- priority: PRIORITY_LEVELS.MIDDLE,
85
- field: FIELDS.ADDRESS,
86
- shouldValidate: ({ asset, sendAmount, fees, spendableBalance, accountState }) =>
87
- sendAmount &&
88
- asset.name === 'solana' &&
89
- fees &&
90
- accountState?.rentExemptAmount &&
91
- spendableBalance,
92
-
93
- isValid: ({ accountState, asset, fromAddress, sendAmount, spendableBalance, fees }) => {
94
- const rentExemptAmount = accountState.rentExemptAmount
95
- const remaining = spendableBalance.sub(fees.fee).sub(sendAmount)
96
- return remaining.isZero || remaining.gte(rentExemptAmount)
97
- },
98
-
99
- getMessage: ({ accountState, asset }) =>
100
- t(
101
- `You can either leave a zero balance, which will close your SOL account, or maintain a minimum balance of ${accountState.rentExemptAmount.toDefaultString()} ${asset.displayTicker} to keep it active.`
102
- ),
8
+ const sendValidationsFactory = ({ api, assetName, assetClientInterface }) => {
9
+ const getAccountInfoCached = memoizeLruCache(
10
+ async (destinationAddress) => {
11
+ const [addressType, targetMint] = await Promise.all([
12
+ api.getAddressType(destinationAddress),
13
+ api.getAddressMint(destinationAddress),
14
+ ])
15
+ return {
16
+ addressType, // token, solana, null (never initialized)
17
+ targetMint, // null if it's a SOL address
18
+ }
19
+ },
20
+ (destinationAddress) => destinationAddress,
21
+ { maxAge: ms('60s') }
22
+ )
23
+
24
+ // cannot send SOL to token Address
25
+ const solanaAddressTypeValidator = createValidator({
26
+ id: 'WRONG_ADDRESS_TYPE',
27
+ type: VALIDATION_TYPES.ERROR,
28
+ field: FIELDS.ADDRESS,
29
+ priority: PRIORITY_LEVELS.BASE,
30
+ validateAndGetMessage: async ({ asset, destinationAddress }) => {
31
+ if (asset.name !== assetName || !destinationAddress) {
32
+ return
33
+ }
34
+
35
+ const addressDetails = await getAccountInfoCached(destinationAddress)
36
+ if (!addressDetails || addressDetails.addressType !== 'token') {
37
+ return
38
+ }
39
+
40
+ return t('Destination address is for a different token type.')
41
+ },
42
+ })
43
+
44
+ // cannot send token X to a different target account address (token Y)
45
+ const solanaMintAddressValidator = createValidator({
46
+ id: 'ADDRESS_MINT_MISMATCH',
47
+ type: VALIDATION_TYPES.ERROR,
48
+ priority: PRIORITY_LEVELS.MIDDLE,
49
+ field: FIELDS.ADDRESS,
50
+ validateAndGetMessage: async ({ asset, destinationAddress }) => {
51
+ if (asset.assetType !== 'SOLANA_TOKEN' || !destinationAddress) {
52
+ return
53
+ }
54
+
55
+ const addressDetails = await getAccountInfoCached(destinationAddress)
56
+ if (!addressDetails) {
57
+ return
58
+ }
59
+
60
+ const isMismatch =
61
+ addressDetails.targetMint && asset.mintAddress !== addressDetails.targetMint
62
+ if (isMismatch) {
63
+ return t(
64
+ `Destination Wallet is not a ${asset.baseAsset.displayName} ${asset.displayTicker} address.`
65
+ )
66
+ }
67
+ },
68
+ })
69
+
70
+ const solanaAddressValidator = createValidator({
71
+ id: 'SOLANA_ADDRESS',
72
+ type: VALIDATION_TYPES.ERROR,
73
+ priority: PRIORITY_LEVELS.MIDDLE,
74
+ field: FIELDS.ADDRESS,
75
+ validateAndGetMessage: async ({ asset, destinationAddress }) => {
76
+ if (asset.name !== assetName || !destinationAddress) {
77
+ return
78
+ }
79
+
80
+ const addressDetails = await getAccountInfoCached(destinationAddress)
81
+ if (addressDetails.addressType === 'token') {
82
+ return t(`The Solana network doesn't allow sending SOL to a Token Account address.`)
83
+ }
84
+ },
85
+ })
86
+
87
+ const solanaRentExemptAmountValidator = createValidator({
88
+ id: 'SOL_RENT_EXEMPT_AMOUNT',
89
+ type: VALIDATION_TYPES.ERROR,
90
+ shouldValidate: ({ asset, sendAmount }) => sendAmount,
91
+ isValid: async ({ asset, destinationAddress, sendAmount, baseAssetBalance, feeAmount }) => {
92
+ if (!destinationAddress || !sendAmount || sendAmount.isZero) {
93
+ return true
94
+ }
95
+
96
+ const rentExemptValue = await api.getRentExemptionMinAmount(destinationAddress)
97
+ const rentExemptAmount = asset.baseAsset.currency.baseUnit(rentExemptValue)
98
+
99
+ // differentiate between SOL and Solana token
100
+ let isEnoughForRent
101
+ if (asset.name === asset.baseAsset.name) {
102
+ // sending SOL
103
+ isEnoughForRent = sendAmount.gte(rentExemptAmount)
104
+ } else {
105
+ // sending token
106
+ isEnoughForRent = baseAssetBalance
107
+ .sub(feeAmount || asset.feeAsset.currency.ZERO)
108
+ .gte(rentExemptAmount)
109
+ }
110
+
111
+ return isEnoughForRent
112
+ },
113
+ priority: PRIORITY_LEVELS.MIDDLE,
114
+
115
+ getMessage: () => t(`Amount too low. Send at least 0.002 SOL to cover network fees.`), // hardcoded rent exempt amount, will be refactored once we have a better solution to return async calls
116
+
117
+ field: FIELDS.ADDRESS,
118
+ })
119
+
120
+ const solanaRentExemptAmountSenderValidator = {
121
+ id: 'SOL_RENT_EXEMPT_AMOUNT_SENDER',
122
+ type: VALIDATION_TYPES.ERROR,
123
+ priority: PRIORITY_LEVELS.MIDDLE,
124
+ field: FIELDS.ADDRESS,
125
+ validateAndGetMessage: async ({
126
+ asset,
127
+ sendAmount,
128
+ fees,
129
+ spendableBalance,
130
+ fromWalletAccount,
131
+ }) => {
132
+ if (
133
+ !sendAmount ||
134
+ asset.name !== assetName ||
135
+ !fees ||
136
+ !spendableBalance ||
137
+ !fromWalletAccount
138
+ ) {
139
+ return
140
+ }
141
+
142
+ const accountState = await assetClientInterface.getAccountState({
143
+ assetName,
144
+ walletAccount: fromWalletAccount,
145
+ })
146
+
147
+ if (!accountState?.rentExemptAmount) {
148
+ return
149
+ }
150
+
151
+ const rentExemptAmount = accountState.rentExemptAmount
152
+ const remaining = spendableBalance.sub(fees.fee).sub(sendAmount)
153
+
154
+ if (!remaining.isZero && remaining.lt(rentExemptAmount)) {
155
+ return t(
156
+ `You can either leave a zero balance, which will close your SOL account, or maintain a minimum balance of ${accountState.rentExemptAmount.toDefaultString()} ${asset.displayTicker} to keep it active.`
157
+ )
158
+ }
159
+ },
160
+ }
161
+
162
+ const solanaPayValidator = createValidator({
163
+ id: 'SOLANA_PAY',
164
+ type: VALIDATION_TYPES.ERROR,
165
+ shouldValidate: ({ solanaPayInfo }) => !!(solanaPayInfo?.recipient || solanaPayInfo?.link),
166
+ isValid: async ({ solanaPayInfo }) => !(solanaPayInfo.recipient || solanaPayInfo.link),
167
+ priority: PRIORITY_LEVELS.MIDDLE,
168
+ getMessage: () => t(`Please use Solana Pay feature to scan this QRCode.`),
169
+ field: FIELDS.ADDRESS,
170
+ })
171
+ return [
172
+ solanaAddressTypeValidator,
173
+ solanaAddressValidator,
174
+ solanaMintAddressValidator,
175
+ solanaRentExemptAmountValidator,
176
+ solanaPayValidator,
177
+ solanaRentExemptAmountSenderValidator,
178
+ ]
103
179
  }
104
180
 
105
- const solanaPayValidator = createValidator({
106
- id: 'SOLANA_PAY',
107
- type: VALIDATION_TYPES.ERROR,
108
- shouldValidate: ({ solanaPayInfo }) => {
109
- return !!(solanaPayInfo?.recipient || solanaPayInfo?.link)
110
- },
111
- isValid: async ({ solanaPayInfo }) => {
112
- return !(solanaPayInfo.recipient || solanaPayInfo.link)
113
- },
114
- priority: PRIORITY_LEVELS.MIDDLE,
115
- getMessage: () => t(`Please use Solana Pay feature to scan this QRCode.`),
116
- field: FIELDS.ADDRESS,
117
- })
118
-
119
- export default [
120
- solanaAddressTypeValidator,
121
- solanaAddressValidator,
122
- solanaMintAddressValidator,
123
- solanaRentExemptAmountValidator,
124
- solanaPayValidator,
125
- solanaRentExemptAmountSenderValidator,
126
- ]
181
+ export default sendValidationsFactory