Skip to content

Commit

Permalink
feat: add set_expiry back
Browse files Browse the repository at this point in the history
  • Loading branch information
Th0rgal committed Jan 2, 2024
1 parent e6a0481 commit dbfa142
Show file tree
Hide file tree
Showing 2 changed files with 23 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 @@ -60,6 +60,8 @@ trait INaming<TContractState> {
// admin
fn set_admin(ref self: TContractState, new_admin: ContractAddress);

fn set_expiry(ref self: TContractState, root_domain: felt252, expiry: u64, metadata: felt252);

fn claim_balance(ref self: TContractState, erc20: ContractAddress);

fn set_discount(ref self: TContractState, discount_id: felt252, discount: Discount);
Expand Down
21 changes: 21 additions & 0 deletions src/naming/main.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,27 @@ mod Naming {
self._admin_address.write(new_admin);
}

fn set_expiry(
ref self: ContractState, root_domain: felt252, expiry: u64, metadata: felt252
) {
assert(get_caller_address() == self._admin_address.read(), 'you are not admin');
let hashed_domain = self.hash_domain(array![root_domain].span());
let domain_data = self._domain_data.read(hashed_domain);
let data = DomainData {
owner: domain_data.owner,
resolver: domain_data.resolver,
address: domain_data.address,
expiry: expiry,
key: domain_data.key,
parent_key: 0,
};
self._domain_data.write(hashed_domain, data);
self
.emit(
Event::DomainRenewal(DomainRenewal { domain: root_domain, new_expiry: expiry })
);
}

fn claim_balance(ref self: ContractState, erc20: ContractAddress) {
assert(get_caller_address() == self._admin_address.read(), 'you are not admin');
let balance = IERC20CamelDispatcher { contract_address: erc20 }
Expand Down

0 comments on commit dbfa142

Please sign in to comment.