Skip to content
This repository has been archived by the owner on May 9, 2024. It is now read-only.

Write cli I/O output data to file #119

Merged
merged 10 commits into from
Nov 3, 2021
5 changes: 5 additions & 0 deletions chains/evm/cli/account/generate-key-pair.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package account

import (
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/logger"
"github.com/ChainSafe/chainbridge-core/crypto/secp256k1"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
Expand All @@ -11,6 +12,10 @@ var generateKeyPairCmd = &cobra.Command{
Short: "Generate bridge keystore (Secp256k1)",
Long: "The generate subcommand is used to generate the bridge keystore. If no options are specified, a Secp256k1 key will be made.",
RunE: generateKeyPair,
PreRun: func(cmd *cobra.Command, args []string) {
confirmTransfer(cmd, args)
nmlinaric marked this conversation as resolved.
Show resolved Hide resolved
logger.LoggerMetadata(cmd.Name(), cmd.Flags())
},
}

func generateKeyPair(cmd *cobra.Command, args []string) error {
Expand Down
12 changes: 8 additions & 4 deletions chains/evm/cli/account/transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/ChainSafe/chainbridge-core/chains/evm/calls"
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/flags"
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/logger"
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/utils"
"github.com/ChainSafe/chainbridge-core/chains/evm/evmclient"
"github.com/ChainSafe/chainbridge-core/chains/evm/evmgaspricer"
Expand All @@ -19,10 +20,13 @@ import (
)

var transferBaseCurrencyCmd = &cobra.Command{
Use: "transfer",
Short: "Transfer base currency",
Long: "The generate subcommand is used to transfer the base currency",
PreRun: confirmTransfer,
Use: "transfer",
Short: "Transfer base currency",
Long: "The generate subcommand is used to transfer the base currency",
PreRun: func(cmd *cobra.Command, args []string) {
confirmTransfer(cmd, args)
logger.LoggerMetadata(cmd.Name(), cmd.Flags())
},
RunE: func(cmd *cobra.Command, args []string) error {
txFabric := evmtransaction.NewTransaction
return TransferBaseCurrency(cmd, args, txFabric, &evmgaspricer.LondonGasPriceDeterminant{})
Expand Down
6 changes: 5 additions & 1 deletion chains/evm/cli/admin/add-admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package admin

import (
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/flags"
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/logger"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
)
Expand All @@ -10,7 +11,10 @@ var addAdminCmd = &cobra.Command{
Use: "add-admin",
Short: "Add a new admin",
Long: "Add a new admin",
Run: addAdmin,
PreRun: func(cmd *cobra.Command, args []string) {
logger.LoggerMetadata(cmd.Name(), cmd.Flags())
},
Run: addAdmin,
}

func init() {
Expand Down
5 changes: 5 additions & 0 deletions chains/evm/cli/admin/add-relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import (

"github.com/ChainSafe/chainbridge-core/chains/evm/calls"
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/flags"
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/logger"
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/utils"
"github.com/ChainSafe/chainbridge-core/chains/evm/evmclient"
"github.com/ChainSafe/chainbridge-core/chains/evm/evmgaspricer"
"github.com/ChainSafe/chainbridge-core/chains/evm/evmtransaction"

"github.com/ethereum/go-ethereum/common"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
Expand All @@ -20,6 +22,9 @@ var addRelayerCmd = &cobra.Command{
Use: "add-relayer",
Short: "Add a new relayer",
Long: "Add a new relayer",
PreRun: func(cmd *cobra.Command, args []string) {
logger.LoggerMetadata(cmd.Name(), cmd.Flags())
},
RunE: func(cmd *cobra.Command, args []string) error {
return AddRelayerEVMCMD(cmd, args, evmtransaction.NewTransaction, &evmgaspricer.LondonGasPriceDeterminant{})
},
Expand Down
4 changes: 4 additions & 0 deletions chains/evm/cli/admin/is-relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/ChainSafe/chainbridge-core/chains/evm/calls"
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/flags"
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/logger"
"github.com/ChainSafe/chainbridge-core/chains/evm/evmclient"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
Expand All @@ -17,6 +18,9 @@ var isRelayerCmd = &cobra.Command{
Use: "is-relayer",
Short: "Check if an address is registered as a relayer",
Long: "Check if an address is registered as a relayer",
PreRun: func(cmd *cobra.Command, args []string) {
logger.LoggerMetadata(cmd.Name(), cmd.Flags())
},
RunE: func(cmd *cobra.Command, args []string) error {
return IsRelayer(cmd, args)
},
Expand Down
6 changes: 5 additions & 1 deletion chains/evm/cli/admin/pause.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package admin

import (
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/flags"
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/logger"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
)
Expand All @@ -10,7 +11,10 @@ var pauseCmd = &cobra.Command{
Use: "pause",
Short: "Pause deposits and proposals",
Long: "Pause deposits and proposals",
Run: pause,
PreRun: func(cmd *cobra.Command, args []string) {
logger.LoggerMetadata(cmd.Name(), cmd.Flags())
},
Run: pause,
}

func init() {
Expand Down
6 changes: 5 additions & 1 deletion chains/evm/cli/admin/remove-admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package admin

import (
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/flags"
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/logger"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
)
Expand All @@ -10,7 +11,10 @@ var removeAdminCmd = &cobra.Command{
Use: "remove-admin",
Short: "Remove an existing admin",
Long: "Remove an existing admin",
Run: removeAdmin,
PreRun: func(cmd *cobra.Command, args []string) {
logger.LoggerMetadata(cmd.Name(), cmd.Flags())
},
Run: removeAdmin,
}

func init() {
Expand Down
6 changes: 5 additions & 1 deletion chains/evm/cli/admin/remove-relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package admin

import (
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/flags"
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/logger"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
)
Expand All @@ -10,7 +11,10 @@ var removeRelayerCmd = &cobra.Command{
Use: "remove-relayer",
Short: "Remove a relayer",
Long: "Remove a relayer",
Run: removeRelayer,
PreRun: func(cmd *cobra.Command, args []string) {
logger.LoggerMetadata(cmd.Name(), cmd.Flags())
},
Run: removeRelayer,
}

func init() {
Expand Down
4 changes: 4 additions & 0 deletions chains/evm/cli/admin/set-deposit-nonce.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/ChainSafe/chainbridge-core/chains/evm/calls"
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/flags"
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/logger"
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/utils"
"github.com/ChainSafe/chainbridge-core/chains/evm/evmclient"
"github.com/ChainSafe/chainbridge-core/chains/evm/evmgaspricer"
Expand All @@ -21,6 +22,9 @@ var setDepositNonceCmd = &cobra.Command{
Long: `Set the deposit nonce

This nonce cannot be less than what is currently stored in the contract`,
PreRun: func(cmd *cobra.Command, args []string) {
logger.LoggerMetadata(cmd.Name(), cmd.Flags())
},
RunE: func(cmd *cobra.Command, args []string) error {
txFabric := evmtransaction.NewTransaction
return SetDepositNonceEVMCMD(cmd, args, txFabric, &evmgaspricer.LondonGasPriceDeterminant{})
Expand Down
6 changes: 5 additions & 1 deletion chains/evm/cli/admin/set-fee.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package admin

import (
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/flags"
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/logger"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
)
Expand All @@ -10,7 +11,10 @@ var setFeeCmd = &cobra.Command{
Use: "set-fee",
Short: "Set a new fee for deposits",
Long: "Set a new fee for deposits",
Run: setFee,
PreRun: func(cmd *cobra.Command, args []string) {
logger.LoggerMetadata(cmd.Name(), cmd.Flags())
},
Run: setFee,
}

func init() {
Expand Down
6 changes: 5 additions & 1 deletion chains/evm/cli/admin/set-threshold.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package admin

import (
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/flags"
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/logger"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
)
Expand All @@ -10,7 +11,10 @@ var setThresholdCmd = &cobra.Command{
Use: "set-threshold",
Short: "Set a new relayer vote threshold",
Long: "Set a new relayer vote threshold",
Run: setThreshold,
PreRun: func(cmd *cobra.Command, args []string) {
logger.LoggerMetadata(cmd.Name(), cmd.Flags())
},
Run: setThreshold,
}

func init() {
Expand Down
6 changes: 5 additions & 1 deletion chains/evm/cli/admin/unpause.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package admin

import (
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/flags"
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/logger"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
)
Expand All @@ -10,7 +11,10 @@ var unpauseCmd = &cobra.Command{
Use: "unpause",
Short: "Unpause deposits and proposals",
Long: "Unpause deposits and proposals",
Run: unpause,
PreRun: func(cmd *cobra.Command, args []string) {
logger.LoggerMetadata(cmd.Name(), cmd.Flags())
},
Run: unpause,
}

func init() {
Expand Down
6 changes: 5 additions & 1 deletion chains/evm/cli/admin/withdraw.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package admin

import (
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/flags"
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/logger"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
)
Expand All @@ -10,7 +11,10 @@ var withdrawCmd = &cobra.Command{
Use: "withdraw",
Short: "Withdraw tokens from the handler contract",
Long: "Withdraw tokens from the handler contract",
Run: withdraw,
PreRun: func(cmd *cobra.Command, args []string) {
logger.LoggerMetadata(cmd.Name(), cmd.Flags())
},
Run: withdraw,
}

func init() {
Expand Down
6 changes: 5 additions & 1 deletion chains/evm/cli/bridge/cancel-proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package bridge

import (
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/flags"
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/logger"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
)
Expand All @@ -10,7 +11,10 @@ var cancelProposalCmd = &cobra.Command{
Use: "cancel-proposal",
Short: "Cancel an expired proposal",
Long: "Cancel an expired proposal",
Run: cancelProposal,
PreRun: func(cmd *cobra.Command, args []string) {
logger.LoggerMetadata(cmd.Name(), cmd.Flags())
},
Run: cancelProposal,
}

func init() {
Expand Down
6 changes: 5 additions & 1 deletion chains/evm/cli/bridge/query-proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package bridge

import (
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/flags"
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/logger"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
)
Expand All @@ -10,7 +11,10 @@ var queryProposalCmd = &cobra.Command{
Use: "query-proposal",
Short: "Query an inbound proposal",
Long: "Query an inbound proposal",
Run: queryProposal,
PreRun: func(cmd *cobra.Command, args []string) {
logger.LoggerMetadata(cmd.Name(), cmd.Flags())
},
Run: queryProposal,
}

func init() {
Expand Down
6 changes: 5 additions & 1 deletion chains/evm/cli/bridge/query-resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package bridge

import (
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/flags"
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/logger"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
)
Expand All @@ -10,7 +11,10 @@ var queryResourceCmd = &cobra.Command{
Use: "query-resource",
Short: "Query the contract address",
Long: "Query the contract address with the provided resource ID for a specific handler contract",
Run: queryResource,
PreRun: func(cmd *cobra.Command, args []string) {
logger.LoggerMetadata(cmd.Name(), cmd.Flags())
},
Run: queryResource,
}

func init() {
Expand Down
6 changes: 5 additions & 1 deletion chains/evm/cli/bridge/register-generic-resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package bridge

import (
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/flags"
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/logger"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
)
Expand All @@ -10,7 +11,10 @@ var registerGenericResourceCmd = &cobra.Command{
Use: "register-generic-resource",
Short: "Register a generic resource ID",
Long: "Register a resource ID with a contract address for a generic handler",
Run: registerGenericResource,
PreRun: func(cmd *cobra.Command, args []string) {
logger.LoggerMetadata(cmd.Name(), cmd.Flags())
},
Run: registerGenericResource,
}

func init() {
Expand Down
4 changes: 4 additions & 0 deletions chains/evm/cli/bridge/register-resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"math/big"

"github.com/ChainSafe/chainbridge-core/chains/evm/cli/logger"
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/utils"

"github.com/ChainSafe/chainbridge-core/chains/evm/calls"
Expand All @@ -20,6 +21,9 @@ var registerResourceCmd = &cobra.Command{
Use: "register-resource",
Short: "Register a resource ID",
Long: "Register a resource ID with a contract address for a handler",
PreRun: func(cmd *cobra.Command, args []string) {
logger.LoggerMetadata(cmd.Name(), cmd.Flags())
},
RunE: func(cmd *cobra.Command, args []string) error {
txFabric := evmtransaction.NewTransaction
return RegisterResourceCmd(cmd, args, txFabric, &evmgaspricer.LondonGasPriceDeterminant{})
Expand Down
4 changes: 4 additions & 0 deletions chains/evm/cli/bridge/set-burn.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"math/big"

"github.com/ChainSafe/chainbridge-core/chains/evm/cli/logger"
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/utils"

"github.com/ChainSafe/chainbridge-core/chains/evm/evmgaspricer"
Expand All @@ -21,6 +22,9 @@ var setBurnCmd = &cobra.Command{
Use: "set-burn",
Short: "Set a token contract as mintable/burnable",
Long: "Set a token contract as mintable/burnable in a handler",
PreRun: func(cmd *cobra.Command, args []string) {
logger.LoggerMetadata(cmd.Name(), cmd.Flags())
},
RunE: func(cmd *cobra.Command, args []string) error {
txFabric := evmtransaction.NewTransaction
return SetBurnCmd(cmd, args, txFabric, &evmgaspricer.LondonGasPriceDeterminant{})
Expand Down
Loading