Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking β€œSign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ci): run sdk tests with devnet #456

Closed
wants to merge 16 commits into from
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix(contracts): ensure caller is the canceller & canceller is the off…
…erer
ptisserand committed Sep 14, 2024
commit 72da2207d32acf994078d9bc16916201a28c83cb
17 changes: 17 additions & 0 deletions contracts/ark_starknet/src/executor.cairo
Original file line number Diff line number Diff line change
@@ -285,6 +285,10 @@ mod executor {

fn cancel_order(ref self: ContractState, cancelInfo: CancelInfo) {
_ensure_is_not_in_maintenance(@self);

let vinfo = CancelOrderInfo { cancelInfo: cancelInfo.clone() };
_verify_cancel_order(@self, @vinfo);

self.orderbook.cancel_order(cancelInfo);
}

@@ -368,6 +372,19 @@ mod executor {
}
}

fn _verify_cancel_order(self: @ContractState, vinfo: @CancelOrderInfo) {
let cancel_info = vinfo.cancelInfo;
let caller = starknet::get_caller_address();
let canceller = *(cancel_info.canceller);
assert!(caller == canceller, "Caller is not the canceller");

let order_info = self.orders.read(*cancel_info.order_hash);
// default value for ContractAddress is zero
// and an order's currency address shall not be zero
assert!(order_info.currency_address.is_non_zero(), "Order not found");
assert!(order_info.offerer == canceller, "Canceller is not the offerer");
}

fn _verify_fulfill_order(self: @ContractState, vinfo: @FulfillOrderInfo) {
let fulfill_info = vinfo.fulfillInfo;
let caller = starknet::get_caller_address();