@exodus/solana-lib 3.6.0 → 3.7.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 +14 -0
- package/package.json +7 -8
- package/src/magiceden/coders.js +2 -2
- package/src/transaction.js +4 -7
- package/src/tx/prepare-for-signing.js +0 -9
- package/src/vendor/publickey.js +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,20 @@
|
|
|
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.7.0](https://github.com/ExodusMovement/assets/compare/@exodus/solana-lib@3.6.0...@exodus/solana-lib@3.7.0) (2024-10-10)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **solana-lib:** switch to exodus/crypto for hashes ([#3681](https://github.com/ExodusMovement/assets/issues/3681)) ([ad32b3a](https://github.com/ExodusMovement/assets/commit/ad32b3a2b83b23472db5898d2c6cf155a5af12fe))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* remove default signature requirement ([#4224](https://github.com/ExodusMovement/assets/issues/4224)) ([53ba3dd](https://github.com/ExodusMovement/assets/commit/53ba3ddd84d796608612ecd064ee7270365bf4bc))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
6
20
|
## [3.6.0](https://github.com/ExodusMovement/assets/compare/@exodus/solana-lib@3.5.1...@exodus/solana-lib@3.6.0) (2024-09-11)
|
|
7
21
|
|
|
8
22
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/solana-lib",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.7.0",
|
|
4
4
|
"description": "Exodus internal Solana low-level library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -22,20 +22,19 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@exodus/asset-lib": "^5.0.0",
|
|
24
24
|
"@exodus/buffer-layout": "^1.2.0-exodus1",
|
|
25
|
+
"@exodus/crypto": "^1.0.0-rc.7",
|
|
25
26
|
"@exodus/currency": "^5.0.2",
|
|
26
|
-
"@exodus/key-utils": "^3.
|
|
27
|
-
"@exodus/solana-web3.js": "^1.63.1-exodus.9-
|
|
27
|
+
"@exodus/key-utils": "^3.7.0",
|
|
28
|
+
"@exodus/solana-web3.js": "^1.63.1-exodus.9-rc4",
|
|
28
29
|
"bn.js": "^5.2.1",
|
|
29
30
|
"borsh": "^0.7.0",
|
|
30
31
|
"bs58": "^4.0.1",
|
|
31
|
-
"create-hash": "^1.1.3",
|
|
32
|
-
"lodash": "^4.17.11",
|
|
33
32
|
"minimalistic-assert": "^1.0.1",
|
|
34
33
|
"tweetnacl": "^1.0.3"
|
|
35
34
|
},
|
|
36
35
|
"devDependencies": {
|
|
37
|
-
"@exodus/key-identifier": "^1.
|
|
38
|
-
"@exodus/keychain": "^
|
|
36
|
+
"@exodus/key-identifier": "^1.3.0",
|
|
37
|
+
"@exodus/keychain": "^7.3.0",
|
|
39
38
|
"@exodus/solana-meta": "^2.0.0",
|
|
40
39
|
"bip39": "^2.6.0"
|
|
41
40
|
},
|
|
@@ -47,5 +46,5 @@
|
|
|
47
46
|
"type": "git",
|
|
48
47
|
"url": "git+https://github.com/ExodusMovement/assets.git"
|
|
49
48
|
},
|
|
50
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "146e3e7f2b0699aa009baddf2b34ea122af2d3fc"
|
|
51
50
|
}
|
package/src/magiceden/coders.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as BufferLayout from '@exodus/buffer-layout'
|
|
2
|
-
import
|
|
2
|
+
import { hashSync } from '@exodus/crypto/hash'
|
|
3
3
|
|
|
4
4
|
import { bnAmountU64, publicKey } from '../vendor/utils/layout.js'
|
|
5
5
|
|
|
@@ -21,7 +21,7 @@ const idl = {
|
|
|
21
21
|
export function sighash(nameSpace, ixName) {
|
|
22
22
|
const preimage = `${nameSpace}:${ixName}`
|
|
23
23
|
|
|
24
|
-
return
|
|
24
|
+
return hashSync('sha256', preimage).slice(0, 8)
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
export function encodeData(name, args = {}) {
|
package/src/transaction.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import BN from 'bn.js'
|
|
2
2
|
import bs58 from 'bs58'
|
|
3
|
-
import lodash from 'lodash'
|
|
4
3
|
import assert from 'minimalistic-assert'
|
|
5
4
|
|
|
6
5
|
import { MEMO_PROGRAM_ID, SEED, STAKE_PROGRAM_ID, TOKEN_2022_PROGRAM_ID } from './constants.js'
|
|
@@ -25,8 +24,6 @@ import {
|
|
|
25
24
|
TransactionInstruction,
|
|
26
25
|
} from './vendor/index.js'
|
|
27
26
|
|
|
28
|
-
const { get } = lodash
|
|
29
|
-
|
|
30
27
|
class Tx {
|
|
31
28
|
constructor({
|
|
32
29
|
from,
|
|
@@ -441,19 +438,19 @@ class Tx {
|
|
|
441
438
|
switch (type) {
|
|
442
439
|
case 'Delegate':
|
|
443
440
|
info.type = 'Delegate'
|
|
444
|
-
info.stakeAddress =
|
|
445
|
-
info.validator =
|
|
441
|
+
info.stakeAddress = (ix?.keys?.[0]?.pubkey ?? '').toString()
|
|
442
|
+
info.validator = (ix?.keys?.[1]?.pubkey ?? '').toString() // pool
|
|
446
443
|
return info
|
|
447
444
|
|
|
448
445
|
case 'Deactivate': // undelegate
|
|
449
446
|
info.type = 'Deactivate'
|
|
450
|
-
info.stakeAddress =
|
|
447
|
+
info.stakeAddress = (ix?.keys?.[0]?.pubkey ?? '').toString()
|
|
451
448
|
// TODO: could have multiple addresses undelegating
|
|
452
449
|
return info
|
|
453
450
|
|
|
454
451
|
case 'Withdraw':
|
|
455
452
|
info.type = 'Withdraw'
|
|
456
|
-
info.stakeAddress =
|
|
453
|
+
info.stakeAddress = (ix?.keys?.[0]?.pubkey ?? '').toString()
|
|
457
454
|
const { lamports, toPubkey } = StakeInstruction.decodeWithdraw(ix)
|
|
458
455
|
info.to = toPubkey.toString()
|
|
459
456
|
info.lamports = lamports.toString()
|
|
@@ -121,15 +121,6 @@ const createTx = ({ txData, method, from }) => {
|
|
|
121
121
|
tx.feePayer = publicKey
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
if (tx.signatures.length !== tx.compileMessage().header.numRequiredSignatures) {
|
|
125
|
-
// Some transactions that we construct internally are technically not complete.
|
|
126
|
-
// They don't contain the empty signature slot for the public key.
|
|
127
|
-
tx.signatures.push({
|
|
128
|
-
publicKey,
|
|
129
|
-
signature: null,
|
|
130
|
-
})
|
|
131
|
-
}
|
|
132
|
-
|
|
133
124
|
return tx
|
|
134
125
|
}
|
|
135
126
|
|
package/src/vendor/publickey.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { hashSync } from '@exodus/crypto/hash'
|
|
1
2
|
import BN from 'bn.js'
|
|
2
3
|
import bs58 from 'bs58'
|
|
3
|
-
import createHash from 'create-hash'
|
|
4
4
|
import nacl from 'tweetnacl'
|
|
5
5
|
|
|
6
6
|
// $FlowFixMe
|
|
@@ -124,8 +124,8 @@ export class PublicKey {
|
|
|
124
124
|
Buffer.from(seed),
|
|
125
125
|
programId.toBuffer(),
|
|
126
126
|
])
|
|
127
|
-
const hash =
|
|
128
|
-
return new PublicKey(
|
|
127
|
+
const hash = hashSync('sha256', buffer)
|
|
128
|
+
return new PublicKey(hash)
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
/**
|
|
@@ -141,7 +141,7 @@ export class PublicKey {
|
|
|
141
141
|
buffer = Buffer.concat([buffer, Buffer.from(seed)])
|
|
142
142
|
})
|
|
143
143
|
buffer = Buffer.concat([buffer, programId.toBuffer(), Buffer.from('ProgramDerivedAddress')])
|
|
144
|
-
const hash =
|
|
144
|
+
const hash = hashSync('sha256', buffer, 'hex')
|
|
145
145
|
const publicKeyBytes = new BN(hash, 16).toArray(null, 32)
|
|
146
146
|
if (isOnCurve(publicKeyBytes)) {
|
|
147
147
|
throw new Error('Invalid seeds, address must fall off the curve')
|