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

add optional chain param to viem deploy #783

Conversation

johnpm-12
Copy link

see #782

@zoeyTM
Copy link
Contributor

zoeyTM commented Jun 17, 2024

I actually don't think this is needed at all. We have access to the chain ID, either by querying the network or via the custom one configured in hardhat config. All we need to do is pass the existing chain ID into the viem functions as well. No need for a new parameter. @kanej

@alcuadrado
Copy link
Member

Agreed with @zoeyTM.

Can you explain the motivation behind a new param? Is it because of a type-level limitation?

@zoeyTM zoeyTM force-pushed the development branch 2 times, most recently from 6f5ec1c to 1675490 Compare June 17, 2024 16:50
@johnpm-12
Copy link
Author

johnpm-12 commented Jun 18, 2024

I actually don't think this is needed at all. We have access to the chain ID, either by querying the network or via the custom one configured in hardhat config. All we need to do is pass the existing chain ID into the viem functions as well. No need for a new parameter. @kanej

I originally considered defining the custom chain inside the deploy function automatically if the chain id doesn't match a supported viem chain. But you have to make assumptions about native currency name, symbol, and decimals. They're required params when defining a viem chain.

https://viem.sh/docs/chains/introduction#custom-chains

EDIT: also I figured it should support functionality similar to the other viem hardhat functions (getPublicClient, getWalletClients, etc). They solve this problem with an optional chain parameter

@zoeyTM
Copy link
Contributor

zoeyTM commented Jun 19, 2024

I actually don't think this is needed at all. We have access to the chain ID, either by querying the network or via the custom one configured in hardhat config. All we need to do is pass the existing chain ID into the viem functions as well. No need for a new parameter. @kanej

I originally considered defining the custom chain inside the deploy function automatically if the chain id doesn't match a supported viem chain. But you have to make assumptions about native currency name, symbol, and decimals. They're required params when defining a viem chain.

https://viem.sh/docs/chains/introduction#custom-chains

EDIT: also I figured it should support functionality similar to the other viem hardhat functions (getPublicClient, getWalletClients, etc). They solve this problem with an optional chain parameter

I think this functionality would be better served via extending hardhat config, adding the necessary fields to custom chains there, then pulling the info from hre.config inside the ignition helper.

@johnpm-12
Copy link
Author

I actually don't think this is needed at all. We have access to the chain ID, either by querying the network or via the custom one configured in hardhat config. All we need to do is pass the existing chain ID into the viem functions as well. No need for a new parameter. @kanej

I originally considered defining the custom chain inside the deploy function automatically if the chain id doesn't match a supported viem chain. But you have to make assumptions about native currency name, symbol, and decimals. They're required params when defining a viem chain.
https://viem.sh/docs/chains/introduction#custom-chains
EDIT: also I figured it should support functionality similar to the other viem hardhat functions (getPublicClient, getWalletClients, etc). They solve this problem with an optional chain parameter

I think this functionality would be better served via extending hardhat config, adding the necessary fields to custom chains there, then pulling the info from hre.config inside the ignition helper.

And generate the custom chain internally if it's defined in the hardhat config?
What if a custom chain is not fully defined in the hardhat config? Throw an error?
I assume getpublicClient, getWalletClients, and the other hardhat viem functions would need to be updated to do this, too?

I can do it this way, I just want to make sure I understand how ya'll want it done before I get started

@kanej kanej force-pushed the fix/add-chain-param-to-viem-deploy branch from f0a9619 to 98e7706 Compare December 13, 2024 12:11
@kanej
Copy link
Member

kanej commented Dec 13, 2024

I am going to close this PR as we are porting Ignition to the Hardhat repo.

We are also reworking the entirety of hardhat.config.{js,ts} for Hardhat 3. I think after the update of Ignition to support Hardhat 3 is the time to tackle configuration options for custom chains in hardhat-plugin-viem.

@kanej kanej closed this Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants