Skip to content

Commit

Permalink
is_accepted_price_reached removed
Browse files Browse the repository at this point in the history
  • Loading branch information
hakymulla committed Nov 30, 2024
1 parent eb96c5c commit 81370ec
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 22 deletions.
11 changes: 0 additions & 11 deletions onchain/cairo/src/afk_id/nameservice.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ pub mod Nameservice {
pub struct Auction {
pub owner: ContractAddress,
pub minimal_price: u256,
pub is_accepted_price_reached: bool,
pub highest_bid: u256,
pub highest_bidder: ContractAddress,
}
Expand Down Expand Up @@ -211,7 +210,6 @@ pub mod Nameservice {
owner: ContractAddress,
username: felt252,
minimal_price: u256,
is_accepted_price_reached: bool

}

Expand Down Expand Up @@ -364,7 +362,6 @@ pub mod Nameservice {
ref self: ContractState,
username: felt252,
minimal_price: u256,
is_accepted_price_reached: bool
) {
let caller_address = get_caller_address();
let username_address = self.get_username_address(username);
Expand All @@ -385,7 +382,6 @@ pub mod Nameservice {
let new_auction = Auction {
owner: caller_address,
minimal_price: minimal_price,
is_accepted_price_reached: is_accepted_price_reached,
highest_bid: 0,
highest_bidder: contract_address_const::<0>(),
};
Expand All @@ -398,7 +394,6 @@ pub mod Nameservice {
owner: caller_address,
username: username,
minimal_price,
is_accepted_price_reached
}
);
}
Expand Down Expand Up @@ -429,7 +424,6 @@ pub mod Nameservice {
let mut updated_auction = auction;
updated_auction.highest_bid = amount;
updated_auction.highest_bidder = bidder;
updated_auction.is_accepted_price_reached = false;
self.auctions.write(username, updated_auction);
}

Expand All @@ -440,7 +434,6 @@ pub mod Nameservice {

let auction = self.auctions.read(username);
assert(auction.owner == caller, UserNameClaimErrors::USER_NOT_AUCTION_OWNER);
assert(auction.is_accepted_price_reached == false, UserNameClaimErrors::ACCEPTED_PRICE_REACHED);

let order = self.orders.entry((username, id)).read();
assert(order.is_active == true, UserNameClaimErrors::ORDER_INACTIVE);
Expand All @@ -452,10 +445,7 @@ pub mod Nameservice {
updated_order.is_active = false;
self.orders.entry((username, id)).write(order);

// Update auction is_accepted_price_reached
let mut updated_auction = auction;
updated_auction.is_accepted_price_reached = true;
self.auctions.write(username, updated_auction);

// Send token from contract to auction owner
let token = IERC20Dispatcher { contract_address: self.token_quote.read() };
Expand Down Expand Up @@ -492,7 +482,6 @@ pub mod Nameservice {
let mut updated_auction = auction;
updated_auction.highest_bid = 0;
updated_auction.highest_bidder = contract_address_const::<0>();
updated_auction.is_accepted_price_reached = false;
self.auctions.write(username, updated_auction);

let token = IERC20Dispatcher { contract_address: self.token_quote.read() };
Expand Down
1 change: 0 additions & 1 deletion onchain/cairo/src/interfaces/nameservice.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ pub trait INameservice<TContractState> {
ref self: TContractState,
username: felt252,
minimal_price: u256,
is_accepted_price_reached: bool
);
fn place_order(ref self: TContractState, username: felt252, amount: u256);
fn cancel_order(ref self: TContractState, username: felt252, id: u64);
Expand Down
19 changes: 9 additions & 10 deletions onchain/cairo/src/tests/nameservice_tests.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -280,12 +280,11 @@ mod nameservice_tests {
let username = selector!("test");
start_cheat_caller_address(nameservice_dispatcher.contract_address, CALLER());
nameservice_dispatcher.claim_username(username);
nameservice_dispatcher.create_auction_for_username(username, 100_u256, false);
nameservice_dispatcher.create_auction_for_username(username, 100_u256);
stop_cheat_caller_address(nameservice_dispatcher.contract_address);

let existing_auction = nameservice_dispatcher.get_auction(username);
assert(existing_auction.minimal_price == 100, 'Minimal price not correct');
assert(existing_auction.is_accepted_price_reached == false, 'price not correct');
assert(existing_auction.highest_bid == 0, 'highest_bid not correct');
assert(existing_auction.highest_bidder == starknet::contract_address_const::<0>(), 'highest_bidder not correct');
}
Expand Down Expand Up @@ -313,7 +312,7 @@ mod nameservice_tests {

let username = selector!("test");
start_cheat_caller_address(nameservice_dispatcher.contract_address, CALLER());
nameservice_dispatcher.create_auction_for_username(username, 100_u256, false);
nameservice_dispatcher.create_auction_for_username(username, 100_u256);
stop_cheat_caller_address(nameservice_dispatcher.contract_address);
}

Expand Down Expand Up @@ -346,7 +345,7 @@ mod nameservice_tests {
stop_cheat_caller_address(nameservice_dispatcher.contract_address);

start_cheat_caller_address(nameservice_dispatcher.contract_address, CALLER());
nameservice_dispatcher.create_auction_for_username(username, 5_u256, false);
nameservice_dispatcher.create_auction_for_username(username, 5_u256);
stop_cheat_caller_address(nameservice_dispatcher.contract_address);

start_cheat_caller_address(payment_token_dispatcher.contract_address, NEW_CALLER());
Expand Down Expand Up @@ -400,7 +399,7 @@ mod nameservice_tests {
stop_cheat_caller_address(nameservice_dispatcher.contract_address);

start_cheat_caller_address(nameservice_dispatcher.contract_address, CALLER()); //10
nameservice_dispatcher.create_auction_for_username(username, 5_u256, false);
nameservice_dispatcher.create_auction_for_username(username, 5_u256);
stop_cheat_caller_address(nameservice_dispatcher.contract_address);

start_cheat_caller_address(payment_token_dispatcher.contract_address, NEW_CALLER()); //2
Expand Down Expand Up @@ -462,7 +461,7 @@ mod nameservice_tests {
stop_cheat_caller_address(nameservice_dispatcher.contract_address);

start_cheat_caller_address(nameservice_dispatcher.contract_address, CALLER());
nameservice_dispatcher.create_auction_for_username(username, 5_u256, false);
nameservice_dispatcher.create_auction_for_username(username, 5_u256);
stop_cheat_caller_address(nameservice_dispatcher.contract_address);

start_cheat_caller_address(payment_token_dispatcher.contract_address, NEW_CALLER());
Expand Down Expand Up @@ -509,7 +508,7 @@ mod nameservice_tests {
stop_cheat_caller_address(nameservice_dispatcher.contract_address);

start_cheat_caller_address(nameservice_dispatcher.contract_address, CALLER()); //10
nameservice_dispatcher.create_auction_for_username(username, 5_u256, false);
nameservice_dispatcher.create_auction_for_username(username, 5_u256);
stop_cheat_caller_address(nameservice_dispatcher.contract_address);

start_cheat_caller_address(payment_token_dispatcher.contract_address, NEW_CALLER()); //2
Expand Down Expand Up @@ -577,7 +576,7 @@ mod nameservice_tests {
assert(stored_address == CALLER(), 'Address not set');

start_cheat_caller_address(nameservice_dispatcher.contract_address, CALLER()); //10
nameservice_dispatcher.create_auction_for_username(username, 5_u256, false);
nameservice_dispatcher.create_auction_for_username(username, 5_u256);
stop_cheat_caller_address(nameservice_dispatcher.contract_address);

start_cheat_caller_address(payment_token_dispatcher.contract_address, NEW_CALLER()); //2
Expand Down Expand Up @@ -642,7 +641,7 @@ mod nameservice_tests {
assert(stored_address == CALLER(), 'Address not set');

start_cheat_caller_address(nameservice_dispatcher.contract_address, CALLER()); //10
nameservice_dispatcher.create_auction_for_username(username, 5_u256, false);
nameservice_dispatcher.create_auction_for_username(username, 5_u256);
stop_cheat_caller_address(nameservice_dispatcher.contract_address);

start_cheat_caller_address(payment_token_dispatcher.contract_address, NEW_CALLER()); //2
Expand Down Expand Up @@ -720,7 +719,7 @@ mod nameservice_tests {
assert(stored_address == CALLER(), 'Address not set');

start_cheat_caller_address(nameservice_dispatcher.contract_address, CALLER()); //10
nameservice_dispatcher.create_auction_for_username(username, 5_u256, false);
nameservice_dispatcher.create_auction_for_username(username, 5_u256);
stop_cheat_caller_address(nameservice_dispatcher.contract_address);

start_cheat_caller_address(payment_token_dispatcher.contract_address, NEW_CALLER()); //2
Expand Down

0 comments on commit 81370ec

Please sign in to comment.