Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

accounts/abi unpack function can not unpack string Array #18352

Closed
weimumu opened this issue Dec 21, 2018 · 2 comments
Closed

accounts/abi unpack function can not unpack string Array #18352

weimumu opened this issue Dec 21, 2018 · 2 comments

Comments

@weimumu
Copy link
Contributor

weimumu commented Dec 21, 2018

Hi there,

please note that this is an issue tracker reserved for bug reports and feature requests.

For general questions please use the gitter channel or the Ethereum stack exchange at https://ethereum.stackexchange.com.

System information

Geth version: geth version 1.8.18 or later
OS & Version: Windows/Linux/OSX
Commit hash : (if develop)

Expected behaviour

I use the accounts/abi unpack function to unpack bytes like "0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000077765696d756d7500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a7765696d756d753132330000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000077765696d756d7500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a7765696d756d7531323300000000000000000000000000000000000000000000" to go variable [4]string. The right answer shoule be ['weimumu', 'weimumu123', 'weimumu', 'weimumu123'] which the web3.js can rightly decode.

Actual behaviour

But I got an error from the unpack function like "cannot marshal in to go type: length insufficient 416 require 480"

Steps to reproduce the behaviour

The main code I right can be show as follows:
func main() {
ggtest := [ { "inputs": [], "payable": false, "stateMutability": "nonpayable", "type": "constructor" }, { "constant": true, "inputs": [ { "name": "", "type": "uint256" } ], "name": "g", "outputs": [ { "name": "", "type": "string" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "get", "outputs": [ { "name": "", "type": "string[4]" } ], "payable": false, "stateMutability": "view", "type": "function" } ]
testABI, err := abi.JSON(strings.NewReader(ggtest))
if err != nil {
fmt.Println("GG")
}
testOutput, _ := hex.DecodeString("0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000077765696d756d7500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a7765696d756d753132330000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000077765696d756d7500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a7765696d756d7531323300000000000000000000000000000000000000000000")
//fmt.Println(testOutput)
ret := [4]string{}
if err := testABI.Unpack(&ret,"get", testOutput); err != nil {
fmt.Println(err)
}
}

Backtrace

[backtrace]
@rjl493456442
Copy link
Member

We just merged an abi relative PR #18406, this issue should be fixed. Could you please try with latest code?

@weimumu
Copy link
Contributor Author

weimumu commented Jan 10, 2019

I know it and it has been fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants