From 6d7d004b2b16b41c8c5880a8bada2a9d349931c9 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Sun, 11 Aug 2024 17:03:42 +0200 Subject: [PATCH] internal/ship/contract_row.go: adding DecodeContractRow that actually decodes data from abi --- internal/ship/contract_row.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/internal/ship/contract_row.go b/internal/ship/contract_row.go index 5449e58..f980e90 100644 --- a/internal/ship/contract_row.go +++ b/internal/ship/contract_row.go @@ -1,6 +1,9 @@ package ship import ( + "bytes" + + "github.com/eosswedenorg/thalos/internal/abi" "github.com/mitchellh/mapstructure" "github.com/shufflingpixels/antelope-go/chain" ) @@ -19,3 +22,16 @@ func ParseContractRow(v map[string]interface{}) (*ContractRow, error) { err := mapstructure.WeakDecode(v, out) return out, err } + +func DecodeContractRow(manager *abi.AbiManager, data map[string]any) (any, error) { + row, err := ParseContractRow(data) + if err != nil { + return nil, err + } + + abi, err := manager.GetAbi(row.Code) + if err != nil { + return nil, err + } + return abi.DecodeTable(bytes.NewReader(row.Value), row.Table) +}