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

Commit

Permalink
Implement cli writer into all commands
Browse files Browse the repository at this point in the history
  • Loading branch information
nmlinaric committed Oct 18, 2021
1 parent 7ac53f3 commit 99f1966
Show file tree
Hide file tree
Showing 30 changed files with 63 additions and 112 deletions.
3 changes: 3 additions & 0 deletions chains/evm/cli/account/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,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/writer"
"github.com/ChainSafe/chainbridge-core/chains/evm/evmclient"
"github.com/ChainSafe/chainbridge-core/chains/evm/evmtransaction"
"github.com/ChainSafe/chainbridge-core/crypto/secp256k1"
Expand Down Expand Up @@ -73,6 +74,7 @@ func importPrivKey(cmd *cobra.Command, args []string) error {
return err
}
log.Debug().Msgf("filepath: %s", res)
writer.WriteCliDataToFile(cmd)
return nil
}

Expand All @@ -82,6 +84,7 @@ func generateKeyPair(cmd *cobra.Command, args []string) error {
return err
}
log.Debug().Msgf("Addr: %s, PrivKey %x", kp.CommonAddress().String(), kp.Encode())
writer.WriteCliDataToFile(cmd)
return nil
}

Expand Down
2 changes: 2 additions & 0 deletions chains/evm/cli/admin/add-admin.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package admin

import (
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/writer"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
)
Expand All @@ -24,6 +25,7 @@ func addAdmin(cmd *cobra.Command, args []string) {
Adding admin
Admin address: %s
Bridge address: %s`, adminAddress, bridgeAddress)
writer.WriteCliDataToFile(cmd)
}

/*
Expand Down
5 changes: 4 additions & 1 deletion chains/evm/cli/admin/add-relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ 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/writer"
"github.com/ChainSafe/chainbridge-core/chains/evm/evmclient"
"github.com/ChainSafe/chainbridge-core/chains/evm/evmtransaction"

"github.com/ethereum/go-ethereum/common"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -37,7 +39,7 @@ func AddRelayerEVMCMD(cmd *cobra.Command, args []string, txFabric calls.TxFabric
relayerAddress := cmd.Flag("relayer").Value.String()
bridgeAddress := cmd.Flag("bridge").Value.String()
log.Debug().Msgf(`
Adding relayer
Adding relayer
Relayer address: %s
Bridge address: %s`, relayerAddress, bridgeAddress)

Expand Down Expand Up @@ -77,5 +79,6 @@ Bridge address: %s`, relayerAddress, bridgeAddress)
log.Info().Msgf("%s added as relayer", relayerAddress)
return err
}
writer.WriteCliDataToFile(cmd)
return nil
}
5 changes: 3 additions & 2 deletions chains/evm/cli/admin/is-relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,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/writer"
"github.com/ChainSafe/chainbridge-core/chains/evm/evmclient"
"github.com/ChainSafe/chainbridge-core/chains/evm/evmtransaction"
"github.com/ethereum/go-ethereum"
Expand All @@ -19,7 +20,7 @@ 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",
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, args []string) error {
txFabric := evmtransaction.NewTransaction
return IsRelayer(cmd, args, txFabric)
},
Expand Down Expand Up @@ -103,6 +104,6 @@ func IsRelayer(cmd *cobra.Command, args []string, txFabric calls.TxFabric) error
} else {
log.Info().Msgf("Address %s is relayer", relayer.String())
}
writer.WriteCliDataToFile(cmd)
return nil
}

2 changes: 2 additions & 0 deletions chains/evm/cli/admin/pause.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package admin

import (
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/writer"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
)
Expand All @@ -21,6 +22,7 @@ func pause(cmd *cobra.Command, args []string) {
log.Debug().Msgf(`
Pausing
Bridge address: %s`, bridgeAddress)
writer.WriteCliDataToFile(cmd)
}

/*
Expand Down
2 changes: 2 additions & 0 deletions chains/evm/cli/admin/remove-admin.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package admin

import (
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/writer"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
)
Expand All @@ -24,6 +25,7 @@ func removeAdmin(cmd *cobra.Command, args []string) {
Removing admin
Admin address: %s
Bridge address: %s`, adminAddress, bridgeAddress)
writer.WriteCliDataToFile(cmd)
}

/*
Expand Down
4 changes: 3 additions & 1 deletion chains/evm/cli/admin/remove-relayer.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package admin

import (
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/writer"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
)
Expand All @@ -21,9 +22,10 @@ func removeRelayer(cmd *cobra.Command, args []string) {
relayerAddress := cmd.Flag("relayer").Value
bridgeAddress := cmd.Flag("bridge").Value
log.Debug().Msgf(`
Removing relayer
Removing relayer
Relayer address: %s
Bridge address: %s`, relayerAddress, bridgeAddress)
writer.WriteCliDataToFile(cmd)
}

/*
Expand Down
2 changes: 2 additions & 0 deletions chains/evm/cli/admin/set-deposit-nonce.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,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/writer"
"github.com/ChainSafe/chainbridge-core/chains/evm/evmclient"
"github.com/ChainSafe/chainbridge-core/chains/evm/evmtransaction"
"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -92,5 +93,6 @@ Bridge Address: %s`, domainId, depositNonce, bridgeAddress)
return err
}
log.Info().Msgf("[domain ID: %v] successfully set nonce: %v at address: %s", domainId, depositNonce, bridgeAddr.String())
writer.WriteCliDataToFile(cmd)
return nil
}
2 changes: 2 additions & 0 deletions chains/evm/cli/admin/set-fee.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package admin

import (
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/writer"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
)
Expand All @@ -24,6 +25,7 @@ func setFee(cmd *cobra.Command, args []string) {
Setting new fee
Fee amount: %s
Bridge address: %s`, feeAmount, bridgeAddress)
writer.WriteCliDataToFile(cmd)
}

/*
Expand Down
2 changes: 2 additions & 0 deletions chains/evm/cli/admin/set-threshold.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package admin

import (
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/writer"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
)
Expand All @@ -24,6 +25,7 @@ func setThreshold(cmd *cobra.Command, args []string) {
Setting new threshold
Threshold: %d
Bridge address: %s`, threshold, bridgeAddress)
writer.WriteCliDataToFile(cmd)
}

/*
Expand Down
2 changes: 2 additions & 0 deletions chains/evm/cli/admin/unpause.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package admin

import (
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/writer"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
)
Expand All @@ -21,6 +22,7 @@ func unpause(cmd *cobra.Command, args []string) {
log.Debug().Msgf(`
Unpausing
Bridge address: %s`, bridgeAddress)
writer.WriteCliDataToFile(cmd)
}

/*
Expand Down
2 changes: 2 additions & 0 deletions chains/evm/cli/admin/withdraw.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package admin

import (
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/writer"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -39,6 +40,7 @@ Handler: %s
Token: %s
Recipient: %s
Decimals: %v`, amount, id, bridgeAddress, handler, token, recipient, decimals)
writer.WriteCliDataToFile(cmd)
}

/*
Expand Down
2 changes: 2 additions & 0 deletions chains/evm/cli/bridge/cancel-proposal.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package bridge

import (
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/writer"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -30,6 +31,7 @@ Admin address: %s
Bridge address: %s
Chain ID: %d
Deposit nonce: %d`, adminAddress, bridgeAddress, domainId, depositNonce)
writer.WriteCliDataToFile(cmd)
}

/*
Expand Down
2 changes: 2 additions & 0 deletions chains/evm/cli/bridge/query-proposal.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package bridge

import (
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/writer"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -30,6 +31,7 @@ Chain ID: %d
Deposit nonce: %d
Data hash: %s
Bridge address: %s`, domainId, depositNonce, dataHash, bridgeAddress)
writer.WriteCliDataToFile(cmd)
}

/*
Expand Down
2 changes: 2 additions & 0 deletions chains/evm/cli/bridge/query-resource.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package bridge

import (
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/writer"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
)
Expand All @@ -24,6 +25,7 @@ func queryResource(cmd *cobra.Command, args []string) {
Querying resource
Handler address: %s
Resource ID: %s`, handlerAddress, resourceId)
writer.WriteCliDataToFile(cmd)
}

/*
Expand Down
2 changes: 2 additions & 0 deletions chains/evm/cli/bridge/register-generic-resource.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package bridge

import (
"github.com/ChainSafe/chainbridge-core/chains/evm/cli/writer"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -40,6 +41,7 @@ Deposit: %s
Execute: %s
Hash: %v
`, handlerAddress, resourceId, bridgeAddress, targetAddress, deposit, execute, hash)
writer.WriteCliDataToFile(cmd)
}

/*
Expand Down
2 changes: 2 additions & 0 deletions chains/evm/cli/bridge/register-resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,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/writer"
"github.com/ChainSafe/chainbridge-core/chains/evm/evmclient"
"github.com/ChainSafe/chainbridge-core/chains/evm/evmtransaction"
"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -98,5 +99,6 @@ Bridge address: %s
}

fmt.Println("Resource registered")
writer.WriteCliDataToFile(cmd)
return nil
}
2 changes: 2 additions & 0 deletions chains/evm/cli/bridge/set-burn.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,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/writer"
"github.com/ChainSafe/chainbridge-core/chains/evm/evmclient"
"github.com/ChainSafe/chainbridge-core/chains/evm/evmtransaction"
"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -79,5 +80,6 @@ func SetBurnCmd(cmd *cobra.Command, args []string, txFabric calls.TxFabric) erro
return err
}
log.Info().Msg("Burnable set")
writer.WriteCliDataToFile(cmd)
return nil
}
Loading

0 comments on commit 99f1966

Please sign in to comment.