Skip to content

Commit

Permalink
Contract: add new event to mock data & update makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
ybensacq committed Jan 17, 2024
1 parent 69ba297 commit 1047bd6
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 10 deletions.
5 changes: 4 additions & 1 deletion contracts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ config := --account katana-0 \
--rpc http://0.0.0.0:7777

ob_cl = $(shell starkli class-hash target/dev/ark_orderbook_orderbook_event_mock.contract_class.json)
ob_addr = 0x05038d0f1471b8a50903539888b0f51891b377416feaacfc7f037405f7cd7658
ob_addr = 0x04e3170ff4f5a4e03a1aadd0eab06acb237e850dbd694b70bf4d010bdf8eb310

generate_artifacts:
scarb build --workspace
Expand All @@ -23,3 +23,6 @@ setup_orderbook_events:
starkli invoke ${ob_addr} emit_order_placed ${config}
starkli invoke ${ob_addr} emit_order_cancelled ${config}
starkli invoke ${ob_addr} emit_order_fulfilled ${config}
starkli invoke ${ob_addr} emit_order_listing ${config}
starkli invoke ${ob_addr} emit_order_offer_placed ${config}
starkli invoke ${ob_addr} emit_order_offer_executed ${config}
81 changes: 76 additions & 5 deletions contracts/ark_orderbook/src/orderbook_event_mock.cairo
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! # Orderbook event mock Contract
//!
//!
//! A very simple orderbook like contract that is only used
//! to emit events in order to test the indexer.
//! This contract will no longer be used once the SDK is operational.
Expand Down Expand Up @@ -72,10 +72,6 @@ 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) {
Expand Down Expand Up @@ -118,4 +114,79 @@ mod orderbook_event_mock {
}
);
}

#[external(v0)]
fn emit_order_listing(ref self: ContractState) {
self
.emit(
OrderPlaced {
order_hash: 0x12345,
order_version: 0x1,
order_type: OrderType::Listing,
cancelled_order_hash: Option::None,
order: OrderV1 {
route: RouteType::Erc721ToErc20,
currency_address: 0x1.try_into().unwrap(),
currency_chain_id: 'chain',
salt: 0x0,
offerer: 0x2.try_into().unwrap(),
token_chain_id: 'chain',
token_address: 0x3.try_into().unwrap(),
token_id: Option::Some(1),
quantity: 1,
start_amount: 3,
end_amount: 4,
start_date: 5,
end_date: 6,
broker_id: 'broker',
additional_data: array![].span(),
}
}
);
}

#[external(v0)]
fn emit_order_offer_placed(ref self: ContractState) {
self
.emit(
OrderPlaced {
order_hash: 0x12346,
order_version: 0x1,
order_type: OrderType::Offer,
cancelled_order_hash: Option::None,
order: OrderV1 {
route: RouteType::Erc721ToErc20,
currency_address: 0x1.try_into().unwrap(),
currency_chain_id: 'chain',
salt: 0x0,
offerer: 0x3.try_into().unwrap(),
token_chain_id: 'chain',
token_address: 0x3.try_into().unwrap(),
token_id: Option::Some(1),
quantity: 2,
start_amount: 4,
end_amount: 0,
start_date: 2,
end_date: 0,
broker_id: 'broker',
additional_data: array![].span(),
}
}
);
}

#[external(v0)]
fn emit_order_offer_executed(ref self: ContractState) {
self
.emit(
OrderExecuted {
order_hash: 0x12346,
}
);
}

#[external(v0)]
fn emit_order_cancelled(ref self: ContractState) {
self.emit(OrderCancelled { order_hash: 0x1234, reason: 'fail', });
}
}
8 changes: 4 additions & 4 deletions crates/solis/messaging.local.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"chain": "starknet",
"rpc_url": "http://127.0.0.1:5050",
"contract_address": "0x4399750a2732c70e2349c59fe0b228c351f64153cd5997cbc286ba898b81b4e",
"sender_address": "0x5686a647a9cdd63ade617e0baf3b364856b813b508f03903eb58a7e622d5855",
"private_key": "0x33003003001800009900180300d206308b0070db00121318d17b5e6262150b",
"contract_address": "0x6bc94e52de145200fb511eb5c3ee5090de8aab947d883c16d995f28998da1c7",
"sender_address": "0x517ececd29116499f4a1b64b094da79ba08dfd54a3edaa316134c41f8160973",
"private_key": "0x1800000000300000180000000000030000000000003006001800006600",
"interval": 2,
"from_block": 0
}
}

0 comments on commit 1047bd6

Please sign in to comment.