-
Notifications
You must be signed in to change notification settings - Fork 568
/
msgs.go
51 lines (41 loc) · 1.24 KB
/
msgs.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
package balancer
import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/osmosis-labs/osmosis/v7/x/gamm/types"
)
const (
TypeMsgCreateBalancerPool = "create_balancer_pool"
)
var _ sdk.Msg = &MsgCreateBalancerPool{}
func (msg MsgCreateBalancerPool) Route() string { return types.RouterKey }
func (msg MsgCreateBalancerPool) Type() string { return TypeMsgCreateBalancerPool }
func (msg MsgCreateBalancerPool) ValidateBasic() error {
_, err := sdk.AccAddressFromBech32(msg.Sender)
if err != nil {
return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err)
}
err = types.ValidateUserSpecifiedPoolAssets(msg.PoolAssets)
if err != nil {
return err
}
err = msg.PoolParams.Validate(msg.PoolAssets)
if err != nil {
return err
}
// validation for future owner
if err = ValidateFutureGovernor(msg.FuturePoolGovernor); err != nil {
return err
}
return nil
}
func (msg MsgCreateBalancerPool) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg))
}
func (msg MsgCreateBalancerPool) GetSigners() []sdk.AccAddress {
sender, err := sdk.AccAddressFromBech32(msg.Sender)
if err != nil {
panic(err)
}
return []sdk.AccAddress{sender}
}