Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/lit 3549 js sdk add datiltest support #523

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
304dca5
feat: add `datil-test` support
Ansonhkg Jul 4, 2024
ea52a31
feat: add `datil-test` support
Ansonhkg Jul 5, 2024
c52d380
fix: use staging api instead of `datil-test`
Ansonhkg Jul 5, 2024
88cf00e
fix: add `datil-test` to `SERVICE_URL_BY_LIT_NETWORK`
Ansonhkg Jul 5, 2024
d7fd0e9
fix: relayer mint claim
Ansonhkg Jul 5, 2024
8c91b34
chore: update `DATIL_TEST_API` from staging to prod
Ansonhkg Jul 11, 2024
acb95ed
chore: prettier
Ansonhkg Jul 11, 2024
e1c9a13
feat: use map of network to RPC, general worker, relayer urls
Ansonhkg Jul 11, 2024
f669cf3
chore: prettier
Ansonhkg Jul 11, 2024
29a6ee9
fix: use map values
Ansonhkg Jul 11, 2024
d1d6f32
fix: use map values instead of keys
Ansonhkg Jul 11, 2024
f615185
fix: doc on LIT_RPC
Ansonhkg Jul 11, 2024
30691ec
fix: let to const
Ansonhkg Jul 11, 2024
9cf33e8
fix: rename `CHAIN_INFO` to `METAMASK_CHAIN_INFO`
Ansonhkg Jul 11, 2024
ea614f6
fix: https://github.com/LIT-Protocol/js-sdk/pull/527#discussion_r1673…
Ansonhkg Jul 11, 2024
bc91353
fix: jsDoc and chain info
Ansonhkg Jul 11, 2024
12569dd
fix: check the correct variable, not the concatenated string
Ansonhkg Jul 11, 2024
e28ef03
Merge pull request #527 from LIT-Protocol/feature/lit-3593-js-sdk-add…
Ansonhkg Jul 11, 2024
2a249dc
fix: https://github.com/LIT-Protocol/js-sdk/pull/523#pullrequestrevie…
Ansonhkg Jul 11, 2024
6dab1b8
Update packages/constants/src/lib/constants/constants.ts
Ansonhkg Jul 11, 2024
69d20e8
Update packages/constants/src/lib/constants/constants.ts
Ansonhkg Jul 11, 2024
31d5d67
fix: remove `as const`
Ansonhkg Jul 11, 2024
89b24c8
feat: add isSupportedLitNetwork checker
Ansonhkg Jul 11, 2024
ac9a6bf
Merge branch 'feature/lit-3549-js-sdk-add-datiltest-support' of https…
Ansonhkg Jul 11, 2024
2c73ec8
feat: add `DatilTest` to SEV
Ansonhkg Jul 11, 2024
80b97f8
chore: prettier
Ansonhkg Jul 11, 2024
a8857e9
https://github.com/LIT-Protocol/js-sdk/pull/523#discussion_r1674672268
Ansonhkg Jul 11, 2024
a56826c
Update local-tests/tests/wrapped-keys/util.ts
Ansonhkg Jul 11, 2024
bb03270
fix: add `DatilTest` to `NETWORKS_WITH_EPOCH_CHANGES`
Ansonhkg Jul 11, 2024
41daabb
chore: prettier
Ansonhkg Jul 11, 2024
3d2830e
fix: PKPEthers use rpc mapper
Ansonhkg Jul 12, 2024
236822d
Merge branch 'master' into feature/lit-3549-js-sdk-add-datiltest-support
Ansonhkg Jul 12, 2024
73293f9
fix: pkp-ethers conflicts against master
Ansonhkg Jul 12, 2024
28972a5
fix: merge master
Ansonhkg Jul 12, 2024
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: 2 additions & 0 deletions local-tests/setup/tinny-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export enum LIT_TESTNET {
MANZANO = 'manzano',
CAYENNE = 'cayenne',
DATIL_DEV = 'datil-dev',
DATIL_TEST = 'datil-test',
}

export enum LIT_RPC {
Expand All @@ -22,6 +23,7 @@ export const RPC_MAP = {
[LIT_TESTNET.MANZANO]: LIT_RPC.CHRONICLE,
[LIT_TESTNET.CAYENNE]: LIT_RPC.CHRONICLE,
[LIT_TESTNET.DATIL_DEV]: LIT_RPC.VESUVIUS,
[LIT_TESTNET.DATIL_TEST]: LIT_RPC.VESUVIUS,
};

export interface ProcessEnvs {
Expand Down
4 changes: 4 additions & 0 deletions local-tests/tests/wrapped-keys/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export function getChainForNetwork(network: LIT_NETWORKS_KEYS): {
};
case 'datil-dev':
return { chain: 'vesuvius', chainId: LIT_CHAINS['datilDevnet'].chainId };
case 'datil-test':
return { chain: 'vesuvius', chainId: LIT_CHAINS['datilTestnet'].chainId };
Ansonhkg marked this conversation as resolved.
Show resolved Hide resolved
default:
throw new Error(`Cannot identify chain params for ${network}`);
}
Expand All @@ -36,6 +38,8 @@ export function getGasParamsForNetwork(network: LIT_NETWORKS_KEYS): {
};
case 'datil-dev':
return { gasLimit: 5000000 };
case 'datil-test':
return { gasLimit: 5000000 };
default:
throw new Error(`Cannot identify chain params for ${network}`);
}
Expand Down
224 changes: 211 additions & 13 deletions packages/constants/src/lib/constants/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -466,22 +466,50 @@ export const LIT_CHAINS: LITChain<LITEVMChain> = {
type: null,
vmType: 'EVM',
},

/**
* Chainlist entry for the Chronicle Testnet.
* https://chainlist.org/chain/175177
*/
chronicleTestnet: {
contractAddress: null,
chainId: 175177,
name: 'Chronicle - Lit Protocol Testnet',
symbol: 'testLPX',
symbol: 'tstLIT',
decimals: 18,
rpcUrls: ['https://lit-protocol.calderachain.xyz/replica-http'],
rpcUrls: [
'https://lit-protocol.calderachain.xyz/replica-http',
'https://chain-rpc.litprotocol.com/http',
],
blockExplorerUrls: ['https://chain.litprotocol.com/'],
type: null,
vmType: 'EVM',
},

/**
* @deprecated Will be removed in version 7.x. - Use `chronicleVesuviusTestnet` instead.
*/
datilDevnet: {
contractAddress: null,
chainId: 2311,
name: 'Vesuvius - Lit Protocol Devnet',
symbol: 'testLIT',
name: 'Chronicle Vesuvius - Lit Protocol Testnet',
symbol: 'tstLPX',
decimals: 18,
rpcUrls: ['https://vesuvius-rpc.litprotocol.com/'],
blockExplorerUrls: ['https://vesuvius-explorer.litprotocol.com/'],
type: null,
vmType: 'EVM',
},

/**
* Chainlist entry for the Chronicle Vesuvius Testnet.
* https://chainlist.org/chain/2311
*/
chronicleVesuviusTestnet: {
contractAddress: null,
chainId: 2311,
name: 'Chronicle Vesuvius - Lit Protocol Testnet',
symbol: 'tstLPX',
decimals: 18,
rpcUrls: ['https://vesuvius-rpc.litprotocol.com/'],
blockExplorerUrls: ['https://vesuvius-explorer.litprotocol.com/'],
Expand All @@ -492,9 +520,12 @@ export const LIT_CHAINS: LITChain<LITEVMChain> = {
contractAddress: null,
chainId: 175177,
name: 'Chronicle - Lit Protocol Testnet',
symbol: 'testLPX',
symbol: 'tstLIT',
decimals: 18,
rpcUrls: ['https://lit-protocol.calderachain.xyz/replica-http'],
rpcUrls: [
'https://lit-protocol.calderachain.xyz/replica-http',
'https://chain-rpc.litprotocol.com/http',
],
blockExplorerUrls: ['https://chain.litprotocol.com/'],
type: null,
vmType: 'EVM',
Expand Down Expand Up @@ -614,27 +645,173 @@ export const LIT_CHAINS: LITChain<LITEVMChain> = {
export const LIT_CHAIN_RPC_URL = LIT_CHAINS['chronicleTestnet'].rpcUrls[0];

/**
* Enum representing the available LIT RPC endpoints.
* Object containing information to submit to Metamask
*/
export enum LIT_RPC {
export const metamaskChainInfo = {
/**
* Information about the "chronicle" chain.
*/
chronicle: {
chainId: LIT_CHAINS['chronicleTestnet'].chainId,
chainName: LIT_CHAINS['chronicleTestnet'].name,
nativeCurrency: {
name: LIT_CHAINS['chronicleTestnet'].symbol,
symbol: LIT_CHAINS['chronicleTestnet'].symbol,
decimals: LIT_CHAINS['chronicleTestnet'].decimals,
},
rpcUrls: LIT_CHAINS['chronicleTestnet'].rpcUrls,
blockExplorerUrls: LIT_CHAINS['chronicleTestnet'].blockExplorerUrls,
iconUrls: ['future'],
},
/**
* Information about the "chronicleVesuvius" chain.
*/
chronicleVesuvius: {
chainId: LIT_CHAINS['chronicleVesuviusTestnet'].chainId,
chainName: LIT_CHAINS['chronicleVesuviusTestnet'].name,
nativeCurrency: {
name: LIT_CHAINS['chronicleVesuviusTestnet'].symbol,
symbol: LIT_CHAINS['chronicleVesuviusTestnet'].symbol,
decimals: LIT_CHAINS['chronicleVesuviusTestnet'].decimals,
},
rpcUrls: LIT_CHAINS['chronicleVesuviusTestnet'].rpcUrls,
blockExplorerUrls: LIT_CHAINS['chronicleVesuviusTestnet'].blockExplorerUrls,
iconUrls: ['future'],
},
};

/**
* Constants representing the available LIT RPC endpoints.
*/
export const LIT_RPC = {
/**
* Local Anvil RPC endpoint.
*/
LOCAL_ANVIL = 'http://127.0.0.1:8545',
LOCAL_ANVIL: 'http://127.0.0.1:8545',

/**
* Chronicle RPC endpoint - Used for Cayenne, Manzano, Habanero
*/
CHRONICLE = 'https://chain-rpc.litprotocol.com/http',
CHRONICLE: 'https://chain-rpc.litprotocol.com/http',

/**
* Vesuvius RPC endpoint - used for >= Datil-dev
* Chronicle Vesuvius RPC endpoint - used for >= Datil-dev, Datil-test
* @deprecated Will be removed in version 7.x. - Use CHRONICLE_VESUVIUS instead
*/
VESUVIUS = 'https://vesuvius-rpc.litprotocol.com',
}
VESUVIUS: 'https://vesuvius-rpc.litprotocol.com',

/**
* Chronicle Vesuvius RPC endpoint - used for >= Datil-dev, Datil-test
*/
CHRONICLE_VESUVIUS: 'https://vesuvius-rpc.litprotocol.com',
} as const;

export const LIT_EVM_CHAINS = LIT_CHAINS;

/**
* Represents the Lit Network constants.
*/
export const LIT_NETWORK = {
Cayenne: 'cayenne',
Manzano: 'manzano',
Habanero: 'habanero',
DatilDev: 'datil-dev',
DatilTest: 'datil-test',
Custom: 'custom',
Localhost: 'localhost',
};

/**
* The type representing the keys of the LIT_NETWORK object.
*/
export type LIT_NETWORK_TYPES = keyof typeof LIT_NETWORK;

/**
* The type representing the values of the LIT_NETWORK object.
*/
export type LIT_NETWORK_VALUES = (typeof LIT_NETWORK)[keyof typeof LIT_NETWORK];

/**
* RPC URL by Network
*
* A mapping of network names to their corresponding RPC URLs.
*/
export const RPC_URL_BY_NETWORK: { [key in LIT_NETWORK_VALUES]: string } = {
cayenne: LIT_RPC.CHRONICLE,
manzano: LIT_RPC.CHRONICLE,
habanero: LIT_RPC.CHRONICLE,
'datil-dev': LIT_RPC.CHRONICLE_VESUVIUS,
'datil-test': LIT_RPC.CHRONICLE_VESUVIUS,
custom: LIT_RPC.LOCAL_ANVIL,
localhost: LIT_RPC.LOCAL_ANVIL,
};

/**
* Mapping of network names to their corresponding relayer URLs.
*/
export const RELAYER_URL_BY_NETWORK: {
[key in LIT_NETWORK_VALUES]: string;
} = {
cayenne: 'https://relayer-server-staging-cayenne.getlit.dev',
manzano: 'https://manzano-relayer.getlit.dev',
habanero: 'https://habanero-relayer.getlit.dev',
'datil-dev': 'https://datil-dev-relayer.getlit.dev',
'datil-test': 'https://datil-test-relayer.getlit.dev',
custom: 'http://localhost:3000',
localhost: 'http://localhost:3000',
};

/**
* URL mappings for general worker URLs by network.
*/
export const GENERAL_WORKER_URL_BY_NETWORK: {
[key in LIT_NETWORK_VALUES]: string;
} = {
cayenne: 'https://apis.getlit.dev/cayenne/contracts',
manzano: 'https://apis.getlit.dev/manzano/contracts',
habanero: 'https://apis.getlit.dev/habanero/contracts',
'datil-dev': 'https://apis.getlit.dev/datil-dev/contracts',
'datil-test': 'https://apis.getlit.dev/datil-test/contracts',

// just use cayenne abis for custom and localhost
custom: 'https://apis.getlit.dev/cayenne/contracts',
localhost: 'https://apis.getlit.dev/cayenne/contracts',
};

/**
* URL constants for the staging worker by network.
*/
export const GENERAL_STAGING_WORKER_URL_BY_NETWORK: {
[key in LIT_NETWORK_VALUES]: string;
} = {
cayenne: 'https://staging.apis.getlit.dev/cayenne/contracts',
manzano: 'https://staging.apis.getlit.dev/manzano/contracts',
habanero: 'https://staging.apis.getlit.dev/habanero/contracts',
'datil-dev': 'https://staging.apis.getlit.dev/datil-dev/contracts',
'datil-test': 'https://staging.apis.getlit.dev/datil-test/contracts',

// just use cayenne abis for custom and localhost
custom: 'https://apis.getlit.dev/cayenne/contracts',
localhost: 'https://apis.getlit.dev/cayenne/contracts',
};

/**
* Mapping of network values to corresponding Metamask chain info.
*/
export const METAMASK_CHAIN_INFO_BY_NETWORK: Record<
LIT_NETWORK_VALUES,
| typeof metamaskChainInfo.chronicle
| typeof metamaskChainInfo.chronicleVesuvius
> = {
cayenne: metamaskChainInfo.chronicle,
manzano: metamaskChainInfo.chronicle,
habanero: metamaskChainInfo.chronicle,
'datil-dev': metamaskChainInfo.chronicleVesuvius,
'datil-test': metamaskChainInfo.chronicleVesuvius,
custom: metamaskChainInfo.chronicleVesuvius,
localhost: metamaskChainInfo.chronicleVesuvius,
};

/**
* Solana Chains supported by the LIT protocol. Use the chain name as a key in this object.
* @constant
Expand Down Expand Up @@ -790,6 +967,7 @@ export const LIT_NETWORKS: { [key in LitNetwork]: string[] } & {
[LitNetwork.Cayenne]: [],
[LitNetwork.Manzano]: [],
[LitNetwork.DatilDev]: [],
[LitNetwork.DatilTest]: [],
[LitNetwork.Habanero]: [],
[LitNetwork.Custom]: [],
// FIXME: Remove localhost and internalDev; replaced with 'custom' type networks
Expand Down Expand Up @@ -827,12 +1005,32 @@ export const TELEM_API_URL = 'https://lit-general-worker.getlit.dev';
// ========== RLI Delegation ==========
export const SIWE_DELEGATION_URI = 'lit:capability:delegation';

/**
* @deprecated Will be removed in version 7.x. - Use RELAYER_URL_BY_NETWORK.Cayenne instead
*/
export const RELAY_URL_CAYENNE =
'https://relayer-server-staging-cayenne.getlit.dev';

/**
* @deprecated Will be removed in version 7.x. - Use RELAYER_URL_BY_NETWORK.Habanero instead
*/
export const RELAY_URL_HABANERO = 'https://habanero-relayer.getlit.dev';

/**
* @deprecated Will be removed in version 7.x. - Use RELAYER_URL_BY_NETWORK.Manzano instead
*/
export const RELAY_URL_MANZANO = 'https://manzano-relayer.getlit.dev';

/**
* @deprecated Will be removed in version 7.x. - Use RELAYER_URL_BY_NETWORK.DatilDev instead
*/
export const RELAY_URL_DATIL_DEV = 'https://datil-dev-relayer.getlit.dev';

/**
* @deprecated Will be removed in version 7.x. - Use RELAYER_URL_BY_NETWORK.DatilTest instead
*/
export const RELAY_URL_DATIL_TEST = 'https://datil-test-relayer.getlit.dev';

// ========== Lit Actions ==========
export const LIT_ACTION_IPFS_HASH =
'QmUjX8MW6StQ7NKNdaS6g4RMkvN5hcgtKmEi8Mca6oX4t3';
1 change: 1 addition & 0 deletions packages/constants/src/lib/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export enum LitNetwork {
Habanero = 'habanero',
Custom = 'custom',
DatilDev = 'datil-dev',
DatilTest = 'datil-test',
}

/**
Expand Down
Loading
Loading