Skip to content

Commit

Permalink
test removed, u256 to usize, owner and transfer_ownership removed
Browse files Browse the repository at this point in the history
  • Loading branch information
mohiiit committed Dec 22, 2023
1 parent 68c00f7 commit c6ee00e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 222 deletions.
24 changes: 7 additions & 17 deletions flex_marketplace/src/marketplace/currency_manager.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ trait ICurrencyManager<TState> {
fn initializer(ref self: TState, owner: ContractAddress, proxy_admin: ContractAddress);
fn add_currency(ref self: TState, currency: ContractAddress);
fn remove_currency(ref self: TState, currency: ContractAddress);
fn transfer_contract_ownership(ref self: TState, new_owner: ContractAddress);
fn contract_owner(self: @TState) -> ContractAddress;
fn is_currency_whitelisted(self: @TState, currency: ContractAddress) -> bool;
fn whitelisted_currency_count(self: @TState) -> u256;
fn whitelisted_currency(self: @TState, index: u256) -> ContractAddress;
fn whitelisted_currency_count(self: @TState) -> usize;
fn whitelisted_currency(self: @TState, index: usize) -> ContractAddress;
}

#[starknet::contract]
Expand All @@ -29,9 +27,9 @@ mod CurrencyManager {

#[storage]
struct Storage {
whitelisted_currency_count: u256,
whitelisted_currencies: LegacyMap::<u256, ContractAddress>,
whitelisted_currency_index: LegacyMap::<ContractAddress, u256>,
whitelisted_currency_count: usize,
whitelisted_currencies: LegacyMap::<usize, ContractAddress>,
whitelisted_currency_index: LegacyMap::<ContractAddress, usize>,
#[substorage(v0)]
ownable: OwnableComponent::Storage
}
Expand Down Expand Up @@ -95,14 +93,6 @@ mod CurrencyManager {
self.emit(CurrencyRemoved { currency, timestamp });
}

fn transfer_contract_ownership(ref self: ContractState, new_owner: ContractAddress) {
self.ownable.assert_only_owner();
self.ownable.transfer_ownership(new_owner);
}
fn contract_owner(self: @ContractState) -> ContractAddress {
self.ownable.owner()
}

fn is_currency_whitelisted(self: @ContractState, currency: ContractAddress) -> bool {
let index = self.whitelisted_currency_index.read(currency);
if (index == 0) {
Expand All @@ -111,11 +101,11 @@ mod CurrencyManager {
true
}

fn whitelisted_currency_count(self: @ContractState) -> u256 {
fn whitelisted_currency_count(self: @ContractState) -> usize {
self.whitelisted_currency_count.read()
}

fn whitelisted_currency(self: @ContractState, index: u256) -> ContractAddress {
fn whitelisted_currency(self: @ContractState, index: usize) -> ContractAddress {
self.whitelisted_currencies.read(index)
}
}
Expand Down
205 changes: 0 additions & 205 deletions flex_marketplace/tests/test_currency_manager.cairo

This file was deleted.

0 comments on commit c6ee00e

Please sign in to comment.