@exodus/solana-lib 1.6.0 → 1.6.3
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/package.json +3 -4
- package/src/fee-data/solana.js +2 -2
- package/src/keypair.js +2 -1
- package/src/tx/build-raw-transaction.js +1 -1
- package/src/tx/decode-tx-instructions.js +1 -1
- package/src/tx/parse-unsigned-tx.js +1 -3
- package/src/tx/sign-unsigned-tx.js +3 -9
- package/src/tx/simulate-and-sign-tx.js +8 -6
- package/src/vendor/message.js +4 -0
- package/src/vendor/transaction.js +0 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/solana-lib",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.3",
|
|
4
4
|
"description": "Exodus internal Solana low-level library",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"files": [
|
|
@@ -14,12 +14,11 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@exodus/asset-lib": "^3.7.1",
|
|
17
|
-
"@exodus/assets": "^8.0.74",
|
|
18
17
|
"@exodus/buffer-layout": "^1.2.0-exodus1",
|
|
19
18
|
"@exodus/models": "^8.10.4",
|
|
19
|
+
"@exodus/solana-meta": "^1.0.2",
|
|
20
20
|
"@exodus/solana-spl-token": "0.1.8-exodus.1",
|
|
21
21
|
"@project-serum/serum": "0.13.64",
|
|
22
|
-
"@solana/web3.js": "1.31.0",
|
|
23
22
|
"bn.js": "^4.11.0",
|
|
24
23
|
"borsh": "^0.7.0",
|
|
25
24
|
"bs58": "^4.0.1",
|
|
@@ -27,5 +26,5 @@
|
|
|
27
26
|
"lodash": "^4.17.11",
|
|
28
27
|
"tweetnacl": "^1.0.3"
|
|
29
28
|
},
|
|
30
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "a7b27e4f299057c16dda446f006fa61a945a6cbf"
|
|
31
30
|
}
|
package/src/fee-data/solana.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FeeData } from '@exodus/asset-lib'
|
|
2
|
-
import
|
|
2
|
+
import { asset } from '@exodus/solana-meta'
|
|
3
3
|
|
|
4
4
|
export default new FeeData({
|
|
5
5
|
config: {
|
|
@@ -7,5 +7,5 @@ export default new FeeData({
|
|
|
7
7
|
fuelThreshold: '0.000015 SOL',
|
|
8
8
|
},
|
|
9
9
|
mainKey: 'fee',
|
|
10
|
-
currency:
|
|
10
|
+
currency: asset.currency,
|
|
11
11
|
})
|
package/src/keypair.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import nacl from 'tweetnacl'
|
|
3
|
+
import { PublicKey } from './vendor'
|
|
3
4
|
|
|
4
5
|
export function getKeyPairFromPrivateKey(privateKey: string | Buffer): Object {
|
|
5
6
|
const { publicKey, secretKey } = nacl.sign.keyPair.fromSeed(
|
|
@@ -17,7 +18,7 @@ export function generateKeyPair() {
|
|
|
17
18
|
|
|
18
19
|
return {
|
|
19
20
|
secretKey: Buffer.from(secretKey, 'hex'), // secretKey
|
|
20
|
-
publicKey:
|
|
21
|
+
publicKey: new PublicKey(publicKey),
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as nacl from 'tweetnacl'
|
|
2
|
-
import { PACKET_DATA_SIZE } from '
|
|
2
|
+
import { PACKET_DATA_SIZE } from '../vendor'
|
|
3
3
|
|
|
4
4
|
// Copied from:
|
|
5
5
|
// https://github.com/solana-labs/solana-web3.js/blob/42612c936d8d4ddbcb09dbb73db9e1aeaf6d8764/src/util/shortvec-encoding.ts#L15-L28.
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { asset } from '@exodus/solana-meta'
|
|
2
2
|
import type { UnsignedTransaction, ParsedTransaction } from '@exodus/models/lib/types'
|
|
3
3
|
|
|
4
4
|
export function parseUnsignedTx(unsignedTx: UnsignedTransaction): ParsedTransaction {
|
|
5
|
-
const asset = assets.solana
|
|
6
5
|
const {
|
|
7
6
|
from,
|
|
8
7
|
to,
|
|
@@ -32,7 +31,6 @@ export function parseUnsignedTx(unsignedTx: UnsignedTransaction): ParsedTransact
|
|
|
32
31
|
const amount = asset.currency.baseUnit(txData.amount)
|
|
33
32
|
const fee = asset.currency.baseUnit(txData.fee)
|
|
34
33
|
return {
|
|
35
|
-
asset,
|
|
36
34
|
from: [from],
|
|
37
35
|
to,
|
|
38
36
|
amount,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import assets from '@exodus/assets'
|
|
1
|
+
import { asset } from '@exodus/solana-meta'
|
|
3
2
|
import type { UnsignedTransaction, SignedTransaction } from '@exodus/models/lib/types'
|
|
4
3
|
|
|
5
4
|
import { Transaction, getTransactionStrategy } from '../'
|
|
@@ -14,17 +13,12 @@ export function signUnsignedTx(
|
|
|
14
13
|
return _signTx({ tx: transaction, privateKey })
|
|
15
14
|
}
|
|
16
15
|
|
|
17
|
-
const asset = assets.solana
|
|
18
16
|
const address = from
|
|
19
17
|
const amount = unitAmount ? asset.currency.baseUnit(unitAmount).toNumber() : unitAmount
|
|
20
18
|
|
|
21
|
-
const
|
|
22
|
-
asset,
|
|
23
|
-
address,
|
|
24
|
-
amount,
|
|
25
|
-
})
|
|
19
|
+
const txData = { ...unsignedTx.txData, address, amount }
|
|
26
20
|
|
|
27
|
-
const tx = createTx({ txData
|
|
21
|
+
const tx = createTx({ txData, method })
|
|
28
22
|
return _signTx({ tx, privateKey })
|
|
29
23
|
}
|
|
30
24
|
|
|
@@ -12,15 +12,17 @@ export function getTransactionSimulationParams(transactionMessage) {
|
|
|
12
12
|
commitment: 'confirmed',
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
const accountAddresses = new Set()
|
|
16
|
+
|
|
16
17
|
if (!transactionMessage.accountKeys) {
|
|
17
18
|
const programIds = new Set(
|
|
18
19
|
transactionMessage.instructions.map((instruction) => instruction.programId.toString())
|
|
19
20
|
)
|
|
21
|
+
|
|
20
22
|
transactionMessage.instructions.forEach((instruction) => {
|
|
21
23
|
instruction.keys.forEach((key) => {
|
|
22
24
|
if (!programIds.has(key.pubkey.toString())) {
|
|
23
|
-
accountAddresses.
|
|
25
|
+
accountAddresses.add(key.pubkey.toString())
|
|
24
26
|
}
|
|
25
27
|
})
|
|
26
28
|
})
|
|
@@ -35,19 +37,19 @@ export function getTransactionSimulationParams(transactionMessage) {
|
|
|
35
37
|
)
|
|
36
38
|
}
|
|
37
39
|
|
|
38
|
-
|
|
40
|
+
transactionMessage.accountKeys
|
|
39
41
|
.filter((_, index) => !indexToProgramIds.has(index))
|
|
40
|
-
.
|
|
42
|
+
.forEach((account) => accountAddresses.add(account.toString()))
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
config['accounts'] = {
|
|
44
46
|
encoding: 'base64',
|
|
45
|
-
addresses: accountAddresses,
|
|
47
|
+
addresses: Array.from(accountAddresses),
|
|
46
48
|
}
|
|
47
49
|
|
|
48
50
|
return {
|
|
49
51
|
config,
|
|
50
|
-
accountAddresses,
|
|
52
|
+
accountAddresses: Array.from(accountAddresses),
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
55
|
|
package/src/vendor/message.js
CHANGED
|
@@ -72,6 +72,10 @@ export class Message {
|
|
|
72
72
|
this.instructions = args.instructions
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
isAccountSigner(index: number): boolean {
|
|
76
|
+
return index < this.header.numRequiredSignatures
|
|
77
|
+
}
|
|
78
|
+
|
|
75
79
|
isAccountWritable(index: number): boolean {
|
|
76
80
|
return (
|
|
77
81
|
index < this.header.numRequiredSignatures - this.header.numReadonlySignedAccounts ||
|
|
@@ -356,12 +356,6 @@ export class Transaction {
|
|
|
356
356
|
}
|
|
357
357
|
})
|
|
358
358
|
|
|
359
|
-
if (numRequiredSignatures !== this.signatures.length) {
|
|
360
|
-
throw new Error(
|
|
361
|
-
`missing signer(s) - required signatures: ${numRequiredSignatures}, got ${this.signatures.length}`
|
|
362
|
-
)
|
|
363
|
-
}
|
|
364
|
-
|
|
365
359
|
const accountKeys = signedKeys.concat(unsignedKeys)
|
|
366
360
|
const instructions: CompiledInstruction[] = this.instructions.map((instruction) => {
|
|
367
361
|
const { data, programId } = instruction
|