Skip to content

Commit

Permalink
Merge pull request #1 from HaoyangLiu/kaifei/develop
Browse files Browse the repository at this point in the history
Add InitBech32Prefix function
  • Loading branch information
kaifei Hu authored Nov 19, 2018
2 parents eb0f847 + f492aed commit c476e61
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 38 deletions.
11 changes: 2 additions & 9 deletions cmd/iris/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@ import (
"encoding/json"
"io"

"github.com/spf13/cobra"

"github.com/cosmos/cosmos-sdk/server"
"github.com/irisnet/irishub/app"
bam "github.com/irisnet/irishub/baseapp"
"github.com/irisnet/irishub/client"

sdk "github.com/cosmos/cosmos-sdk/types"
irisInit "github.com/irisnet/irishub/init"
"github.com/irisnet/irishub/version"
"github.com/spf13/cobra"
"github.com/spf13/viper"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/cli"
Expand All @@ -24,11 +21,7 @@ import (

func main() {

config := sdk.GetConfig()
config.SetBech32PrefixForAccount(irisInit.Bech32PrefixAccAddr, irisInit.Bech32PrefixAccPub)
config.SetBech32PrefixForValidator(irisInit.Bech32PrefixValAddr, irisInit.Bech32PrefixValPub)
config.SetBech32PrefixForConsensusNode(irisInit.Bech32PrefixConsAddr, irisInit.Bech32PrefixConsPub)
config.Seal()
irisInit.InitBech32Prefix()

cdc := app.MakeCodec()
ctx := server.NewDefaultContext()
Expand Down
9 changes: 2 additions & 7 deletions cmd/iriscli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@ import (
"os"
"path"

sdk "github.com/cosmos/cosmos-sdk/types"
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
"github.com/irisnet/irishub/app"
"github.com/irisnet/irishub/client"
bankcmd "github.com/irisnet/irishub/client/bank/cli"
distributioncmd "github.com/irisnet/irishub/client/distribution/cli"
govcmd "github.com/irisnet/irishub/client/gov/cli"
servicecmd "github.com/irisnet/irishub/client/service/cli"
keyscmd "github.com/irisnet/irishub/client/keys/cli"
recordcmd "github.com/irisnet/irishub/client/record/cli"
servicecmd "github.com/irisnet/irishub/client/service/cli"
slashingcmd "github.com/irisnet/irishub/client/slashing/cli"
stakecmd "github.com/irisnet/irishub/client/stake/cli"
tendermintrpccmd "github.com/irisnet/irishub/client/tendermint/rpc"
Expand All @@ -36,11 +35,7 @@ var (

func main() {

config := sdk.GetConfig()
config.SetBech32PrefixForAccount(irisInit.Bech32PrefixAccAddr, irisInit.Bech32PrefixAccPub)
config.SetBech32PrefixForValidator(irisInit.Bech32PrefixValAddr, irisInit.Bech32PrefixValPub)
config.SetBech32PrefixForConsensusNode(irisInit.Bech32PrefixConsAddr, irisInit.Bech32PrefixConsPub)
config.Seal()
irisInit.InitBech32Prefix()

cobra.EnableCommandSorting = false
cdc := app.MakeCodec()
Expand Down
7 changes: 2 additions & 5 deletions cmd/irisdebug/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@ import (
)

func init() {
config := sdk.GetConfig()
config.SetBech32PrefixForAccount(irisInit.Bech32PrefixAccAddr, irisInit.Bech32PrefixAccPub)
config.SetBech32PrefixForValidator(irisInit.Bech32PrefixValAddr, irisInit.Bech32PrefixValPub)
config.SetBech32PrefixForConsensusNode(irisInit.Bech32PrefixConsAddr, irisInit.Bech32PrefixConsPub)
config.Seal()

irisInit.InitBech32Prefix()

rootCmd.AddCommand(txCmd)
rootCmd.AddCommand(pubkeyCmd)
Expand Down
7 changes: 1 addition & 6 deletions cmd/irislcd/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/irisnet/irishub/app"
"github.com/irisnet/irishub/client/lcd"
_ "github.com/irisnet/irishub/client/lcd/statik"
Expand All @@ -21,11 +20,7 @@ var (

func main() {

config := sdk.GetConfig()
config.SetBech32PrefixForAccount(irisInit.Bech32PrefixAccAddr, irisInit.Bech32PrefixAccPub)
config.SetBech32PrefixForValidator(irisInit.Bech32PrefixValAddr, irisInit.Bech32PrefixValPub)
config.SetBech32PrefixForConsensusNode(irisInit.Bech32PrefixConsAddr, irisInit.Bech32PrefixConsPub)
config.Seal()
irisInit.InitBech32Prefix()

cobra.EnableCommandSorting = false
cdc := app.MakeCodec()
Expand Down
14 changes: 4 additions & 10 deletions cmd/irismon/main.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package main

import (
"os"

"github.com/irisnet/irishub/app"
irisInit "github.com/irisnet/irishub/init"
"github.com/irisnet/irishub/tools/prometheus"
"github.com/spf13/cobra"
"github.com/tendermint/tendermint/libs/cli"
"os"

sdk "github.com/cosmos/cosmos-sdk/types"
irisInit "github.com/irisnet/irishub/init"
)

func init() {
Expand All @@ -21,12 +20,7 @@ func init() {
var rootCmd *cobra.Command

func main() {
config := sdk.GetConfig()
config.SetBech32PrefixForAccount(irisInit.Bech32PrefixAccAddr, irisInit.Bech32PrefixAccPub)
config.SetBech32PrefixForValidator(irisInit.Bech32PrefixValAddr, irisInit.Bech32PrefixValPub)
config.SetBech32PrefixForConsensusNode(irisInit.Bech32PrefixConsAddr, irisInit.Bech32PrefixConsPub)
config.Seal()

irisInit.InitBech32Prefix()
executor := cli.PrepareMainCmd(rootCmd, "IRIS", app.DefaultNodeHome)
err := executor.Execute()
if err != nil {
Expand Down
14 changes: 13 additions & 1 deletion init/prefix.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package init

import (
sdk "github.com/cosmos/cosmos-sdk/types"
)

const (
// Bech32PrefixAccAddr defines the Bech32 prefix of an account's address
Bech32PrefixAccAddr = "faa"
Expand All @@ -13,4 +17,12 @@ const (
Bech32PrefixConsAddr = "fca"
// Bech32PrefixConsPub defines the Bech32 prefix of a consensus node public key
Bech32PrefixConsPub = "fcp"
)
)

func InitBech32Prefix() {
config := sdk.GetConfig()
config.SetBech32PrefixForAccount(Bech32PrefixAccAddr, Bech32PrefixAccPub)
config.SetBech32PrefixForValidator(Bech32PrefixValAddr, Bech32PrefixValPub)
config.SetBech32PrefixForConsensusNode(Bech32PrefixConsAddr, Bech32PrefixConsPub)
config.Seal()
}

0 comments on commit c476e61

Please sign in to comment.