diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..a703301c --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,55 @@ +name: Lint + +on: + pull_request: + branches: + - "**" + workflow_dispatch: + +permissions: + contents: read + # Optional: allow read access to pull request. Use with `only-new-issues` option. + # pull-requests: read + +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v4 + with: + go-version: '1.21' + cache: false + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + # Require: The version of golangci-lint to use. + # When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version. + # When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit. + version: v1.55 + + # Optional: working directory, useful for monorepos + # working-directory: somedir + + # Optional: golangci-lint command line arguments. + # + # Note: By default, the `.golangci.yml` file should be at the root of the repository. + # The location of the configuration file can be changed by using `--config=` + # args: --timeout=30m --config=/my/path/.golangci.yml --issues-exit-code=0 + + # Optional: show only new issues if it's a pull request. The default value is `false`. + # only-new-issues: true + + # Optional: if set to true, then all caching functionality will be completely disabled, + # takes precedence over all other caching options. + # skip-cache: true + + # Optional: if set to true, then the action won't cache or restore ~/go/pkg. + # skip-pkg-cache: true + + # Optional: if set to true, then the action won't cache or restore ~/.cache/go-build. + # skip-build-cache: true + + # Optional: The mode to install golangci-lint. It can be 'binary' or 'goinstall'. + # install-mode: "goinstall" diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 00000000..7bddf558 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,34 @@ +run: + tests: true + # timeout for analysis, e.g. 30s, 5m, default is 1m + timeout: 5m + +linters: + disable-all: true + enable: + - errcheck + - misspell + - gosimple + - govet + - gci + +linters-settings: + gci: + # Section configuration to compare against. + # Section names are case-insensitive and may contain parameters in (). + # The default order of sections is `standard > default > custom > blank > dot`, + # If `custom-order` is `true`, it follows the order of `sections` option. + # Default: ["standard", "default"] + sections: + - standard # Standard section: captures all standard packages. + - default # Default section: contains all imports that could not be matched to another section type. + - prefix(github.com/mycel-domain/mycel) # Custom section: groups all imports with the specified Prefix. + - blank # Blank section: contains all blank imports. This section is not present unless explicitly enabled. + - dot # Dot section: contains all dot imports. This section is not present unless explicitly enabled. + # Skip generated files. + # Default: true + skip-generated: false + # Enable custom order of sections. + # If `true`, make the section order the same as the order of `sections`. + # Default: false + custom-order: true diff --git a/Makefile b/Makefile index 72fe2f6c..136d1293 100644 --- a/Makefile +++ b/Makefile @@ -2,14 +2,7 @@ CONTAINER_NAME := mycel_i DOCKERFILE := ./dockerfile-build DOCKER_RUN_CMD := docker run --rm -it -v $(shell pwd):/mycel -w /mycel -p 1317:1317 -p 3000:3000 -p 4500:4500 -p 5000:5000 -p 26657:26657 --name mycel $(CONTAINER_NAME) -test-all-module: - go test ./x/.../ -test-all-keepers: - go test ./x/.../keeper -test-all-types: - go test ./x/.../types -test-module-%: - go test ./x/$*/.../ +## Build docker-build: docker build -t $(CONTAINER_NAME) -f $(DOCKERFILE) . docker-run: @@ -18,3 +11,35 @@ serve: $(DOCKER_RUN_CMD) ignite chain serve -r build: $(DOCKER_RUN_CMD) ignite chain build + +## Test +test-all-module: + go test ./x/.../ +test-all-keepers: + go test ./x/.../keeper +test-all-types: + go test ./x/.../types +test-module-%: + go test ./x/$*/.../ + + +## Lint +golangci_lint_cmd=golangci-lint +golangci_version=v1.55.2 + +lint: + @echo "--> Running linter" + @go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(golangci_version) + @$(golangci_lint_cmd) run --timeout=10m + +lint-fix: + @echo "--> Running linter" + @go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(golangci_version) + @$(golangci_lint_cmd) run --fix --out-format=tab --issues-exit-code=0 + +format: + @go install mvdan.cc/gofumpt@latest + @go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(golangci_version) + find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -path "./tests/mocks/*" -not -name "*.pb.go" -not -name "*.pb.gw.go" -not -name "*.pulsar.go" -not -path "./crypto/keys/secp256k1/*" | xargs gofumpt -w -l + $(golangci_lint_cmd) run --fix +.PHONY: format diff --git a/app/ante.go b/app/ante.go index 844d2bdc..b134d7e0 100644 --- a/app/ante.go +++ b/app/ante.go @@ -1,18 +1,15 @@ package app import ( - ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante" - "github.com/cosmos/ibc-go/v7/modules/core/keeper" - errorsmod "cosmossdk.io/errors" - + wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" + wasmTypes "github.com/CosmWasm/wasmd/x/wasm/types" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/auth/ante" - - wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" - wasmTypes "github.com/CosmWasm/wasmd/x/wasm/types" + ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante" + "github.com/cosmos/ibc-go/v7/modules/core/keeper" ) // HandlerOptions extend the SDK's AnteHandler options by requiring the IBC diff --git a/app/app.go b/app/app.go index 81c73b68..f021f88b 100644 --- a/app/app.go +++ b/app/app.go @@ -10,6 +10,10 @@ import ( autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1" + // CosmWasm + "github.com/CosmWasm/wasmd/x/wasm" + wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" dbm "github.com/cometbft/cometbft-db" abci "github.com/cometbft/cometbft/abci/types" "github.com/cometbft/cometbft/libs/log" @@ -111,31 +115,22 @@ import ( ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" "github.com/spf13/cast" - // CosmWasm - "github.com/CosmWasm/wasmd/x/wasm" - wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" - wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" - - // Registry - registrymodule "github.com/mycel-domain/mycel/x/registry" - registrymodulekeeper "github.com/mycel-domain/mycel/x/registry/keeper" - registrymoduletypes "github.com/mycel-domain/mycel/x/registry/types" - + appparams "github.com/mycel-domain/mycel/app/params" + "github.com/mycel-domain/mycel/docs" // Epochs epochsmodule "github.com/mycel-domain/mycel/x/epochs" epochsmodulekeeper "github.com/mycel-domain/mycel/x/epochs/keeper" epochsmoduletypes "github.com/mycel-domain/mycel/x/epochs/types" - furnacemodule "github.com/mycel-domain/mycel/x/furnace" furnacemodulekeeper "github.com/mycel-domain/mycel/x/furnace/keeper" furnacemoduletypes "github.com/mycel-domain/mycel/x/furnace/types" + // Registry + registrymodule "github.com/mycel-domain/mycel/x/registry" + registrymodulekeeper "github.com/mycel-domain/mycel/x/registry/keeper" + registrymoduletypes "github.com/mycel-domain/mycel/x/registry/types" resolvermodule "github.com/mycel-domain/mycel/x/resolver" resolvermodulekeeper "github.com/mycel-domain/mycel/x/resolver/keeper" resolvermoduletypes "github.com/mycel-domain/mycel/x/resolver/types" - // this line is used by starport scaffolding # stargate/app/moduleImport - - appparams "github.com/mycel-domain/mycel/app/params" - "github.com/mycel-domain/mycel/docs" ) const ( @@ -327,7 +322,7 @@ type App struct { RegistryKeeper registrymodulekeeper.Keeper EpochsKeeper epochsmodulekeeper.Keeper ResolverKeeper resolvermodulekeeper.Keeper - FurnaceKeeper furnacemodulekeeper.Keeper + FurnaceKeeper furnacemodulekeeper.Keeper // this line is used by starport scaffolding # stargate/app/keeperDeclaration // mm is the module manager diff --git a/app/params/config.go b/app/params/config.go index 869283b1..e11accda 100644 --- a/app/params/config.go +++ b/app/params/config.go @@ -16,7 +16,7 @@ const ( Bech32PrefixAccAddr = "mycel" - OneYearInDays = 365 + OneYearInDays = 365 ) var ( diff --git a/app/test_helpers.go b/app/test_helpers.go index 9e669b06..c196fba6 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -4,17 +4,14 @@ import ( "encoding/json" "testing" + "cosmossdk.io/math" + wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" dbm "github.com/cometbft/cometbft-db" abci "github.com/cometbft/cometbft/abci/types" "github.com/cometbft/cometbft/libs/log" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" tmtypes "github.com/cometbft/cometbft/types" - "github.com/stretchr/testify/require" - - "cosmossdk.io/math" - - wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" - wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/server" @@ -25,6 +22,7 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + "github.com/stretchr/testify/require" ) // SetupOptions defines arguments that are passed into `Simapp` constructor. diff --git a/buf.yaml b/buf.yaml new file mode 100644 index 00000000..1a519456 --- /dev/null +++ b/buf.yaml @@ -0,0 +1,7 @@ +version: v1 +breaking: + use: + - FILE +lint: + use: + - DEFAULT diff --git a/cmd/myceld/cmd/root.go b/cmd/myceld/cmd/root.go index eabb16b0..1f703c4e 100644 --- a/cmd/myceld/cmd/root.go +++ b/cmd/myceld/cmd/root.go @@ -3,14 +3,18 @@ package cmd import ( "errors" "io" + "log" "os" "path/filepath" "strings" + // CosmWasm + wasmcli "github.com/CosmWasm/wasmd/x/wasm/client/cli" + wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" dbm "github.com/cometbft/cometbft-db" tmcfg "github.com/cometbft/cometbft/config" tmcli "github.com/cometbft/cometbft/libs/cli" - "github.com/cometbft/cometbft/libs/log" + tmlog "github.com/cometbft/cometbft/libs/log" tmtypes "github.com/cometbft/cometbft/types" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" @@ -38,12 +42,6 @@ import ( "github.com/spf13/cobra" "github.com/spf13/pflag" - // this line is used by starport scaffolding # root/moduleImport - - // CosmWasm - wasmcli "github.com/CosmWasm/wasmd/x/wasm/client/cli" - wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" - "github.com/mycel-domain/mycel/app" appparams "github.com/mycel-domain/mycel/app/params" "github.com/mycel-domain/mycel/cmd/myceld/dns" @@ -224,7 +222,10 @@ func overwriteFlagDefaults(c *cobra.Command, defaults map[string]string) { set := func(s *pflag.FlagSet, key, val string) { if f := s.Lookup(key); f != nil { f.DefValue = val - f.Value.Set(val) + err := f.Value.Set(val) + if err != nil { + log.Printf("%v", err) + } } } for key, val := range defaults { @@ -242,7 +243,7 @@ type appCreator struct { // newApp creates a new Cosmos SDK app func (a appCreator) newApp( - logger log.Logger, + logger tmlog.Logger, db dbm.DB, traceStore io.Writer, appOpts servertypes.AppOptions, @@ -324,7 +325,7 @@ func (a appCreator) newApp( // appExport creates a new simapp (optionally at a given height) func (a appCreator) appExport( - logger log.Logger, + logger tmlog.Logger, db dbm.DB, traceStore io.Writer, height int64, diff --git a/cmd/myceld/dns/dns.go b/cmd/myceld/dns/dns.go index 1b123d05..6c79df76 100644 --- a/cmd/myceld/dns/dns.go +++ b/cmd/myceld/dns/dns.go @@ -8,10 +8,10 @@ import ( "strings" "github.com/miekg/dns" - resolver "github.com/mycel-domain/mycel/x/resolver/types" + "github.com/spf13/cobra" "google.golang.org/grpc" - "github.com/spf13/cobra" + resolver "github.com/mycel-domain/mycel/x/resolver/types" ) type grpcService struct { @@ -193,7 +193,10 @@ func (s *grpcService) HandleDNSRequest(w dns.ResponseWriter, r *dns.Msg) { msg.SetRcode(r, dns.RcodeNameError) } - w.WriteMsg(&msg) + err := w.WriteMsg(&msg) + if err != nil { + log.Printf("Failed to write message: %v", err) + } } func RunDnsServer(nodeAddress string, listenPort int) error { diff --git a/docs/docs.go b/docs/docs.go index 1ba96c79..7815a93f 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -29,12 +29,15 @@ func handler(title string) http.HandlerFunc { t, _ := httptemplate.ParseFS(template, indexFile) return func(w http.ResponseWriter, req *http.Request) { - t.Execute(w, struct { + err := t.Execute(w, struct { Title string URL string }{ title, apiFile, }) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + } } } diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index 37ec88c8..993e92a8 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -50200,62 +50200,31 @@ paths: schema: type: object properties: + isRegstrable: + type: boolean fee: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: type: array items: type: object properties: - '@type': + denom: type: string - additionalProperties: {} - parameters: - - name: name - in: path - required: true - type: string - - name: parent - in: path - required: true - type: string - tags: - - Query - /mycel-domain/mycel/registry/is_registrable_domain/{name}/{parent}: - get: - summary: Queries a list of IsRegistrableDomain items. - operationId: MycelRegistryIsRegistrableDomain - responses: - '200': - description: A successful response. - schema: - type: object - properties: - isRegstrable: - type: boolean + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. + registrationPeriodInYear: + type: string + format: uint64 + maxSubDomainRegistrations: + type: string + format: uint64 errorMessage: type: string default: @@ -50285,6 +50254,11 @@ paths: in: path required: true type: string + - name: registrationPeriodInYear + in: query + required: false + type: string + format: uint64 tags: - Query /mycel-domain/mycel/registry/top_level_domain: @@ -50305,7 +50279,7 @@ paths: type: string expirationDate: type: string - format: int64 + format: date-time metadata: type: object additionalProperties: @@ -50533,7 +50507,7 @@ paths: type: string expirationDate: type: string - format: int64 + format: date-time metadata: type: object additionalProperties: @@ -50726,7 +50700,7 @@ paths: type: string expirationDate: type: string - format: int64 + format: date-time pagination: type: object properties: @@ -50851,7 +50825,7 @@ paths: type: string expirationDate: type: string - format: int64 + format: date-time default: description: An unexpected error response. schema: @@ -81185,10 +81159,340 @@ definitions: NOTE: The amount field is an Int which implements the custom method signatures required by gogoproto. + mycel.registry.MsgExtendTopLevelDomainExpirationDateResponse: + type: object + properties: + topLevelDomain: + type: object + properties: + name: + type: string + expirationDate: + type: string + format: date-time + metadata: + type: object + additionalProperties: + type: string + subdomainConfig: + type: object + properties: + maxSubdomainRegistrations: + type: string + format: uint64 + subdomainRegistrationFees: + type: object + properties: + feeByLength: + type: object + additionalProperties: + type: object + properties: + isRegistrable: + type: boolean + fee: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an + amount. + + + NOTE: The amount field is an Int which implements + the custom method + + signatures required by gogoproto. + feeByName: + type: object + additionalProperties: + type: object + properties: + isRegistrable: + type: boolean + fee: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an + amount. + + + NOTE: The amount field is an Int which implements + the custom method + + signatures required by gogoproto. + defaultFee: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the + custom method + + signatures required by gogoproto. + subdomainCount: + type: string + format: uint64 + accessControl: + type: object + additionalProperties: + type: string + enum: + - NO_ROLE + - OWNER + - EDITOR + default: NO_ROLE + totalWithdrawalAmount: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. + fee: + type: object + properties: + totalFee: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. + burnWeight: + type: string + feeToBurn: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. + feeToTreasury: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. mycel.registry.MsgRegisterSecondLevelDomainResponse: type: object mycel.registry.MsgRegisterTopLevelDomainResponse: type: object + properties: + topLevelDomain: + type: object + properties: + name: + type: string + expirationDate: + type: string + format: date-time + metadata: + type: object + additionalProperties: + type: string + subdomainConfig: + type: object + properties: + maxSubdomainRegistrations: + type: string + format: uint64 + subdomainRegistrationFees: + type: object + properties: + feeByLength: + type: object + additionalProperties: + type: object + properties: + isRegistrable: + type: boolean + fee: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an + amount. + + + NOTE: The amount field is an Int which implements + the custom method + + signatures required by gogoproto. + feeByName: + type: object + additionalProperties: + type: object + properties: + isRegistrable: + type: boolean + fee: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an + amount. + + + NOTE: The amount field is an Int which implements + the custom method + + signatures required by gogoproto. + defaultFee: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the + custom method + + signatures required by gogoproto. + subdomainCount: + type: string + format: uint64 + accessControl: + type: object + additionalProperties: + type: string + enum: + - NO_ROLE + - OWNER + - EDITOR + default: NO_ROLE + totalWithdrawalAmount: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. + fee: + type: object + properties: + totalFee: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. + burnWeight: + type: string + feeToBurn: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. + feeToTreasury: + type: object + properties: + denom: + type: string + amount: + type: string + description: >- + Coin defines a token with a denomination and an amount. + + + NOTE: The amount field is an Int which implements the custom + method + + signatures required by gogoproto. mycel.registry.MsgUpdateDnsRecordResponse: type: object mycel.registry.MsgUpdateWalletRecordResponse: @@ -81286,7 +81590,7 @@ definitions: type: string expirationDate: type: string - format: int64 + format: date-time pagination: type: object properties: @@ -81325,7 +81629,7 @@ definitions: type: string expirationDate: type: string - format: int64 + format: date-time metadata: type: object additionalProperties: @@ -81458,18 +81762,30 @@ definitions: mycel.registry.QueryDomainRegistrationFeeResponse: type: object properties: + isRegstrable: + type: boolean fee: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. + registrationPeriodInYear: + type: string + format: uint64 + maxSubDomainRegistrations: + type: string + format: uint64 + errorMessage: + type: string mycel.registry.QueryGetDomainOwnershipResponse: type: object properties: @@ -81499,7 +81815,7 @@ definitions: type: string expirationDate: type: string - format: int64 + format: date-time mycel.registry.QueryGetTopLevelDomainResponse: type: object properties: @@ -81510,7 +81826,7 @@ definitions: type: string expirationDate: type: string - format: int64 + format: date-time metadata: type: object additionalProperties: @@ -81614,13 +81930,6 @@ definitions: method signatures required by gogoproto. - mycel.registry.QueryIsRegistrableDomainResponse: - type: object - properties: - isRegstrable: - type: boolean - errorMessage: - type: string mycel.registry.QueryParamsResponse: type: object properties: @@ -81644,7 +81953,7 @@ definitions: type: string expirationDate: type: string - format: int64 + format: date-time mycel.registry.SubdomainConfig: type: object properties: @@ -81779,7 +82088,7 @@ definitions: type: string expirationDate: type: string - format: int64 + format: date-time metadata: type: object additionalProperties: @@ -81878,6 +82187,49 @@ definitions: NOTE: The amount field is an Int which implements the custom method signatures required by gogoproto. + mycel.registry.TopLevelDomainFee: + type: object + properties: + totalFee: + type: array + items: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. + burnWeight: + type: string + feeToBurn: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. + feeToTreasury: + type: object + properties: + denom: + type: string + amount: + type: string + description: |- + Coin defines a token with a denomination and an amount. + + NOTE: The amount field is an Int which implements the custom method + signatures required by gogoproto. mycel.registry.DnsRecord: type: object properties: diff --git a/proto/mycel/epochs/epoch_info.proto b/proto/mycel/epochs/epoch_info.proto index 5635f448..1d0a98c8 100644 --- a/proto/mycel/epochs/epoch_info.proto +++ b/proto/mycel/epochs/epoch_info.proto @@ -8,25 +8,24 @@ import "google/protobuf/timestamp.proto"; option go_package = "github.com/mycel-domain/mycel/x/epochs/types"; message EpochInfo { - string identifier = 1; + string identifier = 1; google.protobuf.Timestamp startTime = 2 [ (gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"start_time\"" ]; - google.protobuf.Duration duration = 3[ + google.protobuf.Duration duration = 3 [ (gogoproto.nullable) = false, (gogoproto.stdduration) = true, (gogoproto.jsontag) = "duration,omitempty", (gogoproto.moretags) = "yaml:\"duration\"" - ]; - int64 currentEpoch = 4; - google.protobuf.Timestamp currentEpochStartTime = 5[ + ]; + int64 currentEpoch = 4; + google.protobuf.Timestamp currentEpochStartTime = 5 [ (gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"current_epoch_start_time\"" - ]; - bool epochCountingStarted = 6; - int64 currentEpochStartHeight = 7; + ]; + bool epochCountingStarted = 6; + int64 currentEpochStartHeight = 7; } - diff --git a/proto/mycel/epochs/genesis.proto b/proto/mycel/epochs/genesis.proto index b29ecc79..83d042a4 100644 --- a/proto/mycel/epochs/genesis.proto +++ b/proto/mycel/epochs/genesis.proto @@ -2,8 +2,8 @@ syntax = "proto3"; package mycel.epochs; import "gogoproto/gogo.proto"; -import "mycel/epochs/params.proto"; import "mycel/epochs/epoch_info.proto"; +import "mycel/epochs/params.proto"; option go_package = "github.com/mycel-domain/mycel/x/epochs/types"; @@ -11,4 +11,3 @@ option go_package = "github.com/mycel-domain/mycel/x/epochs/types"; message GenesisState { repeated EpochInfo epochs = 1 [(gogoproto.nullable) = false]; } - diff --git a/proto/mycel/epochs/params.proto b/proto/mycel/epochs/params.proto index 359761d1..70723e5b 100644 --- a/proto/mycel/epochs/params.proto +++ b/proto/mycel/epochs/params.proto @@ -8,5 +8,4 @@ option go_package = "github.com/mycel-domain/mycel/x/epochs/types"; // Params defines the parameters for the module. message Params { option (gogoproto.goproto_stringer) = false; - } diff --git a/proto/mycel/epochs/query.proto b/proto/mycel/epochs/query.proto index add884ab..63b1d77b 100644 --- a/proto/mycel/epochs/query.proto +++ b/proto/mycel/epochs/query.proto @@ -1,40 +1,35 @@ syntax = "proto3"; - package mycel.epochs; +import "cosmos/base/query/v1beta1/pagination.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; -import "cosmos/base/query/v1beta1/pagination.proto"; -import "mycel/epochs/params.proto"; import "mycel/epochs/epoch_info.proto"; +import "mycel/epochs/params.proto"; option go_package = "github.com/mycel-domain/mycel/x/epochs/types"; // Query defines the gRPC querier service. service Query { - // Parameters queries the parameters of the module. - rpc Params (QueryParamsRequest) returns (QueryParamsResponse) { + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { option (google.api.http).get = "/mycel/epochs/params"; - } - + // Queries a list of EpochInfo items. - rpc EpochInfo (QueryGetEpochInfoRequest) returns (QueryGetEpochInfoResponse) { + rpc EpochInfo(QueryGetEpochInfoRequest) returns (QueryGetEpochInfoResponse) { option (google.api.http).get = "/mycel/epochs/epoch_info/{identifier}"; - } - rpc EpochInfoAll (QueryAllEpochInfoRequest) returns (QueryAllEpochInfoResponse) { + rpc EpochInfoAll(QueryAllEpochInfoRequest) returns (QueryAllEpochInfoResponse) { option (google.api.http).get = "/mycel/epochs/epoch_info"; - } } + // QueryParamsRequest is request type for the Query/Params RPC method. message QueryParamsRequest {} // QueryParamsResponse is response type for the Query/Params RPC method. message QueryParamsResponse { - // params holds all the parameters of this module. Params params = 1 [(gogoproto.nullable) = false]; } @@ -52,7 +47,6 @@ message QueryAllEpochInfoRequest { } message QueryAllEpochInfoResponse { - repeated EpochInfo epochInfo = 1 [(gogoproto.nullable) = false]; - cosmos.base.query.v1beta1.PageResponse pagination = 2; + repeated EpochInfo epochInfo = 1 [(gogoproto.nullable) = false]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; } - diff --git a/proto/mycel/epochs/tx.proto b/proto/mycel/epochs/tx.proto index 0af4c662..296243af 100644 --- a/proto/mycel/epochs/tx.proto +++ b/proto/mycel/epochs/tx.proto @@ -4,4 +4,4 @@ package mycel.epochs; option go_package = "github.com/mycel-domain/mycel/x/epochs/types"; // Msg defines the Msg service. -service Msg {} \ No newline at end of file +service Msg {} diff --git a/proto/mycel/furnace/burn_amount.proto b/proto/mycel/furnace/burn_amount.proto index 67b14d55..9cca7c6e 100644 --- a/proto/mycel/furnace/burn_amount.proto +++ b/proto/mycel/furnace/burn_amount.proto @@ -1,16 +1,16 @@ syntax = "proto3"; package mycel.furnace; +import "cosmos/base/v1beta1/coin.proto"; +import "gogoproto/gogo.proto"; + option go_package = "github.com/mycel-domain/mycel/x/furnace/types"; -import "gogoproto/gogo.proto"; -import "cosmos/base/v1beta1/coin.proto"; message BurnAmount { - uint64 index = 1; - bool burnStarted = 2; + uint64 index = 1; + bool burnStarted = 2; uint64 totalEpochs = 3; uint64 currentEpoch = 4; - cosmos.base.v1beta1.Coin totalBurnAmount = 5 [(gogoproto.nullable) = false]; - cosmos.base.v1beta1.Coin cumulativeBurntAmount = 6 [(gogoproto.nullable) = false]; + cosmos.base.v1beta1.Coin totalBurnAmount = 5 [(gogoproto.nullable) = false]; + cosmos.base.v1beta1.Coin cumulativeBurntAmount = 6 [(gogoproto.nullable) = false]; } - diff --git a/proto/mycel/furnace/epoch_burn_config.proto b/proto/mycel/furnace/epoch_burn_config.proto index 3bbcfb43..fffba7a0 100644 --- a/proto/mycel/furnace/epoch_burn_config.proto +++ b/proto/mycel/furnace/epoch_burn_config.proto @@ -1,7 +1,6 @@ syntax = "proto3"; package mycel.furnace; - import "gogoproto/gogo.proto"; import "google/protobuf/duration.proto"; import "google/protobuf/timestamp.proto"; @@ -9,7 +8,7 @@ import "google/protobuf/timestamp.proto"; option go_package = "github.com/mycel-domain/mycel/x/furnace/types"; message EpochBurnConfig { - string epochIdentifier = 1; + string epochIdentifier = 1; uint64 currentBurnAmountIndex = 2; uint64 defaultTotalEpochs = 3; google.protobuf.Timestamp startTime = 4 [ diff --git a/proto/mycel/furnace/genesis.proto b/proto/mycel/furnace/genesis.proto index 3b247ec6..f8e0601c 100644 --- a/proto/mycel/furnace/genesis.proto +++ b/proto/mycel/furnace/genesis.proto @@ -1,18 +1,16 @@ syntax = "proto3"; - package mycel.furnace; import "gogoproto/gogo.proto"; -import "mycel/furnace/params.proto"; -import "mycel/furnace/epoch_burn_config.proto"; import "mycel/furnace/burn_amount.proto"; +import "mycel/furnace/epoch_burn_config.proto"; +import "mycel/furnace/params.proto"; option go_package = "github.com/mycel-domain/mycel/x/furnace/types"; // GenesisState defines the furnace module's genesis state. message GenesisState { - Params params = 1 [(gogoproto.nullable) = false]; - EpochBurnConfig epochBurnConfig = 2 [(gogoproto.nullable) = false]; - repeated BurnAmount burnAmounts = 3 [(gogoproto.nullable) = false]; + Params params = 1 [(gogoproto.nullable) = false]; + EpochBurnConfig epochBurnConfig = 2 [(gogoproto.nullable) = false]; + repeated BurnAmount burnAmounts = 3 [(gogoproto.nullable) = false]; } - diff --git a/proto/mycel/furnace/params.proto b/proto/mycel/furnace/params.proto index 5fbdc34f..668cb7cc 100644 --- a/proto/mycel/furnace/params.proto +++ b/proto/mycel/furnace/params.proto @@ -8,5 +8,4 @@ option go_package = "github.com/mycel-domain/mycel/x/furnace/types"; // Params defines the parameters for the module. message Params { option (gogoproto.goproto_stringer) = false; - } diff --git a/proto/mycel/furnace/query.proto b/proto/mycel/furnace/query.proto index 05f8fa3d..93533168 100644 --- a/proto/mycel/furnace/query.proto +++ b/proto/mycel/furnace/query.proto @@ -1,48 +1,42 @@ syntax = "proto3"; - package mycel.furnace; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "cosmos/base/v1beta1/coin.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; -import "cosmos/base/query/v1beta1/pagination.proto"; -import "mycel/furnace/params.proto"; -import "mycel/furnace/epoch_burn_config.proto"; import "mycel/furnace/burn_amount.proto"; -import "cosmos/base/v1beta1/coin.proto"; +import "mycel/furnace/epoch_burn_config.proto"; +import "mycel/furnace/params.proto"; option go_package = "github.com/mycel-domain/mycel/x/furnace/types"; // Query defines the gRPC querier service. service Query { - // Parameters queries the parameters of the module. - rpc Params (QueryParamsRequest) returns (QueryParamsResponse) { + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { option (google.api.http).get = "/mycel-domain/mycel/furnace/params"; - } - + // Queries a EpochBurnConfig by index. - rpc EpochBurnConfig (QueryGetEpochBurnConfigRequest) returns (QueryGetEpochBurnConfigResponse) { + rpc EpochBurnConfig(QueryGetEpochBurnConfigRequest) returns (QueryGetEpochBurnConfigResponse) { option (google.api.http).get = "/mycel-domain/mycel/furnace/epoch_burn_config"; - } - + // Queries a list of BurnAmount items. - rpc BurnAmount (QueryGetBurnAmountRequest) returns (QueryGetBurnAmountResponse) { + rpc BurnAmount(QueryGetBurnAmountRequest) returns (QueryGetBurnAmountResponse) { option (google.api.http).get = "/mycel-domain/mycel/furnace/burn_amount/{index}"; - } - rpc BurnAmountAll (QueryAllBurnAmountRequest) returns (QueryAllBurnAmountResponse) { + rpc BurnAmountAll(QueryAllBurnAmountRequest) returns (QueryAllBurnAmountResponse) { option (google.api.http).get = "/mycel-domain/mycel/furnace/burn_amount"; - } } + // QueryParamsRequest is request type for the Query/Params RPC method. message QueryParamsRequest {} // QueryParamsResponse is response type for the Query/Params RPC method. message QueryParamsResponse { - // params holds all the parameters of this module. Params params = 1 [(gogoproto.nullable) = false]; } @@ -66,7 +60,6 @@ message QueryAllBurnAmountRequest { } message QueryAllBurnAmountResponse { - repeated BurnAmount burnAmount = 1 [(gogoproto.nullable) = false]; - cosmos.base.query.v1beta1.PageResponse pagination = 2; + repeated BurnAmount burnAmount = 1 [(gogoproto.nullable) = false]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; } - diff --git a/proto/mycel/furnace/tx.proto b/proto/mycel/furnace/tx.proto index 8f2c7dea..220d8237 100644 --- a/proto/mycel/furnace/tx.proto +++ b/proto/mycel/furnace/tx.proto @@ -4,4 +4,4 @@ package mycel.furnace; option go_package = "github.com/mycel-domain/mycel/x/furnace/types"; // Msg defines the Msg service. -service Msg {} \ No newline at end of file +service Msg {} diff --git a/proto/mycel/registry/domain_ownership.proto b/proto/mycel/registry/domain_ownership.proto index 34e5f6bc..baea7772 100644 --- a/proto/mycel/registry/domain_ownership.proto +++ b/proto/mycel/registry/domain_ownership.proto @@ -1,9 +1,10 @@ syntax = "proto3"; package mycel.registry; -option go_package = "github.com/mycel-domain/mycel/x/registry/types"; import "cosmos_proto/cosmos.proto"; +option go_package = "github.com/mycel-domain/mycel/x/registry/types"; + message OwnedDomain { string name = 1; string parent = 2; diff --git a/proto/mycel/registry/genesis.proto b/proto/mycel/registry/genesis.proto index 8b67c43f..2fa17500 100644 --- a/proto/mycel/registry/genesis.proto +++ b/proto/mycel/registry/genesis.proto @@ -1,19 +1,18 @@ syntax = "proto3"; - package mycel.registry; import "gogoproto/gogo.proto"; +import "mycel/registry/domain_ownership.proto"; import "mycel/registry/params.proto"; -import "mycel/registry/top_level_domain.proto"; import "mycel/registry/second_level_domain.proto"; -import "mycel/registry/domain_ownership.proto"; +import "mycel/registry/top_level_domain.proto"; option go_package = "github.com/mycel-domain/mycel/x/registry/types"; // GenesisState defines the registry module's genesis state. message GenesisState { - Params params = 1 [(gogoproto.nullable) = false]; - repeated TopLevelDomain topLevelDomains = 2 [(gogoproto.nullable) = false]; + Params params = 1 [(gogoproto.nullable) = false]; + repeated TopLevelDomain topLevelDomains = 2 [(gogoproto.nullable) = false]; repeated SecondLevelDomain secondLevelDomains = 3 [(gogoproto.nullable) = false]; - repeated DomainOwnership domainOwnerships = 4 [(gogoproto.nullable) = false]; + repeated DomainOwnership domainOwnerships = 4 [(gogoproto.nullable) = false]; } diff --git a/proto/mycel/registry/network_name.proto b/proto/mycel/registry/network_name.proto index 6bff472e..e748ff82 100644 --- a/proto/mycel/registry/network_name.proto +++ b/proto/mycel/registry/network_name.proto @@ -38,24 +38,20 @@ enum NetworkName { //Shardeum // SHARDEUM_MAINNET_ = 20015; // SHARDEUM_TESTNET_ = 20016; - SHARDEUM_BETANET_SPHINX= 20017; + SHARDEUM_BETANET_SPHINX = 20017; // Zetachain // ZETA_MAINNET_MAINNET = 20018; ZETA_TESTNET_ATHENS = 20019; - - // MOVE 3xxxx //Aptos APTOS_MAINNET_MAINNET = 30000; - APTOS_TESTNET_TESTNET = 30001; + APTOS_TESTNET_TESTNET = 30001; // Sui SUI_MAINNET_MAINNET = 30002; - SUI_TESTNET_TESTNET = 30003; + SUI_TESTNET_TESTNET = 30003; // SOLANA 4xxxx SOLANA_MAINNET_MAINNET = 40000; - SOLANA_TESTNET_TESTNET = 40001; + SOLANA_TESTNET_TESTNET = 40001; } - - diff --git a/proto/mycel/registry/query.proto b/proto/mycel/registry/query.proto index ac790da8..e3ddefb0 100644 --- a/proto/mycel/registry/query.proto +++ b/proto/mycel/registry/query.proto @@ -1,75 +1,60 @@ syntax = "proto3"; - package mycel.registry; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "cosmos/base/v1beta1/coin.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; -import "cosmos/base/query/v1beta1/pagination.proto"; +import "google/protobuf/timestamp.proto"; +import "mycel/registry/domain_ownership.proto"; import "mycel/registry/params.proto"; -import "mycel/registry/top_level_domain.proto"; import "mycel/registry/second_level_domain.proto"; -import "mycel/registry/domain_ownership.proto"; -import "cosmos/base/v1beta1/coin.proto"; +import "mycel/registry/top_level_domain.proto"; option go_package = "github.com/mycel-domain/mycel/x/registry/types"; // Query defines the gRPC querier service. service Query { - // Parameters queries the parameters of the module. - rpc Params (QueryParamsRequest) returns (QueryParamsResponse) { + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { option (google.api.http).get = "/mycel/registry/params"; - } // Queries a list of TopLevelDomain items. - rpc TopLevelDomain (QueryGetTopLevelDomainRequest) returns (QueryGetTopLevelDomainResponse) { + rpc TopLevelDomain(QueryGetTopLevelDomainRequest) returns (QueryGetTopLevelDomainResponse) { option (google.api.http).get = "/mycel-domain/mycel/registry/top_level_domain/{name}"; - } - rpc TopLevelDomainAll (QueryAllTopLevelDomainRequest) returns (QueryAllTopLevelDomainResponse) { + rpc TopLevelDomainAll(QueryAllTopLevelDomainRequest) returns (QueryAllTopLevelDomainResponse) { option (google.api.http).get = "/mycel-domain/mycel/registry/top_level_domain"; - } // Queries a list of SecondLevelDomain items. - rpc SecondLevelDomain (QueryGetSecondLevelDomainRequest) returns (QueryGetSecondLevelDomainResponse) { + rpc SecondLevelDomain(QueryGetSecondLevelDomainRequest) returns (QueryGetSecondLevelDomainResponse) { option (google.api.http).get = "/mycel/registry/second_level_domain/{name}/{parent}"; - } - rpc SecondLevelDomainAll (QueryAllSecondLevelDomainRequest) returns (QueryAllSecondLevelDomainResponse) { + rpc SecondLevelDomainAll(QueryAllSecondLevelDomainRequest) returns (QueryAllSecondLevelDomainResponse) { option (google.api.http).get = "/mycel/registry/second_level_domain"; - } // Queries a list of DomainOwnership items. - rpc DomainOwnership (QueryGetDomainOwnershipRequest) returns (QueryGetDomainOwnershipResponse) { + rpc DomainOwnership(QueryGetDomainOwnershipRequest) returns (QueryGetDomainOwnershipResponse) { option (google.api.http).get = "/mycel-domain/mycel/registry/domain_ownership/{owner}"; - } - rpc DomainOwnershipAll (QueryAllDomainOwnershipRequest) returns (QueryAllDomainOwnershipResponse) { + rpc DomainOwnershipAll(QueryAllDomainOwnershipRequest) returns (QueryAllDomainOwnershipResponse) { option (google.api.http).get = "/mycel-domain/mycel/registry/domain_ownership"; - } // Queries a list of DomainRegistrationFee items. - rpc DomainRegistrationFee (QueryDomainRegistrationFeeRequest) returns (QueryDomainRegistrationFeeResponse) { + rpc DomainRegistrationFee(QueryDomainRegistrationFeeRequest) returns (QueryDomainRegistrationFeeResponse) { option (google.api.http).get = "/mycel-domain/mycel/registry/domain_registration_fee/{name}/{parent}"; - - } - - // Queries a list of IsRegistrableDomain items. - rpc IsRegistrableDomain (QueryIsRegistrableDomainRequest) returns (QueryIsRegistrableDomainResponse) { - option (google.api.http).get = "/mycel-domain/mycel/registry/is_registrable_domain/{name}/{parent}"; - } } + // QueryParamsRequest is request type for the Query/Params RPC method. message QueryParamsRequest {} // QueryParamsResponse is response type for the Query/Params RPC method. message QueryParamsResponse { - // params holds all the parameters of this module. Params params = 1 [(gogoproto.nullable) = false]; } @@ -87,19 +72,22 @@ message QueryAllTopLevelDomainRequest { } message QueryAllTopLevelDomainResponse { - repeated TopLevelDomain topLevelDomain = 1 [(gogoproto.nullable) = false]; - cosmos.base.query.v1beta1.PageResponse pagination = 2; + repeated TopLevelDomain topLevelDomain = 1 [(gogoproto.nullable) = false]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; } message QueryGetSecondLevelDomainRequest { - string name = 1; + string name = 1; string parent = 2; } message SecondLevelDomainResponse { - string name = 1; + string name = 1; string parent = 2; - int64 expirationDate = 3; + google.protobuf.Timestamp expirationDate = 3 [ + (gogoproto.stdtime) = true, + (gogoproto.nullable) = false + ]; } message QueryGetSecondLevelDomainResponse { @@ -111,8 +99,8 @@ message QueryAllSecondLevelDomainRequest { } message QueryAllSecondLevelDomainResponse { - repeated SecondLevelDomainResponse secondLevelDomain = 1 [(gogoproto.nullable) = false]; - cosmos.base.query.v1beta1.PageResponse pagination = 2; + repeated SecondLevelDomainResponse secondLevelDomain = 1 [(gogoproto.nullable) = false]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; } message QueryGetDomainOwnershipRequest { @@ -128,26 +116,23 @@ message QueryAllDomainOwnershipRequest { } message QueryAllDomainOwnershipResponse { - repeated DomainOwnership domainOwnership = 1 [(gogoproto.nullable) = false]; - cosmos.base.query.v1beta1.PageResponse pagination = 2; + repeated DomainOwnership domainOwnership = 1 [(gogoproto.nullable) = false]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; } message QueryDomainRegistrationFeeRequest { - string name = 1; + string name = 1; string parent = 2; + uint64 registrationPeriodInYear = 3; } message QueryDomainRegistrationFeeResponse { - cosmos.base.v1beta1.Coin fee = 1 [(gogoproto.nullable) = false]; -} - -message QueryIsRegistrableDomainRequest { - string name = 1; - string parent = 2; -} - -message QueryIsRegistrableDomainResponse { - bool isRegstrable = 1; - string errorMessage = 2; + bool isRegistrable = 1; + repeated cosmos.base.v1beta1.Coin fee = 2 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; + uint64 registrationPeriodInYear = 3; + uint64 maxSubDomainRegistrations = 4; + string errorMessage = 5; } - diff --git a/proto/mycel/registry/role.proto b/proto/mycel/registry/role.proto index f5f51611..ffd63e97 100644 --- a/proto/mycel/registry/role.proto +++ b/proto/mycel/registry/role.proto @@ -7,4 +7,4 @@ enum DomainRole { NO_ROLE = 0; OWNER = 1; EDITOR = 2; -} \ No newline at end of file +} diff --git a/proto/mycel/registry/second_level_domain.proto b/proto/mycel/registry/second_level_domain.proto index 7c3adf50..ed5397ee 100644 --- a/proto/mycel/registry/second_level_domain.proto +++ b/proto/mycel/registry/second_level_domain.proto @@ -1,13 +1,14 @@ syntax = "proto3"; package mycel.registry; +import "gogoproto/gogo.proto"; +import "google/protobuf/timestamp.proto"; import "mycel/registry/dns_record.proto"; import "mycel/registry/network_name.proto"; import "mycel/registry/role.proto"; option go_package = "github.com/mycel-domain/mycel/x/registry/types"; - message DnsRecord { DnsRecordType dnsRecordType = 1; string value = 2; @@ -24,10 +25,10 @@ message Metadata { } message Record { -oneof record { - DnsRecord dnsRecord = 1; - WalletRecord walletRecord = 2; - Metadata metadata = 3; + oneof record { + DnsRecord dnsRecord = 1; + WalletRecord walletRecord = 2; + Metadata metadata = 3; } } @@ -35,7 +36,10 @@ message SecondLevelDomain { string name = 1; string parent = 2; string owner = 3; - int64 expirationDate = 4; + google.protobuf.Timestamp expirationDate = 4 [ + (gogoproto.stdtime) = true, + (gogoproto.nullable) = false + ]; map records = 5; map accessControl = 6; } diff --git a/proto/mycel/registry/subdomain_config.proto b/proto/mycel/registry/subdomain_config.proto index a6cd835f..df8b388e 100644 --- a/proto/mycel/registry/subdomain_config.proto +++ b/proto/mycel/registry/subdomain_config.proto @@ -5,7 +5,6 @@ import "cosmos/base/v1beta1/coin.proto"; option go_package = "github.com/mycel-domain/mycel/x/registry/types"; - message SubdomainRegistrationFees { map feeByLength = 1; map feeByName = 2; diff --git a/proto/mycel/registry/top_level_domain.proto b/proto/mycel/registry/top_level_domain.proto index 039d5e20..7c9e4887 100644 --- a/proto/mycel/registry/top_level_domain.proto +++ b/proto/mycel/registry/top_level_domain.proto @@ -1,16 +1,20 @@ syntax = "proto3"; package mycel.registry; -import "gogoproto/gogo.proto"; import "cosmos/base/v1beta1/coin.proto"; -import "mycel/registry/subdomain_config.proto"; +import "gogoproto/gogo.proto"; +import "google/protobuf/timestamp.proto"; import "mycel/registry/role.proto"; +import "mycel/registry/subdomain_config.proto"; option go_package = "github.com/mycel-domain/mycel/x/registry/types"; message TopLevelDomain { string name = 1; - int64 expirationDate = 2; + google.protobuf.Timestamp expirationDate = 2 [ + (gogoproto.stdtime) = true, + (gogoproto.nullable) = false + ]; map metadata = 3; SubdomainConfig subdomainConfig = 4; uint64 subdomainCount = 5; @@ -20,3 +24,19 @@ message TopLevelDomain { (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" ]; } + +message TopLevelDomainFee { + repeated cosmos.base.v1beta1.Coin totalFee = 1 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; + string burnWeight = 2; + cosmos.base.v1beta1.Coin feeToBurn = 3 [ + (gogoproto.nullable) = false, + (gogoproto.castvalue) = "github.com/cosmos/cosmos-sdk/types.Coin" + ]; + cosmos.base.v1beta1.Coin feeToTreasury = 4 [ + (gogoproto.nullable) = false, + (gogoproto.castvalue) = "github.com/cosmos/cosmos-sdk/types.Coin" + ]; +} diff --git a/proto/mycel/registry/tx.proto b/proto/mycel/registry/tx.proto index 88194e26..da664c24 100644 --- a/proto/mycel/registry/tx.proto +++ b/proto/mycel/registry/tx.proto @@ -1,60 +1,64 @@ syntax = "proto3"; - package mycel.registry; -import "gogoproto/gogo.proto"; import "cosmos/base/v1beta1/coin.proto"; +import "gogoproto/gogo.proto"; +import "mycel/registry/top_level_domain.proto"; option go_package = "github.com/mycel-domain/mycel/x/registry/types"; // Msg defines the Msg service. service Msg { - rpc UpdateWalletRecord (MsgUpdateWalletRecord ) returns (MsgUpdateWalletRecordResponse ); - rpc UpdateDnsRecord (MsgUpdateDnsRecord ) returns (MsgUpdateDnsRecordResponse ); - rpc RegisterSecondLevelDomain (MsgRegisterSecondLevelDomain ) returns (MsgRegisterSecondLevelDomainResponse ); - rpc RegisterTopLevelDomain (MsgRegisterTopLevelDomain ) returns (MsgRegisterTopLevelDomainResponse ); - rpc WithdrawRegistrationFee (MsgWithdrawRegistrationFee) returns (MsgWithdrawRegistrationFeeResponse); + rpc UpdateWalletRecord(MsgUpdateWalletRecord) returns (MsgUpdateWalletRecordResponse); + rpc UpdateDnsRecord(MsgUpdateDnsRecord) returns (MsgUpdateDnsRecordResponse); + rpc RegisterSecondLevelDomain(MsgRegisterSecondLevelDomain) returns (MsgRegisterSecondLevelDomainResponse); + rpc RegisterTopLevelDomain(MsgRegisterTopLevelDomain) returns (MsgRegisterTopLevelDomainResponse); + rpc WithdrawRegistrationFee(MsgWithdrawRegistrationFee) returns (MsgWithdrawRegistrationFeeResponse); + rpc ExtendTopLevelDomainExpirationDate(MsgExtendTopLevelDomainExpirationDate) returns (MsgExtendTopLevelDomainExpirationDateResponse); } message MsgUpdateWalletRecord { - string creator = 1; - string name = 2; - string parent = 3; + string creator = 1; + string name = 2; + string parent = 3; string walletRecordType = 4; - string value = 5; + string value = 5; } message MsgUpdateWalletRecordResponse {} message MsgUpdateDnsRecord { - string creator = 1; - string name = 2; - string parent = 3; + string creator = 1; + string name = 2; + string parent = 3; string dnsRecordType = 4; - string value = 5; + string value = 5; } message MsgUpdateDnsRecordResponse {} message MsgRegisterSecondLevelDomain { - string creator = 1; - string name = 2; - string parent = 3; + string creator = 1; + string name = 2; + string parent = 3; uint64 registrationPeriodInYear = 4; } message MsgRegisterSecondLevelDomainResponse {} message MsgRegisterTopLevelDomain { - string creator = 1; - string name = 2; + string creator = 1; + string name = 2; uint64 registrationPeriodInYear = 3; } -message MsgRegisterTopLevelDomainResponse {} +message MsgRegisterTopLevelDomainResponse { + TopLevelDomain topLevelDomain = 1; + TopLevelDomainFee fee = 2; +} message MsgWithdrawRegistrationFee { string creator = 1; - string name = 2; + string name = 2; } message MsgWithdrawRegistrationFeeResponse { @@ -64,3 +68,13 @@ message MsgWithdrawRegistrationFeeResponse { ]; } +message MsgExtendTopLevelDomainExpirationDate { + string creator = 1; + string name = 2; + uint64 extensionPeriodInYear = 3; +} + +message MsgExtendTopLevelDomainExpirationDateResponse { + TopLevelDomain topLevelDomain = 1; + TopLevelDomainFee fee = 2; +} diff --git a/proto/mycel/resolver/params.proto b/proto/mycel/resolver/params.proto index 62761a99..d651423e 100644 --- a/proto/mycel/resolver/params.proto +++ b/proto/mycel/resolver/params.proto @@ -8,5 +8,4 @@ option go_package = "github.com/mycel-domain/mycel/x/resolver/types"; // Params defines the parameters for the module. message Params { option (gogoproto.goproto_stringer) = false; - } diff --git a/proto/mycel/resolver/query.proto b/proto/mycel/resolver/query.proto index a5e1dcce..d997f682 100644 --- a/proto/mycel/resolver/query.proto +++ b/proto/mycel/resolver/query.proto @@ -1,55 +1,49 @@ syntax = "proto3"; - package mycel.resolver; +import "cosmos/base/query/v1beta1/pagination.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; -import "cosmos/base/query/v1beta1/pagination.proto"; -import "mycel/resolver/params.proto"; import "mycel/registry/second_level_domain.proto"; +import "mycel/resolver/params.proto"; option go_package = "github.com/mycel-domain/mycel/x/resolver/types"; // Query defines the gRPC querier service. service Query { - // Parameters queries the parameters of the module. - rpc Params (QueryParamsRequest) returns (QueryParamsResponse) { + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { option (google.api.http).get = "/mycel-domain/mycel/resolver/params"; - } - + // Queries a list of QueryWalletRecord items. - rpc WalletRecord (QueryWalletRecordRequest) returns (QueryWalletRecordResponse) { + rpc WalletRecord(QueryWalletRecordRequest) returns (QueryWalletRecordResponse) { option (google.api.http).get = "/mycel-domain/mycel/resolver/wallet_record/{domainName}/{domainParent}/{walletRecordType}"; - } - + // Queries a list of DnsRecord items. - rpc DnsRecord (QueryDnsRecordRequest) returns (QueryDnsRecordResponse) { + rpc DnsRecord(QueryDnsRecordRequest) returns (QueryDnsRecordResponse) { option (google.api.http).get = "/mycel-domain/mycel/resolver/dns_record/{domainName}/{domainParent}/{dnsRecordType}"; - } - + // Queries a list of AllRecord items. - rpc AllRecords (QueryAllRecordsRequest) returns (QueryAllRecordsResponse) { + rpc AllRecords(QueryAllRecordsRequest) returns (QueryAllRecordsResponse) { option (google.api.http).get = "/mycel-domain/mycel/resolver/all_records/{domainName}/{domainParent}"; - } } + // QueryParamsRequest is request type for the Query/Params RPC method. message QueryParamsRequest {} // QueryParamsResponse is response type for the Query/Params RPC method. message QueryParamsResponse { - // params holds all the parameters of this module. Params params = 1 [(gogoproto.nullable) = false]; } message QueryWalletRecordRequest { - string domainName = 1; - string domainParent = 2; + string domainName = 1; + string domainParent = 2; string walletRecordType = 3; } @@ -58,8 +52,8 @@ message QueryWalletRecordResponse { } message QueryDnsRecordRequest { - string domainName = 1; - string domainParent = 2; + string domainName = 1; + string domainParent = 2; string dnsRecordType = 3; } @@ -68,11 +62,10 @@ message QueryDnsRecordResponse { } message QueryAllRecordsRequest { - string domainName = 1; + string domainName = 1; string domainParent = 2; } message QueryAllRecordsResponse { map values = 1; } - diff --git a/proto/mycel/resolver/tx.proto b/proto/mycel/resolver/tx.proto index 2cbf8307..15538b84 100644 --- a/proto/mycel/resolver/tx.proto +++ b/proto/mycel/resolver/tx.proto @@ -4,4 +4,4 @@ package mycel.resolver; option go_package = "github.com/mycel-domain/mycel/x/resolver/types"; // Msg defines the Msg service. -service Msg {} \ No newline at end of file +service Msg {} diff --git a/testutil/keeper/epochs.go b/testutil/keeper/epochs.go index 82559d8b..90eb8894 100644 --- a/testutil/keeper/epochs.go +++ b/testutil/keeper/epochs.go @@ -3,9 +3,6 @@ package keeper import ( "testing" - "github.com/mycel-domain/mycel/x/epochs/keeper" - "github.com/mycel-domain/mycel/x/epochs/types" - tmdb "github.com/cometbft/cometbft-db" "github.com/cometbft/cometbft/libs/log" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" @@ -16,6 +13,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" typesparams "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/stretchr/testify/require" + + "github.com/mycel-domain/mycel/x/epochs/keeper" + "github.com/mycel-domain/mycel/x/epochs/types" ) func EpochsKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { diff --git a/testutil/keeper/furnace.go b/testutil/keeper/furnace.go index 219adffa..fbfd1195 100644 --- a/testutil/keeper/furnace.go +++ b/testutil/keeper/furnace.go @@ -12,9 +12,10 @@ import ( storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" typesparams "github.com/cosmos/cosmos-sdk/x/params/types" + "github.com/stretchr/testify/require" + "github.com/mycel-domain/mycel/x/furnace/keeper" "github.com/mycel-domain/mycel/x/furnace/types" - "github.com/stretchr/testify/require" ) func FurnaceKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { diff --git a/testutil/keeper/registry.go b/testutil/keeper/registry.go index 44bd037f..45014df1 100644 --- a/testutil/keeper/registry.go +++ b/testutil/keeper/registry.go @@ -3,9 +3,6 @@ package keeper import ( "testing" - "github.com/mycel-domain/mycel/x/registry/keeper" - "github.com/mycel-domain/mycel/x/registry/types" - tmdb "github.com/cometbft/cometbft-db" "github.com/cometbft/cometbft/libs/log" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" @@ -16,6 +13,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" typesparams "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/stretchr/testify/require" + + "github.com/mycel-domain/mycel/x/registry/keeper" + "github.com/mycel-domain/mycel/x/registry/types" ) func RegistryKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { diff --git a/testutil/keeper/resolver.go b/testutil/keeper/resolver.go index 8f4f9c2a..2684c477 100644 --- a/testutil/keeper/resolver.go +++ b/testutil/keeper/resolver.go @@ -12,9 +12,10 @@ import ( storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" typesparams "github.com/cosmos/cosmos-sdk/x/params/types" + "github.com/stretchr/testify/require" + "github.com/mycel-domain/mycel/x/resolver/keeper" "github.com/mycel-domain/mycel/x/resolver/types" - "github.com/stretchr/testify/require" ) func ResolverKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { diff --git a/testutil/network/network.go b/testutil/network/network.go index 90c25f30..857253e8 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -2,6 +2,9 @@ package network import ( "fmt" + "testing" + "time" + wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" tmdb "github.com/cometbft/cometbft-db" @@ -16,8 +19,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/stretchr/testify/require" - "testing" - "time" "github.com/mycel-domain/mycel/app" ) diff --git a/x/epochs/client/cli/query.go b/x/epochs/client/cli/query.go index 71c4c43b..a22c8504 100644 --- a/x/epochs/client/cli/query.go +++ b/x/epochs/client/cli/query.go @@ -2,13 +2,9 @@ package cli import ( "fmt" - // "strings" - - "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" - // "github.com/cosmos/cosmos-sdk/client/flags" - // sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/spf13/cobra" "github.com/mycel-domain/mycel/x/epochs/types" ) diff --git a/x/epochs/client/cli/query_epoch_info.go b/x/epochs/client/cli/query_epoch_info.go index 7b5001bd..5cd5741b 100644 --- a/x/epochs/client/cli/query_epoch_info.go +++ b/x/epochs/client/cli/query_epoch_info.go @@ -3,11 +3,11 @@ package cli import ( "context" - "github.com/mycel-domain/mycel/x/epochs/types" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/spf13/cobra" + + "github.com/mycel-domain/mycel/x/epochs/types" ) func CmdListEpochInfo() *cobra.Command { diff --git a/x/epochs/client/cli/query_params.go b/x/epochs/client/cli/query_params.go index c1774347..fab7b415 100644 --- a/x/epochs/client/cli/query_params.go +++ b/x/epochs/client/cli/query_params.go @@ -5,8 +5,9 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/mycel-domain/mycel/x/epochs/types" "github.com/spf13/cobra" + + "github.com/mycel-domain/mycel/x/epochs/types" ) func CmdQueryParams() *cobra.Command { diff --git a/x/epochs/client/cli/tx.go b/x/epochs/client/cli/tx.go index 466d3ed9..d2c14f57 100644 --- a/x/epochs/client/cli/tx.go +++ b/x/epochs/client/cli/tx.go @@ -4,9 +4,9 @@ import ( "fmt" "time" + "github.com/cosmos/cosmos-sdk/client" "github.com/spf13/cobra" - "github.com/cosmos/cosmos-sdk/client" // "github.com/cosmos/cosmos-sdk/client/flags" "github.com/mycel-domain/mycel/x/epochs/types" ) diff --git a/x/epochs/genesis.go b/x/epochs/genesis.go index b51e75ca..4760cca8 100644 --- a/x/epochs/genesis.go +++ b/x/epochs/genesis.go @@ -1,11 +1,12 @@ package epochs import ( - "github.com/mycel-domain/mycel/x/epochs/keeper" - "github.com/mycel-domain/mycel/x/epochs/types" "time" sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/mycel-domain/mycel/x/epochs/keeper" + "github.com/mycel-domain/mycel/x/epochs/types" ) // InitGenesis initializes the module's state from a provided genesis state. diff --git a/x/epochs/genesis_test.go b/x/epochs/genesis_test.go index 9174ff60..a154ae0e 100644 --- a/x/epochs/genesis_test.go +++ b/x/epochs/genesis_test.go @@ -3,12 +3,12 @@ package epochs_test import ( "testing" + "github.com/stretchr/testify/require" + keepertest "github.com/mycel-domain/mycel/testutil/keeper" "github.com/mycel-domain/mycel/testutil/nullify" "github.com/mycel-domain/mycel/x/epochs" "github.com/mycel-domain/mycel/x/epochs/types" - - "github.com/stretchr/testify/require" ) func TestGenesis(t *testing.T) { diff --git a/x/epochs/keeper/abci.go b/x/epochs/keeper/abci.go index 1efc253f..1c3237ec 100644 --- a/x/epochs/keeper/abci.go +++ b/x/epochs/keeper/abci.go @@ -4,10 +4,10 @@ import ( "fmt" "time" - "github.com/mycel-domain/mycel/x/epochs/types" - "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/mycel-domain/mycel/x/epochs/types" ) // BeginBlocker of epochs module. diff --git a/x/epochs/keeper/abci_test.go b/x/epochs/keeper/abci_test.go index 1b89063d..d2dd12b1 100644 --- a/x/epochs/keeper/abci_test.go +++ b/x/epochs/keeper/abci_test.go @@ -2,9 +2,10 @@ package keeper_test import ( "fmt" + "time" + "github.com/mycel-domain/mycel/x/epochs" "github.com/mycel-domain/mycel/x/epochs/types" - "time" ) func (suite *KeeperTestSuite) TestEpochInfoChangesBeginBlockerAndInitGenesis() { diff --git a/x/epochs/keeper/epoch_info.go b/x/epochs/keeper/epoch_info.go index 8cd88d37..345e4f8c 100644 --- a/x/epochs/keeper/epoch_info.go +++ b/x/epochs/keeper/epoch_info.go @@ -1,10 +1,10 @@ package keeper import ( - "github.com/mycel-domain/mycel/x/epochs/types" - "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/mycel-domain/mycel/x/epochs/types" ) // SetEpochInfo set a specific epochInfo in the store from its index diff --git a/x/epochs/keeper/epoch_info_test.go b/x/epochs/keeper/epoch_info_test.go index 94c67917..ef599b1e 100644 --- a/x/epochs/keeper/epoch_info_test.go +++ b/x/epochs/keeper/epoch_info_test.go @@ -5,11 +5,12 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + keepertest "github.com/mycel-domain/mycel/testutil/keeper" "github.com/mycel-domain/mycel/testutil/nullify" "github.com/mycel-domain/mycel/x/epochs/keeper" "github.com/mycel-domain/mycel/x/epochs/types" - "github.com/stretchr/testify/require" ) // Prevent strconv unused error diff --git a/x/epochs/keeper/hooks_test.go b/x/epochs/keeper/hooks_test.go index cc788e29..693453fe 100644 --- a/x/epochs/keeper/hooks_test.go +++ b/x/epochs/keeper/hooks_test.go @@ -2,11 +2,13 @@ package keeper_test import ( "fmt" + "strconv" + "time" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/mycel-domain/mycel/testutil" "github.com/mycel-domain/mycel/x/epochs/types" - "strconv" - "time" ) type MockHooks struct{} diff --git a/x/epochs/keeper/msg_server_test.go b/x/epochs/keeper/msg_server_test.go index c23032d8..f0f7cc32 100644 --- a/x/epochs/keeper/msg_server_test.go +++ b/x/epochs/keeper/msg_server_test.go @@ -5,6 +5,7 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" + keepertest "github.com/mycel-domain/mycel/testutil/keeper" "github.com/mycel-domain/mycel/x/epochs/keeper" "github.com/mycel-domain/mycel/x/epochs/types" diff --git a/x/epochs/keeper/params.go b/x/epochs/keeper/params.go index f5136d2c..5f4809cf 100644 --- a/x/epochs/keeper/params.go +++ b/x/epochs/keeper/params.go @@ -2,6 +2,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/mycel-domain/mycel/x/epochs/types" ) diff --git a/x/epochs/keeper/params_test.go b/x/epochs/keeper/params_test.go index 4f400cd9..3f391600 100644 --- a/x/epochs/keeper/params_test.go +++ b/x/epochs/keeper/params_test.go @@ -3,9 +3,10 @@ package keeper_test import ( "testing" + "github.com/stretchr/testify/require" + testkeeper "github.com/mycel-domain/mycel/testutil/keeper" "github.com/mycel-domain/mycel/x/epochs/types" - "github.com/stretchr/testify/require" ) func TestGetParams(t *testing.T) { diff --git a/x/epochs/keeper/query_epoch_info.go b/x/epochs/keeper/query_epoch_info.go index 3969729f..661b8ae7 100644 --- a/x/epochs/keeper/query_epoch_info.go +++ b/x/epochs/keeper/query_epoch_info.go @@ -6,9 +6,10 @@ import ( "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" - "github.com/mycel-domain/mycel/x/epochs/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + + "github.com/mycel-domain/mycel/x/epochs/types" ) func (k Keeper) EpochInfoAll(goCtx context.Context, req *types.QueryAllEpochInfoRequest) (*types.QueryAllEpochInfoResponse, error) { diff --git a/x/epochs/keeper/query_params.go b/x/epochs/keeper/query_params.go index 234aaf15..0476a9d3 100644 --- a/x/epochs/keeper/query_params.go +++ b/x/epochs/keeper/query_params.go @@ -4,9 +4,10 @@ import ( "context" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/mycel-domain/mycel/x/epochs/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + + "github.com/mycel-domain/mycel/x/epochs/types" ) func (k Keeper) Params(goCtx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { diff --git a/x/epochs/keeper/query_params_test.go b/x/epochs/keeper/query_params_test.go index 98154fb0..d11e9860 100644 --- a/x/epochs/keeper/query_params_test.go +++ b/x/epochs/keeper/query_params_test.go @@ -4,9 +4,10 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + testkeeper "github.com/mycel-domain/mycel/testutil/keeper" "github.com/mycel-domain/mycel/x/epochs/types" - "github.com/stretchr/testify/require" ) func TestParamsQuery(t *testing.T) { diff --git a/x/epochs/keeper/setup_test.go b/x/epochs/keeper/setup_test.go index b236b353..2a4c1f9a 100644 --- a/x/epochs/keeper/setup_test.go +++ b/x/epochs/keeper/setup_test.go @@ -1,8 +1,6 @@ package keeper_test import ( - mycelapp "github.com/mycel-domain/mycel/app" - "github.com/mycel-domain/mycel/x/epochs/types" "testing" "time" @@ -10,6 +8,9 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/suite" + + mycelapp "github.com/mycel-domain/mycel/app" + "github.com/mycel-domain/mycel/x/epochs/types" ) type KeeperTestSuite struct { diff --git a/x/epochs/module.go b/x/epochs/module.go index a7c10c26..e7eee1f3 100644 --- a/x/epochs/module.go +++ b/x/epochs/module.go @@ -4,18 +4,17 @@ import ( "context" "encoding/json" "fmt" - // this line is used by starport scaffolding # 1 - - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/spf13/cobra" + "log" abci "github.com/cometbft/cometbft/abci/types" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + "github.com/mycel-domain/mycel/x/epochs/client/cli" "github.com/mycel-domain/mycel/x/epochs/keeper" "github.com/mycel-domain/mycel/x/epochs/types" @@ -70,7 +69,10 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { - types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) + err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) + if err != nil { + log.Printf("%v", err) + } } // GetTxCmd returns the root Tx command for the module. The subcommands of this root command are used by end-users to generate new transactions containing messages defined in the module diff --git a/x/epochs/module_simulation.go b/x/epochs/module_simulation.go index 8bf48de3..fbd65c56 100644 --- a/x/epochs/module_simulation.go +++ b/x/epochs/module_simulation.go @@ -3,15 +3,15 @@ package epochs import ( "math/rand" - "github.com/mycel-domain/mycel/testutil/sample" - epochssimulation "github.com/mycel-domain/mycel/x/epochs/simulation" - "github.com/mycel-domain/mycel/x/epochs/types" - "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/simulation" + + "github.com/mycel-domain/mycel/testutil/sample" + epochssimulation "github.com/mycel-domain/mycel/x/epochs/simulation" + "github.com/mycel-domain/mycel/x/epochs/types" ) // avoid unused import issue diff --git a/x/furnace/client/cli/query.go b/x/furnace/client/cli/query.go index 7fe413de..403ba8d8 100644 --- a/x/furnace/client/cli/query.go +++ b/x/furnace/client/cli/query.go @@ -2,13 +2,9 @@ package cli import ( "fmt" - // "strings" - - "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" - // "github.com/cosmos/cosmos-sdk/client/flags" - // sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/spf13/cobra" "github.com/mycel-domain/mycel/x/furnace/types" ) diff --git a/x/furnace/client/cli/query_burn_amount.go b/x/furnace/client/cli/query_burn_amount.go index 7931eb45..8194a649 100644 --- a/x/furnace/client/cli/query_burn_amount.go +++ b/x/furnace/client/cli/query_burn_amount.go @@ -3,10 +3,10 @@ package cli import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cast" "github.com/spf13/cobra" "github.com/mycel-domain/mycel/x/furnace/types" - "github.com/spf13/cast" ) func CmdListBurnAmount() *cobra.Command { diff --git a/x/furnace/client/cli/tx.go b/x/furnace/client/cli/tx.go index 0e1656f6..524e6d26 100644 --- a/x/furnace/client/cli/tx.go +++ b/x/furnace/client/cli/tx.go @@ -4,9 +4,9 @@ import ( "fmt" "time" + "github.com/cosmos/cosmos-sdk/client" "github.com/spf13/cobra" - "github.com/cosmos/cosmos-sdk/client" // "github.com/cosmos/cosmos-sdk/client/flags" "github.com/mycel-domain/mycel/x/furnace/types" ) diff --git a/x/furnace/genesis.go b/x/furnace/genesis.go index acf2561c..39405fc3 100644 --- a/x/furnace/genesis.go +++ b/x/furnace/genesis.go @@ -2,6 +2,7 @@ package furnace import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/mycel-domain/mycel/x/furnace/keeper" "github.com/mycel-domain/mycel/x/furnace/types" ) diff --git a/x/furnace/genesis_test.go b/x/furnace/genesis_test.go index 3d12ef0a..486a83a3 100644 --- a/x/furnace/genesis_test.go +++ b/x/furnace/genesis_test.go @@ -3,11 +3,12 @@ package furnace_test import ( "testing" + "github.com/stretchr/testify/require" + keepertest "github.com/mycel-domain/mycel/testutil/keeper" "github.com/mycel-domain/mycel/testutil/nullify" "github.com/mycel-domain/mycel/x/furnace" "github.com/mycel-domain/mycel/x/furnace/types" - "github.com/stretchr/testify/require" ) func TestGenesis(t *testing.T) { diff --git a/x/furnace/keeper/burn_amount.go b/x/furnace/keeper/burn_amount.go index cd986056..ed48e2f3 100644 --- a/x/furnace/keeper/burn_amount.go +++ b/x/furnace/keeper/burn_amount.go @@ -4,6 +4,7 @@ import ( errorsmod "cosmossdk.io/errors" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/mycel-domain/mycel/app/params" "github.com/mycel-domain/mycel/x/furnace/types" ) diff --git a/x/furnace/keeper/burn_amount_test.go b/x/furnace/keeper/burn_amount_test.go index 82e37c00..77b859d7 100644 --- a/x/furnace/keeper/burn_amount_test.go +++ b/x/furnace/keeper/burn_amount_test.go @@ -6,12 +6,13 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + "github.com/mycel-domain/mycel/app/params" keepertest "github.com/mycel-domain/mycel/testutil/keeper" "github.com/mycel-domain/mycel/testutil/nullify" "github.com/mycel-domain/mycel/x/furnace/keeper" "github.com/mycel-domain/mycel/x/furnace/types" - "github.com/stretchr/testify/require" ) // Prevent strconv unused error diff --git a/x/furnace/keeper/epoch_burn_config.go b/x/furnace/keeper/epoch_burn_config.go index a3f7a8c7..95840823 100644 --- a/x/furnace/keeper/epoch_burn_config.go +++ b/x/furnace/keeper/epoch_burn_config.go @@ -3,6 +3,7 @@ package keeper import ( "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/mycel-domain/mycel/x/furnace/types" ) diff --git a/x/furnace/keeper/events.go b/x/furnace/keeper/events.go index ad195f76..2de4859d 100644 --- a/x/furnace/keeper/events.go +++ b/x/furnace/keeper/events.go @@ -2,6 +2,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/mycel-domain/mycel/x/furnace/types" ) diff --git a/x/furnace/keeper/hooks.go b/x/furnace/keeper/hooks.go index a259ac43..af33d67e 100644 --- a/x/furnace/keeper/hooks.go +++ b/x/furnace/keeper/hooks.go @@ -2,6 +2,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/mycel-domain/mycel/app/params" epochstypes "github.com/mycel-domain/mycel/x/epochs/types" ) diff --git a/x/furnace/keeper/hooks_test.go b/x/furnace/keeper/hooks_test.go index e7ee5881..1543627f 100644 --- a/x/furnace/keeper/hooks_test.go +++ b/x/furnace/keeper/hooks_test.go @@ -2,12 +2,14 @@ package keeper_test import ( "fmt" + "time" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/mycel-domain/mycel/app/params" "github.com/mycel-domain/mycel/testutil" epochstypes "github.com/mycel-domain/mycel/x/epochs/types" "github.com/mycel-domain/mycel/x/furnace/types" - "time" ) type ExpBurnEvent struct { @@ -27,7 +29,7 @@ type ExpCreateBurnAmountEvent struct { var ( now = time.Now() oneDayDuration = time.Hour*24 + time.Second - defaultConfig = types.GetDefaultEpochBurnConfig() + defaultConfig = types.GetDefaultEpochBurnConfig() ) func (suite *KeeperTestSuite) TestAfterEpochEndCreateBurnAmount() { @@ -45,7 +47,7 @@ func (suite *KeeperTestSuite) TestAfterEpochEndCreateBurnAmount() { }, }, { - epochsCount: int64(defaultConfig.DefaultTotalEpochs+1), + epochsCount: int64(defaultConfig.DefaultTotalEpochs + 1), expectedEvents: []ExpCreateBurnAmountEvent{ { BurnAmountIndex: "1", @@ -213,7 +215,7 @@ func (suite *KeeperTestSuite) TestAfterEpochEnd() { suite.SetupTest() // Set burn totalBurnAmount - for i, _ := range tc.totalBurnAmounts { + for i := range tc.totalBurnAmounts { suite.app.FurnaceKeeper.SetBurnAmount(suite.ctx, types.BurnAmount{ Index: uint64(i + 1), TotalEpochs: 3, diff --git a/x/furnace/keeper/msg_server_test.go b/x/furnace/keeper/msg_server_test.go index 586745a2..eb5ab65a 100644 --- a/x/furnace/keeper/msg_server_test.go +++ b/x/furnace/keeper/msg_server_test.go @@ -5,10 +5,11 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + keepertest "github.com/mycel-domain/mycel/testutil/keeper" "github.com/mycel-domain/mycel/x/furnace/keeper" "github.com/mycel-domain/mycel/x/furnace/types" - "github.com/stretchr/testify/require" ) func setupMsgServer(t testing.TB) (types.MsgServer, context.Context) { diff --git a/x/furnace/keeper/params.go b/x/furnace/keeper/params.go index 06b1ce27..b3e5bc90 100644 --- a/x/furnace/keeper/params.go +++ b/x/furnace/keeper/params.go @@ -2,6 +2,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/mycel-domain/mycel/x/furnace/types" ) diff --git a/x/furnace/keeper/params_test.go b/x/furnace/keeper/params_test.go index b5563a3a..382a3404 100644 --- a/x/furnace/keeper/params_test.go +++ b/x/furnace/keeper/params_test.go @@ -3,9 +3,10 @@ package keeper_test import ( "testing" + "github.com/stretchr/testify/require" + testkeeper "github.com/mycel-domain/mycel/testutil/keeper" "github.com/mycel-domain/mycel/x/furnace/types" - "github.com/stretchr/testify/require" ) func TestGetParams(t *testing.T) { diff --git a/x/furnace/keeper/query_burn_amount.go b/x/furnace/keeper/query_burn_amount.go index 20d55145..01e97889 100644 --- a/x/furnace/keeper/query_burn_amount.go +++ b/x/furnace/keeper/query_burn_amount.go @@ -6,9 +6,10 @@ import ( "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" - "github.com/mycel-domain/mycel/x/furnace/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + + "github.com/mycel-domain/mycel/x/furnace/types" ) func (k Keeper) BurnAmountAll(goCtx context.Context, req *types.QueryAllBurnAmountRequest) (*types.QueryAllBurnAmountResponse, error) { diff --git a/x/furnace/keeper/query_epoch_burn_config.go b/x/furnace/keeper/query_epoch_burn_config.go index 16ce9f3b..e130f2de 100644 --- a/x/furnace/keeper/query_epoch_burn_config.go +++ b/x/furnace/keeper/query_epoch_burn_config.go @@ -4,9 +4,10 @@ import ( "context" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/mycel-domain/mycel/x/furnace/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + + "github.com/mycel-domain/mycel/x/furnace/types" ) func (k Keeper) EpochBurnConfig(goCtx context.Context, req *types.QueryGetEpochBurnConfigRequest) (*types.QueryGetEpochBurnConfigResponse, error) { diff --git a/x/furnace/keeper/query_params.go b/x/furnace/keeper/query_params.go index 01d08cad..9041b7a2 100644 --- a/x/furnace/keeper/query_params.go +++ b/x/furnace/keeper/query_params.go @@ -4,9 +4,10 @@ import ( "context" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/mycel-domain/mycel/x/furnace/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + + "github.com/mycel-domain/mycel/x/furnace/types" ) func (k Keeper) Params(goCtx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { diff --git a/x/furnace/keeper/query_params_test.go b/x/furnace/keeper/query_params_test.go index 8b25b712..0d9552b0 100644 --- a/x/furnace/keeper/query_params_test.go +++ b/x/furnace/keeper/query_params_test.go @@ -4,9 +4,10 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + testkeeper "github.com/mycel-domain/mycel/testutil/keeper" "github.com/mycel-domain/mycel/x/furnace/types" - "github.com/stretchr/testify/require" ) func TestParamsQuery(t *testing.T) { diff --git a/x/furnace/keeper/setup_test.go b/x/furnace/keeper/setup_test.go index b236b353..2a4c1f9a 100644 --- a/x/furnace/keeper/setup_test.go +++ b/x/furnace/keeper/setup_test.go @@ -1,8 +1,6 @@ package keeper_test import ( - mycelapp "github.com/mycel-domain/mycel/app" - "github.com/mycel-domain/mycel/x/epochs/types" "testing" "time" @@ -10,6 +8,9 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/suite" + + mycelapp "github.com/mycel-domain/mycel/app" + "github.com/mycel-domain/mycel/x/epochs/types" ) type KeeperTestSuite struct { diff --git a/x/furnace/module.go b/x/furnace/module.go index 183f99e1..c31ab825 100644 --- a/x/furnace/module.go +++ b/x/furnace/module.go @@ -4,18 +4,17 @@ import ( "context" "encoding/json" "fmt" - // this line is used by starport scaffolding # 1 - - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/spf13/cobra" + "log" abci "github.com/cometbft/cometbft/abci/types" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + "github.com/mycel-domain/mycel/x/furnace/client/cli" "github.com/mycel-domain/mycel/x/furnace/keeper" "github.com/mycel-domain/mycel/x/furnace/types" @@ -70,7 +69,10 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { - types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) + err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) + if err != nil { + log.Printf("%v", err) + } } // GetTxCmd returns the root Tx command for the module. The subcommands of this root command are used by end-users to generate new transactions containing messages defined in the module diff --git a/x/furnace/module_simulation.go b/x/furnace/module_simulation.go index 787b556d..a697fce5 100644 --- a/x/furnace/module_simulation.go +++ b/x/furnace/module_simulation.go @@ -8,6 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/simulation" + "github.com/mycel-domain/mycel/testutil/sample" furnacesimulation "github.com/mycel-domain/mycel/x/furnace/simulation" "github.com/mycel-domain/mycel/x/furnace/types" diff --git a/x/furnace/types/burn_amount.go b/x/furnace/types/burn_amount.go index dbccb997..92772bfb 100644 --- a/x/furnace/types/burn_amount.go +++ b/x/furnace/types/burn_amount.go @@ -2,6 +2,7 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/mycel-domain/mycel/app/params" ) diff --git a/x/furnace/types/errors.go b/x/furnace/types/errors.go index 7d45999e..1485e8dd 100644 --- a/x/furnace/types/errors.go +++ b/x/furnace/types/errors.go @@ -8,6 +8,6 @@ import ( // x/furnace module sentinel errors var ( - ErrSample = sdkerrors.Register(ModuleName, 1100, "sample error") + ErrSample = sdkerrors.Register(ModuleName, 1100, "sample error") ErrInvalidRegistrationPeriod = sdkerrors.Register(ModuleName, 1101, "invalid registration period") ) diff --git a/x/furnace/types/expected_keepers.go b/x/furnace/types/expected_keepers.go index 30d6c3a9..c42195f7 100644 --- a/x/furnace/types/expected_keepers.go +++ b/x/furnace/types/expected_keepers.go @@ -3,6 +3,7 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/types" + epochstypes "github.com/mycel-domain/mycel/x/epochs/types" ) diff --git a/x/furnace/types/genesis.go b/x/furnace/types/genesis.go index 4c8caec6..f5e3a0b2 100644 --- a/x/furnace/types/genesis.go +++ b/x/furnace/types/genesis.go @@ -2,7 +2,9 @@ package types import ( "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/mycel-domain/mycel/app/params" epochstypes "github.com/mycel-domain/mycel/x/epochs/types" ) diff --git a/x/furnace/types/genesis_test.go b/x/furnace/types/genesis_test.go index 79ebcfa7..229c6bd1 100644 --- a/x/furnace/types/genesis_test.go +++ b/x/furnace/types/genesis_test.go @@ -3,8 +3,9 @@ package types_test import ( "testing" - "github.com/mycel-domain/mycel/x/furnace/types" "github.com/stretchr/testify/require" + + "github.com/mycel-domain/mycel/x/furnace/types" ) func TestGenesisState_Validate(t *testing.T) { diff --git a/x/registry/client/cli/query.go b/x/registry/client/cli/query.go index 9c3676c1..bd56ba74 100644 --- a/x/registry/client/cli/query.go +++ b/x/registry/client/cli/query.go @@ -2,13 +2,9 @@ package cli import ( "fmt" - // "strings" - - "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" - // "github.com/cosmos/cosmos-sdk/client/flags" - // sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/spf13/cobra" "github.com/mycel-domain/mycel/x/registry/types" ) @@ -32,9 +28,6 @@ func GetQueryCmd(queryRoute string) *cobra.Command { cmd.AddCommand(CmdListDomainOwnership()) cmd.AddCommand(CmdShowDomainOwnership()) cmd.AddCommand(CmdDomainRegistrationFee()) - - cmd.AddCommand(CmdIsRegistrableDomain()) - cmd.AddCommand(CmdListTopLevelDomain()) cmd.AddCommand(CmdShowTopLevelDomain()) // this line is used by starport scaffolding # 1 diff --git a/x/registry/client/cli/query_domain_ownership.go b/x/registry/client/cli/query_domain_ownership.go index c86951c2..d8fd674c 100644 --- a/x/registry/client/cli/query_domain_ownership.go +++ b/x/registry/client/cli/query_domain_ownership.go @@ -5,8 +5,9 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/mycel-domain/mycel/x/registry/types" "github.com/spf13/cobra" + + "github.com/mycel-domain/mycel/x/registry/types" ) func CmdListDomainOwnership() *cobra.Command { diff --git a/x/registry/client/cli/query_domain_registration_fee.go b/x/registry/client/cli/query_domain_registration_fee.go index 556e4883..a1d9af04 100644 --- a/x/registry/client/cli/query_domain_registration_fee.go +++ b/x/registry/client/cli/query_domain_registration_fee.go @@ -5,20 +5,23 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/mycel-domain/mycel/x/registry/types" + "github.com/spf13/cast" "github.com/spf13/cobra" + + "github.com/mycel-domain/mycel/x/registry/types" ) var _ = strconv.Itoa(0) func CmdDomainRegistrationFee() *cobra.Command { cmd := &cobra.Command{ - Use: "domain-registration-fee [name] [parent]", + Use: "domain-registration-fee [name] [parent] [registration-period-in-year]", Short: "query domain registration fee", - Args: cobra.ExactArgs(2), + Args: cobra.ExactArgs(3), RunE: func(cmd *cobra.Command, args []string) (err error) { reqName := args[0] reqParent := args[1] + reqRegistrationPeriodInYear, err := cast.ToUint64E(args[2]) clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { @@ -28,9 +31,9 @@ func CmdDomainRegistrationFee() *cobra.Command { queryClient := types.NewQueryClient(clientCtx) params := &types.QueryDomainRegistrationFeeRequest{ - - Name: reqName, - Parent: reqParent, + Name: reqName, + Parent: reqParent, + RegistrationPeriodInYear: reqRegistrationPeriodInYear, } res, err := queryClient.DomainRegistrationFee(cmd.Context(), params) diff --git a/x/registry/client/cli/query_is_registrable_domain.go b/x/registry/client/cli/query_is_registrable_domain.go deleted file mode 100644 index 64688205..00000000 --- a/x/registry/client/cli/query_is_registrable_domain.go +++ /dev/null @@ -1,48 +0,0 @@ -package cli - -import ( - "strconv" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/mycel-domain/mycel/x/registry/types" - "github.com/spf13/cobra" -) - -var _ = strconv.Itoa(0) - -func CmdIsRegistrableDomain() *cobra.Command { - cmd := &cobra.Command{ - Use: "is-registrable-domain [name] [parent]", - Short: "query a domain is registrable", - Args: cobra.ExactArgs(2), - RunE: func(cmd *cobra.Command, args []string) (err error) { - reqName := args[0] - reqParent := args[1] - - clientCtx, err := client.GetClientQueryContext(cmd) - if err != nil { - return err - } - - queryClient := types.NewQueryClient(clientCtx) - - params := &types.QueryIsRegistrableDomainRequest{ - - Name: reqName, - Parent: reqParent, - } - - res, err := queryClient.IsRegistrableDomain(cmd.Context(), params) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} diff --git a/x/registry/client/cli/query_params.go b/x/registry/client/cli/query_params.go index 77aaf2ed..0afa9bb1 100644 --- a/x/registry/client/cli/query_params.go +++ b/x/registry/client/cli/query_params.go @@ -5,8 +5,9 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/mycel-domain/mycel/x/registry/types" "github.com/spf13/cobra" + + "github.com/mycel-domain/mycel/x/registry/types" ) func CmdQueryParams() *cobra.Command { diff --git a/x/registry/client/cli/query_second_level_domain.go b/x/registry/client/cli/query_second_level_domain.go index 7a5be438..924bd89b 100644 --- a/x/registry/client/cli/query_second_level_domain.go +++ b/x/registry/client/cli/query_second_level_domain.go @@ -5,8 +5,9 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/mycel-domain/mycel/x/registry/types" "github.com/spf13/cobra" + + "github.com/mycel-domain/mycel/x/registry/types" ) func CmdListSecondLevelDomain() *cobra.Command { diff --git a/x/registry/client/cli/tx.go b/x/registry/client/cli/tx.go index c0eb95fc..4f6baa29 100644 --- a/x/registry/client/cli/tx.go +++ b/x/registry/client/cli/tx.go @@ -4,9 +4,9 @@ import ( "fmt" "time" + "github.com/cosmos/cosmos-sdk/client" "github.com/spf13/cobra" - "github.com/cosmos/cosmos-sdk/client" // "github.com/cosmos/cosmos-sdk/client/flags" "github.com/mycel-domain/mycel/x/registry/types" ) @@ -35,6 +35,7 @@ func GetTxCmd() *cobra.Command { cmd.AddCommand(CmdRegisterDomain()) cmd.AddCommand(CmdRegisterTopLevelDomain()) cmd.AddCommand(CmdWithdrawRegistrationFee()) + cmd.AddCommand(CmdExtendTopLevelDomainExpirationDate()) // this line is used by starport scaffolding # 1 return cmd diff --git a/x/registry/client/cli/tx_extend_top_level_domain_expiration_date.go b/x/registry/client/cli/tx_extend_top_level_domain_expiration_date.go new file mode 100644 index 00000000..c67e2650 --- /dev/null +++ b/x/registry/client/cli/tx_extend_top_level_domain_expiration_date.go @@ -0,0 +1,49 @@ +package cli + +import ( + "strconv" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/spf13/cast" + "github.com/spf13/cobra" + + "github.com/mycel-domain/mycel/x/registry/types" +) + +var _ = strconv.Itoa(0) + +func CmdExtendTopLevelDomainExpirationDate() *cobra.Command { + cmd := &cobra.Command{ + Use: "extend-top-level-domain-expiration-date [name] [extension-period-in-year]", + Short: "Broadcast message extendTopLevelDomainExpirationDate", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) (err error) { + argName := args[0] + argExtensionPeriodInYear, err := cast.ToUint64E(args[1]) + if err != nil { + return err + } + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgExtendTopLevelDomainExpirationDate( + clientCtx.GetFromAddress().String(), + argName, + argExtensionPeriodInYear, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/registry/client/cli/tx_register_second_level_domain.go b/x/registry/client/cli/tx_register_second_level_domain.go index 8c829f85..d791c2d5 100644 --- a/x/registry/client/cli/tx_register_second_level_domain.go +++ b/x/registry/client/cli/tx_register_second_level_domain.go @@ -6,9 +6,10 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" - "github.com/mycel-domain/mycel/x/registry/types" "github.com/spf13/cast" "github.com/spf13/cobra" + + "github.com/mycel-domain/mycel/x/registry/types" ) var _ = strconv.Itoa(0) diff --git a/x/registry/client/cli/tx_register_top_level_domain.go b/x/registry/client/cli/tx_register_top_level_domain.go index 29832b6e..7bd74e36 100644 --- a/x/registry/client/cli/tx_register_top_level_domain.go +++ b/x/registry/client/cli/tx_register_top_level_domain.go @@ -6,9 +6,10 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" - "github.com/mycel-domain/mycel/x/registry/types" "github.com/spf13/cast" "github.com/spf13/cobra" + + "github.com/mycel-domain/mycel/x/registry/types" ) var _ = strconv.Itoa(0) diff --git a/x/registry/client/cli/tx_update_dns_record.go b/x/registry/client/cli/tx_update_dns_record.go index 456eddca..916e89cc 100644 --- a/x/registry/client/cli/tx_update_dns_record.go +++ b/x/registry/client/cli/tx_update_dns_record.go @@ -1,13 +1,14 @@ package cli import ( - "github.com/mycel-domain/mycel/x/registry/types" "strconv" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" "github.com/spf13/cobra" + + "github.com/mycel-domain/mycel/x/registry/types" ) var _ = strconv.Itoa(0) diff --git a/x/registry/client/cli/tx_update_wallet_record.go b/x/registry/client/cli/tx_update_wallet_record.go index 4a366924..fa9fc3c7 100644 --- a/x/registry/client/cli/tx_update_wallet_record.go +++ b/x/registry/client/cli/tx_update_wallet_record.go @@ -6,8 +6,9 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" - "github.com/mycel-domain/mycel/x/registry/types" "github.com/spf13/cobra" + + "github.com/mycel-domain/mycel/x/registry/types" ) var _ = strconv.Itoa(0) diff --git a/x/registry/client/cli/tx_withdraw_registration_fee.go b/x/registry/client/cli/tx_withdraw_registration_fee.go index 0b03b920..3de32139 100644 --- a/x/registry/client/cli/tx_withdraw_registration_fee.go +++ b/x/registry/client/cli/tx_withdraw_registration_fee.go @@ -6,8 +6,9 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" - "github.com/mycel-domain/mycel/x/registry/types" "github.com/spf13/cobra" + + "github.com/mycel-domain/mycel/x/registry/types" ) var _ = strconv.Itoa(0) diff --git a/x/registry/genesis.go b/x/registry/genesis.go index 517a0269..13fa8396 100644 --- a/x/registry/genesis.go +++ b/x/registry/genesis.go @@ -2,6 +2,7 @@ package registry import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/mycel-domain/mycel/x/registry/keeper" "github.com/mycel-domain/mycel/x/registry/types" ) diff --git a/x/registry/genesis_test.go b/x/registry/genesis_test.go index bc1f54e0..175ffffc 100644 --- a/x/registry/genesis_test.go +++ b/x/registry/genesis_test.go @@ -3,11 +3,12 @@ package registry_test import ( "testing" + "github.com/stretchr/testify/require" + keepertest "github.com/mycel-domain/mycel/testutil/keeper" "github.com/mycel-domain/mycel/testutil/nullify" "github.com/mycel-domain/mycel/x/registry" "github.com/mycel-domain/mycel/x/registry/types" - "github.com/stretchr/testify/require" ) func TestGenesis(t *testing.T) { diff --git a/x/registry/keeper/domain_ownership.go b/x/registry/keeper/domain_ownership.go index ed527c2d..297cabf5 100644 --- a/x/registry/keeper/domain_ownership.go +++ b/x/registry/keeper/domain_ownership.go @@ -3,6 +3,7 @@ package keeper import ( "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/mycel-domain/mycel/x/registry/types" ) @@ -61,3 +62,14 @@ func (k Keeper) GetAllDomainOwnership(ctx sdk.Context) (list []types.DomainOwner return } + +// Append to owned domain +func (k Keeper) AppendToOwnedDomain(ctx sdk.Context, owner string, name string, parent string) { + domainOwnership, found := k.GetDomainOwnership(ctx, owner) + if found { + domainOwnership.Domains = append(domainOwnership.Domains, &types.OwnedDomain{Name: name, Parent: parent}) + k.SetDomainOwnership(ctx, domainOwnership) + } else { + k.SetDomainOwnership(ctx, types.DomainOwnership{Owner: owner, Domains: []*types.OwnedDomain{{Name: name, Parent: parent}}}) + } +} diff --git a/x/registry/keeper/domain_ownership_test.go b/x/registry/keeper/domain_ownership_test.go index ff115043..b340fdd2 100644 --- a/x/registry/keeper/domain_ownership_test.go +++ b/x/registry/keeper/domain_ownership_test.go @@ -5,11 +5,12 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + keepertest "github.com/mycel-domain/mycel/testutil/keeper" "github.com/mycel-domain/mycel/testutil/nullify" "github.com/mycel-domain/mycel/x/registry/keeper" "github.com/mycel-domain/mycel/x/registry/types" - "github.com/stretchr/testify/require" ) // Prevent strconv unused error diff --git a/x/registry/keeper/events.go b/x/registry/keeper/events.go index 54b99ada..768a461f 100644 --- a/x/registry/keeper/events.go +++ b/x/registry/keeper/events.go @@ -2,23 +2,24 @@ package keeper import ( "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/mycel-domain/mycel/x/registry/types" - "strconv" ) // Register top-level-domain event -func EmitRegisterTopLevelDomainEvent(ctx sdk.Context, domain types.TopLevelDomain, fee types.TopLevelDomainRegistrationFee) { +func EmitRegisterTopLevelDomainEvent(ctx sdk.Context, domain types.TopLevelDomain, fee types.TopLevelDomainFee) { ctx.EventManager().EmitEvent( sdk.NewEvent( types.EventTypeRegisterTopLevelDomain, sdk.NewAttribute(types.AttributeRegisterTopLevelDomainEventName, domain.Name), - sdk.NewAttribute(types.AttributeRegisterTopLevelDomainEventExpirationDate, fmt.Sprintf("%d", domain.ExpirationDate)), + sdk.NewAttribute(types.AttributeRegisterTopLevelDomainEventExpirationDate, domain.ExpirationDate.String()), sdk.NewAttribute(types.AttributeRegisterTopLevelDomainEventMaxSubdomainRegistrations, fmt.Sprintf("%d", domain.SubdomainConfig.MaxSubdomainRegistrations)), - sdk.NewAttribute(types.AttributeRegisterTopLevelDomainEventTotalRegistrationFee, fee.TotalRegistrationFee.String()), - sdk.NewAttribute(types.AttributeRegisterTopLevelDomainEventBurnWeight, fee.BurnWeight.String()), - sdk.NewAttribute(types.AttributeRegisterTopLevelDomainEventRegistrationFeeToBurn, fee.RegistrationFeeToBurn.String()), - sdk.NewAttribute(types.AttributeRegisterTopLevelDomainEventRegistrationFeeToTreasury, fee.RegistrationFeeToTreasury.String()), + sdk.NewAttribute(types.AttributeRegisterTopLevelDomainEventTotalRegistrationFee, fee.TotalFee.String()), + sdk.NewAttribute(types.AttributeRegisterTopLevelDomainEventBurnWeight, fee.BurnWeight), + sdk.NewAttribute(types.AttributeRegisterTopLevelDomainEventRegistrationFeeToBurn, fee.FeeToBurn.String()), + sdk.NewAttribute(types.AttributeRegisterTopLevelDomainEventRegistrationFeeToTreasury, fee.FeeToTreasury.String()), ), ) } @@ -29,7 +30,7 @@ func EmitRegisterSecondLevelDomainEvent(ctx sdk.Context, domain types.SecondLeve sdk.NewEvent(types.EventTypeRegisterSecondLevelDomain, sdk.NewAttribute(types.AttributeRegisterSecondLevelDomainEventName, domain.Name), sdk.NewAttribute(types.AttributeRegisterSecondLevelDomainEventParent, domain.Parent), - sdk.NewAttribute(types.AttributeRegisterSecondLevelDomainEventExpirationDate, strconv.FormatInt(domain.ExpirationDate, 10)), + sdk.NewAttribute(types.AttributeRegisterSecondLevelDomainEventExpirationDate, domain.ExpirationDate.String()), sdk.NewAttribute(types.AttributeRegisterSecondLevelDomainEventRegistrationFee, fee.String()), ), ) @@ -68,3 +69,17 @@ func EmitWithdrawRegistrationFeeEvent(ctx sdk.Context, msg types.MsgWithdrawRegi ), ) } + +// Extend top-level-domain expiration date event +func EmitExtendTopLevelDomainExpirationDateEvent(ctx sdk.Context, domain types.TopLevelDomain, fee types.TopLevelDomainFee) { + ctx.EventManager().EmitEvent( + sdk.NewEvent(types.EventTypeExtendTopLevelDomainExpirationDate, + sdk.NewAttribute(types.AttributeExtendTopLevelDomainExpirationDateEventDomainName, domain.Name), + sdk.NewAttribute(types.AttributeExtendTopLevelDomainExpirationDateEventExpirationDate, domain.ExpirationDate.String()), + sdk.NewAttribute(types.AttributeExtendTopLevelDomainExpirationDateEventTotalRegistrationFee, fee.TotalFee.String()), + sdk.NewAttribute(types.AttributeExtendTopLevelDomainExpirationDateEventBurnWeight, fee.BurnWeight), + sdk.NewAttribute(types.AttributeExtendTopLevelDomainExpirationDateEventRegistrationFeeToBurn, fee.FeeToBurn.String()), + sdk.NewAttribute(types.AttributeExtendTopLevelDomainExpirationDateEventRegistrationFeeToTreasury, fee.FeeToTreasury.String()), + ), + ) +} diff --git a/x/registry/keeper/hooks.go b/x/registry/keeper/hooks.go index 241fb386..24ad4c98 100644 --- a/x/registry/keeper/hooks.go +++ b/x/registry/keeper/hooks.go @@ -2,6 +2,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + epochstypes "github.com/mycel-domain/mycel/x/epochs/types" ) diff --git a/x/registry/keeper/keeper.go b/x/registry/keeper/keeper.go index e0ef32e2..dc6ed31f 100644 --- a/x/registry/keeper/keeper.go +++ b/x/registry/keeper/keeper.go @@ -48,10 +48,10 @@ func NewKeeper( memKey: memKey, paramstore: ps, - bankKeeper: bankKeeper, + bankKeeper: bankKeeper, distributionKeeper: distributionKeeper, - mintKeeper: mintKeeper, - furnaceKeeper: furnaceKeeper, + mintKeeper: mintKeeper, + furnaceKeeper: furnaceKeeper, } } diff --git a/x/registry/keeper/msg_server_extend_top_level_domain_expiration_date.go b/x/registry/keeper/msg_server_extend_top_level_domain_expiration_date.go new file mode 100644 index 00000000..a79e6530 --- /dev/null +++ b/x/registry/keeper/msg_server_extend_top_level_domain_expiration_date.go @@ -0,0 +1,23 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/mycel-domain/mycel/x/registry/types" +) + +func (k msgServer) ExtendTopLevelDomainExpirationDate(goCtx context.Context, msg *types.MsgExtendTopLevelDomainExpirationDate) (*types.MsgExtendTopLevelDomainExpirationDateResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + topLevelDomain, fee, err := k.Keeper.ExtendTopLevelDomainExpirationDate(ctx, msg.Creator, msg.Name, msg.ExtensionPeriodInYear) + if err != nil { + return nil, err + } + + return &types.MsgExtendTopLevelDomainExpirationDateResponse{ + TopLevelDomain: &topLevelDomain, + Fee: &fee, + }, nil +} diff --git a/x/registry/keeper/msg_server_extend_top_level_domain_expiration_date_test.go b/x/registry/keeper/msg_server_extend_top_level_domain_expiration_date_test.go new file mode 100644 index 00000000..896f3f07 --- /dev/null +++ b/x/registry/keeper/msg_server_extend_top_level_domain_expiration_date_test.go @@ -0,0 +1,119 @@ +package keeper_test + +import ( + "fmt" + + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + + "github.com/mycel-domain/mycel/app/params" + "github.com/mycel-domain/mycel/testutil" + furnacetypes "github.com/mycel-domain/mycel/x/furnace/types" + "github.com/mycel-domain/mycel/x/registry/types" +) + +func (suite *KeeperTestSuite) TestExtendTopLevelDomain() { + name := "hoge" + + testCases := []struct { + creator string + extensionPeriodInYear uint64 + expErr error + fn func() + }{ + { + creator: testutil.Alice, + extensionPeriodInYear: 1, + expErr: nil, + fn: func() {}, + }, + { + creator: testutil.Bob, + extensionPeriodInYear: 1, + expErr: errorsmod.Wrapf(types.ErrTopLevelDomainNotEditable, "%s", testutil.Bob), + fn: func() {}, + }, + } + + for i, tc := range testCases { + suite.Run(fmt.Sprintf("Case %d", i), func() { + suite.SetupTest() + + // Register domain + registerMsg := &types.MsgRegisterTopLevelDomain{ + Creator: testutil.Alice, + Name: name, + RegistrationPeriodInYear: 1, + } + registerRsp, err := suite.msgServer.RegisterTopLevelDomain(suite.ctx, registerMsg) + suite.Require().Nil(err) + beforeDomain, found := suite.app.RegistryKeeper.GetTopLevelDomain(suite.ctx, name) + suite.Require().True(found) + + // Run test case function + tc.fn() + + // Before balances + furnaceAddress := authtypes.NewModuleAddress(furnacetypes.ModuleName) + beforeFurnaceBalance := suite.app.BankKeeper.GetAllBalances(suite.ctx, furnaceAddress) + beforeTreasuryBalance := suite.app.DistrKeeper.GetFeePool(suite.ctx).CommunityPool + + // Extend domain + extendMsg := &types.MsgExtendTopLevelDomainExpirationDate{ + Creator: tc.creator, + Name: name, + ExtensionPeriodInYear: tc.extensionPeriodInYear, + } + extendRsp, err := suite.msgServer.ExtendTopLevelDomainExpirationDate(suite.ctx, extendMsg) + + // After balances + afterFurnaceBalance := suite.app.BankKeeper.GetAllBalances(suite.ctx, furnaceAddress) + afterTreasuryBalance := suite.app.DistrKeeper.GetFeePool(suite.ctx).CommunityPool + + if tc.expErr == nil { + suite.Require().Nil(err) + // Evaluate if domain is extended + // Response + suite.Require().Equal(registerRsp.TopLevelDomain.ExpirationDate.AddDate(0, 0, int(tc.extensionPeriodInYear)*params.OneYearInDays), extendRsp.TopLevelDomain.ExpirationDate) + // Store + afterDomain, found := suite.app.RegistryKeeper.GetTopLevelDomain(suite.ctx, name) + suite.Require().True(found) + expAfterExpirationDate := beforeDomain.ExpirationDate.AddDate(0, 0, int(tc.extensionPeriodInYear)*params.OneYearInDays) + suite.Require().Equal(expAfterExpirationDate, afterDomain.ExpirationDate) + + // Evalute events + events, found := testutil.FindEventsByType(suite.ctx.EventManager().Events(), types.EventTypeExtendTopLevelDomainExpirationDate) + suite.Require().True(found) + for _, event := range events { + suite.Require().Equal(name, event.Attributes[0].Value) + + // Check if the extension fee is correct + total, err := sdk.ParseCoinsNormalized(event.Attributes[2].Value) + suite.Require().Nil(err) + toBurn, err := sdk.ParseCoinNormalized(event.Attributes[4].Value) + suite.Require().Nil(err) + toTreasury, err := sdk.ParseCoinNormalized(event.Attributes[5].Value) + suite.Require().Nil(err) + + // Check if the total is equal to the sum of toBurn and toTreasury + if total.Len() == 1 { + suite.Require().Equal(total, sdk.NewCoins(toBurn.Add(toTreasury))) + + } else { + suite.Require().Equal(total, sdk.NewCoins(toBurn, toTreasury)) + } + + // Check if the furnace balance is increased + expectedFurnaceBalance := beforeFurnaceBalance.Add(toBurn) + suite.Require().Equal(expectedFurnaceBalance, afterFurnaceBalance) + expectedTreasuryBalance := beforeTreasuryBalance.Add(sdk.NewDecCoinFromCoin(toTreasury)) + suite.Require().Equal(expectedTreasuryBalance, afterTreasuryBalance) + } + + } else { + suite.Require().EqualError(err, tc.expErr.Error()) + } + }) + } +} diff --git a/x/registry/keeper/msg_server_register_second_level_domain.go b/x/registry/keeper/msg_server_register_second_level_domain.go index 17b11023..a97454e1 100644 --- a/x/registry/keeper/msg_server_register_second_level_domain.go +++ b/x/registry/keeper/msg_server_register_second_level_domain.go @@ -2,10 +2,11 @@ package keeper import ( "context" - - "github.com/mycel-domain/mycel/x/registry/types" + "time" sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/mycel-domain/mycel/x/registry/types" ) func (k msgServer) RegisterSecondLevelDomain(goCtx context.Context, msg *types.MsgRegisterSecondLevelDomain) (*types.MsgRegisterSecondLevelDomainResponse, error) { @@ -23,7 +24,7 @@ func (k msgServer) RegisterSecondLevelDomain(goCtx context.Context, msg *types.M domain := types.SecondLevelDomain{ Name: msg.Name, Owner: msg.Creator, - ExpirationDate: 0, + ExpirationDate: time.Time{}, Parent: msg.Parent, Records: nil, AccessControl: accessControl, diff --git a/x/registry/keeper/msg_server_register_second_level_domain_test.go b/x/registry/keeper/msg_server_register_second_level_domain_test.go index 59c512f0..65543762 100644 --- a/x/registry/keeper/msg_server_register_second_level_domain_test.go +++ b/x/registry/keeper/msg_server_register_second_level_domain_test.go @@ -3,11 +3,12 @@ package keeper_test import ( "fmt" + errorsmod "cosmossdk.io/errors" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + + "github.com/mycel-domain/mycel/app/params" "github.com/mycel-domain/mycel/testutil" "github.com/mycel-domain/mycel/x/registry/types" - - errorsmod "cosmossdk.io/errors" ) func (suite *KeeperTestSuite) TestRegisterSecondLevelDomain() { @@ -49,7 +50,7 @@ func (suite *KeeperTestSuite) TestRegisterSecondLevelDomain() { name: "foo", parent: "cel", registrationPeriodInYear: 1, - expErr: errorsmod.Wrapf(types.ErrDomainIsAlreadyTaken, "foo.cel"), + expErr: errorsmod.Wrapf(types.ErrSecondLevelDomainAlreadyTaken, "foo.cel"), fn: func() { // Register domain once domain := &types.MsgRegisterSecondLevelDomain{ @@ -67,7 +68,7 @@ func (suite *KeeperTestSuite) TestRegisterSecondLevelDomain() { name: "foo", parent: "xxx", registrationPeriodInYear: 1, - expErr: errorsmod.Wrapf(types.ErrParentDomainDoesNotExist, "xxx"), + expErr: errorsmod.Wrapf(types.ErrSecondLevelDomainParentDoesNotExist, "xxx"), fn: func() { }, }, @@ -92,7 +93,7 @@ func (suite *KeeperTestSuite) TestRegisterSecondLevelDomain() { suite.Require().True(found) moduleAddress := authtypes.NewModuleAddress(types.ModuleName) - beforeModuleBalance := suite.app.BankKeeper.GetBalance(suite.ctx, moduleAddress, types.MycelDenom) + beforeModuleBalance := suite.app.BankKeeper.GetBalance(suite.ctx, moduleAddress, params.DefaultBondDenom) // Register second level domain _, err := suite.msgServer.RegisterSecondLevelDomain(suite.ctx, registerMsg) @@ -108,6 +109,18 @@ func (suite *KeeperTestSuite) TestRegisterSecondLevelDomain() { suite.Require().True(found) suite.Require().Equal(domain.AccessControl[tc.creator], types.DomainRole_OWNER) + // Evaluate if domain is appended to owned domain list + ownedDomains, found := suite.app.RegistryKeeper.GetDomainOwnership(suite.ctx, tc.creator) + suite.Require().True(found) + found = false + for _, ownedDomain := range ownedDomains.Domains { + if ownedDomain.Name == tc.name && ownedDomain.Parent == tc.parent { + found = true + break + } + } + suite.Require().True(found) + // Evaluate if parent's subdomainCount is increased afterParent, found := suite.app.RegistryKeeper.GetTopLevelDomain(suite.ctx, tc.parent) suite.Require().True(found) @@ -115,13 +128,13 @@ func (suite *KeeperTestSuite) TestRegisterSecondLevelDomain() { // Evaluate if module account balance is increased // Get registration fee - config := suite.app.RegistryKeeper.GetParentsSubdomainConfig(suite.ctx, domain) + config := suite.app.RegistryKeeper.GetSecondLevelDomainParentsSubdomainConfig(suite.ctx, domain) fee, err := config.GetRegistrationFee(tc.name, tc.registrationPeriodInYear) suite.Require().Nil(err) - afterModuleBalance := suite.app.BankKeeper.GetBalance(suite.ctx, moduleAddress, types.MycelDenom) - suite.Require().Equal(beforeModuleBalance.Add(*fee), afterModuleBalance) - suite.Require().Equal(beforeParent.TotalWithdrawalAmount.Add(*fee), afterParent.TotalWithdrawalAmount) + afterModuleBalance := suite.app.BankKeeper.GetBalance(suite.ctx, moduleAddress, params.DefaultBondDenom) + suite.Require().Equal(beforeModuleBalance.Add(fee), afterModuleBalance) + suite.Require().Equal(beforeParent.TotalWithdrawalAmount.Add(fee), afterParent.TotalWithdrawalAmount) // Evalute events events, found := testutil.FindEventsByType(suite.ctx.EventManager().Events(), types.EventTypeRegisterSecondLevelDomain) diff --git a/x/registry/keeper/msg_server_register_top_level_domain.go b/x/registry/keeper/msg_server_register_top_level_domain.go index 26835803..bbc25b59 100644 --- a/x/registry/keeper/msg_server_register_top_level_domain.go +++ b/x/registry/keeper/msg_server_register_top_level_domain.go @@ -3,45 +3,26 @@ package keeper import ( "context" - "github.com/mycel-domain/mycel/x/registry/types" - errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/mycel-domain/mycel/app/params" + + "github.com/mycel-domain/mycel/x/registry/types" ) func (k msgServer) RegisterTopLevelDomain(goCtx context.Context, msg *types.MsgRegisterTopLevelDomain) (*types.MsgRegisterTopLevelDomainResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) if msg.RegistrationPeriodInYear < 1 || msg.RegistrationPeriodInYear > 4 { - return nil, errorsmod.Wrapf(types.ErrInvalidRegistrationPeriod, "%d year(s)", msg.RegistrationPeriodInYear) - } - - creatorAddress, err := sdk.AccAddressFromBech32(msg.Creator) - if err != nil { - return nil, err - } - - currentTime := ctx.BlockTime() - expirationDate := currentTime.AddDate(0, 0, params.OneYearInDays*int(msg.RegistrationPeriodInYear)) - accessControl := map[string]types.DomainRole{ - msg.Creator: types.DomainRole_OWNER, - } - - defaultRegistrationConfig := types.GetDefaultSubdomainConfig(3030) - domain := types.TopLevelDomain{ - Name: msg.Name, - ExpirationDate: expirationDate.UnixNano(), - Metadata: nil, - SubdomainConfig: &defaultRegistrationConfig, - AccessControl: accessControl, - TotalWithdrawalAmount: sdk.NewCoins(), + return nil, errorsmod.Wrapf(types.ErrTopLevelDomainInvalidRegistrationPeriod, "%d year(s)", msg.RegistrationPeriodInYear) } - err = k.Keeper.RegisterTopLevelDomain(ctx, domain, creatorAddress, msg.RegistrationPeriodInYear) + topLevelDomain, fee, err := k.Keeper.RegisterTopLevelDomain(ctx, msg.Creator, msg.Name, msg.RegistrationPeriodInYear) if err != nil { return nil, err } - return &types.MsgRegisterTopLevelDomainResponse{}, nil + return &types.MsgRegisterTopLevelDomainResponse{ + TopLevelDomain: &topLevelDomain, + Fee: &fee, + }, nil } diff --git a/x/registry/keeper/msg_server_register_top_level_domain_test.go b/x/registry/keeper/msg_server_register_top_level_domain_test.go index fd9bd54b..539a9889 100644 --- a/x/registry/keeper/msg_server_register_top_level_domain_test.go +++ b/x/registry/keeper/msg_server_register_top_level_domain_test.go @@ -3,13 +3,13 @@ package keeper_test import ( "fmt" + errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/mycel-domain/mycel/testutil" furnacetypes "github.com/mycel-domain/mycel/x/furnace/types" "github.com/mycel-domain/mycel/x/registry/types" - - errorsmod "cosmossdk.io/errors" ) func (suite *KeeperTestSuite) TestRegisterTopLevelDomain() { @@ -38,7 +38,7 @@ func (suite *KeeperTestSuite) TestRegisterTopLevelDomain() { creator: testutil.Alice, name: "cel2", registrationPeriodInYear: 1, - expErr: errorsmod.Wrapf(types.ErrDomainIsAlreadyTaken, "cel2"), + expErr: errorsmod.Wrapf(types.ErrTopLevelDomainAlreadyTaken, "cel2"), fn: func() { // Register domain once domain := &types.MsgRegisterTopLevelDomain{ @@ -83,6 +83,18 @@ func (suite *KeeperTestSuite) TestRegisterTopLevelDomain() { suite.Require().True(found) suite.Require().Equal(domain.AccessControl[tc.creator], types.DomainRole_OWNER) + // Evaluate if domain is appended to owned domain list + ownedDomains, found := suite.app.RegistryKeeper.GetDomainOwnership(suite.ctx, tc.creator) + suite.Require().True(found) + found = false + for _, ownedDomain := range ownedDomains.Domains { + if ownedDomain.Name == tc.name && ownedDomain.Parent == "" { + found = true + break + } + } + suite.Require().True(found) + // Evalute events events, found := testutil.FindEventsByType(suite.ctx.EventManager().Events(), types.EventTypeRegisterTopLevelDomain) suite.Require().True(found) diff --git a/x/registry/keeper/msg_server_test.go b/x/registry/keeper/msg_server_test.go index 444a3207..f58a290e 100644 --- a/x/registry/keeper/msg_server_test.go +++ b/x/registry/keeper/msg_server_test.go @@ -4,12 +4,12 @@ import ( "context" "testing" + sdk "github.com/cosmos/cosmos-sdk/types" + keepertest "github.com/mycel-domain/mycel/testutil/keeper" "github.com/mycel-domain/mycel/x/registry" "github.com/mycel-domain/mycel/x/registry/keeper" "github.com/mycel-domain/mycel/x/registry/types" - - sdk "github.com/cosmos/cosmos-sdk/types" ) func setupMsgServer(t testing.TB) (types.MsgServer, keeper.Keeper, context.Context) { diff --git a/x/registry/keeper/msg_server_update_dns_record.go b/x/registry/keeper/msg_server_update_dns_record.go index 163948e9..9e77d90c 100644 --- a/x/registry/keeper/msg_server_update_dns_record.go +++ b/x/registry/keeper/msg_server_update_dns_record.go @@ -3,10 +3,10 @@ package keeper import ( "context" - "github.com/mycel-domain/mycel/x/registry/types" - errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/mycel-domain/mycel/x/registry/types" ) func (k msgServer) UpdateDnsRecord(goCtx context.Context, msg *types.MsgUpdateDnsRecord) (*types.MsgUpdateDnsRecordResponse, error) { @@ -14,7 +14,7 @@ func (k msgServer) UpdateDnsRecord(goCtx context.Context, msg *types.MsgUpdateDn domain, isFound := k.Keeper.GetSecondLevelDomain(ctx, msg.Name, msg.Parent) if !isFound { - return nil, errorsmod.Wrapf(types.ErrDomainNotFound, "%s.%s", msg.Name, msg.Parent) + return nil, errorsmod.Wrapf(types.ErrSecondLevelDomainNotFound, "%s.%s", msg.Name, msg.Parent) } // Check if the domain is owned by the creator @@ -32,6 +32,5 @@ func (k msgServer) UpdateDnsRecord(goCtx context.Context, msg *types.MsgUpdateDn // Emit event EmitUpdateDnsRecordEvent(ctx, *msg) - return &types.MsgUpdateDnsRecordResponse{}, nil } diff --git a/x/registry/keeper/msg_server_update_dns_record_test.go b/x/registry/keeper/msg_server_update_dns_record_test.go index 11ed770a..7333a56c 100644 --- a/x/registry/keeper/msg_server_update_dns_record_test.go +++ b/x/registry/keeper/msg_server_update_dns_record_test.go @@ -3,10 +3,10 @@ package keeper_test import ( "fmt" + errorsmod "cosmossdk.io/errors" + "github.com/mycel-domain/mycel/testutil" "github.com/mycel-domain/mycel/x/registry/types" - - errorsmod "cosmossdk.io/errors" ) func (suite *KeeperTestSuite) TestUpdateDnsRecord() { @@ -52,7 +52,7 @@ func (suite *KeeperTestSuite) TestUpdateDnsRecord() { parent: "fuga", dnsRecordType: "A", value: "192.168.0.1", - expErr: errorsmod.Wrapf(types.ErrDomainNotFound, "hoge.fuga"), + expErr: errorsmod.Wrapf(types.ErrSecondLevelDomainNotFound, "hoge.fuga"), fn: func() {}, }, { @@ -61,7 +61,7 @@ func (suite *KeeperTestSuite) TestUpdateDnsRecord() { parent: "cel", dnsRecordType: "A", value: "192.168.0.1", - expErr: errorsmod.Wrapf(types.ErrDomainNotEditable, "%s", testutil.Bob), + expErr: errorsmod.Wrapf(types.ErrSecondLevelDomainNotEditable, "%s", testutil.Bob), fn: func() {}, }, } diff --git a/x/registry/keeper/msg_server_update_wallet_record.go b/x/registry/keeper/msg_server_update_wallet_record.go index 2f8f67d3..e661c873 100644 --- a/x/registry/keeper/msg_server_update_wallet_record.go +++ b/x/registry/keeper/msg_server_update_wallet_record.go @@ -3,10 +3,10 @@ package keeper import ( "context" - "github.com/mycel-domain/mycel/x/registry/types" - errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/mycel-domain/mycel/x/registry/types" ) func (k msgServer) UpdateWalletRecord(goCtx context.Context, msg *types.MsgUpdateWalletRecord) (*types.MsgUpdateWalletRecordResponse, error) { @@ -14,7 +14,7 @@ func (k msgServer) UpdateWalletRecord(goCtx context.Context, msg *types.MsgUpdat domain, isFound := k.Keeper.GetSecondLevelDomain(ctx, msg.Name, msg.Parent) if !isFound { - return nil, errorsmod.Wrapf(types.ErrDomainNotFound, "%s.%s", msg.Name, msg.Parent) + return nil, errorsmod.Wrapf(types.ErrSecondLevelDomainNotFound, "%s.%s", msg.Name, msg.Parent) } // Check if the domain is owned by the creator @@ -32,6 +32,5 @@ func (k msgServer) UpdateWalletRecord(goCtx context.Context, msg *types.MsgUpdat // Emit event EmitUpdateWalletRecordEvent(ctx, *msg) - return &types.MsgUpdateWalletRecordResponse{}, nil } diff --git a/x/registry/keeper/msg_server_update_wallet_record_test.go b/x/registry/keeper/msg_server_update_wallet_record_test.go index 0f399047..7829b3df 100644 --- a/x/registry/keeper/msg_server_update_wallet_record_test.go +++ b/x/registry/keeper/msg_server_update_wallet_record_test.go @@ -3,11 +3,10 @@ package keeper_test import ( "fmt" - "github.com/mycel-domain/mycel/x/registry/types" + errorsmod "cosmossdk.io/errors" "github.com/mycel-domain/mycel/testutil" - - errorsmod "cosmossdk.io/errors" + "github.com/mycel-domain/mycel/x/registry/types" ) func (suite *KeeperTestSuite) TestUpdateWalletRecord() { @@ -71,7 +70,7 @@ func (suite *KeeperTestSuite) TestUpdateWalletRecord() { parent: "fuga", walletRecordType: "ETHEREUM_MAINNET_MAINNET", value: "0x1234567890123456789012345678901234567890", - expErr: errorsmod.Wrapf(types.ErrDomainNotFound, "hoge.fuga"), + expErr: errorsmod.Wrapf(types.ErrSecondLevelDomainNotFound, "hoge.fuga"), fn: func() {}, }, { @@ -80,7 +79,7 @@ func (suite *KeeperTestSuite) TestUpdateWalletRecord() { parent: "cel", walletRecordType: "ETHEREUM_MAINNET_MAINNET", value: "0x1234567890123456789012345678901234567890", - expErr: errorsmod.Wrapf(types.ErrDomainNotEditable, "%s", testutil.Bob), + expErr: errorsmod.Wrapf(types.ErrSecondLevelDomainNotEditable, "%s", testutil.Bob), fn: func() {}, }, } diff --git a/x/registry/keeper/msg_server_withdraw_registration_fee.go b/x/registry/keeper/msg_server_withdraw_registration_fee.go index c9881e25..8623eadd 100644 --- a/x/registry/keeper/msg_server_withdraw_registration_fee.go +++ b/x/registry/keeper/msg_server_withdraw_registration_fee.go @@ -5,6 +5,7 @@ import ( errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/mycel-domain/mycel/x/registry/types" ) @@ -13,7 +14,7 @@ func (k msgServer) WithdrawRegistrationFee(goCtx context.Context, msg *types.Msg // Get top level domain topLevelDomain, found := k.Keeper.GetTopLevelDomain(ctx, msg.Name) if !found { - return nil, errorsmod.Wrapf(types.ErrDomainNotFound, "%s", msg.Name) + return nil, errorsmod.Wrapf(types.ErrSecondLevelDomainNotFound, "%s", msg.Name) } if topLevelDomain.TotalWithdrawalAmount.IsZero() { diff --git a/x/registry/keeper/params.go b/x/registry/keeper/params.go index 3c356e6e..6c017c04 100644 --- a/x/registry/keeper/params.go +++ b/x/registry/keeper/params.go @@ -2,6 +2,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/mycel-domain/mycel/x/registry/types" ) diff --git a/x/registry/keeper/params_test.go b/x/registry/keeper/params_test.go index ebc790f1..e0b7a9fe 100644 --- a/x/registry/keeper/params_test.go +++ b/x/registry/keeper/params_test.go @@ -3,9 +3,10 @@ package keeper_test import ( "testing" + "github.com/stretchr/testify/require" + testkeeper "github.com/mycel-domain/mycel/testutil/keeper" "github.com/mycel-domain/mycel/x/registry/types" - "github.com/stretchr/testify/require" ) func TestGetParams(t *testing.T) { diff --git a/x/registry/keeper/query_domain_ownership.go b/x/registry/keeper/query_domain_ownership.go index cedb145c..da634540 100644 --- a/x/registry/keeper/query_domain_ownership.go +++ b/x/registry/keeper/query_domain_ownership.go @@ -6,9 +6,10 @@ import ( "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" - "github.com/mycel-domain/mycel/x/registry/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + + "github.com/mycel-domain/mycel/x/registry/types" ) func (k Keeper) DomainOwnershipAll(goCtx context.Context, req *types.QueryAllDomainOwnershipRequest) (*types.QueryAllDomainOwnershipResponse, error) { diff --git a/x/registry/keeper/query_domain_registration_fee.go b/x/registry/keeper/query_domain_registration_fee.go index 5925c2ad..93667304 100644 --- a/x/registry/keeper/query_domain_registration_fee.go +++ b/x/registry/keeper/query_domain_registration_fee.go @@ -4,26 +4,70 @@ import ( "context" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/mycel-domain/mycel/x/registry/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + + "github.com/mycel-domain/mycel/x/registry/types" ) +func createErrorResponse(err error) *types.QueryDomainRegistrationFeeResponse { + return &types.QueryDomainRegistrationFeeResponse{ + IsRegistrable: false, + Fee: sdk.NewCoins(), + RegistrationPeriodInYear: 0, + MaxSubDomainRegistrations: 0, + ErrorMessage: err.Error(), + } +} + func (k Keeper) DomainRegistrationFee(goCtx context.Context, req *types.QueryDomainRegistrationFeeRequest) (*types.QueryDomainRegistrationFeeResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") } ctx := sdk.UnwrapSDKContext(goCtx) - - // TODO: Process the query - _ = ctx - domain := types.SecondLevelDomain{Name: req.Name, Parent: req.Parent} - config := k.GetParentsSubdomainConfig(ctx, domain) - fee, err := config.GetRegistrationFee(domain.Name, 1) - if err != nil { - return nil, err + if req.Parent == "" { + // Top level domain + config := types.GetDefaultSubdomainConfig(1) + domain := types.TopLevelDomain{ + Name: req.Name, + SubdomainConfig: &config, + } + err := k.ValidateTopLevelDomainIsRegistrable(ctx, domain) + if err != nil { + return createErrorResponse(err), nil + } + fee, err := k.GetTopLevelDomainFee(ctx, domain, req.RegistrationPeriodInYear) + if err != nil { + return createErrorResponse(err), nil + } else { + return &types.QueryDomainRegistrationFeeResponse{ + IsRegistrable: true, + Fee: fee.TotalFee, + RegistrationPeriodInYear: 1, + MaxSubDomainRegistrations: config.MaxSubdomainRegistrations, + ErrorMessage: "", + }, nil + } + } else { + // Second level domain + domain := types.SecondLevelDomain{Name: req.Name, Parent: req.Parent} + err := k.ValidateSecondLevelDomainIsRegistrable(ctx, domain) + if err != nil { + return createErrorResponse(err), nil + } + config := k.GetSecondLevelDomainParentsSubdomainConfig(ctx, domain) + fee, err := config.GetRegistrationFee(domain.Name, req.RegistrationPeriodInYear) + if err != nil { + return createErrorResponse(err), nil + } else { + return &types.QueryDomainRegistrationFeeResponse{ + IsRegistrable: true, + Fee: sdk.NewCoins(fee), + RegistrationPeriodInYear: 1, + MaxSubDomainRegistrations: 0, + ErrorMessage: "", + }, nil + } } - - return &types.QueryDomainRegistrationFeeResponse{Fee: *fee}, nil } diff --git a/x/registry/keeper/query_is_registrable_domain.go b/x/registry/keeper/query_is_registrable_domain.go deleted file mode 100644 index b7b2683f..00000000 --- a/x/registry/keeper/query_is_registrable_domain.go +++ /dev/null @@ -1,28 +0,0 @@ -package keeper - -import ( - "context" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/mycel-domain/mycel/x/registry/types" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" -) - -func (k Keeper) IsRegistrableDomain(goCtx context.Context, req *types.QueryIsRegistrableDomainRequest) (*types.QueryIsRegistrableDomainResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - - ctx := sdk.UnwrapSDKContext(goCtx) - - // TODO: Process the query - _ = ctx - domain := types.SecondLevelDomain{Name: req.Name, Parent: req.Parent} - err := k.ValidateSecondLevelDomain(ctx, domain) - if err != nil { - return &types.QueryIsRegistrableDomainResponse{IsRegstrable: false, ErrorMessage: err.Error()}, nil - } - - return &types.QueryIsRegistrableDomainResponse{IsRegstrable: true, ErrorMessage: ""}, nil -} diff --git a/x/registry/keeper/query_params.go b/x/registry/keeper/query_params.go index d6c2738e..80e68c20 100644 --- a/x/registry/keeper/query_params.go +++ b/x/registry/keeper/query_params.go @@ -4,9 +4,10 @@ import ( "context" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/mycel-domain/mycel/x/registry/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + + "github.com/mycel-domain/mycel/x/registry/types" ) func (k Keeper) Params(goCtx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { diff --git a/x/registry/keeper/query_params_test.go b/x/registry/keeper/query_params_test.go index b23d6e3e..1d641a6f 100644 --- a/x/registry/keeper/query_params_test.go +++ b/x/registry/keeper/query_params_test.go @@ -4,9 +4,10 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + testkeeper "github.com/mycel-domain/mycel/testutil/keeper" "github.com/mycel-domain/mycel/x/registry/types" - "github.com/stretchr/testify/require" ) func TestParamsQuery(t *testing.T) { diff --git a/x/registry/keeper/query_second_level_domain.go b/x/registry/keeper/query_second_level_domain.go index 9593c228..1a7a0f40 100644 --- a/x/registry/keeper/query_second_level_domain.go +++ b/x/registry/keeper/query_second_level_domain.go @@ -6,9 +6,10 @@ import ( "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" - "github.com/mycel-domain/mycel/x/registry/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + + "github.com/mycel-domain/mycel/x/registry/types" ) func (k Keeper) SecondLevelDomainAll(goCtx context.Context, req *types.QueryAllSecondLevelDomainRequest) (*types.QueryAllSecondLevelDomainResponse, error) { diff --git a/x/registry/keeper/query_top_level_domain.go b/x/registry/keeper/query_top_level_domain.go index c6dfb12d..b6bfd7a0 100644 --- a/x/registry/keeper/query_top_level_domain.go +++ b/x/registry/keeper/query_top_level_domain.go @@ -6,9 +6,10 @@ import ( "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" - "github.com/mycel-domain/mycel/x/registry/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + + "github.com/mycel-domain/mycel/x/registry/types" ) func (k Keeper) TopLevelDomainAll(goCtx context.Context, req *types.QueryAllTopLevelDomainRequest) (*types.QueryAllTopLevelDomainResponse, error) { diff --git a/x/registry/keeper/register_second_level_domain.go b/x/registry/keeper/register_second_level_domain.go deleted file mode 100644 index 6a5b456a..00000000 --- a/x/registry/keeper/register_second_level_domain.go +++ /dev/null @@ -1,109 +0,0 @@ -package keeper - -import ( - "github.com/mycel-domain/mycel/x/registry/types" - - errorsmod "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -func (k Keeper) GetParentDomain(ctx sdk.Context, domain types.SecondLevelDomain) (parentDomain types.TopLevelDomain, found bool) { - // Get parent domain - parent := domain.ParseParent() - parentDomain, found = k.GetTopLevelDomain(ctx, parent) - return parentDomain, found -} - -func (k Keeper) GetParentsSubdomainConfig(ctx sdk.Context, domain types.SecondLevelDomain) types.SubdomainConfig { - // Get parent domain - parentDomain, found := k.GetParentDomain(ctx, domain) - if !found || parentDomain.SubdomainConfig == nil { - panic("parent domain or config not found") - } - return *parentDomain.SubdomainConfig -} - -// Pay SLD registration fee -func (k Keeper) PaySLDRegstrationFee(ctx sdk.Context, payer sdk.AccAddress, domain types.SecondLevelDomain, registrationPeriodInYear uint64) (fee *sdk.Coin, err error) { - config := k.GetParentsSubdomainConfig(ctx, domain) - - fee, err = config.GetRegistrationFee(domain.Name, registrationPeriodInYear) - if err != nil { - return fee, err - } - - // Send coins from payer to module account - k.bankKeeper.SendCoinsFromAccountToModule(ctx, payer, types.ModuleName, sdk.NewCoins(*fee)) - - // Update store - parent, found := k.GetTopLevelDomain(ctx, domain.Parent) - if !found { - panic("parent not found") - } - parent.TotalWithdrawalAmount = parent.TotalWithdrawalAmount.Add(*fee) - k.SetTopLevelDomain(ctx, parent) - - return fee, err -} - -func (k Keeper) AppendToOwnedDomain(ctx sdk.Context, owner string, name string, parent string) { - domainOwnership, found := k.GetDomainOwnership(ctx, owner) - if found { - domainOwnership.Domains = append(domainOwnership.Domains, &types.OwnedDomain{Name: name, Parent: parent}) - k.SetDomainOwnership(ctx, domainOwnership) - } else { - k.SetDomainOwnership(ctx, types.DomainOwnership{Owner: owner, Domains: []*types.OwnedDomain{{Name: name, Parent: parent}}}) - } -} - -func (k Keeper) IncrementParentsSubdomainCount(ctx sdk.Context, domain types.SecondLevelDomain) { - // Increment parent's subdomain count - parent := domain.ParseParent() - parentDomain, found := k.GetTopLevelDomain(ctx, parent) - if !found { - panic("parent not found") - } - parentDomain.SubdomainCount++ - k.SetTopLevelDomain(ctx, parentDomain) -} - -func (k Keeper) RegisterSecondLevelDomain(ctx sdk.Context, domain types.SecondLevelDomain, owner sdk.AccAddress, registrationPeriodIYear uint64) (err error) { - // Validate domain - err = k.ValidateSecondLevelDomain(ctx, domain) - if err != nil { - return err - } - - // Get parent domain of second level domain - parentDomain, found := k.GetParentDomain(ctx, domain) - - if !found { - panic("parent not found") - } - - // Check if parent domain has subdomain registration config - if parentDomain.SubdomainConfig.MaxSubdomainRegistrations <= parentDomain.SubdomainCount { - err = errorsmod.Wrapf(types.ErrMaxSubdomainCountReached, "%d", parentDomain.SubdomainCount) - return err - } - - // Increment parents subdomain SubdomainCount - k.IncrementParentsSubdomainCount(ctx, domain) - - // Pay SLD registration fee - fee, err := k.PaySLDRegstrationFee(ctx, owner, domain, registrationPeriodIYear) - if err != nil { - return err - } - - // Append to owned domain - k.AppendToOwnedDomain(ctx, owner.String(), domain.Name, domain.Parent) - - // Set domain - k.SetSecondLevelDomain(ctx, domain) - - // Emit event - EmitRegisterSecondLevelDomainEvent(ctx, domain, *fee) - - return err -} diff --git a/x/registry/keeper/register_top_level_domain.go b/x/registry/keeper/register_top_level_domain.go deleted file mode 100644 index fbc9db28..00000000 --- a/x/registry/keeper/register_top_level_domain.go +++ /dev/null @@ -1,113 +0,0 @@ -package keeper - -import ( - "fmt" - - "cosmossdk.io/math" - - "github.com/mycel-domain/mycel/x/registry/types" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/mycel-domain/mycel/app/params" - furnacetypes "github.com/mycel-domain/mycel/x/furnace/types" -) - -func (k Keeper) GetBurnWeight(ctx sdk.Context) (weight math.LegacyDec, err error) { - inflation := k.mintKeeper.GetMinter(ctx).Inflation - bondedRatio := k.mintKeeper.BondedRatio(ctx) - - // TODO: Get alpha from params - stakingInflationRatio := k.GetParams(ctx).StakingInflationRatio - alpha := math.LegacyMustNewDecFromStr(fmt.Sprintf("%f", stakingInflationRatio)) - - w1 := alpha.Mul(bondedRatio) - w2 := inflation.Mul(math.LegacyMustNewDecFromStr("1").Sub(alpha)) - weight = w1.Add(w2) - return weight, nil -} - -// Pay TLD registration fee -func (k Keeper) PayTLDRegstrationFee(ctx sdk.Context, payer sdk.AccAddress, domain types.TopLevelDomain, registrationPeriodInYear uint64) (registrationFee types.TopLevelDomainRegistrationFee, err error) { - // TODO: Support other denoms - denom := params.DefaultBondDenom - - // Get base fee - baseFeeInUsd := k.GetParams(ctx).TopLevelDomainBaseFeeInUsd - if baseFeeInUsd == 0 { - panic("base fee is not set") - } - - // Get Registration fee (=X) - fee, err := domain.GetRegistrationFeeAmountInDenom(denom, baseFeeInUsd, registrationPeriodInYear) - if err != nil { - return types.TopLevelDomainRegistrationFee{}, err - } - - // Get burn weight (=W) - weight, err := k.GetBurnWeight(ctx) - if err != nil { - return types.TopLevelDomainRegistrationFee{}, err - } - registrationFee.BurnWeight = weight - - // Get price (=P) - price, err := types.GetMycelPrice(denom) - if err != nil { - return types.TopLevelDomainRegistrationFee{}, err - } - - // Calc burn amount (=WX/P) - amountToBurn := weight.Mul(math.LegacyNewDecFromBigInt(fee.BigInt())).Quo(math.LegacyNewDecFromBigInt(price.BigInt())).TruncateInt() - amountToTreasury := fee.Sub(amountToBurn) - - registrationFee.RegistrationFeeToBurn = sdk.NewCoin(denom, amountToBurn) - registrationFee.RegistrationFeeToTreasury = sdk.NewCoin(denom, amountToTreasury) - - // Send coins to treasury - err = k.distributionKeeper.FundCommunityPool(ctx, sdk.NewCoins(registrationFee.RegistrationFeeToTreasury), payer) - if err != nil { - return types.TopLevelDomainRegistrationFee{}, err - } - - // Send coins to furnace module - err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, payer, furnacetypes.ModuleName, sdk.NewCoins(registrationFee.RegistrationFeeToBurn)) - if err != nil { - return types.TopLevelDomainRegistrationFee{}, err - } - // Store burn amount - _, err = k.furnaceKeeper.AddRegistrationFeeToBurnAmounts(ctx, registrationPeriodInYear, registrationFee.RegistrationFeeToBurn) - if err != nil { - return types.TopLevelDomainRegistrationFee{}, err - } - - // Set total registration fee - if registrationFee.RegistrationFeeToBurn.Denom == registrationFee.RegistrationFeeToTreasury.Denom { - registrationFee.TotalRegistrationFee = sdk.NewCoins(registrationFee.RegistrationFeeToBurn.Add(registrationFee.RegistrationFeeToTreasury)) - } else { - registrationFee.TotalRegistrationFee = sdk.NewCoins(registrationFee.RegistrationFeeToBurn, registrationFee.RegistrationFeeToTreasury) - } - - return registrationFee, nil -} - -func (k Keeper) RegisterTopLevelDomain(ctx sdk.Context, domain types.TopLevelDomain, owner sdk.AccAddress, registrationPeriodIYear uint64) (err error) { - // Validate domain - err = k.ValidateTopLevelDomain(ctx, domain) - if err != nil { - return err - } - - // Pay TLD registration fee - topLevelDomainRegistrationFee, err := k.PayTLDRegstrationFee(ctx, owner, domain, registrationPeriodIYear) - if err != nil { - return err - } - - // Set domain - k.SetTopLevelDomain(ctx, domain) - - // Emit event - EmitRegisterTopLevelDomainEvent(ctx, domain, topLevelDomainRegistrationFee) - - return err -} diff --git a/x/registry/keeper/second_level_domain.go b/x/registry/keeper/second_level_domain.go index 6f7be26c..96bf3fb2 100644 --- a/x/registry/keeper/second_level_domain.go +++ b/x/registry/keeper/second_level_domain.go @@ -1,12 +1,13 @@ package keeper import ( - "github.com/mycel-domain/mycel/x/registry/types" "time" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" - errosmod "github.com/cosmos/cosmos-sdk/types/errors" + errorsmod "github.com/cosmos/cosmos-sdk/types/errors" + + "github.com/mycel-domain/mycel/x/registry/types" ) // SetSecondLevelDomain set a specific second-level-domain in the store from its index @@ -70,7 +71,13 @@ func (k Keeper) GetAllSecondLevelDomain(ctx sdk.Context) (list []types.SecondLev return } -// Get valid second level domain +// Get is second-level-domain already taken +func (k Keeper) GetIsSecondLevelDomainAlreadyTaken(ctx sdk.Context, domain types.SecondLevelDomain) (isDomainAlreadyTaken bool) { + _, isDomainAlreadyTaken = k.GetSecondLevelDomain(ctx, domain.Name, domain.Parent) + return isDomainAlreadyTaken +} + +// Get valid second-level-domain func (k Keeper) GetValidSecondLevelDomain(ctx sdk.Context, name string, parent string) (secondLevelDomain types.SecondLevelDomain, err error) { // Regex validation err = types.ValidateSecondLevelDomainName(name) @@ -81,17 +88,135 @@ func (k Keeper) GetValidSecondLevelDomain(ctx sdk.Context, name string, parent s if err != nil { return secondLevelDomain, err } - // Get second level domain + + // Get parent domain + _, err = k.GetValidTopLevelDomain(ctx, parent) + if err != nil { + return types.SecondLevelDomain{}, err + } + + // Get second-level-domain secondLevelDomain, isFound := k.GetSecondLevelDomain(ctx, name, parent) if !isFound { - return secondLevelDomain, errosmod.Wrapf(types.ErrDomainNotFound, "%s.%s", name, parent) + return types.SecondLevelDomain{}, errorsmod.Wrapf(types.ErrSecondLevelDomainNotFound, "%s.%s", name, parent) } - // Check if domain is not expired - expirationDate := time.Unix(0, secondLevelDomain.ExpirationDate) - if ctx.BlockTime().After(expirationDate) && secondLevelDomain.ExpirationDate != 0 { - return secondLevelDomain, errosmod.Wrapf(types.ErrDomainExpired, "%s", name) + // Check if second-level-domain is not expired + if ctx.BlockTime().After(secondLevelDomain.ExpirationDate) && secondLevelDomain.ExpirationDate != (time.Time{}) { + return types.SecondLevelDomain{}, errorsmod.Wrapf(types.ErrSecondLevelDomainExpired, "%s", name) } return secondLevelDomain, nil } + +// Get parent domain +func (k Keeper) GetSecondLevelDomainParent(ctx sdk.Context, domain types.SecondLevelDomain) (parentDomain types.TopLevelDomain, found bool) { + // Get parent domain + parent := domain.ParseParent() + parentDomain, found = k.GetTopLevelDomain(ctx, parent) + return parentDomain, found +} + +// Get parent domain's subdomain config +func (k Keeper) GetSecondLevelDomainParentsSubdomainConfig(ctx sdk.Context, domain types.SecondLevelDomain) types.SubdomainConfig { + // Get parent domain + parentDomain, found := k.GetSecondLevelDomainParent(ctx, domain) + if !found || parentDomain.SubdomainConfig == nil { + panic("parent domain or config not found") + } + return *parentDomain.SubdomainConfig +} + +// Increment parents subdomain count +func (k Keeper) IncrementParentsSubdomainCount(ctx sdk.Context, domain types.SecondLevelDomain) { + // Increment parent's subdomain count + parent := domain.ParseParent() + parentDomain, found := k.GetTopLevelDomain(ctx, parent) + if !found { + panic("parent not found") + } + parentDomain.SubdomainCount++ + k.SetTopLevelDomain(ctx, parentDomain) +} + +// Pay SLD registration fee +func (k Keeper) PaySecondLevelDomainRegstrationFee(ctx sdk.Context, payer sdk.AccAddress, domain types.SecondLevelDomain, registrationPeriodInYear uint64) (fee sdk.Coin, err error) { + config := k.GetSecondLevelDomainParentsSubdomainConfig(ctx, domain) + + fee, err = config.GetRegistrationFee(domain.Name, registrationPeriodInYear) + if err != nil { + return fee, err + } + + // Send coins from payer to module account + err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, payer, types.ModuleName, sdk.NewCoins(fee)) + if err != nil { + return fee, err + } + + // Update store + parent, found := k.GetTopLevelDomain(ctx, domain.Parent) + if !found { + panic("parent not found") + } + parent.TotalWithdrawalAmount = parent.TotalWithdrawalAmount.Add(fee) + k.SetTopLevelDomain(ctx, parent) + + return fee, err +} + +// Validate second-level-domain is registrable +func (k Keeper) ValidateSecondLevelDomainIsRegistrable(ctx sdk.Context, secondLevelDomain types.SecondLevelDomain) error { + // Validate second-level-domain + err := secondLevelDomain.Validate() + if err != nil { + return err + } + // Check if second-level-domain is already taken + isTaken := k.GetIsSecondLevelDomainAlreadyTaken(ctx, secondLevelDomain) + if isTaken { + return errorsmod.Wrapf(types.ErrSecondLevelDomainAlreadyTaken, "%s.%s", secondLevelDomain.Name, secondLevelDomain.Parent) + } + + // Get parent domain of second-level-domain + parentDomain, found := k.GetSecondLevelDomainParent(ctx, secondLevelDomain) + if !found { + return errorsmod.Wrapf(types.ErrSecondLevelDomainParentDoesNotExist, "%s", secondLevelDomain.Parent) + } + + // Check if parent domain has subdomain registration config + if parentDomain.SubdomainConfig.MaxSubdomainRegistrations <= parentDomain.SubdomainCount { + return errorsmod.Wrapf(types.ErrTopLevelDomainMaxSubdomainCountReached, "%d", parentDomain.SubdomainCount) + } + + return nil +} + +// Register second level domain +func (k Keeper) RegisterSecondLevelDomain(ctx sdk.Context, secondLevelDomain types.SecondLevelDomain, owner sdk.AccAddress, registrationPeriodIYear uint64) (err error) { + // Validate second-level-domain is registrable + err = k.ValidateSecondLevelDomainIsRegistrable(ctx, secondLevelDomain) + if err != nil { + return err + } + + // Increment parents subdomain SubdomainCount + k.IncrementParentsSubdomainCount(ctx, secondLevelDomain) + + // Pay SLD registration fee + fee, err := k.PaySecondLevelDomainRegstrationFee(ctx, owner, secondLevelDomain, registrationPeriodIYear) + if err != nil { + return err + } + + // Append to owned domain + k.AppendToOwnedDomain(ctx, owner.String(), secondLevelDomain.Name, secondLevelDomain.Parent) + + // Set domain + k.SetSecondLevelDomain(ctx, secondLevelDomain) + + // Emit event + EmitRegisterSecondLevelDomainEvent(ctx, secondLevelDomain, fee) + + return err +} diff --git a/x/registry/keeper/second_level_domain_test.go b/x/registry/keeper/second_level_domain_test.go index 2fa32153..3c2af8bf 100644 --- a/x/registry/keeper/second_level_domain_test.go +++ b/x/registry/keeper/second_level_domain_test.go @@ -4,15 +4,16 @@ import ( "fmt" "strconv" "testing" + "time" + + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" keepertest "github.com/mycel-domain/mycel/testutil/keeper" "github.com/mycel-domain/mycel/testutil/nullify" "github.com/mycel-domain/mycel/x/registry/keeper" "github.com/mycel-domain/mycel/x/registry/types" - - errorsmod "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" ) // Prevent strconv unused error @@ -88,16 +89,16 @@ func (suite *KeeperTestSuite) TestGetValidSecondLevelDomain() { { secondLevelDomain: types.SecondLevelDomain{ Name: "test", - Parent: "test", - ExpirationDate: suite.ctx.BlockTime().AddDate(0, 0, 20).UnixNano(), + Parent: "cel", + ExpirationDate: suite.ctx.BlockTime().AddDate(0, 0, 20), }, expErr: nil, }, { secondLevelDomain: types.SecondLevelDomain{ Name: "test", - Parent: "test", - ExpirationDate: 0, + Parent: "cel", + ExpirationDate: time.Time{}, }, expErr: nil, }, @@ -105,9 +106,9 @@ func (suite *KeeperTestSuite) TestGetValidSecondLevelDomain() { secondLevelDomain: types.SecondLevelDomain{ Name: "test", Parent: "test", - ExpirationDate: suite.ctx.BlockTime().AddDate(0, 0, -20).UnixNano(), + ExpirationDate: suite.ctx.BlockTime().AddDate(0, 0, -20), }, - expErr: errorsmod.Wrapf(types.ErrDomainExpired, "test"), + expErr: errorsmod.Wrapf(types.ErrTopLevelDomainNotFound, "test"), }, } for i, tc := range testCases { diff --git a/x/registry/keeper/setup_test.go b/x/registry/keeper/setup_test.go index 42335286..c468a8d1 100644 --- a/x/registry/keeper/setup_test.go +++ b/x/registry/keeper/setup_test.go @@ -1,19 +1,20 @@ package keeper_test import ( - mycelapp "github.com/mycel-domain/mycel/app" - "github.com/mycel-domain/mycel/x/registry/keeper" - "github.com/mycel-domain/mycel/x/registry/types" "testing" "time" - "github.com/mycel-domain/mycel/testutil" - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/stretchr/testify/suite" + + mycelapp "github.com/mycel-domain/mycel/app" + "github.com/mycel-domain/mycel/app/params" + "github.com/mycel-domain/mycel/testutil" + "github.com/mycel-domain/mycel/x/registry/keeper" + "github.com/mycel-domain/mycel/x/registry/types" ) type KeeperTestSuite struct { @@ -56,7 +57,7 @@ func makeBalance(address string, balance int64) banktypes.Balance { Address: address, Coins: sdk.Coins{ sdk.Coin{ - Denom: types.MycelDenom, + Denom: params.DefaultBondDenom, Amount: sdk.NewInt(balance), }, }, diff --git a/x/registry/keeper/top_level_domain.go b/x/registry/keeper/top_level_domain.go index fd9983e6..2b4df079 100644 --- a/x/registry/keeper/top_level_domain.go +++ b/x/registry/keeper/top_level_domain.go @@ -6,6 +6,9 @@ import ( errorsmod "cosmossdk.io/errors" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/mycel-domain/mycel/app/params" + furnacetypes "github.com/mycel-domain/mycel/x/furnace/types" "github.com/mycel-domain/mycel/x/registry/types" ) @@ -65,8 +68,13 @@ func (k Keeper) GetAllTopLevelDomain(ctx sdk.Context) (list []types.TopLevelDoma return } -// Get valid top level domain +// Get is top-level-domain already taken +func (k Keeper) GetIsTopLevelDomainAlreadyTaken(ctx sdk.Context, domain types.TopLevelDomain) (isDomainAlreadyTaken bool) { + _, isDomainAlreadyTaken = k.GetTopLevelDomain(ctx, domain.Name) + return isDomainAlreadyTaken +} +// Get valid-top-level domain func (k Keeper) GetValidTopLevelDomain(ctx sdk.Context, name string) (topLevelDomain types.TopLevelDomain, err error) { // Regex validation err = types.ValidateTopLevelDomainName(name) @@ -75,16 +83,151 @@ func (k Keeper) GetValidTopLevelDomain(ctx sdk.Context, name string) (topLevelDo } // Get top level domain - topLevelDomain, isFound := k.GetTopLevelDomain(ctx, name) - if !isFound { - return topLevelDomain, errorsmod.Wrapf(types.ErrDomainNotFound, "%s", name) + topLevelDomain, found := k.GetTopLevelDomain(ctx, name) + if !found { + return topLevelDomain, errorsmod.Wrapf(types.ErrTopLevelDomainNotFound, "%s", name) } // Check if domain is not expired - expirationDate := time.Unix(0, topLevelDomain.ExpirationDate) - if ctx.BlockTime().After(expirationDate) && topLevelDomain.ExpirationDate != 0 { - return topLevelDomain, errorsmod.Wrapf(types.ErrDomainExpired, "%s", name) + if ctx.BlockTime().After(topLevelDomain.ExpirationDate) && topLevelDomain.ExpirationDate != (time.Time{}) { + return topLevelDomain, errorsmod.Wrapf(types.ErrTopLevelDomainExpired, "%s", name) } return topLevelDomain, nil } + +// Pay top-level-domain registration fee +func (k Keeper) PayTopLevelDomainFee(ctx sdk.Context, payer sdk.AccAddress, domain types.TopLevelDomain, registrationPeriodInYear uint64) (registrationFee types.TopLevelDomainFee, err error) { + // Get registration fee + registrationFee, err = k.GetTopLevelDomainFee(ctx, domain, registrationPeriodInYear) + if err != nil { + return types.TopLevelDomainFee{}, err + } + + // Send coins to treasury + err = k.distributionKeeper.FundCommunityPool(ctx, sdk.NewCoins(registrationFee.FeeToTreasury), payer) + if err != nil { + return types.TopLevelDomainFee{}, err + } + + // Send coins to furnace module + err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, payer, furnacetypes.ModuleName, sdk.NewCoins(registrationFee.FeeToBurn)) + if err != nil { + return types.TopLevelDomainFee{}, err + } + // Store burn amount + _, err = k.furnaceKeeper.AddRegistrationFeeToBurnAmounts(ctx, registrationPeriodInYear, registrationFee.FeeToBurn) + if err != nil { + return types.TopLevelDomainFee{}, err + } + + // Set total registration fee + if registrationFee.FeeToBurn.Denom == registrationFee.FeeToTreasury.Denom { + registrationFee.TotalFee = sdk.NewCoins(registrationFee.FeeToBurn.Add(registrationFee.FeeToTreasury)) + } else { + registrationFee.TotalFee = sdk.NewCoins(registrationFee.FeeToBurn, registrationFee.FeeToTreasury) + } + + return registrationFee, nil +} + +func (k Keeper) ValidateTopLevelDomainIsRegistrable(ctx sdk.Context, topLevelDomain types.TopLevelDomain) error { + // Validate top-level-domain + err := topLevelDomain.Validate() + if err != nil { + return err + } + // Check if top-level-domain is already taken + isTaken := k.GetIsTopLevelDomainAlreadyTaken(ctx, topLevelDomain) + if isTaken { + return errorsmod.Wrapf(types.ErrTopLevelDomainAlreadyTaken, "%s", topLevelDomain.Name) + } + + return nil +} + +// Register top-level-domain +func (k Keeper) RegisterTopLevelDomain(ctx sdk.Context, creator string, domainName string, registrationPeriodInYear uint64) (topLevelDomain types.TopLevelDomain, fee types.TopLevelDomainFee, err error) { + // Create top-level-domain + currentTime := ctx.BlockTime() + expirationDate := currentTime.AddDate(0, 0, params.OneYearInDays*int(registrationPeriodInYear)) + accessControl := map[string]types.DomainRole{ + creator: types.DomainRole_OWNER, + } + defaultRegistrationConfig := types.GetDefaultSubdomainConfig(303) + topLevelDomain = types.TopLevelDomain{ + Name: domainName, + ExpirationDate: expirationDate, + Metadata: nil, + SubdomainConfig: &defaultRegistrationConfig, + AccessControl: accessControl, + TotalWithdrawalAmount: sdk.NewCoins(), + } + + // Validate top-level-domain is registrable + err = k.ValidateTopLevelDomainIsRegistrable(ctx, topLevelDomain) + if err != nil { + return types.TopLevelDomain{}, types.TopLevelDomainFee{}, err + } + + // Pay TLD registration fee + creatorAddress, err := sdk.AccAddressFromBech32(creator) + if err != nil { + return types.TopLevelDomain{}, types.TopLevelDomainFee{}, err + } + fee, err = k.PayTopLevelDomainFee(ctx, creatorAddress, topLevelDomain, registrationPeriodInYear) + if err != nil { + return types.TopLevelDomain{}, types.TopLevelDomainFee{}, err + } + + // Set domain + k.SetTopLevelDomain(ctx, topLevelDomain) + + // Append to owned domain + k.AppendToOwnedDomain(ctx, creator, topLevelDomain.Name, "") + + // Emit event + EmitRegisterTopLevelDomainEvent(ctx, topLevelDomain, fee) + + return topLevelDomain, fee, nil +} + +// Extend expiration date +func (k Keeper) ExtendTopLevelDomainExpirationDate(ctx sdk.Context, creator string, domainName string, extensionPeriodInYear uint64) (topLevelDomain types.TopLevelDomain, fee types.TopLevelDomainFee, err error) { + // Get domain + topLevelDomain, found := k.GetTopLevelDomain(ctx, domainName) + if !found { + return types.TopLevelDomain{}, types.TopLevelDomainFee{}, errorsmod.Wrapf(types.ErrTopLevelDomainNotFound, "%s", domainName) + } + + // Check if the domain is editable + _, err = topLevelDomain.IsEditable(creator) + if err != nil { + return types.TopLevelDomain{}, types.TopLevelDomainFee{}, err + } + + creatorAddress, err := sdk.AccAddressFromBech32(creator) + if err != nil { + return types.TopLevelDomain{}, types.TopLevelDomainFee{}, err + } + // Check if the domain is editable + _, err = topLevelDomain.IsEditable(creator) + if err != nil { + return types.TopLevelDomain{}, types.TopLevelDomainFee{}, err + } + + // Pay TLD extend fee + fee, err = k.PayTopLevelDomainFee(ctx, creatorAddress, topLevelDomain, extensionPeriodInYear) + if err != nil { + return types.TopLevelDomain{}, types.TopLevelDomainFee{}, err + } + + // Update domain store + topLevelDomain.ExtendExpirationDate(topLevelDomain.ExpirationDate, extensionPeriodInYear) + k.SetTopLevelDomain(ctx, topLevelDomain) + + // Emit event + EmitExtendTopLevelDomainExpirationDateEvent(ctx, topLevelDomain, fee) + + return topLevelDomain, fee, err +} diff --git a/x/registry/keeper/top_level_domain_fee.go b/x/registry/keeper/top_level_domain_fee.go new file mode 100644 index 00000000..5ab09778 --- /dev/null +++ b/x/registry/keeper/top_level_domain_fee.go @@ -0,0 +1,66 @@ +package keeper + +import ( + "fmt" + + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/mycel-domain/mycel/app/params" + "github.com/mycel-domain/mycel/x/registry/types" +) + +// Get burn weight +func (k Keeper) GetBurnWeight(ctx sdk.Context) (weight math.LegacyDec, err error) { + inflation := k.mintKeeper.GetMinter(ctx).Inflation + bondedRatio := k.mintKeeper.BondedRatio(ctx) + + // TODO: Get alpha from params + stakingInflationRatio := k.GetParams(ctx).StakingInflationRatio + alpha := math.LegacyMustNewDecFromStr(fmt.Sprintf("%f", stakingInflationRatio)) + + w1 := alpha.Mul(bondedRatio) + w2 := inflation.Mul(math.LegacyMustNewDecFromStr("1").Sub(alpha)) + weight = w1.Add(w2) + return weight, nil +} + +// Get top-level-domain fee +func (k Keeper) GetTopLevelDomainFee(ctx sdk.Context, topLevelDomain types.TopLevelDomain, registrationPeriodInYear uint64) (topLevelDomainFee types.TopLevelDomainFee, err error) { + // TODO: Support other denoms + denom := params.DefaultBondDenom + + // Get base fee + baseFeeInUsd := k.GetParams(ctx).TopLevelDomainBaseFeeInUsd + if baseFeeInUsd == 0 { + panic("base fee is not set") + } + + // Get Registration fee (=X) + fee, err := topLevelDomain.GetRegistrationFeeAmountInDenom(denom, baseFeeInUsd, registrationPeriodInYear) + if err != nil { + return types.TopLevelDomainFee{}, err + } + topLevelDomainFee.TotalFee = sdk.NewCoins(sdk.NewCoin(denom, fee)) + + // Get burn weight (=W) + weight, err := k.GetBurnWeight(ctx) + if err != nil { + return types.TopLevelDomainFee{}, err + } + topLevelDomainFee.BurnWeight = weight.String() + + // Get price (=P) + price, err := types.GetMycelPrice(denom) + if err != nil { + return types.TopLevelDomainFee{}, err + } + + // Calc burn amount (=WX/P) + amountToBurn := weight.Mul(math.LegacyNewDecFromBigInt(fee.BigInt())).Quo(math.LegacyNewDecFromBigInt(price.BigInt())).TruncateInt() + amountToTreasury := fee.Sub(amountToBurn) + topLevelDomainFee.FeeToBurn = sdk.NewCoin(denom, amountToBurn) + topLevelDomainFee.FeeToTreasury = sdk.NewCoin(denom, amountToTreasury) + + return topLevelDomainFee, nil +} diff --git a/x/registry/keeper/top_level_domain_test.go b/x/registry/keeper/top_level_domain_test.go index 01e11941..f90d1d94 100644 --- a/x/registry/keeper/top_level_domain_test.go +++ b/x/registry/keeper/top_level_domain_test.go @@ -2,17 +2,18 @@ package keeper_test import ( "fmt" - "strconv" "testing" + "time" errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + keepertest "github.com/mycel-domain/mycel/testutil/keeper" "github.com/mycel-domain/mycel/testutil/nullify" "github.com/mycel-domain/mycel/x/registry/keeper" "github.com/mycel-domain/mycel/x/registry/types" - "github.com/stretchr/testify/require" ) // Prevent strconv unused error @@ -73,23 +74,23 @@ func (suite *KeeperTestSuite) TestGetValidTopLevelDomain() { { topLevelDomain: types.TopLevelDomain{ Name: "test", - ExpirationDate: suite.ctx.BlockTime().AddDate(0, 0, 20).UnixNano(), + ExpirationDate: suite.ctx.BlockTime().AddDate(0, 0, 20), }, expErr: nil, }, { topLevelDomain: types.TopLevelDomain{ Name: "test", - ExpirationDate: 0, + ExpirationDate: time.Time{}, }, expErr: nil, }, { topLevelDomain: types.TopLevelDomain{ Name: "test", - ExpirationDate: suite.ctx.BlockTime().AddDate(0, 0, -20).UnixNano(), + ExpirationDate: suite.ctx.BlockTime().AddDate(0, 0, -20), }, - expErr: errorsmod.Wrapf(types.ErrDomainExpired, "test"), + expErr: errorsmod.Wrapf(types.ErrTopLevelDomainExpired, "test"), }, } for i, tc := range testCases { diff --git a/x/registry/keeper/validate_registration.go b/x/registry/keeper/validate_registration.go deleted file mode 100644 index 544acbb6..00000000 --- a/x/registry/keeper/validate_registration.go +++ /dev/null @@ -1,109 +0,0 @@ -package keeper - -import ( - "github.com/mycel-domain/mycel/x/registry/types" - - errorsmod "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// Get is domain already taken -func (k Keeper) GetIsDomainAlreadyTaken(ctx sdk.Context, domain types.SecondLevelDomain) (isDomainAlreadyTaken bool) { - _, isDomainAlreadyTaken = k.GetSecondLevelDomain(ctx, domain.Name, domain.Parent) - return isDomainAlreadyTaken -} - -// Get is parent domain exist -func (k Keeper) GetIsParentDomainExist(ctx sdk.Context, domain types.SecondLevelDomain) (isParentDomainExist bool) { - parent := domain.ParseParent() - _, isParentDomainExist = k.GetTopLevelDomain(ctx, parent) - return isParentDomainExist -} - -// Get is domain already taken -func (k Keeper) GetIsTopLevelDomainAlreadyTaken(ctx sdk.Context, domain types.TopLevelDomain) (isDomainAlreadyTaken bool) { - _, isDomainAlreadyTaken = k.GetTopLevelDomain(ctx, domain.Name) - return isDomainAlreadyTaken -} - -// Validate TLD registration -func (k Keeper) ValidateRegisterTLD(ctx sdk.Context, domain types.TopLevelDomain) (err error) { - // TODO: Validate TLD - // TODO: Is Staked enough to register TLD - return err -} - -// Validate SLD registration -func (k Keeper) ValidateRegisterSLD(ctx sdk.Context, domain types.SecondLevelDomain) (err error) { - isParentDomainExist := k.GetIsParentDomainExist(ctx, domain) - if !isParentDomainExist { - err = errorsmod.Wrapf(types.ErrParentDomainDoesNotExist, "%s", domain.Parent) - - } - - return err -} - -// Validate subdomain GetRegistrationFee -func (k Keeper) ValidateRegisterSubdomain(ctx sdk.Context, domain types.SecondLevelDomain) (err error) { - isParentDomainExist := k.GetIsParentDomainExist(ctx, domain) - if !isParentDomainExist { - err = errorsmod.Wrapf(types.ErrParentDomainDoesNotExist, "%s", domain.Parent) - - } - return err -} - -// Validate second-level-domain -func (k Keeper) ValidateSecondLevelDomain(ctx sdk.Context, domain types.SecondLevelDomain) (err error) { - // Type check - err = domain.Validate() - if err != nil { - return err - } - // Check if domain is already taken - isDomainAlreadyTaken := k.GetIsDomainAlreadyTaken(ctx, domain) - if isDomainAlreadyTaken { - err = errorsmod.Wrapf(types.ErrDomainIsAlreadyTaken, "%s.%s", domain.Name, domain.Parent) - return err - } - - // Validate SLD - err = k.ValidateRegisterSLD(ctx, domain) - if err != nil { - return err - } - // TODO: check is there any subdomain registration case? - // default: // Subdomain - // // Validate Subdomain - // err = k.ValidateRegisterSubdomain(ctx, domain) - // if err != nil { - // return err - // } - // } - - return err -} - -// Validate top-level-domain -func (k Keeper) ValidateTopLevelDomain(ctx sdk.Context, domain types.TopLevelDomain) (err error) { - // Type check - err = domain.Validate() - if err != nil { - return err - } - // Check if domain is already taken - isDomainAlreadyTaken := k.GetIsTopLevelDomainAlreadyTaken(ctx, domain) - if isDomainAlreadyTaken { - err = errorsmod.Wrapf(types.ErrDomainIsAlreadyTaken, "%s", domain.Name) - return err - } - - // Validate TLD - err = k.ValidateRegisterTLD(ctx, domain) - if err != nil { - return err - } - - return err -} diff --git a/x/registry/module.go b/x/registry/module.go index 49d94117..e85238c5 100644 --- a/x/registry/module.go +++ b/x/registry/module.go @@ -4,23 +4,20 @@ import ( "context" "encoding/json" "fmt" - - // this line is used by starport scaffolding # 1 - - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/spf13/cobra" + "log" abci "github.com/cometbft/cometbft/abci/types" - - "github.com/mycel-domain/mycel/x/registry/client/cli" - "github.com/mycel-domain/mycel/x/registry/keeper" - "github.com/mycel-domain/mycel/x/registry/types" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + "github.com/mycel-domain/mycel/x/registry/client/cli" + "github.com/mycel-domain/mycel/x/registry/keeper" + "github.com/mycel-domain/mycel/x/registry/types" ) var ( @@ -72,7 +69,10 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { - types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) + err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) + if err != nil { + log.Printf("%v", err) + } } // GetTxCmd returns the root Tx command for the module. The subcommands of this root command are used by end-users to generate new transactions containing messages defined in the module diff --git a/x/registry/module_simulation.go b/x/registry/module_simulation.go index 7dd05afc..5c227986 100644 --- a/x/registry/module_simulation.go +++ b/x/registry/module_simulation.go @@ -8,6 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/simulation" + "github.com/mycel-domain/mycel/testutil/sample" registrysimulation "github.com/mycel-domain/mycel/x/registry/simulation" "github.com/mycel-domain/mycel/x/registry/types" @@ -39,6 +40,10 @@ const ( // TODO: Determine the simulation weight value defaultWeightMsgWithdrawRegistrationFee int = 100 + opWeightMsgExtendTopLevelDomainExpirationDate = "op_weight_msg_extend_top_level_domain_expiration" + // TODO: Determine the simulation weight value + defaultWeightMsgExtendTopLevelDomainExpirationDate int = 100 + // this line is used by starport scaffolding # simapp/module/const ) @@ -111,6 +116,17 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp registrysimulation.SimulateMsgWithdrawRegistrationFee(am.accountKeeper, am.bankKeeper, am.keeper), )) + var weightMsgExtendTopLevelDomainExpirationDate int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgExtendTopLevelDomainExpirationDate, &weightMsgExtendTopLevelDomainExpirationDate, nil, + func(_ *rand.Rand) { + weightMsgExtendTopLevelDomainExpirationDate = defaultWeightMsgExtendTopLevelDomainExpirationDate + }, + ) + operations = append(operations, simulation.NewWeightedOperation( + weightMsgExtendTopLevelDomainExpirationDate, + registrysimulation.SimulateMsgExtendTopLevelDomainExpirationDate(am.accountKeeper, am.bankKeeper, am.keeper), + )) + // this line is used by starport scaffolding # simapp/module/operation return operations diff --git a/x/registry/simulation/extend_top_level_domain_expiration_date.go b/x/registry/simulation/extend_top_level_domain_expiration_date.go new file mode 100644 index 00000000..fe0ccd5b --- /dev/null +++ b/x/registry/simulation/extend_top_level_domain_expiration_date.go @@ -0,0 +1,30 @@ +package simulation + +import ( + "math/rand" + + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + + "github.com/mycel-domain/mycel/x/registry/keeper" + "github.com/mycel-domain/mycel/x/registry/types" +) + +func SimulateMsgExtendTopLevelDomainExpirationDate( + ak types.AccountKeeper, + bk types.BankKeeper, + k keeper.Keeper, +) simtypes.Operation { + return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + simAccount, _ := simtypes.RandomAcc(r, accs) + msg := &types.MsgExtendTopLevelDomainExpirationDate{ + Creator: simAccount.Address.String(), + } + + // TODO: Handling the ExtendTopLevelDomainExpirationDate simulation + + return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "ExtendTopLevelDomainExpirationDate simulation not implemented"), nil, nil + } +} diff --git a/x/registry/simulation/register_domain.go b/x/registry/simulation/register_domain.go index dd5f86cb..d793f92f 100644 --- a/x/registry/simulation/register_domain.go +++ b/x/registry/simulation/register_domain.go @@ -6,6 +6,7 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/mycel-domain/mycel/x/registry/keeper" "github.com/mycel-domain/mycel/x/registry/types" ) diff --git a/x/registry/simulation/register_top_level_domain.go b/x/registry/simulation/register_top_level_domain.go index 046b8325..e09595e2 100644 --- a/x/registry/simulation/register_top_level_domain.go +++ b/x/registry/simulation/register_top_level_domain.go @@ -6,6 +6,7 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/mycel-domain/mycel/x/registry/keeper" "github.com/mycel-domain/mycel/x/registry/types" ) diff --git a/x/registry/simulation/update_wallet_record.go b/x/registry/simulation/update_wallet_record.go index cc096361..4b9c600d 100644 --- a/x/registry/simulation/update_wallet_record.go +++ b/x/registry/simulation/update_wallet_record.go @@ -6,6 +6,7 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/mycel-domain/mycel/x/registry/keeper" "github.com/mycel-domain/mycel/x/registry/types" ) diff --git a/x/registry/simulation/withdraw_registration_fee.go b/x/registry/simulation/withdraw_registration_fee.go index 6ecae95e..c53d7c38 100644 --- a/x/registry/simulation/withdraw_registration_fee.go +++ b/x/registry/simulation/withdraw_registration_fee.go @@ -6,6 +6,7 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/mycel-domain/mycel/x/registry/keeper" "github.com/mycel-domain/mycel/x/registry/types" ) diff --git a/x/registry/types/codec.go b/x/registry/types/codec.go index 12dd4af1..1f72106b 100644 --- a/x/registry/types/codec.go +++ b/x/registry/types/codec.go @@ -12,6 +12,7 @@ func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgRegisterSecondLevelDomain{}, "registry/RegisterSecondLevelDomain", nil) cdc.RegisterConcrete(&MsgRegisterTopLevelDomain{}, "registry/RegisterTopLevelDomain", nil) cdc.RegisterConcrete(&MsgWithdrawRegistrationFee{}, "registry/WithdrawRegistrationFee", nil) + cdc.RegisterConcrete(&MsgExtendTopLevelDomainExpirationDate{}, "registry/ExtendTopLevelDomainExpirationDate", nil) // this line is used by starport scaffolding # 2 } @@ -28,6 +29,9 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgWithdrawRegistrationFee{}, ) + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgExtendTopLevelDomainExpirationDate{}, + ) // this line is used by starport scaffolding # 3 msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/registry/types/domain_type.go b/x/registry/types/domain_type.go deleted file mode 100644 index 08312eef..00000000 --- a/x/registry/types/domain_type.go +++ /dev/null @@ -1,9 +0,0 @@ -package types - -type DomainType int - -const ( - TLD DomainType = iota - SLD - SubDomain -) diff --git a/x/registry/types/errors.go b/x/registry/types/errors.go index 31151e09..216b58ac 100644 --- a/x/registry/types/errors.go +++ b/x/registry/types/errors.go @@ -6,26 +6,43 @@ import ( errorsmod "cosmossdk.io/errors" ) -// x/mycel module sentinel errors +// top-level-domain sentinel errors var ( - ErrSample = errorsmod.Register(ModuleName, 1100, "sample error") - ErrDomainIsAlreadyTaken = errorsmod.Register(ModuleName, 1101, "domain is already taken") - ErrInvalidDomainName = errorsmod.Register(ModuleName, 1102, "invalid name") - ErrInvalidDomainParent = errorsmod.Register(ModuleName, 1103, "invalid parent") - ErrDomainNotFound = errorsmod.Register(ModuleName, 1104, "domain not found") - ErrInvalidWalletAddress = errorsmod.Register(ModuleName, 1105, "invalid wallet address") - ErrInvalidWalletRecordType = errorsmod.Register(ModuleName, 1106, "invalid wallet record type") - ErrInvalidDnsRecordValue = errorsmod.Register(ModuleName, 1107, "invalid dns record value") - ErrInvalidDnsRecordType = errorsmod.Register(ModuleName, 1108, "invalid dns record type") - ErrDomainNotEditable = errorsmod.Register(ModuleName, 1109, "role not pemitted to edit the domain") - ErrParentDomainDoesNotExist = errorsmod.Register(ModuleName, 1110, "parent domain does not exist") - ErrParentDomainMustBeEmpty = errorsmod.Register(ModuleName, 1111, "parent domain must be empty") - ErrDomainNotRegistrable = errorsmod.Register(ModuleName, 1112, "domain is not registrable") - ErrMaxSubdomainCountReached = errorsmod.Register(ModuleName, 1113, "max subdomain count reached") - ErrInvalidRegistrationPeriod = errorsmod.Register(ModuleName, 1114, "invalid registration period") - ErrDomainExpired = errorsmod.Register(ModuleName, 1115, "domain expired") - ErrNoEnoughBalance = errorsmod.Register(ModuleName, 1116, "no enough balance") - ErrNoPermissionToWithdraw = errorsmod.Register(ModuleName, 1117, "no permission to withdraw") - ErrNoWithdrawalAmountToWithdraw = errorsmod.Register(ModuleName, 1118, "no registration fee to withdraw") - ErrInvalidDenom = errorsmod.Register(ModuleName, 1119, "invalid denom") + ErrInvalidTopLevelDomainName = errorsmod.Register(ModuleName, 1000, "invalid top-level-domain name") + ErrTopLevelDomainNotFound = errorsmod.Register(ModuleName, 1001, "top-level-domain not found") + ErrTopLevelDomainExpired = errorsmod.Register(ModuleName, 1002, "top-level-domain expired") + ErrTopLevelDomainAlreadyTaken = errorsmod.Register(ModuleName, 1003, "top-level-domain already taken") + ErrTopLevelDomainNotRegistrable = errorsmod.Register(ModuleName, 1004, "top-level-domain not registrable") + ErrTopLevelDomainMaxSubdomainCountReached = errorsmod.Register(ModuleName, 1005, "top-level-domain max subdomain count reached") + ErrTopLevelDomainInvalidRegistrationPeriod = errorsmod.Register(ModuleName, 1006, "top-level-domain invalid registration period") + ErrTopLevelDomainNotEditable = errorsmod.Register(ModuleName, 1007, "top-level-domain not editable") +) + +// second-level-domain sentinel errors +var ( + ErrInvalidSecondLevelDomainName = errorsmod.Register(ModuleName, 1100, "invalid second-level-domain name") + ErrInvalidSecondLevelDomainParent = errorsmod.Register(ModuleName, 1101, "invalid second-level-domain parent") + ErrSecondLevelDomainNotFound = errorsmod.Register(ModuleName, 1102, "second-level-domain not found") + ErrSecondLevelDomainExpired = errorsmod.Register(ModuleName, 1103, "second-level-domain expired") + ErrSecondLevelDomainAlreadyTaken = errorsmod.Register(ModuleName, 1104, "second-level-domain already taken") + ErrSecondLevelDomainParentDoesNotExist = errorsmod.Register(ModuleName, 1105, "second-level-domain parent does not exist") + ErrSecondLevelDomainInvalidRegistrationPeriod = errorsmod.Register(ModuleName, 1106, "second-level-domain invalid registration period") + ErrSecondLevelDomainNotEditable = errorsmod.Register(ModuleName, 1107, "second-level-domain not editable") + ErrSecondLevelDomainNotRegistrable = errorsmod.Register(ModuleName, 1108, "second-level-domain not registrable") +) + +// record sentinel errors +var ( + ErrInvalidWalletAddress = errorsmod.Register(ModuleName, 1200, "invalid wallet address") + ErrInvalidWalletRecordType = errorsmod.Register(ModuleName, 1201, "invalid wallet record type") + ErrInvalidDnsRecordValue = errorsmod.Register(ModuleName, 1202, "invalid dns record value") + ErrInvalidDnsRecordType = errorsmod.Register(ModuleName, 1203, "invalid dns record type") +) + +// withdraw sentinel errors +var ( + ErrNoEnoughBalance = errorsmod.Register(ModuleName, 1300, "no enough balance") + ErrNoPermissionToWithdraw = errorsmod.Register(ModuleName, 1301, "no permission to withdraw") + ErrNoWithdrawalAmountToWithdraw = errorsmod.Register(ModuleName, 1302, "no registration fee to withdraw") + ErrInvalidDenom = errorsmod.Register(ModuleName, 1303, "invalid denom") ) diff --git a/x/registry/types/events.go b/x/registry/types/events.go index 77fc384e..edd5e367 100644 --- a/x/registry/types/events.go +++ b/x/registry/types/events.go @@ -50,3 +50,15 @@ const ( AttributeWithdrawRegistrationFeeEventDomainName = "name" AttributeWithdrawRegistrationFeeEventDomainFee = "fee" ) + +// Extend top-level-domain expiration date event +const ( + EventTypeExtendTopLevelDomainExpirationDate = "extend-top-level-domain-expiration-date" + + AttributeExtendTopLevelDomainExpirationDateEventDomainName = "name" + AttributeExtendTopLevelDomainExpirationDateEventExpirationDate = "expiration-date" + AttributeExtendTopLevelDomainExpirationDateEventTotalRegistrationFee = "total-registration-fee" + AttributeExtendTopLevelDomainExpirationDateEventBurnWeight = "burn-weight" + AttributeExtendTopLevelDomainExpirationDateEventRegistrationFeeToBurn = "registration-fee-to-burn" + AttributeExtendTopLevelDomainExpirationDateEventRegistrationFeeToTreasury = "registration-fee-to-treasury" +) diff --git a/x/registry/types/expected_keepers.go b/x/registry/types/expected_keepers.go index c6d5a468..85a8b12d 100644 --- a/x/registry/types/expected_keepers.go +++ b/x/registry/types/expected_keepers.go @@ -5,6 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + furnacetypes "github.com/mycel-domain/mycel/x/furnace/types" ) diff --git a/x/registry/types/genesis_test.go b/x/registry/types/genesis_test.go index 232f0d17..4c597359 100644 --- a/x/registry/types/genesis_test.go +++ b/x/registry/types/genesis_test.go @@ -3,8 +3,9 @@ package types_test import ( "testing" - "github.com/mycel-domain/mycel/x/registry/types" "github.com/stretchr/testify/require" + + "github.com/mycel-domain/mycel/x/registry/types" ) func TestGenesisState_Validate(t *testing.T) { diff --git a/x/registry/types/message_extend_top_level_domain_expiration_date.go b/x/registry/types/message_extend_top_level_domain_expiration_date.go new file mode 100644 index 00000000..309ae658 --- /dev/null +++ b/x/registry/types/message_extend_top_level_domain_expiration_date.go @@ -0,0 +1,47 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const TypeMsgExtendTopLevelDomainExpirationDate = "extend_top_level_domain_expiration" + +var _ sdk.Msg = &MsgExtendTopLevelDomainExpirationDate{} + +func NewMsgExtendTopLevelDomainExpirationDate(creator string, name string, extentsionPeriodInYear uint64) *MsgExtendTopLevelDomainExpirationDate { + return &MsgExtendTopLevelDomainExpirationDate{ + Creator: creator, + Name: name, + ExtensionPeriodInYear: extentsionPeriodInYear, + } +} + +func (msg *MsgExtendTopLevelDomainExpirationDate) Route() string { + return RouterKey +} + +func (msg *MsgExtendTopLevelDomainExpirationDate) Type() string { + return TypeMsgExtendTopLevelDomainExpirationDate +} + +func (msg *MsgExtendTopLevelDomainExpirationDate) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgExtendTopLevelDomainExpirationDate) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgExtendTopLevelDomainExpirationDate) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + return nil +} diff --git a/x/registry/types/message_extend_top_level_domain_expiration_date_test.go b/x/registry/types/message_extend_top_level_domain_expiration_date_test.go new file mode 100644 index 00000000..94505c5f --- /dev/null +++ b/x/registry/types/message_extend_top_level_domain_expiration_date_test.go @@ -0,0 +1,41 @@ +package types + +import ( + "testing" + + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/stretchr/testify/require" + + "github.com/mycel-domain/mycel/testutil/sample" +) + +func TestMsgExtendTopLevelDomainExpirationDate_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgExtendTopLevelDomainExpirationDate + err error + }{ + { + name: "invalid address", + msg: MsgExtendTopLevelDomainExpirationDate{ + Creator: "invalid_address", + }, + err: sdkerrors.ErrInvalidAddress, + }, { + name: "valid address", + msg: MsgExtendTopLevelDomainExpirationDate{ + Creator: sample.AccAddress(), + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} diff --git a/x/registry/types/message_register_second_level_domain_test.go b/x/registry/types/message_register_second_level_domain_test.go index 173c4bc7..ea6b41c4 100644 --- a/x/registry/types/message_register_second_level_domain_test.go +++ b/x/registry/types/message_register_second_level_domain_test.go @@ -4,8 +4,9 @@ import ( "testing" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/mycel-domain/mycel/testutil/sample" "github.com/stretchr/testify/require" + + "github.com/mycel-domain/mycel/testutil/sample" ) func TestMsgRegisterSecondLevelDomain_ValidateBasic(t *testing.T) { diff --git a/x/registry/types/message_register_top_level_domain_test.go b/x/registry/types/message_register_top_level_domain_test.go index 934f7884..ac9d3df8 100644 --- a/x/registry/types/message_register_top_level_domain_test.go +++ b/x/registry/types/message_register_top_level_domain_test.go @@ -4,8 +4,9 @@ import ( "testing" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/mycel-domain/mycel/testutil/sample" "github.com/stretchr/testify/require" + + "github.com/mycel-domain/mycel/testutil/sample" ) func TestMsgRegisterTopLevelDomain_ValidateBasic(t *testing.T) { diff --git a/x/registry/types/message_update_dns_record_test.go b/x/registry/types/message_update_dns_record_test.go index 71959276..48d297f7 100644 --- a/x/registry/types/message_update_dns_record_test.go +++ b/x/registry/types/message_update_dns_record_test.go @@ -3,10 +3,10 @@ package types import ( "testing" - "github.com/mycel-domain/mycel/testutil/sample" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/stretchr/testify/require" + + "github.com/mycel-domain/mycel/testutil/sample" ) func TestMsgUpdateDnsRecord_ValidateBasic(t *testing.T) { diff --git a/x/registry/types/message_update_wallet_record_test.go b/x/registry/types/message_update_wallet_record_test.go index 80b88974..bc6a7fe9 100644 --- a/x/registry/types/message_update_wallet_record_test.go +++ b/x/registry/types/message_update_wallet_record_test.go @@ -4,8 +4,9 @@ import ( "testing" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/mycel-domain/mycel/testutil/sample" "github.com/stretchr/testify/require" + + "github.com/mycel-domain/mycel/testutil/sample" ) func TestMsgUpdateWalletRecord_ValidateBasic(t *testing.T) { diff --git a/x/registry/types/message_withdraw_registration_fee.go b/x/registry/types/message_withdraw_registration_fee.go index ce631723..3d632ef7 100644 --- a/x/registry/types/message_withdraw_registration_fee.go +++ b/x/registry/types/message_withdraw_registration_fee.go @@ -1,9 +1,9 @@ package types import ( + errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - errorsmod "cosmossdk.io/errors" ) const TypeMsgWithdrawRegistrationFee = "withdraw_registration_fee" diff --git a/x/registry/types/message_withdraw_registration_fee_test.go b/x/registry/types/message_withdraw_registration_fee_test.go index 67b8bf1a..802f9481 100644 --- a/x/registry/types/message_withdraw_registration_fee_test.go +++ b/x/registry/types/message_withdraw_registration_fee_test.go @@ -4,8 +4,9 @@ import ( "testing" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/mycel-domain/mycel/testutil/sample" "github.com/stretchr/testify/require" + + "github.com/mycel-domain/mycel/testutil/sample" ) func TestMsgWithdrawRegistrationFee_ValidateBasic(t *testing.T) { diff --git a/x/registry/types/query.pb.go b/x/registry/types/query.pb.go index c5d88b1a..731168ba 100644 --- a/x/registry/types/query.pb.go +++ b/x/registry/types/query.pb.go @@ -6,24 +6,29 @@ package types import ( context "context" fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" query "github.com/cosmos/cosmos-sdk/types/query" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" + github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" + _ "google.golang.org/protobuf/types/known/timestamppb" io "io" math "math" math_bits "math/bits" + time "time" ) // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal var _ = fmt.Errorf var _ = math.Inf +var _ = time.Kitchen // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -351,9 +356,9 @@ func (m *QueryGetSecondLevelDomainRequest) GetParent() string { } type SecondLevelDomainResponse struct { - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Parent string `protobuf:"bytes,2,opt,name=parent,proto3" json:"parent,omitempty"` - ExpirationDate int64 `protobuf:"varint,3,opt,name=expirationDate,proto3" json:"expirationDate,omitempty"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Parent string `protobuf:"bytes,2,opt,name=parent,proto3" json:"parent,omitempty"` + ExpirationDate time.Time `protobuf:"bytes,3,opt,name=expirationDate,proto3,stdtime" json:"expirationDate"` } func (m *SecondLevelDomainResponse) Reset() { *m = SecondLevelDomainResponse{} } @@ -403,11 +408,11 @@ func (m *SecondLevelDomainResponse) GetParent() string { return "" } -func (m *SecondLevelDomainResponse) GetExpirationDate() int64 { +func (m *SecondLevelDomainResponse) GetExpirationDate() time.Time { if m != nil { return m.ExpirationDate } - return 0 + return time.Time{} } type QueryGetSecondLevelDomainResponse struct { @@ -735,8 +740,9 @@ func (m *QueryAllDomainOwnershipResponse) GetPagination() *query.PageResponse { } type QueryDomainRegistrationFeeRequest struct { - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Parent string `protobuf:"bytes,2,opt,name=parent,proto3" json:"parent,omitempty"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Parent string `protobuf:"bytes,2,opt,name=parent,proto3" json:"parent,omitempty"` + RegistrationPeriodInYear uint64 `protobuf:"varint,3,opt,name=registrationPeriodInYear,proto3" json:"registrationPeriodInYear,omitempty"` } func (m *QueryDomainRegistrationFeeRequest) Reset() { *m = QueryDomainRegistrationFeeRequest{} } @@ -786,8 +792,19 @@ func (m *QueryDomainRegistrationFeeRequest) GetParent() string { return "" } +func (m *QueryDomainRegistrationFeeRequest) GetRegistrationPeriodInYear() uint64 { + if m != nil { + return m.RegistrationPeriodInYear + } + return 0 +} + type QueryDomainRegistrationFeeResponse struct { - Fee types.Coin `protobuf:"bytes,1,opt,name=fee,proto3" json:"fee"` + IsRegistrable bool `protobuf:"varint,1,opt,name=isRegistrable,proto3" json:"isRegistrable,omitempty"` + Fee github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=fee,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"fee"` + RegistrationPeriodInYear uint64 `protobuf:"varint,3,opt,name=registrationPeriodInYear,proto3" json:"registrationPeriodInYear,omitempty"` + MaxSubDomainRegistrations uint64 `protobuf:"varint,4,opt,name=maxSubDomainRegistrations,proto3" json:"maxSubDomainRegistrations,omitempty"` + ErrorMessage string `protobuf:"bytes,5,opt,name=errorMessage,proto3" json:"errorMessage,omitempty"` } func (m *QueryDomainRegistrationFeeResponse) Reset() { *m = QueryDomainRegistrationFeeResponse{} } @@ -823,111 +840,35 @@ func (m *QueryDomainRegistrationFeeResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryDomainRegistrationFeeResponse proto.InternalMessageInfo -func (m *QueryDomainRegistrationFeeResponse) GetFee() types.Coin { +func (m *QueryDomainRegistrationFeeResponse) GetIsRegistrable() bool { if m != nil { - return m.Fee + return m.IsRegistrable } - return types.Coin{} -} - -type QueryIsRegistrableDomainRequest struct { - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Parent string `protobuf:"bytes,2,opt,name=parent,proto3" json:"parent,omitempty"` -} - -func (m *QueryIsRegistrableDomainRequest) Reset() { *m = QueryIsRegistrableDomainRequest{} } -func (m *QueryIsRegistrableDomainRequest) String() string { return proto.CompactTextString(m) } -func (*QueryIsRegistrableDomainRequest) ProtoMessage() {} -func (*QueryIsRegistrableDomainRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_0f2c8f2d33ba1956, []int{17} -} -func (m *QueryIsRegistrableDomainRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryIsRegistrableDomainRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryIsRegistrableDomainRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryIsRegistrableDomainRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryIsRegistrableDomainRequest.Merge(m, src) -} -func (m *QueryIsRegistrableDomainRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryIsRegistrableDomainRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryIsRegistrableDomainRequest.DiscardUnknown(m) + return false } -var xxx_messageInfo_QueryIsRegistrableDomainRequest proto.InternalMessageInfo - -func (m *QueryIsRegistrableDomainRequest) GetName() string { +func (m *QueryDomainRegistrationFeeResponse) GetFee() github_com_cosmos_cosmos_sdk_types.Coins { if m != nil { - return m.Name + return m.Fee } - return "" + return nil } -func (m *QueryIsRegistrableDomainRequest) GetParent() string { +func (m *QueryDomainRegistrationFeeResponse) GetRegistrationPeriodInYear() uint64 { if m != nil { - return m.Parent + return m.RegistrationPeriodInYear } - return "" -} - -type QueryIsRegistrableDomainResponse struct { - IsRegstrable bool `protobuf:"varint,1,opt,name=isRegstrable,proto3" json:"isRegstrable,omitempty"` - ErrorMessage string `protobuf:"bytes,2,opt,name=errorMessage,proto3" json:"errorMessage,omitempty"` -} - -func (m *QueryIsRegistrableDomainResponse) Reset() { *m = QueryIsRegistrableDomainResponse{} } -func (m *QueryIsRegistrableDomainResponse) String() string { return proto.CompactTextString(m) } -func (*QueryIsRegistrableDomainResponse) ProtoMessage() {} -func (*QueryIsRegistrableDomainResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_0f2c8f2d33ba1956, []int{18} -} -func (m *QueryIsRegistrableDomainResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryIsRegistrableDomainResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryIsRegistrableDomainResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryIsRegistrableDomainResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryIsRegistrableDomainResponse.Merge(m, src) -} -func (m *QueryIsRegistrableDomainResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryIsRegistrableDomainResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryIsRegistrableDomainResponse.DiscardUnknown(m) + return 0 } -var xxx_messageInfo_QueryIsRegistrableDomainResponse proto.InternalMessageInfo - -func (m *QueryIsRegistrableDomainResponse) GetIsRegstrable() bool { +func (m *QueryDomainRegistrationFeeResponse) GetMaxSubDomainRegistrations() uint64 { if m != nil { - return m.IsRegstrable + return m.MaxSubDomainRegistrations } - return false + return 0 } -func (m *QueryIsRegistrableDomainResponse) GetErrorMessage() string { +func (m *QueryDomainRegistrationFeeResponse) GetErrorMessage() string { if m != nil { return m.ErrorMessage } @@ -952,77 +893,79 @@ func init() { proto.RegisterType((*QueryAllDomainOwnershipResponse)(nil), "mycel.registry.QueryAllDomainOwnershipResponse") proto.RegisterType((*QueryDomainRegistrationFeeRequest)(nil), "mycel.registry.QueryDomainRegistrationFeeRequest") proto.RegisterType((*QueryDomainRegistrationFeeResponse)(nil), "mycel.registry.QueryDomainRegistrationFeeResponse") - proto.RegisterType((*QueryIsRegistrableDomainRequest)(nil), "mycel.registry.QueryIsRegistrableDomainRequest") - proto.RegisterType((*QueryIsRegistrableDomainResponse)(nil), "mycel.registry.QueryIsRegistrableDomainResponse") } func init() { proto.RegisterFile("mycel/registry/query.proto", fileDescriptor_0f2c8f2d33ba1956) } var fileDescriptor_0f2c8f2d33ba1956 = []byte{ - // 997 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x97, 0xcf, 0x6f, 0xdc, 0x44, - 0x14, 0xc7, 0x33, 0xdd, 0x36, 0xa2, 0x43, 0x95, 0x2a, 0xd3, 0x10, 0xa5, 0x06, 0x9c, 0x30, 0x55, - 0x4b, 0x00, 0xc5, 0x93, 0x4d, 0x9a, 0x72, 0x00, 0x0e, 0x09, 0xab, 0x94, 0x1f, 0x29, 0x29, 0x0b, - 0x12, 0x12, 0x12, 0x5a, 0x79, 0x37, 0x53, 0xc7, 0xc8, 0xeb, 0x71, 0x3c, 0x4e, 0xe9, 0x2a, 0xca, - 0xa5, 0x7f, 0x01, 0x12, 0xff, 0x04, 0x48, 0x70, 0x00, 0x09, 0x71, 0xe0, 0xca, 0xa1, 0x12, 0x1c, - 0x2a, 0x71, 0xe1, 0x84, 0x50, 0xc2, 0x1f, 0x52, 0x79, 0xfc, 0xdc, 0xac, 0x67, 0x3d, 0xce, 0xee, - 0x6a, 0x6f, 0x5e, 0xbf, 0x37, 0xdf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f6, 0x07, 0xc2, 0xf7, - 0x14, 0xe1, 0xdb, 0x64, 0xa3, 0xb2, 0x1d, 0xf4, 0x1b, 0x3f, 0x3b, 0x52, 0x8f, 0xc7, 0xe4, 0x47, - 0x84, 0x89, 0x26, 0x9d, 0x26, 0xd7, 0xd8, 0x94, 0x23, 0x61, 0x9b, 0x8f, 0x99, 0x21, 0xbb, 0x58, - 0xc7, 0x26, 0x7f, 0x21, 0xfc, 0x52, 0xe9, 0xb8, 0x26, 0xe5, 0xc5, 0xad, 0x3a, 0x2b, 0xac, 0xb5, - 0x51, 0x96, 0x00, 0xf7, 0x8e, 0xe2, 0xde, 0x26, 0x8d, 0x61, 0xb8, 0xe3, 0x3e, 0x91, 0xd6, 0x03, - 0xce, 0x07, 0x9a, 0xfb, 0x0f, 0x84, 0xaf, 0x95, 0x4c, 0x75, 0x52, 0x9e, 0x4e, 0xf3, 0x71, 0x62, - 0xad, 0x0e, 0xbf, 0x00, 0x02, 0xf9, 0x48, 0x05, 0xd2, 0x20, 0x5b, 0x95, 0x81, 0xf8, 0xf2, 0x79, - 0x10, 0xed, 0x80, 0x1b, 0xbe, 0xd1, 0xad, 0x0f, 0x9e, 0x9c, 0xd8, 0xe8, 0xe9, 0x89, 0x8d, 0xfe, - 0x3b, 0xb1, 0xd1, 0xb7, 0xa7, 0xf6, 0xd4, 0xd3, 0x53, 0x7b, 0xea, 0x9f, 0x53, 0x7b, 0xea, 0x4b, - 0xc7, 0xf3, 0x93, 0xfd, 0xc3, 0xb6, 0xd3, 0x11, 0xdd, 0xb2, 0x7d, 0x1e, 0xf5, 0x0d, 0xac, 0x5e, - 0xc4, 0x65, 0x7b, 0x5a, 0xfd, 0xd3, 0x5c, 0x7f, 0x16, 0x00, 0x00, 0xff, 0xff, 0x78, 0xd0, 0xb6, - 0x51, 0xac, 0x0f, 0x00, 0x00, + // 1057 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02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d4, 0x36, 0x64, 0xf9, 0x74, 0x31, 0x71, 0xdf, + 0xfe, 0x92, 0xf0, 0x1d, 0x4e, 0xf8, 0x26, 0x5c, 0xa9, 0x6c, 0x07, 0xf5, 0x7f, 0x11, 0x7c, 0xc8, + 0x7f, 0x1e, 0xc1, 0xef, 0x0d, 0x00, 0x95, 0xd4, 0x99, 0xb8, 0xda, 0xa6, 0x1c, 0x08, 0x5b, 0x3f, + 0xd9, 0xfa, 0xec, 0x62, 0x15, 0x1b, 0xfe, 0x6e, 0x80, 0xe7, 0x4a, 0xcf, 0x78, 0x58, 0xbe, 0xb9, + 0x55, 0xd3, 0xc9, 0x5c, 0x1a, 0x24, 0x44, 0x72, 0x6f, 0x72, 0xee, 0x0d, 0xb8, 0xde, 0x0f, 0x77, + 0xf7, 0x39, 0xbe, 0xbd, 0x43, 0x88, 0xda, 0xdc, 0x6b, 0xef, 0x3d, 0x3e, 0xb1, 0x8c, 0x27, 0x27, + 0x96, 0xf1, 0xf7, 0x89, 0x65, 0x3c, 0x3a, 0xb5, 0x46, 0x9e, 0x9c, 0x5a, 0x23, 0x7f, 0x9e, 0x5a, + 0x23, 0x9f, 0xda, 0x5d, 0x43, 0xa5, 0x64, 0xa5, 0xfd, 0xae, 0x2f, 0x3d, 0x1b, 0x30, 0xcd, 0x09, + 0x7e, 0xa1, 0x5e, 0xfe, 0x2f, 0x00, 0x00, 0xff, 0xff, 0xfa, 0x0d, 0x25, 0xca, 0xa0, 0x0f, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1050,8 +993,6 @@ type QueryClient interface { DomainOwnershipAll(ctx context.Context, in *QueryAllDomainOwnershipRequest, opts ...grpc.CallOption) (*QueryAllDomainOwnershipResponse, error) // Queries a list of DomainRegistrationFee items. DomainRegistrationFee(ctx context.Context, in *QueryDomainRegistrationFeeRequest, opts ...grpc.CallOption) (*QueryDomainRegistrationFeeResponse, error) - // Queries a list of IsRegistrableDomain items. - IsRegistrableDomain(ctx context.Context, in *QueryIsRegistrableDomainRequest, opts ...grpc.CallOption) (*QueryIsRegistrableDomainResponse, error) } type queryClient struct { @@ -1134,15 +1075,6 @@ func (c *queryClient) DomainRegistrationFee(ctx context.Context, in *QueryDomain return out, nil } -func (c *queryClient) IsRegistrableDomain(ctx context.Context, in *QueryIsRegistrableDomainRequest, opts ...grpc.CallOption) (*QueryIsRegistrableDomainResponse, error) { - out := new(QueryIsRegistrableDomainResponse) - err := c.cc.Invoke(ctx, "/mycel.registry.Query/IsRegistrableDomain", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - // QueryServer is the server API for Query service. type QueryServer interface { // Parameters queries the parameters of the module. @@ -1158,8 +1090,6 @@ type QueryServer interface { DomainOwnershipAll(context.Context, *QueryAllDomainOwnershipRequest) (*QueryAllDomainOwnershipResponse, error) // Queries a list of DomainRegistrationFee items. DomainRegistrationFee(context.Context, *QueryDomainRegistrationFeeRequest) (*QueryDomainRegistrationFeeResponse, error) - // Queries a list of IsRegistrableDomain items. - IsRegistrableDomain(context.Context, *QueryIsRegistrableDomainRequest) (*QueryIsRegistrableDomainResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -1190,9 +1120,6 @@ func (*UnimplementedQueryServer) DomainOwnershipAll(ctx context.Context, req *Qu func (*UnimplementedQueryServer) DomainRegistrationFee(ctx context.Context, req *QueryDomainRegistrationFeeRequest) (*QueryDomainRegistrationFeeResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method DomainRegistrationFee not implemented") } -func (*UnimplementedQueryServer) IsRegistrableDomain(ctx context.Context, req *QueryIsRegistrableDomainRequest) (*QueryIsRegistrableDomainResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method IsRegistrableDomain not implemented") -} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -1342,24 +1269,6 @@ func _Query_DomainRegistrationFee_Handler(srv interface{}, ctx context.Context, return interceptor(ctx, in, info, handler) } -func _Query_IsRegistrableDomain_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryIsRegistrableDomainRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).IsRegistrableDomain(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/mycel.registry.Query/IsRegistrableDomain", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).IsRegistrableDomain(ctx, req.(*QueryIsRegistrableDomainRequest)) - } - return interceptor(ctx, in, info, handler) -} - var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "mycel.registry.Query", HandlerType: (*QueryServer)(nil), @@ -1396,10 +1305,6 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "DomainRegistrationFee", Handler: _Query_DomainRegistrationFee_Handler, }, - { - MethodName: "IsRegistrableDomain", - Handler: _Query_IsRegistrableDomain_Handler, - }, }, Streams: []grpc.StreamDesc{}, Metadata: "mycel/registry/query.proto", @@ -1665,11 +1570,14 @@ func (m *SecondLevelDomainResponse) MarshalToSizedBuffer(dAtA []byte) (int, erro _ = i var l int _ = l - if m.ExpirationDate != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.ExpirationDate)) - i-- - dAtA[i] = 0x18 + n5, err5 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.ExpirationDate, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.ExpirationDate):]) + if err5 != nil { + return 0, err5 } + i -= n5 + i = encodeVarintQuery(dAtA, i, uint64(n5)) + i-- + dAtA[i] = 0x1a if len(m.Parent) > 0 { i -= len(m.Parent) copy(dAtA[i:], m.Parent) @@ -1971,6 +1879,11 @@ func (m *QueryDomainRegistrationFeeRequest) MarshalToSizedBuffer(dAtA []byte) (i _ = i var l int _ = l + if m.RegistrationPeriodInYear != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.RegistrationPeriodInYear)) + i-- + dAtA[i] = 0x18 + } if len(m.Parent) > 0 { i -= len(m.Parent) copy(dAtA[i:], m.Parent) @@ -2004,76 +1917,6 @@ func (m *QueryDomainRegistrationFeeResponse) MarshalTo(dAtA []byte) (int, error) } func (m *QueryDomainRegistrationFeeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Fee.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *QueryIsRegistrableDomainRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryIsRegistrableDomainRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryIsRegistrableDomainRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Parent) > 0 { - i -= len(m.Parent) - copy(dAtA[i:], m.Parent) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Parent))) - i-- - dAtA[i] = 0x12 - } - if len(m.Name) > 0 { - i -= len(m.Name) - copy(dAtA[i:], m.Name) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Name))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *QueryIsRegistrableDomainResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryIsRegistrableDomainResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryIsRegistrableDomainResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2083,11 +1926,35 @@ func (m *QueryIsRegistrableDomainResponse) MarshalToSizedBuffer(dAtA []byte) (in copy(dAtA[i:], m.ErrorMessage) i = encodeVarintQuery(dAtA, i, uint64(len(m.ErrorMessage))) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x2a + } + if m.MaxSubDomainRegistrations != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.MaxSubDomainRegistrations)) + i-- + dAtA[i] = 0x20 + } + if m.RegistrationPeriodInYear != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.RegistrationPeriodInYear)) + i-- + dAtA[i] = 0x18 + } + if len(m.Fee) > 0 { + for iNdEx := len(m.Fee) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Fee[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } } - if m.IsRegstrable { + if m.IsRegistrable { i-- - if m.IsRegstrable { + if m.IsRegistrable { dAtA[i] = 1 } else { dAtA[i] = 0 @@ -2216,9 +2083,8 @@ func (m *SecondLevelDomainResponse) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - if m.ExpirationDate != 0 { - n += 1 + sovQuery(uint64(m.ExpirationDate)) - } + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.ExpirationDate) + n += 1 + l + sovQuery(uint64(l)) return n } @@ -2335,6 +2201,9 @@ func (m *QueryDomainRegistrationFeeRequest) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } + if m.RegistrationPeriodInYear != 0 { + n += 1 + sovQuery(uint64(m.RegistrationPeriodInYear)) + } return n } @@ -2344,36 +2213,20 @@ func (m *QueryDomainRegistrationFeeResponse) Size() (n int) { } var l int _ = l - l = m.Fee.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func (m *QueryIsRegistrableDomainRequest) Size() (n int) { - if m == nil { - return 0 + if m.IsRegistrable { + n += 2 } - var l int - _ = l - l = len(m.Name) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) + if len(m.Fee) > 0 { + for _, e := range m.Fee { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } } - l = len(m.Parent) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) + if m.RegistrationPeriodInYear != 0 { + n += 1 + sovQuery(uint64(m.RegistrationPeriodInYear)) } - return n -} - -func (m *QueryIsRegistrableDomainResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.IsRegstrable { - n += 2 + if m.MaxSubDomainRegistrations != 0 { + n += 1 + sovQuery(uint64(m.MaxSubDomainRegistrations)) } l = len(m.ErrorMessage) if l > 0 { @@ -3100,10 +2953,10 @@ func (m *SecondLevelDomainResponse) Unmarshal(dAtA []byte) error { m.Parent = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: - if wireType != 0 { + if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ExpirationDate", wireType) } - m.ExpirationDate = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -3113,11 +2966,25 @@ func (m *SecondLevelDomainResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ExpirationDate |= int64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.ExpirationDate, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -3892,61 +3759,11 @@ func (m *QueryDomainRegistrationFeeRequest) Unmarshal(dAtA []byte) error { } m.Parent = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryDomainRegistrationFeeResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryDomainRegistrationFeeResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryDomainRegistrationFeeResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Fee", wireType) + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RegistrationPeriodInYear", wireType) } - var msglen int + m.RegistrationPeriodInYear = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -3956,25 +3773,11 @@ func (m *QueryDomainRegistrationFeeResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + m.RegistrationPeriodInYear |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Fee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -3996,7 +3799,7 @@ func (m *QueryDomainRegistrationFeeResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryIsRegistrableDomainRequest) Unmarshal(dAtA []byte) error { +func (m *QueryDomainRegistrationFeeResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4019,17 +3822,17 @@ func (m *QueryIsRegistrableDomainRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryIsRegistrableDomainRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryDomainRegistrationFeeResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryIsRegistrableDomainRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryDomainRegistrationFeeResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsRegistrable", wireType) } - var stringLen uint64 + var v int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -4039,29 +3842,17 @@ func (m *QueryIsRegistrableDomainRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + v |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Name = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex + m.IsRegistrable = bool(v != 0) case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Parent", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Fee", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -4071,79 +3862,50 @@ func (m *QueryIsRegistrableDomainRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - m.Parent = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { + m.Fee = append(m.Fee, types.Coin{}) + if err := m.Fee[len(m.Fee)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryIsRegistrableDomainResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RegistrationPeriodInYear", wireType) } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + m.RegistrationPeriodInYear = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RegistrationPeriodInYear |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryIsRegistrableDomainResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryIsRegistrableDomainResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + case 4: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field IsRegstrable", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field MaxSubDomainRegistrations", wireType) } - var v int + m.MaxSubDomainRegistrations = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -4153,13 +3915,12 @@ func (m *QueryIsRegistrableDomainResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - v |= int(b&0x7F) << shift + m.MaxSubDomainRegistrations |= uint64(b&0x7F) << shift if b < 0x80 { break } } - m.IsRegstrable = bool(v != 0) - case 2: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ErrorMessage", wireType) } diff --git a/x/registry/types/query.pb.gw.go b/x/registry/types/query.pb.gw.go index e393e20b..5419ce78 100644 --- a/x/registry/types/query.pb.gw.go +++ b/x/registry/types/query.pb.gw.go @@ -343,6 +343,10 @@ func local_request_Query_DomainOwnershipAll_0(ctx context.Context, marshaler run } +var ( + filter_Query_DomainRegistrationFee_0 = &utilities.DoubleArray{Encoding: map[string]int{"name": 0, "parent": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}} +) + func request_Query_DomainRegistrationFee_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryDomainRegistrationFeeRequest var metadata runtime.ServerMetadata @@ -376,51 +380,20 @@ func request_Query_DomainRegistrationFee_0(ctx context.Context, marshaler runtim return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "parent", err) } - msg, err := client.DomainRegistrationFee(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_DomainRegistrationFee_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryDomainRegistrationFeeRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["name"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") - } - - protoReq.Name, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) - } - - val, ok = pathParams["parent"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent") + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - - protoReq.Parent, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "parent", err) + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_DomainRegistrationFee_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := server.DomainRegistrationFee(ctx, &protoReq) + msg, err := client.DomainRegistrationFee(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func request_Query_IsRegistrableDomain_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryIsRegistrableDomainRequest +func local_request_Query_DomainRegistrationFee_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryDomainRegistrationFeeRequest var metadata runtime.ServerMetadata var ( @@ -452,45 +425,14 @@ func request_Query_IsRegistrableDomain_0(ctx context.Context, marshaler runtime. return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "parent", err) } - msg, err := client.IsRegistrableDomain(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_IsRegistrableDomain_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryIsRegistrableDomainRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["name"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") - } - - protoReq.Name, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) - } - - val, ok = pathParams["parent"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent") + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - - protoReq.Parent, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "parent", err) + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_DomainRegistrationFee_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := server.IsRegistrableDomain(ctx, &protoReq) + msg, err := server.DomainRegistrationFee(ctx, &protoReq) return msg, metadata, err } @@ -685,29 +627,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_IsRegistrableDomain_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_IsRegistrableDomain_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_IsRegistrableDomain_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - return nil } @@ -909,26 +828,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_IsRegistrableDomain_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_IsRegistrableDomain_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_IsRegistrableDomain_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - return nil } @@ -948,8 +847,6 @@ var ( pattern_Query_DomainOwnershipAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"mycel-domain", "mycel", "registry", "domain_ownership"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Query_DomainRegistrationFee_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"mycel-domain", "mycel", "registry", "domain_registration_fee", "name", "parent"}, "", runtime.AssumeColonVerbOpt(true))) - - pattern_Query_IsRegistrableDomain_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"mycel-domain", "mycel", "registry", "is_registrable_domain", "name", "parent"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( @@ -968,6 +865,4 @@ var ( forward_Query_DomainOwnershipAll_0 = runtime.ForwardResponseMessage forward_Query_DomainRegistrationFee_0 = runtime.ForwardResponseMessage - - forward_Query_IsRegistrableDomain_0 = runtime.ForwardResponseMessage ) diff --git a/x/registry/types/secend_level_domain.go b/x/registry/types/secend_level_domain.go index f76ab24f..17e7f965 100644 --- a/x/registry/types/secend_level_domain.go +++ b/x/registry/types/secend_level_domain.go @@ -3,6 +3,8 @@ package types import ( fmt "fmt" "strings" + + errorsmod "cosmossdk.io/errors" ) const ( @@ -106,3 +108,11 @@ func (secondLevelDomain *SecondLevelDomain) UpdateDnsRecord(dnsRecordType string return err } + +func (secondLevelDomain SecondLevelDomain) IsRecordEditable(sender string) (isEditable bool, err error) { + if secondLevelDomain.AccessControl[sender] == DomainRole_NO_ROLE { + err = errorsmod.Wrapf(ErrSecondLevelDomainNotEditable, "%s", sender) + } + isEditable = secondLevelDomain.AccessControl[sender] == DomainRole_EDITOR || secondLevelDomain.AccessControl[sender] == DomainRole_OWNER + return isEditable, err +} diff --git a/x/registry/types/second_level_domain.pb.go b/x/registry/types/second_level_domain.pb.go index a9516deb..9a9f5d77 100644 --- a/x/registry/types/second_level_domain.pb.go +++ b/x/registry/types/second_level_domain.pb.go @@ -5,16 +5,21 @@ package types import ( fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" + github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" + _ "google.golang.org/protobuf/types/known/timestamppb" io "io" math "math" math_bits "math/bits" + time "time" ) // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal var _ = fmt.Errorf var _ = math.Inf +var _ = time.Kitchen // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -180,7 +185,6 @@ func (m *Metadata) GetValue() string { type Record struct { // Types that are valid to be assigned to Record: - // // *Record_DnsRecord // *Record_WalletRecord // *Record_Metadata @@ -281,7 +285,7 @@ type SecondLevelDomain struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Parent string `protobuf:"bytes,2,opt,name=parent,proto3" json:"parent,omitempty"` Owner string `protobuf:"bytes,3,opt,name=owner,proto3" json:"owner,omitempty"` - ExpirationDate int64 `protobuf:"varint,4,opt,name=expirationDate,proto3" json:"expirationDate,omitempty"` + ExpirationDate time.Time `protobuf:"bytes,4,opt,name=expirationDate,proto3,stdtime" json:"expirationDate"` Records map[string]*Record `protobuf:"bytes,5,rep,name=records,proto3" json:"records,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` AccessControl map[string]DomainRole `protobuf:"bytes,6,rep,name=accessControl,proto3" json:"accessControl,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3,enum=mycel.registry.DomainRole"` } @@ -340,11 +344,11 @@ func (m *SecondLevelDomain) GetOwner() string { return "" } -func (m *SecondLevelDomain) GetExpirationDate() int64 { +func (m *SecondLevelDomain) GetExpirationDate() time.Time { if m != nil { return m.ExpirationDate } - return 0 + return time.Time{} } func (m *SecondLevelDomain) GetRecords() map[string]*Record { @@ -376,41 +380,44 @@ func init() { } var fileDescriptor_71a2ae6361ebd509 = []byte{ - // 536 bytes of a gzipped FileDescriptorProto + // 584 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x54, 0xcf, 0x6e, 0xd3, 0x4c, - 0x10, 0xb7, 0x9b, 0x36, 0x5f, 0x32, 0x49, 0xa3, 0x7e, 0x2b, 0x54, 0xb9, 0x01, 0x4c, 0xc8, 0x01, - 0xe5, 0x00, 0x0e, 0x32, 0x08, 0x01, 0x37, 0xd2, 0x20, 0x72, 0x80, 0x1e, 0x16, 0x24, 0xa4, 0x0a, - 0x29, 0xda, 0xda, 0x43, 0x89, 0x6a, 0xef, 0x5a, 0xeb, 0x6d, 0x53, 0xbf, 0x05, 0x8f, 0x05, 0xb7, - 0x5e, 0x90, 0x38, 0xa2, 0xe4, 0x45, 0x50, 0x76, 0x9d, 0xd6, 0x71, 0x1a, 0x71, 0xf3, 0x24, 0xbf, - 0x7f, 0x33, 0xfa, 0xd9, 0xd0, 0x8b, 0xb3, 0x00, 0xa3, 0xbe, 0xc4, 0xd3, 0x49, 0xaa, 0x64, 0xd6, - 0x4f, 0x31, 0x10, 0x3c, 0x1c, 0x47, 0x78, 0x81, 0xd1, 0x38, 0x14, 0x31, 0x9b, 0x70, 0x2f, 0x91, - 0x42, 0x09, 0xd2, 0xd2, 0x48, 0x6f, 0x89, 0x6c, 0x3f, 0x28, 0x31, 0x43, 0x9e, 0x8e, 0x25, 0x06, - 0x42, 0x86, 0x86, 0xd0, 0x7e, 0x58, 0x02, 0x70, 0x54, 0x53, 0x21, 0xcf, 0xc6, 0x9c, 0xc5, 0x98, - 0x43, 0x0e, 0x4a, 0x10, 0x29, 0xa2, 0xfc, 0xaf, 0xee, 0x57, 0xa8, 0x0f, 0x79, 0x4a, 0xb5, 0x20, - 0x39, 0x84, 0xdd, 0x70, 0x39, 0x7c, 0xca, 0x12, 0x74, 0xec, 0x8e, 0xdd, 0x6b, 0xf9, 0xf7, 0xbd, - 0xd5, 0x4c, 0xde, 0xb0, 0x08, 0xa2,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00, 0xff, 0xff, + 0x91, 0x01, 0x88, 0xf9, 0xf7, 0x04, 0x00, 0x00, } func (m *DnsRecord) Marshal() (dAtA []byte, err error) { @@ -678,11 +685,14 @@ func (m *SecondLevelDomain) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x2a } } - if m.ExpirationDate != 0 { - i = encodeVarintSecondLevelDomain(dAtA, i, uint64(m.ExpirationDate)) - i-- - dAtA[i] = 0x20 + n5, err5 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.ExpirationDate, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.ExpirationDate):]) + if err5 != nil { + return 0, err5 } + i -= n5 + i = encodeVarintSecondLevelDomain(dAtA, i, uint64(n5)) + i-- + dAtA[i] = 0x22 if len(m.Owner) > 0 { i -= len(m.Owner) copy(dAtA[i:], m.Owner) @@ -833,9 +843,8 @@ func (m *SecondLevelDomain) Size() (n int) { if l > 0 { n += 1 + l + sovSecondLevelDomain(uint64(l)) } - if m.ExpirationDate != 0 { - n += 1 + sovSecondLevelDomain(uint64(m.ExpirationDate)) - } + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.ExpirationDate) + n += 1 + l + sovSecondLevelDomain(uint64(l)) if len(m.Records) > 0 { for k, v := range m.Records { _ = k @@ -1463,10 +1472,10 @@ func (m *SecondLevelDomain) Unmarshal(dAtA []byte) error { m.Owner = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 4: - if wireType != 0 { + if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ExpirationDate", wireType) } - m.ExpirationDate = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowSecondLevelDomain @@ -1476,11 +1485,25 @@ func (m *SecondLevelDomain) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ExpirationDate |= int64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } + if msglen < 0 { + return ErrInvalidLengthSecondLevelDomain + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSecondLevelDomain + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.ExpirationDate, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Records", wireType) diff --git a/x/registry/types/second_level_domain_test.go b/x/registry/types/second_level_domain_test.go index 90800118..6409f978 100644 --- a/x/registry/types/second_level_domain_test.go +++ b/x/registry/types/second_level_domain_test.go @@ -34,32 +34,32 @@ func TestDomainValidate(t *testing.T) { }, // Invalid name {domain: SecondLevelDomain{Name: ".foo", Parent: "myc"}, - expErr: errorsmod.Wrapf(ErrInvalidDomainName, ".foo"), + expErr: errorsmod.Wrapf(ErrInvalidSecondLevelDomainName, ".foo"), }, {domain: SecondLevelDomain{Name: "", Parent: "myc"}, - expErr: errorsmod.Wrapf(ErrInvalidDomainName, ""), + expErr: errorsmod.Wrapf(ErrInvalidSecondLevelDomainName, ""), }, {domain: SecondLevelDomain{Name: "bar.foo", Parent: "myc"}, - expErr: errorsmod.Wrapf(ErrInvalidDomainName, "bar.foo"), + expErr: errorsmod.Wrapf(ErrInvalidSecondLevelDomainName, "bar.foo"), }, {domain: SecondLevelDomain{Name: ".", Parent: "myc"}, - expErr: errorsmod.Wrapf(ErrInvalidDomainName, "."), + expErr: errorsmod.Wrapf(ErrInvalidSecondLevelDomainName, "."), }, {domain: SecondLevelDomain{Name: "##", Parent: "myc"}, - expErr: errorsmod.Wrapf(ErrInvalidDomainName, "##"), + expErr: errorsmod.Wrapf(ErrInvalidSecondLevelDomainName, "##"), }, // Invalid parent { domain: SecondLevelDomain{Name: "foo", Parent: ".##"}, - expErr: errorsmod.Wrapf(ErrInvalidDomainParent, ".##"), + expErr: errorsmod.Wrapf(ErrInvalidSecondLevelDomainParent, ".##"), }, { domain: SecondLevelDomain{Name: "foo", Parent: ".myc"}, - expErr: errorsmod.Wrapf(ErrInvalidDomainParent, ".myc"), + expErr: errorsmod.Wrapf(ErrInvalidSecondLevelDomainParent, ".myc"), }, { domain: SecondLevelDomain{Name: "foo", Parent: ".foo.myc"}, - expErr: errorsmod.Wrapf(ErrInvalidDomainParent, ".foo.myc"), + expErr: errorsmod.Wrapf(ErrInvalidSecondLevelDomainParent, ".foo.myc"), }, } diff --git a/x/registry/types/subdomain_config.go b/x/registry/types/subdomain_config.go index 2de6c1b1..2996f4c0 100644 --- a/x/registry/types/subdomain_config.go +++ b/x/registry/types/subdomain_config.go @@ -6,10 +6,12 @@ import ( errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/mycel-domain/mycel/app/params" ) func GetDefaultSubdomainConfig(baseFee int64) SubdomainConfig { - defaultFee := sdk.NewCoin(MycelDenom, sdk.NewInt(baseFee)) + defaultFee := sdk.NewCoin(params.DefaultBondDenom, sdk.NewInt(baseFee)) fees := GetFeeByNameLength(10, int(baseFee)) return SubdomainConfig{ @@ -25,7 +27,7 @@ func GetFeeByNameLength(base int, baseFee int) map[uint32]*Fee { fees := make(map[uint32]*Fee) for i := uint32(1); i < 5; i++ { amount := baseFee * int(math.Pow(float64(base), float64((5-i)))) - fee := sdk.NewCoin(MycelDenom, sdk.NewInt(int64(amount))) + fee := sdk.NewCoin(params.DefaultBondDenom, sdk.NewInt(int64(amount))) fees[i] = &Fee{ IsRegistrable: true, Fee: &fee, @@ -34,24 +36,24 @@ func GetFeeByNameLength(base int, baseFee int) map[uint32]*Fee { return fees } -func (config *SubdomainConfig) GetRegistrationFee(name string, registrationPeriodInYear uint64) (amount *sdk.Coin, err error) { - amount = config.SubdomainRegistrationFees.DefaultFee +func (config SubdomainConfig) GetRegistrationFee(name string, registrationPeriodInYear uint64) (amount sdk.Coin, err error) { + amount = *config.SubdomainRegistrationFees.DefaultFee // Set amount if bylength found if config.SubdomainRegistrationFees.FeeByName[name] != nil { if config.SubdomainRegistrationFees.FeeByName[name].IsRegistrable { - amount = config.SubdomainRegistrationFees.FeeByName[name].Fee + amount = *config.SubdomainRegistrationFees.FeeByName[name].Fee } else { - err = errorsmod.Wrap(errors.New(name), ErrDomainNotRegistrable.Error()) + err = errorsmod.Wrap(errors.New(name), ErrSecondLevelDomainNotRegistrable.Error()) } } // Set amount if byname found if config.SubdomainRegistrationFees.FeeByLength[uint32(len(name))] != nil { if config.SubdomainRegistrationFees.FeeByLength[uint32(len(name))].IsRegistrable { - amount = config.SubdomainRegistrationFees.FeeByLength[uint32(len(name))].Fee + amount = *config.SubdomainRegistrationFees.FeeByLength[uint32(len(name))].Fee } else { - err = errorsmod.Wrap(errors.New(name), ErrDomainNotRegistrable.Error()) + err = errorsmod.Wrap(errors.New(name), ErrSecondLevelDomainNotRegistrable.Error()) } } diff --git a/x/registry/types/tokens.go b/x/registry/types/tokens.go deleted file mode 100644 index 959aa697..00000000 --- a/x/registry/types/tokens.go +++ /dev/null @@ -1,5 +0,0 @@ -package types - -const ( - MycelDenom = "umycel" -) diff --git a/x/registry/types/top_level_domain.go b/x/registry/types/top_level_domain.go index cdeaa8b2..5f3cfa20 100644 --- a/x/registry/types/top_level_domain.go +++ b/x/registry/types/top_level_domain.go @@ -1,18 +1,15 @@ package types import ( + "time" + + errorsmod "cosmossdk.io/errors" "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/mycel-domain/mycel/app/params" ) -type TopLevelDomainRegistrationFee struct { - TotalRegistrationFee sdk.Coins - BurnWeight math.LegacyDec - RegistrationFeeToBurn sdk.Coin - RegistrationFeeToTreasury sdk.Coin -} - func GetMycelPrice(denom string) (price math.Int, err error) { switch denom { case params.DefaultBondDenom: @@ -47,3 +44,18 @@ func (topLevelDommain TopLevelDomain) GetRegistrationFeeAmountInDenom(denom stri amount = sdk.NewInt(int64(registrationPeriodInYear) * int64(topLevelDommain.SubdomainConfig.MaxSubdomainRegistrations)).Mul(baseFeeAmount) return amount, nil } + +func (topLevelDomain TopLevelDomain) IsEditable(sender string) (isEditable bool, err error) { + if topLevelDomain.AccessControl[sender] == DomainRole_NO_ROLE { + err = errorsmod.Wrapf(ErrTopLevelDomainNotEditable, "%s", sender) + } + isEditable = topLevelDomain.AccessControl[sender] == DomainRole_EDITOR || topLevelDomain.AccessControl[sender] == DomainRole_OWNER + return isEditable, err +} + +func (topLevelDomain *TopLevelDomain) ExtendExpirationDate(from time.Time, extensionPeriodInYear uint64) (expirationDate time.Time) { + expirationDate = from.AddDate(0, 0, params.OneYearInDays*int(extensionPeriodInYear)) + topLevelDomain.ExpirationDate = expirationDate + + return expirationDate +} diff --git a/x/registry/types/top_level_domain.pb.go b/x/registry/types/top_level_domain.pb.go index 53f7992a..7344dd9e 100644 --- a/x/registry/types/top_level_domain.pb.go +++ b/x/registry/types/top_level_domain.pb.go @@ -9,15 +9,19 @@ import ( types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" + github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" + _ "google.golang.org/protobuf/types/known/timestamppb" io "io" math "math" math_bits "math/bits" + time "time" ) // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal var _ = fmt.Errorf var _ = math.Inf +var _ = time.Kitchen // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -27,7 +31,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type TopLevelDomain struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - ExpirationDate int64 `protobuf:"varint,2,opt,name=expirationDate,proto3" json:"expirationDate,omitempty"` + ExpirationDate time.Time `protobuf:"bytes,2,opt,name=expirationDate,proto3,stdtime" json:"expirationDate"` Metadata map[string]string `protobuf:"bytes,3,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` SubdomainConfig *SubdomainConfig `protobuf:"bytes,4,opt,name=subdomainConfig,proto3" json:"subdomainConfig,omitempty"` SubdomainCount uint64 `protobuf:"varint,5,opt,name=subdomainCount,proto3" json:"subdomainCount,omitempty"` @@ -75,11 +79,11 @@ func (m *TopLevelDomain) GetName() string { return "" } -func (m *TopLevelDomain) GetExpirationDate() int64 { +func (m *TopLevelDomain) GetExpirationDate() time.Time { if m != nil { return m.ExpirationDate } - return 0 + return time.Time{} } func (m *TopLevelDomain) GetMetadata() map[string]string { @@ -117,10 +121,79 @@ func (m *TopLevelDomain) GetTotalWithdrawalAmount() github_com_cosmos_cosmos_sdk return nil } +type TopLevelDomainFee struct { + TotalFee github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=totalFee,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"totalFee"` + BurnWeight string `protobuf:"bytes,2,opt,name=burnWeight,proto3" json:"burnWeight,omitempty"` + FeeToBurn types.Coin `protobuf:"bytes,3,opt,name=feeToBurn,proto3,castvalue=github.com/cosmos/cosmos-sdk/types.Coin" json:"feeToBurn"` + FeeToTreasury types.Coin `protobuf:"bytes,4,opt,name=feeToTreasury,proto3,castvalue=github.com/cosmos/cosmos-sdk/types.Coin" json:"feeToTreasury"` +} + +func (m *TopLevelDomainFee) Reset() { *m = TopLevelDomainFee{} } +func (m *TopLevelDomainFee) String() string { return proto.CompactTextString(m) } +func (*TopLevelDomainFee) ProtoMessage() {} +func (*TopLevelDomainFee) Descriptor() ([]byte, []int) { + return fileDescriptor_0136e389ac8054f7, []int{1} +} +func (m *TopLevelDomainFee) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TopLevelDomainFee) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TopLevelDomainFee.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *TopLevelDomainFee) XXX_Merge(src proto.Message) { + xxx_messageInfo_TopLevelDomainFee.Merge(m, src) +} +func (m *TopLevelDomainFee) XXX_Size() int { + return m.Size() +} +func (m *TopLevelDomainFee) XXX_DiscardUnknown() { + xxx_messageInfo_TopLevelDomainFee.DiscardUnknown(m) +} + +var xxx_messageInfo_TopLevelDomainFee proto.InternalMessageInfo + +func (m *TopLevelDomainFee) GetTotalFee() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.TotalFee + } + return nil +} + +func (m *TopLevelDomainFee) GetBurnWeight() string { + if m != nil { + return m.BurnWeight + } + return "" +} + +func (m *TopLevelDomainFee) GetFeeToBurn() types.Coin { + if m != nil { + return m.FeeToBurn + } + return types.Coin{} +} + +func (m *TopLevelDomainFee) GetFeeToTreasury() types.Coin { + if m != nil { + return m.FeeToTreasury + } + return types.Coin{} +} + func init() { proto.RegisterType((*TopLevelDomain)(nil), "mycel.registry.TopLevelDomain") proto.RegisterMapType((map[string]DomainRole)(nil), "mycel.registry.TopLevelDomain.AccessControlEntry") proto.RegisterMapType((map[string]string)(nil), "mycel.registry.TopLevelDomain.MetadataEntry") + proto.RegisterType((*TopLevelDomainFee)(nil), "mycel.registry.TopLevelDomainFee") } func init() { @@ -128,38 +201,46 @@ func init() { } var fileDescriptor_0136e389ac8054f7 = []byte{ - // 484 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x53, 0x41, 0x6b, 0xd4, 0x40, - 0x14, 0xde, 0xe9, 0x76, 0xab, 0x9d, 0xd2, 0x55, 0x86, 0x0a, 0x69, 0x0e, 0xd9, 0x20, 0x28, 0x39, - 0xd8, 0x49, 0x77, 0xbd, 0x88, 0x9e, 0xda, 0xad, 0x50, 0x41, 0x2f, 0x51, 0x28, 0x88, 0xb0, 0x4c, - 0xb2, 0x63, 0x1a, 0x3a, 0xc9, 0x0b, 0x99, 0xd9, 0xb5,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b1, 0x00, 0x04, 0x6f, 0xb0, 0x1f, 0x9f, 0x5e, 0xaf, 0x1c, 0x74, - 0xb3, 0x72, 0xd0, 0x9f, 0x95, 0x83, 0xbe, 0xaf, 0x9d, 0xde, 0xcd, 0xda, 0xe9, 0xfd, 0x5c, 0x3b, - 0xbd, 0xcf, 0xb4, 0xa1, 0x5a, 0x53, 0x1d, 0x18, 0xbf, 0xcc, 0xc1, 0xbf, 0x6c, 0xfc, 0x66, 0xd5, - 0x06, 0xc2, 0x2d, 0xfd, 0xa8, 0x5f, 0xfe, 0x0d, 0x00, 0x00, 0xff, 0xff, 0x08, 0xbd, 0xcb, 0x4f, - 0x85, 0x03, 0x00, 0x00, + // 609 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0x41, 0x4f, 0xd4, 0x40, + 0x14, 0xde, 0xb2, 0x80, 0x30, 0x84, 0x55, 0x27, 0x98, 0x94, 0x1e, 0xba, 0x1b, 0x12, 0x75, 0x0f, + 0x32, 0x05, 0xbc, 0x18, 0x3d, 0xb1, 0x20, 0xc1, 0x04, 0x2f, 0x75, 0x13, 0x12, 0x63, 0x42, 0xa6, + 0xdd, 0x47, 0xb7, 0xa1, 0xed, 0x34, 0x33, 0x53, 0xa4, 0x47, 0xaf, 0x9e, 0xf8, 0x17, 0x26, 0xfe, + 0x12, 0x8e, 0x1c, 0x3d, 0x89, 0x81, 0x3f, 0xe1, 0xd1, 0x74, 0xa6, 0xbb, 0xb6, 0x95, 0xa8, 0x07, + 0x4e, 0x3b, 0x6f, 0xfa, 0xbd, 0xef, 0x7d, 0xdf, 0xdb, 0xaf, 0x45, 0x8f, 0xe3, 0xdc, 0x87, 0xc8, + 0xe1, 0x10, 0x84, 0x42, 0xf2, 0xdc, 0x91, 0x2c, 0x3d, 0x8a, 0xe0, 0x14, 0xa2, 0xa3, 0x11, 0x8b, + 0x69, 0x98, 0x90, 0x94,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 0xb2, 0x07, 0x45, 0x60, 0xef, 0x7c, 0x4d, 0x53, 0x72, 0x6c, 0x23, 0xe4, 0x65, 0x3c, + 0x39, 0x84, 0x30, 0x18, 0xcb, 0xd2, 0x7b, 0xe5, 0x06, 0x8f, 0xd1, 0xe2, 0x31, 0xc0, 0x90, 0x0d, + 0x32, 0x9e, 0x98, 0x6d, 0x95, 0xc1, 0xbf, 0x28, 0x71, 0x0a, 0x25, 0x9f, 0xaf, 0xba, 0x4f, 0xff, + 0x53, 0x89, 0xfb, 0x9b, 0x1c, 0xa7, 0x68, 0x59, 0x15, 0x43, 0x0e, 0x54, 0x64, 0x3c, 0x2f, 0x13, + 0x7f, 0x97, 0xd3, 0xea, 0x03, 0x06, 0xfb, 0x17, 0xd7, 0xb6, 0x71, 0x79, 0x6d, 0x1b, 0x3f, 0xae, + 0x6d, 0xe3, 0xfc, 0xc6, 0x6e, 0x5d, 0xde, 0xd8, 0xad, 0x6f, 0x37, 0x76, 0xeb, 0x3d, 0xa9, 0x30, + 0xaa, 0x7f, 0x71, 0x5d, 0xbf, 0x2a, 0xba, 0x70, 0xce, 0x2a, 0x1f, 0xca, 0x82, 0xdd, 0x9b, 0x57, + 0xdf, 0x89, 0xe7, 0xbf, 0x02, 0x00, 0x00, 0xff, 0xff, 0x71, 0x7d, 0x7a, 0x07, 0x47, 0x05, 0x00, + 0x00, } func (m *TopLevelDomain) Marshal() (dAtA []byte, err error) { @@ -249,11 +330,14 @@ func (m *TopLevelDomain) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x1a } } - if m.ExpirationDate != 0 { - i = encodeVarintTopLevelDomain(dAtA, i, uint64(m.ExpirationDate)) - i-- - dAtA[i] = 0x10 + n2, err2 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.ExpirationDate, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.ExpirationDate):]) + if err2 != nil { + return 0, err2 } + i -= n2 + i = encodeVarintTopLevelDomain(dAtA, i, uint64(n2)) + i-- + dAtA[i] = 0x12 if len(m.Name) > 0 { i -= len(m.Name) copy(dAtA[i:], m.Name) @@ -264,6 +348,70 @@ func (m *TopLevelDomain) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *TopLevelDomainFee) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TopLevelDomainFee) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TopLevelDomainFee) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.FeeToTreasury.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTopLevelDomain(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + { + size, err := m.FeeToBurn.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTopLevelDomain(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.BurnWeight) > 0 { + i -= len(m.BurnWeight) + copy(dAtA[i:], m.BurnWeight) + i = encodeVarintTopLevelDomain(dAtA, i, uint64(len(m.BurnWeight))) + i-- + dAtA[i] = 0x12 + } + if len(m.TotalFee) > 0 { + for iNdEx := len(m.TotalFee) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.TotalFee[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTopLevelDomain(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func encodeVarintTopLevelDomain(dAtA []byte, offset int, v uint64) int { offset -= sovTopLevelDomain(v) base := offset @@ -285,9 +433,8 @@ func (m *TopLevelDomain) Size() (n int) { if l > 0 { n += 1 + l + sovTopLevelDomain(uint64(l)) } - if m.ExpirationDate != 0 { - n += 1 + sovTopLevelDomain(uint64(m.ExpirationDate)) - } + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.ExpirationDate) + n += 1 + l + sovTopLevelDomain(uint64(l)) if len(m.Metadata) > 0 { for k, v := range m.Metadata { _ = k @@ -320,6 +467,29 @@ func (m *TopLevelDomain) Size() (n int) { return n } +func (m *TopLevelDomainFee) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.TotalFee) > 0 { + for _, e := range m.TotalFee { + l = e.Size() + n += 1 + l + sovTopLevelDomain(uint64(l)) + } + } + l = len(m.BurnWeight) + if l > 0 { + n += 1 + l + sovTopLevelDomain(uint64(l)) + } + l = m.FeeToBurn.Size() + n += 1 + l + sovTopLevelDomain(uint64(l)) + l = m.FeeToTreasury.Size() + n += 1 + l + sovTopLevelDomain(uint64(l)) + return n +} + func sovTopLevelDomain(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -388,10 +558,10 @@ func (m *TopLevelDomain) Unmarshal(dAtA []byte) error { m.Name = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: - if wireType != 0 { + if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ExpirationDate", wireType) } - m.ExpirationDate = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTopLevelDomain @@ -401,11 +571,25 @@ func (m *TopLevelDomain) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ExpirationDate |= int64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } + if msglen < 0 { + return ErrInvalidLengthTopLevelDomain + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTopLevelDomain + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.ExpirationDate, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) @@ -756,6 +940,188 @@ func (m *TopLevelDomain) Unmarshal(dAtA []byte) error { } return nil } +func (m *TopLevelDomainFee) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTopLevelDomain + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: TopLevelDomainFee: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TopLevelDomainFee: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalFee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTopLevelDomain + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTopLevelDomain + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTopLevelDomain + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TotalFee = append(m.TotalFee, types.Coin{}) + if err := m.TotalFee[len(m.TotalFee)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BurnWeight", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTopLevelDomain + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTopLevelDomain + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTopLevelDomain + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BurnWeight = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FeeToBurn", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTopLevelDomain + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTopLevelDomain + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTopLevelDomain + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.FeeToBurn.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FeeToTreasury", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTopLevelDomain + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTopLevelDomain + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTopLevelDomain + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.FeeToTreasury.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTopLevelDomain(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTopLevelDomain + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTopLevelDomain(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/registry/types/top_level_domain_test.go b/x/registry/types/top_level_domain_test.go index 4ba515c2..734e5618 100644 --- a/x/registry/types/top_level_domain_test.go +++ b/x/registry/types/top_level_domain_test.go @@ -2,17 +2,12 @@ package types import ( "testing" + "time" errorsmod "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" ) -type TopLevelDomainTest struct { - Domain TopLevelDomain - DomainPrice sdk.Coins -} - func TestTopLevelDomainValidate(t *testing.T) { testCases := []struct { domain TopLevelDomain @@ -24,19 +19,19 @@ func TestTopLevelDomainValidate(t *testing.T) { }, // Invalid name {domain: TopLevelDomain{Name: ".foo"}, - expErr: errorsmod.Wrapf(ErrInvalidDomainName, ".foo"), + expErr: errorsmod.Wrapf(ErrInvalidTopLevelDomainName, ".foo"), }, {domain: TopLevelDomain{Name: ""}, - expErr: errorsmod.Wrapf(ErrInvalidDomainName, ""), + expErr: errorsmod.Wrapf(ErrInvalidTopLevelDomainName, ""), }, {domain: TopLevelDomain{Name: "bar.foo"}, - expErr: errorsmod.Wrapf(ErrInvalidDomainName, "bar.foo"), + expErr: errorsmod.Wrapf(ErrInvalidTopLevelDomainName, "bar.foo"), }, {domain: TopLevelDomain{Name: "."}, - expErr: errorsmod.Wrapf(ErrInvalidDomainName, "."), + expErr: errorsmod.Wrapf(ErrInvalidTopLevelDomainName, "."), }, {domain: TopLevelDomain{Name: "##"}, - expErr: errorsmod.Wrapf(ErrInvalidDomainName, "##"), + expErr: errorsmod.Wrapf(ErrInvalidTopLevelDomainName, "##"), }, } @@ -49,3 +44,31 @@ func TestTopLevelDomainValidate(t *testing.T) { } } } + +func TestExtendExpirationDate(t *testing.T) { + testCases := []struct { + from time.Time + extensionPeriodInYear uint64 + expectedExpirationDate time.Time + }{ + { + from: time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC), + extensionPeriodInYear: 1, + expectedExpirationDate: time.Date(2020, 12, 31, 0, 0, 0, 0, time.UTC), + }, + { + from: time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC), + extensionPeriodInYear: 2, + expectedExpirationDate: time.Date(2021, 12, 31, 0, 0, 0, 0, time.UTC), + }, + } + + for _, tc := range testCases { + domain := TopLevelDomain{ + Name: "myc", + } + extendExpirationDate := domain.ExtendExpirationDate(tc.from, tc.extensionPeriodInYear) + require.Equal(t, tc.expectedExpirationDate, domain.ExpirationDate) + require.Equal(t, tc.expectedExpirationDate, extendExpirationDate) + } +} diff --git a/x/registry/types/tx.pb.go b/x/registry/types/tx.pb.go index 455a46c4..9fef78d3 100644 --- a/x/registry/types/tx.pb.go +++ b/x/registry/types/tx.pb.go @@ -419,6 +419,8 @@ func (m *MsgRegisterTopLevelDomain) GetRegistrationPeriodInYear() uint64 { } type MsgRegisterTopLevelDomainResponse struct { + TopLevelDomain *TopLevelDomain `protobuf:"bytes,1,opt,name=topLevelDomain,proto3" json:"topLevelDomain,omitempty"` + Fee *TopLevelDomainFee `protobuf:"bytes,2,opt,name=fee,proto3" json:"fee,omitempty"` } func (m *MsgRegisterTopLevelDomainResponse) Reset() { *m = MsgRegisterTopLevelDomainResponse{} } @@ -454,6 +456,20 @@ func (m *MsgRegisterTopLevelDomainResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgRegisterTopLevelDomainResponse proto.InternalMessageInfo +func (m *MsgRegisterTopLevelDomainResponse) GetTopLevelDomain() *TopLevelDomain { + if m != nil { + return m.TopLevelDomain + } + return nil +} + +func (m *MsgRegisterTopLevelDomainResponse) GetFee() *TopLevelDomainFee { + if m != nil { + return m.Fee + } + return nil +} + type MsgWithdrawRegistrationFee struct { Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` @@ -550,6 +566,122 @@ func (m *MsgWithdrawRegistrationFeeResponse) GetRegistrationFee() github_com_cos return nil } +type MsgExtendTopLevelDomainExpirationDate struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + ExtensionPeriodInYear uint64 `protobuf:"varint,3,opt,name=extensionPeriodInYear,proto3" json:"extensionPeriodInYear,omitempty"` +} + +func (m *MsgExtendTopLevelDomainExpirationDate) Reset() { *m = MsgExtendTopLevelDomainExpirationDate{} } +func (m *MsgExtendTopLevelDomainExpirationDate) String() string { return proto.CompactTextString(m) } +func (*MsgExtendTopLevelDomainExpirationDate) ProtoMessage() {} +func (*MsgExtendTopLevelDomainExpirationDate) Descriptor() ([]byte, []int) { + return fileDescriptor_7a4e7619dfc6612f, []int{10} +} +func (m *MsgExtendTopLevelDomainExpirationDate) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgExtendTopLevelDomainExpirationDate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgExtendTopLevelDomainExpirationDate.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgExtendTopLevelDomainExpirationDate) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgExtendTopLevelDomainExpirationDate.Merge(m, src) +} +func (m *MsgExtendTopLevelDomainExpirationDate) XXX_Size() int { + return m.Size() +} +func (m *MsgExtendTopLevelDomainExpirationDate) XXX_DiscardUnknown() { + xxx_messageInfo_MsgExtendTopLevelDomainExpirationDate.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgExtendTopLevelDomainExpirationDate proto.InternalMessageInfo + +func (m *MsgExtendTopLevelDomainExpirationDate) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgExtendTopLevelDomainExpirationDate) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *MsgExtendTopLevelDomainExpirationDate) GetExtensionPeriodInYear() uint64 { + if m != nil { + return m.ExtensionPeriodInYear + } + return 0 +} + +type MsgExtendTopLevelDomainExpirationDateResponse struct { + TopLevelDomain *TopLevelDomain `protobuf:"bytes,1,opt,name=topLevelDomain,proto3" json:"topLevelDomain,omitempty"` + Fee *TopLevelDomainFee `protobuf:"bytes,2,opt,name=fee,proto3" json:"fee,omitempty"` +} + +func (m *MsgExtendTopLevelDomainExpirationDateResponse) Reset() { + *m = MsgExtendTopLevelDomainExpirationDateResponse{} +} +func (m *MsgExtendTopLevelDomainExpirationDateResponse) String() string { + return proto.CompactTextString(m) +} +func (*MsgExtendTopLevelDomainExpirationDateResponse) ProtoMessage() {} +func (*MsgExtendTopLevelDomainExpirationDateResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_7a4e7619dfc6612f, []int{11} +} +func (m *MsgExtendTopLevelDomainExpirationDateResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgExtendTopLevelDomainExpirationDateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgExtendTopLevelDomainExpirationDateResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgExtendTopLevelDomainExpirationDateResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgExtendTopLevelDomainExpirationDateResponse.Merge(m, src) +} +func (m *MsgExtendTopLevelDomainExpirationDateResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgExtendTopLevelDomainExpirationDateResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgExtendTopLevelDomainExpirationDateResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgExtendTopLevelDomainExpirationDateResponse proto.InternalMessageInfo + +func (m *MsgExtendTopLevelDomainExpirationDateResponse) GetTopLevelDomain() *TopLevelDomain { + if m != nil { + return m.TopLevelDomain + } + return nil +} + +func (m *MsgExtendTopLevelDomainExpirationDateResponse) GetFee() *TopLevelDomainFee { + if m != nil { + return m.Fee + } + return nil +} + func init() { proto.RegisterType((*MsgUpdateWalletRecord)(nil), "mycel.registry.MsgUpdateWalletRecord") proto.RegisterType((*MsgUpdateWalletRecordResponse)(nil), "mycel.registry.MsgUpdateWalletRecordResponse") @@ -561,49 +693,58 @@ func init() { proto.RegisterType((*MsgRegisterTopLevelDomainResponse)(nil), "mycel.registry.MsgRegisterTopLevelDomainResponse") proto.RegisterType((*MsgWithdrawRegistrationFee)(nil), "mycel.registry.MsgWithdrawRegistrationFee") proto.RegisterType((*MsgWithdrawRegistrationFeeResponse)(nil), "mycel.registry.MsgWithdrawRegistrationFeeResponse") + proto.RegisterType((*MsgExtendTopLevelDomainExpirationDate)(nil), "mycel.registry.MsgExtendTopLevelDomainExpirationDate") + proto.RegisterType((*MsgExtendTopLevelDomainExpirationDateResponse)(nil), "mycel.registry.MsgExtendTopLevelDomainExpirationDateResponse") } func init() { proto.RegisterFile("mycel/registry/tx.proto", fileDescriptor_7a4e7619dfc6612f) } var fileDescriptor_7a4e7619dfc6612f = []byte{ - // 579 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0x41, 0x6f, 0xd3, 0x4c, - 0x10, 0x8d, 0xbf, 0xa4, 0xad, 0xbe, 0x41, 0x50, 0xb4, 0x2a, 0xad, 0x6b, 0x15, 0xb7, 0x98, 0x82, - 0x42, 0x45, 0x6c, 0x12, 0x38, 0x71, 0x2c, 0x15, 0x02, 0x44, 0x24, 0x64, 0x8a, 0x2a, 0xb8, 0x6d, - 0xec, 0x91, 0x6b, 0x48, 0xbc, 0xd6, 0xee, 0x26, 0x6d, 0x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0xdd, 0x18, 0x85, 0xfa, 0x82, 0x70, 0x4f, 0xf7, 0xa8, - 0xf5, 0x4a, 0x50, 0xac, 0x8b, 0x80, 0xbc, 0x07, 0x32, 0xc5, 0xdf, 0x77, 0xec, 0xc9, 0x3f, 0x10, - 0x7b, 0xaa, 0xcb, 0x8c, 0xca, 0x5c, 0xb0, 0x74, 0x54, 0x0a, 0xcb, 0xa7, 0x8d, 0x68, 0xe5, 0x32, - 0xa4, 0x18, 0x63, 0xe7, 0x7c, 0x4c, 0xda, 0xe2, 0x23, 0xac, 0xe7, 0x9b, 0xe6, 0xfe, 0x14, 0xa2, - 0x5c, 0xb4, 0xf1, 0xe8, 0x22, 0xe8, 0x54, 0x40, 0x07, 0x56, 0x73, 0x56, 0xfd, 0xde, 0x0c, 0xbe, - 0x49, 0xa8, 0x51, 0x9d, 0x1b, 0x9a, 0xf6, 0xed, 0xc2, 0x5a, 0xde, 0xda, 0x4e, 0xfb, 0xfd, 0x72, - 0xb0, 0x46, 0x6d, 0x7e, 0xec, 0xb8, 0xf5, 0xee, 0xb3, 0x5e, 0xdf, 0xd4, 0x4e, 0xfa, 0xa6, 0xf6, - 0xa7, 0x6f, 0x6a, 0x9f, 0x07, 0x66, 0xe1, 0x64, 0x60, 0x16, 0x7e, 0x0e, 0xcc, 0xc2, 0x3b, 0x3b, - 0xb3, 0x9f, 0x8a, 0xb7, 0xe2, 0x2b, 0xd5, 0x49, 0xe0, 0x1c, 0x67, 0x5e, 0xae, 0xe1, 0xae, 0x36, - 0x16, 0xd5, 0xbb, 0xf3, 0xf0, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7a, 0x61, 0x5d, 0xde, 0xd8, - 0x06, 0x00, 0x00, + // 697 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x56, 0xcf, 0x4f, 0x13, 0x41, + 0x14, 0xee, 0x58, 0x7e, 0xc4, 0x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0xd3, 0x0a, 0xaa, + 0xd7, 0xe4, 0xb4, 0xfc, 0x57, 0x26, 0x61, 0x28, 0xa0, 0x21, 0xfa, 0x42, 0xcd, 0xca, 0xd9, 0xe6, + 0x48, 0x59, 0x86, 0x9b, 0x07, 0x6d, 0xac, 0xdb, 0xf5, 0x00, 0xd5, 0x01, 0x89, 0x38, 0x33, 0xaf, + 0x8c, 0xc3, 0x60, 0x95, 0x96, 0xf7, 0x51, 0x1d, 0x94, 0x80, 0x68, 0x60, 0xcc, 0xc2, 0xad, 0x44, + 0x81, 0x36, 0xf2, 0x80, 0xf9, 0x1c, 0x8d, 0xcf, 0x04, 0x94, 0x18, 0xb1, 0xe1, 0xf3, 0x2b, 0xd5, + 0xbf, 0x00, 0x37, 0x9c, 0x16, 0x65, 0x9b, 0xf8, 0xce, 0xc9, 0x14, 0xe5, 0x33, 0xa0, 0x9d, 0xd5, + 0x15, 0xcb, 0x3e, 0x24, 0x30, 0x53, 0xe0, 0xae, 0x2d, 0x37, 0x08, 0xc3, 0x17, 0x58, 0x62, 0xbe, + 0xf3, 0xac, 0xb1, 0x43, 0x1b, 0x72, 0x83, 0xae, 0xa8, 0x81, 0x07, 0xa0, 0x36, 0xcf, 0x00, 0x15, + 0x1e, 0xf3, 0x9f, 0x63, 0xe8, 0x31, 0xe7, 0x89, 0xff, 0x0a, 0x69, 0x28, 0x7b, 0x19, 0xb0, 0x53, + 0xe3, 0xc6, 0x6d, 0x58, 0xe8, 0xa5, 0x30, 0x6e, 0xe5, 0x03, 0x81, 0xe9, 0x36, 0xe0, 0x36, 0x0b, + 0x2e, 0xdf, 0x47, 0x2f, 0xbd, 0xd9, 0x73, 0xf4, 0x1e, 0x12, 0x98, 0x4f, 0xd5, 0xd1, 0x52, 0xab, + 0x6c, 0xc1, 0xa8, 0xe8, 0x88, 0x48, 0x59, 0x23, 0x79, 0xdd, 0xec, 0xbc, 0x78, 0x66, 0x57, 0x7e, + 0x57, 0x96, 0xb2, 0x0a, 0xd9,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, 0xe2, 0x3d, 0x4c, 0xa7, 0xfb, + 0xdd, 0xdd, 0x04, 0xa2, 0x54, 0xb4, 0xb6, 0x76, 0x11, 0x74, 0x2c, 0xa0, 0x0a, 0x93, 0x29, 0x2e, + 0x75, 0xa7, 0x07, 0x5f, 0x27, 0x54, 0x5b, 0xe9, 0x1b, 0x1a, 0xd7, 0xad, 0xc3, 0x54, 0xda, 0x9d, + 0x4f, 0x5a, 0xbf, 0x14, 0xac, 0x96, 0xef, 0x1f, 0x1b, 0x97, 0xfe, 0x42, 0xc0, 0xe8, 0xe3, 0x12, + 0xde, 0x4f, 0xa0, 0x3e, 0x3f, 0x4d, 0x7b, 0x78, 0xa9, 0xb4, 0x96, 0xb8, 0xf5, 0xc7, 0x47, 0x27, + 0x3a, 0x39, 0x3e, 0xd1, 0xc9, 0x9f, 0x13, 0x9d, 0x7c, 0x3a, 0xd5, 0x33, 0xc7, 0xa7, 0x7a, 0xe6, + 0xe7, 0xa9, 0x9e, 0x79, 0x6d, 0xb6, 0x39, 0x8f, 0x2c, 0x91, 0x8b, 0xde, 0x2d, 0xd1, 0xc0, 0xaa, + 0xb5, 0xbd, 0x6c, 0x1a, 0x2e, 0x54, 0x1c, 0x92, 0xef, 0x99, 0xd5, 0x7f, 0x01, 0x00, 0x00, 0xff, + 0xff, 0x3e, 0xc7, 0xc4, 0xba, 0x57, 0x09, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -623,6 +764,7 @@ type MsgClient interface { RegisterSecondLevelDomain(ctx context.Context, in *MsgRegisterSecondLevelDomain, opts ...grpc.CallOption) (*MsgRegisterSecondLevelDomainResponse, error) RegisterTopLevelDomain(ctx context.Context, in *MsgRegisterTopLevelDomain, opts ...grpc.CallOption) (*MsgRegisterTopLevelDomainResponse, error) WithdrawRegistrationFee(ctx context.Context, in *MsgWithdrawRegistrationFee, opts ...grpc.CallOption) (*MsgWithdrawRegistrationFeeResponse, error) + ExtendTopLevelDomainExpirationDate(ctx context.Context, in *MsgExtendTopLevelDomainExpirationDate, opts ...grpc.CallOption) (*MsgExtendTopLevelDomainExpirationDateResponse, error) } type msgClient struct { @@ -678,6 +820,15 @@ func (c *msgClient) WithdrawRegistrationFee(ctx context.Context, in *MsgWithdraw return out, nil } +func (c *msgClient) ExtendTopLevelDomainExpirationDate(ctx context.Context, in *MsgExtendTopLevelDomainExpirationDate, opts ...grpc.CallOption) (*MsgExtendTopLevelDomainExpirationDateResponse, error) { + out := new(MsgExtendTopLevelDomainExpirationDateResponse) + err := c.cc.Invoke(ctx, "/mycel.registry.Msg/ExtendTopLevelDomainExpirationDate", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { UpdateWalletRecord(context.Context, *MsgUpdateWalletRecord) (*MsgUpdateWalletRecordResponse, error) @@ -685,6 +836,7 @@ type MsgServer interface { RegisterSecondLevelDomain(context.Context, *MsgRegisterSecondLevelDomain) (*MsgRegisterSecondLevelDomainResponse, error) RegisterTopLevelDomain(context.Context, *MsgRegisterTopLevelDomain) (*MsgRegisterTopLevelDomainResponse, error) WithdrawRegistrationFee(context.Context, *MsgWithdrawRegistrationFee) (*MsgWithdrawRegistrationFeeResponse, error) + ExtendTopLevelDomainExpirationDate(context.Context, *MsgExtendTopLevelDomainExpirationDate) (*MsgExtendTopLevelDomainExpirationDateResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -706,6 +858,9 @@ func (*UnimplementedMsgServer) RegisterTopLevelDomain(ctx context.Context, req * func (*UnimplementedMsgServer) WithdrawRegistrationFee(ctx context.Context, req *MsgWithdrawRegistrationFee) (*MsgWithdrawRegistrationFeeResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method WithdrawRegistrationFee not implemented") } +func (*UnimplementedMsgServer) ExtendTopLevelDomainExpirationDate(ctx context.Context, req *MsgExtendTopLevelDomainExpirationDate) (*MsgExtendTopLevelDomainExpirationDateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ExtendTopLevelDomainExpirationDate not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -801,6 +956,24 @@ func _Msg_WithdrawRegistrationFee_Handler(srv interface{}, ctx context.Context, return interceptor(ctx, in, info, handler) } +func _Msg_ExtendTopLevelDomainExpirationDate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgExtendTopLevelDomainExpirationDate) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).ExtendTopLevelDomainExpirationDate(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/mycel.registry.Msg/ExtendTopLevelDomainExpirationDate", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).ExtendTopLevelDomainExpirationDate(ctx, req.(*MsgExtendTopLevelDomainExpirationDate)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "mycel.registry.Msg", HandlerType: (*MsgServer)(nil), @@ -825,6 +998,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "WithdrawRegistrationFee", Handler: _Msg_WithdrawRegistrationFee_Handler, }, + { + MethodName: "ExtendTopLevelDomainExpirationDate", + Handler: _Msg_ExtendTopLevelDomainExpirationDate_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "mycel/registry/tx.proto", @@ -1126,6 +1303,30 @@ func (m *MsgRegisterTopLevelDomainResponse) MarshalToSizedBuffer(dAtA []byte) (i _ = i var l int _ = l + if m.Fee != nil { + { + size, err := m.Fee.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.TopLevelDomain != nil { + { + size, err := m.TopLevelDomain.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } return len(dAtA) - i, nil } @@ -1203,6 +1404,95 @@ func (m *MsgWithdrawRegistrationFeeResponse) MarshalToSizedBuffer(dAtA []byte) ( return len(dAtA) - i, nil } +func (m *MsgExtendTopLevelDomainExpirationDate) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgExtendTopLevelDomainExpirationDate) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgExtendTopLevelDomainExpirationDate) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ExtensionPeriodInYear != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.ExtensionPeriodInYear)) + i-- + dAtA[i] = 0x18 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintTx(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0x12 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgExtendTopLevelDomainExpirationDateResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgExtendTopLevelDomainExpirationDateResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgExtendTopLevelDomainExpirationDateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Fee != nil { + { + size, err := m.Fee.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.TopLevelDomain != nil { + { + size, err := m.TopLevelDomain.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -1349,6 +1639,14 @@ func (m *MsgRegisterTopLevelDomainResponse) Size() (n int) { } var l int _ = l + if m.TopLevelDomain != nil { + l = m.TopLevelDomain.Size() + n += 1 + l + sovTx(uint64(l)) + } + if m.Fee != nil { + l = m.Fee.Size() + n += 1 + l + sovTx(uint64(l)) + } return n } @@ -1384,6 +1682,43 @@ func (m *MsgWithdrawRegistrationFeeResponse) Size() (n int) { return n } +func (m *MsgExtendTopLevelDomainExpirationDate) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Name) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.ExtensionPeriodInYear != 0 { + n += 1 + sovTx(uint64(m.ExtensionPeriodInYear)) + } + return n +} + +func (m *MsgExtendTopLevelDomainExpirationDateResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.TopLevelDomain != nil { + l = m.TopLevelDomain.Size() + n += 1 + l + sovTx(uint64(l)) + } + if m.Fee != nil { + l = m.Fee.Size() + n += 1 + l + sovTx(uint64(l)) + } + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -2287,23 +2622,95 @@ func (m *MsgRegisterTopLevelDomainResponse) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: MsgRegisterTopLevelDomainResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TopLevelDomain", wireType) } - if (skippy < 0) || (iNdEx+skippy) < 0 { + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { return ErrInvalidLengthTx } - if (iNdEx + skippy) > l { + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { return io.ErrUnexpectedEOF } - iNdEx += skippy - } - } - - if iNdEx > l { + if m.TopLevelDomain == nil { + m.TopLevelDomain = &TopLevelDomain{} + } + if err := m.TopLevelDomain.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Fee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Fee == nil { + m.Fee = &TopLevelDomainFee{} + } + if err := m.Fee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { return io.ErrUnexpectedEOF } return nil @@ -2506,6 +2913,261 @@ func (m *MsgWithdrawRegistrationFeeResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgExtendTopLevelDomainExpirationDate) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgExtendTopLevelDomainExpirationDate: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgExtendTopLevelDomainExpirationDate: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ExtensionPeriodInYear", wireType) + } + m.ExtensionPeriodInYear = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ExtensionPeriodInYear |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgExtendTopLevelDomainExpirationDateResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgExtendTopLevelDomainExpirationDateResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgExtendTopLevelDomainExpirationDateResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TopLevelDomain", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.TopLevelDomain == nil { + m.TopLevelDomain = &TopLevelDomain{} + } + if err := m.TopLevelDomain.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Fee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Fee == nil { + m.Fee = &TopLevelDomainFee{} + } + if err := m.Fee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/registry/types/validate_second_level_domain.go b/x/registry/types/validate_second_level_domain.go index 8c7883b5..0c05e2bb 100644 --- a/x/registry/types/validate_second_level_domain.go +++ b/x/registry/types/validate_second_level_domain.go @@ -14,7 +14,7 @@ const ( func ValidateSecondLevelDomainName(name string) (err error) { regex := regexp.MustCompile(fmt.Sprintf(`(^[%s]+$)`, NamePattern)) if !regex.MatchString(name) { - err = errorsmod.Wrapf(ErrInvalidDomainName, "%s", name) + err = errorsmod.Wrapf(ErrInvalidSecondLevelDomainName, "%s", name) } return err } @@ -27,7 +27,7 @@ func (secondLevelDomain SecondLevelDomain) ValidateName() (err error) { func ValidateSecondLevelDomainParent(parent string) (err error) { regex := regexp.MustCompile(fmt.Sprintf(`(^[%s]+[%[1]s\.]*[%[1]s]$)|^$`, NamePattern)) if !regex.MatchString(parent) { - err = errorsmod.Wrapf(ErrInvalidDomainParent, "%s", parent) + err = errorsmod.Wrapf(ErrInvalidSecondLevelDomainParent, "%s", parent) } return err @@ -77,11 +77,3 @@ func ValidateDnsRecordType(dnsRecordType string) (err error) { } return err } - -func (secondLevelDomain SecondLevelDomain) IsRecordEditable(sender string) (isEditable bool, err error) { - if secondLevelDomain.AccessControl[sender] == DomainRole_NO_ROLE { - err = errorsmod.Wrapf(ErrDomainNotEditable, "%s", sender) - } - isEditable = secondLevelDomain.AccessControl[sender] == DomainRole_EDITOR || secondLevelDomain.AccessControl[sender] == DomainRole_OWNER - return isEditable, err -} diff --git a/x/registry/types/validate_top_level_domain.go b/x/registry/types/validate_top_level_domain.go index ec824885..f0c49be3 100644 --- a/x/registry/types/validate_top_level_domain.go +++ b/x/registry/types/validate_top_level_domain.go @@ -14,7 +14,7 @@ const ( func ValidateTopLevelDomainName(name string) (err error) { regex := regexp.MustCompile(fmt.Sprintf(`(^[%s]+$)`, TLDNamePattern)) if !regex.MatchString(name) { - err = errorsmod.Wrapf(ErrInvalidDomainName, "%s", name) + err = errorsmod.Wrapf(ErrInvalidTopLevelDomainName, "%s", name) } return err diff --git a/x/resolver/client/cli/query.go b/x/resolver/client/cli/query.go index 61a86033..6c6798e0 100644 --- a/x/resolver/client/cli/query.go +++ b/x/resolver/client/cli/query.go @@ -2,13 +2,9 @@ package cli import ( "fmt" - // "strings" - - "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" - // "github.com/cosmos/cosmos-sdk/client/flags" - // sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/spf13/cobra" "github.com/mycel-domain/mycel/x/resolver/types" ) diff --git a/x/resolver/client/cli/query_all_records.go b/x/resolver/client/cli/query_all_records.go index a1c50173..0920a4de 100644 --- a/x/resolver/client/cli/query_all_records.go +++ b/x/resolver/client/cli/query_all_records.go @@ -5,8 +5,9 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/mycel-domain/mycel/x/resolver/types" "github.com/spf13/cobra" + + "github.com/mycel-domain/mycel/x/resolver/types" ) var _ = strconv.Itoa(0) diff --git a/x/resolver/client/cli/query_dns_record.go b/x/resolver/client/cli/query_dns_record.go index a0c291b2..4e7340bb 100644 --- a/x/resolver/client/cli/query_dns_record.go +++ b/x/resolver/client/cli/query_dns_record.go @@ -5,8 +5,9 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/mycel-domain/mycel/x/resolver/types" "github.com/spf13/cobra" + + "github.com/mycel-domain/mycel/x/resolver/types" ) var _ = strconv.Itoa(0) diff --git a/x/resolver/client/cli/query_wallet_record.go b/x/resolver/client/cli/query_wallet_record.go index 2197759d..03e535c0 100644 --- a/x/resolver/client/cli/query_wallet_record.go +++ b/x/resolver/client/cli/query_wallet_record.go @@ -5,8 +5,9 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/mycel-domain/mycel/x/resolver/types" "github.com/spf13/cobra" + + "github.com/mycel-domain/mycel/x/resolver/types" ) var _ = strconv.Itoa(0) diff --git a/x/resolver/client/cli/tx.go b/x/resolver/client/cli/tx.go index d288ff80..7252f95e 100644 --- a/x/resolver/client/cli/tx.go +++ b/x/resolver/client/cli/tx.go @@ -4,9 +4,9 @@ import ( "fmt" "time" + "github.com/cosmos/cosmos-sdk/client" "github.com/spf13/cobra" - "github.com/cosmos/cosmos-sdk/client" // "github.com/cosmos/cosmos-sdk/client/flags" "github.com/mycel-domain/mycel/x/resolver/types" ) diff --git a/x/resolver/genesis.go b/x/resolver/genesis.go index cb2111c4..ac77526f 100644 --- a/x/resolver/genesis.go +++ b/x/resolver/genesis.go @@ -2,6 +2,7 @@ package resolver import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/mycel-domain/mycel/x/resolver/keeper" "github.com/mycel-domain/mycel/x/resolver/types" ) diff --git a/x/resolver/genesis_test.go b/x/resolver/genesis_test.go index 49b01882..f376ae9f 100644 --- a/x/resolver/genesis_test.go +++ b/x/resolver/genesis_test.go @@ -3,11 +3,12 @@ package resolver_test import ( "testing" + "github.com/stretchr/testify/require" + keepertest "github.com/mycel-domain/mycel/testutil/keeper" "github.com/mycel-domain/mycel/testutil/nullify" "github.com/mycel-domain/mycel/x/resolver" "github.com/mycel-domain/mycel/x/resolver/types" - "github.com/stretchr/testify/require" ) func TestGenesis(t *testing.T) { diff --git a/x/resolver/keeper/msg_server_test.go b/x/resolver/keeper/msg_server_test.go index 9207633a..980c287a 100644 --- a/x/resolver/keeper/msg_server_test.go +++ b/x/resolver/keeper/msg_server_test.go @@ -5,10 +5,11 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + keepertest "github.com/mycel-domain/mycel/testutil/keeper" "github.com/mycel-domain/mycel/x/resolver/keeper" "github.com/mycel-domain/mycel/x/resolver/types" - "github.com/stretchr/testify/require" ) func setupMsgServer(t testing.TB) (types.MsgServer, context.Context) { diff --git a/x/resolver/keeper/params.go b/x/resolver/keeper/params.go index 7b61958a..5d48ceba 100644 --- a/x/resolver/keeper/params.go +++ b/x/resolver/keeper/params.go @@ -2,6 +2,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/mycel-domain/mycel/x/resolver/types" ) diff --git a/x/resolver/keeper/params_test.go b/x/resolver/keeper/params_test.go index 0481cd91..b925b7b9 100644 --- a/x/resolver/keeper/params_test.go +++ b/x/resolver/keeper/params_test.go @@ -3,9 +3,10 @@ package keeper_test import ( "testing" + "github.com/stretchr/testify/require" + testkeeper "github.com/mycel-domain/mycel/testutil/keeper" "github.com/mycel-domain/mycel/x/resolver/types" - "github.com/stretchr/testify/require" ) func TestGetParams(t *testing.T) { diff --git a/x/resolver/keeper/query_all_records.go b/x/resolver/keeper/query_all_records.go index 30e58f7d..c6197e9d 100644 --- a/x/resolver/keeper/query_all_records.go +++ b/x/resolver/keeper/query_all_records.go @@ -4,9 +4,10 @@ import ( "context" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/mycel-domain/mycel/x/resolver/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + + "github.com/mycel-domain/mycel/x/resolver/types" ) func (k Keeper) AllRecords(goCtx context.Context, req *types.QueryAllRecordsRequest) (*types.QueryAllRecordsResponse, error) { diff --git a/x/resolver/keeper/query_dns_record.go b/x/resolver/keeper/query_dns_record.go index fa2d6081..db4691ca 100644 --- a/x/resolver/keeper/query_dns_record.go +++ b/x/resolver/keeper/query_dns_record.go @@ -4,11 +4,11 @@ import ( "context" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/mycel-domain/mycel/x/resolver/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" registrytypes "github.com/mycel-domain/mycel/x/registry/types" + "github.com/mycel-domain/mycel/x/resolver/types" ) func (k Keeper) DnsRecord(goCtx context.Context, req *types.QueryDnsRecordRequest) (*types.QueryDnsRecordResponse, error) { diff --git a/x/resolver/keeper/query_params.go b/x/resolver/keeper/query_params.go index 650bddf6..6f4d8980 100644 --- a/x/resolver/keeper/query_params.go +++ b/x/resolver/keeper/query_params.go @@ -4,9 +4,10 @@ import ( "context" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/mycel-domain/mycel/x/resolver/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + + "github.com/mycel-domain/mycel/x/resolver/types" ) func (k Keeper) Params(goCtx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { diff --git a/x/resolver/keeper/query_params_test.go b/x/resolver/keeper/query_params_test.go index acc057e4..ee4d6197 100644 --- a/x/resolver/keeper/query_params_test.go +++ b/x/resolver/keeper/query_params_test.go @@ -4,9 +4,10 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + testkeeper "github.com/mycel-domain/mycel/testutil/keeper" "github.com/mycel-domain/mycel/x/resolver/types" - "github.com/stretchr/testify/require" ) func TestParamsQuery(t *testing.T) { diff --git a/x/resolver/keeper/query_wallet_record.go b/x/resolver/keeper/query_wallet_record.go index d96d402c..8e88f5d6 100644 --- a/x/resolver/keeper/query_wallet_record.go +++ b/x/resolver/keeper/query_wallet_record.go @@ -4,11 +4,11 @@ import ( "context" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/mycel-domain/mycel/x/resolver/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" registrytypes "github.com/mycel-domain/mycel/x/registry/types" + "github.com/mycel-domain/mycel/x/resolver/types" ) func (k Keeper) WalletRecord(goCtx context.Context, req *types.QueryWalletRecordRequest) (*types.QueryWalletRecordResponse, error) { diff --git a/x/resolver/keeper/setup_test.go b/x/resolver/keeper/setup_test.go index 72299998..cf116850 100644 --- a/x/resolver/keeper/setup_test.go +++ b/x/resolver/keeper/setup_test.go @@ -1,19 +1,20 @@ package keeper_test import ( - mycelapp "github.com/mycel-domain/mycel/app" - "github.com/mycel-domain/mycel/x/registry/keeper" - "github.com/mycel-domain/mycel/x/registry/types" "testing" "time" - "github.com/mycel-domain/mycel/testutil" - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/stretchr/testify/suite" + + mycelapp "github.com/mycel-domain/mycel/app" + "github.com/mycel-domain/mycel/app/params" + "github.com/mycel-domain/mycel/testutil" + "github.com/mycel-domain/mycel/x/registry/keeper" + "github.com/mycel-domain/mycel/x/registry/types" ) type KeeperTestSuite struct { @@ -55,7 +56,7 @@ func makeBalance(address string, balance int64) banktypes.Balance { Address: address, Coins: sdk.Coins{ sdk.Coin{ - Denom: types.MycelDenom, + Denom: params.DefaultBondDenom, Amount: sdk.NewInt(balance), }, }, diff --git a/x/resolver/module.go b/x/resolver/module.go index 9d8f7310..a883083e 100644 --- a/x/resolver/module.go +++ b/x/resolver/module.go @@ -4,18 +4,17 @@ import ( "context" "encoding/json" "fmt" - // this line is used by starport scaffolding # 1 - - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/spf13/cobra" + "log" abci "github.com/cometbft/cometbft/abci/types" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + "github.com/mycel-domain/mycel/x/resolver/client/cli" "github.com/mycel-domain/mycel/x/resolver/keeper" "github.com/mycel-domain/mycel/x/resolver/types" @@ -70,7 +69,10 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { - types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) + err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) + if err != nil { + log.Printf("%v", err) + } } // GetTxCmd returns the root Tx command for the module. The subcommands of this root command are used by end-users to generate new transactions containing messages defined in the module diff --git a/x/resolver/module_simulation.go b/x/resolver/module_simulation.go index a04c3cbd..e184c701 100644 --- a/x/resolver/module_simulation.go +++ b/x/resolver/module_simulation.go @@ -8,6 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/simulation" + "github.com/mycel-domain/mycel/testutil/sample" resolversimulation "github.com/mycel-domain/mycel/x/resolver/simulation" "github.com/mycel-domain/mycel/x/resolver/types" diff --git a/x/resolver/types/expected_keepers.go b/x/resolver/types/expected_keepers.go index 9b1dbaf9..a754bc89 100644 --- a/x/resolver/types/expected_keepers.go +++ b/x/resolver/types/expected_keepers.go @@ -3,6 +3,7 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/types" + registrytypes "github.com/mycel-domain/mycel/x/registry/types" ) diff --git a/x/resolver/types/genesis_test.go b/x/resolver/types/genesis_test.go index 3f2d0479..f5c5ef88 100644 --- a/x/resolver/types/genesis_test.go +++ b/x/resolver/types/genesis_test.go @@ -3,8 +3,9 @@ package types_test import ( "testing" - "github.com/mycel-domain/mycel/x/resolver/types" "github.com/stretchr/testify/require" + + "github.com/mycel-domain/mycel/x/resolver/types" ) func TestGenesisState_Validate(t *testing.T) {