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(diri): update indexer to support relations for tokens #263

Merged
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
35 changes: 35 additions & 0 deletions artifacts/orderbook.abi.json
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,36 @@
}
]
},
{
"type": "enum",
"name": "ark_common::protocol::order_types::OrderStatus",
"variants": [
{
"name": "Open",
"type": "()"
},
{
"name": "Fulfilled",
"type": "()"
},
{
"name": "Executed",
"type": "()"
},
{
"name": "CancelledUser",
"type": "()"
},
{
"name": "CancelledByNewOrder",
"type": "()"
},
{
"name": "CancelledAssetFault",
"type": "()"
}
]
},
{
"type": "event",
"name": "ark_orderbook::orderbook::orderbook::OrderExecuted",
Expand All @@ -513,6 +543,11 @@
"name": "order_hash",
"type": "core::felt252",
"kind": "key"
},
{
"name": "order_status",
"type": "ark_common::protocol::order_types::OrderStatus",
"kind": "key"
}
]
},
Expand Down
6 changes: 5 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 = 0x045dd7f47f2621491763ebf2095de7b4535487e3ffacde139a832c547c994a2f
ob_addr = 0x04e3170ff4f5a4e03a1aadd0eab06acb237e850dbd694b70bf4d010bdf8eb310

generate_artifacts:
scarb build --workspace
Expand All @@ -17,8 +17,12 @@ generate_artifacts:
setup_orderbook_events:
scarb build
starkli declare target/dev/ark_orderbook_orderbook_event_mock.contract_class.json ${config}
sleep 2
starkli deploy ${ob_cl} ${config} --max-fee 0 --salt 0x1234

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}
76 changes: 71 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,74 @@ 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', });
}
}
2 changes: 1 addition & 1 deletion crates/diri/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ be stored and mapped to a specific block from which is was created.

Once stored, the order, identified by it's `order_hash`, has it's lifecycle
which is the one state among the following:
0. The order is created and open (`OrderPladced`).
0. The order is created and open (`OrderPlaced`).
1. The order is cancelled (`OrderCancelled`).
2. The order is fulfilled (`OrderFulfilled`).
3. The order is executed (`OrderExecuted`).
Expand Down
35 changes: 35 additions & 0 deletions crates/diri/artifacts/orderbook.abi.json
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,36 @@
}
]
},
{
"type": "enum",
"name": "ark_common::protocol::order_types::OrderStatus",
"variants": [
{
"name": "Open",
"type": "()"
},
{
"name": "Fulfilled",
"type": "()"
},
{
"name": "Executed",
"type": "()"
},
{
"name": "CancelledUser",
"type": "()"
},
{
"name": "CancelledByNewOrder",
"type": "()"
},
{
"name": "CancelledAssetFault",
"type": "()"
}
]
},
{
"type": "event",
"name": "ark_orderbook::orderbook::orderbook::OrderExecuted",
Expand All @@ -513,6 +543,11 @@
"name": "order_hash",
"type": "core::felt252",
"kind": "key"
},
{
"name": "order_status",
"type": "ark_common::protocol::order_types::OrderStatus",
"kind": "key"
}
]
},
Expand Down
6 changes: 3 additions & 3 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
}
Loading