Skip to content

Commit

Permalink
Merge pull request #38 from dylenfu/master
Browse files Browse the repository at this point in the history
chaintool: env
  • Loading branch information
dylenfu authored Apr 16, 2021
2 parents 7eee8a9 + b1fd3d7 commit 27f53bd
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
13 changes: 13 additions & 0 deletions chain_tool/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ var (
Usage: "set dest asset for cross chain",
}

OwnerAccountFlag = cli.StringFlag{
Name: "owner",
Usage: "set `owner` account",
}
SrcAccountFlag = cli.StringFlag{
Name: "from",
Usage: "set `from` account, or approve `sender` account",
Expand Down Expand Up @@ -460,6 +464,15 @@ var (
MethodCodeFlag,
},
}

CmdEnv = cli.Command{
Name: "env",
Usage: "ensure your environment is correct",
Action: handleCmdEnv,
Flags: []cli.Flag{
OwnerAccountFlag,
},
}
)

//getFlagName deal with short flag, and return the flag name whether flag name have short name
Expand Down
26 changes: 26 additions & 0 deletions chain_tool/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ func setupApp() *cli.App {
CmdTokenUrls,
CmdNFTBalance,
CmdParseLockParams,
CmdEnv,
}

app.Before = beforeCommands
Expand Down Expand Up @@ -850,6 +851,31 @@ func handleCmdDecodeWrapLock(ctx *cli.Context) error {
return nil
}

func handleCmdEnv(ctx *cli.Context) error {
currentInfo := fmt.Sprintf("current env: side chain name %s, side chain id %d\r\n", cc.SideChainName, cc.SideChainID)

polyInfo := fmt.Sprintf("poly side chain id - %d\r\n", basedef.POLY_CROSSCHAIN_ID)
ethInfo := fmt.Sprintf("eth side chain id - %d\r\n", basedef.ETHEREUM_CROSSCHAIN_ID)
ontInfo := fmt.Sprintf("ont side chain id - %d\r\n", basedef.ONT_CROSSCHAIN_ID)
neoInfo := fmt.Sprintf("neo side chain id - %d\r\n", basedef.NEO_CROSSCHAIN_ID)
bscInfo := fmt.Sprintf("bsc side chain id - %d\r\n", basedef.BSC_CROSSCHAIN_ID)
hecoInfo := fmt.Sprintf("heco side chain id - %d\r\n", basedef.HECO_CROSSCHAIN_ID)
o3Info := fmt.Sprintf("o3 side chain id - %d\r\n", basedef.O3_CROSSCHAIN_ID)

log.Info(currentInfo, polyInfo, ethInfo, ontInfo, neoInfo, bscInfo, hecoInfo, o3Info)

owner := flag2address(ctx, OwnerAccountFlag)
addr := owner.Hex()
log.Info("check your owner address %s", addr)
_, err := wallet.LoadEthAccount(storage, cc.Keystore, addr, defaultAccPwd)
if err != nil {
return err
}
//enc := crypto.FromECDSA(key)
//log.Info(hex.EncodeToString(enc))
return nil
}

// getFeeTokenOrERC20Asset return feeToken if `feeToken` is true
//func getFeeTokenOrERC20Asset(ctx *cli.Context) common.Address {
// if ctx.Bool(getFlagName(NativeTokenFlag)) {
Expand Down

0 comments on commit 27f53bd

Please sign in to comment.