Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion packages/constants/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Quick Start

This submodule exports various modules, constants, interfaces, enums, errors, utilities that are being used in Lit Protocol.
This submodule exports various modules, constants, interfaces, errors, utilities that are being used in Lit Protocol.

### node.js / browser

Expand Down
3 changes: 0 additions & 3 deletions packages/constants/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ export * from './lib/constants/mappers';
// ----------- Interfaces -----------
export * from './lib/interfaces/i-errors';

// ----------- ENUMS -----------
export * from './lib/enums';

// ----------- Errors -----------
export * from './lib/errors';

Expand Down
108 changes: 97 additions & 11 deletions packages/constants/src/lib/constants/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
} from '@lit-protocol/types';

import { INTERNAL_DEV } from './autogen_internal';
import { LitNetwork } from '../enums';

/**
* Lit Protocol Network Public Key
Expand Down Expand Up @@ -698,7 +697,7 @@ export const LIT_NETWORK = {
Datil: 'datil',
Custom: 'custom',
Localhost: 'localhost',
};
} as const;

/**
* The type representing the keys of the LIT_NETWORK object.
Expand All @@ -707,6 +706,7 @@ export type LIT_NETWORK_TYPES = keyof typeof LIT_NETWORK;

/**
* The type representing the values of the LIT_NETWORK object.
* This should duplicate LIT_NETWORKS_KEYS in types package
*/
export type LIT_NETWORK_VALUES = (typeof LIT_NETWORK)[keyof typeof LIT_NETWORK];

Expand Down Expand Up @@ -766,14 +766,15 @@ export const HTTPS = 'https://';
* Mapping of network values to corresponding http protocol.
*/
export const HTTP_BY_NETWORK: Record<
LIT_NETWORK_VALUES,
LIT_NETWORK_VALUES | 'internalDev',
typeof HTTP | typeof HTTPS
> = {
cayenne: HTTPS,
manzano: HTTPS,
habanero: HTTPS,
'datil-dev': HTTPS,
'datil-test': HTTPS,
datil: HTTPS,
internalDev: HTTPS,
custom: HTTP, // default, can be changed by config
localhost: HTTP, // default, can be changed by config
Expand Down Expand Up @@ -944,17 +945,17 @@ export const CAYENNE_URL = 'https://cayenne.litgateway.com';
* Note: Dynamic networks such as Habanero have no default node URLS; they are always
* loaded from the chain during initialization
*/
export const LIT_NETWORKS: { [key in LitNetwork]: string[] } & {
export const LIT_NETWORKS: { [key in LIT_NETWORK_VALUES]: string[] } & {
localhost: string[];
internalDev: string[];
} = {
[LitNetwork.Cayenne]: [],
[LitNetwork.Manzano]: [],
[LitNetwork.DatilDev]: [],
[LitNetwork.DatilTest]: [],
[LitNetwork.Datil]: [],
[LitNetwork.Habanero]: [],
[LitNetwork.Custom]: [],
cayenne: [],
manzano: [],
'datil-dev': [],
'datil-test': [],
datil: [],
habanero: [],
custom: [],
// FIXME: Remove localhost and internalDev; replaced with 'custom' type networks
localhost: [
'http://localhost:7470',
Expand Down Expand Up @@ -1018,3 +1019,88 @@ export const RELAY_URL_DATIL_TEST = 'https://datil-test-relayer.getlit.dev';
// ========== Lit Actions ==========
export const LIT_ACTION_IPFS_HASH =
'QmUjX8MW6StQ7NKNdaS6g4RMkvN5hcgtKmEi8Mca6oX4t3';

// ========== Chains ==========
export const VMTYPE = {
EVM: 'EVM',
SVM: 'SVM',
CVM: 'CVM',
} as const;
export type VMTYPE_TYPE = keyof typeof VMTYPE;
export type VMTYPE_VALUES = (typeof VMTYPE)[keyof typeof VMTYPE];

export const LIT_CURVE = {
BLS: 'BLS',
EcdsaK256: 'K256',
EcdsaCaitSith: 'ECDSA_CAIT_SITH', // Legacy alias of K256
EcdsaCAITSITHP256: 'EcdsaCaitSithP256',
} as const;
export type LIT_CURVE_TYPE = keyof typeof LIT_CURVE;
export type LIT_CURVE_VALUES = (typeof LIT_CURVE)[keyof typeof LIT_CURVE];

// ========== Either Types ==========
export const EITHER_TYPE = {
ERROR: 'ERROR',
SUCCESS: 'SUCCESS',
} as const;
export type EITHER_TYPE_TYPE = keyof typeof EITHER_TYPE;
export type EITHER_TYPE_VALUES = (typeof EITHER_TYPE)[keyof typeof EITHER_TYPE];

// ========== Supported PKP Auth Method Types ==========
export const AuthMethodType = {
EthWallet: 1,
LitAction: 2,
WebAuthn: 3,
Discord: 4,
Google: 5,
GoogleJwt: 6,
AppleJwt: 8,
StytchOtp: 9,
StytchEmailFactorOtp: 10,
StytchSmsFactorOtp: 11,
StytchWhatsAppFactorOtp: 12,
StytchTotpFactorOtp: 13,
} as const;
export type AuthMethodType_TYPE = keyof typeof AuthMethodType;
export type AuthMethodType_VALUES =
(typeof AuthMethodType)[keyof typeof AuthMethodType];

// ========== Supported PKP Auth Method Scopes ==========
export const AuthMethodScope = {
NoPermissions: 0,
SignAnything: 1,
PersonalSign: 2,
} as const;
export type AuthMethodScope_TYPE = keyof typeof AuthMethodScope;
export type AuthMethodScope_VALUES =
(typeof AuthMethodScope)[keyof typeof AuthMethodScope];

// ========== Supported Provider Types ==========
export const ProviderType = {
Discord: 'discord',
Google: 'google',
EthWallet: 'ethwallet',
WebAuthn: 'webauthn',
Apple: 'apple',
StytchOtp: 'stytchOtp',
StytchEmailFactorOtp: 'stytchEmailFactorOtp',
StytchSmsFactorOtp: 'stytchSmsFactorOtp',
StytchWhatsAppFactorOtp: 'stytchWhatsAppFactorOtp',
StytchTotpFactor: 'stytchTotpFactor',
} as const;
export type ProviderType_TYPE = keyof typeof ProviderType;
export type ProviderType_VALUES =
(typeof ProviderType)[keyof typeof ProviderType];

// ========== Supported Staking States ==========
export const StakingStates = {
Active: 0,
NextValidatorSetLocked: 1,
ReadyForNextEpoch: 2,
Unlocked: 3,
Paused: 4,
Restore: 5,
} as const;
export type StakingStates_TYPE = keyof typeof StakingStates;
export type StakingStates_VALUES =
(typeof StakingStates)[keyof typeof StakingStates];
2 changes: 1 addition & 1 deletion packages/constants/src/lib/constants/mappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const NETWORK_CONTEXT_BY_NETWORK: {
* @deprecated Will be removed in version 7.x.
*/
export const GENERAL_WORKER_URL_BY_NETWORK: {
[key in LIT_NETWORK_VALUES]: string;
[key in Exclude<LIT_NETWORK_VALUES, 'datil'>]: string;
} = {
cayenne: 'https://apis.getlit.dev/cayenne/contracts',
manzano: 'https://apis.getlit.dev/manzano/contracts',
Expand Down
80 changes: 0 additions & 80 deletions packages/constants/src/lib/enums.ts

This file was deleted.

4 changes: 2 additions & 2 deletions packages/constants/src/lib/interfaces/i-errors.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EITHER_TYPE } from '../enums';
import { EITHER_TYPE_VALUES } from '../constants/constants';

export interface ILitError {
message?: string;
Expand All @@ -17,6 +17,6 @@ export interface ILitErrorTypeParams {
* A standardized way to return either error or success
*/
export interface IEither<T> {
type: EITHER_TYPE.SUCCESS | EITHER_TYPE.ERROR;
type: EITHER_TYPE_VALUES;
result: T | ILitError;
}
2 changes: 1 addition & 1 deletion packages/constants/src/lib/utils/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EITHER_TYPE } from '../enums';
import { EITHER_TYPE } from '../constants/constants';
import { IEither, ILitError } from '../interfaces/i-errors';

/**
Expand Down
10 changes: 5 additions & 5 deletions packages/contracts-sdk/src/lib/contracts-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ import * as stakingBalancesContract from '../abis/StakingBalances.sol/StakingBal
// ----- autogen:imports:end -----

import {
AuthMethodScope,
AuthMethodType,
AuthMethodType_VALUES,
AuthMethodScope_VALUES,
METAMASK_CHAIN_INFO_BY_NETWORK,
NETWORK_CONTEXT_BY_NETWORK,
LIT_NETWORK_VALUES,
Expand Down Expand Up @@ -1189,9 +1189,9 @@ https://developer.litprotocol.com/v3/sdk/wallets/auth-methods/#auth-method-scope
webAuthnPubkey,
}: {
pkpTokenId: string;
authMethodType: AuthMethodType | number;
authMethodType: AuthMethodType_VALUES;
authMethodId: string | Uint8Array;
authMethodScopes: AuthMethodScope[];
authMethodScopes: AuthMethodScope_VALUES[];
webAuthnPubkey?: string;
}): Promise<ethers.ContractReceipt> => {
const _authMethodId =
Expand Down Expand Up @@ -1237,7 +1237,7 @@ https://developer.litprotocol.com/v3/sdk/wallets/auth-methods/#auth-method-scope
}: {
ipfsId: string;
pkpTokenId: string;
authMethodScopes: AuthMethodScope[];
authMethodScopes: AuthMethodScope_VALUES[];
}) => {
const ipfsIdBytes = this.utils.getBytesFromMultihash(ipfsId);
const scopes = authMethodScopes ?? [];
Expand Down
Loading