From ef926e486dacc8d4337d78316d10f451691e7187 Mon Sep 17 00:00:00 2001 From: anson Date: Wed, 15 Oct 2025 15:47:59 +0100 Subject: [PATCH 1/4] docs(test): add a command to test custom spec file --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 721fa441f..ac379fa0e 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,14 @@ LOCAL_MASTER_ACCOUNT=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf NETWORK= pnpm run test:e2e all ``` +### Run a custom ticket spec + +Run a single test file by pointing `--runTestsByPath` at the spec you are iterating on: + +```bash +pnpm test:custom -- --runTestsByPath packages/e2e/src/tickets/drel1157-la-decryptandcombine.spec.ts +``` + # Running it against a local network ## Required Environment Variables From c4182df752a4879cb40800bb72ea380dbc4b1448 Mon Sep 17 00:00:00 2001 From: anson Date: Wed, 15 Oct 2025 15:48:17 +0100 Subject: [PATCH 2/4] feat(tests): add executeJs basic and decryptAndCombine tests --- packages/e2e/src/e2e.spec.ts | 29 +-- .../{execute-js.ts => executeJs/basic.ts} | 23 +- .../tests/executeJs/decrypt-and-combine.ts | 179 ++++++++++++++++ .../e2e/src/helper/tests/executeJs/index.ts | 5 + packages/e2e/src/helper/tests/index.ts | 5 +- packages/e2e/src/init.ts | 196 +++++++++++------- .../drel1157-la-decryptandcombine.spec.ts | 16 ++ 7 files changed, 364 insertions(+), 89 deletions(-) rename packages/e2e/src/helper/tests/{execute-js.ts => executeJs/basic.ts} (61%) create mode 100644 packages/e2e/src/helper/tests/executeJs/decrypt-and-combine.ts create mode 100644 packages/e2e/src/helper/tests/executeJs/index.ts create mode 100644 packages/e2e/src/tickets/drel1157-la-decryptandcombine.spec.ts diff --git a/packages/e2e/src/e2e.spec.ts b/packages/e2e/src/e2e.spec.ts index bd425633f..3e7b66b2b 100644 --- a/packages/e2e/src/e2e.spec.ts +++ b/packages/e2e/src/e2e.spec.ts @@ -1,21 +1,19 @@ +import { createCustomAuthContext } from './helper/auth-contexts'; import { - createCustomAuthContext, - createPkpAuthContext, -} from './helper/auth-contexts'; -import { - createExecuteJsTest, - createPkpSignTest, - createPkpEncryptDecryptTest, createEncryptDecryptFlowTest, - createPkpPermissionsManagerFlowTest, createEoaNativeAuthFlowTest, + createExecuteJsDecryptAndCombineTest, + createExecuteJsBasicTest, + createPaymentDelegationFlowTest, + createPaymentManagerFlowTest, + createPkpEncryptDecryptTest, + createPkpPermissionsManagerFlowTest, + createPkpSignTest, createViemSignMessageTest, createViemSignTransactionTest, createViemSignTypedDataTest, createViewPKPsByAddressTest, createViewPKPsByAuthDataTest, - createPaymentManagerFlowTest, - createPaymentDelegationFlowTest, } from './helper/tests'; import { init } from './init'; import { AuthContext } from './types'; @@ -56,7 +54,12 @@ describe('all', () => { it('pkpSign', () => createPkpSignTest(ctx, () => ctx.aliceEoaAuthContext)()); it('executeJs', () => - createExecuteJsTest(ctx, () => ctx.aliceEoaAuthContext)()); + createExecuteJsBasicTest(ctx, () => ctx.aliceEoaAuthContext)()); + it('executeJs decryptAndCombine', () => + createExecuteJsDecryptAndCombineTest( + ctx, + () => ctx.aliceEoaAuthContext + )()); it('viewPKPsByAddress', () => createViewPKPsByAddressTest(ctx)()); it('viewPKPsByAuthData', () => createViewPKPsByAuthDataTest(ctx, () => ctx.aliceEoaAuthContext)()); @@ -96,7 +99,7 @@ describe('all', () => { it('pkpSign', () => createPkpSignTest(ctx, () => ctx.alicePkpAuthContext)()); it('executeJs', () => - createExecuteJsTest(ctx, () => ctx.alicePkpAuthContext)()); + createExecuteJsBasicTest(ctx, () => ctx.alicePkpAuthContext)()); it('viewPKPsByAddress', () => createViewPKPsByAddressTest(ctx)()); it('viewPKPsByAuthData', () => createViewPKPsByAuthDataTest(ctx, () => ctx.alicePkpAuthContext)()); @@ -137,7 +140,7 @@ describe('all', () => { ctx.eveViemAccountPkp.pubkey )()); it('executeJs', () => - createExecuteJsTest( + createExecuteJsBasicTest( ctx, () => eveCustomAuthContext, ctx.eveViemAccountPkp.pubkey diff --git a/packages/e2e/src/helper/tests/execute-js.ts b/packages/e2e/src/helper/tests/executeJs/basic.ts similarity index 61% rename from packages/e2e/src/helper/tests/execute-js.ts rename to packages/e2e/src/helper/tests/executeJs/basic.ts index a3c4341d7..9cf2a56f9 100644 --- a/packages/e2e/src/helper/tests/execute-js.ts +++ b/packages/e2e/src/helper/tests/executeJs/basic.ts @@ -1,8 +1,14 @@ -import { init } from '../../init'; +import { init } from '../../../init'; +import { AuthContext } from '../../../types'; -export const createExecuteJsTest = ( - ctx: Awaited>, - getAuthContext: () => any, +type ExecuteJsContext = Pick< + Awaited>, + 'litClient' | 'aliceViemAccountPkp' +>; + +export const createExecuteJsBasicTest = ( + ctx: ExecuteJsContext, + getAuthContext: () => AuthContext, pubkey?: string ) => { return async () => { @@ -22,6 +28,13 @@ export const createExecuteJsTest = ( }); })();`; + const defaultPubkey = ctx.aliceViemAccountPkp?.pubkey; + const targetPubkey = pubkey ?? defaultPubkey; + + if (!targetPubkey) { + throw new Error('Missing PKP public key for executeJs test'); + } + const result = await ctx.litClient.executeJs({ code: litActionCode, authContext: getAuthContext(), @@ -29,7 +42,7 @@ export const createExecuteJsTest = ( message: 'Test message from e2e executeJs', sigName: 'e2e-test-sig', toSign: 'Test message from e2e executeJs', - publicKey: pubkey || ctx.aliceViemAccountPkp.pubkey, + publicKey: targetPubkey, }, }); diff --git a/packages/e2e/src/helper/tests/executeJs/decrypt-and-combine.ts b/packages/e2e/src/helper/tests/executeJs/decrypt-and-combine.ts new file mode 100644 index 000000000..7f60ae5a0 --- /dev/null +++ b/packages/e2e/src/helper/tests/executeJs/decrypt-and-combine.ts @@ -0,0 +1,179 @@ +import { AuthContext, LitClientInstance } from '../../../types'; + +type ExecuteJsContext = { + litClient: LitClientInstance; + aliceEoaAuthContext: AuthContext; +}; + +export const decryptAndCombineLitAction = ` +(async () => { + const results = { + step1_getCurrentCid: null, + step2_generateEntropy: null, + step3_encrypt: null, + step4_decrypt: null, + step5_verify: null, + }; + + try { + // Step 1: Get current action IPFS CID + const currentCid = Lit.Auth.actionIpfsIdStack[0]; + results.step1_getCurrentCid = { + success: true, + cid: currentCid, + }; + + // Step 2: Generate entropy (32 random bytes) + const entropyHex = await Lit.Actions.runOnce( + { waitForResponse: true, name: "generateEntropy" }, + async () => { + return ethers.utils.hexlify(ethers.utils.randomBytes(32)); + } + ); + const entropy = ethers.utils.arrayify(entropyHex); + results.step2_generateEntropy = { + success: true, + entropyPreview: entropyHex.substring(0, 20) + "...", + entropyLength: entropy.length, + }; + + // Step 3: Encrypt with access control locked to current IPFS CID + const accessControlConditions = [ + { + contractAddress: "", + standardContractType: "", + chain: "ethereum", + method: "", + parameters: [":currentActionIpfsId"], + returnValueTest: { + comparator: "=", + value: currentCid, + }, + }, + ]; + + let encryptResult = await Lit.Actions.runOnce( + { waitForResponse: true, name: "encrypt" }, + async () => { + return JSON.stringify( + await Lit.Actions.encrypt({ + accessControlConditions, + to_encrypt: ethers.utils.toUtf8Bytes(entropyHex), + }) + ); + } + ); + encryptResult = JSON.parse(encryptResult); + + // Convert ciphertext to base64 for transmission + let ciphertextStr; + if (encryptResult.ciphertext instanceof Uint8Array) { + const binaryStr = Array.from(encryptResult.ciphertext) + .map((byte) => String.fromCharCode(byte)) + .join(""); + ciphertextStr = btoa(binaryStr); + } else { + ciphertextStr = encryptResult.ciphertext; + } + + // Convert dataToEncryptHash to hex + let dataHashStr; + if (encryptResult.dataToEncryptHash instanceof Uint8Array) { + dataHashStr = ethers.utils.hexlify(encryptResult.dataToEncryptHash); + } else { + dataHashStr = encryptResult.dataToEncryptHash; + } + + results.step3_encrypt = { + success: true, + ciphertextLength: ciphertextStr.length, + ciphertextPreview: ciphertextStr.substring(0, 30) + "...", + dataToEncryptHash: dataHashStr, + }; + + // Step 4: Decrypt using decryptAndCombine + const decryptResult = await Lit.Actions.decryptAndCombine({ + accessControlConditions, + ciphertext: encryptResult.ciphertext, + dataToEncryptHash: encryptResult.dataToEncryptHash, + authSig: null, + chain: "ethereum", + }); + + // Convert decrypted result to hex for comparison + let decryptedHex; + if (decryptResult instanceof Uint8Array) { + decryptedHex = ethers.utils.hexlify(decryptResult); + } else if (typeof decryptResult === "string") { + decryptedHex = decryptResult; + } else { + decryptedHex = "unknown format"; + } + + results.step4_decrypt = { + success: true, + decryptedDataPreview: decryptedHex.substring(0, 20) + "...", + decryptedLength: decryptResult.length, + }; + + // Step 5: Verify original matches decrypted + const matches = entropyHex === decryptedHex; + results.step5_verify = { + success: true, + matches, + originalPreview: entropyHex.substring(0, 20) + "...", + decryptedPreview: decryptedHex.substring(0, 20) + "...", + }; + + Lit.Actions.setResponse({ + response: JSON.stringify( + { + success: true, + currentCid, + results, + }, + null, + 2 + ), + }); + } catch (error) { + Lit.Actions.setResponse({ + response: JSON.stringify( + { + success: false, + error: error.message, + results, + }, + null, + 2 + ), + }); + } +})();`; + +export const createExecuteJsDecryptAndCombineTest = ( + ctx: ExecuteJsContext, + getAuthContext: () => AuthContext = () => ctx.aliceEoaAuthContext +) => { + return async () => { + const result = await ctx.litClient.executeJs({ + code: decryptAndCombineLitAction, + authContext: getAuthContext(), + jsParams: {}, + }); + + if (typeof result.response !== 'string') { + throw new Error('Expected executeJs response to be a string payload'); + } + + const parsed = JSON.parse(result.response); + + expect(parsed.success).toBe(true); + expect(parsed.currentCid).toBeDefined(); + expect(parsed.results?.step1_getCurrentCid?.success).toBe(true); + expect(parsed.results?.step2_generateEntropy?.entropyLength).toBe(32); + expect(parsed.results?.step3_encrypt?.success).toBe(true); + expect(parsed.results?.step4_decrypt?.success).toBe(true); + expect(parsed.results?.step5_verify?.matches).toBe(true); + }; +}; diff --git a/packages/e2e/src/helper/tests/executeJs/index.ts b/packages/e2e/src/helper/tests/executeJs/index.ts new file mode 100644 index 000000000..531a8bbc9 --- /dev/null +++ b/packages/e2e/src/helper/tests/executeJs/index.ts @@ -0,0 +1,5 @@ +export { createExecuteJsBasicTest } from './basic'; +export { + createExecuteJsDecryptAndCombineTest, + decryptAndCombineLitAction, +} from './decrypt-and-combine'; diff --git a/packages/e2e/src/helper/tests/index.ts b/packages/e2e/src/helper/tests/index.ts index 19467b7ab..5946943b6 100644 --- a/packages/e2e/src/helper/tests/index.ts +++ b/packages/e2e/src/helper/tests/index.ts @@ -1,6 +1,9 @@ // Endpoint tests export { createPkpSignTest } from './pkp-sign'; -export { createExecuteJsTest } from './execute-js'; +export { + createExecuteJsBasicTest, + createExecuteJsDecryptAndCombineTest, +} from './executeJs'; export { createViewPKPsByAddressTest } from './view-pkps-by-address'; export { createViewPKPsByAuthDataTest } from './view-pkps-by-auth-data'; export { createPkpEncryptDecryptTest } from './pkp-encrypt-decrypt'; diff --git a/packages/e2e/src/init.ts b/packages/e2e/src/init.ts index 4ffe403c7..4929c74ee 100644 --- a/packages/e2e/src/init.ts +++ b/packages/e2e/src/init.ts @@ -38,27 +38,52 @@ const LIVE_NETWORK_LEDGER_DEPOSIT_AMOUNT = '2'; const EVE_VALIDATION_IPFS_CID = 'QmcxWmo3jefFsPUnskJXYBwsJYtiFuMAH1nDQEs99AwzDe'; -export const init = async ( - network?: SupportedNetwork, - logLevel?: LogLevel -): Promise<{ +const NETWORK_CONFIG = { + 'naga-dev': { importName: 'nagaDev', type: 'live' }, + 'naga-test': { importName: 'nagaTest', type: 'live' }, + 'naga-local': { importName: 'nagaLocal', type: 'local' }, + 'naga-staging': { importName: 'nagaStaging', type: 'live' }, +} as const; + +type NetworkConfigKey = keyof typeof NETWORK_CONFIG; + +type BaseInitResult = { litClient: LitClientInstance; authManager: AuthManagerInstance; localMasterAccount: ViemAccount; aliceViemAccount: ViemAccount; aliceViemAccountAuthData: AuthData; + aliceEoaAuthContext: AuthContext; + masterDepositForUser: (userAddress: string) => Promise; +}; + +type FullInitResult = BaseInitResult & { aliceViemAccountPkp: PKPData; bobViemAccount: ViemAccount; bobViemAccountAuthData: AuthData; bobViemAccountPkp: PKPData; - aliceEoaAuthContext: AuthContext; alicePkpAuthContext: AuthContext; eveViemAccount: ViemAccount; eveCustomAuthData: CustomAuthData; eveViemAccountPkp: PKPData; eveValidationIpfsCid: `Qm${string}`; - masterDepositForUser: (userAddress: string) => Promise; -}> => { +}; + +async function initInternal( + mode: 'fast', + network?: SupportedNetwork, + logLevel?: LogLevel +): Promise; +async function initInternal( + mode: 'full', + network?: SupportedNetwork, + logLevel?: LogLevel +): Promise; +async function initInternal( + mode: 'fast' | 'full', + network?: SupportedNetwork, + logLevel?: LogLevel +): Promise { /** * ==================================== * Prepare accounts for testing @@ -75,13 +100,6 @@ export const init = async ( aliceViemAccount ); - const bobViemAccount = privateKeyToAccount(generatePrivateKey()); - const bobViemAccountAuthData = await ViemAccountAuthenticator.authenticate( - bobViemAccount - ); - - const eveViemAccount = privateKeyToAccount(generatePrivateKey()); - /** * ==================================== * Environment settings @@ -89,7 +107,9 @@ export const init = async ( */ const _network = network || process.env['NETWORK']; const _logLevel = logLevel || process.env['LOG_LEVEL']; - process.env['LOG_LEVEL'] = _logLevel; + if (_logLevel) { + process.env['LOG_LEVEL'] = _logLevel; + } if (!_network) { throw new Error( @@ -109,16 +129,7 @@ export const init = async ( * ❗️ If it's on live chain, we will fund it with the master account. (set in the .env file) * ==================================== */ - - // Network configuration map - const networkConfig = { - 'naga-dev': { importName: 'nagaDev', type: 'live' }, - 'naga-test': { importName: 'nagaTest', type: 'live' }, - 'naga-local': { importName: 'nagaLocal', type: 'local' }, - 'naga-staging': { importName: 'nagaStaging', type: 'live' }, - } as const; - - const config = networkConfig[_network as keyof typeof networkConfig]; + const config = NETWORK_CONFIG[_network as NetworkConfigKey]; if (!config) { throw new Error(`❌ Invalid network: ${_network}`); } @@ -154,15 +165,28 @@ export const init = async ( thenFundWith: fundingAmount, }); - await fundAccount(bobViemAccount, masterAccount, _networkModule, { - ifLessThan: fundingAmount, - thenFundWith: fundingAmount, - }); + let bobViemAccount: ViemAccount | undefined; + let bobViemAccountAuthData: AuthData | undefined; + let eveViemAccount: ViemAccount | undefined; - await fundAccount(eveViemAccount, masterAccount, _networkModule, { - ifLessThan: fundingAmount, - thenFundWith: fundingAmount, - }); + if (mode === 'full') { + bobViemAccount = privateKeyToAccount(generatePrivateKey()); + bobViemAccountAuthData = await ViemAccountAuthenticator.authenticate( + bobViemAccount + ); + + eveViemAccount = privateKeyToAccount(generatePrivateKey()); + + await fundAccount(bobViemAccount, masterAccount, _networkModule, { + ifLessThan: fundingAmount, + thenFundWith: fundingAmount, + }); + + await fundAccount(eveViemAccount, masterAccount, _networkModule, { + ifLessThan: fundingAmount, + thenFundWith: fundingAmount, + }); + } /** * ==================================== @@ -209,6 +233,49 @@ export const init = async ( }), }); + const createAliceEoaAuthContext = () => + authManager.createEoaAuthContext({ + config: { + account: aliceViemAccount, + }, + authConfig: { + statement: 'I authorize the Lit Protocol to execute this Lit Action.', + domain: 'example.com', + resources: [ + ['lit-action-execution', '*'], + ['pkp-signing', '*'], + ['access-control-condition-decryption', '*'], + ], + capabilityAuthSigs: [], + expiration: new Date(Date.now() + 1000 * 60 * 15).toISOString(), + }, + litClient: litClient, + }); + + if (mode === 'fast') { + await masterDepositForUser(aliceViemAccount.address); + + const aliceEoaAuthContext = await createAliceEoaAuthContext(); + + console.log('✅ Initialised components (fast)'); + + const baseResult: BaseInitResult = { + litClient, + authManager, + localMasterAccount, + aliceViemAccount, + aliceViemAccountAuthData, + aliceEoaAuthContext, + masterDepositForUser, + }; + + return baseResult; + } + + if (!bobViemAccount || !bobViemAccountAuthData || !eveViemAccount) { + throw new Error('❌ Failed to prepare accounts for full init'); + } + /** * ==================================== * Get or create PKPs for Alice and Bob @@ -257,23 +324,7 @@ export const init = async ( * Create the auth context * ==================================== */ - const aliceEoaAuthContext = await authManager.createEoaAuthContext({ - config: { - account: aliceViemAccount, - }, - authConfig: { - statement: 'I authorize the Lit Protocol to execute this Lit Action.', - domain: 'example.com', - resources: [ - ['lit-action-execution', '*'], - ['pkp-signing', '*'], - ['access-control-condition-decryption', '*'], - ], - capabilityAuthSigs: [], - expiration: new Date(Date.now() + 1000 * 60 * 15).toISOString(), - }, - litClient: litClient, - }); + const aliceEoaAuthContext = await createAliceEoaAuthContext(); console.log('✅ Initialised components'); @@ -310,42 +361,47 @@ export const init = async ( /** * ==================================== - * Depositing to Lit Ledger for differen + * Depositing to Lit Ledger for different accounts * ==================================== */ - - // Deposit to the PKP Viem account Ledger await masterDepositForUser(alicePkpViemAccount.address); - // const alicePkpViemAccountPermissionsManager = await litClient.getPKPPermissionsManager({ - // pkpIdentifier: { - // tokenId: aliceViemAccountPkp.tokenId, - // }, - // account: alicePkpViemAccount, - // }); - - /** - * ==================================== - * Return the initialised components - * ==================================== - */ - return { + const baseResult: BaseInitResult = { litClient, authManager, localMasterAccount, aliceViemAccount, aliceViemAccountAuthData, + aliceEoaAuthContext, + masterDepositForUser, + }; + + const fullResult: FullInitResult = { + ...baseResult, aliceViemAccountPkp, bobViemAccount, bobViemAccountAuthData, bobViemAccountPkp, + alicePkpAuthContext, eveViemAccount, eveCustomAuthData, eveViemAccountPkp, eveValidationIpfsCid: EVE_VALIDATION_IPFS_CID, - aliceEoaAuthContext, - alicePkpAuthContext, - masterDepositForUser, - // alicePkpViemAccountPermissionsManager }; + + return fullResult; +} + +export const init = async ( + network?: SupportedNetwork, + logLevel?: LogLevel +): Promise => { + return initInternal('full', network, logLevel); +}; + +export const initFast = async ( + network?: SupportedNetwork, + logLevel?: LogLevel +): Promise => { + return initInternal('fast', network, logLevel); }; diff --git a/packages/e2e/src/tickets/drel1157-la-decryptandcombine.spec.ts b/packages/e2e/src/tickets/drel1157-la-decryptandcombine.spec.ts new file mode 100644 index 000000000..8f6d56f41 --- /dev/null +++ b/packages/e2e/src/tickets/drel1157-la-decryptandcombine.spec.ts @@ -0,0 +1,16 @@ +import { createExecuteJsDecryptAndCombineTest } from '../helper/tests/executeJs'; +import { initFast } from '../init'; + +describe('drel1157 decryptAndCombine Lit Action', () => { + let ctx: Awaited>; + + beforeAll(async () => { + ctx = await initFast(); + }); + + it('should execute the decrypt and combine Lit Action successfully', () => + createExecuteJsDecryptAndCombineTest( + ctx, + () => ctx.aliceEoaAuthContext + )()); +}); From 1d3e9cc473eadcda653a21ad5b97add13823e962 Mon Sep 17 00:00:00 2001 From: anson Date: Wed, 15 Oct 2025 15:49:03 +0100 Subject: [PATCH 3/4] fmt --- .../e2e/src/tickets/drel1157-la-decryptandcombine.spec.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/e2e/src/tickets/drel1157-la-decryptandcombine.spec.ts b/packages/e2e/src/tickets/drel1157-la-decryptandcombine.spec.ts index 8f6d56f41..b3eb8c68d 100644 --- a/packages/e2e/src/tickets/drel1157-la-decryptandcombine.spec.ts +++ b/packages/e2e/src/tickets/drel1157-la-decryptandcombine.spec.ts @@ -9,8 +9,5 @@ describe('drel1157 decryptAndCombine Lit Action', () => { }); it('should execute the decrypt and combine Lit Action successfully', () => - createExecuteJsDecryptAndCombineTest( - ctx, - () => ctx.aliceEoaAuthContext - )()); + createExecuteJsDecryptAndCombineTest(ctx, () => ctx.aliceEoaAuthContext)()); }); From 334d92562fc98722dffaadcd333608217f586c31 Mon Sep 17 00:00:00 2001 From: anson Date: Wed, 15 Oct 2025 16:15:41 +0100 Subject: [PATCH 4/4] feat(init): add aliceViemAccountPkp to BaseInitResult and FullInitResult --- packages/e2e/src/init.ts | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/packages/e2e/src/init.ts b/packages/e2e/src/init.ts index 4929c74ee..43be59807 100644 --- a/packages/e2e/src/init.ts +++ b/packages/e2e/src/init.ts @@ -53,12 +53,12 @@ type BaseInitResult = { localMasterAccount: ViemAccount; aliceViemAccount: ViemAccount; aliceViemAccountAuthData: AuthData; + aliceViemAccountPkp: PKPData; aliceEoaAuthContext: AuthContext; masterDepositForUser: (userAddress: string) => Promise; }; type FullInitResult = BaseInitResult & { - aliceViemAccountPkp: PKPData; bobViemAccount: ViemAccount; bobViemAccountAuthData: AuthData; bobViemAccountPkp: PKPData; @@ -252,8 +252,15 @@ async function initInternal( litClient: litClient, }); + const aliceViemAccountPkp = await getOrCreatePkp( + litClient, + aliceViemAccountAuthData, + aliceViemAccount + ); + if (mode === 'fast') { await masterDepositForUser(aliceViemAccount.address); + await masterDepositForUser(aliceViemAccountPkp.ethAddress); const aliceEoaAuthContext = await createAliceEoaAuthContext(); @@ -265,6 +272,7 @@ async function initInternal( localMasterAccount, aliceViemAccount, aliceViemAccountAuthData, + aliceViemAccountPkp, aliceEoaAuthContext, masterDepositForUser, }; @@ -281,10 +289,11 @@ async function initInternal( * Get or create PKPs for Alice and Bob * ==================================== */ - const [aliceViemAccountPkp, bobViemAccountPkp] = await Promise.all([ - getOrCreatePkp(litClient, aliceViemAccountAuthData, aliceViemAccount), - getOrCreatePkp(litClient, bobViemAccountAuthData, bobViemAccount), - ]); + const bobViemAccountPkp = await getOrCreatePkp( + litClient, + bobViemAccountAuthData, + bobViemAccount + ); // Use custom auth to create a PKP for Eve const uniqueDappName = 'e2e-test-dapp'; @@ -372,13 +381,13 @@ async function initInternal( localMasterAccount, aliceViemAccount, aliceViemAccountAuthData, + aliceViemAccountPkp, aliceEoaAuthContext, masterDepositForUser, }; const fullResult: FullInitResult = { ...baseResult, - aliceViemAccountPkp, bobViemAccount, bobViemAccountAuthData, bobViemAccountPkp,