-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove remnants of basecoin tx as ibc functions are now under relay
- Loading branch information
Showing
7 changed files
with
2 additions
and
278 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters