Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package txs
import (
"fmt"
"github.com/hyperledger/burrow/txs/payload"
"github.com/tendermint/go-amino"
)
type aminoCodec struct {
*amino.Codec
}
func NewAminoCodec() *aminoCodec {
cdc := amino.NewCodec()
cdc.RegisterInterface((*payload.Payload)(nil), nil)
registerTx(cdc, &payload.SendTx{})
registerTx(cdc, &payload.CallTx{})
registerTx(cdc, &payload.BondTx{})
registerTx(cdc, &payload.UnbondTx{})
registerTx(cdc, &payload.PermissionsTx{})
registerTx(cdc, &payload.NameTx{})
registerTx(cdc, &payload.GovernanceTx{})
return &aminoCodec{cdc}
}
func (gwc *aminoCodec) EncodeTx(env *Envelope) ([]byte, error) {
return gwc.MarshalBinary(env)
}
func (gwc *aminoCodec) DecodeTx(txBytes []byte) (*Envelope, error) {
env := new(Envelope)
err := gwc.UnmarshalBinary(txBytes, env)
if err != nil {
return nil, err
}
return env, nil
}
func registerTx(cdc *amino.Codec, tx payload.Payload) {
cdc.RegisterConcrete(tx, fmt.Sprintf("burrow/txs/payload/%v", tx.Type()), nil)
}