Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Ansonhkg committed Dec 19, 2024
1 parent 2b88caf commit 5fa589c
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 53 deletions.
1 change: 0 additions & 1 deletion packages/contracts-sdk/src/lib/contracts-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,6 @@ export class LitContracts {
});

const networks = activeValidatorStructs.map((item: ValidatorStruct) => {

// Convert the integer IP to a string format
const ip = intToIP(item.ip);
const port = item.port;
Expand Down
16 changes: 9 additions & 7 deletions packages/core/src/lib/lit-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ export class LitCore {

/**
* Gets the set of nodes from validator data, transforming bootstrap URLs into NodeSet objects.
*
*
* @returns {Promise<NodeSet[]>} A promise that resolves with an array of NodeSet objects.
*/
protected _getNodeSet = async (): Promise<NodeSet[]> => {
Expand Down Expand Up @@ -699,9 +699,11 @@ export class LitCore {
await Promise.race([
new Promise((_resolve, reject) => {
timeoutHandle = setTimeout(() => {
const msg = `Error: Could not handshake with nodes after timeout of ${this.config.connectTimeout
}ms. Could only connect to ${Object.keys(serverKeys).length} of ${this.config.bootstrapUrls.length
} nodes. Please check your network connection and try again. Note that you can control this timeout with the connectTimeout config option which takes milliseconds.`;
const msg = `Error: Could not handshake with nodes after timeout of ${
this.config.connectTimeout
}ms. Could only connect to ${Object.keys(serverKeys).length} of ${
this.config.bootstrapUrls.length
} nodes. Please check your network connection and try again. Note that you can control this timeout with the connectTimeout config option which takes milliseconds.`;

try {
throw new InitError({}, msg);
Expand Down Expand Up @@ -1029,8 +1031,8 @@ export class LitCore {
this._epochCache.currentNumber &&
this._epochCache.startTime &&
Math.floor(Date.now() / 1000) <
this._epochCache.startTime +
Math.floor(EPOCH_PROPAGATION_DELAY / 1000) &&
this._epochCache.startTime +
Math.floor(EPOCH_PROPAGATION_DELAY / 1000) &&
this._epochCache.currentNumber >= 3 // FIXME: Why this check?
) {
return this._epochCache.currentNumber - 1;
Expand Down Expand Up @@ -1061,7 +1063,7 @@ export class LitCore {
data,
requestId,
}: // eslint-disable-next-line @typescript-eslint/no-explicit-any
SendNodeCommand): Promise<any> => {
SendNodeCommand): Promise<any> => {
// FIXME: Replace <any> usage with explicit, strongly typed handlers
data = { ...data, epoch: this.currentEpochNumber };

Expand Down
23 changes: 12 additions & 11 deletions packages/lit-node-client-nodejs/src/lib/lit-node-client-nodejs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ import type {

export class LitNodeClientNodeJs
extends LitCore
implements LitClientSessionManager, ILitNodeClient {
implements LitClientSessionManager, ILitNodeClient
{
defaultAuthCallback?: (authSigParams: AuthCallbackParams) => Promise<AuthSig>;

// ========== Constructor ==========
Expand Down Expand Up @@ -871,7 +872,7 @@ export class LitNodeClientNodeJs
const reqBody: JsonExecutionRequest = {
...formattedParams,
authSig: sessionSig,
nodeSet
nodeSet,
};

const urlWithPath = composeLitUrl({
Expand Down Expand Up @@ -1163,10 +1164,10 @@ export class LitNodeClientNodeJs
// -- optional params
...(params.authMethods &&
params.authMethods.length > 0 && {
authMethods: params.authMethods,
}),
authMethods: params.authMethods,
}),

nodeSet
nodeSet,
};

logWithRequestId(requestId, 'reqBody:', reqBody);
Expand Down Expand Up @@ -1892,8 +1893,8 @@ export class LitNodeClientNodeJs
const sessionCapabilityObject = params.sessionCapabilityObject
? params.sessionCapabilityObject
: await this.generateSessionCapabilityObjectWithWildcards(
params.resourceAbilityRequests.map((r) => r.resource)
);
params.resourceAbilityRequests.map((r) => r.resource)
);
const expiration = params.expiration || LitNodeClientNodeJs.getExpiration();

// -- (TRY) to get the wallet signature
Expand Down Expand Up @@ -1975,10 +1976,10 @@ export class LitNodeClientNodeJs

const capabilities = params.capacityDelegationAuthSig
? [
...(params.capabilityAuthSigs ?? []),
params.capacityDelegationAuthSig,
authSig,
]
...(params.capabilityAuthSigs ?? []),
params.capacityDelegationAuthSig,
authSig,
]
: [...(params.capabilityAuthSigs ?? []), authSig];

// This is the template that will be combined with the node address as a single object, then signed by the session key
Expand Down
67 changes: 33 additions & 34 deletions packages/types/src/lib/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ export interface JsonPkpSignSdkParams extends BaseJsonPkpSignRequest {
*/
export interface JsonPkpSignRequest
extends BaseJsonPkpSignRequest,
NodeSetRequired {
NodeSetRequired {
authSig: AuthSig;

/**
Expand Down Expand Up @@ -280,7 +280,6 @@ export interface JsonSignChainDataRequest {
// Naga V8: Selected Nodes for ECDSA endpoints #1223
// https://github.com/LIT-Protocol/lit-assets/pull/1223/
export interface NodeSet {

// reference: https://github.com/LIT-Protocol/lit-assets/blob/f82b28e83824a861547307aaed981a6186e51d48/rust/lit-node/common/lit-node-testnet/src/node_collection.rs#L185-L191
// eg: 192.168.0.1:8080
socketAddress: string;
Expand All @@ -297,8 +296,8 @@ export interface NodeSetRequired {

export interface JsonSignSessionKeyRequestV1
extends Pick<LitActionSdkParams, 'jsParams'>,
Pick<LitActionSdkParams, 'litActionIpfsId'>,
NodeSetRequired {
Pick<LitActionSdkParams, 'litActionIpfsId'>,
NodeSetRequired {
sessionKey: string;
authMethods: AuthMethod[];
pkpPublicKey?: string;
Expand Down Expand Up @@ -482,7 +481,7 @@ export interface JsonExecutionSdkParamsTargetNode

export interface JsonExecutionSdkParams
extends Pick<LitActionSdkParams, 'jsParams'>,
ExecuteJsAdvancedOptions {
ExecuteJsAdvancedOptions {
/**
* JS code to run on the nodes
*/
Expand Down Expand Up @@ -528,7 +527,7 @@ export interface JsonExecutionRequestTargetNode extends JsonExecutionRequest {

export interface JsonExecutionRequest
extends Pick<LitActionSdkParams, 'jsParams'>,
NodeSetRequired {
NodeSetRequired {
authSig: AuthSig;

/**
Expand Down Expand Up @@ -559,7 +558,7 @@ export interface SessionSigsOrAuthSig {

export interface DecryptRequestBase
extends SessionSigsOrAuthSig,
MultipleAccessControlConditions {
MultipleAccessControlConditions {
/**
* The chain name of the chain that this contract is deployed on. See LIT_CHAINS for currently supported chains.
*/
Expand Down Expand Up @@ -605,7 +604,7 @@ export interface EncryptFileRequest extends DecryptRequestBase {
file: AcceptedFileType;
}

export interface DecryptRequest extends EncryptResponse, DecryptRequestBase { }
export interface DecryptRequest extends EncryptResponse, DecryptRequestBase {}

export interface DecryptResponse {
// The decrypted data as a Uint8Array
Expand All @@ -627,10 +626,10 @@ export interface SigResponse {

export interface ExecuteJsResponseBase {
signatures:
| {
sig: SigResponse;
}
| any;
| {
sig: SigResponse;
}
| any;
}

/**
Expand Down Expand Up @@ -660,7 +659,7 @@ export interface ExecuteJsNoSigningResponse extends ExecuteJsResponseBase {
logs: string;
}

export interface LitNodePromise { }
export interface LitNodePromise {}

export interface SendNodeCommand {
url: string;
Expand All @@ -669,10 +668,10 @@ export interface SendNodeCommand {
}
export interface SigShare {
sigType:
| 'BLS'
| 'K256'
| 'ECDSA_CAIT_SITH' // Legacy alias of K256
| 'EcdsaCaitSithP256';
| 'BLS'
| 'K256'
| 'ECDSA_CAIT_SITH' // Legacy alias of K256
| 'EcdsaCaitSithP256';

signatureShare: string;
shareIndex?: number;
Expand Down Expand Up @@ -1117,7 +1116,7 @@ export interface CommonGetSessionSigsProps {

export interface BaseProviderGetSessionSigsProps
extends CommonGetSessionSigsProps,
LitActionSdkParams {
LitActionSdkParams {
/**
* This is a callback that will be used to generate an AuthSig within the session signatures. It's inclusion is required, as it defines the specific resources and abilities that will be allowed for the current session.
*/
Expand All @@ -1126,7 +1125,7 @@ export interface BaseProviderGetSessionSigsProps

export interface GetSessionSigsProps
extends CommonGetSessionSigsProps,
LitActionSdkParams {
LitActionSdkParams {
/**
* This is a callback that will be used to generate an AuthSig within the session signatures. It's inclusion is required, as it defines the specific resources and abilities that will be allowed for the current session.
*/
Expand Down Expand Up @@ -1621,7 +1620,7 @@ export interface BaseProviderSessionSigsParams {
resourceAbilityRequests?: LitResourceAbilityRequest[];
}

export interface BaseAuthenticateOptions { }
export interface BaseAuthenticateOptions {}

export interface EthWalletAuthenticateOptions extends BaseAuthenticateOptions {
/**
Expand Down Expand Up @@ -1687,9 +1686,9 @@ export interface MintCapacityCreditsPerKilosecond
}
export interface MintCapacityCreditsContext
extends MintCapacityCreditsPerDay,
MintCapacityCreditsPerSecond,
MintCapacityCreditsPerKilosecond,
GasLimitParam { }
MintCapacityCreditsPerSecond,
MintCapacityCreditsPerKilosecond,
GasLimitParam {}
export interface MintCapacityCreditsRes {
rliTxHash: string;
capacityTokenId: any;
Expand Down Expand Up @@ -1812,12 +1811,12 @@ export interface LitActionSdkParams {
* An object that contains params to expose to the Lit Action. These will be injected to the JS runtime before your code runs, so you can use any of these as normal variables in your Lit Action.
*/
jsParams?:
| {
[key: string]: any;
publicKey?: string;
sigName?: string;
}
| any;
| {
[key: string]: any;
publicKey?: string;
sigName?: string;
}
| any;
}

export interface LitEndpoint {
Expand All @@ -1839,7 +1838,7 @@ export interface SignerLike {

export interface GetPkpSessionSigs
extends CommonGetSessionSigsProps,
LitActionSdkParams {
LitActionSdkParams {
pkpPublicKey: string;

/**
Expand All @@ -1865,11 +1864,11 @@ export type GetLitActionSessionSigs = CommonGetSessionSigsProps &
Pick<Required<LitActionSdkParams>, 'jsParams'> &
(
| (Pick<Required<LitActionSdkParams>, 'litActionCode'> & {
litActionIpfsId?: never;
})
litActionIpfsId?: never;
})
| (Pick<Required<LitActionSdkParams>, 'litActionIpfsId'> & {
litActionCode?: never;
})
litActionCode?: never;
})
) & {
ipfsOptions?: IpfsOptions;
};
Expand Down

0 comments on commit 5fa589c

Please sign in to comment.