/
types.go
42 lines (35 loc) · 894 Bytes
/
types.go
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 types
import (
"github.com/cosmos/ibc-go/modules/core/exported"
"github.com/gogo/protobuf/proto"
)
type (
// TxID represents a ID of transaction. This value must be unique in a chain
TxID = []byte
// TxIndex represents an index of an array of contract transactions
TxIndex = uint32
)
var _ exported.Acknowledgement = (*Acknowledgement)(nil)
func NewAcknowledgement(success bool, result []byte) *Acknowledgement {
return &Acknowledgement{
IsSuccess: success,
Result: result,
}
}
func (ack Acknowledgement) Success() bool {
return ack.IsSuccess
}
func (ack Acknowledgement) Acknowledgement() []byte {
bz, err := proto.Marshal(&ack)
if err != nil {
panic(err)
}
return bz
}
func UnmarshalAcknowledgement(bz []byte) (*Acknowledgement, error) {
var ack Acknowledgement
if err := proto.Unmarshal(bz, &ack); err != nil {
return nil, err
}
return &ack, nil
}