Skip to content

SolidityPack negative int equal positive (PaddedBigBytes) #108

Description

@b1674927

github.com/0xsequence/ethkit v1.22.4

SolidityPack seems to not consider negative signs:

entry1, err := ethcoder.SolidityPackHex([]string{"int32"}, []interface{}{int32(-42)})
entry2, err := ethcoder.SolidityPackHex([]string{"int32"}, []interface{}{int32(42)})
fmt.Println(entry1)
fmt.Println(entry2)
// entry1 == entry2

yields 0x0000002a, 0x0000002a

Other integer-types seem to show the same issue.

comparing to ethers/utils/solidity.ts:

let v1 = ethers.utils.solidityPack(["int32"], [-42]);
let v2 = ethers.utils.solidityPack(["int32"], [42]);
console.log(v1);
console.log(v2);

yields 0xffffffd6, 0x0000002a

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions