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: expose types required by orderbook indexer #504

Merged
merged 3 commits into from
Nov 26, 2024
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
30 changes: 30 additions & 0 deletions crates/orderbook/src/events/order_placed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ abigen!(
{
"name": "Erc721ToErc20",
"type": "()"
},
{
"name": "Erc20ToErc1155",
"type": "()"
},
{
"name": "Erc1155ToErc20",
"type": "()"
}
]
},
Expand Down Expand Up @@ -198,3 +206,25 @@ impl TryFrom<EmittedEvent> for OrderPlaced {
}
}
}

impl From<&RouteType> for crate::RouteType {
fn from(value: &RouteType) -> Self {
match value {
RouteType::Erc20ToErc721 => crate::RouteType::Erc20ToErc721,
RouteType::Erc721ToErc20 => crate::RouteType::Erc721ToErc20,
RouteType::Erc20ToErc1155 => crate::RouteType::Erc20ToErc1155,
RouteType::Erc1155ToErc20 => crate::RouteType::Erc1155ToErc20,
}
}
}

impl From<&OrderType> for crate::OrderType {
fn from(value: &OrderType) -> Self {
match value {
OrderType::Listing => crate::OrderType::Listing,
OrderType::Auction => crate::OrderType::Auction,
OrderType::Offer => crate::OrderType::Offer,
OrderType::CollectionOffer => crate::OrderType::CollectionOffer,
}
}
}
26 changes: 26 additions & 0 deletions crates/orderbook/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,29 @@ impl From<EmittedEvent> for Event {
}
}
}

pub enum RouteType {
Erc20ToErc721,
Erc721ToErc20,
Erc20ToErc1155,
Erc1155ToErc20,
}

pub enum OrderType {
Listing,
Auction,
Offer,
CollectionOffer,
}

pub mod error {
use starknet::core::types::Felt;

pub const CANCELLED_USER: Felt = Felt::from_hex_unchecked("0x43414e43454c4c45445f55534552");
pub const CANCELLED_BY_NEW_ORDER: Felt =
Felt::from_hex_unchecked("0x43414e43454c4c45445f4e45575f4f52444552");
pub const CANCELLED_ASSET_FAULT: Felt =
Felt::from_hex_unchecked("0x43414e43454c4c45445f41535345545f4641554c54");
pub const CANCELLED_OWNERSHIP: Felt =
Felt::from_hex_unchecked("0x43414e43454c4c45445f4f574e455253484950");
}
Loading