mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-16 17:03:46 +00:00
accounts/abi: include fixed array size for offset for dynamic types
This commit is contained in:
parent
2261731917
commit
701635d7b7
1 changed files with 11 additions and 1 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue