diff options
author | Martin Holst Swende <martin@swende.se> | 2017-12-21 21:42:03 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-21 21:42:03 +0800 |
commit | b0d41e386e456cefd593db303a9f5284bf08cd07 (patch) | |
tree | 4c2db9b717b5d508393ba7e2617e9af10f241d1f /accounts/abi/method.go | |
parent | 91c3362315ca8161c4b927c8f41a9165ae75f3ac (diff) | |
parent | cf7aba36c82a1a6c2b2c9e5c623045093b1827eb (diff) | |
download | go-tangerine-b0d41e386e456cefd593db303a9f5284bf08cd07.tar go-tangerine-b0d41e386e456cefd593db303a9f5284bf08cd07.tar.gz go-tangerine-b0d41e386e456cefd593db303a9f5284bf08cd07.tar.bz2 go-tangerine-b0d41e386e456cefd593db303a9f5284bf08cd07.tar.lz go-tangerine-b0d41e386e456cefd593db303a9f5284bf08cd07.tar.xz go-tangerine-b0d41e386e456cefd593db303a9f5284bf08cd07.tar.zst go-tangerine-b0d41e386e456cefd593db303a9f5284bf08cd07.zip |
Merge pull request #15285 from yondonfu/abi-offset-fixed-arrays
accounts/abi: include fixed array size in offset for dynamic type
Diffstat (limited to 'accounts/abi/method.go')
-rw-r--r-- | accounts/abi/method.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/accounts/abi/method.go b/accounts/abi/method.go index 6b9aa011e..66e8751f3 100644 --- a/accounts/abi/method.go +++ b/accounts/abi/method.go @@ -48,6 +48,16 @@ func (method Method) pack(args ...interface{}) ([]byte, error) { // output. This is used for strings and bytes types input. var variableInput []byte + // input offset is the bytes offset for packed output + inputOffset := 0 + for _, input := range method.Inputs { + if input.Type.T == ArrayTy { + inputOffset += (32 * input.Type.Size) + } else { + inputOffset += 32 + } + } + var ret []byte for i, a := range args { input := method.Inputs[i] @@ -60,7 +70,8 @@ func (method Method) pack(args ...interface{}) ([]byte, error) { // check for a slice type (string, bytes, slice) if input.Type.requiresLengthPrefix() { // calculate the offset - offset := len(method.Inputs)*32 + len(variableInput) + offset := inputOffset + len(variableInput) + // set the offset ret = append(ret, packNum(reflect.ValueOf(offset))...) // Append the packed output to the variable input. The variable input |