-
Notifications
You must be signed in to change notification settings - Fork 2
/
handler.go
82 lines (76 loc) · 3.3 KB
/
handler.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package anconprotocol
import (
"fmt"
"github.com/Electronic-Signatures-Industries/ancon-protocol/x/anconprotocol/keeper"
"github.com/Electronic-Signatures-Industries/ancon-protocol/x/anconprotocol/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
// NewHandler ...
func NewHandler(k keeper.Keeper) sdk.Handler {
msgServer := keeper.NewMsgServerImpl(k)
return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) {
ctx = ctx.WithEventManager(sdk.NewEventManager())
switch msg := msg.(type) {
// this line is used by starport scaffolding # 1
// Not yet
// Use case #2 IDCollection + pub/priv spaces
// MsgCreateDIDOwner
// MsgMintTrustedResourceContent
// Metadata = stored in metadata anconprotocol
// NFT Token = mint nft cosmos
// DID = create DID Owner
// case *types.MsgRoyaltyInfo:
// res, err := msgServer.RoyaltyInfo(sdk.WrapSDKContext(ctx), msg)
// return sdk.WrapServiceResult(ctx, res, err)
case *types.MsgMintTrustedContent:
res, err := msgServer.MintTrustedContent(sdk.WrapSDKContext(ctx), msg)
return sdk.WrapServiceResult(ctx, res, err)
case *types.MsgMintTrustedResource:
res, err := msgServer.MintTrustedResource(sdk.WrapSDKContext(ctx), msg)
return sdk.WrapServiceResult(ctx, res, err)
case *types.MsgChangeOwner:
res, err := msgServer.ChangeOwner(sdk.WrapSDKContext(ctx), msg)
return sdk.WrapServiceResult(ctx, res, err)
case *types.MsgGrantDelegate:
res, err := msgServer.GrantDelegate(sdk.WrapSDKContext(ctx), msg)
return sdk.WrapServiceResult(ctx, res, err)
case *types.MsgRevokeDelegate:
res, err := msgServer.RevokeDelegate(sdk.WrapSDKContext(ctx), msg)
return sdk.WrapServiceResult(ctx, res, err)
case *types.MsgGrantAttribute:
res, err := msgServer.GrantAttribute(sdk.WrapSDKContext(ctx), msg)
return sdk.WrapServiceResult(ctx, res, err)
case *types.MsgRevokeAttribute:
res, err := msgServer.RevokeAttribute(sdk.WrapSDKContext(ctx), msg)
return sdk.WrapServiceResult(ctx, res, err)
case *types.MsgIssueDenom:
res, err := msgServer.IssueDenom(sdk.WrapSDKContext(ctx), msg)
return sdk.WrapServiceResult(ctx, res, err)
case *types.MsgMintNFT:
res, err := msgServer.MintNFT(sdk.WrapSDKContext(ctx), msg)
return sdk.WrapServiceResult(ctx, res, err)
case *types.MsgTransferNFT:
res, err := msgServer.TransferNFT(sdk.WrapSDKContext(ctx), msg)
return sdk.WrapServiceResult(ctx, res, err)
case *types.MsgEditNFT:
res, err := msgServer.EditNFT(sdk.WrapSDKContext(ctx), msg)
return sdk.WrapServiceResult(ctx, res, err)
case *types.MsgBurnNFT:
res, err := msgServer.BurnNFT(sdk.WrapSDKContext(ctx), msg)
return sdk.WrapServiceResult(ctx, res, err)
case *types.MsgTransferDenom:
res, err := msgServer.TransferDenom(sdk.WrapSDKContext(ctx), msg)
return sdk.WrapServiceResult(ctx, res, err)
case *types.MsgMetadata:
res, err := msgServer.Metadata(sdk.WrapSDKContext(ctx), msg)
return sdk.WrapServiceResult(ctx, res, err)
case *types.MsgUpdateMetadataOwnership:
res, err := msgServer.UpdateMetadataOwnership(sdk.WrapSDKContext(ctx), msg)
return sdk.WrapServiceResult(ctx, res, err)
default:
errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg)
return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg)
}
}
}