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: