Skip to content

Commit 6d5d004

Browse files
committed
refactor(network): add NagaTest network support and update related constants
1 parent 332cd51 commit 6d5d004

File tree

5 files changed

+11
-108
lines changed

5 files changed

+11
-108
lines changed

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

Lines changed: 3 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,6 +1070,7 @@ export const LIT_EVM_CHAINS = LIT_CHAINS;
10701070
*/
10711071
export const LIT_NETWORK = {
10721072
NagaDev: 'naga-dev',
1073+
NagaTest: 'naga-test',
10731074
Custom: 'custom',
10741075
} as const;
10751076

@@ -1091,54 +1092,13 @@ export type LIT_NETWORK_VALUES = ConstantValues<typeof LIT_NETWORK>;
10911092
*/
10921093
export const RPC_URL_BY_NETWORK: Record<LIT_NETWORK_VALUES, LIT_RPC_VALUES> = {
10931094
[LIT_NETWORK.NagaDev]: LIT_RPC.CHRONICLE_YELLOWSTONE,
1095+
[LIT_NETWORK.NagaTest]: LIT_RPC.CHRONICLE_YELLOWSTONE,
10941096
[LIT_NETWORK.Custom]: LIT_RPC.LOCAL_ANVIL,
10951097
} as const;
10961098

1097-
/**
1098-
* Mapping of network names to their corresponding relayer URLs.
1099-
* @deprecated - use naga doesn't use these urls anymore.
1100-
*/
1101-
export const RELAYER_URL_BY_NETWORK: Record<LIT_NETWORK_VALUES, string> = {
1102-
[LIT_NETWORK.NagaDev]: 'https://naga-dev-relayer.getlit.dev',
1103-
[LIT_NETWORK.Custom]: 'http://localhost:3000',
1104-
} as const;
1105-
1106-
/**
1107-
* Mapping of network values to corresponding Metamask chain info.
1108-
*/
1109-
export const METAMASK_CHAIN_INFO_BY_NETWORK: Record<
1110-
LIT_NETWORK_VALUES,
1111-
typeof METAMASK_CHAIN_INFO.yellowstone
1112-
> = {
1113-
[LIT_NETWORK.NagaDev]: METAMASK_CHAIN_INFO.yellowstone,
1114-
[LIT_NETWORK.Custom]: METAMASK_CHAIN_INFO.yellowstone,
1115-
} as const;
1116-
11171099
export const HTTP = 'http://';
11181100
export const HTTPS = 'https://';
11191101

1120-
/**
1121-
* Mapping of network values to corresponding http protocol.
1122-
*/
1123-
export const HTTP_BY_NETWORK: Record<
1124-
LIT_NETWORK_VALUES,
1125-
typeof HTTP | typeof HTTPS
1126-
> = {
1127-
[LIT_NETWORK.NagaDev]: HTTPS,
1128-
[LIT_NETWORK.Custom]: HTTP, // default, can be changed by config
1129-
} as const;
1130-
1131-
/**
1132-
* Mapping of network values to their corresponding centralisation status.
1133-
*/
1134-
export const CENTRALISATION_BY_NETWORK: Record<
1135-
LIT_NETWORK_VALUES,
1136-
'centralised' | 'decentralised' | 'unknown'
1137-
> = {
1138-
[LIT_NETWORK.NagaDev]: 'centralised',
1139-
[LIT_NETWORK.Custom]: 'unknown',
1140-
} as const;
1141-
11421102
/**
11431103
* Solana Chains supported by the LIT protocol. Use the chain name as a key in this object.
11441104
* @constant
@@ -1270,6 +1230,7 @@ export const LOCAL_STORAGE_KEYS = {
12701230
*/
12711231
export const LIT_NETWORKS: Record<LIT_NETWORK_VALUES, string[]> = {
12721232
[LIT_NETWORK.NagaDev]: [],
1233+
[LIT_NETWORK.NagaTest]: [],
12731234
[LIT_NETWORK.Custom]: [],
12741235
} as const;
12751236

packages/crypto/src/lib/misc.ts

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
LIT_NETWORK,
88
LIT_NETWORK_VALUES,
99
NetworkError,
10-
RELAYER_URL_BY_NETWORK,
1110
UnknownError,
1211
WrongNetworkException,
1312
} from '@lit-protocol/constants';
@@ -521,64 +520,6 @@ export function isSupportedLitNetwork(
521520
}
522521
}
523522

524-
export const defaultMintClaimCallback: MintCallback<
525-
RelayClaimProcessor
526-
> = async (
527-
params: ClaimResult<RelayClaimProcessor>,
528-
network: LIT_NETWORK_VALUES = LIT_NETWORK.NagaDev
529-
): Promise<string> => {
530-
isSupportedLitNetwork(network);
531-
532-
const AUTH_CLAIM_PATH = '/auth/claim';
533-
534-
const relayUrl: string = params.relayUrl || RELAYER_URL_BY_NETWORK[network];
535-
536-
if (!relayUrl) {
537-
throw new InvalidArgumentException(
538-
{
539-
info: {
540-
network,
541-
relayUrl,
542-
},
543-
},
544-
'No relayUrl provided and no default relayUrl found for network'
545-
);
546-
}
547-
548-
const relayUrlWithPath = relayUrl + AUTH_CLAIM_PATH;
549-
550-
const response = await fetch(relayUrlWithPath, {
551-
method: 'POST',
552-
body: JSON.stringify(params),
553-
headers: {
554-
'api-key': params.relayApiKey
555-
? params.relayApiKey
556-
: '67e55044-10b1-426f-9247-bb680e5fe0c8_relayer',
557-
'Content-Type': 'application/json',
558-
},
559-
});
560-
561-
if (response.status < 200 || response.status >= 400) {
562-
const errResp = (await response.json()) ?? '';
563-
const errStmt = `An error occurred requesting "/auth/claim" endpoint ${JSON.stringify(
564-
errResp
565-
)}`;
566-
console.warn(errStmt);
567-
throw new NetworkError(
568-
{
569-
info: {
570-
response,
571-
errResp,
572-
},
573-
},
574-
`An error occurred requesting "/auth/claim" endpoint`
575-
);
576-
}
577-
578-
const body = await response.json();
579-
return body.requestId;
580-
};
581-
582523
export const isHexableString = (str: string): boolean => {
583524
return /^(0x|0X)?[0-9a-fA-F]+$/.test(str);
584525
};

packages/wrapped-keys/src/lib/service-client/constants.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ const SERVICE_URL_BY_NETWORKTYPE: Record<NETWORK_TYPES, string> = {
99
};
1010

1111
export const SERVICE_URL_BY_LIT_NETWORK: Record<SupportedNetworks, string> = {
12-
[LIT_NETWORK.DatilDev]: SERVICE_URL_BY_NETWORKTYPE.TestNetworks,
13-
[LIT_NETWORK.DatilTest]: SERVICE_URL_BY_NETWORKTYPE.TestNetworks,
14-
[LIT_NETWORK.Datil]: SERVICE_URL_BY_NETWORKTYPE.Production,
12+
[LIT_NETWORK.NagaDev]: SERVICE_URL_BY_NETWORKTYPE.TestNetworks,
13+
[LIT_NETWORK.NagaTest]: SERVICE_URL_BY_NETWORKTYPE.TestNetworks,
1514
};
1615

1716
export const LIT_SESSIONSIG_AUTHORIZATION_SCHEMA_PREFIX = 'LitSessionSig:';

packages/wrapped-keys/src/lib/service-client/types.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ export type FetchKeyParams = BaseApiParams & {
1515

1616
export type ListKeysParams = BaseApiParams & { pkpAddress: string };
1717

18-
export type SupportedNetworks = Extract<LIT_NETWORK_VALUES, 'naga-dev'>;
18+
export type SupportedNetworks = Extract<
19+
LIT_NETWORK_VALUES,
20+
'naga-dev' | 'naga-test'
21+
>;
1922

2023
export interface StoreKeyParams extends BaseApiParams {
2124
storedKeyMetadata: Pick<

packages/wrapped-keys/src/lib/service-client/utils.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ function composeAuthHeader(sessionSig: AuthSig) {
1717
}
1818

1919
const supportedNetworks: SupportedNetworks[] = [
20-
'datil-dev',
21-
'datil-test',
22-
'datil',
20+
'naga-dev',
21+
'naga-test'
2322
];
2423

2524
function isSupportedLitNetwork(

0 commit comments

Comments
 (0)