diff --git a/src/proposals.cairo b/src/proposals.cairo index ca3f518c..a0a41e8f 100644 --- a/src/proposals.cairo +++ b/src/proposals.cairo @@ -53,8 +53,6 @@ mod proposals { use governance::types::VoteStatus; use governance::traits::IERC20Dispatcher; use governance::traits::IERC20DispatcherTrait; - use governance::traits::IGovernanceTokenDispatcher; - use governance::traits::IGovernanceTokenDispatcherTrait; use governance::traits::get_governance_token_address_self; use governance::constants; @@ -279,16 +277,13 @@ mod proposals { assert_correct_contract_type(to_upgrade); let govtoken_addr = get_governance_token_address_self(); let caller = get_caller_address(); - let caller_balance: u128 = IGovernanceTokenDispatcher { - contract_address: govtoken_addr - } - .balance_of(caller) + let caller_balance: u128 = IERC20Dispatcher { contract_address: govtoken_addr } + .balanceOf(caller) .low; - let total_supply = IGovernanceTokenDispatcher { contract_address: govtoken_addr } - .total_supply(); + let total_supply = IERC20Dispatcher { contract_address: govtoken_addr }.totalSupply(); let res: u256 = (caller_balance * constants::NEW_PROPOSAL_QUORUM) .into(); // TODO use such multiplication that u128 * u128 = u256 - assert(total_supply <= res, 'not enough tokens to submit'); + assert(total_supply < res, 'not enough tokens to submit'); let prop_id = self.get_free_prop_id_timestamp(); let prop_details = PropDetails { payload: payload, to_upgrade: to_upgrade.into() }; @@ -377,10 +372,8 @@ mod proposals { // TODO allow override of previous vote assert(curr_vote_status == 0, 'already voted'); - let caller_balance_u256: u256 = IGovernanceTokenDispatcher { - contract_address: gov_token_addr - } - .balance_of(caller_addr); + let caller_balance_u256: u256 = IERC20Dispatcher { contract_address: gov_token_addr } + .balanceOf(caller_addr); assert(caller_balance_u256.high == 0, 'CARM balance > u128'); let caller_balance: u128 = caller_balance_u256.low; assert(caller_balance != 0, 'CARM balance is zero'); diff --git a/src/traits.cairo b/src/traits.cairo index 22af5dbf..584f2be0 100644 --- a/src/traits.cairo +++ b/src/traits.cairo @@ -258,11 +258,11 @@ trait IGovernanceToken { fn name(self: @TContractState) -> felt252; fn symbol(self: @TContractState) -> felt252; fn decimals(self: @TContractState) -> felt252; - fn total_supply(self: @TContractState) -> u256; - fn balance_of(self: @TContractState, account: ContractAddress) -> u256; + fn totalSupply(self: @TContractState) -> u256; + fn balanceOf(self: @TContractState, account: ContractAddress) -> u256; fn allowance(self: @TContractState, owner: ContractAddress, spender: ContractAddress) -> u256; fn transfer(ref self: TContractState, recipient: ContractAddress, amount: u256) -> felt252; - fn transfer_from( + fn transferFrom( ref self: TContractState, sender: ContractAddress, recipient: ContractAddress, amount: u256 ) -> felt252; fn mint(ref self: TContractState, to: ContractAddress, amount: u256);