Skip to content
This repository was archived by the owner on Nov 2, 2021. It is now read-only.

fix: Make smoddit work for bytesN map keys #36

Merged
merged 1 commit into from
Apr 8, 2021

Conversation

smartcontracts
Copy link
Collaborator

Description
Fixes smoddit so that it'll work for bytesN keys. Underlying bug was that all values were being treated like uint and were being right-aligned (padding the start with zeros). Solidity handles bytesN where N < 32 by padding the end with zeros (left-aligned). Also adds a regression test.

Metadata

@@ -6,10 +6,15 @@ export const toHexString32 = (
value: string | number | BigNumber | boolean
): string => {
if (typeof value === 'string' && value.startsWith('0x')) {
return '0x' + remove0x(value).padStart(64, '0').toLowerCase()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This function probably needs to be cleaned up in the future but whatever for now.

Copy link

@ben-chain ben-chain left a comment

Choose a reason for hiding this comment

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

LGTM!

@smartcontracts smartcontracts merged commit a597537 into main Apr 8, 2021
@smartcontracts smartcontracts deleted the fix/smod-bytesN-map branch April 8, 2021 02:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Setting a mapping bytes5 key fails
2 participants