From 7e5b8ff2f7dc611b6290c3d739a782f4c9d9e9a9 Mon Sep 17 00:00:00 2001 From: Thomas Marchand Date: Fri, 12 Jan 2024 11:54:58 +0000 Subject: [PATCH] fix: overriding a subdomain by a root domain --- src/naming/internal.cairo | 16 +++++++++------- src/naming/main.cairo | 1 - 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/naming/internal.cairo b/src/naming/internal.cairo index cd1d998..1b25986 100644 --- a/src/naming/internal.cairo +++ b/src/naming/internal.cairo @@ -44,13 +44,15 @@ impl InternalImpl of InternalTrait { fn set_address_to_domain_util( ref self: Naming::ContractState, address: ContractAddress, mut domain: Span ) { - match domain.pop_back() { - Option::Some(domain_part) => { - self._address_to_domain.write((address, domain.len()), *domain_part); - self.set_address_to_domain_util(address, domain) - }, - Option::None => {} - } + self._address_to_domain.write((address, domain.len()), 0); + loop { + match domain.pop_back() { + Option::Some(domain_part) => { + self._address_to_domain.write((address, domain.len()), *domain_part); + }, + Option::None => { break; } + } + }; } fn domain_to_resolver( diff --git a/src/naming/main.cairo b/src/naming/main.cairo index 3300756..af1f95b 100644 --- a/src/naming/main.cairo +++ b/src/naming/main.cairo @@ -247,7 +247,6 @@ mod Naming { } } - // EXTERNAL fn buy(