-
Notifications
You must be signed in to change notification settings - Fork 47
/
types.go
71 lines (59 loc) · 1.78 KB
/
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package types
import (
"math/big"
"cosmossdk.io/errors"
"github.com/cosmos/cosmos-sdk/bsc/rlp"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/gov/types"
)
const (
TransferOutChannel = "transferOut"
TransferInChannel = "transferIn"
TransferOutChannelID sdk.ChannelID = 1
TransferInChannelID sdk.ChannelID = 2
SyncParamsChannelID = types.SyncParamsChannelID
)
type TransferOutSynPackage struct {
Amount *big.Int
Recipient sdk.AccAddress
RefundAddress sdk.AccAddress
}
func DeserializeTransferOutSynPackage(serializedPackage []byte) (*TransferOutSynPackage, error) {
var tp TransferOutSynPackage
err := rlp.DecodeBytes(serializedPackage, &tp)
if err != nil {
return nil, errors.Wrapf(ErrInvalidPackage, "deserialize transfer out package failed")
}
return &tp, nil
}
type TransferOutRefundPackage struct {
RefundAmount *big.Int
RefundAddr sdk.AccAddress
RefundReason uint32
}
func DeserializeTransferOutRefundPackage(serializedPackage []byte) (*TransferOutRefundPackage, error) {
var tp TransferOutRefundPackage
err := rlp.DecodeBytes(serializedPackage, &tp)
if err != nil {
return nil, errors.Wrapf(ErrInvalidPackage, "deserialize transfer out refund package failed")
}
return &tp, nil
}
type TransferInSynPackage struct {
Amount *big.Int
ReceiverAddress sdk.AccAddress
RefundAddress sdk.AccAddress
}
func DeserializeTransferInSynPackage(serializedPackage []byte) (*TransferInSynPackage, error) {
var tp TransferInSynPackage
err := rlp.DecodeBytes(serializedPackage, &tp)
if err != nil {
return nil, errors.Wrapf(ErrInvalidPackage, "deserialize transfer in package failed")
}
return &tp, nil
}
type TransferInRefundPackage struct {
RefundAmount *big.Int
RefundAddress sdk.AccAddress
RefundReason uint32
}