Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,36 @@ jobs:
- name: Install project dependencies
run: bun install

- name: Debug Git and Environment
run: |
echo "Current branch:"
git branch --show-current
echo "Available branches:"
git branch -a
echo "Git remotes:"
git remote -v
echo "Last 3 commits:"
git log --oneline -3
echo "Git status:"
git status
echo "NX configuration:"
cat nx.json | head -10
echo "Prettier configuration:"
cat .prettierrc

- name: Lint
run: bun run nx format:check --all
run: |
echo "Running format check..."
# Use prettier directly to avoid NX git issues
npx prettier --check . || {
echo "Format check failed. Running prettier --write to fix issues..."
npx prettier --write .
echo "Checking again after formatting..."
npx prettier --check . || {
echo "Still failing after auto-format. Manual intervention needed."
exit 1
}
echo "Auto-formatting successful. All files are now properly formatted."
echo "Note: Some files were auto-formatted. Consider committing these changes in your next commit."
}
echo "Format check passed!"
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ tools
/packages/wasm/rust/*
/packages/wasm/src/pkg/*
**/*/dist

# Network schema files and generated files
packages/networks/src/networks/vNaga/**/*.ts
packages/wrapped-keys-lit-actions/src/lib/**/*.ts
1 change: 0 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"insertPragma": false,
"singleAttributePerLine": false,
"bracketSameLine": false,
"jsxBracketSameLine": false,
"jsxSingleQuote": false,
"printWidth": 80,
"proseWrap": "preserve",
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<div align="center">
<h1>Lit Protocol Javascript/Typescript SDK V8.x.x</h1>


<img src="https://i.ibb.co/p2xfzK1/Screenshot-2022-11-15-at-09-56-57.png">
<br/>
<a href="https://twitter.com/LitProtocol"><img src="https://img.shields.io/twitter/follow/litprotocol?label=Follow&style=social"/></a>
Expand Down
152 changes: 79 additions & 73 deletions e2e/src/e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,93 +65,99 @@ describe('all', () => {
createPaymentManagerFlowTest(ctx, () => ctx.aliceEoaAuthContext)());
it('paymentDelegationFlow', () =>
createPaymentDelegationFlowTest(ctx, () => ctx.aliceEoaAuthContext)());
});

describe('integrations', () => {
describe('pkp viem account', () => {
it('sign message', () =>
createViemSignMessageTest(ctx, () => ctx.aliceEoaAuthContext)());
it('sign transaction', () =>
createViemSignTransactionTest(ctx, () => ctx.aliceEoaAuthContext)());
it('sign typed data', () =>
createViemSignTypedDataTest(ctx, () => ctx.aliceEoaAuthContext)());
describe('integrations', () => {
describe('pkp viem account', () => {
it('sign message', () =>
createViemSignMessageTest(ctx, () => ctx.aliceEoaAuthContext)());
it('sign transaction', () =>
createViemSignTransactionTest(
ctx,
() => ctx.aliceEoaAuthContext
)());
it('sign typed data', () =>
createViemSignTypedDataTest(ctx, () => ctx.aliceEoaAuthContext)());
});
});
});
});

describe('PKP Auth', () => {
console.log('🔐 Testing using Programmable Key Pair authentication');
describe('PKP Auth', () => {
console.log('🔐 Testing using Programmable Key Pair authentication');

describe('endpoints', () => {
it('pkpSign', () =>
createPkpSignTest(ctx, () => ctx.alicePkpAuthContext)());
it('executeJs', () =>
createExecuteJsTest(ctx, () => ctx.alicePkpAuthContext)());
it('viewPKPsByAddress', () =>
createViewPKPsByAddressTest(ctx, () => ctx.alicePkpAuthContext)());
it('viewPKPsByAuthData', () =>
createViewPKPsByAuthDataTest(ctx, () => ctx.alicePkpAuthContext)());
it('pkpEncryptDecrypt', () =>
createPkpEncryptDecryptTest(ctx, () => ctx.alicePkpAuthContext)());
it('encryptDecryptFlow', () =>
createEncryptDecryptFlowTest(ctx, () => ctx.alicePkpAuthContext)());
it('pkpPermissionsManagerFlow', () =>
createPkpPermissionsManagerFlowTest(
ctx,
() => ctx.alicePkpAuthContext
)());
});
describe('endpoints', () => {
it('pkpSign', () =>
createPkpSignTest(ctx, () => ctx.alicePkpAuthContext)());
it('executeJs', () =>
createExecuteJsTest(ctx, () => ctx.alicePkpAuthContext)());
it('viewPKPsByAddress', () =>
createViewPKPsByAddressTest(ctx, () => ctx.alicePkpAuthContext)());
it('viewPKPsByAuthData', () =>
createViewPKPsByAuthDataTest(ctx, () => ctx.alicePkpAuthContext)());
it('pkpEncryptDecrypt', () =>
createPkpEncryptDecryptTest(ctx, () => ctx.alicePkpAuthContext)());
it('encryptDecryptFlow', () =>
createEncryptDecryptFlowTest(ctx, () => ctx.alicePkpAuthContext)());
it('pkpPermissionsManagerFlow', () =>
createPkpPermissionsManagerFlowTest(
ctx,
() => ctx.alicePkpAuthContext
)());
});

describe('integrations', () => {
describe('pkp viem account', () => {
it('sign message', () =>
createViemSignMessageTest(ctx, () => ctx.alicePkpAuthContext)());
it('sign transaction', () =>
createViemSignTransactionTest(ctx, () => ctx.alicePkpAuthContext)());
it('sign typed data', () =>
createViemSignTypedDataTest(ctx, () => ctx.alicePkpAuthContext)());
describe('integrations', () => {
describe('pkp viem account', () => {
it('sign message', () =>
createViemSignMessageTest(ctx, () => ctx.alicePkpAuthContext)());
it('sign transaction', () =>
createViemSignTransactionTest(
ctx,
() => ctx.alicePkpAuthContext
)());
it('sign typed data', () =>
createViemSignTypedDataTest(ctx, () => ctx.alicePkpAuthContext)());
});
});
});
});

describe('Custom Auth', () => {
console.log('🔐 Testing using Custom authentication method');
describe('Custom Auth', () => {
console.log('🔐 Testing using Custom authentication method');

describe('endpoints', () => {
it('pkpSign', () =>
createPkpSignTest(ctx, () => aliceCustomAuthContext)());
it('executeJs', () =>
createExecuteJsTest(ctx, () => aliceCustomAuthContext)());
it('viewPKPsByAddress', () =>
createViewPKPsByAddressTest(ctx, () => aliceCustomAuthContext)());
it('viewPKPsByAuthData', () =>
createViewPKPsByAuthDataTest(ctx, () => aliceCustomAuthContext)());
it('pkpEncryptDecrypt', () =>
createPkpEncryptDecryptTest(ctx, () => aliceCustomAuthContext)());
it('encryptDecryptFlow', () =>
createEncryptDecryptFlowTest(ctx, () => aliceCustomAuthContext)());
it('pkpPermissionsManagerFlow', () =>
createPkpPermissionsManagerFlowTest(
ctx,
() => aliceCustomAuthContext
)());
});
describe('endpoints', () => {
it('pkpSign', () =>
createPkpSignTest(ctx, () => aliceCustomAuthContext)());
it('executeJs', () =>
createExecuteJsTest(ctx, () => aliceCustomAuthContext)());
it('viewPKPsByAddress', () =>
createViewPKPsByAddressTest(ctx, () => aliceCustomAuthContext)());
it('viewPKPsByAuthData', () =>
createViewPKPsByAuthDataTest(ctx, () => aliceCustomAuthContext)());
it('pkpEncryptDecrypt', () =>
createPkpEncryptDecryptTest(ctx, () => aliceCustomAuthContext)());
it('encryptDecryptFlow', () =>
createEncryptDecryptFlowTest(ctx, () => aliceCustomAuthContext)());
it('pkpPermissionsManagerFlow', () =>
createPkpPermissionsManagerFlowTest(
ctx,
() => aliceCustomAuthContext
)());
});

describe('integrations', () => {
describe('pkp viem account', () => {
it('sign message', () =>
createViemSignMessageTest(ctx, () => aliceCustomAuthContext)());
it('sign transaction', () =>
createViemSignTransactionTest(ctx, () => aliceCustomAuthContext)());
it('sign typed data', () =>
createViemSignTypedDataTest(ctx, () => aliceCustomAuthContext)());
describe('integrations', () => {
describe('pkp viem account', () => {
it('sign message', () =>
createViemSignMessageTest(ctx, () => aliceCustomAuthContext)());
it('sign transaction', () =>
createViemSignTransactionTest(ctx, () => aliceCustomAuthContext)());
it('sign typed data', () =>
createViemSignTypedDataTest(ctx, () => aliceCustomAuthContext)());
});
});
});
});

describe('EOA Native', () => {
console.log('🔐 Testing EOA native authentication and PKP minting');
describe('EOA Native', () => {
console.log('🔐 Testing EOA native authentication and PKP minting');

it('eoaNativeAuthFlow', () => createEoaNativeAuthFlowTest(ctx)());
it('eoaNativeAuthFlow', () => createEoaNativeAuthFlowTest(ctx)());
});
});
});
2 changes: 1 addition & 1 deletion nx.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"affected": {
"defaultBase": "main"
"defaultBase": "origin/master"
Copy link
Preview

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing the default base from 'main' to 'origin/master' may cause issues if the repository's primary branch is actually 'main'. Verify that 'master' is the correct primary branch name for this repository.

Suggested change
"defaultBase": "origin/master"
"defaultBase": "main"

Copilot uses AI. Check for mistakes.

},
"tasksRunnerOptions": {
"default": {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"gen:docs": "node ./tools/scripts/gen-doc.mjs",
"gen:readme": "node ./tools/scripts/gen-readme.mjs",
"prettier": "npx nx format:write --all",
"format:check": "npx nx format:check --all",
"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",
"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",
"auth-services": "cd packages/auth-services && bun run start",
Expand Down
6 changes: 3 additions & 3 deletions packages/lit-client/src/lib/LitClient/createLitClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ export const _createNagaLitClient = async (
pricingContext: {
product: 'SIGN',
userMaxPrice: params.userMaxPrice,
nodePrices: currentConnectionInfo.priceFeedInfo.networkPrices,
nodePrices: jitContext.nodePrices,
threshold: currentHandshakeResult.threshold,
},
authContext: params.authContext,
Expand Down Expand Up @@ -383,7 +383,7 @@ export const _createNagaLitClient = async (
pricingContext: {
product: 'LIT_ACTION',
userMaxPrice: params.userMaxPrice,
nodePrices: currentConnectionInfo.priceFeedInfo.networkPrices,
nodePrices: jitContext.nodePrices,
threshold: currentHandshakeResult.threshold,
},
authContext: params.authContext,
Expand Down Expand Up @@ -650,7 +650,7 @@ export const _createNagaLitClient = async (
pricingContext: {
product: 'DECRYPTION',
userMaxPrice: params.userMaxPrice,
nodePrices: currentConnectionInfo.priceFeedInfo.networkPrices,
nodePrices: jitContext.nodePrices,
threshold: currentHandshakeResult.threshold,
},
authContext: params.authContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,18 @@
* ```
*/

const _logger = getChildLogger({
module: 'priceFeedApi',
});

import { NodePrices } from '@lit-protocol/types';
import { ExpectedAccountOrWalletClient } from '../../../../LitChainClient/contract-manager/createContractsManager';
import { DefaultNetworkConfig } from '../../../../interfaces/NetworkContext';
import { INetworkConfig } from '../../../../interfaces/NetworkContext';
import {
getNodesForRequest,
PRODUCT_IDS,
} from '../../../apis/rawContractApis/pricing/getNodesForRequest';
import { getChildLogger } from '@lit-protocol/logger';

// Configuration constants
const STALE_PRICES_SECONDS = 3 * 1000; // Update prices if > X seconds old
Expand All @@ -38,16 +44,13 @@ const PRODUCT_IDS_ARRAY = Object.values(PRODUCT_IDS);
export interface PriceFeedInfo {
epochId: any;
minNodeCount: any;
networkPrices: {
url: string;
prices: bigint[];
}[];
networkPrices: NodePrices;
}

// Type for the parameters
// Type for the parameters - now accepts any valid network config
export interface GetPriceFeedInfoParams {
realmId?: number;
networkCtx: DefaultNetworkConfig;
networkCtx: INetworkConfig<any, any>;
productIds?: bigint[];
}

Expand Down Expand Up @@ -154,6 +157,9 @@ export async function getPriceFeedInfo(
): Promise<PriceFeedInfo> {
// If there's a local promise, an update is in progress; wait for that
if (fetchingPriceFeedInfo) {
_logger.info(
'💲 Local promise is already fetching price feed info. Returning that instead.'
);
return fetchingPriceFeedInfo;
}

Expand All @@ -162,9 +168,14 @@ export async function getPriceFeedInfo(
priceFeedInfo &&
Date.now() - lastUpdatedTimestamp < STALE_PRICES_SECONDS
) {
_logger.info(
`💲 Returning stale price feed info. Remaining stale time: ${
STALE_PRICES_SECONDS - (Date.now() - lastUpdatedTimestamp)
}ms`
);
return priceFeedInfo;
}

_logger.info('💲 Fetching new price feed info');
// Fetch new prices, update local cache values, and return them
return fetchPriceFeedInfoWithLocalPromise(params, accountOrWalletClient);
}
Expand All @@ -191,7 +202,7 @@ export async function getPriceFeedInfo(
export async function getNodePrices(
params: GetPriceFeedInfoParams,
accountOrWalletClient: ExpectedAccountOrWalletClient
): Promise<PriceFeedInfo['networkPrices']> {
): Promise<NodePrices> {
const priceInfo = await getPriceFeedInfo(params, accountOrWalletClient);
return priceInfo.networkPrices;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { z } from 'zod';
import { generateValidatorURLs } from '../../../../../shared/utils/transformers';
import { DefaultNetworkConfig } from '../../../../interfaces/NetworkContext';
import {
DefaultNetworkConfig,
INetworkConfig,
} from '../../../../interfaces/NetworkContext';
import {
createContractsManager,
ExpectedAccountOrWalletClient,
Expand All @@ -27,18 +30,15 @@ const getNodesForRequestSchema = z.object({
type GetNodesForRequestRequest = z.infer<typeof getNodesForRequestSchema>;

/**
* Get nodes available for a request with their pricing information
*
* This function retrieves information about nodes that can service a request,
* including their pricing data for various product IDs.
* Gets nodes for a given set of product IDs with their prices
*
* @param request - Object containing product IDs to get pricing for
* @param networkCtx - The Naga network context
* @param networkCtx - The network context (any valid network configuration)
* @returns Information about nodes, their prices, epoch ID, and minimum node count
*/
export async function getNodesForRequest(
request: GetNodesForRequestRequest,
networkCtx: DefaultNetworkConfig,
networkCtx: INetworkConfig<any, any>,
accountOrWalletClient: ExpectedAccountOrWalletClient
) {
const { productIds } = getNodesForRequestSchema.parse(request);
Expand Down
Loading
Loading