diff --git a/contracts/src/interface.cairo b/contracts/src/interface.cairo index ad5800e..cd3285d 100644 --- a/contracts/src/interface.cairo +++ b/contracts/src/interface.cairo @@ -4,7 +4,6 @@ use starknet::ContractAddress; pub trait IKudos { fn give_kudos( ref self: TState, - amount: u256, sender_credentials: felt252, receiver_credentials: felt252, description: felt252, diff --git a/contracts/src/kudos.cairo b/contracts/src/kudos.cairo index 7d9ab06..90373cf 100644 --- a/contracts/src/kudos.cairo +++ b/contracts/src/kudos.cairo @@ -4,7 +4,7 @@ pub mod Kudos { use kudos::credential_registry::{ICredentialRegistry, CredentialRegistryComponent}; use kudos::oz16::IERC20ReadOnly; use kudos::oz16::erc20::{ERC20Component, ERC20HooksEmptyImpl, ERC20Component::InternalTrait}; - use kudos::utils::constants::REGISTRATION_AMOUNT; + use kudos::utils::constants::{REGISTRATION_AMOUNT, ONE}; use starknet::storage::{ StoragePointerReadAccess, StoragePointerWriteAccess, StoragePathEntry, Map }; @@ -50,7 +50,6 @@ pub mod Kudos { pub sender: ContractAddress, #[key] pub receiver: ContractAddress, - pub amount: u256, pub description: felt252, } @@ -68,7 +67,6 @@ pub mod Kudos { impl Kudos of IKudos { fn give_kudos( ref self: ContractState, - amount: u256, sender_credentials: felt252, receiver_credentials: felt252, description: felt252, @@ -79,15 +77,15 @@ pub mod Kudos { let receiver = self.credential_registry.get_credential_address(receiver_credentials); assert(self.credential_registry.is_registered(receiver), Errors::RECEIVER_UNREGISTERED); - self.erc20.transfer(receiver, amount); + self.erc20.transfer(receiver, ONE); let total_given = self.total_given.entry(sender).read(); - self.total_given.entry(sender).write(total_given + amount); + self.total_given.entry(sender).write(total_given + ONE); let total_received = self.total_given.entry(receiver).read(); - self.total_received.entry(receiver).write(total_received + amount); + self.total_received.entry(receiver).write(total_received + ONE); - self.emit(KudosGiven { sender, receiver, amount, description }); + self.emit(KudosGiven { sender, receiver, description }); } fn register_sw_employee(ref self: ContractState, credential_hash: felt252,) { diff --git a/contracts/src/utils/constants.cairo b/contracts/src/utils/constants.cairo index a27ac24..b1aac94 100644 --- a/contracts/src/utils/constants.cairo +++ b/contracts/src/utils/constants.cairo @@ -22,7 +22,7 @@ pub fn ZERO_ADDRESS() -> ContractAddress { pub const DECIMALS: u8 = 18; pub const ONE: u256 = 1_000_000_000_000_000_000; -pub const REGISTRATION_AMOUNT: u256 = 1_000_000_000_000_000_000_000; +pub const REGISTRATION_AMOUNT: u256 = 5_000_000_000_000_000_000; pub fn NAME() -> ByteArray { "Kudos" diff --git a/contracts/tests/lib.cairo b/contracts/tests/lib.cairo index 84b9737..fb596ff 100644 --- a/contracts/tests/lib.cairo +++ b/contracts/tests/lib.cairo @@ -10,7 +10,7 @@ use kudos::utils::constants::{ }; use kudos::{Kudos, IKudosDispatcher, IKudosDispatcherTrait}; use snforge_std::{spy_events, EventSpyAssertionsTrait, start_cheat_caller_address}; -use utils::{setup, setup_registered, test_amount, test_description}; +use utils::{setup, setup_registered, test_description, one}; #[test] fn test_erc20_metadata() { @@ -85,17 +85,14 @@ fn test_give_kudos() { let kudos = IKudosDispatcher { contract_address: setup_registered() }; start_cheat_caller_address(kudos.contract_address, CALLER()); - kudos.give_kudos(test_amount(), CREDENTIAL_HASH, CREDENTIAL_HASH_2, test_description()); + kudos.give_kudos(CREDENTIAL_HASH, CREDENTIAL_HASH_2, test_description()); - assert_eq!(kudos.get_total_given(CALLER()), test_amount()); - assert_eq!(kudos.get_total_received(RECEIVER()), test_amount()); + assert_eq!(kudos.get_total_given(CALLER()), one()); + assert_eq!(kudos.get_total_received(RECEIVER()), one()); let expected_kudos_event = Kudos::Event::KudosGiven( Kudos::KudosGiven { - sender: CALLER(), - receiver: RECEIVER(), - amount: test_amount(), - description: test_description() + sender: CALLER(), receiver: RECEIVER(), description: test_description() } ); spy.assert_emitted(@array![(kudos.contract_address, expected_kudos_event)]); @@ -106,7 +103,7 @@ fn test_give_kudos() { fn test_give_kudos_sender_unregistered() { let kudos = IKudosDispatcher { contract_address: setup_registered() }; start_cheat_caller_address(kudos.contract_address, DUMMY()); - kudos.give_kudos(test_amount(), CREDENTIAL_HASH, CREDENTIAL_HASH_2, test_description()); + kudos.give_kudos(CREDENTIAL_HASH, CREDENTIAL_HASH_2, test_description()); } #[test] @@ -114,5 +111,5 @@ fn test_give_kudos_sender_unregistered() { fn test_give_kudos_receiver_unregistered() { let kudos = IKudosDispatcher { contract_address: setup_registered() }; start_cheat_caller_address(kudos.contract_address, CALLER()); - kudos.give_kudos(test_amount(), CREDENTIAL_HASH, CREDENTIAL_HASH_BAD, test_description()); + kudos.give_kudos(CREDENTIAL_HASH, CREDENTIAL_HASH_BAD, test_description()); } diff --git a/contracts/tests/utils.cairo b/contracts/tests/utils.cairo index c6a3728..f692637 100644 --- a/contracts/tests/utils.cairo +++ b/contracts/tests/utils.cairo @@ -42,8 +42,8 @@ pub fn setup_registered() -> ContractAddress { contract_address } -pub fn test_amount() -> u256 { - ONE * 25 +pub fn one() -> u256 { + ONE * 1 } pub fn test_description() -> felt252 {