-
Notifications
You must be signed in to change notification settings - Fork 69
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
Proposal/return all contracts #451
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,7 @@ import { | |
convertRequestsPerDayToPerSecond, | ||
requestsToKilosecond, | ||
} from './utils'; | ||
import { LitNetwork } from '@lit-protocol/constants'; | ||
|
||
const DEFAULT_RPC = 'https://chain-rpc.litprotocol.com/http'; | ||
const BLOCK_EXPLORER = 'https://chain.litprotocol.com/'; | ||
|
@@ -568,6 +569,33 @@ export class LitContracts { | |
this.connected = true; | ||
}; | ||
|
||
/** | ||
* Here are the Lit contracts for different networks; you can use whichever blockchain clients you want to interact with them, e.g., ethers.js, web3.js, viem, etc. We don't care. | ||
* | ||
* @returns {Promise<{ | ||
* manzano: LitContractContext, | ||
* habanero: LitContractContext, | ||
* cayenne: LitContractContext | ||
* }>} Returns an object with the contracts for each network. | ||
*/ | ||
public static getContracts = async (): Promise<{ | ||
manzano: LitContractContext; | ||
habanero: LitContractContext; | ||
cayenne: LitContractContext; | ||
}> => { | ||
const [manzano, habanero, cayenne] = await Promise.all([ | ||
await LitContracts._resolveContractContext(LitNetwork.Manzano), | ||
await LitContracts._resolveContractContext(LitNetwork.Habanero), | ||
await LitContracts._resolveContractContext(LitNetwork.Cayenne), | ||
Comment on lines
+587
to
+589
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the equivalent of: const val = await LitContracts._resolveContractContext(LitNetwork.Manzano);
const val2 = await LitContracts._resolveContractContext(LitNetwork.Habanero);
const val3 = await LitContracts._resolveContractContext(LitNetwork.Cayenne);
const [manzano, habanero, cayenne] = await Promise.all([val, val2, val3]);
return {
manzano,
habanero,
cayenne
}; 🔪 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch! yea was copy/pasting the original code didn't pay attention to that, but we can discuss if we actually want this. It was a 3am idea that i quickly drafted, so it's not a hard requirement nor tracked in linear. |
||
]); | ||
|
||
return { | ||
manzano, | ||
habanero, | ||
cayenne, | ||
}; | ||
}; | ||
|
||
public static async getStakingContract( | ||
network: 'cayenne' | 'manzano' | 'habanero' | 'custom' | 'localhost', | ||
context?: LitContractContext | LitContractResolverContext | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not
import 'cross-fetch/polyfill';
at top of file?