Skip to content

Commit

Permalink
feat: add reset_subdomains function
Browse files Browse the repository at this point in the history
  • Loading branch information
Th0rgal committed Aug 29, 2023
1 parent 87b293d commit 6409948
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/interface/naming.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ trait INaming<TContractState> {

fn transfer_domain(ref self: TContractState, domain: Span<felt252>, target_id: u128);

fn reset_subdomains(ref self: TContractState, domain: Span<felt252>);

// admin
fn set_admin(ref self: TContractState, new_admin: ContractAddress);

Expand Down
22 changes: 22 additions & 0 deletions src/naming/main.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ mod Naming {
DomainRenewal: DomainRenewal,
DomainToResolver: DomainToResolver,
DomainTransfer: DomainTransfer,
SubdomainsReset: SubdomainsReset,
SaleMetadata: SaleMetadata,
}

Expand Down Expand Up @@ -62,6 +63,12 @@ mod Naming {
new_owner: u128
}

#[derive(Drop, starknet::Event)]
struct SubdomainsReset {
#[key]
domain: Span<felt252>,
}

#[derive(Drop, starknet::Event)]
struct SaleMetadata {
domain: felt252,
Expand Down Expand Up @@ -299,6 +306,21 @@ mod Naming {
.set_verifier_data(target_id, 'name', hashed_domain, 0);
}

fn reset_subdomains(ref self: ContractState, domain: Span<felt252>) {
self.assert_control_domain(domain, get_caller_address());
let hashed_domain = self.hash_domain(domain);
let current_domain_data = self._domain_data.read(hashed_domain);
let new_domain_data = DomainData {
owner: current_domain_data.owner,
resolver: current_domain_data.resolver,
address: current_domain_data.address,
expiry: current_domain_data.expiry,
key: current_domain_data.key + 1,
parent_key: current_domain_data.parent_key,
};
self._domain_data.write(hashed_domain, new_domain_data);
self.emit(Event::SubdomainsReset(SubdomainsReset { domain: domain, }));
}

// ADMIN

Expand Down

0 comments on commit 6409948

Please sign in to comment.