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

Commit

Permalink
Move RegistrationPolicyType from TopLevelDomain to SubdomainConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
foxytanuki committed Dec 26, 2023
1 parent a29ebf2 commit a7b9845
Show file tree
Hide file tree
Showing 10 changed files with 142 additions and 142 deletions.
6 changes: 6 additions & 0 deletions proto/mycel/registry/subdomain_config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ import "mycel/registry/access_control.proto";

option go_package = "github.com/mycel-domain/mycel/x/registry/types";

enum RegistrationPolicyType {
PRIVATE = 0;
PUBLIC = 1;
}

message SubdomainRegistrationFees {
repeated FeeByLength feeByLength = 1;
repeated FeeByName feeByName = 2;
Expand All @@ -30,4 +35,5 @@ message SubdomainConfig {
bool isRegistrable = 3;
DomainRole registrableRole = 4;
bool customExpirationDate = 5;
RegistrationPolicyType registrationPolicy = 6;
}
6 changes: 0 additions & 6 deletions proto/mycel/registry/top_level_domain.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ import "mycel/registry/subdomain_config.proto";

option go_package = "github.com/mycel-domain/mycel/x/registry/types";

enum RegistrationPolicyType {
PRIVATE = 0;
PUBLIC = 1;
}

message TopLevelDomain {
string name = 1;
google.protobuf.Timestamp expirationDate = 2
Expand All @@ -25,7 +20,6 @@ message TopLevelDomain {
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
RegistrationPolicyType registrationPolicy = 7;
}

message TopLevelDomainFee {
Expand Down
2 changes: 1 addition & 1 deletion x/registry/keeper/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func EmitUpdateTopLevelDomainRegistrationPolicyEvent(ctx sdk.Context, domain typ
ctx.EventManager().EmitEvent(
sdk.NewEvent(types.EventTypeUpdateTopLevelDomainRegistrationPolicy,
sdk.NewAttribute(types.AttributeUpdateTopLevelDomainRegistrationPolicyEventDomainName, domain.Name),
sdk.NewAttribute(types.AttributeUpdateTopLevelDomainRegistrationPolicyEventRegistrationPolicy, domain.RegistrationPolicy.String()),
sdk.NewAttribute(types.AttributeUpdateTopLevelDomainRegistrationPolicyEventRegistrationPolicy, domain.SubdomainConfig.RegistrationPolicy.String()),
),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (suite *KeeperTestSuite) TestUpdateTopLevelDomainRegistrationPolicy() {
// Check if the record is updated
suite.Require().Nil(err)
res, _ := suite.app.RegistryKeeper.GetTopLevelDomain(suite.ctx, tc.name)
suite.Require().Equal(tc.registrationPolicy, res.GetRegistrationPolicy().String())
suite.Require().Equal(tc.registrationPolicy, res.GetSubdomainConfig().RegistrationPolicy.String())
// Evalute events
events, found := testutil.FindEventsByType(suite.ctx.EventManager().Events(), types.EventTypeUpdateTopLevelDomainRegistrationPolicy)
suite.Require().True(found)
Expand Down
2 changes: 1 addition & 1 deletion x/registry/keeper/second_level_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func (k Keeper) ValidateSecondLevelDomainIsRegistrable(ctx sdk.Context, secondLe
}

// Check if the registering domain is allowed or not
isPrivate := parentDomain.RegistrationPolicy == types.RegistrationPolicyType_PRIVATE
isPrivate := parentDomain.SubdomainConfig.RegistrationPolicy == types.RegistrationPolicyType_PRIVATE
isOwner := parentDomain.GetRole(sldOwner.String()) == types.DomainRole_OWNER

if isPrivate && !isOwner {
Expand Down
6 changes: 3 additions & 3 deletions x/registry/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ func GetDefaultTLDNames() []string {
func GetDefaultTLDs() (defaultTLDs []TopLevelDomain) {
defaultRegistrationConfig := GetDefaultSubdomainConfig(3030)
defaultRegistrationConfig.MaxSubdomainRegistrations = math.MaxInt64
defaultRegistrationConfig.RegistrationPolicy = RegistrationPolicyType_PUBLIC
for _, v := range GetDefaultTLDNames() {
defaultTLDs = append(defaultTLDs, TopLevelDomain{
Name: v,
SubdomainConfig: &defaultRegistrationConfig,
RegistrationPolicy: RegistrationPolicyType_PUBLIC,
Name: v,
SubdomainConfig: &defaultRegistrationConfig,
})
}
return defaultTLDs
Expand Down
1 change: 1 addition & 0 deletions x/registry/types/subdomain_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ func GetDefaultSubdomainConfig(baseFee int64) SubdomainConfig {
SubdomainRegistrationFees: &SubdomainRegistrationFees{
DefaultFee: &defaultFee,
},
RegistrationPolicy: RegistrationPolicyType_PRIVATE,
}
}

Expand Down
124 changes: 94 additions & 30 deletions x/registry/types/subdomain_config.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion x/registry/types/top_level_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (topLevelDomain *TopLevelDomain) ExtendExpirationDate(from time.Time, exten
}

func (topLevelDomain *TopLevelDomain) UpdateRegistrationPolicy(rp RegistrationPolicyType) {
topLevelDomain.RegistrationPolicy = rp
topLevelDomain.SubdomainConfig.RegistrationPolicy = rp
}

func (topLevelDomain TopLevelDomain) IsEditable(sender string) (isEditable bool, err error) {
Expand Down
Loading

0 comments on commit a7b9845

Please sign in to comment.