From 2e27f08157146a3688e0a7b010167a3c7cdea84a Mon Sep 17 00:00:00 2001 From: Iris Date: Tue, 5 Mar 2024 18:02:31 +0100 Subject: [PATCH] fix: quote typing --- src/interface/naming.cairo | 5 ++--- src/naming/main.cairo | 10 ++++++---- src/tests/naming/test_altcoin.cairo | 22 +++++++++++----------- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/interface/naming.cairo b/src/interface/naming.cairo index d0f9bb0..7b18ad5 100644 --- a/src/interface/naming.cairo +++ b/src/interface/naming.cairo @@ -1,6 +1,5 @@ use starknet::{ContractAddress, ClassHash}; use naming::naming::main::Naming::{Discount, DomainData}; -use wadray::Wad; #[starknet::interface] trait INaming { @@ -43,7 +42,7 @@ trait INaming { discount_id: felt252, metadata: felt252, altcoin_addr: ContractAddress, - quote: Wad, + quote: u128, max_validity: u64, sig: (felt252, felt252), ); @@ -65,7 +64,7 @@ trait INaming { discount_id: felt252, metadata: felt252, altcoin_addr: ContractAddress, - quote: Wad, + quote: u128, max_validity: u64, sig: (felt252, felt252), ); diff --git a/src/naming/main.cairo b/src/naming/main.cairo index 92a3c04..e8ab66a 100644 --- a/src/naming/main.cairo +++ b/src/naming/main.cairo @@ -286,7 +286,7 @@ mod Naming { discount_id: felt252, metadata: felt252, altcoin_addr: ContractAddress, - quote: Wad, + quote: u128, max_validity: u64, sig: (felt252, felt252), ) { @@ -316,7 +316,8 @@ mod Naming { } .compute_buy_price(domain_len, days); // compute domain cost in altcoin - let price_in_altcoin = self.get_altcoin_price(quote, price_in_eth.try_into().unwrap()); + let price_in_altcoin = self + .get_altcoin_price(quote.into(), price_in_eth.try_into().unwrap()); self .pay_domain( domain_len, @@ -383,7 +384,7 @@ mod Naming { discount_id: felt252, metadata: felt252, altcoin_addr: ContractAddress, - quote: Wad, + quote: u128, max_validity: u64, sig: (felt252, felt252), ) { @@ -414,7 +415,8 @@ mod Naming { } .compute_renew_price(domain_len, days); // compute domain cost in altcoin - let price_in_altcoin = self.get_altcoin_price(quote, price_in_eth.try_into().unwrap()); + let price_in_altcoin = self + .get_altcoin_price(quote.into(), price_in_eth.try_into().unwrap()); self .pay_domain( domain_len, diff --git a/src/tests/naming/test_altcoin.cairo b/src/tests/naming/test_altcoin.cairo index 621d4b1..b25b1ba 100644 --- a/src/tests/naming/test_altcoin.cairo +++ b/src/tests/naming/test_altcoin.cairo @@ -63,9 +63,9 @@ fn test_buy_domain_with_strk() { identity.mint(id1); // we check how much a domain costs - let quote = Wad { val: 5221805004292776 }; + let quote = 5221805004292776_u128; let (_, price_in_eth) = pricing.compute_buy_price(7, 365); - let price_in_strk: Wad = Wad { val: price_in_eth.low } / quote; + let price_in_strk: Wad = Wad { val: price_in_eth.low } / quote.into(); // we allow the naming to take our money strk.approve(naming.contract_address, price_in_strk.into()); @@ -120,9 +120,9 @@ fn test_buy_domain_altcoin_quote_expired() { identity.mint(id1); // we check how much a domain costs - let quote = Wad { val: 5221805004292776 }; + let quote = 5221805004292776_u128; let (_, price_in_eth) = pricing.compute_buy_price(7, 365); - let price_in_strk: Wad = Wad { val: price_in_eth.low } / quote; + let price_in_strk: Wad = Wad { val: price_in_eth.low } / quote.into(); // we allow the naming to take our money strk.approve(naming.contract_address, price_in_strk.into()); @@ -174,9 +174,9 @@ fn test_buy_domain_altcoin_wrong_quote() { identity.mint(id1); // we check how much a domain costs - let quote = Wad { val: 5221805004292776 }; + let quote = 5221805004292776_u128; let (_, price_in_eth) = pricing.compute_buy_price(7, 365); - let price_in_strk: Wad = Wad { val: price_in_eth.low } / quote; + let price_in_strk: Wad = Wad { val: price_in_eth.low } / quote.into(); // we allow the naming to take our money strk.approve(naming.contract_address, price_in_strk.into()); @@ -198,7 +198,7 @@ fn test_buy_domain_altcoin_wrong_quote() { 0, 0, strk.contract_address, - Wad { val: 1 }, + 1, max_validity, sig ); @@ -224,9 +224,9 @@ fn test_renew_domain_with_strk() { identity.mint(id1); // we check how much a domain costs - let quote = Wad { val: 5221805004292776 }; + let quote = 5221805004292776_u128; let (_, price_in_eth) = pricing.compute_buy_price(7, 365); - let price_in_strk: Wad = Wad { val: price_in_eth.low } / quote; + let price_in_strk: Wad = Wad { val: price_in_eth.low } / quote.into(); // we allow the naming to take our money strk.approve(naming.contract_address, price_in_strk.into()); @@ -259,9 +259,9 @@ fn test_renew_domain_with_strk() { ); // we check how much a domain costs to renew - let quote = Wad { val: 1221805004292776 }; + let quote = 1221805004292776_u128; let (_, price_in_eth) = pricing.compute_buy_price(7, 365); - let price_in_strk: Wad = Wad { val: price_in_eth.low } / quote; + let price_in_strk: Wad = Wad { val: price_in_eth.low } / quote.into(); // we allow the naming to take our money strk.approve(naming.contract_address, price_in_strk.into());