@exodus/solana-plugin 1.23.2 → 1.24.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 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.1](https://github.com/ExodusMovement/assets/compare/@exodus/solana-plugin@1.24.0...@exodus/solana-plugin@1.24.1) (2025-09-15)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+
12
+ * fix: integration tests of SOL, THETA, DOT (#6166)
13
+
14
+ * fix: use toMatchObject to ignore extra keys in actual reports (#6260)
15
+
16
+
17
+
18
+ ## [1.24.0](https://github.com/ExodusMovement/assets/compare/@exodus/solana-plugin@1.23.2...@exodus/solana-plugin@1.24.0) (2025-07-16)
19
+
20
+
21
+ ### Features
22
+
23
+
24
+ * feat: move send validation to each asset plugin (#6076)
25
+
26
+
27
+
6
28
  ## [1.23.2](https://github.com/ExodusMovement/assets/compare/@exodus/solana-plugin@1.23.1...@exodus/solana-plugin@1.23.2) (2025-06-25)
7
29
 
8
30
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/solana-plugin",
3
- "version": "1.23.2",
3
+ "version": "1.24.1",
4
4
  "description": "Solana plugin for Exodus SDK powered wallets.",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -21,8 +21,11 @@
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",
27
+ "@exodus/i18n-dummy": "^1.0.0",
28
+ "@exodus/send-validation-model": "^1.0.0",
26
29
  "@exodus/solana-api": "^3.20.3",
27
30
  "@exodus/solana-lib": "^3.11.2",
28
31
  "@exodus/solana-meta": "^2.3.1",
@@ -40,5 +43,5 @@
40
43
  "type": "git",
41
44
  "url": "git+https://github.com/ExodusMovement/assets.git"
42
45
  },
43
- "gitHead": "a5721f9708d787604715c4dba1f0ab16a683d7c4"
46
+ "gitHead": "4f019150ea10a3b3853bb351ebd8e55517277e46"
44
47
  }
@@ -24,6 +24,7 @@ import {
24
24
  import ms from 'ms'
25
25
 
26
26
  import { createGetBalanceForAddress } from './get-balance-for-address.js'
27
+ import sendValidationsFactory from './send-validations.js'
27
28
  import { createWeb3API } from './web3/index.js'
28
29
 
29
30
  const DEFAULT_ACCOUNT_RESERVE = 0
@@ -151,6 +152,7 @@ export const createSolanaAssetFactory =
151
152
 
152
153
  const getFeeAsync = getFeeAsyncFactory({ api: serverApi })
153
154
 
155
+ const sendValidations = sendValidationsFactory({ api: serverApi, assetName: baseName })
154
156
  const api = {
155
157
  getActivityTxs,
156
158
  addressHasHistory: (...args) => serverApi.getAccountInfo(...args).then((acc) => !!acc),
@@ -180,6 +182,7 @@ export const createSolanaAssetFactory =
180
182
  getFeeData: () => feeData,
181
183
  getSupportedPurposes: () => [44],
182
184
  getKeyIdentifier: createGetKeyIdentifier({ bip44, assetName: base.name }),
185
+ getSendValidations: () => sendValidations,
183
186
  getTokens: () =>
184
187
  Object.values(assets)
185
188
  .filter((asset) => asset.name !== base.name)
@@ -0,0 +1,181 @@
1
+ import { memoizeLruCache } from '@exodus/asset-lib'
2
+ import { t } from '@exodus/i18n-dummy'
3
+ import sendValidationModel from '@exodus/send-validation-model'
4
+ import ms from 'ms'
5
+
6
+ const { createValidator, FIELDS, PRIORITY_LEVELS, VALIDATION_TYPES } = sendValidationModel
7
+
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
+ ]
179
+ }
180
+
181
+ export default sendValidationsFactory