Skip to content

Commit 61fe370

Browse files
authored
Merge pull request #860 from LIT-Protocol/feature/jss-34-naga-fix-getting-node-prices-for-session-sigs
[Fix] get fresh node prices for paid endpoint calls
2 parents 86cf2a2 + bcf6c21 commit 61fe370

File tree

21 files changed

+277
-136
lines changed

21 files changed

+277
-136
lines changed

.github/workflows/lint.yml

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,36 @@ jobs:
3232
- name: Install project dependencies
3333
run: bun install
3434

35+
- name: Debug Git and Environment
36+
run: |
37+
echo "Current branch:"
38+
git branch --show-current
39+
echo "Available branches:"
40+
git branch -a
41+
echo "Git remotes:"
42+
git remote -v
43+
echo "Last 3 commits:"
44+
git log --oneline -3
45+
echo "Git status:"
46+
git status
47+
echo "NX configuration:"
48+
cat nx.json | head -10
49+
echo "Prettier configuration:"
50+
cat .prettierrc
51+
3552
- name: Lint
36-
run: bun run nx format:check --all
53+
run: |
54+
echo "Running format check..."
55+
# Use prettier directly to avoid NX git issues
56+
npx prettier --check . || {
57+
echo "Format check failed. Running prettier --write to fix issues..."
58+
npx prettier --write .
59+
echo "Checking again after formatting..."
60+
npx prettier --check . || {
61+
echo "Still failing after auto-format. Manual intervention needed."
62+
exit 1
63+
}
64+
echo "Auto-formatting successful. All files are now properly formatted."
65+
echo "Note: Some files were auto-formatted. Consider committing these changes in your next commit."
66+
}
67+
echo "Format check passed!"

.prettierignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
tools
1515
/packages/wasm/rust/*
1616
/packages/wasm/src/pkg/*
17-
**/*/dist
17+
**/*/dist

.prettierrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"insertPragma": false,
77
"singleAttributePerLine": false,
88
"bracketSameLine": false,
9-
"jsxBracketSameLine": false,
109
"jsxSingleQuote": false,
1110
"printWidth": 80,
1211
"proseWrap": "preserve",

e2e/src/e2e.spec.ts

Lines changed: 79 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -65,93 +65,99 @@ describe('all', () => {
6565
createPaymentManagerFlowTest(ctx, () => ctx.aliceEoaAuthContext)());
6666
it('paymentDelegationFlow', () =>
6767
createPaymentDelegationFlowTest(ctx, () => ctx.aliceEoaAuthContext)());
68-
});
6968

70-
describe('integrations', () => {
71-
describe('pkp viem account', () => {
72-
it('sign message', () =>
73-
createViemSignMessageTest(ctx, () => ctx.aliceEoaAuthContext)());
74-
it('sign transaction', () =>
75-
createViemSignTransactionTest(ctx, () => ctx.aliceEoaAuthContext)());
76-
it('sign typed data', () =>
77-
createViemSignTypedDataTest(ctx, () => ctx.aliceEoaAuthContext)());
69+
describe('integrations', () => {
70+
describe('pkp viem account', () => {
71+
it('sign message', () =>
72+
createViemSignMessageTest(ctx, () => ctx.aliceEoaAuthContext)());
73+
it('sign transaction', () =>
74+
createViemSignTransactionTest(
75+
ctx,
76+
() => ctx.aliceEoaAuthContext
77+
)());
78+
it('sign typed data', () =>
79+
createViemSignTypedDataTest(ctx, () => ctx.aliceEoaAuthContext)());
80+
});
7881
});
7982
});
80-
});
8183

82-
describe('PKP Auth', () => {
83-
console.log('🔐 Testing using Programmable Key Pair authentication');
84+
describe('PKP Auth', () => {
85+
console.log('🔐 Testing using Programmable Key Pair authentication');
8486

85-
describe('endpoints', () => {
86-
it('pkpSign', () =>
87-
createPkpSignTest(ctx, () => ctx.alicePkpAuthContext)());
88-
it('executeJs', () =>
89-
createExecuteJsTest(ctx, () => ctx.alicePkpAuthContext)());
90-
it('viewPKPsByAddress', () =>
91-
createViewPKPsByAddressTest(ctx, () => ctx.alicePkpAuthContext)());
92-
it('viewPKPsByAuthData', () =>
93-
createViewPKPsByAuthDataTest(ctx, () => ctx.alicePkpAuthContext)());
94-
it('pkpEncryptDecrypt', () =>
95-
createPkpEncryptDecryptTest(ctx, () => ctx.alicePkpAuthContext)());
96-
it('encryptDecryptFlow', () =>
97-
createEncryptDecryptFlowTest(ctx, () => ctx.alicePkpAuthContext)());
98-
it('pkpPermissionsManagerFlow', () =>
99-
createPkpPermissionsManagerFlowTest(
100-
ctx,
101-
() => ctx.alicePkpAuthContext
102-
)());
103-
});
87+
describe('endpoints', () => {
88+
it('pkpSign', () =>
89+
createPkpSignTest(ctx, () => ctx.alicePkpAuthContext)());
90+
it('executeJs', () =>
91+
createExecuteJsTest(ctx, () => ctx.alicePkpAuthContext)());
92+
it('viewPKPsByAddress', () =>
93+
createViewPKPsByAddressTest(ctx, () => ctx.alicePkpAuthContext)());
94+
it('viewPKPsByAuthData', () =>
95+
createViewPKPsByAuthDataTest(ctx, () => ctx.alicePkpAuthContext)());
96+
it('pkpEncryptDecrypt', () =>
97+
createPkpEncryptDecryptTest(ctx, () => ctx.alicePkpAuthContext)());
98+
it('encryptDecryptFlow', () =>
99+
createEncryptDecryptFlowTest(ctx, () => ctx.alicePkpAuthContext)());
100+
it('pkpPermissionsManagerFlow', () =>
101+
createPkpPermissionsManagerFlowTest(
102+
ctx,
103+
() => ctx.alicePkpAuthContext
104+
)());
105+
});
104106

105-
describe('integrations', () => {
106-
describe('pkp viem account', () => {
107-
it('sign message', () =>
108-
createViemSignMessageTest(ctx, () => ctx.alicePkpAuthContext)());
109-
it('sign transaction', () =>
110-
createViemSignTransactionTest(ctx, () => ctx.alicePkpAuthContext)());
111-
it('sign typed data', () =>
112-
createViemSignTypedDataTest(ctx, () => ctx.alicePkpAuthContext)());
107+
describe('integrations', () => {
108+
describe('pkp viem account', () => {
109+
it('sign message', () =>
110+
createViemSignMessageTest(ctx, () => ctx.alicePkpAuthContext)());
111+
it('sign transaction', () =>
112+
createViemSignTransactionTest(
113+
ctx,
114+
() => ctx.alicePkpAuthContext
115+
)());
116+
it('sign typed data', () =>
117+
createViemSignTypedDataTest(ctx, () => ctx.alicePkpAuthContext)());
118+
});
113119
});
114120
});
115-
});
116121

117-
describe('Custom Auth', () => {
118-
console.log('🔐 Testing using Custom authentication method');
122+
describe('Custom Auth', () => {
123+
console.log('🔐 Testing using Custom authentication method');
119124

120-
describe('endpoints', () => {
121-
it('pkpSign', () =>
122-
createPkpSignTest(ctx, () => aliceCustomAuthContext)());
123-
it('executeJs', () =>
124-
createExecuteJsTest(ctx, () => aliceCustomAuthContext)());
125-
it('viewPKPsByAddress', () =>
126-
createViewPKPsByAddressTest(ctx, () => aliceCustomAuthContext)());
127-
it('viewPKPsByAuthData', () =>
128-
createViewPKPsByAuthDataTest(ctx, () => aliceCustomAuthContext)());
129-
it('pkpEncryptDecrypt', () =>
130-
createPkpEncryptDecryptTest(ctx, () => aliceCustomAuthContext)());
131-
it('encryptDecryptFlow', () =>
132-
createEncryptDecryptFlowTest(ctx, () => aliceCustomAuthContext)());
133-
it('pkpPermissionsManagerFlow', () =>
134-
createPkpPermissionsManagerFlowTest(
135-
ctx,
136-
() => aliceCustomAuthContext
137-
)());
138-
});
125+
describe('endpoints', () => {
126+
it('pkpSign', () =>
127+
createPkpSignTest(ctx, () => aliceCustomAuthContext)());
128+
it('executeJs', () =>
129+
createExecuteJsTest(ctx, () => aliceCustomAuthContext)());
130+
it('viewPKPsByAddress', () =>
131+
createViewPKPsByAddressTest(ctx, () => aliceCustomAuthContext)());
132+
it('viewPKPsByAuthData', () =>
133+
createViewPKPsByAuthDataTest(ctx, () => aliceCustomAuthContext)());
134+
it('pkpEncryptDecrypt', () =>
135+
createPkpEncryptDecryptTest(ctx, () => aliceCustomAuthContext)());
136+
it('encryptDecryptFlow', () =>
137+
createEncryptDecryptFlowTest(ctx, () => aliceCustomAuthContext)());
138+
it('pkpPermissionsManagerFlow', () =>
139+
createPkpPermissionsManagerFlowTest(
140+
ctx,
141+
() => aliceCustomAuthContext
142+
)());
143+
});
139144

140-
describe('integrations', () => {
141-
describe('pkp viem account', () => {
142-
it('sign message', () =>
143-
createViemSignMessageTest(ctx, () => aliceCustomAuthContext)());
144-
it('sign transaction', () =>
145-
createViemSignTransactionTest(ctx, () => aliceCustomAuthContext)());
146-
it('sign typed data', () =>
147-
createViemSignTypedDataTest(ctx, () => aliceCustomAuthContext)());
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+
});
148154
});
149155
});
150-
});
151156

152-
describe('EOA Native', () => {
153-
console.log('🔐 Testing EOA native authentication and PKP minting');
157+
describe('EOA Native', () => {
158+
console.log('🔐 Testing EOA native authentication and PKP minting');
154159

155-
it('eoaNativeAuthFlow', () => createEoaNativeAuthFlowTest(ctx)());
160+
it('eoaNativeAuthFlow', () => createEoaNativeAuthFlowTest(ctx)());
161+
});
156162
});
157163
});

nx.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "./node_modules/nx/schemas/nx-schema.json",
33
"affected": {
4-
"defaultBase": "main"
4+
"defaultBase": "origin/master"
55
},
66
"tasksRunnerOptions": {
77
"default": {

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"gen:docs": "node ./tools/scripts/gen-doc.mjs",
2121
"gen:readme": "node ./tools/scripts/gen-readme.mjs",
2222
"prettier": "npx nx format:write --all",
23+
"format:check": "npx nx format:check --all",
2324
"link-all": "for dir in packages/*/; do echo \"Linking in $dir\"; (cd \"$dir\" && bun link) || { echo \"ERROR: Failed to link in $dir\"; exit 1; }; done",
2425
"unlink-all": "for dir in packages/*/; do echo \"Unlinking in $dir\"; (cd \"$dir\" && bun unlink) || { echo \"ERROR: Failed to unlink in $dir\"; exit 1; }; done",
2526
"auth-services": "cd packages/auth-services && bun run start",

packages/constants/src/lib/constants/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,3 +1428,6 @@ export const SIWE_URI_PREFIX = {
14281428

14291429
export type SIWE_URI_PREFIX_TYPE = ConstantKeys<typeof SIWE_URI_PREFIX>;
14301430
export type SIWE_URI_PREFIX_VALUES = ConstantValues<typeof SIWE_URI_PREFIX>;
1431+
1432+
1433+
export const DEV_PRIVATE_KEY = "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80";

packages/lit-client/src/lib/LitClient/createLitClient.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import {
5252
MintWithCustomAuthSchema,
5353
} from './schemas/MintWithCustomAuthSchema';
5454
import { NagaNetworkModule } from './type';
55+
import { DEV_PRIVATE_KEY } from '@lit-protocol/constants';
5556

5657
const _logger = getChildLogger({
5758
module: 'createLitClient',
@@ -175,8 +176,7 @@ export const _createNagaLitClient = async (
175176
}
176177
): Promise<LitNodeSignature> {
177178
_logger.info(
178-
`🔥 signing on ${params.chain} with ${params.signingScheme} (bypass: ${
179-
params.bypassAutoHashing || false
179+
`🔥 signing on ${params.chain} with ${params.signingScheme} (bypass: ${params.bypassAutoHashing || false
180180
})`
181181
);
182182

@@ -219,7 +219,7 @@ export const _createNagaLitClient = async (
219219
pricingContext: {
220220
product: 'SIGN',
221221
userMaxPrice: params.userMaxPrice,
222-
nodePrices: currentConnectionInfo.priceFeedInfo.networkPrices,
222+
nodePrices: jitContext.nodePrices,
223223
threshold: currentHandshakeResult.threshold,
224224
},
225225
authContext: params.authContext,
@@ -383,7 +383,7 @@ export const _createNagaLitClient = async (
383383
pricingContext: {
384384
product: 'LIT_ACTION',
385385
userMaxPrice: params.userMaxPrice,
386-
nodePrices: currentConnectionInfo.priceFeedInfo.networkPrices,
386+
nodePrices: jitContext.nodePrices,
387387
threshold: currentHandshakeResult.threshold,
388388
},
389389
authContext: params.authContext,
@@ -650,7 +650,7 @@ export const _createNagaLitClient = async (
650650
pricingContext: {
651651
product: 'DECRYPTION',
652652
userMaxPrice: params.userMaxPrice,
653-
nodePrices: currentConnectionInfo.priceFeedInfo.networkPrices,
653+
nodePrices: jitContext.nodePrices,
654654
threshold: currentHandshakeResult.threshold,
655655
},
656656
authContext: params.authContext,
@@ -809,7 +809,7 @@ export const _createNagaLitClient = async (
809809
viewPKPPermissions: async (pkpIdentifier: PkpIdentifierRaw) => {
810810
// It's an Anvil private key, chill. 🤣
811811
const account = privateKeyToAccount(
812-
'0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80'
812+
DEV_PRIVATE_KEY
813813
);
814814

815815
const pkpPermissionsManager =
@@ -829,18 +829,18 @@ export const _createNagaLitClient = async (
829829
},
830830
viewPKPsByAuthData: async (params: {
831831
authData:
832-
| {
833-
authMethodType: number | bigint;
834-
authMethodId: string;
835-
accessToken?: string;
836-
}
837-
| AuthData;
832+
| {
833+
authMethodType: number | bigint;
834+
authMethodId: string;
835+
accessToken?: string;
836+
}
837+
| AuthData;
838838
pagination?: { limit?: number; offset?: number };
839839
storageProvider?: PKPStorageProvider;
840840
}) => {
841841
// Use read-only account for viewing PKPs
842842
const account = privateKeyToAccount(
843-
'0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80'
843+
DEV_PRIVATE_KEY
844844
);
845845

846846
return await networkModule.chainApi.getPKPsByAuthData({
@@ -857,7 +857,7 @@ export const _createNagaLitClient = async (
857857
}) => {
858858
// Use read-only account for viewing PKPs
859859
const account = privateKeyToAccount(
860-
'0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80'
860+
DEV_PRIVATE_KEY
861861
);
862862

863863
return await networkModule.chainApi.getPKPsByAddress({

0 commit comments

Comments
 (0)