Skip to content

Commit 3ae6e3d

Browse files
committed
feat:
- made versionedTransaction optional - updated with latest master - applied format rules
1 parent 9465d0e commit 3ae6e3d

File tree

6 files changed

+16
-14
lines changed

6 files changed

+16
-14
lines changed

packages/wrapped-keys-lit-actions/src/lib/internal/solana/signTransaction.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,25 +89,27 @@ export async function signTransactionSolanaKey({
8989
broadcast,
9090
privateKey,
9191
unsignedTransaction,
92-
versionedTransaction
92+
versionedTransaction,
9393
}: {
9494
broadcast: boolean;
9595
privateKey: string;
9696
unsignedTransaction: UnsignedTransaction;
97-
versionedTransaction: boolean
97+
versionedTransaction?: boolean;
9898
}) {
9999
// Be sure you call validateUnsignedTransaction(unsignedTransaction); before calling this method!
100100

101101
const solanaKeyPair = Keypair.fromSecretKey(Buffer.from(privateKey, 'hex'));
102102

103-
let transaction
104-
let signature
103+
let transaction;
104+
let signature;
105105
if (versionedTransaction) {
106-
const swapTransactionBuf = Buffer.from(unsignedTransaction.serializedTransaction, 'base64');
106+
const swapTransactionBuf = Buffer.from(
107+
unsignedTransaction.serializedTransaction,
108+
'base64'
109+
);
107110
transaction = VersionedTransaction.deserialize(swapTransactionBuf);
108111
signature = signVersionedTransaction({ transaction, solanaKeyPair });
109112
} else {
110-
111113
transaction = Transaction.from(
112114
Buffer.from(unsignedTransaction.serializedTransaction, 'base64')
113115
);

packages/wrapped-keys-lit-actions/src/lib/raw-action-functions/solana/signTransactionWithEncryptedSolanaKey.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export interface SignTransactionWithEncryptedSolanaKeyParams {
1212
dataToEncryptHash: string; // The hash of the data to encrypt
1313
unsignedTransaction: UnsignedTransaction;
1414
broadcast: boolean; // Flag to determine if the transaction should be broadcasted
15-
versionedTransaction: boolean; // Flag to determine if the transaction is a versioned one or a legacy one
15+
versionedTransaction?: boolean; // Flag to determine if the transaction is a versioned one or a legacy one
1616
}
1717

1818
/**
@@ -29,7 +29,7 @@ export async function signTransactionWithEncryptedSolanaKey({
2929
dataToEncryptHash,
3030
unsignedTransaction,
3131
broadcast,
32-
versionedTransaction
32+
versionedTransaction,
3333
}: SignTransactionWithEncryptedSolanaKeyParams): Promise<string> {
3434
validateUnsignedTransaction(unsignedTransaction);
3535

@@ -43,6 +43,6 @@ export async function signTransactionWithEncryptedSolanaKey({
4343
broadcast,
4444
privateKey,
4545
unsignedTransaction,
46-
versionedTransaction
46+
versionedTransaction,
4747
});
4848
}

packages/wrapped-keys-lit-actions/src/lib/self-executing-actions/solana/signTransactionWithEncryptedSolanaKey.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ declare const versionedTransaction: SignTransactionWithEncryptedSolanaKeyParams[
2121
dataToEncryptHash,
2222
unsignedTransaction,
2323
broadcast,
24-
versionedTransaction
24+
versionedTransaction,
2525
})
2626
))();

packages/wrapped-keys/src/lib/api/sign-transaction-with-encrypted-key.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { SignTransactionWithEncryptedKeyParams } from '../types';
1111
/**
1212
* Signs a transaction inside the Lit Action using the previously persisted wrapped key associated with the current LIT PK.
1313
* This method fetches the encrypted key from the wrapped keys service, then executes a Lit Action that decrypts the key inside the LIT action and uses
14-
* the decrypted key to sign the provided transaction
14+
* the decrypted key to sign the provided transaction
1515
* use `versionedTransaction: true` to sign a versioned transaction and `false` for a legacy one
1616
* Optionally, if you pass `broadcast: true`, the LIT action will also submit the signed transaction to the associated RPC endpoint on your behalf
1717
*

packages/wrapped-keys/src/lib/lit-actions-client/sign-transaction.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export async function signTransactionWithLitAction({
3333
pkpSessionSigs,
3434
storedKeyMetadata: { ciphertext, dataToEncryptHash, pkpAddress },
3535
unsignedTransaction,
36-
versionedTransaction
36+
versionedTransaction,
3737
}: SignTransactionWithLitActionParams): Promise<string> {
3838
const result = await litNodeClient.executeJs({
3939
sessionSigs: pkpSessionSigs,
@@ -46,7 +46,7 @@ export async function signTransactionWithLitAction({
4646
unsignedTransaction,
4747
broadcast,
4848
accessControlConditions,
49-
versionedTransaction
49+
versionedTransaction,
5050
},
5151
ipfsOptions: {
5252
overwriteCode:

packages/wrapped-keys/src/lib/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ export interface SignTransactionParamsSupportedSolana
291291
extends SignTransactionParams {
292292
unsignedTransaction: SerializedTransaction;
293293
network: Extract<Network, 'solana'>;
294-
versionedTransaction: boolean;
294+
versionedTransaction?: boolean;
295295
}
296296

297297
/** @typedef SignTransactionWithEncryptedKeyParams

0 commit comments

Comments
 (0)