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 5 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
17 changes: 15 additions & 2 deletions packages/constants/src/lib/constants/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,18 @@ export const LIT_CHAINS: LITChain<LITEVMChain> = {
contractAddress: null,
chainId: 2311,
name: 'Vesuvius - Lit Protocol Devnet',
symbol: 'testLIT',
symbol: 'tstLit',
decimals: 18,
rpcUrls: ['https://vesuvius-rpc.litprotocol.com/'],
blockExplorerUrls: ['https://vesuvius-explorer.litprotocol.com/'],
type: null,
vmType: 'EVM',
},
datilTestnet: {
contractAddress: null,
chainId: 2311,
name: 'Vesuvius - Lit Protocol Testnet',
symbol: 'tstLit',
decimals: 18,
rpcUrls: ['https://vesuvius-rpc.litprotocol.com/'],
blockExplorerUrls: ['https://vesuvius-explorer.litprotocol.com/'],
Expand Down Expand Up @@ -628,7 +639,7 @@ export enum LIT_RPC {
CHRONICLE = 'https://chain-rpc.litprotocol.com/http',

/**
* Vesuvius RPC endpoint - used for >= Datil-dev
* Vesuvius RPC endpoint - used for >= Datil-dev, Datil-test
*/
VESUVIUS = 'https://vesuvius-rpc.litprotocol.com',
}
Expand Down Expand Up @@ -790,6 +801,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 @@ -832,6 +844,7 @@ export const RELAY_URL_CAYENNE =
export const RELAY_URL_HABANERO = 'https://habanero-relayer.getlit.dev';
export const RELAY_URL_MANZANO = 'https://manzano-relayer.getlit.dev';
export const RELAY_URL_DATIL_DEV = 'https://datil-dev-relayer.getlit.dev';
export const RELAY_URL_DATIL_TEST = 'https://datil-test-relayer.getlit.dev';

// ========== Lit Actions ==========
export const LIT_ACTION_IPFS_HASH =
Expand Down
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
20 changes: 15 additions & 5 deletions packages/contracts-sdk/src/lib/contracts-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,9 @@ export class LitContracts {
// if rpc is not specified, use the default rpc
if (!this.rpc) {
this.rpc =
args?.network === 'datil-dev' ? LIT_RPC.VESUVIUS : LIT_RPC.CHRONICLE;
args?.network === 'datil-dev' || args?.network === 'datil-test'
? LIT_RPC.VESUVIUS
: LIT_RPC.CHRONICLE;
}

if (!this.rpcs) {
Expand Down Expand Up @@ -304,7 +306,9 @@ export class LitContracts {
};

const chainInfo =
this.network === 'datil-dev' ? vesuviusChainInfo : chronicleChainInfo;
this.network === 'datil-dev' || this.network === 'datil-test'
? vesuviusChainInfo
: chronicleChainInfo;

try {
await web3Provider.send('wallet_switchEthereumChain', [
Expand Down Expand Up @@ -612,14 +616,16 @@ export class LitContracts {
) {
let provider: ethers.providers.JsonRpcProvider;
rpcUrl =
rpcUrl ?? network === 'datil-dev' ? LIT_RPC.VESUVIUS : LIT_RPC.CHRONICLE;
rpcUrl ?? (network === 'datil-dev' || network === 'datil-test')
? LIT_RPC.VESUVIUS
: LIT_RPC.CHRONICLE;
if (context && 'provider' in context!) {
provider = context.provider;
} else {
provider = new ethers.providers.JsonRpcProvider(rpcUrl);
}

if (network === 'datil-dev') {
if (network === 'datil-dev' || network === 'datil-test') {
// @ts-ignore
context!.Staking!.abi = minStakingAbi;
}
Expand Down Expand Up @@ -986,6 +992,8 @@ export class LitContracts {
'https://lit-general-worker.getlit.dev/habanero-contract-addresses';
const DATIL_DEV_API =
'https://lit-general-worker.getlit.dev/datil-dev/contracts';
const DATIL_TEST_API =
'https://staging.apis.getlit.dev/datil-test/contracts';
Ansonhkg marked this conversation as resolved.
Show resolved Hide resolved

const fetchData = async (url: string) => {
try {
Expand All @@ -1008,6 +1016,9 @@ export class LitContracts {
case 'datil-dev':
data = await fetchData(DATIL_DEV_API);
break;
case 'datil-test':
data = await fetchData(DATIL_TEST_API);
break;
case 'custom':
case 'localhost':
// just use cayenne abis for custom and localhost
Expand Down Expand Up @@ -2425,7 +2436,6 @@ https://developer.litprotocol.com/v3/sdk/wallets/auth-methods/#auth-method-scope
permittedAuthMethodScopes,
addPkpEthAddressAsPermittedAddress,
sendPkpToItself,

{
value: mintCost,
gasLimit: gasLimit || GAS_LIMIT,
Expand Down
16 changes: 14 additions & 2 deletions packages/lit-auth-client/src/lib/lit-auth-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
ProviderType,
RELAY_URL_CAYENNE,
RELAY_URL_DATIL_DEV,
RELAY_URL_DATIL_TEST,
RELAY_URL_HABANERO,
RELAY_URL_MANZANO,
} from '@lit-protocol/constants';
Expand Down Expand Up @@ -97,7 +98,13 @@ export class LitAuthClient {
);
}

const supportedNetworks = ['cayenne', 'habanero', 'manzano', 'datil-dev'];
const supportedNetworks = [
Ansonhkg marked this conversation as resolved.
Show resolved Hide resolved
'cayenne',
'habanero',
'manzano',
'datil-dev',
'datil-test',
];

if (!supportedNetworks.includes(this.litNodeClient.config.litNetwork)) {
throw new Error(
Expand All @@ -122,6 +129,9 @@ export class LitAuthClient {
case 'datil-dev':
url = RELAY_URL_DATIL_DEV;
break;
case 'datil-test':
url = RELAY_URL_DATIL_TEST;
break;
}

this.relay = new LitRelay({
Expand All @@ -146,7 +156,9 @@ export class LitAuthClient {

// Set RPC URL
this.rpcUrl =
options?.rpcUrl || this.litNodeClient.config.litNetwork === 'datil-dev'
options?.rpcUrl ||
this.litNodeClient.config.litNetwork === 'datil-dev' ||
this.litNodeClient.config.litNetwork === 'datil-test'
FedericoAmura marked this conversation as resolved.
Show resolved Hide resolved
? LIT_RPC.VESUVIUS
: LIT_RPC.CHRONICLE;
log('rpc url: ', this.rpcUrl);
Expand Down
5 changes: 5 additions & 0 deletions packages/misc/src/lib/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
LitNetwork,
RELAY_URL_CAYENNE,
RELAY_URL_DATIL_DEV,
RELAY_URL_DATIL_TEST,
RELAY_URL_HABANERO,
RELAY_URL_MANZANO,
} from '@lit-protocol/constants';
Expand Down Expand Up @@ -681,6 +682,10 @@ export const defaultMintClaimCallback: MintCallback<
case LitNetwork.DatilDev:
relayUrl = RELAY_URL_DATIL_DEV + '/auth/claim';
break;
break;
case LitNetwork.DatilTest:
relayUrl = RELAY_URL_DATIL_TEST + '/auth/claim';
break;
}

const url = params.relayUrl ? params.relayUrl : relayUrl;
Expand Down
1 change: 1 addition & 0 deletions packages/types/src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export type LITChain<T> = Record<string, T>;
export type LIT_NETWORKS_KEYS =
| 'cayenne'
| 'datil-dev'
| 'datil-test'
| 'localhost'
| 'custom'
| 'habanero'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const SERVICE_URL_BY_NETWORKTYPE: Record<NETWORK_TYPES, string> = {

export const SERVICE_URL_BY_LIT_NETWORK: Record<SupportedNetworks, string> = {
[LitNetwork.DatilDev]: SERVICE_URL_BY_NETWORKTYPE.TestNetworks,
[LitNetwork.DatilTest]: SERVICE_URL_BY_NETWORKTYPE.TestNetworks,
[LitNetwork.Cayenne]: SERVICE_URL_BY_NETWORKTYPE.TestNetworks,
[LitNetwork.Manzano]: SERVICE_URL_BY_NETWORKTYPE.TestNetworks,
[LitNetwork.Habanero]: SERVICE_URL_BY_NETWORKTYPE.Production,
Expand Down
2 changes: 1 addition & 1 deletion packages/wrapped-keys/src/lib/service-client/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export type FetchKeyParams = BaseApiParams;

export type SupportedNetworks = Extract<
LIT_NETWORKS_KEYS,
'cayenne' | 'manzano' | 'habanero' | 'datil-dev'
'cayenne' | 'manzano' | 'habanero' | 'datil-dev' | 'datil-test'
>;

export interface StoreKeyParams extends BaseApiParams {
Expand Down
1 change: 1 addition & 0 deletions packages/wrapped-keys/src/lib/service-client/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const supportedNetworks: SupportedNetworks[] = [
'manzano',
'habanero',
'datil-dev',
'datil-test',
];

function isSupportedLitNetwork(
Expand Down
Loading