bytes32 type is too strict #77
Replies: 8 comments 2 replies
-
You could try extending the config like it's shown here. For the wagmi package something like this should work import "abitype";
declare module "wagmi/node_modules/abitype" {
export interface Config {
BytesType: Uint8Array | string;
}
} |
Beta Was this translation helpful? Give feedback.
-
Nice! I still think it should be the default. It’s odd for literal bytes to not match type for something expecting bytes |
Beta Was this translation helpful? Give feedback.
-
Looks really easy to make it the default I can do the pr |
Beta Was this translation helpful? Give feedback.
-
Ethers does use something similar Reference Could possibly make sense in having a similar default |
Beta Was this translation helpful? Give feedback.
-
The default used to be When thinking about defaults, I think about ABI item inputs and outputs. Does For example, if I want to decode Think there are two approaches here:
|
Beta Was this translation helpful? Give feedback.
-
Being worked on #78 |
Beta Was this translation helpful? Give feedback.
-
fwiw I disagree with past me here. Consistently using hex strings is quite nice |
Beta Was this translation helpful? Give feedback.
-
I always wonder if there are peformance reasons to use bytes array rather than hex strings though |
Beta Was this translation helpful? Give feedback.
-
Is there an existing issue for this?
Package Version
latest
TypeScript Version
latest
Current Behavior
The type for bytes32 only accepts hex numbers of type
0x....
. Have to awkwardly convert bytes to a hex value. I think not accepting a string makes sense as it could be a mistake but literal bytes should be validExpected Behavior
Should loosen type to accept bytes arrays too
Link to Minimal Reproducible Example (TypeScript Playground)
https://github.com/ethereum-optimism/optimism/blob/ef8d1454ddd68cc6a42129549595cb0f1d84af87/packages/atst/src/index.ts
Steps To Reproduce
Pass in any bytes array to a contract method that accepts bytes32
Anything else?
No response
Beta Was this translation helpful? Give feedback.
All reactions