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

Optional chain parameter in Scaffold hooks #931

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

JacobHomanics
Copy link
Contributor

Description

Provides the option to pass a different network into the scaffold hooks than the one that the user's wallet is currently connected to. This allows for applications that can show data from different blockchains than that of which the user's wallet is connected to. The hooks still abide by the rules that the contract instance's need to be within the deployedContracts file and targetNetworks needs to have the expected chain(s) present.

live example: https://scaffold-eth-optional-chains-example-nextjs.vercel.app/
live example repo: https://github.com/Hotmanics/scaffold-eth-optionalChainsExample

Additional Information

Your ENS/address: jacobhomanics.eth

@@ -22,16 +23,19 @@ import {
*/
export const useScaffoldWriteContract = <TContractName extends ContractName>(
contractName: TContractName,
chain?: Chain,
Copy link
Member

@rin-st rin-st Sep 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for pr @Hotmanics !

Some thoughts regarding params:
so if I want for example pass writeContractParams without chain, I need to use undefined every time?

const { writeContractAsync } = useScaffoldWriteContract("YourContract", undefined, {});

changing order to contractName, writeContractParams?, chain? will cause same problem when needed to pass chain without writeContractParams.

So maybe we need to change params to object {contractName, writeContractParams?, chain?} here and for all other hooks without object in params? And params will become more consistent. Because for now somewhere we have objects, somewhere not. Or another option: (contractName, options?: {writeContractParams?, chain?}) but I'm voting for one object. Probably this can be changed in later pr's

Don't change it right now, let's wait Shiv or Carlos

cc @technophile-04 @carletex

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are absolutely correct. This was an oversight by me.

Not sure as the best path forward, I'm sure others will be able to provide a more detailed observation.

Appreciate you looking at the PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants