-
Notifications
You must be signed in to change notification settings - Fork 0
/
encoding.go
35 lines (30 loc) · 1.19 KB
/
encoding.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
package keeper
import (
"github.com/soominhyunwoo/chain-sdk/x/ibc/applications/transfer/types"
)
// UnmarshalDenomTrace attempts to decode and return an DenomTrace object from
// raw encoded bytes.
func (k Keeper) UnmarshalDenomTrace(bz []byte) (types.DenomTrace, error) {
var denomTrace types.DenomTrace
if err := k.cdc.UnmarshalBinaryBare(bz, &denomTrace); err != nil {
return types.DenomTrace{}, err
}
return denomTrace, nil
}
// MustUnmarshalDenomTrace attempts to decode and return an DenomTrace object from
// raw encoded bytes. It panics on error.
func (k Keeper) MustUnmarshalDenomTrace(bz []byte) types.DenomTrace {
var denomTrace types.DenomTrace
k.cdc.MustUnmarshalBinaryBare(bz, &denomTrace)
return denomTrace
}
// MarshalDenomTrace attempts to encode an DenomTrace object and returns the
// raw encoded bytes.
func (k Keeper) MarshalDenomTrace(denomTrace types.DenomTrace) ([]byte, error) {
return k.cdc.MarshalBinaryBare(&denomTrace)
}
// MustMarshalDenomTrace attempts to encode an DenomTrace object and returns the
// raw encoded bytes. It panics on error.
func (k Keeper) MustMarshalDenomTrace(denomTrace types.DenomTrace) []byte {
return k.cdc.MustMarshalBinaryBare(&denomTrace)
}