@exodus/solana-lib 1.7.1 → 1.7.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/solana-lib",
3
- "version": "1.7.1",
3
+ "version": "1.7.3",
4
4
  "description": "Exodus internal Solana low-level library",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -27,5 +27,5 @@
27
27
  "lodash": "^4.17.11",
28
28
  "tweetnacl": "^1.0.3"
29
29
  },
30
- "gitHead": "c0a8ca34924dc74d81ea0b339aa0909062c79d1a"
30
+ "gitHead": "ed1cf2465307952f91fac5fbfef36eaa59a3acaf"
31
31
  }
@@ -21,7 +21,7 @@ export function prepareForSigning(unsignedTx) {
21
21
 
22
22
  const txData = { ...unsignedTx.txData, address, amount }
23
23
 
24
- const { transaction } = createTx({ txData, method })
24
+ const transaction = createTx({ txData, method })
25
25
 
26
26
  if (!transaction.feePayer) {
27
27
  transaction.feePayer = new PublicKey(from)
@@ -174,7 +174,7 @@ const createTokenTransaction = ({
174
174
  tokenMintAddress,
175
175
  memo,
176
176
  reference,
177
- })
177
+ }).transaction
178
178
 
179
179
  const createCloseAccountTransaction = ({ account, programId, recentBlockhash, walletPublicKey }) =>
180
180
  Transaction.createCloseAccount({
@@ -34,8 +34,21 @@ const signWithHardwareWallet = async ({ tx, hardwareDevice, accountIndex }) => {
34
34
 
35
35
  const applySignatures = ({ tx, signatures }) => {
36
36
  if (isLegacyTransaction(tx)) {
37
- const publicKeys = signatures.map(({ publicKey }) => new PublicKey(publicKey))
38
- tx.setSigners(...publicKeys)
37
+ signatures.forEach(({ publicKey: publicKeyBuffer }) => {
38
+ const publicKey = new PublicKey(publicKeyBuffer)
39
+ // Some transactions that we construct internally are technically not complete.
40
+ // They don't contain the empty signature slot for the public key.
41
+ const foundEmptySignatureSlot = tx.signatures.find(({ publicKey: pubKey }) =>
42
+ pubKey.equals(publicKey)
43
+ )
44
+ if (!foundEmptySignatureSlot) {
45
+ // We could use `setSigners` but maybe this is more robust?
46
+ tx.signatures.push({
47
+ publicKey,
48
+ signature: null,
49
+ })
50
+ }
51
+ })
39
52
  }
40
53
 
41
54
  signatures.forEach(({ publicKey, signature }) => {
@@ -24,6 +24,23 @@ const _signTx = ({ tx, privateKey }) => {
24
24
  tx.sign([account])
25
25
  } else {
26
26
  // Legacy Transactions
27
- tx.sign(account)
27
+
28
+ // Some transactions that we construct internally are technically not complete.
29
+ // They don't contain the empty signature slot for the public key.
30
+ const foundEmptySignatureSlot = tx.signatures.find(({ publicKey }) =>
31
+ publicKey.equals(account.publicKey)
32
+ )
33
+ if (!foundEmptySignatureSlot) {
34
+ // We could use `setSigners` but maybe this is more robust?
35
+ tx.signatures.push({
36
+ publicKey: account.publicKey,
37
+ signature: null,
38
+ })
39
+ }
40
+
41
+ // We need to use `partialSign()` here because legacy `sign()` will
42
+ // delete all existing signatures which isn't great if we're
43
+ // signing a transaction that already has signatures.
44
+ tx.partialSign(account)
28
45
  }
29
46
  }