fix: evm: decode params/return in cli (#9536)

This commit is contained in:
Steven Allen 2022-10-21 09:43:58 -07:00 committed by vyzo
parent 7f81780ffb
commit 98e7623480

View File

@ -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")
}