-
Notifications
You must be signed in to change notification settings - Fork 807
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
allow overrides
in useScaffoldContractWrite
#345
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cc @sverps, can we merge this? I think the solution of passing in "recklesslyUnprepared" argument to UseContractWriteConfig generic type makes sense and is minimal since we are deterministically using "recklesslyUnprepared" in our |
Yes, good fix 👍 (Will get resolved with the |
sverps
approved these changes
Jun 5, 2023
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
deployContracts.ts
is empty :This does problem does not show up if the
deployedContract.ts
is empty.Non empty
deployedContracts
:1.) It seems that typescript complains when you try to pass
![Screenshot 2023-05-13 at 3 26 52 PM](https://private-user-images.githubusercontent.com/80153681/238127633-2a38f177-558e-4a56-9be2-8215d1d3914d.jpg?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU3NzU3MDYsIm5iZiI6MTcyNTc3NTQwNiwicGF0aCI6Ii84MDE1MzY4MS8yMzgxMjc2MzMtMmEzOGYxNzctNTU4ZS00YTU2LTliZTItODIxNWQxZDM5MTRkLmpwZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTA4VDA2MDMyNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWU5MGJmNzE4ODEyY2Y0MGYwODNjNDdlOWQwMzViOTQ4MmI4ZWQyNDlhNzk2MmQyMTA3YjEwNmQ4ZWMxZWExNzAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.hPKLhyFh24La2vaaRy8YaYdEZy9qHCadsdvDUp2UL9c)
overrides
touseScafffoldContractWrite
:2.) Also another small problem is if people pass in
value
as normal arg(ETH value string) andoverrides : {gasLimit : BigNumber.from("210000")}
it will callcontract
with 0value
since we have omitted fieldvalue
inoverrides
, checkout the logic below this linescaffold-eth-2/packages/nextjs/hooks/scaffold-eth/useScaffoldContractWrite.ts
Line 42 in dd5082c
Originally mentioned in #336
Additional Information
Proposed solution :
1). Fixing types :
Passed in "recklesslyUnprepared" argument to
UseContractWriteConfig
generic type :UseContractWriteConfig<"recklesslyUnprepared">
Reason - It seems that wagmi kind of use Union discriminators for getting
UseContractWriteConfig
type checkout ->this line on wagmi implementation.
Passing
"recklesslyUnprepared"
to generic helps typescript to correctly grabPartialBy< WriteContractUnpreparedArgs<TAbi, TFunctionName>, 'abi' | 'address' | 'args' | 'functionName' >
this part of Union discriminator since that is what we want.**2.) Spreaded
overrides
andresConfig
separately checkout f32ebbfDoubt
I am kind of bit confused why TS does no complain on passing
overrides
whendeployedContract.ts
is empty.My guess is that its something to do with keys mentioned in
Omit
which is causing it to pickPrepared
branch of Union discriminator but don't know if that's truescaffold-eth-2/packages/nextjs/utils/scaffold-eth/contract.ts
Line 116 in dd5082c
Reason for doubting above line since this the type being used when
deployedContract.ts
in non-empty.Related Issues
None
Please feel free to correct me if I missed something / close this PR in case of better approach 🙌