-
Notifications
You must be signed in to change notification settings - Fork 22
feat: create near-mpc-sdk crate with types for sign requests
#2202
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
Merged
Merged
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
7d172e1
.
DSharifi 02fcf18
revise on LLM reviews
DSharifi fdaa925
create separate module for with hex
DSharifi 633b06e
move bounds to conts
DSharifi 9e78903
Delete crates/near-mpc-sdk/src/sign.rs
DSharifi 338609a
Update crates/contract/Cargo.toml
DSharifi 3d63bd0
Merge remote-tracking branch 'origin/main' into dsharifi/add-bounded-vec
DSharifi d196924
Merge branch 'dsharifi/add-bounded-vec' of github.com:near/mpc into d…
DSharifi a412077
just bounded vec
DSharifi ff05535
Merge remote-tracking branch 'origin/main' into just-bounded-vec
DSharifi f3fff6f
cargo fmt
DSharifi 4f8ef1f
fix doc tests
DSharifi a55c475
Merge remote-tracking branch 'origin/main' into just-bounded-vec
DSharifi c8dfdfe
rename into_vec
DSharifi fe3fb48
remove as_vec, we have as_slice
DSharifi ed0dd27
remove opt function, and impl mapping for all witnesses
DSharifi 1738eca
created the sdk crate with builder
DSharifi 74f89d0
added signing module
DSharifi 211c10c
added sign for the method name
DSharifi 3a90eae
make NotSet public
DSharifi c82139a
use sdk builder in sign_utils sandbox test
DSharifi 33e5c4f
integrate the sdk into the contract sandbox tests
DSharifi a7f451e
sort/shear
DSharifi e0474c5
remove clone for type with copy
DSharifi 7b44c5c
remove stale copy pasta comments
DSharifi f73856e
remove from implementation
DSharifi c9a4bfc
Merge remote-tracking branch 'origin/main' into dsharifi/make-sdk-crate
DSharifi d588938
move SignRequestArgs to interface crate
DSharifi ae84e11
remove serde unused dep
DSharifi 01d9eed
move import to top
DSharifi 1a891e6
rename to payload_v2
DSharifi cba6326
add comment to the bounds for payload sizes
DSharifi 3015e3b
Merge remote-tracking branch 'origin/main' into dsharifi/make-sdk-crate
DSharifi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,31 @@ | ||
| use bounded_collections::{BoundedVec, hex_serde}; | ||
| use serde::{Deserialize, Serialize}; | ||
|
|
||
| use crate::types::DomainId; | ||
|
|
||
| pub const ECDSA_PAYLOAD_SIZE_BYTES: usize = 32; | ||
|
|
||
| pub const EDDSA_PAYLOAD_SIZE_LOWER_BOUND_BYTES: usize = 32; | ||
| // Transaction signatures for Solana is over the whole transaction payload, | ||
| // not the transaction hash. The max size for a solana transaction is 1232 bytes, | ||
| // to fit in a single UDP packet, hence the 1232 byte upper bounds. | ||
| pub const EDDSA_PAYLOAD_SIZE_UPPER_BOUND_BYTES: usize = 1232; | ||
|
|
||
| #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] | ||
| pub struct SignRequestArgs { | ||
| pub path: String, | ||
| pub payload_v2: Payload, | ||
| pub domain_id: DomainId, | ||
| } | ||
|
|
||
| #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] | ||
| pub enum Payload { | ||
| Ecdsa( | ||
| #[serde(with = "hex_serde")] | ||
| BoundedVec<u8, ECDSA_PAYLOAD_SIZE_BYTES, ECDSA_PAYLOAD_SIZE_BYTES>, | ||
| ), | ||
| Eddsa( | ||
| #[serde(with = "hex_serde")] | ||
| BoundedVec<u8, EDDSA_PAYLOAD_SIZE_LOWER_BOUND_BYTES, EDDSA_PAYLOAD_SIZE_UPPER_BOUND_BYTES>, | ||
| ), | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 @@ | ||
| [package] | ||
| name = "near-mpc-sdk" | ||
| version.workspace = true | ||
| edition.workspace = true | ||
| license.workspace = true | ||
|
|
||
| [dependencies] | ||
| bounded-collections = { workspace = true } | ||
| contract-interface = { workspace = true } | ||
|
|
||
| [dev-dependencies] | ||
|
|
||
| [lints] | ||
| workspace = true |
This file contains hidden or 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,4 @@ | ||
| pub use bounded_collections; | ||
| pub use contract_interface; | ||
|
|
||
| pub mod sign; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.