Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: set default denom #137

Merged
merged 2 commits into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/config/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ const (
// BondDenom staking denom
BondDenom = "uluna"

// More denoms
// Luna = "luna" // 1 (base denom unit)
// MilliLuna = "mluna" // 10^-3 (milli)
MicroLuna = BondDenom // 10^-6 (micro)
// NanoLuna = "nluna" // 10^-9 (nano)

AuthzMsgExec = "/cosmos.authz.v1beta1.MsgExec"
AuthzMsgGrant = "/cosmos.authz.v1beta1.MsgGrant"
AuthzMsgRevoke = "/cosmos.authz.v1beta1.MsgRevoke"
Expand Down
24 changes: 24 additions & 0 deletions app/params/address.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package params

import (
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/terra-money/core/v2/app/config"
)

func RegisterAddressesConfig() {
sdkConfig := sdk.GetConfig()
sdkConfig.SetCoinType(config.CoinType)

accountPubKeyPrefix := config.AccountAddressPrefix + "pub"
validatorAddressPrefix := config.AccountAddressPrefix + "valoper"
validatorPubKeyPrefix := config.AccountAddressPrefix + "valoperpub"
consNodeAddressPrefix := config.AccountAddressPrefix + "valcons"
consNodePubKeyPrefix := config.AccountAddressPrefix + "valconspub"

sdkConfig.SetBech32PrefixForAccount(config.AccountAddressPrefix, accountPubKeyPrefix)
sdkConfig.SetBech32PrefixForValidator(validatorAddressPrefix, validatorPubKeyPrefix)
sdkConfig.SetBech32PrefixForConsensusNode(consNodeAddressPrefix, consNodePubKeyPrefix)
sdkConfig.SetAddressVerifier(wasmtypes.VerifyAddressLen())
sdkConfig.Seal()
}
13 changes: 13 additions & 0 deletions app/params/denoms.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package params

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/terra-money/core/v2/app/config"
)

func RegisterDenomsConfig() {
// sdk.RegisterDenom(config.Luna, sdk.OneDec())
// sdk.RegisterDenom(config.MilliLuna, sdk.NewDecWithPrec(1, 3))
sdk.RegisterDenom(config.MicroLuna, sdk.NewDecWithPrec(1, 6))
emidev98 marked this conversation as resolved.
Show resolved Hide resolved
// sdk.RegisterDenom(config.NanoLuna, sdk.NewDecWithPrec(1, 9))
}
2 changes: 1 addition & 1 deletion client/docs/statik/statik.go

Large diffs are not rendered by default.

18 changes: 16 additions & 2 deletions client/docs/swagger-ui/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,11 @@ paths:
summary: >-
Query a delegation to an alliance by delegator addr, validator_addr and
denom

@deprecated: this endpoint will be replaced for by the encoded version

of the denom e.g.:
GET:/terra/alliances/terradr1231/terravaloper41234/ibc%2Falliance
operationId: IBCAllianceDelegation
responses:
'200':
Expand Down Expand Up @@ -1045,7 +1050,10 @@ paths:
- Query
/terra/alliances/ibc/{hash}:
get:
summary: Query a specific alliance by ibc hash
summary: |-
Query a specific alliance by ibc hash
@deprecated: this endpoint will be replaced for by the encoded version
of the denom e.g.: GET:/terra/alliances/ibc%2Falliance
operationId: IBCAlliance
responses:
'200':
Expand Down Expand Up @@ -1186,7 +1194,13 @@ paths:
- Query
/terra/alliances/rewards/{delegator_addr}/{validator_addr}/ibc/{hash}:
get:
summary: Query for rewards by delegator addr, validator_addr and denom
summary: >-
Query for rewards by delegator addr, validator_addr and denom

@deprecated: this endpoint will be replaced for by the encoded version

of the denom e.g.:
GET:/terra/alliances/terradr1231/terravaloper41234/ibc%2Falliance
operationId: IBCAllianceDelegationRewards
responses:
'200':
Expand Down
19 changes: 2 additions & 17 deletions cmd/terrad/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/tendermint/tendermint/libs/log"
dbm "github.com/tendermint/tm-db"

wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
sdkconfig "github.com/cosmos/cosmos-sdk/client/config"
Expand All @@ -35,7 +34,6 @@ import (
tmcfg "github.com/tendermint/tendermint/config"

terraapp "github.com/terra-money/core/v2/app"
config "github.com/terra-money/core/v2/app/config"
"github.com/terra-money/core/v2/app/params"
"github.com/terra-money/core/v2/app/wasmconfig"
)
Expand All @@ -47,21 +45,8 @@ const flagIAVLCacheSize = "iavl-cache-size"
// main function.
func NewRootCmd() (*cobra.Command, params.EncodingConfig) {
encodingConfig := terraapp.MakeEncodingConfig()

sdkConfig := sdk.GetConfig()
sdkConfig.SetCoinType(config.CoinType)

accountPubKeyPrefix := config.AccountAddressPrefix + "pub"
validatorAddressPrefix := config.AccountAddressPrefix + "valoper"
validatorPubKeyPrefix := config.AccountAddressPrefix + "valoperpub"
consNodeAddressPrefix := config.AccountAddressPrefix + "valcons"
consNodePubKeyPrefix := config.AccountAddressPrefix + "valconspub"

sdkConfig.SetBech32PrefixForAccount(config.AccountAddressPrefix, accountPubKeyPrefix)
sdkConfig.SetBech32PrefixForValidator(validatorAddressPrefix, validatorPubKeyPrefix)
sdkConfig.SetBech32PrefixForConsensusNode(consNodeAddressPrefix, consNodePubKeyPrefix)
sdkConfig.SetAddressVerifier(wasmtypes.VerifyAddressLen())
sdkConfig.Seal()
params.RegisterDenomsConfig()
params.RegisterAddressesConfig()

initClientCtx := client.Context{}.
WithCodec(encodingConfig.Marshaler).
Expand Down