-
Notifications
You must be signed in to change notification settings - Fork 0
/
msg_convert.go
41 lines (35 loc) · 1.09 KB
/
msg_convert.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 distribution
import (
"encoding/json"
"errors"
"github.com/evoblockchain/evochain/libs/cosmos-sdk/baseapp"
sdk "github.com/evoblockchain/evochain/libs/cosmos-sdk/types"
tmtypes "github.com/evoblockchain/evochain/libs/tendermint/types"
"github.com/evoblockchain/evochain/x/common"
"github.com/evoblockchain/evochain/x/distribution/types"
)
var (
ErrCheckSignerFail = errors.New("check signer fail")
)
func init() {
RegisterConvert()
}
func RegisterConvert() {
enableHeight := tmtypes.GetVenus3Height()
baseapp.RegisterCmHandle("evoblockchain/distribution/MsgWithdrawDelegatorAllRewards", baseapp.NewCMHandle(ConvertWithdrawDelegatorAllRewardsMsg, enableHeight))
}
func ConvertWithdrawDelegatorAllRewardsMsg(data []byte, signers []sdk.AccAddress) (sdk.Msg, error) {
newMsg := types.MsgWithdrawDelegatorAllRewards{}
err := json.Unmarshal(data, &newMsg)
if err != nil {
return nil, err
}
err = newMsg.ValidateBasic()
if err != nil {
return nil, err
}
if ok := common.CheckSignerAddress(signers, newMsg.GetSigners()); !ok {
return nil, ErrCheckSignerFail
}
return newMsg, nil
}