/
msg_server_update_funder.go
42 lines (35 loc) · 1.16 KB
/
msg_server_update_funder.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
package keeper
import (
"context"
"cosmossdk.io/errors"
"github.com/KYVENetwork/chain/x/funders/types"
sdk "github.com/cosmos/cosmos-sdk/types"
errorsTypes "github.com/cosmos/cosmos-sdk/types/errors"
)
// UpdateFunder allows a funder to change basic metadata like moniker, address, logo, etc.
func (k msgServer) UpdateFunder(goCtx context.Context, msg *types.MsgUpdateFunder) (*types.MsgUpdateFunderResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
// Error if funder does not exist
if !k.DoesFunderExist(ctx, msg.Creator) {
return nil, errors.Wrap(errorsTypes.ErrNotFound, types.ErrFunderDoesNotExist.Error())
}
// Update funder
k.SetFunder(ctx, &types.Funder{
Address: msg.Creator,
Moniker: msg.Moniker,
Identity: msg.Identity,
Website: msg.Website,
Contact: msg.Contact,
Description: msg.Description,
})
// Emit a update funder event
_ = ctx.EventManager().EmitTypedEvent(&types.EventUpdateFunder{
Address: msg.Creator,
Moniker: msg.Moniker,
Identity: msg.Identity,
Website: msg.Website,
Contact: msg.Contact,
Description: msg.Description,
})
return &types.MsgUpdateFunderResponse{}, nil
}