-
Notifications
You must be signed in to change notification settings - Fork 53
/
state.go
41 lines (35 loc) · 1.14 KB
/
state.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
package types
import (
"reflect"
errorsmod "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/dymensionxyz/gerr-cosmos/gerrc"
"github.com/dymensionxyz/sdk-utils/utils/uibc"
)
func (s *State) Validate() error {
for _, a := range s.GetGenesisAccounts() {
if err := a.GetAmount().Validate(); err != nil {
return errorsmod.Wrap(err, "amount")
}
if uibc.IsIBCDenom(a.Amount.GetDenom()) {
return errorsmod.Wrapf(gerrc.ErrInvalidArgument, "ibc denoms not allowed in genesis accounts: %s", a.Amount)
}
_, err := sdk.AccAddressFromBech32(a.GetAddress())
if err != nil {
return errorsmod.Wrap(err, "address from bech 32")
}
}
return nil
}
func (s *State) IsCanonicalHubTransferChannel(port, channel string) bool {
return s.CanonicalHubTransferChannelHasBeenSet() && s.HubPortAndChannel.Port == port && s.HubPortAndChannel.Channel == channel
}
func (s *State) CanonicalHubTransferChannelHasBeenSet() bool {
return !reflect.ValueOf(s.HubPortAndChannel).IsZero()
}
func (s *State) SetCanonicalTransferChannel(port, channel string) {
s.HubPortAndChannel = &PortAndChannel{
Port: port,
Channel: channel,
}
}