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

Commit 3b9eed4

Browse files
author
Silas Davis
authored
Merge pull request #1525 from xuperchain/abi_encoding
fix encoding error of dynamic objet after uint[]
2 parents 61946d7 + 69a547c commit 3b9eed4

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

Diff for: execution/evm/abi/abi_test.go

+7
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,13 @@ func TestPacker(t *testing.T) {
139139
"arrayOfBoolsPack",
140140
append(pad([]byte{1}, 32, true), pad([]byte{0}, 32, true)...),
141141
},
142+
// test dynamic objet uint[]
143+
{
144+
`[{"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"}]`,
145+
[]interface{}{[]string{"201", "202", "203"}, "hello"},
146+
"increase",
147+
[]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},
148+
},
142149
} {
143150
t.Log(test.args)
144151
if output, _, err := EncodeFunctionCall(test.ABI, test.name, logging.NewNoopLogger(), test.args...); err != nil {

Diff for: execution/evm/abi/packing.go

+1
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ func pack(argSpec []Argument, getArg func(int) interface{}) ([]byte, error) {
233233
if err != nil {
234234
return nil, err
235235
}
236+
fixedSize += len(d)
236237
packedDynamic = append(packedDynamic, d...)
237238
}
238239
}

0 commit comments

Comments
 (0)