Skip to content

Commit

Permalink
feat: expose types required by orderbook indexer (#504)
Browse files Browse the repository at this point in the history
## Description
Add public enums for `OrderType` and `RouteType`

<!--
Please do not leave this blank.
Describe the changes in this PR. What does it [add/remove/fix/replace]?

For crafting a good description, consider using ChatGPT to help
articulate your changes.
-->

## What type of PR is this? (check all applicable)

- [x] 🍕 Feature (`feat:`)
- [ ] 🐛 Bug Fix (`fix:`)
- [ ] 📝 Documentation Update (`docs:`)
- [ ] 🎨 Style (`style:`)
- [ ] 🧑‍💻 Code Refactor (`refactor:`)
- [ ] 🔥 Performance Improvements (`perf:`)
- [ ] ✅ Test (`test:`)
- [ ] 🤖 Build (`build:`)
- [ ] 🔁 CI (`ci:`)
- [ ] 📦 Chore (`chore:`)
- [ ] ⏩ Revert (`revert:`)
- [ ] 🚀 Breaking Changes (`BREAKING CHANGE:`)

## Related Tickets & Documents

<!--
Please use this format to link related issues: Fixes #<issue_number>
More info:
https://docs.github.com/en/free-pro-team@latest/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword
-->

## Added tests?

- [ ] 👍 yes
- [ ] 🙅 no, because they aren't needed
- [ ] 🙋 no, because I need help

## Added to documentation?

- [ ] 📜 README.md
- [ ] 📓 Documentation
- [ ] 🙅 no documentation needed

## [optional] Are there any post-deployment tasks we need to perform?

<!-- Describe any additional tasks, if any, and provide steps. -->

## [optional] What gif best describes this PR or how it makes you feel?

<!-- Share a fun gif related to your PR! -->

### PR Title and Description Guidelines:

- Ensure your PR title follows semantic versioning standards. This helps
automate releases and changelogs.
- Use types like `feat:`, `fix:`, `chore:`, `BREAKING CHANGE:` etc. in
your PR title.
- Your PR title will be used as a commit message when merging. Make sure
it adheres to [Conventional Commits
standards](https://www.conventionalcommits.org/).

## Closing Issues

<!--
Use keywords to close related issues. This ensures that the associated
issues will automatically close when the PR is merged.

- `Fixes #123` will close issue 123 when the PR is merged.
- `Closes #123` will also close issue 123 when the PR is merged.
- `Resolves #123` will also close issue 123 when the PR is merged.

You can also use multiple keywords in one comment:
- `Fixes #123, Resolves #456`

More info:
https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue
-->
  • Loading branch information
ptisserand authored Nov 26, 2024
1 parent d78f8ed commit 2ca0228
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
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");
}

0 comments on commit 2ca0228

Please sign in to comment.