Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove extraneous check in can_register_in_v2 #159

Merged
merged 2 commits into from
Sep 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 12 additions & 15 deletions router/sources/router.move
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ module router::router {

// == ROUTER MANAGEMENT READ FUNCTIONS ==

inline fun get_router_signer(): signer acquires RouterConfig {
inline fun get_router_signer(): &signer acquires RouterConfig {
let router_config = borrow_global<RouterConfig>(@router);
account::create_signer_with_capability(&router_config.signer_cap)
&account::create_signer_with_capability(&router_config.signer_cap)
}

inline fun router_signer_addr(): address acquires RouterConfig {
Expand Down Expand Up @@ -147,10 +147,7 @@ module router::router {
/// If the name is registered and active in v1, then the name can only be registered if we have burned the token (sent it to the router_signer)
/// Else, the name can only be registered if it is available in v2 (we double check availablity for safety)
inline fun can_register_in_v2(domain_name: String, subdomain_name: Option<String>): bool {
if (domains::name_is_registered(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why don't we need name_is_registered?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is checked in name_is_expired

subdomain_name,
domain_name
) && !domains::name_is_expired(subdomain_name, domain_name)) {
if (!domains::name_is_expired_past_grace(subdomain_name, domain_name)) {
let (is_burned, _token_id) = domains::is_token_owner(
router_signer_addr(),
subdomain_name,
Expand Down Expand Up @@ -188,13 +185,13 @@ module router::router {
} else if (mode == MODE_V1_AND_V2) {
assert!(can_register_in_v2(domain_name, option::none()), error::unavailable(ENAME_NOT_AVAILABLE));
v2_domains::register_domain(
&get_router_signer(),
get_router_signer(),
user,
domain_name,
registration_duration_secs,
);
// Clear the name in v1
domains::force_clear_registration(&get_router_signer(), option::none(), domain_name)
domains::force_clear_registration(get_router_signer(), option::none(), domain_name)
} else {
abort error::not_implemented(ENOT_IMPLEMENTED_IN_MODE)
};
Expand Down Expand Up @@ -273,7 +270,7 @@ module router::router {
error::unavailable(ENAME_NOT_AVAILABLE)
);
v2_domains::register_subdomain(
&get_router_signer(),
get_router_signer(),
user,
domain_name,
subdomain_name,
Expand All @@ -285,7 +282,7 @@ module router::router {
subdomain_name,
expiration_policy,
);
domains::force_clear_registration(&get_router_signer(), option::some(subdomain_name), domain_name)
domains::force_clear_registration(get_router_signer(), option::some(subdomain_name), domain_name)
} else {
abort error::not_implemented(ENOT_IMPLEMENTED_IN_MODE)
};
Expand All @@ -304,7 +301,7 @@ module router::router {
};
if (mode == MODE_V1_AND_V2) {
v2_domains::set_subdomain_transferability_as_domain_owner(
&get_router_signer(),
get_router_signer(),
user,
domain_name,
subdomain_name,
Expand Down Expand Up @@ -389,7 +386,7 @@ module router::router {
let router_signer = get_router_signer();
aptos_token::token::direct_transfer(
user,
&router_signer,
router_signer,
token_id,
1,
);
Expand All @@ -408,7 +405,7 @@ module router::router {

// Mint token in v2
v2_domains::register_name_with_router(
&router_signer,
router_signer,
user,
domain_name,
subdomain_name,
Expand All @@ -429,7 +426,7 @@ module router::router {
};

// Clear the name in v1. Will also clear the primary name if it was a primary name
domains::force_clear_registration(&router_signer, subdomain_name, domain_name)
domains::force_clear_registration(router_signer, subdomain_name, domain_name)
} else {
abort error::not_implemented(ENOT_IMPLEMENTED_IN_MODE)
}
Expand Down Expand Up @@ -635,7 +632,7 @@ module router::router {
abort error::not_implemented(ENOT_IMPLEMENTED_IN_MODE)
} else if (mode == MODE_V1_AND_V2) {
v2_domains::set_subdomain_transferability_as_domain_owner(
&get_router_signer(),
get_router_signer(),
domain_admin,
domain_name,
subdomain_name,
Expand Down