Skip to content

Commit

Permalink
add coin type, update app to use it
Browse files Browse the repository at this point in the history
  • Loading branch information
jiujiteiro committed Mar 3, 2023
1 parent 75f19ff commit fffc39c
Show file tree
Hide file tree
Showing 3 changed files with 225 additions and 1 deletion.
174 changes: 174 additions & 0 deletions .protolint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
---
# Lint directives.
lint:
# # Linter files to ignore.
# ignores:
# - id: MESSAGE_NAMES_UPPER_CAMEL_CASE
# files:
# # NOTE: UNIX paths will be properly accepted by both UNIX and Windows.
# - _example/proto/simple.proto
# - id: ENUM_NAMES_UPPER_CAMEL_CASE
# files:
# - path/to/foo.proto

# # Linter files to walk.
# files:
# # The specific files to exclude.
# exclude:
# # NOTE: UNIX paths will be properly accepted by both UNIX and Windows.
# - path/to/file

# # Linter directories to walk.
# directories:
# # The specific directories to exclude.
# exclude:
# # NOTE: UNIX paths will be properly accepted by both UNIX and Windows.
# - path/to/dir

# Linter rules.
# Run `protolint list` to see all available rules.
rules:
# Determines whether or not to include the default set of linters.
no_default: true

# Set the default to all linters. This option works the other way around as no_default does.
# If you want to enable this option, delete the comment out below and no_default.
# all_default: true

# The specific linters to add.
add:
- FIELD_NAMES_LOWER_SNAKE_CASE
- MESSAGE_NAMES_UPPER_CAMEL_CASE
- MAX_LINE_LENGTH
- INDENT
# - SERVICE_NAMES_END_WITH
- FIELD_NAMES_EXCLUDE_PREPOSITIONS
- MESSAGE_NAMES_EXCLUDE_PREPOSITIONS
- FILE_NAMES_LOWER_SNAKE_CASE
- IMPORTS_SORTED
- PACKAGE_NAME_LOWER_CASE
- ORDER
- MESSAGES_HAVE_COMMENT
- SERVICES_HAVE_COMMENT
- RPCS_HAVE_COMMENT
- FIELDS_HAVE_COMMENT
- PROTO3_FIELDS_AVOID_REQUIRED
- PROTO3_GROUPS_AVOID
# - REPEATED_FIELD_NAMES_PLURALIZED
- ENUMS_HAVE_COMMENT
- ENUM_FIELDS_HAVE_COMMENT
- SYNTAX_CONSISTENT
- RPC_NAMES_UPPER_CAMEL_CASE
# - FILE_HAS_COMMENT
- QUOTE_CONSISTENT

# # The specific linters to remove.
# remove:
# - RPC_NAMES_UPPER_CAMEL_CASE

# Linter rules option.
rules_option:
# MAX_LINE_LENGTH rule option.
max_line_length:
# Enforces a maximum line length
max_chars: 120
# Specifies the character count for tab characters
tab_chars: 2

# INDENT rule option.
indent:
# Available styles are 4(4-spaces), 2(2-spaces) or tab.
style: 2
# Specifies if it should stop considering and inserting new lines at the appropriate positions
# when the inner elements are on the same line. Default is false.
not_insert_newline: true

# # FILE_NAMES_LOWER_SNAKE_CASE rule option.
# file_names_lower_snake_case:
# excludes:
# - ../proto/invalidFileName.proto

# QUOTE_CONSISTENT rule option.
quote_consistent:
# Available quote are "double" or "single".
quote: double

# ENUM_FIELD_NAMES_ZERO_VALUE_END_WITH rule option.
enum_field_names_zero_value_end_with:
suffix: INVALID

# # SERVICE_NAMES_END_WITH rule option.
# service_names_end_with:
# text: Service

# FIELD_NAMES_EXCLUDE_PREPOSITIONS rule option.
field_names_exclude_prepositions:
# The specific prepositions to determine if the field name includes.
prepositions:
- for
- at
- of
# The specific keywords including prepositions to ignore. E.g. end_of_support is a term you would like to use, and skip checking.
excludes:
- duration_of_decay

# # REPEATED_FIELD_NAMES_PLURALIZED rule option.
# ## The spec for each rules follows the implementation of https://github.com/gertd/go-pluralize.
# ## Plus, you can refer to this rule's test code.
# repeated_field_names_pluralized:
# uncountable_rules:
# - paper
# irregular_rules:
# Irregular: Regular

# MESSAGE_NAMES_EXCLUDE_PREPOSITIONS rule option.
message_names_exclude_prepositions:
# The specific prepositions to determine if the message name includes.
prepositions:
- With
- For
- Of
# # The specific keywords including prepositions to ignore. E.g. EndOfSupport is a term you would like to use, and skip checking.
# excludes:
# - EndOfSupport

# # RPC_NAMES_CASE rule option.
# rpc_names_case:
# # The specific convention the name should conforms to.
# ## Available conventions are "lower_camel_case", "upper_snake_case", or "lower_snake_case".
# convention: upper_snake_case

# MESSAGES_HAVE_COMMENT rule option.
messages_have_comment:
# Comments need to begin with the name of the thing being described. default is false.
should_follow_golang_style: true

# SERVICES_HAVE_COMMENT rule option.
services_have_comment:
# Comments need to begin with the name of the thing being described. default is false.
should_follow_golang_style: true

# RPCS_HAVE_COMMENT rule option.
rpcs_have_comment:
# Comments need to begin with the name of the thing being described. default is false.
should_follow_golang_style: true

# FIELDS_HAVE_COMMENT rule option.
fields_have_comment:
# Comments need to begin with the name of the thing being described. default is false.
should_follow_golang_style: true

# ENUMS_HAVE_COMMENT rule option.
enums_have_comment:
# Comments need to begin with the name of the thing being described. default is false.
should_follow_golang_style: true

# ENUM_FIELDS_HAVE_COMMENT rule option.
enum_fields_have_comment:
# Comments need to begin with the name of the thing being described. default is false.
should_follow_golang_style: true

# # SYNTAX_CONSISTENT rule option.
# syntax_consistent:
# # Default is proto3.
# version: proto2
4 changes: 3 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ import (
assetmodulekeeper "github.com/realiotech/realio-network/x/asset/keeper"
assetmoduletypes "github.com/realiotech/realio-network/x/asset/types"

realionetworktypes "github.com/realiotech/realio-network/types"

// unnamed import of statik for swagger UI support
_ "github.com/realiotech/realio-network/client/docs/statik"
// this line is used by starport scaffolding # stargate/app/moduleImport
Expand Down Expand Up @@ -194,7 +196,7 @@ func init() {
DefaultNodeHome = filepath.Join(userHomeDir, "."+Name)

// manually update the power reduction by replacing micro (u) -> atto (a) rio
sdk.DefaultPowerReduction = ethermint.PowerReduction
sdk.DefaultPowerReduction = realionetworktypes.PowerReduction
}

// RealioNetwork extends an ABCI application, but with most of its parameters exported.
Expand Down
48 changes: 48 additions & 0 deletions types/coin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package types

import (
"math/big"

sdkmath "cosmossdk.io/math"

sdk "github.com/cosmos/cosmos-sdk/types"
)

const (
// AttoRio defines the default coin denomination used in RealioNetwork in:
//
// - Staking parameters: denomination used as stake in the dPoS chain
// - Mint parameters: denomination minted due to fee distribution rewards
// - Governance parameters: denomination used for spam prevention in proposal deposits
// - Crisis parameters: constant fee denomination used for spam prevention to check broken invariant
// - EVM parameters: denomination used for running EVM state transitions in RealioNetwork.
AttoRio string = "ario"

// BaseDenomUnit defines the base denomination unit for RealioNetwork.
// 1 rio = 1x10^{BaseDenomUnit} ario
BaseDenomUnit = 18

// DefaultGasPrice is default gas price for evm transactions
DefaultGasPrice = 20
)

// PowerReduction defines the default power reduction value for staking
var PowerReduction = sdkmath.NewIntFromBigInt(new(big.Int).Exp(big.NewInt(10), big.NewInt(BaseDenomUnit), nil))

// NewRioCoin is a utility function that returns an "ario" coin with the given sdkmath.Int amount.
// The function will panic if the provided amount is negative.
func NewRioCoin(amount sdkmath.Int) sdk.Coin {
return sdk.NewCoin(AttoRio, amount)
}

// NewRioDecCoin is a utility function that returns an "ario" decimal coin with the given sdkmath.Int amount.
// The function will panic if the provided amount is negative.
func NewRioDecCoin(amount sdkmath.Int) sdk.DecCoin {
return sdk.NewDecCoin(AttoRio, amount)
}

// NewRioCoinInt64 is a utility function that returns an "ario" coin with the given int64 amount.
// The function will panic if the provided amount is negative.
func NewRioCoinInt64(amount int64) sdk.Coin {
return sdk.NewInt64Coin(AttoRio, amount)
}

0 comments on commit fffc39c

Please sign in to comment.