-
Notifications
You must be signed in to change notification settings - Fork 11
/
host_chain_params.go
36 lines (28 loc) · 1.13 KB
/
host_chain_params.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
package keeper
import (
sdk "github.com/cosmos/cosmos-sdk/types"
ibctransfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types"
"github.com/persistenceOne/pstake-native/x/lscosmos/types"
)
// SetHostChainParams sets the host chain params in store
func (k Keeper) SetHostChainParams(ctx sdk.Context, hostChainParams types.HostChainParams) {
store := ctx.KVStore(k.storeKey)
store.Set(types.HostChainParamsKey, k.cdc.MustMarshal(&hostChainParams))
}
// GetHostChainParams gets the host chain params in store
func (k Keeper) GetHostChainParams(ctx sdk.Context) types.HostChainParams {
store := ctx.KVStore(k.storeKey)
var hostChainParams types.HostChainParams
k.cdc.MustUnmarshal(store.Get(types.HostChainParamsKey), &hostChainParams)
return hostChainParams
}
// GetIBCDenom returns IBC denom in form of string
func (k Keeper) GetIBCDenom(ctx sdk.Context) string {
hostChainParams := k.GetHostChainParams(ctx)
ibcDenom := ibctransfertypes.ParseDenomTrace(
ibctransfertypes.GetPrefixedDenom(
hostChainParams.TransferPort, hostChainParams.TransferChannel, hostChainParams.BaseDenom,
),
).IBCDenom()
return ibcDenom
}