From 6e45f7fc2bc9e8e9d874a1d2c2d46e3226a96f6d Mon Sep 17 00:00:00 2001 From: Thomas Marchand Date: Fri, 12 Jan 2024 12:14:50 +0000 Subject: [PATCH] fix: overriding a subdomain by a root domain (#20) --- 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(