-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(listing): add fulfill listing & tests (#184)
## Description This pull request introduces significant updates to the `Orderbook` contract, focusing on the implementation of listing order fulfillment and the enhancement of testing scenarios. #### Key Additions: 1. **Fulfilling Listing Order Functionality:** - A new function, `fulfill_order`, has been added to handle the process of fulfilling orders. This function takes in `execution_info` and `signer` as parameters and follows these steps: - Verifies the signer. - Validates the existence of the order and its status. - Checks if the order is open and not fulfilled by the same offerer. - Distinguishes the order type and proceeds with the fulfillment process for listing orders. 2. **Private Function for Listing Order Fulfillment:** - The `_fulfill_listing_order` private function has been implemented to specifically handle listing orders. It checks the order's expiration date and updates the order status to 'Fulfilled' upon successful execution. 3. **Enhanced Test Coverage:** - New test scenarios have been added to validate the functionality: - `test_create_listing_order_and_fulfill_non_existing_order`: Ensures the system correctly handles attempts to fulfill non-existing orders. - `test_create_listing_order_and_fulfill`: Tests the successful creation and fulfillment of a listing order. - `test_create_listing_order_and_fulfill_with_same_fulfiller`: Validates that an order cannot be fulfilled by the same entity that created it. These updates aim to streamline the order fulfillment process, particularly for listing orders, while ensuring robustness through comprehensive testing. <!-- 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? - [x] 👍 yes - [ ] 🙅 no, because they aren't needed - [ ] 🙋 no, because I need help ## Added to documentation? - [ ] 📜 README.md - [ ] 📓 Documentation - [x] 🙅 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
Showing
12 changed files
with
450 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use arkchain::crypto::signer::{Signer, SignInfo}; | ||
use snforge_std::signature::{ | ||
StarkCurveKeyPair, StarkCurveKeyPairTrait, Signer as SNSigner, Verifier | ||
}; | ||
|
||
fn sign_mock(message_hash: felt252) -> Signer { | ||
let private_key: felt252 = 0x1234567890987654321; | ||
let mut key_pair = StarkCurveKeyPairTrait::from_private_key(private_key); | ||
let (r, s) = key_pair.sign(message_hash).unwrap(); | ||
|
||
Signer::WEIERSTRESS_STARKNET( | ||
SignInfo { user_pubkey: key_pair.public_key, user_sig_r: r, user_sig_s: s, } | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.