From 98e762348006d02c07fe873f91c9363ab56325ac Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Fri, 21 Oct 2022 09:43:58 -0700 Subject: [PATCH] fix: evm: decode params/return in cli (#9536) --- cli/chain.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/cli/chain.go b/cli/chain.go index 8efd009ef..837f2346f 100644 --- a/cli/chain.go +++ b/cli/chain.go @@ -1681,6 +1681,12 @@ var ChainInvokeEVMCmd = &cli.Command{ return xerrors.Errorf("failed to serialize evm actor invoke params: %w", err) } + var buffer bytes.Buffer + if err := cbg.WriteByteArray(&buffer, params); err != nil { + return xerrors.Errorf("failed to encode evm params as cbor: %w", err) + } + params = buffer.Bytes() + var fromAddr address.Address if from := cctx.String("from"); from == "" { defaddr, err := api.WalletDefaultAddress(ctx) @@ -1723,9 +1729,14 @@ var ChainInvokeEVMCmd = &cli.Command{ return xerrors.Errorf("actor execution failed") } - if len(wait.Receipt.Return) > 0 { - result := hex.EncodeToString(wait.Receipt.Return) - afmt.Println(result) + afmt.Println("Gas used: ", wait.Receipt.GasUsed) + result, err := cbg.ReadByteArray(bytes.NewBuffer(wait.Receipt.Return), uint64(len(wait.Receipt.Return))) + if err != nil { + return xerrors.Errorf("evm result not correctly encoded: %w", err) + } + + if len(result) > 0 { + afmt.Println(hex.EncodeToString(result)) } else { afmt.Println("OK") }