@exodus/solana-lib 3.2.2 → 3.3.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/solana-lib",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.1",
|
|
4
4
|
"description": "Exodus internal Solana low-level library",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"files": [
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"@solana/web3.js": "^1.90.0",
|
|
41
41
|
"bip39": "^2.6.0"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "45964c12e52066c643ee1b6c906eb898baad1088"
|
|
44
44
|
}
|
|
@@ -10,7 +10,7 @@ const signMessageWithSigner = async ({ signer, message }) => {
|
|
|
10
10
|
'expected signer with a sign method'
|
|
11
11
|
)
|
|
12
12
|
|
|
13
|
-
return signer.sign({ data: rawMessage })
|
|
13
|
+
return signer.sign({ data: rawMessage, signatureType: 'ed25519' })
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export default signMessageWithSigner
|
|
@@ -38,6 +38,21 @@ export async function signUnsignedTx(unsignedTx, privateKey) {
|
|
|
38
38
|
return extractTransaction({ tx })
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
// Some transactions that we construct internally are technically not complete.
|
|
42
|
+
// They don't contain the empty signature slot for the public key.
|
|
43
|
+
export const fillTransactionWithEmptySignatureSlot = ({ transaction, publicKey }) => {
|
|
44
|
+
const foundEmptySignatureSlot = transaction.signatures.find(({ publicKey: _publicKey }) =>
|
|
45
|
+
_publicKey.equals(publicKey)
|
|
46
|
+
)
|
|
47
|
+
if (!foundEmptySignatureSlot) {
|
|
48
|
+
// We could use `setSigners` but maybe this is more robust?
|
|
49
|
+
transaction.signatures.push({
|
|
50
|
+
publicKey,
|
|
51
|
+
signature: null,
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
41
56
|
// Signs plain tx.
|
|
42
57
|
const _signTx = async ({ tx, signer }) => {
|
|
43
58
|
const publicKey = new PublicKey(bs58.encode(Buffer.from(await signer.getPublicKey())))
|
|
@@ -46,32 +61,21 @@ const _signTx = async ({ tx, signer }) => {
|
|
|
46
61
|
// VersionedTransaction
|
|
47
62
|
return _signVersionedTransaction({ tx, signer, publicKey })
|
|
48
63
|
}
|
|
49
|
-
// Legacy Transactions
|
|
50
64
|
|
|
51
|
-
//
|
|
52
|
-
|
|
53
|
-
const foundEmptySignatureSlot = tx.signatures.find(({ publicKey: _publicKey }) =>
|
|
54
|
-
_publicKey.equals(publicKey)
|
|
55
|
-
)
|
|
56
|
-
if (!foundEmptySignatureSlot) {
|
|
57
|
-
// We could use `setSigners` but maybe this is more robust?
|
|
58
|
-
tx.signatures.push({
|
|
59
|
-
publicKey,
|
|
60
|
-
signature: null,
|
|
61
|
-
})
|
|
62
|
-
}
|
|
65
|
+
// Legacy Transactions
|
|
66
|
+
fillTransactionWithEmptySignatureSlot({ transaction: tx, publicKey })
|
|
63
67
|
|
|
64
68
|
return _signLegacyTransaction({ tx, signer, publicKey })
|
|
65
69
|
}
|
|
66
70
|
|
|
67
71
|
const _signVersionedTransaction = async ({ tx, signer, publicKey }) => {
|
|
68
72
|
const messageData = tx.message.serialize()
|
|
69
|
-
const signature = await signer.sign({ data: messageData })
|
|
73
|
+
const signature = await signer.sign({ data: messageData, signatureType: 'ed25519' })
|
|
70
74
|
tx.addSignature(publicKey, signature)
|
|
71
75
|
}
|
|
72
76
|
|
|
73
77
|
const _signLegacyTransaction = async ({ tx, signer, publicKey }) => {
|
|
74
78
|
const messageData = tx.compileMessage().serialize()
|
|
75
|
-
const signature = await signer.sign({ data: messageData })
|
|
79
|
+
const signature = await signer.sign({ data: messageData, signatureType: 'ed25519' })
|
|
76
80
|
tx.addSignature(publicKey, signature)
|
|
77
81
|
}
|