Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/events.cairo
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use starknet::ContractAddress;
use starkware_utils::signature::stark::HashType;

#[derive(Debug, Drop, PartialEq, starknet::Event)]
pub struct FeeSet {
Expand Down Expand Up @@ -44,5 +45,5 @@ pub struct OrderCanceled {
#[key]
pub user: ContractAddress,
#[key]
pub hash: felt252,
pub hash: HashType,
}
12 changes: 8 additions & 4 deletions src/payments.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ pub mod payments {
// Emit an event.
self.emit(TokenRegistered { token });
}

fn remove_token(ref self: ContractState, token: ContractAddress) {
self.roles.only_app_governor();

Expand All @@ -278,10 +279,6 @@ pub mod payments {
// Emit an event.
self.emit(TokenRemoved { token });
}
fn is_token_registered(self: @ContractState, token: ContractAddress) -> bool {
assert(token.is_non_zero(), INVALID_ZERO_TOKEN);
self.tokens.read(token)
}

fn cancel_orders(ref self: ContractState, orders: Span<Order>) {
self.roles.only_operator();
Expand Down Expand Up @@ -309,13 +306,20 @@ pub mod payments {
fn get_fee_limit(self: @ContractState) -> u128 {
self.fee_limit.read()
}

fn get_fee(self: @ContractState) -> u128 {
self.fee.read()
}

fn get_fee_recipient(self: @ContractState) -> ContractAddress {
self.fee_recipient.read()
}

fn is_token_registered(self: @ContractState, token: ContractAddress) -> bool {
assert(token.is_non_zero(), INVALID_ZERO_TOKEN);
self.tokens.read(token)
}

fn get_order_fulfillment(self: @ContractState, order_hash: HashType) -> u128 {
self.fulfillment.read(order_hash)
}
Expand Down
14 changes: 0 additions & 14 deletions src/tests/test_payments.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use starknet_payments::interface::{
IPaymentsSafeDispatcherTrait,
};
use starkware_utils::signature::stark::HashType;
use starkware_utils::time::time::Timestamp;
use starkware_utils_testing::constants as testing_constants;
use starkware_utils_testing::test_utils::{
assert_expected_event_emitted, assert_panic_with_error, assert_panic_with_felt_error,
Expand All @@ -20,19 +19,6 @@ use crate::order::Order;
use crate::payments::payments::SNIP12MetadataImpl;
use crate::tests::test_utils::*;

fn default_order() -> Order {
Order {
salt: 0,
expiry: Timestamp { seconds: 0 },
user: testing_constants::DUMMY_ADDRESS,
sell_token: testing_constants::DUMMY_ADDRESS,
buy_token: testing_constants::DUMMY_ADDRESS,
sell_amount: 100,
buy_amount: 200,
approved_counterparties: array![].span(),
}
}

#[test]
fn test_successful_register_token() {
let contract_address = init_contract_with_roles();
Expand Down
15 changes: 15 additions & 0 deletions src/tests/test_utils.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ use snforge_std::signature::stark_curve::{StarkCurveKeyPairImpl, StarkCurveSigne
use snforge_std::signature::{KeyPair, KeyPairTrait};
use snforge_std::{Token, TokenImpl, TokenTrait, set_balance};
use starknet::ContractAddress;
use starkware_utils::time::time::Timestamp;
use starkware_utils_testing::{constants as testing_constants, test_utils};
use crate::order::Order;
use crate::payments::payments::SNIP12MetadataImpl;

pub mod constants {
Expand Down Expand Up @@ -62,3 +64,16 @@ pub fn test_setup() -> (

(contract_address, token_a, token_b, user_a, user_b, key_pair_a, key_pair_b)
}

pub fn default_order() -> Order {
Order {
salt: 0,
expiry: Timestamp { seconds: 0 },
user: testing_constants::DUMMY_ADDRESS,
sell_token: testing_constants::DUMMY_ADDRESS,
buy_token: testing_constants::DUMMY_ADDRESS,
sell_amount: 100,
buy_amount: 200,
approved_counterparties: array![].span(),
}
}