This repository has been archived by the owner on Oct 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add valitating for TLD domain & fix to pass test
- Loading branch information
Showing
3 changed files
with
84 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package keeper | ||
|
||
import ( | ||
// "errors" | ||
// "fmt" | ||
"github.com/mycel-domain/mycel/x/registry/types" | ||
"strconv" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
// sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" | ||
) | ||
|
||
// Pay TLD registration fee | ||
func (k Keeper) PayTLDRegstrationFee(ctx sdk.Context, payer sdk.AccAddress, domain types.TopLevelDomain, registrationPeriodInYear uint64) (err error) { | ||
// TODO: Pay fee | ||
return 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 | ||
err = k.PayTLDRegstrationFee(ctx, owner, domain, registrationPeriodIYear) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// Set domain | ||
k.SetTopLevelDomain(ctx, domain) | ||
|
||
// Emit event | ||
ctx.EventManager().EmitEvent( | ||
sdk.NewEvent(types.EventTypeRegsterTopLevelDomain, | ||
sdk.NewAttribute(types.AttributeRegisterTopLevelDomainEventName, domain.Name), | ||
sdk.NewAttribute(types.AttributeRegisterTopLevelDomainEventExpirationDate, strconv.FormatInt(domain.ExpirationDate, 10)), | ||
), | ||
) | ||
|
||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters