-
Notifications
You must be signed in to change notification settings - Fork 47
/
message_cancel_migrate_bucket.go
53 lines (42 loc) · 1.24 KB
/
message_cancel_migrate_bucket.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
package types
import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/bnb-chain/greenfield/types/s3util"
)
const TypeMsgCancelMigrateBucket = "cancel_migrate_bucket"
var _ sdk.Msg = &MsgCancelMigrateBucket{}
func NewMsgCancelMigrateBucket(operator sdk.AccAddress, bucketName string) *MsgCancelMigrateBucket {
return &MsgCancelMigrateBucket{
Operator: operator.String(),
BucketName: bucketName,
}
}
func (msg *MsgCancelMigrateBucket) Route() string {
return RouterKey
}
func (msg *MsgCancelMigrateBucket) Type() string {
return TypeMsgCancelMigrateBucket
}
func (msg *MsgCancelMigrateBucket) GetSigners() []sdk.AccAddress {
creator, err := sdk.AccAddressFromHexUnsafe(msg.Operator)
if err != nil {
panic(err)
}
return []sdk.AccAddress{creator}
}
func (msg *MsgCancelMigrateBucket) GetSignBytes() []byte {
bz := ModuleCdc.MustMarshalJSON(msg)
return sdk.MustSortJSON(bz)
}
func (msg *MsgCancelMigrateBucket) ValidateBasic() error {
_, err := sdk.AccAddressFromHexUnsafe(msg.Operator)
if err != nil {
return sdkerrors.ErrInvalidAddress.Wrapf("invalid creator address (%s)", err)
}
err = s3util.CheckValidBucketName(msg.BucketName)
if err != nil {
return err
}
return nil
}