@exodus/solana-lib 3.10.0 → 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,26 @@
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
+
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)
17
+
18
+
19
+ ### Bug Fixes
20
+
21
+
22
+ * fix(solana): fee payer validation (#5387)
23
+
24
+
25
+
6
26
  ## [3.10.0](https://github.com/ExodusMovement/assets/compare/@exodus/solana-lib@3.9.5...@exodus/solana-lib@3.10.0) (2025-04-03)
7
27
 
8
28
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/solana-lib",
3
- "version": "3.10.0",
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": "59c4d4a4a7404eb915e4fa722a2afe01d1556046"
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()
65
+ )
66
+
67
+ const afterAccountsPublicKeys = afterTx.message.instructions[index].accounts.map(
68
+ (id) => afterTx.message.accountKeys[id]
47
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) => {
@@ -61,6 +97,10 @@ export function verifyOnlyFeePayerChanged(beforeTx, afterTx) {
61
97
  )
62
98
  })
63
99
 
100
+ afterTx.message.indexToProgramIds.forEach((value, key) => {
101
+ assert(afterTx.message.accountKeys[key] === value, 'IndexToProgramIds do not match accountKeys')
102
+ })
103
+
64
104
  assert(
65
105
  lodash.isEqual(
66
106
  {
@@ -85,12 +125,14 @@ export function verifyOnlyFeePayerChanged(beforeTx, afterTx) {
85
125
  header: { ...beforeTx.message.header, numRequiredSignatures: null },
86
126
  accountKeys: null,
87
127
  instructions: null,
128
+ indexToProgramIds: null,
88
129
  },
89
130
  {
90
131
  ...afterTx.message,
91
132
  header: { ...afterTx.message.header, numRequiredSignatures: null },
92
133
  accountKeys: null,
93
134
  instructions: null,
135
+ indexToProgramIds: null,
94
136
  }
95
137
  ),
96
138
  'Transactions do not match in some attributes'