Start tx holder with gen

This commit is contained in:
Ethan Frey 2017-05-17 18:53:53 +02:00
parent defe9f941f
commit bdd0463849
3 changed files with 58 additions and 0 deletions

6
_gen.go Normal file
View File

@ -0,0 +1,6 @@
package main
import (
_ "github.com/tendermint/go-wire/gen"
_ "github.com/clipperhouse/stringer"
)

6
tx.go Normal file
View File

@ -0,0 +1,6 @@
package basecoin
// TODO: add some common functionality here...
// +gen wrapper:"Tx"
type TxInner interface {
}

46
txinner_wrapper.go Normal file
View File

@ -0,0 +1,46 @@
// Generated by: main
// TypeWriter: wrapper
// Directive: +gen on TxInner
package basecoin
import (
"github.com/tendermint/go-wire/data"
)
// Auto-generated adapters for happily unmarshaling interfaces
// Apache License 2.0
// Copyright (c) 2017 Ethan Frey (ethan.frey@tendermint.com)
type Tx struct {
TxInner "json:\"unwrap\""
}
var TxMapper = data.NewMapper(Tx{})
func (h Tx) MarshalJSON() ([]byte, error) {
return TxMapper.ToJSON(h.TxInner)
}
func (h *Tx) UnmarshalJSON(data []byte) (err error) {
parsed, err := TxMapper.FromJSON(data)
if err == nil && parsed != nil {
h.TxInner = parsed.(TxInner)
}
return err
}
// Unwrap recovers the concrete interface safely (regardless of levels of embeds)
func (h Tx) Unwrap() TxInner {
hi := h.TxInner
for wrap, ok := hi.(Tx); ok; wrap, ok = hi.(Tx) {
hi = wrap.TxInner
}
return hi
}
func (h Tx) Empty() bool {
return h.TxInner == nil
}
/*** below are bindings for each implementation ***/