fix: evm: decode params/return in cli (#9536)
This commit is contained in:
parent
7f81780ffb
commit
98e7623480
17
cli/chain.go
17
cli/chain.go
@ -1681,6 +1681,12 @@ var ChainInvokeEVMCmd = &cli.Command{
|
|||||||
return xerrors.Errorf("failed to serialize evm actor invoke params: %w", err)
|
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
|
var fromAddr address.Address
|
||||||
if from := cctx.String("from"); from == "" {
|
if from := cctx.String("from"); from == "" {
|
||||||
defaddr, err := api.WalletDefaultAddress(ctx)
|
defaddr, err := api.WalletDefaultAddress(ctx)
|
||||||
@ -1723,9 +1729,14 @@ var ChainInvokeEVMCmd = &cli.Command{
|
|||||||
return xerrors.Errorf("actor execution failed")
|
return xerrors.Errorf("actor execution failed")
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(wait.Receipt.Return) > 0 {
|
afmt.Println("Gas used: ", wait.Receipt.GasUsed)
|
||||||
result := hex.EncodeToString(wait.Receipt.Return)
|
result, err := cbg.ReadByteArray(bytes.NewBuffer(wait.Receipt.Return), uint64(len(wait.Receipt.Return)))
|
||||||
afmt.Println(result)
|
if err != nil {
|
||||||
|
return xerrors.Errorf("evm result not correctly encoded: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(result) > 0 {
|
||||||
|
afmt.Println(hex.EncodeToString(result))
|
||||||
} else {
|
} else {
|
||||||
afmt.Println("OK")
|
afmt.Println("OK")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user