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

Commit

Permalink
adds access control registration for TLD
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaguarmouse committed Sep 15, 2023
1 parent afa812e commit d35ee3e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions x/registry/keeper/msg_server_register_top_level_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,17 @@ func (k msgServer) RegisterTopLevelDomain(goCtx context.Context, msg *types.MsgR

currentTime := ctx.BlockTime()
expirationDate := currentTime.AddDate(int(msg.RegistrationPeriodInYear), 0, 0)
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,
}

err = k.Keeper.RegisterTopLevelDomain(ctx, domain, creatorAddress, msg.RegistrationPeriodInYear)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ func (suite *KeeperTestSuite) TestRegisterTopLevelDomain() {

if tc.expErr == nil {
// Evalute if domain is registered
_, found := suite.app.RegistryKeeper.GetTopLevelDomain(suite.ctx, tc.name)
domain, found := suite.app.RegistryKeeper.GetTopLevelDomain(suite.ctx, tc.name)
suite.Require().True(found)
suite.Require().Equal(domain.AccessControl[tc.creator], types.DomainRole_OWNER)

// Evalute events
suite.Require().Nil(err)
Expand Down

0 comments on commit d35ee3e

Please sign in to comment.