Skip to content

Commit 45e19d7

Browse files
types: Replace any types with more explicit typing
1 parent 15523a8 commit 45e19d7

File tree

6 files changed

+26
-13
lines changed

6 files changed

+26
-13
lines changed

packages/wrapped-keys-lit-actions/src/lib/abortError.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export class AbortError extends Error {
22
override name = 'AbortError';
33
}
44

5-
export const rethrowIfAbortError = (err: any) => {
5+
export const rethrowIfAbortError = (err: unknown) => {
66
if (err instanceof AbortError) {
77
throw err;
88
}

packages/wrapped-keys-lit-actions/src/lib/internal/common/getDecryptedKeyToSingleNode.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ async function tryDecryptToSingleNode({
2323
chain: 'ethereum',
2424
authSig: null,
2525
});
26-
} catch (err: any) {
27-
throw new Error(`When decrypting key to a single node - ${err.message}`);
26+
} catch (err: unknown) {
27+
throw new Error(
28+
`When decrypting key to a single node - ${(err as Error).message}`
29+
);
2830
}
2931
}
3032

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

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,20 @@ export interface UnsignedTransaction {
1010
gasLimit?: number;
1111
}
1212

13+
export interface ValidatedTransaction {
14+
to: string;
15+
value: string;
16+
chainId: number;
17+
data?: string;
18+
from?: string;
19+
nonce?: string;
20+
gasPrice?: string;
21+
gasLimit?: number;
22+
}
23+
1324
export function getValidatedUnsignedTx(
1425
unsignedTransaction: UnsignedTransaction
15-
) {
26+
): ValidatedTransaction {
1627
try {
1728
if (!unsignedTransaction.toAddress) {
1829
throw new Error('Missing required field: toAddress');
@@ -101,7 +112,7 @@ async function getGasLimit({
101112
}: {
102113
provider: ethers['providers']['JsonRpcProvider'];
103114
userProvidedGasLimit?: number;
104-
validatedTx: any;
115+
validatedTx: ValidatedTransaction;
105116
}) {
106117
if (userProvidedGasLimit) {
107118
return userProvidedGasLimit;
@@ -118,8 +129,8 @@ async function signTransaction({
118129
validatedTx,
119130
wallet,
120131
}: {
121-
validatedTx: any;
122-
wallet: any;
132+
validatedTx: ValidatedTransaction;
133+
wallet: ethers['wallet'];
123134
}) {
124135
try {
125136
return await wallet.signTransaction(validatedTx);
@@ -150,7 +161,7 @@ export async function signTransactionEthereumKey({
150161
}: {
151162
broadcast: boolean;
152163
privateKey: string;
153-
validatedTx: any;
164+
validatedTx: ValidatedTransaction;
154165
unsignedTransaction: UnsignedTransaction;
155166
}) {
156167
const wallet = new ethers.Wallet(privateKey);
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { AbortError } from './abortError';
22

3-
export async function litActionHandler(actionFunc: () => Promise<any>) {
3+
export async function litActionHandler(actionFunc: () => Promise<unknown>) {
44
try {
55
const litActionResult = await actionFunc();
66
// Don't re-stringify a string; we don't want to double-escape it
@@ -10,14 +10,14 @@ export async function litActionHandler(actionFunc: () => Promise<any>) {
1010
: JSON.stringify(litActionResult);
1111

1212
Lit.Actions.setResponse({ response });
13-
} catch (err: any) {
13+
} catch (err: unknown) {
1414
// AbortError means exit immediately and do _NOT_ set a response
1515
// Nested code should really only throw this in cases where using e.g. `decryptToSingleNode`
1616
// And this execution isn't that node.
1717
if (err instanceof AbortError) {
1818
return;
1919
}
2020

21-
Lit.Actions.setResponse({ response: `Error: ${err.message}` });
21+
Lit.Actions.setResponse({ response: `Error: ${(err as Error).message}` });
2222
}
2323
}

packages/wrapped-keys-lit-actions/src/lib/raw-action-functions/ethereum/generateEncryptedEthereumPrivateKey.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Generates a random Ethers private key and only allows the provided PKP to decrypt it
44
*
55
* @param {string} pkpAddress - The Eth address of the PKP which is associated with the Wrapped Key
6-
* @param {any} accessControlConditions - The access control condition that allows only the pkpAddress to decrypt the Wrapped Key
6+
* @param {string} accessControlConditions - The access control condition that allows only the pkpAddress to decrypt the Wrapped Key
77
*
88
* @returns { Promise<{ciphertext: string, dataToEncryptHash: string, publicKey: string}> } - Returns object with ciphertext & dataToEncryptHash which are the result of the encryption. Also returns the publicKey of the newly generated Ethers Wrapped Key.
99
*/

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { generateSolanaPrivateKey } from '../../internal/solana/generatePrivateK
44
/**
55
* Bundles solana/web3.js package as it's required to generate a random Solana key and only allows the provided PKP to decrypt it
66
*
7-
* @param {any} accessControlConditions - The access control condition that allows only the pkpAddress to decrypt the Wrapped Key
7+
* @param {string} accessControlConditions - The access control condition that allows only the pkpAddress to decrypt the Wrapped Key
88
*
99
* @returns { Promise<{ciphertext: string, dataToEncryptHash: string, publicKey: string}> } - Returns JSON object with ciphertext & dataToEncryptHash which are the result of the encryption. Also returns the publicKey of the newly generated Solana Wrapped Key.
1010
*/

0 commit comments

Comments
 (0)