-
Notifications
You must be signed in to change notification settings - Fork 40
/
msg_update_vesting_info.go
45 lines (35 loc) · 1.29 KB
/
msg_update_vesting_info.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
package wasm
import (
"encoding/json"
errorsmod "cosmossdk.io/errors"
wasmvmtypes "github.com/CosmWasm/wasmvm/types"
sdk "github.com/cosmos/cosmos-sdk/types"
keeper "github.com/elys-network/elys/x/commitment/keeper"
types "github.com/elys-network/elys/x/commitment/types"
)
func (m *Messenger) msgUpdateVestingInfo(ctx sdk.Context, contractAddr sdk.AccAddress, msg *types.MsgUpdateVestingInfo) ([]sdk.Event, [][]byte, error) {
if msg == nil {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "UpdateVestingInfo null msg"}
}
brokerAddress := m.parameterKeeper.GetParams(ctx).BrokerAddress
if msg.Authority != contractAddr.String() && contractAddr.String() != brokerAddress {
return nil, nil, wasmvmtypes.InvalidRequest{Err: "update vesting info wrong sender"}
}
msgServer := keeper.NewMsgServerImpl(*m.keeper)
if err := msg.ValidateBasic(); err != nil {
return nil, nil, errorsmod.Wrap(err, "failed validating msg")
}
res, err := msgServer.UpdateVestingInfo(
sdk.WrapSDKContext(ctx),
msg,
)
if err != nil {
return nil, nil, errorsmod.Wrap(err, "UpdateVestingInfo msg")
}
responseBytes, err := json.Marshal(*res)
if err != nil {
return nil, nil, errorsmod.Wrap(err, "failed to serialize UpdateVestingInfo response")
}
resp := [][]byte{responseBytes}
return nil, resp, nil
}