Skip to content

Commit 4ef2b8e

Browse files
committed
fmt
1 parent 4766389 commit 4ef2b8e

File tree

6 files changed

+91
-86
lines changed

6 files changed

+91
-86
lines changed

local-tests/tests/testUseEoaSessionSigsToPkpSign.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ export const testUseEoaSessionSigsToPkpSign = async (
1414
const alice = await devEnv.createRandomPerson();
1515

1616
const eoaSessionSigs = await getEoaSessionSigs(devEnv, alice);
17-
1817
const runWithSessionSigs = await devEnv.litNodeClient.pkpSign({
1918
toSign: alice.loveLetter,
2019
pubKey: alice.pkp.publicKey,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1273,7 +1273,7 @@ export const LIT_CURVE = {
12731273
EcdsaK256: 'K256',
12741274
EcdsaCaitSith: 'ECDSA_CAIT_SITH', // Legacy alias of K256
12751275
EcdsaCAITSITHP256: 'EcdsaCaitSithP256',
1276-
EcdsaK256Sha256: 'EcdsaK256Sha256', // same as caitsith
1276+
EcdsaK256Sha256: 'EcdsaK256Sha256', // same as caitsith
12771277
} as const;
12781278

12791279
export type LIT_CURVE_TYPE = keyof typeof LIT_CURVE;

packages/contracts-sdk/src/lib/contracts-sdk.ts

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -620,18 +620,18 @@ export class LitContracts {
620620
};
621621

622622
/**
623-
* Retrieves the PriceFeed contract instance based on the provided network, context, and RPC URL.
624-
* If a context is provided, it determines if a contract resolver is used for bootstrapping contracts.
625-
* If a resolver address is present in the context, it retrieves the PriceFeed contract from the contract resolver instance.
626-
* Otherwise, it retrieves the PriceFeed contract using the contract address and ABI.
627-
* Throws an error if required contract data is missing or if the PriceFeed contract cannot be obtained.
628-
*
629-
* @param network - The network key.
630-
* @param context - The contract context or contract resolver context.
631-
* @param rpcUrl - The RPC URL.
632-
* @returns The PriceFeed contract instance.
633-
* @throws Error if required contract data is missing or if the PriceFeed contract cannot be obtained.
634-
*/
623+
* Retrieves the PriceFeed contract instance based on the provided network, context, and RPC URL.
624+
* If a context is provided, it determines if a contract resolver is used for bootstrapping contracts.
625+
* If a resolver address is present in the context, it retrieves the PriceFeed contract from the contract resolver instance.
626+
* Otherwise, it retrieves the PriceFeed contract using the contract address and ABI.
627+
* Throws an error if required contract data is missing or if the PriceFeed contract cannot be obtained.
628+
*
629+
* @param network - The network key.
630+
* @param context - The contract context or contract resolver context.
631+
* @param rpcUrl - The RPC URL.
632+
* @returns The PriceFeed contract instance.
633+
* @throws Error if required contract data is missing or if the PriceFeed contract cannot be obtained.
634+
*/
635635
public static async getPriceFeedContract(
636636
network: LIT_NETWORKS_KEYS,
637637
context?: LitContractContext | LitContractResolverContext,
@@ -1281,16 +1281,16 @@ export class LitContracts {
12811281
rpcUrl,
12821282
nodeProtocol,
12831283
}: {
1284-
litNetwork: LIT_NETWORKS_KEYS,
1284+
litNetwork: LIT_NETWORKS_KEYS;
12851285
networkContext?: LitContractContext | LitContractResolverContext;
12861286
rpcUrl?: string;
12871287
nodeProtocol?: typeof HTTP | typeof HTTPS | null;
12881288
}) => {
12891289
const priceFeedContract = await LitContracts.getPriceFeedContract(
12901290
litNetwork,
12911291
networkContext,
1292-
rpcUrl,
1293-
)
1292+
rpcUrl
1293+
);
12941294

12951295
const nodesForRequest = await priceFeedContract['getNodesForRequest']([0]);
12961296

@@ -1300,18 +1300,20 @@ export class LitContracts {
13001300

13011301
// const totalNodes = nodesAndPrices.length;
13021302

1303-
const activeValidatorStructs: ValidatorStruct[] = nodesAndPrices.map((item: any) => {
1304-
const activeUnkickedValidatorStruct = item.validator;
1305-
return {
1306-
ip: activeUnkickedValidatorStruct.ip,
1307-
ipv6: activeUnkickedValidatorStruct.ipv6,
1308-
port: activeUnkickedValidatorStruct.port,
1309-
nodeAddress: activeUnkickedValidatorStruct.nodeAddress,
1310-
reward: activeUnkickedValidatorStruct.reward,
1311-
seconderPubkey: activeUnkickedValidatorStruct.seconderPubkey,
1312-
receiverPubkey: activeUnkickedValidatorStruct.receiverPubkey,
1303+
const activeValidatorStructs: ValidatorStruct[] = nodesAndPrices.map(
1304+
(item: any) => {
1305+
const activeUnkickedValidatorStruct = item.validator;
1306+
return {
1307+
ip: activeUnkickedValidatorStruct.ip,
1308+
ipv6: activeUnkickedValidatorStruct.ipv6,
1309+
port: activeUnkickedValidatorStruct.port,
1310+
nodeAddress: activeUnkickedValidatorStruct.nodeAddress,
1311+
reward: activeUnkickedValidatorStruct.reward,
1312+
seconderPubkey: activeUnkickedValidatorStruct.seconderPubkey,
1313+
receiverPubkey: activeUnkickedValidatorStruct.receiverPubkey,
1314+
};
13131315
}
1314-
});
1316+
);
13151317

13161318
const networks = activeValidatorStructs.map((item: ValidatorStruct) => {
13171319
// Convert the integer IP to a string format
@@ -1334,21 +1336,23 @@ export class LitContracts {
13341336
return url;
13351337
});
13361338

1337-
console.log("networks:", networks);
1339+
console.log('networks:', networks);
13381340

13391341
const prices = nodesAndPrices.flatMap((item: any) => {
13401342
// Flatten the nested prices array and convert BigNumber to number
1341-
return item.prices.map((price: ethers.BigNumber) => parseFloat(price.toString()));
1343+
return item.prices.map((price: ethers.BigNumber) =>
1344+
parseFloat(price.toString())
1345+
);
13421346
});
13431347

1344-
console.log("Prices as numbers:", prices);
1348+
console.log('Prices as numbers:', prices);
13451349

13461350
const networkPriceMap = networks.reduce((acc: any, network, index) => {
13471351
acc[network] = prices[index];
13481352
return acc;
13491353
}, {});
13501354

1351-
console.log("Network to Price Map:", networkPriceMap);
1355+
console.log('Network to Price Map:', networkPriceMap);
13521356

13531357
const networkPriceObjArr = networks.map((network, index) => {
13541358
return {
@@ -1362,10 +1366,10 @@ export class LitContracts {
13621366
minNodeCount,
13631367
networkPrices: {
13641368
arrObjects: networkPriceObjArr,
1365-
map: networkPriceMap
1369+
map: networkPriceMap,
13661370
},
1367-
}
1368-
}
1371+
};
1372+
};
13691373

13701374
private static async _resolveContractContext(
13711375
network: LIT_NETWORK_VALUES

packages/core/src/lib/lit-core.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -699,9 +699,11 @@ export class LitCore {
699699
await Promise.race([
700700
new Promise((_resolve, reject) => {
701701
timeoutHandle = setTimeout(() => {
702-
const msg = `Error: Could not handshake with nodes after timeout of ${this.config.connectTimeout
703-
}ms. Could only connect to ${Object.keys(serverKeys).length} of ${this.config.bootstrapUrls.length
704-
} nodes. Please check your network connection and try again. Note that you can control this timeout with the connectTimeout config option which takes milliseconds.`;
702+
const msg = `Error: Could not handshake with nodes after timeout of ${
703+
this.config.connectTimeout
704+
}ms. Could only connect to ${Object.keys(serverKeys).length} of ${
705+
this.config.bootstrapUrls.length
706+
} nodes. Please check your network connection and try again. Note that you can control this timeout with the connectTimeout config option which takes milliseconds.`;
705707

706708
try {
707709
throw new InitError({}, msg);
@@ -1029,8 +1031,8 @@ export class LitCore {
10291031
this._epochCache.currentNumber &&
10301032
this._epochCache.startTime &&
10311033
Math.floor(Date.now() / 1000) <
1032-
this._epochCache.startTime +
1033-
Math.floor(EPOCH_PROPAGATION_DELAY / 1000) &&
1034+
this._epochCache.startTime +
1035+
Math.floor(EPOCH_PROPAGATION_DELAY / 1000) &&
10341036
this._epochCache.currentNumber >= 3 // FIXME: Why this check?
10351037
) {
10361038
return this._epochCache.currentNumber - 1;
@@ -1061,7 +1063,7 @@ export class LitCore {
10611063
data,
10621064
requestId,
10631065
}: // eslint-disable-next-line @typescript-eslint/no-explicit-any
1064-
SendNodeCommand): Promise<any> => {
1066+
SendNodeCommand): Promise<any> => {
10651067
// FIXME: Replace <any> usage with explicit, strongly typed handlers
10661068
data = { ...data, epoch: this.currentEpochNumber };
10671069

packages/lit-node-client-nodejs/src/lib/lit-node-client-nodejs.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ import { LitContracts } from '@lit-protocol/contracts-sdk';
137137

138138
export class LitNodeClientNodeJs
139139
extends LitCore
140-
implements LitClientSessionManager, ILitNodeClient {
140+
implements LitClientSessionManager, ILitNodeClient
141+
{
141142
defaultAuthCallback?: (authSigParams: AuthCallbackParams) => Promise<AuthSig>;
142143

143144
// ========== Constructor ==========
@@ -1164,8 +1165,8 @@ export class LitNodeClientNodeJs
11641165
// -- optional params
11651166
...(params.authMethods &&
11661167
params.authMethods.length > 0 && {
1167-
authMethods: params.authMethods,
1168-
}),
1168+
authMethods: params.authMethods,
1169+
}),
11691170

11701171
nodeSet,
11711172
};
@@ -1217,7 +1218,7 @@ export class LitNodeClientNodeJs
12171218

12181219
return signatures.signature; // only a single signature is ever present, so we just return it.
12191220
} catch (e) {
1220-
console.error("Error getting signature", e);
1221+
console.error('Error getting signature', e);
12211222
throw e;
12221223
}
12231224
};
@@ -1898,8 +1899,8 @@ export class LitNodeClientNodeJs
18981899
const sessionCapabilityObject = params.sessionCapabilityObject
18991900
? params.sessionCapabilityObject
19001901
: await this.generateSessionCapabilityObjectWithWildcards(
1901-
params.resourceAbilityRequests.map((r) => r.resource)
1902-
);
1902+
params.resourceAbilityRequests.map((r) => r.resource)
1903+
);
19031904
const expiration = params.expiration || LitNodeClientNodeJs.getExpiration();
19041905

19051906
// -- (TRY) to get the wallet signature
@@ -1981,10 +1982,10 @@ export class LitNodeClientNodeJs
19811982

19821983
const capabilities = params.capacityDelegationAuthSig
19831984
? [
1984-
...(params.capabilityAuthSigs ?? []),
1985-
params.capacityDelegationAuthSig,
1986-
authSig,
1987-
]
1985+
...(params.capabilityAuthSigs ?? []),
1986+
params.capacityDelegationAuthSig,
1987+
authSig,
1988+
]
19881989
: [...(params.capabilityAuthSigs ?? []), authSig];
19891990

19901991
// get max price from contract
@@ -2014,7 +2015,6 @@ export class LitNodeClientNodeJs
20142015
const sessionSigs: SessionSigsMap = {};
20152016

20162017
this.connectedNodes.forEach((nodeAddress: string) => {
2017-
20182018
const maxPrice = priceFeedInfo.networkPrices.map[nodeAddress];
20192019

20202020
if (maxPrice <= 0) {

0 commit comments

Comments
 (0)