-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sdk): add sdk base create listing, offer & cancel order (#203)
## Description # New JS SDK Library for ArkChain Orderbook Interaction This pull request introduces a new SDK library specifically designed for interacting with the ArkChain orderbook. This library is a comprehensive toolset enabling users to effectively engage with ArkChain's functionalities. The following outlines the key features and components included in this initial release: ## Features - **Account Creation (Burner Wallet):** Facilitates the creation of new accounts, functioning as burner wallets for transactions. - **Listing Creation:** Provides the ability to create listings on the ArkChain orderbook. - **Offer Creation:** Enables the creation of offers within the orderbook environment. - **Order Cancellation:** Offers the functionality to cancel existing orders. - **Fulfilling Listings:** Introduces the capability to fulfill active listings in the orderbook. - **Fulfilling Offers:** Allows users to fulfill existing offers within the orderbook. ## Example Scripts - A set of example scripts are included to demonstrate practical applications of the SDK functions, such as creating accounts, listings, offers, and more. ## Testing - Comprehensive tests using Chai and Mocha have been added to validate the interaction with the ArkChain. These tests cover all the core features of the SDK, ensuring reliability and performance. This SDK represents a foundational step in streamlining and simplifying interactions with the ArkChain orderbook, providing developers with the tools necessary for efficient and effective blockchain engagements. ## What type of PR is this? (check all applicable) - [x] 🍕 Feature (`feat:`) ## 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 - [ ] 🙅 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 --> --------- Co-authored-by: Rémi Roycourt <[email protected]>
- Loading branch information
Showing
80 changed files
with
6,827 additions
and
96 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// This configuration only applies to the package manager root. | ||
/** @type {import("eslint").Linter.Config} */ | ||
module.exports = { | ||
ignorePatterns: ["apps/**", "packages/**"], | ||
extends: ["@repo/eslint-config/library.js"], | ||
parser: "@typescript-eslint/parser", | ||
parserOptions: { | ||
project: true, | ||
}, | ||
}; |
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 |
---|---|---|
@@ -1,7 +1,14 @@ | ||
{ | ||
"rust-analyzer.linkedProjects": ["./Cargo.toml"], | ||
"rust-analyzer.linkedProjects": [ | ||
"./Cargo.toml" | ||
], | ||
"[cairo]": { | ||
"editor.formatOnSave": false | ||
}, | ||
"editor.formatOnSave": true | ||
} | ||
"editor.formatOnSave": true, | ||
"eslint.workingDirectories": [ | ||
{ | ||
"mode": "auto" | ||
} | ||
] | ||
} |
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
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,32 @@ | ||
use core::debug::PrintTrait; | ||
use ark_common::crypto::hash::serialized_hash; | ||
use ark_common::crypto::signer; | ||
use core::option::OptionTrait; | ||
use ark_common::crypto::signer::{Signer, SignInfo}; | ||
use snforge_std::signature::{ | ||
StarkCurveKeyPair, StarkCurveKeyPairTrait, Signer as SNSigner, Verifier | ||
}; | ||
|
||
fn sign_mock(message_hash: felt252, pk: Option<felt252>) -> Signer { | ||
let private_key: felt252 = 0x1234567890987654321; | ||
if pk.is_some() { | ||
let private_key = pk.unwrap(); | ||
} | ||
let mut key_pair = StarkCurveKeyPairTrait::from_private_key(private_key); | ||
let (r, s) = key_pair.sign(message_hash).unwrap(); | ||
|
||
key_pair.public_key.print(); | ||
r.print(); | ||
s.print(); | ||
Signer::WEIERSTRESS_STARKNET( | ||
SignInfo { user_pubkey: key_pair.public_key, user_sig_r: r, user_sig_s: s, } | ||
) | ||
} | ||
|
||
#[test] | ||
fn test_create_listing() { | ||
let order_hash = 1187808578384236024063928606418651083953200617486980640350664202139369612009; | ||
let poseidon_hash = serialized_hash(order_hash); | ||
poseidon_hash.print(); | ||
let signer = sign_mock(poseidon_hash, Option::None); | ||
} |
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
{ | ||
"chain": "starknet", | ||
"rpc_url": "http://127.0.0.1:5050", | ||
"contract_address": "0x046c0ea3fb2ad27053e8af3c8cfab38a51afb9fe90fcab1f75446bd41f7d3796", | ||
"sender_address": "0x5686a647a9cdd63ade617e0baf3b364856b813b508f03903eb58a7e622d5855", | ||
"private_key": "0x33003003001800009900180300d206308b0070db00121318d17b5e6262150b", | ||
"interval": 2, | ||
"from_block": 0 | ||
"chain": "starknet", | ||
"rpc_url": "http://127.0.0.1:5050", | ||
"contract_address": "0x046c0ea3fb2ad27053e8af3c8cfab38a51afb9fe90fcab1f75446bd41f7d3796", | ||
"sender_address": "0x5686a647a9cdd63ade617e0baf3b364856b813b508f03903eb58a7e622d5855", | ||
"private_key": "0x33003003001800009900180300d206308b0070db00121318d17b5e6262150b", | ||
"interval": 2, | ||
"from_block": 0 | ||
} |
Oops, something went wrong.