@exodus/solana-lib 3.10.1 → 3.11.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/CHANGELOG.md CHANGED
@@ -3,6 +3,16 @@
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.11.0](https://github.com/ExodusMovement/assets/compare/@exodus/solana-lib@3.10.1...@exodus/solana-lib@3.11.0) (2025-04-11)
7
+
8
+
9
+ ### Features
10
+
11
+
12
+ * feat(solana): generalize verify-only-fee-payer-changed (#5434)
13
+
14
+
15
+
6
16
  ## [3.10.1](https://github.com/ExodusMovement/assets/compare/@exodus/solana-lib@3.10.0...@exodus/solana-lib@3.10.1) (2025-04-04)
7
17
 
8
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/solana-lib",
3
- "version": "3.10.1",
3
+ "version": "3.11.0",
4
4
  "description": "Solana utils, such as for cryptography, address encoding/decoding, transaction building, etc.",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -46,5 +46,5 @@
46
46
  "type": "git",
47
47
  "url": "git+https://github.com/ExodusMovement/assets.git"
48
48
  },
49
- "gitHead": "b4ed33112d03cda68ad156c3c455b4168f7abc16"
49
+ "gitHead": "0322939ba85d4dec4f754c6131b1a68b15aea919"
50
50
  }
@@ -1,6 +1,10 @@
1
1
  import lodash from 'lodash'
2
2
  import assert from 'minimalistic-assert'
3
3
 
4
+ import { TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID } from '../constants.js'
5
+ import { ASSOCIATED_TOKEN_PROGRAM_ID } from '../helpers/spl-token.js'
6
+ import { SYSVAR_RENT_PUBKEY } from '../vendor/index.js'
7
+
4
8
  export function verifyOnlyFeePayerChanged(beforeTx, afterTx) {
5
9
  assert(
6
10
  beforeTx.signatures.length + 1 === afterTx.signatures.length &&
@@ -18,9 +22,17 @@ export function verifyOnlyFeePayerChanged(beforeTx, afterTx) {
18
22
  beforeTx.message.accountKeys.length + 1 === afterTx.message.accountKeys.length,
19
23
  'Fee payer account key was not added'
20
24
  )
25
+ assert(
26
+ beforeTx.message.accountKeys.every(
27
+ (beforeAccountKey) => !lodash.isEqual(beforeAccountKey, afterTx.message.accountKeys[0])
28
+ ),
29
+ 'Fee payer account key was not added'
30
+ )
21
31
  beforeTx.message.accountKeys.forEach((accountKey, index) => {
22
32
  assert(
23
- lodash.isEqual(accountKey, afterTx.message.accountKeys[index + 1]),
33
+ afterTx.message.accountKeys.some((afterAccountKey) =>
34
+ lodash.isEqual(accountKey, afterAccountKey)
35
+ ),
24
36
  'Existing account keys do not match'
25
37
  )
26
38
  })
@@ -32,19 +44,43 @@ export function verifyOnlyFeePayerChanged(beforeTx, afterTx) {
32
44
 
33
45
  beforeTx.message.instructions.forEach(({ programIdIndex }, index) => {
34
46
  assert(
35
- programIdIndex + 1 === afterTx.message.instructions[index]?.programIdIndex,
47
+ lodash.isEqual(
48
+ beforeTx.message.accountKeys[beforeTx.message.instructions[index].programIdIndex],
49
+ afterTx.message.accountKeys[afterTx.message.instructions[index]?.programIdIndex]
50
+ ),
36
51
  'Instructions program ids were not updated'
37
52
  )
38
53
  })
39
54
 
40
55
  beforeTx.message.instructions.forEach(({ accounts }, index) => {
41
- assert(
42
- lodash.isEqual(
43
- accounts.map((id) => id + 1),
44
- afterTx.message.instructions[index].accounts
45
- ),
46
- 'Instructions account key indexes were not updated'
56
+ const programId =
57
+ beforeTx.message.accountKeys[beforeTx.message.instructions[index].programIdIndex].toString()
58
+ const isATAProgram =
59
+ programId === TOKEN_PROGRAM_ID.toString() ||
60
+ programId === TOKEN_2022_PROGRAM_ID.toString() ||
61
+ programId === ASSOCIATED_TOKEN_PROGRAM_ID.toString()
62
+ const accountsPublicKeys = accounts.map((id) => beforeTx.message.accountKeys[id])
63
+ const containsRentSysvar = accountsPublicKeys.some(
64
+ (publicKey) => publicKey.toString() === SYSVAR_RENT_PUBKEY.toString()
47
65
  )
66
+
67
+ const afterAccountsPublicKeys = afterTx.message.instructions[index].accounts.map(
68
+ (id) => afterTx.message.accountKeys[id]
69
+ )
70
+
71
+ if (containsRentSysvar && isATAProgram) {
72
+ const adjustedAccountsPublicKeys = [...accountsPublicKeys]
73
+ adjustedAccountsPublicKeys[0] = afterTx.message.accountKeys[0] // replace with the new fee payer
74
+ assert(
75
+ lodash.isEqual(adjustedAccountsPublicKeys, afterAccountsPublicKeys),
76
+ 'Instructions account key indexes were not updated'
77
+ )
78
+ } else {
79
+ assert(
80
+ lodash.isEqual(accountsPublicKeys, afterAccountsPublicKeys),
81
+ 'Instructions account key indexes were not updated'
82
+ )
83
+ }
48
84
  })
49
85
 
50
86
  beforeTx.message.instructions.forEach((instruction, index) => {