From b1fd3d7f27f084ceb55aecf068810f6ace2a0e22 Mon Sep 17 00:00:00 2001 From: dylenfu Date: Fri, 16 Apr 2021 12:10:21 +0800 Subject: [PATCH] chaintool: env --- chain_tool/flag.go | 13 +++++++++++++ chain_tool/main.go | 26 ++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/chain_tool/flag.go b/chain_tool/flag.go index 26419f5a..dfcde305 100644 --- a/chain_tool/flag.go +++ b/chain_tool/flag.go @@ -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", @@ -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 diff --git a/chain_tool/main.go b/chain_tool/main.go index e9ad45b5..132d23f6 100644 --- a/chain_tool/main.go +++ b/chain_tool/main.go @@ -115,6 +115,7 @@ func setupApp() *cli.App { CmdTokenUrls, CmdNFTBalance, CmdParseLockParams, + CmdEnv, } app.Before = beforeCommands @@ -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)) {