From 21e62708a56db78c32cfcdc3d8cc2973b15fccee Mon Sep 17 00:00:00 2001 From: Charles Dusek Date: Fri, 19 Apr 2024 02:38:14 -0500 Subject: [PATCH] Create Drop now has Uid --- x/market/keeper/msg_server_create_drop.go | 4 ++++ x/market/keeper/uid.go | 15 +++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/x/market/keeper/msg_server_create_drop.go b/x/market/keeper/msg_server_create_drop.go index abfbb46..7e05605 100644 --- a/x/market/keeper/msg_server_create_drop.go +++ b/x/market/keeper/msg_server_create_drop.go @@ -46,8 +46,12 @@ func (k msgServer) CreateDrop(goCtx context.Context, msg *types.MsgCreateDrop) ( return nil, types.ErrMemberBalanceZero } + // Create the uid + uid := k.GetUidCount(ctx) + _ = memberA _ = memberB + _ = uid.Count return &types.MsgCreateDropResponse{}, nil } diff --git a/x/market/keeper/uid.go b/x/market/keeper/uid.go index 444b4bd..031a428 100644 --- a/x/market/keeper/uid.go +++ b/x/market/keeper/uid.go @@ -1,22 +1,25 @@ package keeper import ( - "github.com/cosmos/cosmos-sdk/runtime" - "context" "onex/x/market/types" + + "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/runtime" ) -// GetParams get all parameters as types.Params +// GetUidCount gets the current unique identifier func (k Keeper) GetUidCount( ctx context.Context, -) (uid types.Uid, found bool) { +) (uid types.Uid) { store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) bz := store.Get(types.UidKey()) if bz == nil { - return uid, false + return types.Uid{ + Count: math.OneInt().Uint64(), + } } k.cdc.MustUnmarshal(bz, &uid) - return uid, true + return uid }