From cf40e199859d6841c0787dea8b626ebc563818f0 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Tue, 25 May 2021 17:10:48 +0300 Subject: [PATCH] [#505] morph/container: Change parsing of Get contract method's result `Get` method of `Container` contract returns structure with 4 fields (container is the 1st one). Signed-off-by: Leonard Lyubich --- pkg/morph/client/container/get.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pkg/morph/client/container/get.go b/pkg/morph/client/container/get.go index bcf586806..b9f579b81 100644 --- a/pkg/morph/client/container/get.go +++ b/pkg/morph/client/container/get.go @@ -43,9 +43,18 @@ func (c *Client) Get(args GetArgs) (*GetValues, error) { return nil, fmt.Errorf("unexpected stack item count (%s): %d", c.getMethod, ln) } - cnrBytes, err := client.BytesFromStackItem(prms[0]) + arr, err := client.ArrayFromStackItem(prms[0]) if err != nil { - return nil, fmt.Errorf("could not get byte array from stack item (%s): %w", c.getMethod, err) + return nil, fmt.Errorf("could not get item array of container (%s): %w", c.getMethod, err) + } + + if len(arr) != 4 { + return nil, fmt.Errorf("unexpected container stack item count (%s): %d", c.getMethod, len(arr)) + } + + cnrBytes, err := client.BytesFromStackItem(arr[0]) + if err != nil { + return nil, fmt.Errorf("could not get byte array of container (%s): %w", c.getMethod, err) } return &GetValues{