Skip to content

Commit

Permalink
update command line name
Browse files Browse the repository at this point in the history
  • Loading branch information
Honglei-Cong committed Nov 28, 2019
1 parent 1c83e82 commit 6274adf
Show file tree
Hide file tree
Showing 22 changed files with 134 additions and 230 deletions.
6 changes: 3 additions & 3 deletions cmd/account_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var (
Usage: "Manage accounts",
ArgsUsage: "[arguments...]",
Description: `Wallet management commands can be used to add, view, modify, delete, import account, and so on.
You can use ./Ontology account --help command to view help information of wallet management command.`,
You can use ./DNA account --help command to view help information of wallet management command.`,
Subcommands: []cli.Command{
{
Action: accountCreate,
Expand All @@ -61,8 +61,8 @@ You can use ./Ontology account --help command to view help information of wallet
utils.WalletFileFlag,
},
Description: ` Add a new account to wallet.
Ontology support three type of key: ecdsa, sm2 and ed25519, and support 224、256、384、521 bits length of key in ecdsa, but only support 256 bits length of key in sm2 and ed25519.
Ontology support multiple signature scheme.
DNA support three type of key: ecdsa, sm2 and ed25519, and support 224、256、384、521 bits length of key in ecdsa, but only support 256 bits length of key in sm2 and ed25519.
DNA support multiple signature scheme.
For ECDSA support SHA224withECDSA、SHA256withECDSA、SHA384withECDSA、SHA512withEdDSA、SHA3-224withECDSA、SHA3-256withECDSA、SHA3-384withECDSA、SHA3-512withECDSA、RIPEMD160withECDSA;
For SM2 support SM3withSM2, and for SHA512withEdDSA.
-------------------------------------------------
Expand Down
118 changes: 6 additions & 112 deletions cmd/asset_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ package cmd

import (
"fmt"
"strconv"
"strings"

"github.com/DNAProject/DNA/account"
cmdcom "github.com/DNAProject/DNA/cmd/common"
"github.com/DNAProject/DNA/cmd/utils"
"github.com/DNAProject/DNA/common/config"
nutils "github.com/DNAProject/DNA/smartcontract/service/native/utils"
"github.com/urfave/cli"
"strconv"
"strings"
)

var AssetCommand = cli.Command{
Expand Down Expand Up @@ -112,28 +112,6 @@ var AssetCommand = cli.Command{
utils.WalletFileFlag,
},
},
{
Action: unboundOng,
Name: "unboundong",
Usage: "Show the balance of unbound ONG",
ArgsUsage: "<address|label|index>",
Flags: []cli.Flag{
utils.RPCPortFlag,
utils.WalletFileFlag,
},
},
{
Action: withdrawOng,
Name: "withdrawong",
Usage: "Withdraw ONG",
ArgsUsage: "<address|label|index>",
Flags: []cli.Flag{
utils.RPCPortFlag,
utils.TransactionGasPriceFlag,
utils.TransactionGasLimitFlag,
utils.WalletFileFlag,
},
},
},
}

Expand Down Expand Up @@ -220,7 +198,7 @@ func transfer(ctx *cli.Context) error {
PrintInfoMsg(" Amount:%s", amountStr)
PrintInfoMsg(" TxHash:%s", txHash)
PrintInfoMsg("\nTip:")
PrintInfoMsg(" Using './ontology info status %s' to query transaction status.", txHash)
PrintInfoMsg(" Using './DNA info status %s' to query transaction status.", txHash)
return nil
}

Expand Down Expand Up @@ -362,7 +340,7 @@ func approve(ctx *cli.Context) error {
PrintInfoMsg(" Amount:%s", amountStr)
PrintInfoMsg(" TxHash:%s", txHash)
PrintInfoMsg("\nTip:")
PrintInfoMsg(" Using './ontology info status %s' to query transaction status.", txHash)
PrintInfoMsg(" Using './DNA info status %s' to query transaction status.", txHash)
return nil
}

Expand Down Expand Up @@ -460,90 +438,6 @@ func transferFrom(ctx *cli.Context) error {
PrintInfoMsg(" Amount:%s", amountStr)
PrintInfoMsg(" TxHash:%s", txHash)
PrintInfoMsg("\nTip:")
PrintInfoMsg(" Using './ontology info status %s' to query transaction status.", txHash)
return nil
}

func unboundOng(ctx *cli.Context) error {
SetRpcPort(ctx)
if ctx.NArg() < 1 {
PrintErrorMsg("Missing account argument.")
cli.ShowSubcommandHelp(ctx)
return nil
}
addrArg := ctx.Args().First()
accAddr, err := cmdcom.ParseAddress(addrArg, ctx)
if err != nil {
return err
}
fromAddr := nutils.OntContractAddress.ToBase58()
balanceStr, err := utils.GetAllowance("ong", fromAddr, accAddr)
if err != nil {
return err
}
balance, err := strconv.ParseUint(balanceStr, 10, 64)
if err != nil {
return err
}
balanceStr = utils.FormatOng(balance)
PrintInfoMsg("Unbound ONG:")
PrintInfoMsg(" Account:%s", accAddr)
PrintInfoMsg(" ONG:%s", balanceStr)
return nil
}

func withdrawOng(ctx *cli.Context) error {
SetRpcPort(ctx)
if ctx.NArg() < 1 {
PrintErrorMsg("Missing account argument.")
cli.ShowSubcommandHelp(ctx)
return nil
}
addrArg := ctx.Args().First()
accAddr, err := cmdcom.ParseAddress(addrArg, ctx)
if err != nil {
return err
}
fromAddr := nutils.OntContractAddress.ToBase58()
balance, err := utils.GetAllowance("ong", fromAddr, accAddr)
if err != nil {
return err
}

amount, err := strconv.ParseUint(balance, 10, 64)
if err != nil {
return err
}
if amount <= 0 {
return fmt.Errorf("haven't unbound ong\n")
}

var signer *account.Account
signer, err = cmdcom.GetAccount(ctx, accAddr)
if err != nil {
return err
}

gasPrice := ctx.Uint64(utils.TransactionGasPriceFlag.Name)
gasLimit := ctx.Uint64(utils.TransactionGasLimitFlag.Name)
networkId, err := utils.GetNetworkId()
if err != nil {
return err
}
if networkId == config.NETWORK_ID_SOLO_NET {
gasPrice = 0
}

txHash, err := utils.TransferFrom(gasPrice, gasLimit, signer, "ong", accAddr, fromAddr, accAddr, amount)
if err != nil {
return err
}

PrintInfoMsg("Withdraw ONG:")
PrintInfoMsg(" Account:%s", accAddr)
PrintInfoMsg(" Amount:%s", utils.FormatOng(amount))
PrintInfoMsg(" TxHash:%s", txHash)
PrintInfoMsg("\nTip:")
PrintInfoMsg(" Using './ontology info status %s' to query transaction status.", txHash)
PrintInfoMsg(" Using './DNA info status %s' to query transaction status.", txHash)
return nil
}
5 changes: 3 additions & 2 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ package cmd

import (
"fmt"

"github.com/DNAProject/DNA/cmd/utils"
"github.com/DNAProject/DNA/common"
"github.com/DNAProject/DNA/common/config"
Expand All @@ -31,7 +32,7 @@ import (
"github.com/urfave/cli"
)

func SetOntologyConfig(ctx *cli.Context) (*config.OntologyConfig, error) {
func SetBlockchainConfig(ctx *cli.Context) (*config.BlockchainConfig, error) {
cfg := config.DefConfig
err := setGenesis(ctx, cfg)
if err != nil {
Expand Down Expand Up @@ -67,7 +68,7 @@ func SetOntologyConfig(ctx *cli.Context) (*config.OntologyConfig, error) {
return cfg, nil
}

func setGenesis(ctx *cli.Context, cfg *config.OntologyConfig) error {
func setGenesis(ctx *cli.Context, cfg *config.BlockchainConfig) error {
netWorkId := ctx.Int(utils.GetFlagName(utils.NetworkIdFlag))
switch netWorkId {
case config.NETWORK_ID_MAIN_NET:
Expand Down
10 changes: 5 additions & 5 deletions cmd/contract_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var (
{
Action: deployContract,
Name: "deploy",
Usage: "Deploy a smart contract to ontology",
Usage: "Deploy a smart contract to blockchain",
ArgsUsage: " ",
Flags: []cli.Flag{
utils.RPCPortFlag,
Expand All @@ -69,7 +69,7 @@ var (
Action: invokeContract,
Name: "invoke",
Usage: "Invoke smart contract",
ArgsUsage: `Ontology contract support bytearray(need encode to hex string), string, integer, boolean parameter type.
ArgsUsage: `Smart contract supports bytearray(need encode to hex string), string, integer, boolean parameter type.
Parameter
Contract parameters separate with comma ',' to split params. and must add type prefix to params.
Expand Down Expand Up @@ -189,7 +189,7 @@ func deployContract(ctx *cli.Context) error {
PrintInfoMsg(" Contract Address:%s", address.ToHexString())
PrintInfoMsg(" TxHash:%s", txHash)
PrintInfoMsg("\nTip:")
PrintInfoMsg(" Using './ontology info status %s' to query transaction status.", txHash)
PrintInfoMsg(" Using './DNA info status %s' to query transaction status.", txHash)
return nil
}

Expand Down Expand Up @@ -281,7 +281,7 @@ func invokeCodeContract(ctx *cli.Context) error {

PrintInfoMsg("TxHash:%s", txHash)
PrintInfoMsg("\nTip:")
PrintInfoMsg(" Using './ontology info status %s' to query transaction status.", txHash)
PrintInfoMsg(" Using './DNA info status %s' to query transaction status.", txHash)
return nil
}

Expand Down Expand Up @@ -380,6 +380,6 @@ func invokeContract(ctx *cli.Context) error {

PrintInfoMsg(" TxHash:%s", txHash)
PrintInfoMsg("\nTips:")
PrintInfoMsg(" Using './ontology info status %s' to query transaction status.", txHash)
PrintInfoMsg(" Using './DNA info status %s' to query transaction status.", txHash)
return nil
}
4 changes: 2 additions & 2 deletions cmd/import_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ var ImportCommand = cli.Command{
func importBlocks(ctx *cli.Context) error {
log.InitLog(log.InfoLog)

cfg, err := SetOntologyConfig(ctx)
cfg, err := SetBlockchainConfig(ctx)
if err != nil {
PrintErrorMsg("SetOntologyConfig error:%s", err)
PrintErrorMsg("SetBlockchainConfig error:%s", err)
cli.ShowSubcommandHelp(ctx)
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/info_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ var InfoCommand = cli.Command{
},
},
Description: `Query information command can query information such as blocks, transactions, and transaction executions.
You can use the ./Ontology info block --help command to view help information.`,
You can use the ./DNA info block --help command to view help information.`,
}

var ShowTxCommand = cli.Command{
Expand Down
4 changes: 2 additions & 2 deletions cmd/sig_tx_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func multiSigToTx(ctx *cli.Context) error {
PrintInfoMsg("Send transaction success.")
PrintInfoMsg(" TxHash:%s", txHash)
PrintInfoMsg("\nTip:")
PrintInfoMsg(" Using './ontology info status %s' to query transaction status.", txHash)
PrintInfoMsg(" Using './DNA info status %s' to query transaction status.", txHash)
}
return nil
}
Expand Down Expand Up @@ -292,7 +292,7 @@ func sigToTx(ctx *cli.Context) error {
PrintInfoMsg("Send transaction success.")
PrintInfoMsg(" TxHash:%s", txHash)
PrintInfoMsg("\nTip:")
PrintInfoMsg(" Using './ontology info status %s' to query transaction status.", txHash)
PrintInfoMsg(" Using './DNA info status %s' to query transaction status.", txHash)
}
return nil
}
6 changes: 3 additions & 3 deletions cmd/tx_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ import (

var SendTxCommand = cli.Command{
Name: "sendtx",
Usage: "Send raw transaction to Ontology",
Description: "Send raw transaction to Ontology.",
Usage: "Send raw transaction to blockchain",
Description: "Send raw transaction to blockchain.",
ArgsUsage: "<rawtx>",
Action: sendTx,
Flags: []cli.Flag{
Expand Down Expand Up @@ -74,7 +74,7 @@ func sendTx(ctx *cli.Context) error {
PrintInfoMsg("Send transaction success.")
PrintInfoMsg(" TxHash:%s", txHash)
PrintInfoMsg("\nTip:")
PrintInfoMsg(" Using './ontology info status %s' to query transaction status.", txHash)
PrintInfoMsg(" Using './DNA info status %s' to query transaction status.", txHash)
return nil
}

Expand Down
9 changes: 5 additions & 4 deletions cmd/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,21 @@ import (
"encoding/json"
"flag"
"fmt"
"github.com/DNAProject/DNA/cmd/utils"
"github.com/urfave/cli"
"io"
"sort"
"strings"
"text/template"

"github.com/DNAProject/DNA/cmd/utils"
"github.com/urfave/cli"
)

// AppHelpTemplate is the test template for the default, global app help topic.
var (
AppHelpTemplate = `NAME:
{{.App.Name}} - {{.App.Usage}}
Ontology CLI is an Ontology node command line Client for starting and managing Ontology nodes,
Blockchain CLI is an blockchain node command line Client for starting and managing blockchain nodes,
managing user wallets, sending transactions, deploying and invoking contract, and so on.
USAGE:
Expand Down Expand Up @@ -98,7 +99,7 @@ type flagGroup struct {

var AppHelpFlagGroups = []flagGroup{
{
Name: "ONTOLOGY",
Name: "BLOCKCHAIN",
Flags: []cli.Flag{
utils.ConfigFlag,
utils.LogLevelFlag,
Expand Down
10 changes: 5 additions & 5 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const (
)

var (
//Ontology setting
//Blockchain setting
ConfigFlag = cli.StringFlag{
Name: "config",
Usage: "Genesis block config `<file>`. If doesn't specifies, use main net config as default.",
Expand Down Expand Up @@ -120,7 +120,7 @@ var (
}
NetworkIdFlag = cli.UintFlag{
Name: "networkid",
Usage: "Network id `<number>`. 1=ontology main net, 2=polaris test net, 3=testmode, and other for custom network",
Usage: "Network id `<number>`",
Value: config.NETWORK_ID_MAIN_NET,
}
NodePortFlag = cli.UintFlag{
Expand Down Expand Up @@ -199,11 +199,11 @@ var (
AccountPassFlag = cli.StringFlag{
Name: "password,p",
Hidden: true,
Usage: "Account `<password>` when Ontology node starts.",
Usage: "Account `<password>` when blockchain node starts.",
}
AccountAddressFlag = cli.StringFlag{
Name: "account,a",
Usage: "Account `<address>` when the Ontology node starts. If not specific, using default account instead",
Usage: "Account `<address>` when the blockchain node starts. If not specific, using default account instead",
}
AccountDefaultFlag = cli.BoolFlag{
Name: "default,d",
Expand Down Expand Up @@ -401,7 +401,7 @@ var (
}
SendTxFlag = cli.BoolFlag{
Name: "send,s",
Usage: "Send raw transaction to Ontology",
Usage: "Send raw transaction to blockchain",
}
ForceSendTxFlag = cli.BoolFlag{
Name: "force,f",
Expand Down
2 changes: 1 addition & 1 deletion cmd/utils/ont.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ func Sign(data []byte, signer *account.Account) ([]byte, error) {
return sigData, nil
}

//SendRawTransaction send a transaction to ontology network, and return hash of the transaction
// SendRawTransaction send a transaction to blockchain network, and return hash of the transaction
func SendRawTransaction(tx *types.Transaction) (string, error) {
txData := hex.EncodeToString(common.SerializeToBytes(tx))
return SendRawTransactionData(txData)
Expand Down
Loading

0 comments on commit 6274adf

Please sign in to comment.