Skip to content
This repository has been archived by the owner on Oct 24, 2024. It is now read-only.

Commit

Permalink
Merge pull request #99 from mycel-domain/feat/withdraw-sld-fee
Browse files Browse the repository at this point in the history
Withdraw SLD Registration Fees
  • Loading branch information
taryune authored Oct 31, 2023
2 parents c08ff3c + c2c121b commit 2cc9843
Show file tree
Hide file tree
Showing 27 changed files with 1,235 additions and 233 deletions.
102 changes: 101 additions & 1 deletion docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50393,6 +50393,24 @@ paths:
- OWNER
- EDITOR
default: NO_ROLE
registrationFees:
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.
pagination:
type: object
properties:
Expand Down Expand Up @@ -50603,6 +50621,23 @@ paths:
- OWNER
- EDITOR
default: NO_ROLE
registrationFees:
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.
default:
description: An unexpected error response.
schema:
Expand Down Expand Up @@ -81143,14 +81178,31 @@ definitions:

NOTE: The amount field is an Int which implements the custom method
signatures required by gogoproto.
mycel.registry.MsgRegisterDomainResponse:
mycel.registry.MsgRegisterSecondLevelDomainResponse:
type: object
mycel.registry.MsgRegisterTopLevelDomainResponse:
type: object
mycel.registry.MsgUpdateDnsRecordResponse:
type: object
mycel.registry.MsgUpdateWalletRecordResponse:
type: object
mycel.registry.MsgWithdrawRegistrationFeeResponse:
type: object
properties:
registrationFees:
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.
mycel.registry.OwnedDomain:
type: object
properties:
Expand Down Expand Up @@ -81346,6 +81398,23 @@ definitions:
- OWNER
- EDITOR
default: NO_ROLE
registrationFees:
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.
pagination:
type: object
properties:
Expand Down Expand Up @@ -81514,6 +81583,23 @@ definitions:
- OWNER
- EDITOR
default: NO_ROLE
registrationFees:
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.
mycel.registry.QueryIsRegistrableDomainResponse:
type: object
properties:
Expand Down Expand Up @@ -81757,6 +81843,20 @@ definitions:
- OWNER
- EDITOR
default: NO_ROLE
registrationFees:
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.
mycel.registry.DnsRecord:
type: object
properties:
Expand Down
6 changes: 6 additions & 0 deletions proto/mycel/registry/top_level_domain.proto
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
syntax = "proto3";
package mycel.registry;

import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";
import "mycel/registry/subdomain_config.proto";
import "mycel/registry/role.proto";

Expand All @@ -13,4 +15,8 @@ message TopLevelDomain {
SubdomainConfig subdomainConfig = 4;
uint64 subdomainCount = 5;
map<string, DomainRole> accessControl = 6;
repeated cosmos.base.v1beta1.Coin registrationFee = 7 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}
29 changes: 23 additions & 6 deletions proto/mycel/registry/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@ syntax = "proto3";

package mycel.registry;

import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.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 RegisterDomain (MsgRegisterDomain ) returns (MsgRegisterDomainResponse );
rpc RegisterTopLevelDomain (MsgRegisterTopLevelDomain) returns (MsgRegisterTopLevelDomainResponse);
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);
}
message MsgUpdateWalletRecord {
string creator = 1;
Expand All @@ -31,14 +35,14 @@ message MsgUpdateDnsRecord {

message MsgUpdateDnsRecordResponse {}

message MsgRegisterDomain {
message MsgRegisterSecondLevelDomain {
string creator = 1;
string name = 2;
string parent = 3;
uint64 registrationPeriodInYear = 4;
}

message MsgRegisterDomainResponse {}
message MsgRegisterSecondLevelDomainResponse {}

message MsgRegisterTopLevelDomain {
string creator = 1;
Expand All @@ -47,3 +51,16 @@ message MsgRegisterTopLevelDomain {
}

message MsgRegisterTopLevelDomainResponse {}

message MsgWithdrawRegistrationFee {
string creator = 1;
string name = 2;
}

message MsgWithdrawRegistrationFeeResponse {
repeated cosmos.base.v1beta1.Coin registrationFee = 7 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

1 change: 1 addition & 0 deletions x/registry/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func GetTxCmd() *cobra.Command {
cmd.AddCommand(CmdUpdateDnsRecord())
cmd.AddCommand(CmdRegisterDomain())
cmd.AddCommand(CmdRegisterTopLevelDomain())
cmd.AddCommand(CmdWithdrawRegistrationFee())
// this line is used by starport scaffolding # 1

return cmd
Expand Down
2 changes: 1 addition & 1 deletion x/registry/client/cli/tx_register_second_level_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func CmdRegisterDomain() *cobra.Command {
return err
}

msg := types.NewMsgRegisterDomain(
msg := types.NewMsgRegisterSecondLevelDomain(
clientCtx.GetFromAddress().String(),
argName,
argParent,
Expand Down
42 changes: 42 additions & 0 deletions x/registry/client/cli/tx_withdraw_registration_fee.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
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/mycel-domain/mycel/x/registry/types"
"github.com/spf13/cobra"
)

var _ = strconv.Itoa(0)

func CmdWithdrawRegistrationFee() *cobra.Command {
cmd := &cobra.Command{
Use: "withdraw-registration-fee [name]",
Short: "Broadcast message withdrawRegistrationFee",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) (err error) {
argName := args[0]

clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}

msg := types.NewMsgWithdrawRegistrationFee(
clientCtx.GetFromAddress().String(),
argName,
)
if err := msg.ValidateBasic(); err != nil {
return err
}
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}

flags.AddTxFlagsToCmd(cmd)

return cmd
}
6 changes: 3 additions & 3 deletions x/registry/keeper/msg_server_register_second_level_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
)

func (k msgServer) RegisterDomain(goCtx context.Context, msg *types.MsgRegisterDomain) (*types.MsgRegisterDomainResponse, error) {
func (k msgServer) RegisterSecondLevelDomain(goCtx context.Context, msg *types.MsgRegisterSecondLevelDomain) (*types.MsgRegisterSecondLevelDomainResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)

if msg.RegistrationPeriodInYear < 1 || msg.RegistrationPeriodInYear > 4 {
Expand All @@ -38,10 +38,10 @@ func (k msgServer) RegisterDomain(goCtx context.Context, msg *types.MsgRegisterD
AccessControl: accessControl,
}

err = k.Keeper.RegisterDomain(ctx, domain, creatorAddress, msg.RegistrationPeriodInYear)
err = k.Keeper.RegisterSecondLevelDomain(ctx, domain, creatorAddress, msg.RegistrationPeriodInYear)
if err != nil {
return nil, err
}

return &types.MsgRegisterDomainResponse{}, nil
return &types.MsgRegisterSecondLevelDomainResponse{}, nil
}
Loading

0 comments on commit 2cc9843

Please sign in to comment.