@exodus/solana-lib 3.3.0 → 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 +2 -2
- package/src/tx/sign-unsigned-tx.js +17 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/solana-lib",
|
|
3
|
-
"version": "3.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
|
}
|
|
@@ -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,20 +61,9 @@ 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
|
}
|