-
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
Conversation
…whatever blockchain clients you want to interact with them. eg. ethers.js, web3.js, viem, etc. We don't care.
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.
👍 It would be great to allow consumers to find contracts themselves I think 👍
I am curious about why we have a single method that always returns all 3 networks of contracts, though? I think most commonly consumers work within the context of a single network at a time, and everything else in the contracts-sdk
is specific to a single network at a time.
Why not make _resolveContractContext
a public, static method if we want to expose its behaviour? Then consumers could call it for one or for many networks however they want.
|
||
it('should get all contracts', async () => { | ||
// polyfill | ||
const crossFetch = require('cross-fetch'); |
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?
await LitContracts._resolveContractContext(LitNetwork.Manzano), | ||
await LitContracts._resolveContractContext(LitNetwork.Habanero), | ||
await LitContracts._resolveContractContext(LitNetwork.Cayenne), |
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.
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
};
🔪 await
ing each array element here -- promise.all()
should receive an array of promises that are running in parallel, but this is awaiting each array element, putting the the un-wrapped values into an array, then passing the array of no-longer-promises into promise.all()
instead of passing the promises themselves into `promise.all()...
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.
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.
Description
LitContracts
package only supports ethers5 atm., and we are pretty much locked-in to this version and blockchain client. We should just return all the network contract addresses & abis; then, the developers can use whatever clients they want. However, we need to provide documentation on how to use common smart contract features, such asmintNext
for PKP,addPermittedAction
to add permitted action to a given PKP & IPFS ID, etc.Usage
Interface
Type of change
How Has This Been Tested?
Jessy jesty jest
Checklist: