cosmos-sdk/modules/fee/tx.go

45 lines
945 B
Go
Raw Normal View History

package fee
import (
"github.com/tendermint/basecoin"
2017-07-06 05:59:45 -07:00
"github.com/tendermint/basecoin/modules/coin"
)
2017-07-06 05:59:45 -07:00
// nolint
const (
2017-07-21 14:47:18 -07:00
ByteFees = 0x28
2017-07-12 10:06:55 -07:00
TypeFees = NameFee + "/tx"
)
func init() {
basecoin.TxMapper.
2017-07-12 10:06:55 -07:00
RegisterImplementation(Fee{}, TypeFees, ByteFees)
}
/**** Fee ****/
// Fee attaches a fee payment to the embedded tx
type Fee struct {
2017-07-12 10:06:55 -07:00
// Gas coin.Coin `json:"gas"` // ?????
2017-07-06 05:59:45 -07:00
Fee coin.Coin `json:"fee"`
Payer basecoin.Actor `json:"payer"` // the address who pays the fee
2017-07-12 10:06:55 -07:00
Tx basecoin.Tx `json:"tx"`
}
2017-07-12 10:06:55 -07:00
// NewFee wraps a tx with a promised fee from this actor
2017-07-06 05:59:45 -07:00
func NewFee(tx basecoin.Tx, fee coin.Coin, payer basecoin.Actor) basecoin.Tx {
2017-07-12 10:06:55 -07:00
return Fee{Tx: tx, Fee: fee, Payer: payer}.Wrap()
}
2017-07-12 10:06:55 -07:00
// nolint - TxInner Functions
func (f Fee) ValidateBasic() error {
// TODO: more checks
return f.Tx.ValidateBasic()
}
2017-07-12 10:06:55 -07:00
func (f Fee) Wrap() basecoin.Tx {
return basecoin.Tx{f}
}
2017-07-12 10:06:55 -07:00
func (f Fee) Next() basecoin.Tx {
return f.Tx
}