From 4b2ff01a55d22e7b77324fd3bb23c9e8be6cd02c Mon Sep 17 00:00:00 2001 From: Shrenuj Bansal Date: Fri, 16 Dec 2022 13:03:27 -0500 Subject: [PATCH] make gen and lint --- cli/eth.go | 13 ++++++++-- documentation/en/cli-lotus.md | 46 +++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/cli/eth.go b/cli/eth.go index b75d9fa73..4f42fbbf9 100644 --- a/cli/eth.go +++ b/cli/eth.go @@ -4,12 +4,15 @@ import ( "context" "encoding/hex" "fmt" + + "github.com/urfave/cli/v2" + "golang.org/x/xerrors" + "github.com/filecoin-project/go-address" + "github.com/filecoin-project/lotus/api/v0api" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types/ethtypes" - "github.com/urfave/cli/v2" - "golang.org/x/xerrors" ) var EthCmd = &cli.Command{ @@ -28,6 +31,9 @@ func ethAddrFromFilecoinAddress(ctx context.Context, addr address.Address, fnapi switch addr.Protocol() { case address.BLS, address.SECP256K1: faddr, err = fnapi.StateLookupID(ctx, addr, types.EmptyTSK) + if err != nil { + return ethtypes.EthAddress{}, addr, err + } case address.Actor, address.ID: f0addr, err := fnapi.StateLookupID(ctx, addr, types.EmptyTSK) if err != nil { @@ -91,6 +97,9 @@ var EthGetAddressCmd = &cli.Command{ return err } eaddr, faddr, err = ethAddrFromFilecoinAddress(ctx, addr, api) + if err != nil { + return err + } } else if ethaddr != "" { addr, err := hex.DecodeString(ethaddr) if err != nil { diff --git a/documentation/en/cli-lotus.md b/documentation/en/cli-lotus.md index 35bc11760..04297433b 100644 --- a/documentation/en/cli-lotus.md +++ b/documentation/en/cli-lotus.md @@ -31,6 +31,7 @@ COMMANDS: log Manage logging wait-api Wait for lotus api to come online fetch-params Fetch proving parameters + eth Query eth contract state NETWORK: net Manage P2P Network sync Inspect or interact with the chain syncer @@ -2569,6 +2570,51 @@ OPTIONS: ``` +## lotus eth +``` +NAME: + lotus eth - Query eth contract state + +USAGE: + lotus eth command [command options] [arguments...] + +COMMANDS: + stat Print eth/filecoin addrs and code cid + call Simulate an eth contract call + help, h Shows a list of commands or help for one command + +OPTIONS: + --help, -h show help (default: false) + +``` + +### lotus eth stat +``` +NAME: + lotus eth stat - Print eth/filecoin addrs and code cid + +USAGE: + lotus eth stat [command options] [faddr] + +OPTIONS: + --ethaddr value Ethereum address + --filaddr value Filecoin address + +``` + +### lotus eth call +``` +NAME: + lotus eth call - Simulate an eth contract call + +USAGE: + lotus eth call [command options] [from] [to] [params] + +OPTIONS: + --help, -h show help (default: false) + +``` + ## lotus net ``` NAME: