Skip to content

Commit

Permalink
feat(wrapped-keys): LIT-3995 - Add sign transaction capability to `ba…
Browse files Browse the repository at this point in the history
…tchGeneratePrivateKeys` api
  • Loading branch information
MaximusHaximus committed Oct 22, 2024
1 parent 31d3cea commit 250aff5
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
10 changes: 8 additions & 2 deletions packages/wrapped-keys/src/lib/api/batch-generate-private-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,16 @@ export async function batchGeneratePrivateKeys(
} = actionResult;
const id = ids[ndx]; // Result of writes is in same order as provided

const signature = actionResult.signMessage?.signature;
const messageSignature = actionResult.signMessage?.signature;
const transactionSignature = actionResult.signTransaction?.signature;

return {
...(signature ? { signMessage: { signature } } : {}),
...(messageSignature
? { signMessage: { signature: messageSignature } }
: {}),
...(transactionSignature
? { signTransaction: { signature: transactionSignature } }
: {}),
generateEncryptedPrivateKey: {
memo: memo,
id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ interface GeneratePrivateKeyLitActionResult {
interface BatchGeneratePrivateKeysWithLitActionResult {
network: Network;
signMessage?: { signature: string };
signTransaction?: { signature: string };
generateEncryptedPrivateKey: GeneratePrivateKeyLitActionResult;
}

Expand Down
28 changes: 24 additions & 4 deletions packages/wrapped-keys/src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,33 @@ export interface ExportPrivateKeyResult {
id: string;
}

/** @typedef GeneratePrivateKeyAction
* @extends ApiParamsSupportedNetworks
*/
export type GeneratePrivateKeyAction = ApiParamsSupportedNetworks & {
export type GeneratePrivateKeyActionBase = ApiParamsSupportedNetworks & {
generateKeyParams: { memo: string };
signMessageParams?: { messageToSign: string | Uint8Array };
};

export type GeneratePrivateKeyActionSolana = GeneratePrivateKeyActionBase & {
network: Extract<Network, 'solana'>;
signTransactionParams: {
unsignedTransaction: SerializedTransaction;
broadcast?: boolean;
};
};

export type GeneratePrivateKeyActionEthereum = GeneratePrivateKeyActionBase & {
network: Extract<Network, 'evm'>;
signTransactionParams: {
unsignedTransaction: EthereumLitTransaction;
broadcast?: boolean;
};
};

/** @typedef GeneratePrivateKeyAction
*/
export type GeneratePrivateKeyAction =
| GeneratePrivateKeyActionSolana
| GeneratePrivateKeyActionEthereum;

/** @typedef BatchGeneratePrivateKeysParams
* @extends BaseApiParams
*/
Expand All @@ -180,6 +199,7 @@ export type BatchGeneratePrivateKeysParams = BaseApiParams & {
export interface BatchGeneratePrivateKeysActionResult {
generateEncryptedPrivateKey: GeneratePrivateKeyResult & { memo: string };
signMessage?: { signature: string };
signTransaction?: { signature: string };
}

export interface BatchGeneratePrivateKeysResult {
Expand Down

0 comments on commit 250aff5

Please sign in to comment.