Skip to content

Commit

Permalink
Create Drop now has Uid
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles Dusek committed Apr 19, 2024
1 parent 33f34ae commit 21e6270
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
4 changes: 4 additions & 0 deletions x/market/keeper/msg_server_create_drop.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
15 changes: 9 additions & 6 deletions x/market/keeper/uid.go
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 21e6270

Please sign in to comment.