Skip to content

Commit

Permalink
wip: add Makefile for testing events only
Browse files Browse the repository at this point in the history
  • Loading branch information
glihm committed Nov 30, 2023
1 parent da7140a commit aef5007
Show file tree
Hide file tree
Showing 5 changed files with 622 additions and 14 deletions.
22 changes: 11 additions & 11 deletions crates/ark-contracts/arkchain/Makefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
config := --account katana-0 \
--rpc http://0.0.0.0:7777

ob_cl = $(shell starkli class-hash target/dev/arkchain_orderbook.contract_class.json)
ob_cl = $(shell starkli class-hash target/dev/arkchain_orderbook_event_mock.contract_class.json)
ob_addr = 0x045dd7f47f2621491763ebf2095de7b4535487e3ffacde139a832c547c994a2f

generate_artifacts:
scarb build
mkdir -p ../../../artifacts
# For now, the json is duplicated to be able to run
# cargo build -p diri from here, and from ark-services too.
jq .abi ./target/dev/arkchain_orderbook.contract_class.json > ../../../artifacts/orderbook.json
jq .abi ./target/dev/arkchain_orderbook.contract_class.json > ../../diri/artifacts/orderbook.json

# Using max-fee 0 avoids starkli to run estimate_fee before actually sending the tx.
# There are no fees on Solis.
setup_orderbook:
setup_orderbook_events:
scarb build
starkli declare target/dev/arkchain_orderbook.contract_class.json ${config}
starkli deploy ${ob_cl} 0x517ececd29116499f4a1b64b094da79ba08dfd54a3edaa316134c41f8160973 ${config} --max-fee 0 --salt 0x1234
starkli declare target/dev/arkchain_orderbook_event_mock.contract_class.json ${config}
starkli deploy ${ob_cl} ${config} --max-fee 0 --salt 0x1234

invoke_create_order:
starkli invoke \
0x024df499c7b1b14c0e52ea237e26a7401ef70507cf72eaef105316dfb5a207a7 \
create_order \
0 0x1 0x2 0x3 0x4 0x5 0x6 u256:0x7 u256:0x1 u256:0x1 u256:0x2 10000 20000 str:broker 0 \
0x1 0x2 0x3 \
--max-fee-raw 10581100000000000
starkli invoke ${ob_addr} emit_order_placed ${config}
starkli invoke ${ob_addr} emit_order_cancelled ${config}
starkli invoke ${ob_addr} emit_order_fulfilled ${config}
17 changes: 17 additions & 0 deletions crates/ark-contracts/arkchain/src/orderbook_event_mock.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,23 @@ mod orderbook_event_mock {
related_order_hash: Option<felt252>,
}

#[external(v0)]
fn emit_order_cancelled(ref self: ContractState) {
self.emit(OrderCancelled {
order_hash: 0x1,
reason: 'fail',
});
}

#[external(v0)]
fn emit_order_fulfilled(ref self: ContractState) {
self.emit(OrderFulfilled {
order_hash: 0x1,
fulfiller: 0x123.try_into().unwrap(),
related_order_hash: Option::Some(0x1111),
});
}

#[external(v0)]
fn emit_order_placed(ref self: ContractState) {
self
Expand Down
Loading

0 comments on commit aef5007

Please sign in to comment.