bug: Types of property 'abi' are incompatible.
See original GitHub issueIs there an existing issue for this?
- I have searched the existing issues
Package Version
0.7.3
Current Behavior
I upgraded from 0.6.8 to 0.7.3. I followed the migration guide, principally addressOrName and contractInterface renamed to address and abi
. My config
from usePrepareConfigWrite
now throws an error when passed into useContractWrite
Types of property 'abi' are incompatible.
Type 'readonly unknown[]' is not assignable to type 'readonly {}[]'.
Type 'unknown' is not assignable to type '{}'.
Expected Behavior
With the fields renamed, I expected the config
to work as it did previously
Steps To Reproduce
Before, with 0.6.8:
const { config } = usePrepareContractWrite({
addressOrName: contractAddresses(writeContractName),
contractInterface: abis[writeContractName],
functionName: 'safeClaimUBI',
args: [outstandingCharacters]
});
const { writeAsync } = useContractWrite({ ...config, chainId: genesisChain.id });
After, with 0.7.3:
const { config } = usePrepareContractWrite({
address: contractAddresses(writeContractName),
abi: abis[writeContractName],
functionName: 'safeClaimUBI',
args: [outstandingCharacters]
});
const { writeAsync } = useContractWrite({ ...config, chainId: genesisChain.id }); // this line throws the error:
Error:
TS2345: Argument of type '{ chainId: number; abi: readonly unknown[]; address: string; functionName: "safeClaimUBI"; mode: "prepared"; request: ethers.PopulatedTransaction & { to: `0x${string}`; gasLimit: ethers.BigNumber; }; }' is not assignable to parameter of type 'UseContractWriteConfig<readonly unknown[], "safeClaimUBI"> | undefined'.
Type '{ chainId: number; abi: readonly unknown[]; address: string; functionName: "safeClaimUBI"; mode: "prepared"; request: ethers.PopulatedTransaction & { to: `0x${string}`; gasLimit: ethers.BigNumber; }; }' is not assignable to type 'MutationConfig<SendTransactionResult, Error, UseContractWriteArgs<Abi, string>> & Omit<ContractConfig<Omit<{ ...; }, OmitConfigProperties>, readonly unknown[], "safeClaimUBI", never, { ...; }>, "args"> & ... 5 more ... & Omit<...>'.
Type '{ chainId: number; abi: readonly unknown[]; address: string; functionName: "safeClaimUBI"; mode: "prepared"; request: ethers.PopulatedTransaction & { to: `0x${string}`; gasLimit: ethers.BigNumber; }; }' is not assignable to type 'Omit<ContractConfig<Omit<{ abi: readonly unknown[]; functionName: "safeClaimUBI"; chainId?: number | undefined; }, OmitConfigProperties>, readonly unknown[], "safeClaimUBI", never, { isAbiOptional: true; isAddressOptional: true; isArgsOptional: true; isFunctionNameOptional: true; isRequestOptional: true; }>, "args">'.
Types of property 'abi' are incompatible.
Type 'readonly unknown[]' is not assignable to type 'readonly {}[]'.
Type 'unknown' is not assignable to type '{}'.
87 | });
88 |
> 89 | const { writeAsync } = useContractWrite({ ...config, chainId: genesisChain.id });
Link to Minimal Reproducible Example (CodeSandbox, StackBlitz, etc.)
No response
Anything else?
No response
Issue Analytics
- State:
- Created a year ago
- Comments:10 (8 by maintainers)
Top Results From Across the Web
bug: Types of property 'abi' are incompatible. - PullAnswer
Error: TS2345: Argument of type '{ chainId: number; abi: readonly unknown[]; address: string; functionName: "safeClaimUBI"; mode: "prepared"; request: ethers.
Read more >solidity JSON ABI type not supported by Contract or Interface ...
I'm creating contract instances by importing the JSON ABI (out of solidity, or as copied from etherscan contract page e.g.) in typescript ...
Read more >Android ABIs - NDK
This page enumerates the ABIs that the NDK supports, and provides information about how each ABI works. ABI can also refer to the...
Read more >GCC ABI compatibility - c++ - Stack Overflow
Since gcc-3.4.0, the ABI is forward compatible. I.E. a library made using an older release can be linked with a newer one and...
Read more >libabigail(7) - Linux manual page - man7.org
The type of interface incompatibilities that Abigail focuses on is related to changes on the exported ELF functions and variables symbols, as well...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I have this same issue and it’s tough to track down what is wrong or whats wrong with my ABI - given i generate it directly using hardhats generation functionality.
Ok well I figured out a workaround. I"m using hardhat’s sample deploy script to generate the abi.
The current script has this function:
I can generate a typescript friendly abi with the following code:
Altogether it looks like:
Then in my code I can do:
and use that abi successfully.
Not sure if theres a better way to generate the
ts
abi file but open to suggestions.