Skip to content

Commit 1849a33

Browse files
authored
Merge branch 'naga' into hwrdtm/ncc_hash_collision
2 parents eda06c9 + 928acbf commit 1849a33

File tree

47 files changed

+9137
-8692
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+9137
-8692
lines changed

.github/workflows/e2e.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ jobs:
5151
run: NETWORK=naga-dev bun run test:e2e all
5252
timeout-minutes: 10
5353

54-
- name: Run health check for naga-test
55-
run: NETWORK=naga-test bun run test:e2e all
56-
timeout-minutes: 10
54+
# - name: Run health check for naga-test
55+
# run: NETWORK=naga-test bun run test:e2e all
56+
# timeout-minutes: 10
5757

5858
- name: Run health check for naga-staging
5959
run: NETWORK=naga-staging bun run test:e2e all

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,5 @@ lit-cache
9090
lit-auth-local
9191
artillery-state.json
9292
artillery-pkp-tokens
93-
lit-auth-artillery
93+
lit-auth-artillery
94+
alice-auth-manager-data

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,4 @@ bunx changeset publish
113113

114114
# Contact
115115

116-
You can reach the Lit Protocol team through [Telegram](https://t.me/+aa73FAF9Vp82ZjJh), [Discord](https://litgateway.com/discord), or [X](https://x.com/litprotocol).
116+
You can reach the Lit Protocol team through [Telegram](https://t.me/+aa73FAF9Vp82ZjJh), [Discord](https://litgateway.com/discord), or [X](https://x.com/litprotocol).

bun.lock

Lines changed: 702 additions & 944 deletions
Large diffs are not rendered by default.

e2e/src/e2e.spec.ts

Lines changed: 168 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,29 @@ import {
1919
} from './helper/tests';
2020
import { init } from './init';
2121

22+
const RPC_OVERRIDE = process.env['LIT_YELLOWSTONE_PRIVATE_RPC_URL'];
23+
if (RPC_OVERRIDE) {
24+
console.log(
25+
'🧪 E2E: Using RPC override (LIT_YELLOWSTONE_PRIVATE_RPC_URL):',
26+
RPC_OVERRIDE
27+
);
28+
}
29+
2230
describe('all', () => {
2331
// Singleton baby
2432
let ctx: Awaited<ReturnType<typeof init>>;
2533

2634
// Auth contexts for testing
2735
let alicePkpAuthContext: any;
28-
let aliceCustomAuthContext: any;
36+
let eveCustomAuthContext: any;
2937

3038
beforeAll(async () => {
3139
try {
3240
ctx = await init();
3341

3442
// Create PKP and custom auth contexts using helper functions
3543
// alicePkpAuthContext = await createPkpAuthContext(ctx);
36-
aliceCustomAuthContext = await createCustomAuthContext(ctx);
44+
eveCustomAuthContext = await createCustomAuthContext(ctx);
3745
} catch (e) {
3846
console.error(e);
3947
process.exit(1);
@@ -48,10 +56,12 @@ describe('all', () => {
4856
createPkpSignTest(ctx, () => ctx.aliceEoaAuthContext)());
4957
it('executeJs', () =>
5058
createExecuteJsTest(ctx, () => ctx.aliceEoaAuthContext)());
51-
it('viewPKPsByAddress', () =>
52-
createViewPKPsByAddressTest(ctx, () => ctx.aliceEoaAuthContext)());
59+
it('viewPKPsByAddress', () => createViewPKPsByAddressTest(ctx)());
5360
it('viewPKPsByAuthData', () =>
54-
createViewPKPsByAuthDataTest(ctx, () => ctx.aliceEoaAuthContext)());
61+
createViewPKPsByAuthDataTest(
62+
ctx,
63+
ctx.aliceViemAccountAuthData
64+
)());
5565
it('pkpEncryptDecrypt', () =>
5666
createPkpEncryptDecryptTest(ctx, () => ctx.aliceEoaAuthContext)());
5767
it('encryptDecryptFlow', () =>
@@ -90,9 +100,12 @@ describe('all', () => {
90100
it('executeJs', () =>
91101
createExecuteJsTest(ctx, () => ctx.alicePkpAuthContext)());
92102
it('viewPKPsByAddress', () =>
93-
createViewPKPsByAddressTest(ctx, () => ctx.alicePkpAuthContext)());
103+
createViewPKPsByAddressTest(ctx)());
94104
it('viewPKPsByAuthData', () =>
95-
createViewPKPsByAuthDataTest(ctx, () => ctx.alicePkpAuthContext)());
105+
createViewPKPsByAuthDataTest(
106+
ctx,
107+
ctx.aliceViemAccountAuthData
108+
)());
96109
it('pkpEncryptDecrypt', () =>
97110
createPkpEncryptDecryptTest(ctx, () => ctx.alicePkpAuthContext)());
98111
it('encryptDecryptFlow', () =>
@@ -124,34 +137,51 @@ describe('all', () => {
124137

125138
describe('endpoints', () => {
126139
it('pkpSign', () =>
127-
createPkpSignTest(ctx, () => aliceCustomAuthContext)());
140+
createPkpSignTest(
141+
ctx,
142+
() => eveCustomAuthContext,
143+
ctx.eveViemAccountPkp.pubkey
144+
)());
128145
it('executeJs', () =>
129-
createExecuteJsTest(ctx, () => aliceCustomAuthContext)());
130-
it('viewPKPsByAddress', () =>
131-
createViewPKPsByAddressTest(ctx, () => aliceCustomAuthContext)());
146+
createExecuteJsTest(
147+
ctx,
148+
() => eveCustomAuthContext,
149+
ctx.eveViemAccountPkp.pubkey
150+
)());
151+
it('viewPKPsByAddress', () => createViewPKPsByAddressTest(ctx)());
132152
it('viewPKPsByAuthData', () =>
133-
createViewPKPsByAuthDataTest(ctx, () => aliceCustomAuthContext)());
153+
createViewPKPsByAuthDataTest(ctx, ctx.eveCustomAuthData)());
134154
it('pkpEncryptDecrypt', () =>
135-
createPkpEncryptDecryptTest(ctx, () => aliceCustomAuthContext)());
155+
createPkpEncryptDecryptTest(
156+
ctx,
157+
() => eveCustomAuthContext,
158+
ctx.eveViemAccountPkp.ethAddress
159+
)());
136160
it('encryptDecryptFlow', () =>
137-
createEncryptDecryptFlowTest(ctx, () => aliceCustomAuthContext)());
138-
it('pkpPermissionsManagerFlow', () =>
139-
createPkpPermissionsManagerFlowTest(
161+
createEncryptDecryptFlowTest(
140162
ctx,
141-
() => aliceCustomAuthContext
163+
() => eveCustomAuthContext,
164+
ctx.eveViemAccountPkp.pubkey
142165
)());
143-
});
144166

145-
describe('integrations', () => {
146-
describe('pkp viem account', () => {
147-
it('sign message', () =>
148-
createViemSignMessageTest(ctx, () => aliceCustomAuthContext)());
149-
it('sign transaction', () =>
150-
createViemSignTransactionTest(ctx, () => aliceCustomAuthContext)());
151-
it('sign typed data', () =>
152-
createViemSignTypedDataTest(ctx, () => aliceCustomAuthContext)());
153-
});
167+
// Disable for now because it requires a different flow
168+
// it('pkpPermissionsManagerFlow', () =>
169+
// createPkpPermissionsManagerFlowTest(
170+
// ctx,
171+
// () => eveCustomAuthContext, ctx.eveViemAccountPkp.pubkey
172+
// )());
154173
});
174+
175+
// describe('integrations', () => {
176+
// describe('pkp viem account', () => {
177+
// it('sign message', () =>
178+
// createViemSignMessageTest(ctx, () => eveCustomAuthContext, ctx.eveViemAccountPkp.pubkey)());
179+
// it('sign transaction', () =>
180+
// createViemSignTransactionTest(ctx, () => eveCustomAuthContext, ctx.eveViemAccountPkp.pubkey)());
181+
// it('sign typed data', () =>
182+
// createViemSignTypedDataTest(ctx, () => eveCustomAuthContext, ctx.eveViemAccountPkp.pubkey)());
183+
// });
184+
// });
155185
});
156186

157187
describe('EOA Native', () => {
@@ -161,3 +191,114 @@ describe('all', () => {
161191
});
162192
});
163193
});
194+
195+
describe('rpc override', () => {
196+
const TEST_RPC = process.env.LIT_YELLOWSTONE_PRIVATE_RPC_URL;
197+
// const TEST_RPC = 'https://yellowstone-override.example';
198+
199+
// beforeAll(() => {
200+
// process.env.LIT_YELLOWSTONE_PRIVATE_RPC_URL = TEST_RPC;
201+
// });
202+
203+
// afterAll(() => {
204+
// process.env.LIT_YELLOWSTONE_PRIVATE_RPC_URL = ORIGINAL_RPC;
205+
// });
206+
207+
it('applies env rpc override to module and client', async () => {
208+
const networks = await import('@lit-protocol/networks');
209+
210+
// choose module by NETWORK env (same way init.ts does)
211+
const network = process.env.NETWORK || 'naga-dev';
212+
const importNameMap: Record<string, string> = {
213+
'naga-dev': 'nagaDev',
214+
'naga-test': 'nagaTest',
215+
'naga-local': 'nagaLocal',
216+
'naga-staging': 'nagaStaging',
217+
};
218+
const importName = importNameMap[network];
219+
const baseModule: any = (networks as any)[importName];
220+
221+
// apply override
222+
const mod =
223+
typeof baseModule.withOverrides === 'function'
224+
? baseModule.withOverrides({ rpcUrl: TEST_RPC })
225+
: baseModule;
226+
227+
// log for verification
228+
// base vs effective (when override is supported)
229+
const baseRpcUrl =
230+
typeof baseModule.getRpcUrl === 'function'
231+
? baseModule.getRpcUrl()
232+
: 'n/a';
233+
const effRpcUrl =
234+
typeof mod.getRpcUrl === 'function' ? mod.getRpcUrl() : 'n/a';
235+
// eslint-disable-next-line no-console
236+
console.log('[rpc-override] TEST_RPC:', TEST_RPC);
237+
// eslint-disable-next-line no-console
238+
console.log(
239+
'[rpc-override] module rpc (base → effective):',
240+
baseRpcUrl,
241+
'→',
242+
effRpcUrl
243+
);
244+
try {
245+
const baseChain =
246+
typeof baseModule.getChainConfig === 'function'
247+
? baseModule.getChainConfig()
248+
: null;
249+
const effChain =
250+
typeof mod.getChainConfig === 'function' ? mod.getChainConfig() : null;
251+
if (baseChain && effChain) {
252+
// eslint-disable-next-line no-console
253+
console.log(
254+
'[rpc-override] module chain id/name (base → effective):',
255+
`${baseChain.id}/${baseChain.name}`,
256+
'→',
257+
`${effChain.id}/${effChain.name}`
258+
);
259+
// eslint-disable-next-line no-console
260+
console.log(
261+
'[rpc-override] module rpcUrls.default.http (base → effective):',
262+
baseChain.rpcUrls.default.http,
263+
'→',
264+
effChain.rpcUrls.default.http
265+
);
266+
// eslint-disable-next-line no-console
267+
console.log(
268+
'[rpc-override] module rpcUrls.public.http (base → effective):',
269+
(baseChain.rpcUrls as any)['public']?.http,
270+
'→',
271+
(effChain.rpcUrls as any)['public']?.http
272+
);
273+
}
274+
} catch {}
275+
276+
// module reflects override
277+
expect(mod.getRpcUrl()).toBe(TEST_RPC);
278+
const chain = mod.getChainConfig();
279+
expect(chain.rpcUrls.default.http[0]).toBe(TEST_RPC);
280+
expect((chain.rpcUrls as any)['public'].http[0]).toBe(TEST_RPC);
281+
282+
// client reflects override
283+
const { createLitClient } = await import('@lit-protocol/lit-client');
284+
const client = await createLitClient({ network: mod });
285+
const cc = client.getChainConfig();
286+
287+
// eslint-disable-next-line no-console
288+
console.log('[rpc-override] client rpcUrl:', cc.rpcUrl);
289+
// eslint-disable-next-line no-console
290+
console.log(
291+
'[rpc-override] client viem rpcUrls.default:',
292+
cc.viemConfig.rpcUrls.default.http
293+
);
294+
// eslint-disable-next-line no-console
295+
console.log(
296+
'[rpc-override] client viem rpcUrls.public:',
297+
(cc.viemConfig.rpcUrls as any)['public']?.http
298+
);
299+
300+
expect(cc.rpcUrl).toBe(TEST_RPC);
301+
expect(cc.viemConfig.rpcUrls.default.http[0]).toBe(TEST_RPC);
302+
expect((cc.viemConfig.rpcUrls as any)['public'].http[0]).toBe(TEST_RPC);
303+
});
304+
});

e2e/src/helper/auth-contexts.ts

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,12 @@ export const createCustomAuthContext = async (
3939
ctx: Awaited<ReturnType<typeof init>>
4040
) => {
4141
console.log('🔁 Creating Custom Auth Context');
42+
4243
try {
4344
// Set up custom auth method type and validation IPFS CID (from custom-auth-flow example)
44-
const uniqueDappName = 'e2e-test-dapp';
45-
const uniqueAuthMethodType = hexToBigInt(
46-
keccak256(toBytes(uniqueDappName))
47-
);
48-
const uniqueUserId = `${uniqueDappName}-alice`;
49-
const authMethodId = keccak256(toBytes(uniqueUserId));
50-
const validationIpfsCid = 'QmYLeVmwJPVs7Uebk85YdVPivMyrvoeKR6X37kyVRZUXW4';
5145

5246
const customAuthContext = await ctx.authManager.createCustomAuthContext({
53-
pkpPublicKey: ctx.aliceViemAccountPkp.publicKey,
47+
pkpPublicKey: ctx.eveViemAccountPkp.pubkey,
5448
authConfig: {
5549
resources: [
5650
['pkp-signing', '*'],
@@ -61,17 +55,17 @@ export const createCustomAuthContext = async (
6155
},
6256
litClient: ctx.litClient,
6357
customAuthParams: {
64-
litActionIpfsId: validationIpfsCid,
58+
litActionIpfsId: ctx.eveValidationIpfsCid,
6559
jsParams: {
66-
pkpPublicKey: ctx.aliceViemAccountPkp.publicKey,
67-
username: 'alice',
60+
pkpPublicKey: ctx.eveViemAccountPkp.pubkey,
61+
username: 'eve',
6862
password: 'lit',
69-
authMethodId: authMethodId,
63+
authMethodId: ctx.eveCustomAuthData.authMethodId,
7064
},
7165
},
7266
});
7367

74-
console.log('✅ Custom Auth Context created');
68+
console.log('✅ Custom Auth Context created', customAuthContext);
7569
return customAuthContext;
7670
} catch (e) {
7771
console.error('❌ Error creating Custom Auth Context', e);

e2e/src/helper/tests/encrypt-decrypt-flow.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { assert } from '../assertions';
33

44
export const createEncryptDecryptFlowTest = (
55
ctx: Awaited<ReturnType<typeof init>>,
6-
getAuthContext: () => any
6+
getAuthContext: () => any,
7+
address?: string
78
) => {
89
return async () => {
910
const { createAccBuilder } = await import(
@@ -17,7 +18,7 @@ export const createEncryptDecryptFlowTest = (
1718
if (authContext === ctx.aliceEoaAuthContext) {
1819
aliceAddress = ctx.aliceViemAccount.address;
1920
} else {
20-
aliceAddress = ctx.aliceViemAccountPkp.ethAddress;
21+
aliceAddress = address || ctx.aliceViemAccountPkp.ethAddress;
2122
}
2223

2324
// Set up access control conditions requiring Bob's wallet ownership

e2e/src/helper/tests/execute-js.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { assert } from '../assertions';
33

44
export const createExecuteJsTest = (
55
ctx: Awaited<ReturnType<typeof init>>,
6-
getAuthContext: () => any
6+
getAuthContext: () => any,
7+
pubkey?: string
78
) => {
89
return async () => {
910
const litActionCode = `
@@ -29,7 +30,7 @@ export const createExecuteJsTest = (
2930
message: 'Test message from e2e executeJs',
3031
sigName: 'e2e-test-sig',
3132
toSign: 'Test message from e2e executeJs',
32-
publicKey: ctx.aliceViemAccountPkp.publicKey,
33+
publicKey: pubkey || ctx.aliceViemAccountPkp.publicKey,
3334
},
3435
});
3536

e2e/src/helper/tests/pkp-encrypt-decrypt.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { assert } from '../assertions';
33

44
export const createPkpEncryptDecryptTest = (
55
ctx: Awaited<ReturnType<typeof init>>,
6-
getAuthContext: () => any
6+
getAuthContext: () => any,
7+
address?: string
78
) => {
89
return async () => {
910
const { createAccBuilder } = await import(
@@ -19,7 +20,7 @@ export const createPkpEncryptDecryptTest = (
1920
addressToUse = ctx.aliceViemAccount.address;
2021
} else {
2122
// PKP or Custom auth contexts
22-
addressToUse = ctx.aliceViemAccountPkp.ethAddress;
23+
addressToUse = address || ctx.aliceViemAccountPkp.ethAddress;
2324
}
2425

2526
// Set up access control conditions requiring wallet ownership

e2e/src/helper/tests/pkp-sign.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ import { assert } from '../assertions';
33

44
export const createPkpSignTest = (
55
ctx: Awaited<ReturnType<typeof init>>,
6-
getAuthContext: () => any
6+
getAuthContext: () => any,
7+
pubkey?: string
78
) => {
89
return async () => {
910
const res = await ctx.litClient.chain.ethereum.pkpSign({
1011
authContext: getAuthContext(),
11-
pubKey: ctx.aliceViemAccountPkp.publicKey,
12+
pubKey: pubkey || ctx.aliceViemAccountPkp.publicKey,
1213
toSign: 'Hello, world!',
1314
});
1415

0 commit comments

Comments
 (0)