diff options
author | Yondon Fu <yondon.fu@gmail.com> | 2017-10-12 22:58:53 +0800 |
---|---|---|
committer | Yondon Fu <yondon.fu@gmail.com> | 2017-10-12 22:58:53 +0800 |
commit | a5330fe0c569b75cb8a524f60f7e8dc06498262b (patch) | |
tree | 48d19fd353e6ad443107a44234613a6d0c8563c7 /accounts/abi/method.go | |
parent | 8d8034fe59e40d606e6feea4c71b4798e7862e2f (diff) | |
download | dexon-a5330fe0c569b75cb8a524f60f7e8dc06498262b.tar dexon-a5330fe0c569b75cb8a524f60f7e8dc06498262b.tar.gz dexon-a5330fe0c569b75cb8a524f60f7e8dc06498262b.tar.bz2 dexon-a5330fe0c569b75cb8a524f60f7e8dc06498262b.tar.lz dexon-a5330fe0c569b75cb8a524f60f7e8dc06498262b.tar.xz dexon-a5330fe0c569b75cb8a524f60f7e8dc06498262b.tar.zst dexon-a5330fe0c569b75cb8a524f60f7e8dc06498262b.zip |
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 62b3d2957..32077e8a6 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.IsArray { + inputOffset += (32 * input.Type.SliceSize) + } 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 |