accounts/abi: include fixed array size for offset for dynamic types

This commit is contained in:
Yondon Fu 2017-10-11 20:51:15 -04:00
parent 2261731917
commit 701635d7b7

View file

@ -60,7 +60,17 @@ func (method Method) pack(args ...interface{}) ([]byte, error) {
// check for a slice type (string, bytes, slice) // check for a slice type (string, bytes, slice)
if input.Type.requiresLengthPrefix() { if input.Type.requiresLengthPrefix() {
// calculate the offset // calculate the offset
offset := len(method.Inputs)*32 + len(variableInput) offset := 0
for _, mInput := range method.Inputs {
if mInput.Type.IsArray {
offset += (32 * mInput.Type.SliceSize)
} else {
offset += 32
}
}
offset += len(variableInput)
// set the offset // set the offset
ret = append(ret, packNum(reflect.ValueOf(offset))...) ret = append(ret, packNum(reflect.ValueOf(offset))...)
// Append the packed output to the variable input. The variable input // Append the packed output to the variable input. The variable input