-
Notifications
You must be signed in to change notification settings - Fork 922
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
bug: deployedContracts file being out of sync #369
Comments
Fair point. One remark, though, is that anything generated on a local chain is only present locally, so I think it's fine to keep Committing stuff deployed to other chains to a repo makes sense. |
Hey @kevinjoshi46b Thanks for posting this issue. I noticed this when working with multiple people and deploying different smart contracts. As you said, the source of truth is the I saw your PR #370 where you un-gitignore the Related to this (thinking about the localhost contracts «noise»), I'm wondering if we should have different files for the
No need to fix it in the same PR/Issues, just saying it out loud for future action. 2 also might be tricky with types (we ended up having an "empty" deployedContracts.ts file to detect that no contracts have been deployed.) What do you guys think? @technophile-04 @sverps |
(Sorry I missed @sverps comment while writing mine) Same page tho! : D |
Hmmm, if we were to split the generated contract files and gitignore the local ones, we'd again run into the issues that lead to it being included. We'd need to figure out a post-install step etc. So not sure if we win much by doing so. Keeping the generated contract files in the repo also ensures that types aren't broken until someone runs a deploy step, which is easier for pre-commit hooks and pipelines to validate stuff. So I'd keep things as they are now concerning the generated contract typescript files. |
I think that it's helpful to have different files for the local, non-local, and external contracts, and have the non-local and external contracts inside the repository. About the comment from @sverps "Hmmm, if we were to split the generated contract files and gitignore the local ones, we'd again run into the issues that lead to it being included.", I'm not sure what was "the issues that lead to it being included". In doubt, I think that it is better to add all files to git, and then the developer can decide if a change inside these files makes sense to commit the changes or not. |
In summary, the types derived from this contract file, which is imported somewhere, so it must exist. When it wasn't in the repo (due to gitignore), we had 2 options:
So we went for the option to just include it in the repo, and simplify a bunch of scripts. |
I feel the current state where the About ignoring the I would like to work on this issue, for now atleast splitting the current single |
Thanks all for the feedback, good discussion :) It's a bit tricky! A few thoughts: => As @damianmarti and @kevinjoshi46b say, having the contracts split into 3 files (local, non-local, external) is a good DX. In the same way that we don't want to commit the But, as @sverps said, we had some issues with the types, and ended up adding the file (was .gitignored before). Not the ideal solution, but it works! Some context: #255, #260, #282 This is the file in question:
Yeah, this makes sense to me |
@carletex @kevinjoshi46b Maybe we can create some custom resolver logic in webpack to try and resolve the generated local contracts, and if it doesn't exist, take some fallback file that exports It'll be tricky to properly resolve the types based on this custom webpack resolver and based on configured network though, but maybe there's a way to get this working. |
You are talking about editing the PS, I am new to TS and I got overwhelmed after opening the |
The functionality of |
Ya I think we can edit it to read the chain id and apply our separation for local chain. I will try working on this. |
I think this has gotten a lot easier after #592, We could probably achieve this by :
// contract.ts
const allDeployedContracts = deepMergeContracts(deployedContracts, deployedLocalhostContracts)
const contractsData = deepMergeContracts(allDeployedContracts, externalContractsData); @kevinjoshi46b could you please revamp #370 / create a fresh PR since a lot of things have changed, please let us know if you need any help 🙌, also happy to take this if you are busy 🙌 |
Hello @technophile-04, |
Current Behavior
Currently the
deployments
folder in hardhat has been gitignored leading to all the data related to deployments being stored only on local computer.The
deployedContracts
file in nextjs is being generated based on thisdeployments
folder whenever a new deployment takes place.Consider a scenario where you deployed the smart contract on polygon from your machine which updated the
deployedContracts
file with its address, abi etc. You committed and pushed all the changes to github. Now someone else working on the same project pulled the changes and deployed the contract on arbitrum, what happens is thedeployedContracts
file gets updated with the deployement data of only arbitrum and looses the data from polygon since the second person doesn't have thedeployements
folder containing data related to deployment on polygon chain on their computer.Expected Behavior
The expected behavior would be when the second person deploys the contract on arbitrum the
deployedContracts
file should be updated by appending the data related to arbitrum deployment and not loosing any previously existing deployment data related to other chainsAnything else?
Removing the
deployments
folder in hardhat from gitignore solves this issue of inconsistency. I am not sure on why it was added but I am currently unable to see any reason for its existence if there is some please do enlighten me.The text was updated successfully, but these errors were encountered: