/
msg_token.go
58 lines (47 loc) · 1.49 KB
/
msg_token.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
package types
import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/ethereum/go-ethereum/common"
"github.com/axelarnetwork/axelar-core/utils"
nexus "github.com/axelarnetwork/axelar-core/x/nexus/exported"
)
// NewConfirmTokenRequest creates a message of type ConfirmTokenRequest
func NewConfirmTokenRequest(sender sdk.AccAddress, chain string, asset Asset, txID common.Hash) *ConfirmTokenRequest {
return &ConfirmTokenRequest{
Sender: sender,
Chain: nexus.ChainName(utils.NormalizeString(chain)),
Asset: asset,
TxID: Hash(txID),
}
}
// Route implements sdk.Msg
func (m ConfirmTokenRequest) Route() string {
return RouterKey
}
// Type implements sdk.Msg
func (m ConfirmTokenRequest) Type() string {
return "ConfirmERC20TokenDeployment"
}
// ValidateBasic implements sdk.Msg
func (m ConfirmTokenRequest) ValidateBasic() error {
if err := sdk.VerifyAddressFormat(m.Sender); err != nil {
return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, sdkerrors.Wrap(err, "sender").Error())
}
if err := m.Chain.Validate(); err != nil {
return sdkerrors.Wrap(err, "invalid chain")
}
if err := m.Asset.Validate(); err != nil {
return err
}
return nil
}
// GetSignBytes implements sdk.Msg
func (m ConfirmTokenRequest) GetSignBytes() []byte {
bz := ModuleCdc.MustMarshalJSON(&m)
return sdk.MustSortJSON(bz)
}
// GetSigners implements sdk.Msg
func (m ConfirmTokenRequest) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{m.Sender}
}