Skip to content

Commit 45bbde7

Browse files
committed
chore: tidy up
1 parent e641523 commit 45bbde7

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

packages/wrapped-keys/src/lib/api/tria-batch-generate-private-keys.ts

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,20 @@ import { computeAddress } from 'ethers/lib/utils';
2121
import { SessionSigsMap } from '@lit-protocol/types';
2222

2323
/**
24-
* TODO: Document batch behaviour
25-
* @param { BatchGeneratePrivateKeysParams } params Parameters to use for generating keys and optionally signing messages
26-
*
27-
* @returns { Promise<BatchGeneratePrivateKeysResult> } - The generated keys and, optionally, signed messages
24+
* Generates a batch of private keys and optionally signs messages.
25+
*
26+
* @param {Object} params - Parameters for generating keys and signing messages.
27+
* @param {string} params.pkpPublicKey - The public key for the PKP (e.g., "0x123...").
28+
* @param {string} params.ipfsId - The IPFS ID (e.g., "Qm...").
29+
* @param {Object} params.authMethod - The authentication method.
30+
* @param {string} params.authMethod.authMethodType - The type of authentication method (e.g., "0x...").
31+
* @param {string} params.authMethod.accessToken - The access token (e.g., "eyJ...").
32+
* @param {Object} params.litNodeClient - The Lit Node client instance.
33+
* @param {Array} params.actions - The actions to perform.
34+
*
35+
* @returns {Promise<BatchGeneratePrivateKeysResult>} - The generated keys and optionally signed messages.
36+
*
37+
* @throws {Error} - Throws an error if required parameters are missing or if the Lit Action Session Sigs cannot be retrieved.
2838
*/
2939
export async function triaBatchGeneratePrivateKeys(
3040
params: Omit<BatchGeneratePrivateKeysParams, 'pkpSessionSigs'> & {
@@ -46,11 +56,7 @@ export async function triaBatchGeneratePrivateKeys(
4656
throw new Error(`Error: ipfsId is required`);
4757
}
4858

49-
let pkpPubKey = params.pkpPublicKey;
50-
51-
if (pkpPubKey.startsWith('0x')) {
52-
pkpPubKey = pkpPubKey.slice(2);
53-
}
59+
let pkpPubKey = params.pkpPublicKey.startsWith('0x') ? params.pkpPublicKey.slice(2) : params.pkpPublicKey;
5460

5561
const pkpPubkeyBuffer = Buffer.from(pkpPubKey, 'hex');
5662
const pkpEthAddress = computeAddress(pkpPubkeyBuffer);
@@ -89,18 +95,14 @@ export async function triaBatchGeneratePrivateKeys(
8995
handleAllResponses: true,
9096
strategy: 'leastCommon',
9197
});
92-
} catch (e) {
93-
throw new Error(`Error getting Lit Action Session Sigs: ${e}`);
98+
} catch (e: any) {
99+
throw new Error(`Error getting Lit Action Session Sigs: ${e.message}`);
94100
}
95101

96102
const firstSessionSig = Object.entries(litActionSessionSigs)[0][1];
97-
98103
const firstSignedMessage = JSON.parse(firstSessionSig.signedMessage);
99-
100104
const firstCapabilities = firstSignedMessage.capabilities[0];
101-
102105
const theCustomAuthResources = firstCapabilities.customAuthResources;
103-
104106
const pkpAddress = getPkpAddressFromSessionSig(firstSessionSig);
105107

106108
const keyParamsBatch = theCustomAuthResources.map((keyData: any) => {

0 commit comments

Comments
 (0)