Skip to content

Commit 15523a8

Browse files
fix: Use local declarations instead of declare global {} in module scopes
- Also removed now-unnecessary eslint hints for `/* global Lit */` etc. - Fixes mismatched type conflict with same name 'UnsignedTransaction'; ethereum's type is different than Solana.
1 parent 52fffc9 commit 15523a8

21 files changed

+95
-112
lines changed

local-tests/test.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -293,22 +293,22 @@ setLitActionsCodeToLocal();
293293
tests: {
294294
// testExample,
295295
// testBundleSpeed,
296-
...eoaSessionSigsTests,
297-
...pkpSessionSigsTests,
298-
...litActionSessionSigsTests,
299-
...litActionIpfsIdSessionSigsTests,
300-
...capacityDelegationTests,
301-
...bareAuthSigTests,
302-
303-
...pkpEthersTest.eoaSessionSigs,
304-
...pkpEthersTest.pkpSessionSigs,
305-
...pkpEthersTest.litActionSessionSigs,
306-
307-
...litActionCombiningTests.broadcastAndCombine,
308-
...litActionCombiningTests.decryptAndCombine,
309-
...litActionCombiningTests.ecdsaSignAndCombine,
310-
311-
...relayerTests,
296+
// ...eoaSessionSigsTests,
297+
// ...pkpSessionSigsTests,
298+
// ...litActionSessionSigsTests,
299+
// ...litActionIpfsIdSessionSigsTests,
300+
// ...capacityDelegationTests,
301+
// ...bareAuthSigTests,
302+
//
303+
// ...pkpEthersTest.eoaSessionSigs,
304+
// ...pkpEthersTest.pkpSessionSigs,
305+
// ...pkpEthersTest.litActionSessionSigs,
306+
//
307+
// ...litActionCombiningTests.broadcastAndCombine,
308+
// ...litActionCombiningTests.decryptAndCombine,
309+
// ...litActionCombiningTests.ecdsaSignAndCombine,
310+
//
311+
// ...relayerTests,
312312
...wrappedKeysTests,
313313
},
314314
devEnv,

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ export interface UnsignedTransaction {
88
dataHex?: string;
99
gasPrice?: string;
1010
gasLimit?: number;
11-
serializedTransaction?: any;
1211
}
1312

1413
export function getValidatedUnsignedTx(

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
import { Keypair } from '@solana/web3.js';
2-
import nacl from 'tweetnacl';
31
import { Buffer } from 'buffer';
42

5-
/**
6-
* The global ethers library (5.7.0) is available on Lit Action (Unbundled)
7-
*/
8-
import { ethers } from 'ethers';
3+
import { Keypair } from '@solana/web3.js';
4+
import nacl from 'tweetnacl';
95

106
interface SignMessageParams {
117
messageToSign: string;

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import {
66
Transaction,
77
} from '@solana/web3.js';
88

9-
/**
10-
* The global ethers library (5.7.0) is available on Lit Action (Unbundled)
11-
*/
12-
import { ethers } from 'ethers';
13-
import { UnsignedTransaction } from '../ethereum/signTransaction';
9+
// Solana transactions are pre-serialized; much simpler API than ethereum transactions
10+
export interface UnsignedTransaction {
11+
chain: string;
12+
serializedTransaction: string;
13+
}
1414

1515
export function validateUnsignedTransaction(
1616
unsignedTransaction: UnsignedTransaction
@@ -88,6 +88,7 @@ export async function signTransactionSolanaKey({
8888
if (!broadcast) {
8989
return signature;
9090
}
91+
9192
// Ensure the chain is a valid Cluster type
9293
const chain: Cluster = unsignedTransaction.chain as Cluster;
9394

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* global Lit */
2-
31
import { AbortError } from './abortError';
42

53
export async function litActionHandler(actionFunc: () => Promise<any>) {

packages/wrapped-keys-lit-actions/src/lib/raw-action-functions/common/batchGenerateEncryptedKeys.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ interface Action {
1414
};
1515
}
1616

17+
export interface BatchGenerateEncryptedKeysParams {
18+
actions: Action[];
19+
accessControlConditions: string;
20+
}
21+
1722
async function processEthereumAction({
1823
action,
1924
accessControlConditions,
@@ -94,10 +99,7 @@ async function processSolanaAction({
9499
async function processActions({
95100
actions,
96101
accessControlConditions,
97-
}: {
98-
actions: Action[];
99-
accessControlConditions: string;
100-
}) {
102+
}: BatchGenerateEncryptedKeysParams) {
101103
return Promise.all(
102104
actions.map(async (action, ndx) => {
103105
const { network } = action;
@@ -159,10 +161,7 @@ function validateParams(actions: Action[]) {
159161
export async function batchGenerateEncryptedKeys({
160162
actions,
161163
accessControlConditions,
162-
}: {
163-
actions: Action[];
164-
accessControlConditions: string;
165-
}) {
164+
}: BatchGenerateEncryptedKeysParams) {
166165
validateParams(actions);
167166

168167
return processActions({

packages/wrapped-keys-lit-actions/src/lib/raw-action-functions/common/exportPrivateKey.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { getDecryptedKeyToSingleNode } from '../../internal/common/getDecryptedKeyToSingleNode';
22

3-
interface ExportPrivateKeyParams {
3+
export interface ExportPrivateKeyParams {
44
accessControlConditions: string;
55
ciphertext: string;
66
dataToEncryptHash: string;
@@ -10,10 +10,10 @@ interface ExportPrivateKeyParams {
1010
*
1111
* Exports the private key after decrypting and removing the salt from it.
1212
*
13-
* @param {string} pkpAddress - The Eth address of the PKP which is associated with the Wrapped Key
14-
* @param {string} ciphertext - For the encrypted Wrapped Key
15-
* @param {string} dataToEncryptHash - For the encrypted Wrapped Key
16-
* @param {any} accessControlConditions - The access control condition that allows only the pkpAddress to decrypt the Wrapped Key
13+
* @param {object} params
14+
* @param {string} params.ciphertext - For the encrypted Wrapped Key
15+
* @param {string} params.dataToEncryptHash - For the encrypted Wrapped Key
16+
* @param {string} params.accessControlConditions - The access control condition that allows only the pkpAddress to decrypt the Wrapped Key
1717
*
1818
* @returns { Promise<string> } - Returns a decrypted private key.
1919
*/

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
@@ -10,7 +10,7 @@
1010
import { encryptPrivateKey } from '../../internal/common/encryptKey';
1111
import { generateEthereumPrivateKey } from '../../internal/ethereum/generatePrivateKey';
1212

13-
interface GenerateEncryptedEthereumPrivateKeyParams {
13+
export interface GenerateEncryptedEthereumPrivateKeyParams {
1414
accessControlConditions: string;
1515
}
1616

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { getDecryptedKeyToSingleNode } from '../../internal/common/getDecryptedKeyToSingleNode';
22
import { signMessageEthereumKey } from '../../internal/ethereum/signMessage';
33

4-
interface SignMessageWithEncryptedEthereumKeyParams {
4+
export interface SignMessageWithEncryptedEthereumKeyParams {
55
accessControlConditions: string;
66
ciphertext: string;
77
dataToEncryptHash: string;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
UnsignedTransaction,
66
} from '../../internal/ethereum/signTransaction';
77

8-
interface SignTransactionWithEncryptedEthereumKeyParams {
8+
export interface SignTransactionWithEncryptedEthereumKeyParams {
99
accessControlConditions: string;
1010
ciphertext: string;
1111
dataToEncryptHash: string;

0 commit comments

Comments
 (0)