cosmos-sdk/tx.go

37 lines
977 B
Go
Raw Normal View History

2017-05-17 09:53:53 -07:00
package basecoin
2017-06-01 07:54:16 -07:00
// TxInner is the interface all concrete transactions should implement.
//
// It adds bindings for clean un/marhsaling of the various implementations
// both as json and binary, as well as some common functionality to move them.
//
2017-05-17 09:53:53 -07:00
// +gen wrapper:"Tx"
type TxInner interface {
2017-05-18 08:11:26 -07:00
Wrap() Tx
2017-06-01 07:54:16 -07:00
// ValidateBasic should be a stateless check and just verify that the
// tx is properly formated (required strings not blank, signatures exist, etc.)
// this can also be run on the client-side for better debugging before posting a tx
ValidateBasic() error
2017-05-18 08:11:26 -07:00
}
2017-06-01 07:54:16 -07:00
// TODO: do we need this abstraction? TxLayer???
// please review again after implementing "middleware"
2017-05-18 08:11:26 -07:00
// TxLayer provides a standard way to deal with "middleware" tx,
// That add context to an embedded tx.
type TxLayer interface {
TxInner
Next() Tx
}
func (t Tx) IsLayer() bool {
_, ok := t.Unwrap().(TxLayer)
return ok
}
func (t Tx) GetLayer() TxLayer {
l, _ := t.Unwrap().(TxLayer)
return l
2017-05-17 09:53:53 -07:00
}