Moved Coins from types -> modules/coin

This commit is contained in:
Ethan Frey
2017-07-06 14:59:45 +02:00
parent 49357a3574
commit 6983f61961
21 changed files with 152 additions and 136 deletions
+6 -6
View File
@@ -3,9 +3,9 @@ package fee
import (
"github.com/tendermint/basecoin"
"github.com/tendermint/basecoin/errors"
"github.com/tendermint/basecoin/modules/coin"
"github.com/tendermint/basecoin/stack"
"github.com/tendermint/basecoin/state"
"github.com/tendermint/basecoin/types"
)
// NameFee - namespace for the fee module
@@ -14,17 +14,17 @@ const NameFee = "fee"
// AccountChecker - interface used by SimpleFeeHandler
type AccountChecker interface {
// Get amount checks the current amount
GetAmount(store state.KVStore, addr basecoin.Actor) (types.Coins, error)
GetAmount(store state.KVStore, addr basecoin.Actor) (coin.Coins, error)
// ChangeAmount modifies the balance by the given amount and returns the new balance
// always returns an error if leading to negative balance
ChangeAmount(store state.KVStore, addr basecoin.Actor, coins types.Coins) (types.Coins, error)
ChangeAmount(store state.KVStore, addr basecoin.Actor, coins coin.Coins) (coin.Coins, error)
}
// SimpleFeeHandler - checker object for fee checking
type SimpleFeeHandler struct {
AccountChecker
MinFee types.Coins
MinFee coin.Coins
stack.PassOption
}
@@ -44,7 +44,7 @@ func (h SimpleFeeHandler) CheckTx(ctx basecoin.Context, store state.KVStore, tx
return res, errors.ErrInvalidFormat(tx)
}
fees := types.Coins{feeTx.Fee}
fees := coin.Coins{feeTx.Fee}
if !fees.IsGTE(h.MinFee) {
return res, ErrInsufficientFees()
}
@@ -68,7 +68,7 @@ func (h SimpleFeeHandler) DeliverTx(ctx basecoin.Context, store state.KVStore, t
return res, errors.ErrInvalidFormat(tx)
}
fees := types.Coins{feeTx.Fee}
fees := coin.Coins{feeTx.Fee}
if !fees.IsGTE(h.MinFee) {
return res, ErrInsufficientFees()
}
+5 -4
View File
@@ -2,9 +2,10 @@ package fee
import (
"github.com/tendermint/basecoin"
"github.com/tendermint/basecoin/types"
"github.com/tendermint/basecoin/modules/coin"
)
// nolint
const (
ByteFees = 0x20
TypeFees = "fee"
@@ -20,12 +21,12 @@ func init() {
// Fee attaches a fee payment to the embedded tx
type Fee struct {
Tx basecoin.Tx `json:"tx"`
Fee types.Coin `json:"fee"`
Fee coin.Coin `json:"fee"`
Payer basecoin.Actor `json:"payer"` // the address who pays the fee
// Gas types.Coin `json:"gas"` // ?????
// Gas coin.Coin `json:"gas"` // ?????
}
func NewFee(tx basecoin.Tx, fee types.Coin, payer basecoin.Actor) basecoin.Tx {
func NewFee(tx basecoin.Tx, fee coin.Coin, payer basecoin.Actor) basecoin.Tx {
return (&Fee{Tx: tx, Fee: fee, Payer: payer}).Wrap()
}