/
msg_server_create_collection.go
50 lines (43 loc) · 1.88 KB
/
msg_server_create_collection.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
package keeper
import (
"context"
"github.com/bitbadges/bitbadgeschain/x/badges/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)
func (k msgServer) CreateCollection(goCtx context.Context, msg *types.MsgCreateCollection) (*types.MsgCreateCollectionResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
newMsg := types.MsgUniversalUpdateCollection{
Creator: msg.Creator,
CollectionId: sdk.NewUint(0), //We use 0 to indicate a new collection
//Exclusive to collection creations
BalancesType: msg.BalancesType,
DefaultBalances: msg.DefaultBalances,
//Applicable to creations and updates
BadgesToCreate: msg.BadgesToCreate,
UpdateCollectionPermissions: true,
CollectionPermissions: msg.CollectionPermissions,
UpdateManagerTimeline: true,
ManagerTimeline: msg.ManagerTimeline,
UpdateCollectionMetadataTimeline: true,
CollectionMetadataTimeline: msg.CollectionMetadataTimeline,
UpdateBadgeMetadataTimeline: true,
BadgeMetadataTimeline: msg.BadgeMetadataTimeline,
UpdateOffChainBalancesMetadataTimeline: true,
OffChainBalancesMetadataTimeline: msg.OffChainBalancesMetadataTimeline,
UpdateCustomDataTimeline: true,
CustomDataTimeline: msg.CustomDataTimeline,
UpdateCollectionApprovals: true,
CollectionApprovals: msg.CollectionApprovals,
UpdateStandardsTimeline: true,
StandardsTimeline: msg.StandardsTimeline,
UpdateIsArchivedTimeline: true,
IsArchivedTimeline: msg.IsArchivedTimeline,
}
res, err := k.UniversalUpdateCollection(ctx, &newMsg)
if err != nil {
return nil, err
}
return &types.MsgCreateCollectionResponse{
CollectionId: res.CollectionId,
}, nil
}