diff --git a/x/coin/coin.go b/types/coin.go similarity index 97% rename from x/coin/coin.go rename to types/coin.go index 7c3af50d7f..30e96b2950 100644 --- a/x/coin/coin.go +++ b/types/coin.go @@ -1,12 +1,9 @@ -package coin +package types import ( "fmt" "sort" - "strconv" "strings" - - "github.com/pkg/errors" ) // Coin hold some amount of one currency @@ -200,3 +197,11 @@ var _ sort.Interface = Coins{} // Sort is a helper function to sort the set of coins inplace func (coins Coins) Sort() { sort.Sort(coins) } + +//---------------------------------------- +// Misc + +type Coinser interface { + GetCoins() Coins + SetCoins(Coins) +} diff --git a/x/coin/coin_test.go b/types/coin_test.go similarity index 99% rename from x/coin/coin_test.go rename to types/coin_test.go index 0cb2b4f21b..bf651c50de 100644 --- a/x/coin/coin_test.go +++ b/types/coin_test.go @@ -1,4 +1,4 @@ -package coin +package types import ( "testing" diff --git a/x/coin/types.go b/x/coin/types.go deleted file mode 100644 index 5da29b465d..0000000000 --- a/x/coin/types.go +++ /dev/null @@ -1,6 +0,0 @@ -package coin - -type Coinser interface { - GetCoins() Coins - SetCoins(Coins) -} diff --git a/x/coin/_attic/bench_test.go b/x/coinstore/_attic/bench_test.go similarity index 100% rename from x/coin/_attic/bench_test.go rename to x/coinstore/_attic/bench_test.go diff --git a/x/coin/_attic/handler.go b/x/coinstore/_attic/handler.go similarity index 100% rename from x/coin/_attic/handler.go rename to x/coinstore/_attic/handler.go diff --git a/x/coin/_attic/handler_test.go b/x/coinstore/_attic/handler_test.go similarity index 100% rename from x/coin/_attic/handler_test.go rename to x/coinstore/_attic/handler_test.go diff --git a/x/coin/_attic/helper.go b/x/coinstore/_attic/helper.go similarity index 100% rename from x/coin/_attic/helper.go rename to x/coinstore/_attic/helper.go diff --git a/x/coin/_attic/ibc_test.go b/x/coinstore/_attic/ibc_test.go similarity index 100% rename from x/coin/_attic/ibc_test.go rename to x/coinstore/_attic/ibc_test.go diff --git a/x/coin/_attic/store.go b/x/coinstore/_attic/store.go similarity index 100% rename from x/coin/_attic/store.go rename to x/coinstore/_attic/store.go diff --git a/x/coin/commands/query.go b/x/coinstore/commands/query.go similarity index 100% rename from x/coin/commands/query.go rename to x/coinstore/commands/query.go diff --git a/x/coin/commands/tx.go b/x/coinstore/commands/tx.go similarity index 100% rename from x/coin/commands/tx.go rename to x/coinstore/commands/tx.go diff --git a/x/coin/decorator.go b/x/coinstore/decorator.go similarity index 100% rename from x/coin/decorator.go rename to x/coinstore/decorator.go diff --git a/x/coin/errors.go b/x/coinstore/errors.go similarity index 100% rename from x/coin/errors.go rename to x/coinstore/errors.go diff --git a/x/coin/genesis.go b/x/coinstore/genesis.go similarity index 93% rename from x/coin/genesis.go rename to x/coinstore/genesis.go index b174c8c11a..cc0163fcf0 100644 --- a/x/coin/genesis.go +++ b/x/coinstore/genesis.go @@ -5,6 +5,7 @@ import ( "github.com/pkg/errors" + "github.com/cosmos/cosmos-sdk/types" crypto "github.com/tendermint/go-crypto" "github.com/tendermint/go-wire/data" ) @@ -16,7 +17,7 @@ type GenesisAccount struct { Address data.Bytes `json:"address"` // this from types.Account (don't know how to embed this properly) PubKey crypto.PubKey `json:"pub_key"` // May be nil, if not known. - Balance Coins `json:"coins"` + Balance types.Coins `json:"coins"` } // ToAccount - GenesisAccount struct to a basecoin Account diff --git a/x/coin/rest/handlers.go b/x/coinstore/rest/handlers.go similarity index 100% rename from x/coin/rest/handlers.go rename to x/coinstore/rest/handlers.go diff --git a/x/coin/tx.go b/x/coinstore/tx.go similarity index 89% rename from x/coin/tx.go rename to x/coinstore/tx.go index fcb0c84d54..ab12893741 100644 --- a/x/coin/tx.go +++ b/x/coinstore/tx.go @@ -4,6 +4,7 @@ package coin import ( "fmt" + "github.com/cosmos/cosmos-sdk/types" cmn "github.com/tendermint/tmlibs/common" ) @@ -17,7 +18,7 @@ type CoinMsg interface { // Input is a source of coins in a transaction. type Input struct { Address cmn.Bytes - Coins Coins + Coins types.Coins } func (in Input) ValidateBasic() error { @@ -38,7 +39,7 @@ func (txIn TxInput) String() string { } // NewTxInput - create a transaction input, used with SendTx -func NewTxInput(addr Actor, coins Coins) TxInput { +func NewTxInput(addr Actor, coins types.Coins) TxInput { input := TxInput{ Address: addr, Coins: coins, @@ -50,8 +51,8 @@ func NewTxInput(addr Actor, coins Coins) TxInput { // TxOutput - expected coin movement output, used with SendTx type TxOutput struct { - Address Actor `json:"address"` - Coins Coins `json:"coins"` + Address Actor `json:"address"` + Coins types.Coins `json:"coins"` } // ValidateBasic - validate transaction output @@ -77,7 +78,7 @@ func (txOut TxOutput) String() string { } // NewTxOutput - create a transaction output, used with SendTx -func NewTxOutput(addr Actor, coins Coins) TxOutput { +func NewTxOutput(addr Actor, coins types.Coins) TxOutput { output := TxOutput{ Address: addr, Coins: coins, @@ -103,7 +104,7 @@ func NewSendTx(in []TxInput, out []TxOutput) SendTx { // types.Tx { // NewSendOneTx is a helper for the standard (?) case where there is exactly // one sender and one recipient -func NewSendOneTx(sender, recipient Actor, amount Coins) SendTx { +func NewSendOneTx(sender, recipient Actor, amount types.Coins) SendTx { in := []TxInput{{Address: sender, Coins: amount}} out := []TxOutput{{Address: recipient, Coins: amount}} return SendTx{Inputs: in, Outputs: out} @@ -120,7 +121,7 @@ func (tx SendTx) ValidateBasic() error { return ErrNoOutputs() } // make sure all inputs and outputs are individually valid - var totalIn, totalOut Coins + var totalIn, totalOut types.Coins for _, in := range tx.Inputs { if err := in.ValidateBasic(); err != nil { return err @@ -153,11 +154,11 @@ type CreditTx struct { // Credit is the amount to change the credit... // This may be negative to remove some over-issued credit, // but can never bring the credit or the balance to negative - Credit Coins `json:"credit"` + Credit types.Coins `json:"credit"` } // NewCreditTx - modify the credit granted to a given account -func NewCreditTx(debitor Actor, credit Coins) CreditTx { +func NewCreditTx(debitor Actor, credit types.Coins) CreditTx { return CreditTx{Debitor: debitor, Credit: credit} } diff --git a/x/coin/tx_test.go b/x/coinstore/tx_test.go similarity index 100% rename from x/coin/tx_test.go rename to x/coinstore/tx_test.go diff --git a/x/coin/utils.go b/x/coinstore/utils.go similarity index 100% rename from x/coin/utils.go rename to x/coinstore/utils.go