make gen and lint

This commit is contained in:
Shrenuj Bansal 2022-12-16 13:03:27 -05:00
parent d71f5a7d12
commit 4b2ff01a55
2 changed files with 57 additions and 2 deletions

View File

@ -4,12 +4,15 @@ import (
"context" "context"
"encoding/hex" "encoding/hex"
"fmt" "fmt"
"github.com/urfave/cli/v2"
"golang.org/x/xerrors"
"github.com/filecoin-project/go-address" "github.com/filecoin-project/go-address"
"github.com/filecoin-project/lotus/api/v0api" "github.com/filecoin-project/lotus/api/v0api"
"github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/lotus/chain/types"
"github.com/filecoin-project/lotus/chain/types/ethtypes" "github.com/filecoin-project/lotus/chain/types/ethtypes"
"github.com/urfave/cli/v2"
"golang.org/x/xerrors"
) )
var EthCmd = &cli.Command{ var EthCmd = &cli.Command{
@ -28,6 +31,9 @@ func ethAddrFromFilecoinAddress(ctx context.Context, addr address.Address, fnapi
switch addr.Protocol() { switch addr.Protocol() {
case address.BLS, address.SECP256K1: case address.BLS, address.SECP256K1:
faddr, err = fnapi.StateLookupID(ctx, addr, types.EmptyTSK) faddr, err = fnapi.StateLookupID(ctx, addr, types.EmptyTSK)
if err != nil {
return ethtypes.EthAddress{}, addr, err
}
case address.Actor, address.ID: case address.Actor, address.ID:
f0addr, err := fnapi.StateLookupID(ctx, addr, types.EmptyTSK) f0addr, err := fnapi.StateLookupID(ctx, addr, types.EmptyTSK)
if err != nil { if err != nil {
@ -91,6 +97,9 @@ var EthGetAddressCmd = &cli.Command{
return err return err
} }
eaddr, faddr, err = ethAddrFromFilecoinAddress(ctx, addr, api) eaddr, faddr, err = ethAddrFromFilecoinAddress(ctx, addr, api)
if err != nil {
return err
}
} else if ethaddr != "" { } else if ethaddr != "" {
addr, err := hex.DecodeString(ethaddr) addr, err := hex.DecodeString(ethaddr)
if err != nil { if err != nil {

View File

@ -31,6 +31,7 @@ COMMANDS:
log Manage logging log Manage logging
wait-api Wait for lotus api to come online wait-api Wait for lotus api to come online
fetch-params Fetch proving parameters fetch-params Fetch proving parameters
eth Query eth contract state
NETWORK: NETWORK:
net Manage P2P Network net Manage P2P Network
sync Inspect or interact with the chain syncer 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 ## lotus net
``` ```
NAME: NAME: