Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e28ef03

Browse files
authored
Merge pull request #527 from LIT-Protocol/feature/lit-3593-js-sdk-add-a-map-of-network-names-to-rpc-url
Feature/lit 3593 js sdk add a map of network names to rpc url
2 parents acb95ed + 12569dd commit e28ef03

File tree

4 files changed

+258
-173
lines changed

4 files changed

+258
-173
lines changed

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

Lines changed: 197 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -466,32 +466,49 @@ export const LIT_CHAINS: LITChain<LITEVMChain> = {
466466
type: null,
467467
vmType: 'EVM',
468468
},
469+
470+
/**
471+
* Chainlist entry for the Chronicle Testnet.
472+
* https://chainlist.org/chain/175177
473+
*/
469474
chronicleTestnet: {
470475
contractAddress: null,
471476
chainId: 175177,
472477
name: 'Chronicle - Lit Protocol Testnet',
473-
symbol: 'testLPX',
478+
symbol: 'tstLPX',
474479
decimals: 18,
475-
rpcUrls: ['https://lit-protocol.calderachain.xyz/replica-http'],
480+
rpcUrls: [
481+
'https://lit-protocol.calderachain.xyz/replica-http',
482+
'https://chain-rpc.litprotocol.com/http',
483+
],
476484
blockExplorerUrls: ['https://chain.litprotocol.com/'],
477485
type: null,
478486
vmType: 'EVM',
479487
},
488+
489+
/**
490+
* @deprecated Will be removed in version 7.x. - Use `chronicleVesuviusTestnet` instead.
491+
*/
480492
datilDevnet: {
481493
contractAddress: null,
482494
chainId: 2311,
483-
name: 'Vesuvius - Lit Protocol Devnet',
495+
name: 'Chronicle Vesuvius - Lit Protocol Testnet',
484496
symbol: 'tstLit',
485497
decimals: 18,
486498
rpcUrls: ['https://vesuvius-rpc.litprotocol.com/'],
487499
blockExplorerUrls: ['https://vesuvius-explorer.litprotocol.com/'],
488500
type: null,
489501
vmType: 'EVM',
490502
},
491-
datilTestnet: {
503+
504+
/**
505+
* Chainlist entry for the Chronicle Vesuvius Testnet.
506+
* https://chainlist.org/chain/2311
507+
*/
508+
chronicleVesuviusTestnet: {
492509
contractAddress: null,
493510
chainId: 2311,
494-
name: 'Vesuvius - Lit Protocol Testnet',
511+
name: 'Chronicle Vesuvius - Lit Protocol Testnet',
495512
symbol: 'tstLit',
496513
decimals: 18,
497514
rpcUrls: ['https://vesuvius-rpc.litprotocol.com/'],
@@ -503,9 +520,12 @@ export const LIT_CHAINS: LITChain<LITEVMChain> = {
503520
contractAddress: null,
504521
chainId: 175177,
505522
name: 'Chronicle - Lit Protocol Testnet',
506-
symbol: 'testLPX',
523+
symbol: 'tstLit',
507524
decimals: 18,
508-
rpcUrls: ['https://lit-protocol.calderachain.xyz/replica-http'],
525+
rpcUrls: [
526+
'https://lit-protocol.calderachain.xyz/replica-http',
527+
'https://chain-rpc.litprotocol.com/http',
528+
],
509529
blockExplorerUrls: ['https://chain.litprotocol.com/'],
510530
type: null,
511531
vmType: 'EVM',
@@ -625,27 +645,171 @@ export const LIT_CHAINS: LITChain<LITEVMChain> = {
625645
export const LIT_CHAIN_RPC_URL = LIT_CHAINS['chronicleTestnet'].rpcUrls[0];
626646

627647
/**
628-
* Enum representing the available LIT RPC endpoints.
648+
* Object containing information to submit to Metamask
649+
*/
650+
export const metamaskChainInfo = {
651+
/**
652+
* Information about the "chronicle" chain.
653+
*/
654+
chronicle: {
655+
chainId: LIT_CHAINS['chronicleTestnet'].chainId,
656+
chainName: LIT_CHAINS['chronicleTestnet'].name,
657+
nativeCurrency: {
658+
name: LIT_CHAINS['chronicleTestnet'].symbol,
659+
symbol: LIT_CHAINS['chronicleTestnet'].symbol,
660+
decimals: LIT_CHAINS['chronicleTestnet'].decimals,
661+
},
662+
rpcUrls: LIT_CHAINS['chronicleTestnet'].rpcUrls,
663+
blockExplorerUrls: LIT_CHAINS['chronicleTestnet'].blockExplorerUrls,
664+
iconUrls: ['future'],
665+
},
666+
/**
667+
* Information about the "chronicleVesuvius" chain.
668+
*/
669+
chronicleVesuvius: {
670+
chainId: LIT_CHAINS['chronicleVesuviusTestnet'].chainId,
671+
chainName: LIT_CHAINS['chronicleVesuviusTestnet'].name,
672+
nativeCurrency: {
673+
name: LIT_CHAINS['chronicleVesuviusTestnet'].symbol,
674+
symbol: LIT_CHAINS['chronicleVesuviusTestnet'].symbol,
675+
decimals: LIT_CHAINS['chronicleVesuviusTestnet'].decimals,
676+
},
677+
rpcUrls: LIT_CHAINS['chronicleVesuviusTestnet'].rpcUrls,
678+
blockExplorerUrls: LIT_CHAINS['chronicleVesuviusTestnet'].blockExplorerUrls,
679+
iconUrls: ['future'],
680+
},
681+
};
682+
683+
/**
684+
* Constants representing the available LIT RPC endpoints.
629685
*/
630-
export enum LIT_RPC {
686+
export const LIT_RPC = {
631687
/**
632688
* Local Anvil RPC endpoint.
633689
*/
634-
LOCAL_ANVIL = 'http://127.0.0.1:8545',
690+
LOCAL_ANVIL: 'http://127.0.0.1:8545',
635691

636692
/**
637693
* Chronicle RPC endpoint - Used for Cayenne, Manzano, Habanero
638694
*/
639-
CHRONICLE = 'https://chain-rpc.litprotocol.com/http',
695+
CHRONICLE: 'https://chain-rpc.litprotocol.com/http',
640696

641697
/**
642-
* Vesuvius RPC endpoint - used for >= Datil-dev, Datil-test
698+
* Chronicle Vesuvius RPC endpoint - used for >= Datil-dev, Datil-test
699+
* @deprecated Will be removed in version 7.x. - Use CHRONICLE_VESUVIUS instead
643700
*/
644-
VESUVIUS = 'https://vesuvius-rpc.litprotocol.com',
645-
}
701+
VESUVIUS: 'https://vesuvius-rpc.litprotocol.com',
702+
703+
/**
704+
* Chronicle Vesuvius RPC endpoint - used for >= Datil-dev, Datil-test
705+
*/
706+
CHRONICLE_VESUVIUS: 'https://vesuvius-rpc.litprotocol.com',
707+
} as const;
646708

647709
export const LIT_EVM_CHAINS = LIT_CHAINS;
648710

711+
/**
712+
* Represents the Lit Network constants.
713+
*/
714+
export const LIT_NETWORK = {
715+
Cayenne: 'cayenne',
716+
Manzano: 'manzano',
717+
Habanero: 'habanero',
718+
DatilDev: 'datil-dev',
719+
DatilTest: 'datil-test',
720+
Custom: 'custom',
721+
Localhost: 'localhost',
722+
} as const;
723+
724+
/**
725+
* The type representing the keys of the LIT_NETWORK object.
726+
*/
727+
export type LIT_NETWORK_TYPES = keyof typeof LIT_NETWORK;
728+
729+
/**
730+
* The type representing the values of the LIT_NETWORK object.
731+
*/
732+
export type LIT_NETWORK_VALUES = (typeof LIT_NETWORK)[keyof typeof LIT_NETWORK];
733+
734+
/**
735+
* RPC URL by Network
736+
*
737+
* A mapping of network names to their corresponding RPC URLs.
738+
*/
739+
export const RPC_URL_BY_NETWORK: { [key in LIT_NETWORK_VALUES]: string } = {
740+
cayenne: LIT_RPC.CHRONICLE,
741+
manzano: LIT_RPC.CHRONICLE,
742+
habanero: LIT_RPC.CHRONICLE,
743+
'datil-dev': LIT_RPC.CHRONICLE_VESUVIUS,
744+
'datil-test': LIT_RPC.CHRONICLE_VESUVIUS,
745+
custom: LIT_RPC.LOCAL_ANVIL,
746+
localhost: LIT_RPC.LOCAL_ANVIL,
747+
};
748+
749+
/**
750+
* Mapping of network names to their corresponding relayer URLs.
751+
*/
752+
export const RELAYER_URL_BY_NETWORK: { [key in LIT_NETWORK_VALUES]: string } = {
753+
cayenne: 'https://relayer-server-staging-cayenne.getlit.dev',
754+
manzano: 'https://manzano-relayer.getlit.dev',
755+
habanero: 'https://habanero-relayer.getlit.dev',
756+
'datil-dev': 'https://datil-dev-relayer.getlit.dev',
757+
'datil-test': 'https://datil-test-relayer.getlit.dev',
758+
custom: 'http://localhost:3000',
759+
localhost: 'http://localhost:3000',
760+
};
761+
762+
/**
763+
* URL mappings for general worker URLs by network.
764+
*/
765+
export const GENERAL_WORKER_URL_BY_NETWORK: {
766+
[key in LIT_NETWORK_VALUES]: string;
767+
} = {
768+
cayenne: 'https://apis.getlit.dev/cayenne/contracts',
769+
manzano: 'https://apis.getlit.dev/manzano/contracts',
770+
habanero: 'https://apis.getlit.dev/habanero/contracts',
771+
'datil-dev': 'https://apis.getlit.dev/datil-dev/contracts',
772+
'datil-test': 'https://apis.getlit.dev/datil-test/contracts',
773+
774+
// just use cayenne abis for custom and localhost
775+
custom: 'https://apis.getlit.dev/cayenne/contracts',
776+
localhost: 'https://apis.getlit.dev/cayenne/contracts',
777+
};
778+
779+
/**
780+
* URL constants for the staging worker by network.
781+
*/
782+
export const GENERAL_STAGING_WORKER_URL_BY_NETWORK: {
783+
[key in LIT_NETWORK_VALUES]: string;
784+
} = {
785+
cayenne: 'https://staging.apis.getlit.dev/cayenne/contracts',
786+
manzano: 'https://staging.apis.getlit.dev/manzano/contracts',
787+
habanero: 'https://staging.apis.getlit.dev/habanero/contracts',
788+
'datil-dev': 'https://staging.apis.getlit.dev/datil-dev/contracts',
789+
'datil-test': 'https://staging.apis.getlit.dev/datil-test/contracts',
790+
791+
// just use cayenne abis for custom and localhost
792+
custom: 'https://apis.getlit.dev/cayenne/contracts',
793+
localhost: 'https://apis.getlit.dev/cayenne/contracts',
794+
};
795+
796+
/**
797+
* Mapping of network values to corresponding Metamask chain info.
798+
*/
799+
export const METAMASK_CHAIN_INFO_BY_NETWORK: Record<
800+
LIT_NETWORK_VALUES,
801+
| typeof metamaskChainInfo.chronicle
802+
| typeof metamaskChainInfo.chronicleVesuvius
803+
> = {
804+
cayenne: metamaskChainInfo.chronicle,
805+
manzano: metamaskChainInfo.chronicle,
806+
habanero: metamaskChainInfo.chronicle,
807+
'datil-dev': metamaskChainInfo.chronicleVesuvius,
808+
'datil-test': metamaskChainInfo.chronicleVesuvius,
809+
custom: metamaskChainInfo.chronicleVesuvius,
810+
localhost: metamaskChainInfo.chronicleVesuvius,
811+
};
812+
649813
/**
650814
* Solana Chains supported by the LIT protocol. Use the chain name as a key in this object.
651815
* @constant
@@ -839,11 +1003,30 @@ export const TELEM_API_URL = 'https://lit-general-worker.getlit.dev';
8391003
// ========== RLI Delegation ==========
8401004
export const SIWE_DELEGATION_URI = 'lit:capability:delegation';
8411005

1006+
/**
1007+
* @deprecated Will be removed in version 7.x. - Use RELAYER_URL_BY_NETWORK.Cayenne instead
1008+
*/
8421009
export const RELAY_URL_CAYENNE =
8431010
'https://relayer-server-staging-cayenne.getlit.dev';
1011+
1012+
/**
1013+
* @deprecated Will be removed in version 7.x. - Use RELAYER_URL_BY_NETWORK.Habanero instead
1014+
*/
8441015
export const RELAY_URL_HABANERO = 'https://habanero-relayer.getlit.dev';
1016+
1017+
/**
1018+
* @deprecated Will be removed in version 7.x. - Use RELAYER_URL_BY_NETWORK.Manzano instead
1019+
*/
8451020
export const RELAY_URL_MANZANO = 'https://manzano-relayer.getlit.dev';
1021+
1022+
/**
1023+
* @deprecated Will be removed in version 7.x. - Use RELAYER_URL_BY_NETWORK.DatilDev instead
1024+
*/
8461025
export const RELAY_URL_DATIL_DEV = 'https://datil-dev-relayer.getlit.dev';
1026+
1027+
/**
1028+
* @deprecated Will be removed in version 7.x. - Use RELAYER_URL_BY_NETWORK.DatilTest instead
1029+
*/
8471030
export const RELAY_URL_DATIL_TEST = 'https://datil-test-relayer.getlit.dev';
8481031

8491032
// ========== Lit Actions ==========

0 commit comments

Comments
 (0)