Skip to content

Commit

Permalink
Remove remnants of basecoin tx as ibc functions are now under relay
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanfrey committed Jun 16, 2017
1 parent cb075bb commit a57e2d3
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 278 deletions.
1 change: 0 additions & 1 deletion cmd/basecoin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ func main() {
commands.InitCmd,
commands.StartCmd,
commands.RelayCmd,
commands.TxCmd,
commands.UnsafeResetAllCmd,
commands.VersionCmd,
)
Expand Down
81 changes: 1 addition & 80 deletions cmd/commands/ibc.go
Original file line number Diff line number Diff line change
@@ -1,87 +1,8 @@
package commands

import (
"encoding/json"
"fmt"
"io/ioutil"

"github.com/pkg/errors"
"github.com/spf13/cobra"

"github.com/tendermint/basecoin/plugins/ibc"

"github.com/tendermint/go-wire"
)
import "github.com/tendermint/basecoin/plugins/ibc"

// returns a new IBC plugin to be registered with Basecoin
func NewIBCPlugin() *ibc.IBCPlugin {
return ibc.New()
}

//commands
var (
IBCTxCmd = &cobra.Command{
Use: "ibc",
Short: "An IBC transaction, for InterBlockchain Communication",
}

IBCRegisterTxCmd = &cobra.Command{
Use: "register",
Short: "Register a blockchain via IBC",
RunE: ibcRegisterTxCmd,
}
)

//flags
var (
ibcChainIDFlag string
ibcGenesisFlag string
)

func init() {
// register flags
registerFlags := []Flag2Register{
{&ibcChainIDFlag, "ibc_chain_id", "", "ChainID for the new blockchain"},
{&ibcGenesisFlag, "genesis", "", "Genesis file for the new blockchain"},
}

RegisterFlags(IBCRegisterTxCmd, registerFlags)

//register commands
IBCTxCmd.AddCommand(IBCRegisterTxCmd)
RegisterTxSubcommand(IBCTxCmd)
}

//---------------------------------------------------------------------
// ibc command implementations

func ibcRegisterTxCmd(cmd *cobra.Command, args []string) error {
chainID := ibcChainIDFlag
genesisFile := ibcGenesisFlag

genesisBytes, err := ioutil.ReadFile(genesisFile)
if err != nil {
return errors.Errorf("Error reading genesis file %v: %v\n", genesisFile, err)
}

ibcTx := ibc.IBCRegisterChainTx{
ibc.BlockchainGenesis{
ChainID: chainID,
Genesis: string(genesisBytes),
},
}

out, err := json.Marshal(ibcTx)
if err != nil {
return err
}

fmt.Printf("IBCTx: %s\n", string(out))

data := []byte(wire.BinaryBytes(struct {
ibc.IBCTx `json:"unwrap"`
}{ibcTx}))
name := "IBC"

return AppTx(name, data)
}
5 changes: 0 additions & 5 deletions cmd/commands/plugin_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ func RegisterStartPlugin(name string, newPlugin func() types.Plugin) {
plugins = append(plugins, plugin{name: name, newPlugin: newPlugin})
}

// Register a subcommand of TxCmd to craft transactions for plugins
func RegisterTxSubcommand(cmd *cobra.Command) {
TxCmd.AddCommand(cmd)
}

//Returns a version command based on version input
func QuickVersionCmd(version string) *cobra.Command {
return &cobra.Command{
Expand Down
2 changes: 1 addition & 1 deletion cmd/commands/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func loop(addr1, addr2, id1, id2 string) {
nextSeq := 0

// load the priv key
privKey, err := LoadKey(fromFlag)
privKey, err := LoadKey(fromFileFlag)
if err != nil {
logger.Error(err.Error())
cmn.PanicCrisis(err.Error())
Expand Down
142 changes: 0 additions & 142 deletions cmd/commands/tx.go

This file was deleted.

48 changes: 0 additions & 48 deletions cmd/counter/cmd.go
Original file line number Diff line number Diff line change
@@ -1,59 +1,11 @@
package main

import (
"encoding/json"
"fmt"

"github.com/spf13/cobra"
"github.com/spf13/viper"
wire "github.com/tendermint/go-wire"

"github.com/tendermint/basecoin/cmd/commands"
"github.com/tendermint/basecoin/plugins/counter"
"github.com/tendermint/basecoin/types"
)

//commands
var CounterTxCmd = &cobra.Command{
Use: "counter",
Short: "Create, sign, and broadcast a transaction to the counter plugin",
RunE: counterTxCmd,
}

const (
flagValid = "valid"
flagCountFee = "countfee"
)

func init() {

CounterTxCmd.Flags().Bool(flagValid, false, "Set valid field in CounterTx")
CounterTxCmd.Flags().String(flagCountFee, "", "Coins for the counter fee of the format <amt><coin>")

commands.RegisterTxSubcommand(CounterTxCmd)
commands.RegisterStartPlugin("counter", func() types.Plugin { return counter.New() })
}

func counterTxCmd(cmd *cobra.Command, args []string) error {

countFee, err := types.ParseCoins(viper.GetString(flagCountFee))
if err != nil {
return err
}

counterTx := counter.CounterTx{
Valid: viper.GetBool(flagValid),
Fee: countFee,
}

out, err := json.Marshal(counterTx)
if err != nil {
return err
}
fmt.Println("CounterTx:", string(out))

data := wire.BinaryBytes(counterTx)
name := "counter"

return commands.AppTx(name, data)
}
1 change: 0 additions & 1 deletion cmd/counter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ func main() {
RootCmd.AddCommand(
commands.InitCmd,
commands.StartCmd,
commands.TxCmd,
commands.UnsafeResetAllCmd,
commands.VersionCmd,
)
Expand Down

0 comments on commit a57e2d3

Please sign in to comment.