Skip to content

Commit f1c33b0

Browse files
committed
feat(wrapped-keys): naga-test works when running against wrapped-keys.spec.ts directly, but not e2e.spec.ts
1 parent b24d456 commit f1c33b0

File tree

8 files changed

+415
-232
lines changed

8 files changed

+415
-232
lines changed

packages/auth/src/lib/AuthManager/authAdapters/getPkpAuthContextFromPreGeneratedAdapter.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,8 @@ function extractAuthConfigFromDelegationAuthSig(delegationAuthSig: AuthSig): {
292292
} {
293293
const siweMessage = delegationAuthSig.signedMessage;
294294

295+
// const parsedSiweMessage = new SiweMessage(siweMessage);
296+
295297
// Extract domain
296298
const domainMatch = siweMessage.match(/^([^\s]+) wants you to sign in/m);
297299
const domain = domainMatch ? domainMatch[1] : undefined;

packages/e2e/src/helper/createEnvVars.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ export function createEnvVars(): EnvVars {
123123
});
124124

125125
console.log('✅ Env Vars:', clone);
126+
console.log("When RPC URL is undefined, module's default RPC will be used.")
126127

127128
return result;
128129
}

packages/e2e/src/helper/createTestAccount.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ViemAccountAuthenticator } from '@lit-protocol/auth';
2-
import { PKPData } from '@lit-protocol/schemas';
2+
import { AuthData, PKPData } from '@lit-protocol/schemas';
33
import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts';
44
import { AuthContext } from '../types';
55
import { TestEnv } from './createTestEnv';
@@ -40,6 +40,7 @@ export type CreateTestAccountResult = {
4040
paymentManager?: Awaited<
4141
ReturnType<TestEnv['litClient']['getPaymentManager']>
4242
>;
43+
authData?: AuthData;
4344
};
4445

4546
export async function createTestAccount(
@@ -55,11 +56,15 @@ export async function createTestAccount(
5556
pkpAuthContext: undefined,
5657
pkpViemAccount: undefined,
5758
paymentManager: undefined,
59+
authData: undefined,
5860
};
5961

6062
const personAccountAuthData = await ViemAccountAuthenticator.authenticate(
6163
person.account
6264
);
65+
66+
person.authData = personAccountAuthData;
67+
6368
console.log(`Address`, person.account.address);
6469
console.log(`opts:`, opts);
6570

packages/e2e/src/helper/createTestEnv.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1+
import {
2+
createAuthManager,
3+
generateSessionKeyPair,
4+
storagePlugins,
5+
} from '@lit-protocol/auth';
6+
import { createLitClient } from '@lit-protocol/lit-client';
17
import {
28
LitNetworkModule,
9+
naga,
310
nagaDev,
411
nagaLocal,
12+
nagaProto,
513
nagaStaging,
614
nagaTest,
7-
nagaProto,
8-
naga,
915
PaymentManager,
1016
} from '@lit-protocol/networks';
11-
import { EnvVars } from './createEnvVars';
12-
import { createLitClient } from '@lit-protocol/lit-client';
13-
import { createAuthManager, storagePlugins } from '@lit-protocol/auth';
1417
import { privateKeyToAccount } from 'viem/accounts';
18+
import { EnvVars } from './createEnvVars';
1519

1620
export const CONFIG = {
1721
LOCAL: {
@@ -24,7 +28,7 @@ export const CONFIG = {
2428
},
2529
LIVE: {
2630
nativeFundingAmount: '0.1',
27-
ledgerDepositAmount: '0.1',
31+
ledgerDepositAmount: '10',
2832
sponsorshipLimits: {
2933
totalMaxPriceInWei: '50000000000000000',
3034
userMaxPrice: 50000000000000000n,
@@ -59,6 +63,9 @@ export type TestEnv = {
5963
userMaxPrice: bigint;
6064
};
6165
};
66+
67+
// --- Wrapped Keys related ---
68+
sessionKeyPair: ReturnType<typeof generateSessionKeyPair>;
6269
};
6370

6471
export const createTestEnv = async (envVars: EnvVars): Promise<TestEnv> => {
@@ -149,12 +156,16 @@ export const createTestEnv = async (envVars: EnvVars): Promise<TestEnv> => {
149156
account: masterAccount,
150157
});
151158

159+
// --- This info are used by wrapped keys tests ---
160+
const sessionKeyPair = generateSessionKeyPair();
161+
152162
return {
153163
masterAccount,
154164
masterPaymentManager,
155165
networkModule,
156166
litClient,
157167
authManager,
158168
config,
169+
sessionKeyPair,
159170
};
160171
};

packages/e2e/src/helper/fundAccount.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ export const fundAccount = async (
126126
console.log(`- Using default network RPC URL:`, defaultRpcUrl);
127127
}
128128

129+
const rpcUrl = customRpcUrl ?? defaultRpcUrl;
130+
129131
// check account balance
130132
const publicClient = createPublicClient({
131133
chain: networkModule.getChainConfig(),

packages/e2e/src/helper/network.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ export const NETWORKS = {
1616
'naga-test': { importName: 'nagaTest', type: 'live' },
1717
'naga-local': { importName: 'nagaLocal', type: 'local' },
1818
'naga-staging': { importName: 'nagaStaging', type: 'live' },
19+
'naga-proto': { importName: 'nagaProto', type: 'live' },
20+
naga: { importName: 'naga', type: 'live' },
1921
} as const;
2022

2123
export type NetworkName = keyof typeof NETWORKS;

packages/e2e/src/init.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ type LogLevel = z.infer<typeof LogLevelSchema>;
4242
// Configurations
4343
const LIVE_NETWORK_FUNDING_AMOUNT = '0.01';
4444
const LOCAL_NETWORK_FUNDING_AMOUNT = '1';
45-
const LIVE_NETWORK_LEDGER_DEPOSIT_AMOUNT = '2';
45+
const LIVE_NETWORK_LEDGER_DEPOSIT_AMOUNT = '0.1';
4646
const MAINNET_NETWORK_FUNDING_AMOUNT = '0.01';
4747
const MAINNET_LEDGER_DEPOSIT_AMOUNT = '0.01';
4848

0 commit comments

Comments
 (0)