-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Charles Dusek
committed
Apr 18, 2024
1 parent
3d6881e
commit e8fb9c4
Showing
3 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package keeper | ||
|
||
import ( | ||
"github.com/cosmos/cosmos-sdk/runtime" | ||
|
||
"context" | ||
"onex/x/market/types" | ||
) | ||
|
||
// GetParams get all parameters as types.Params | ||
func (k Keeper) GetMember( | ||
ctx context.Context, | ||
denomA string, | ||
denomB string, | ||
) (member types.Member, found bool) { | ||
store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) | ||
bz := store.Get(types.MemberKey( | ||
denomA, | ||
denomB, | ||
)) | ||
if bz == nil { | ||
return member, false | ||
} | ||
|
||
k.cdc.MustUnmarshal(bz, &member) | ||
return member, true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package types | ||
|
||
const ( | ||
// MemberKeyPrefix is the prefix to retrieve all Member | ||
MemberKeyPrefix = "Member/value/" | ||
) | ||
|
||
// MemberKey returns the store key to retrieve a Member from the index fields | ||
func MemberKey( | ||
denomA string, | ||
denomB string, | ||
) []byte { | ||
var key []byte | ||
|
||
denomABytes := []byte(denomA) | ||
key = append(key, denomABytes...) | ||
key = append(key, []byte("/")...) | ||
|
||
denomBBytes := []byte(denomB) | ||
key = append(key, denomBBytes...) | ||
key = append(key, []byte("/")...) | ||
|
||
return key | ||
} |