Skip to content

Commit 9b3897d

Browse files
committed
fmt
1 parent b3c6e23 commit 9b3897d

File tree

159 files changed

+25886
-25358
lines changed

Some content is hidden

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

159 files changed

+25886
-25358
lines changed

.github/workflows/e2e.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ name: E2E Tests
22

33
on:
44
push:
5+
branches:
6+
- main
7+
- master
8+
- develop
59
pull_request:
610
workflow_dispatch:
711
inputs:
@@ -50,6 +54,30 @@ jobs:
5054
- name: Build project
5155
run: bun run build
5256

57+
- name: Validate environment variables
58+
run: |
59+
echo "Checking environment variables..."
60+
if [ -z "$LIVE_MASTER_ACCOUNT" ]; then
61+
echo "❌ LIVE_MASTER_ACCOUNT is not set"
62+
exit 1
63+
fi
64+
if [ -z "$LOCAL_MASTER_ACCOUNT" ]; then
65+
echo "❌ LOCAL_MASTER_ACCOUNT is not set"
66+
exit 1
67+
fi
68+
echo "✅ Required environment variables are set"
69+
70+
# Validate private key format (should be 0x followed by 64 hex chars)
71+
if [[ ! "$LIVE_MASTER_ACCOUNT" =~ ^0x[a-fA-F0-9]{64}$ ]]; then
72+
echo "❌ LIVE_MASTER_ACCOUNT is not in correct format (should be 0x followed by 64 hex characters)"
73+
exit 1
74+
fi
75+
if [[ ! "$LOCAL_MASTER_ACCOUNT" =~ ^0x[a-fA-F0-9]{64}$ ]]; then
76+
echo "❌ LOCAL_MASTER_ACCOUNT is not in correct format (should be 0x followed by 64 hex characters)"
77+
exit 1
78+
fi
79+
echo "✅ Private key formats are valid"
80+
5381
- name: Run health check for naga-dev
5482
run: NETWORK=naga-dev bun run test:e2e pkpSign
5583
timeout-minutes: 10

e2e/artillery/configs/pkp-sign.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
config:
2-
target: "dummy"
2+
target: 'dummy'
33
phases:
44
# Over 60s, ramp up to creating 50 vusers per second
55
- duration: 60
66
arrivalRate: 5
77
# rampTo: 50
88
rampTo: 10
9-
name: "Ramp Up"
9+
name: 'Ramp Up'
1010
# Over 300s, create 50 vusers per second
1111
- duration: 300
1212
# arrivalRate: 50
1313
arrivalRate: 10
14-
name: "Sustained PKP Signing"
14+
name: 'Sustained PKP Signing'
1515
# Over 60s, ramp down to creating 5 vusers per second
1616
- duration: 60
1717
arrivalRate: 5
18-
name: "Ramp Down"
19-
processor: "../src/processors/multi-endpoints.ts"
18+
name: 'Ramp Down'
19+
processor: '../src/processors/multi-endpoints.ts'
2020

2121
scenarios:
22-
- name: "PKP Sign Stress Test"
22+
- name: 'PKP Sign Stress Test'
2323
weight: 100
2424
flow:
25-
- function: "runPkpSignTest"
26-
- think: 0.1
25+
- function: 'runPkpSignTest'
26+
- think: 0.1
Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
11
config:
2-
target: "dummy"
2+
target: 'dummy'
33
phases:
44
# Over 60s, ramp up to creating 50 vusers per second
55
- duration: 60
66
arrivalRate: 5
77
# rampTo: 50
88
rampTo: 10
9-
name: "Ramp Up"
9+
name: 'Ramp Up'
1010
# Over 300s, create 50 vusers per second
1111
- duration: 300
1212
# arrivalRate: 50
1313
arrivalRate: 10
14-
name: "Sustained Sign Session Key"
14+
name: 'Sustained Sign Session Key'
1515
# Over 60s, ramp down to creating 5 vusers per second
1616
- duration: 60
1717
arrivalRate: 5
18-
name: "Ramp Down"
19-
processor: "../src/processors/multi-endpoints.ts"
18+
name: 'Ramp Down'
19+
processor: '../src/processors/multi-endpoints.ts'
2020

2121
scenarios:
22-
- name: "Sign Session Key Stress Test"
22+
- name: 'Sign Session Key Stress Test'
2323
weight: 100
2424
flow:
25-
26-
- function: "runSignSessionKeyTest"
27-
- think: 0.1
25+
- function: 'runSignSessionKeyTest'
26+
- think: 0.1
Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import * as NetworkManager from "../../../e2e/src/helper/NetworkManager";
2-
import { privateKeyToAccount } from "viem/accounts";
3-
import { createPublicClient, formatEther, http } from "viem";
4-
import { createLitClient } from "@lit-protocol/lit-client";
5-
import * as StateManager from "./StateManager";
6-
import { printAligned } from "../../../e2e/src/helper/utils";
1+
import * as NetworkManager from '../../../e2e/src/helper/NetworkManager';
2+
import { privateKeyToAccount } from 'viem/accounts';
3+
import { createPublicClient, formatEther, http } from 'viem';
4+
import { createLitClient } from '@lit-protocol/lit-client';
5+
import * as StateManager from './StateManager';
6+
import { printAligned } from '../../../e2e/src/helper/utils';
77

88
export const getMasterAccount = async () => {
99
const privateKey = process.env['LIVE_MASTER_ACCOUNT'];
@@ -13,13 +13,13 @@ export const getMasterAccount = async () => {
1313
}
1414

1515
return privateKeyToAccount(privateKey as `0x${string}`);
16-
}
16+
};
1717

1818
export const getAccountDetails = async ({
1919
account,
2020
publicClient,
2121
litClient,
22-
accountLabel = "Account",
22+
accountLabel = 'Account',
2323
}: {
2424
account: any;
2525
publicClient: any;
@@ -29,40 +29,44 @@ export const getAccountDetails = async ({
2929
console.log(`\n========== ${accountLabel} Details ==========`);
3030

3131
// Get all the data first
32-
const ethBalance = formatEther(await publicClient.getBalance({
33-
address: account.address,
34-
}));
32+
const ethBalance = formatEther(
33+
await publicClient.getBalance({
34+
address: account.address,
35+
})
36+
);
3537

3638
const paymentManager = await litClient.getPaymentManager({
3739
account: account,
3840
});
3941

4042
const paymentBalance = await paymentManager.getBalance({
41-
userAddress: account.address
43+
userAddress: account.address,
4244
});
4345

4446
// Determine status
45-
let statusLabel = "";
46-
let statusValue = "";
47+
let statusLabel = '';
48+
let statusValue = '';
4749

4850
if (Number(paymentBalance.availableBalance) < 0) {
49-
statusLabel = "🚨 Status:";
51+
statusLabel = '🚨 Status:';
5052
statusValue = `Negative balance (debt): ${paymentBalance.availableBalance}`;
5153
}
5254

5355
// Print all information with consistent alignment
5456
printAligned([
55-
{ label: "🔑 Address:", value: account.address },
56-
{ label: "💰 ETH Balance:", value: `${ethBalance} ETH` },
57-
{ label: "💳 Ledger Total Balance:", value: paymentBalance.totalBalance },
58-
{ label: "💳 Ledger Available Balance:", value: paymentBalance.availableBalance },
57+
{ label: '🔑 Address:', value: account.address },
58+
{ label: '💰 ETH Balance:', value: `${ethBalance} ETH` },
59+
{ label: '💳 Ledger Total Balance:', value: paymentBalance.totalBalance },
60+
{
61+
label: '💳 Ledger Available Balance:',
62+
value: paymentBalance.availableBalance,
63+
},
5964
{ label: statusLabel, value: statusValue },
6065
]);
6166

6267
return {
6368
ethBalance,
6469
ledgerBalance: paymentBalance.availableBalance,
6570
paymentManager,
66-
}
67-
}
68-
71+
};
72+
};

e2e/artillery/src/StateManager.ts

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const StateObject = {
88
masterAccount: {
99
// privateKey: undefined as string | `0x${string}` | undefined,
1010
// address: undefined as string | `0x${string}` | undefined,
11-
authData: undefined as any | undefined, // Changed from string to any since authData is an object
11+
authData: undefined as any | undefined, // Changed from string to any since authData is an object
1212
pkp: undefined as any | undefined,
1313
},
1414
};
@@ -34,7 +34,7 @@ export const readFile = async (): Promise<State> => {
3434
try {
3535
return await _readFile();
3636
} catch (error) {
37-
console.log("🚨 Failed to read file, creating new file...");
37+
console.log('🚨 Failed to read file, creating new file...');
3838
await createFile();
3939
return await _readFile();
4040
}
@@ -48,22 +48,23 @@ export const createFile = async () => {
4848
// Type-safe field paths - dynamically derived from State type
4949
type StatePaths = {
5050
[K in keyof State]: K extends string
51-
? State[K] extends object
52-
? {
53-
[P in keyof State[K]]: P extends string ? `${K}.${P}` : never
54-
}[keyof State[K]] | K // Include both nested paths AND top-level key
55-
: K
56-
: never
51+
? State[K] extends object
52+
?
53+
| {
54+
[P in keyof State[K]]: P extends string ? `${K}.${P}` : never;
55+
}[keyof State[K]]
56+
| K // Include both nested paths AND top-level key
57+
: K
58+
: never;
5759
}[keyof State];
5860

5961
// Helper type to get nested property type
60-
type GetNestedType<T, P extends string> =
61-
P extends `${infer K}.${infer Rest}`
62+
type GetNestedType<T, P extends string> = P extends `${infer K}.${infer Rest}`
6263
? K extends keyof T
63-
? Rest extends keyof T[K]
64-
? T[K][Rest]
65-
: never
66-
: never
64+
? Rest extends keyof T[K]
65+
? T[K][Rest]
66+
: never
67+
: never
6768
: P extends keyof T
6869
? T[P]
6970
: never;
@@ -86,7 +87,11 @@ export const updateField = async <T extends StatePaths>(
8687
const pathParts = path.split('.') as [keyof State, string];
8788
const [rootKey, nestedKey] = pathParts;
8889

89-
if (rootKey in state && typeof state[rootKey] === 'object' && state[rootKey] !== null) {
90+
if (
91+
rootKey in state &&
92+
typeof state[rootKey] === 'object' &&
93+
state[rootKey] !== null
94+
) {
9095
(state[rootKey] as any)[nestedKey] = value;
9196
await fs.writeFile(FILE_NAME, JSON.stringify(state, null, 2));
9297
} else {
@@ -125,7 +130,11 @@ export const getOrUpdate = async <T extends StatePaths>(
125130
const pathParts = path.split('.') as [keyof State, string];
126131
const [rootKey, nestedKey] = pathParts;
127132

128-
if (rootKey in state && typeof state[rootKey] === 'object' && state[rootKey] !== null) {
133+
if (
134+
rootKey in state &&
135+
typeof state[rootKey] === 'object' &&
136+
state[rootKey] !== null
137+
) {
129138
const currentValue = (state[rootKey] as any)[nestedKey];
130139

131140
// If value exists and is not null/undefined/empty string, return it
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import { createLitClient } from "@lit-protocol/lit-client";
2-
import * as NetworkManager from "../../src/helper/NetworkManager";
1+
import { createLitClient } from '@lit-protocol/lit-client';
2+
import * as NetworkManager from '../../src/helper/NetworkManager';
33
import * as AccountManager from '../src/AccountManager';
44

55
(async () => {
6-
76
// 1. Setup network and chain client
87
const networkModule = await NetworkManager.getLitNetworkModule();
9-
const publicClient = await NetworkManager.getViemPublicClient({ networkModule });
8+
const publicClient = await NetworkManager.getViemPublicClient({
9+
networkModule,
10+
});
1011
const litClient = await createLitClient({ network: networkModule });
1112

1213
// 2. Get the master account
@@ -15,11 +16,10 @@ import * as AccountManager from '../src/AccountManager';
1516
// every 5 seconds, check the balance of the master account
1617
setInterval(async () => {
1718
await AccountManager.getAccountDetails({
18-
accountLabel: "Master Account",
19+
accountLabel: 'Master Account',
1920
account: masterAccount,
2021
publicClient,
2122
litClient,
2223
});
2324
}, 3000);
24-
25-
})();
25+
})();

0 commit comments

Comments
 (0)