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

fix(contract.ts): improve missing config check #372

Merged
merged 2 commits into from
Jun 16, 2023

Conversation

sverps
Copy link
Collaborator

@sverps sverps commented Jun 12, 2023

Description

Rather than just check if deployedContracts is null, this improves the behavior to check if there is a contract definition for the network selected in scaffold.config.ts. This results in fewer type errors when a contract might have been deployed on some network, but locally a user only has the file generated for another network.

Related Issues

Fixes #371

@technophile-04
Copy link
Collaborator

technophile-04 commented Jun 12, 2023

Tysm @sverps 🙌, but I think I am kind of neutral on this because I would love to see an error when I deploy my contract to sepolia and my frontend is pointing to goerli.

With this fix I deployed my contract to sepolia and pointed my frontend to mainnet and I see no error for contractReads/Write even when you run yarn next:types no errors are shown this means while deploying too it would get easily deployed even though I am pointing to mainnet and don't have any contract on it.

Yup this fix will be beginner friendly also the TS error message { contractName: string; functionName: string; } is not good but I would prefer to get an error if am doing something wrong 😅


An idea : What if we log a message like "Make sure you update the chain to seplolia in scaffold.config.ts" after you run deploy to avoid situations like #371, since now we run our custom script in the end :

console.log(`📝 Updated TypeScript contract definition file on ${TARGET_DIR}deployedContracts.ts`);

@sverps
Copy link
Collaborator Author

sverps commented Jun 12, 2023

When you run the frontend without a deployed contract on the chain you configured, it already properly informs you of it, right? For beginners, I think that is slightly preferred over some console warning or error that could easily get overlooked.

But it's not entirely clear-cut either. So I'm okay with exploring this discussion a bit further.

@technophile-04
Copy link
Collaborator

If you run frontend without a deployed contract on the chain you configured

Screen.Recording.2023-06-13.at.11.36.30.AM.mov

People get this popup if they use useScaffold hooks


Regarding types error

Screen.Recording.2023-06-13.at.11.32.27.AM.mov

As we can see we don't get any error on this branch even if we have a missing deployed contract for that chain.


But it's not entirely clear-cut either.

+++

I mean I am completely fine with the current fix and it makes sense, but I am kind of leaning towards showing good ts-error(which will be tough) instead of not showing the error itself but yeah current fix also makes sense!! since the ts-error is not beginner friendly

@sverps
Copy link
Collaborator Author

sverps commented Jun 16, 2023

#378 seems to have the same issue (awaiting confirmation from issue creator)

@technophile-04 I'd like to merge this PR to avoid blocking users with non-intuitive errors.

Copy link
Collaborator

@technophile-04 technophile-04 left a comment

Choose a reason for hiding this comment

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

blocking users with non-intuitive errors

Yeah I agree, people might spend time in the wrong direction while debugging due to non-intuitive errors so lets merge, Tysm @sverps for the fix 🙌

@technophile-04 technophile-04 merged commit 237a500 into main Jun 16, 2023
1 check passed
@technophile-04 technophile-04 deleted the fix/371-improve-contract-types branch June 16, 2023 09:16
kmjones1979 added a commit that referenced this pull request Jul 3, 2023
* Update SE-2 nomenclautre  (#317)

* Fix autoConnect when contract not deployed (#292)

* oxford comma lol

* Fix icon visibility on dark mode in EtherInput (#320)

* Update README: Add Vercel ENV var to disable type/lint checking (#327)

* Fix typo (#334)

Fix typo at code snippet

* README: Updated SE-2 custom hook section (#330)

Co-authored-by: KcPele <fidekg123@gmail.com>
Co-authored-by: Shiv Bhonde <shivbhonde04@gmail.com>
Co-authored-by: Carlos Sánchez <oceanrdn@gmail.com>

* Remove duplicated HINT on README (#335)

* PR and Issue templates (#329)

* Native currency symbol and price as per target network (#322)

* useAppStore => useGlobalState (#338)

* Event history filter type (#333)

* fix: event history filter type

Fixes #332

* fix: make scaffold event history config separate type

* fix: prettier broke due to invalid syntax

* fix: ts error after generating contract

* Indexed prop + example

---------

Co-authored-by: Carlos Sánchez <oceanrdn@gmail.com>

* Update README: custom hooks section (#339)

* fix: assert type as Abi to avoid ts error (#350)

* fix: assert type as Abi to avoid ts error

Fixes #344

* assert type as Abi to avoid ts error on useScaffoldContract

---------

Co-authored-by: Carlos Sánchez <oceanrdn@gmail.com>

* Fix useEffect filter dep on event hook (#349)

* Block confirmation options / callback for useScaffoldContractWrite (#348)

* Patch useLocalStorage setting the right initial value to avoid a hydration error (#356)

Co-authored-by: sverps <sverps@gmail.com>

* Save selected contract to local storage (#326)

* Save selected contract to local storage

* refactor: Replaced native localStorage with useLocalStorage from usehooks-ts

* Fixed empty string parameter error.

* Updated parameter requirements to fix issue.

* Fixed error.

* Fixed parameter assignment error.

* Use useLocalStorage to save selected contract

---------

Co-authored-by: Damian <damianmarti@gmail.com>

* Refactor meta tags into separate component and add default thumbnail / image (#359)

* Hotfix: thumbnail.png => thumbnail.jpg

* Local Block Explorer (#351)

Co-authored-by: Shiv Bhonde <shivbhonde04@gmail.com>

* Fix daisyUI dropdown on IOS (#342)

* allow `overrides` in useScaffoldContractWrite (#345)

* allow overrides for useScaffoldContractWrite

* spread overrides and restConfig separately

* feat: proactively disable read hook when it would result in error (#250)

Fixes #249

Co-authored-by: Shiv Bhonde | shivbhonde.eth <shivbhonde04@gmail.com>

* Size prop on Address component (#365)


Co-authored-by: Carlos Sánchez <oceanrdn@gmail.com>

* Generate TS ABIs from deploy script (#368)

* enable solidity optimizer by default (#360)

* fix(Balance): font-size of symbol should be relative to current font-size, not document root (#375)

* fix(contract.ts): very long abi's now no longer go over type instantiation limit (#377)

Fixes #374

* fix(contract.ts): improve missing config check (#372)

Fixes #371

* fix listner types error when contracts missing (#379)

* zkSyncEra Testnet config (#383)

* Upgrade hardhat-deploy to 0.11.26 where zkSync is supported

* Dependency for @matterlabs/hardhat-zksync-solc

* Add zkSyncEraTestnet to networks

* Import @matterlabs/hardhat-zksync-solc

* Add artifacts-zk and cache-zk to gitignore

* yarn install

* Add zkSync mainnet config

* add hardhat-zksync-verify for contract verification

---------

Co-authored-by: moltam89 <moltam89@gmail.com>
Co-authored-by: Damian <damianmarti@gmail.com>
Co-authored-by: Shiv Bhonde <shivbhonde04@gmail.com>

* allow writeAsync by useScaffoldContractWrite to be called with updated args (#385)

* update wagmi & rainbow for walletConnectV2 (#381)

* meged changes from main, additional configuration in subgraph.yaml

---------

Co-authored-by: Shiv Bhonde | shivbhonde.eth <shivbhonde04@gmail.com>
Co-authored-by: Austin Griffith <austin@ethereum.org>
Co-authored-by: Kevin Joshi <kevinjoshi46b@gmail.com>
Co-authored-by: Carlos Sánchez <oceanrdn@gmail.com>
Co-authored-by: AlehN <natsevsky@gmail.com>
Co-authored-by: Pablo Alayeto <55535804+Pabl0cks@users.noreply.github.com>
Co-authored-by: KcPele <fidekg123@gmail.com>
Co-authored-by: Samuel | solidixen.eth <sverps@gmail.com>
Co-authored-by: Eda Akturk <edakturk96@gmail.com>
Co-authored-by: Tamas Molnar <tamas.molnar@liferay.com>
Co-authored-by: Damian Martinelli <damianmarti@gmail.com>
Co-authored-by: Alexander <a00112699@gmail.com>
Co-authored-by: port <108868128+portdeveloper@users.noreply.github.com>
Co-authored-by: moltam89 <moltam89@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants