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: create a simple Sign API example on top of the WS client #48

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk

# VScode settings
.vscode
7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,21 @@ license = "Apache-2.0"
[workspace]
members = [
"relay_client",
"relay_rpc"
"relay_rpc",
"sign_api"
]

[features]
default = ["full"]
full = ["client", "rpc"]
full = ["client", "rpc", "sign_api"]
client = ["dep:relay_client"]
rpc = ["dep:relay_rpc"]
sign_api = ["dep:sign_api"]

[dependencies]
relay_client = { path = "./relay_client", optional = true }
relay_rpc = { path = "./relay_rpc", optional = true }
sign_api = { path = "./sign_api", optional = true }

[dev-dependencies]
anyhow = "1"
Expand Down
41 changes: 41 additions & 0 deletions sign_api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[package]
name = "sign_api"
version = "0.1.0"
edition = "2021"

[dependencies]
base58 = "0.2"
base64 = "0.21"
base64-url = "2.0"
chacha20poly1305 = "0.10"
chrono = "0.4"
hex = "0.4"
hex-literal = "0.4"
hkdf = "0.12"
lazy_static = "1.4"
once_cell = "1.16"
paste = "1.0"
rand = "0.8"
regex = "1.10"
sha2 = "0.10"
serde = { version = "1.0", features = ["derive", "rc"] }
serde_json = "1.0"
thiserror = "1.0"
x25519-dalek = { version = "2.0", features = ["static_secrets"] }
url = "2.4"

[dev-dependencies]
# Serialization/Deserealization changes order of fields. Preserving order
# makes it easier to construct the unittests.
serde_json = { version = "1.0", features = ["preserve_order"] }

anyhow = "1"
clap = { version = "4.4", features = ["derive"] }
chrono = "0.4"
dashmap = "5.5"
relay_client = { path = "../relay_client" }
relay_rpc = { path = "../relay_rpc" }
tokio = { version = "1.22", features = ["full"] }

[[example]]
name = "session"
23 changes: 23 additions & 0 deletions sign_api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Rust Sign API SDK

This crate implements Sign API, described in:
https://specs.walletconnect.com/2.0/specs/clients/sign/

There is a simple Sign API client example built on top of the websocket client, which can be run as follows:
- In a browser, open: https://react-app.walletconnect.com/
- Click on "Goerli" and then "connect"
- In a new pop-up, click "New Pairing"
- Copy the Pairing URI
- In the terminal, cd _path/to/WalletConnectRust/sign_api_
- .../sign_api$ cargo run --example session "_copied URI_"
- DApp should now display the session window
- Click disconnect to terminate session and pairing

__Warning: this Rust Sign API SDK is community-maintained and may be lacking features and stability or security fixes that other versions of the Sign API SDK receive. We strongly recommend using the JavaScript or other Sign API SDKs instead.__

## Disclaimer

Please note that this crate is still under development, and thus:
- Is incomplete
- Might lack testing in places
- Being developed from a wallet perspective, and thus some DApp specific SDK details might have been overlooked
Loading