Skip to content
This repository has been archived by the owner on May 13, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1525 from xuperchain/abi_encoding
Browse files Browse the repository at this point in the history
fix encoding error of dynamic objet after uint[]
  • Loading branch information
Silas Davis authored Dec 9, 2021
2 parents 61946d7 + 69a547c commit 3b9eed4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions execution/evm/abi/abi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@ func TestPacker(t *testing.T) {
"arrayOfBoolsPack",
append(pad([]byte{1}, 32, true), pad([]byte{0}, 32, true)...),
},
// test dynamic objet uint[]
{
`[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"uint256[]","name":"_tokenIds","type":"uint256[]"},{"internalType":"string","name":"_uri","type":"string"}],"name":"increase","outputs":[],"stateMutability":"nonpayable","type":"function"}]`,
[]interface{}{[]string{"201", "202", "203"}, "hello"},
"increase",
[]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 201, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 202, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 203, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 104, 101, 108, 108, 111, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
},
} {
t.Log(test.args)
if output, _, err := EncodeFunctionCall(test.ABI, test.name, logging.NewNoopLogger(), test.args...); err != nil {
Expand Down
1 change: 1 addition & 0 deletions execution/evm/abi/packing.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ func pack(argSpec []Argument, getArg func(int) interface{}) ([]byte, error) {
if err != nil {
return nil, err
}
fixedSize += len(d)
packedDynamic = append(packedDynamic, d...)
}
}
Expand Down

0 comments on commit 3b9eed4

Please sign in to comment.