Skip to content

Commit a0e8935

Browse files
chore(payments): cosmetic changes
1 parent 0aa8ed6 commit a0e8935

File tree

4 files changed

+25
-19
lines changed

4 files changed

+25
-19
lines changed

src/events.cairo

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use starknet::ContractAddress;
2+
use starkware_utils::signature::stark::HashType;
23

34
#[derive(Debug, Drop, PartialEq, starknet::Event)]
45
pub struct FeeSet {
@@ -44,5 +45,5 @@ pub struct OrderCanceled {
4445
#[key]
4546
pub user: ContractAddress,
4647
#[key]
47-
pub hash: felt252,
48+
pub hash: HashType,
4849
}

src/payments.cairo

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ pub mod payments {
269269
// Emit an event.
270270
self.emit(TokenRegistered { token });
271271
}
272+
272273
fn remove_token(ref self: ContractState, token: ContractAddress) {
273274
self.roles.only_app_governor();
274275

@@ -278,10 +279,6 @@ pub mod payments {
278279
// Emit an event.
279280
self.emit(TokenRemoved { token });
280281
}
281-
fn is_token_registered(self: @ContractState, token: ContractAddress) -> bool {
282-
assert(token.is_non_zero(), INVALID_ZERO_TOKEN);
283-
self.tokens.read(token)
284-
}
285282

286283
fn cancel_orders(ref self: ContractState, orders: Span<Order>) {
287284
self.roles.only_operator();
@@ -309,13 +306,20 @@ pub mod payments {
309306
fn get_fee_limit(self: @ContractState) -> u128 {
310307
self.fee_limit.read()
311308
}
309+
312310
fn get_fee(self: @ContractState) -> u128 {
313311
self.fee.read()
314312
}
313+
315314
fn get_fee_recipient(self: @ContractState) -> ContractAddress {
316315
self.fee_recipient.read()
317316
}
318317

318+
fn is_token_registered(self: @ContractState, token: ContractAddress) -> bool {
319+
assert(token.is_non_zero(), INVALID_ZERO_TOKEN);
320+
self.tokens.read(token)
321+
}
322+
319323
fn get_order_fulfillment(self: @ContractState, order_hash: HashType) -> u128 {
320324
self.fulfillment.read(order_hash)
321325
}

src/tests/test_payments.cairo

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use starknet_payments::interface::{
99
IPaymentsSafeDispatcherTrait,
1010
};
1111
use starkware_utils::signature::stark::HashType;
12-
use starkware_utils::time::time::Timestamp;
1312
use starkware_utils_testing::constants as testing_constants;
1413
use starkware_utils_testing::test_utils::{
1514
assert_expected_event_emitted, assert_panic_with_error, assert_panic_with_felt_error,
@@ -20,19 +19,6 @@ use crate::order::Order;
2019
use crate::payments::payments::SNIP12MetadataImpl;
2120
use crate::tests::test_utils::*;
2221

23-
fn default_order() -> Order {
24-
Order {
25-
salt: 0,
26-
expiry: Timestamp { seconds: 0 },
27-
user: testing_constants::DUMMY_ADDRESS,
28-
sell_token: testing_constants::DUMMY_ADDRESS,
29-
buy_token: testing_constants::DUMMY_ADDRESS,
30-
sell_amount: 100,
31-
buy_amount: 200,
32-
approved_counterparties: array![].span(),
33-
}
34-
}
35-
3622
#[test]
3723
fn test_successful_register_token() {
3824
let contract_address = init_contract_with_roles();

src/tests/test_utils.cairo

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ use snforge_std::signature::stark_curve::{StarkCurveKeyPairImpl, StarkCurveSigne
44
use snforge_std::signature::{KeyPair, KeyPairTrait};
55
use snforge_std::{Token, TokenImpl, TokenTrait, set_balance};
66
use starknet::ContractAddress;
7+
use starkware_utils::time::time::Timestamp;
78
use starkware_utils_testing::{constants as testing_constants, test_utils};
9+
use crate::order::Order;
810
use crate::payments::payments::SNIP12MetadataImpl;
911

1012
pub mod constants {
@@ -62,3 +64,16 @@ pub fn test_setup() -> (
6264

6365
(contract_address, token_a, token_b, user_a, user_b, key_pair_a, key_pair_b)
6466
}
67+
68+
pub fn default_order() -> Order {
69+
Order {
70+
salt: 0,
71+
expiry: Timestamp { seconds: 0 },
72+
user: testing_constants::DUMMY_ADDRESS,
73+
sell_token: testing_constants::DUMMY_ADDRESS,
74+
buy_token: testing_constants::DUMMY_ADDRESS,
75+
sell_amount: 100,
76+
buy_amount: 200,
77+
approved_counterparties: array![].span(),
78+
}
79+
}

0 commit comments

Comments
 (0)