Skip to content

Commit

Permalink
feat: retain old register() signature for backward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
realnimish committed Jul 18, 2024
1 parent 998f901 commit 4f419ac
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/azns_registry/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,8 @@ mod azns_registry {
}

/// Register specific name with caller as owner.
///
/// NOTE: Whitelisted addresses can buy one name during the whitelist phase by submitting its proof
#[ink(message, payable)]
pub fn register(
pub fn register_v2(
&mut self,
name: String,
years_to_register: u8,
Expand All @@ -410,6 +408,19 @@ mod azns_registry {
Ok(())
}

/// register_v1
#[ink(message, payable)]
pub fn register(
&mut self,
name: String,
years_to_register: u8,
referrer: Option<String>,
_merkle_proof: Option<Vec<[u8; 32]>>,
set_as_primary_name: bool,
) -> Result<()> {
self.register_v2(name, years_to_register, referrer, None, set_as_primary_name)
}

#[ink(message, payable)]
pub fn renew(
&mut self,
Expand Down Expand Up @@ -3292,7 +3303,7 @@ mod tests {
set_next_caller(default_accounts().alice);
transfer_in::<DefaultEnvironment>(1000);
contract
.register(name1.clone(), 1, None, Some(bonus_name.clone()), false)
.register_v2(name1.clone(), 1, None, Some(bonus_name.clone()), false)
.unwrap();

assert_eq!(
Expand All @@ -3301,7 +3312,7 @@ mod tests {
);

contract
.register(name2, 10, None, Some(bonus_name.clone()), false)
.register_v2(name2, 10, None, Some(bonus_name.clone()), false)
.unwrap();
assert_eq!(contract.get_owner(bonus_name), Ok(accounts.alice))
}
Expand Down

0 comments on commit 4f419ac

Please sign in to comment.