Skip to content

Commit 11539e9

Browse files
committed
feat: add shared SDK lib to SDK package
1 parent 15f5fa5 commit 11539e9

35 files changed

+12101
-17
lines changed

packages/sdk/lib/Cargo.lock

Lines changed: 6271 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/sdk/lib/Cargo.toml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
[package]
2+
name = "namada-sdk-wasm"
3+
authors = ["Heliax AG <hello@heliax.dev>"]
4+
version = "1.0.0"
5+
edition = "2021"
6+
repository = "https://github.com/anoma/namada-interface/"
7+
description = "Shared functionality from Namada protocol"
8+
license = "MIT"
9+
10+
[lib]
11+
crate-type = ["cdylib", "rlib"]
12+
13+
[features]
14+
default = []
15+
dev = []
16+
multicore = ["rayon", "wasm-bindgen-rayon", "namada_sdk/multicore"]
17+
nodejs = []
18+
web = []
19+
20+
[build-dependencies]
21+
namada_tx = { git = "https://github.com/anoma/namada", rev = "49a4a5d3260423df19ead14df82d18a51fa9b157" }
22+
23+
[dependencies]
24+
async-trait = {version = "0.1.51"}
25+
tiny-bip39 = "0.8.2"
26+
chrono = "0.4.22"
27+
getrandom = { version = "0.2.7", features = ["js"] }
28+
gloo-utils = { version = "0.1.5", features = ["serde"] }
29+
js-sys = "0.3.60"
30+
namada_sdk = { git = "https://github.com/anoma/namada", rev="49a4a5d3260423df19ead14df82d18a51fa9b157", default-features = false }
31+
rand = "0.8.5"
32+
rayon = { version = "1.5.3", optional = true }
33+
rexie = "0.5"
34+
serde = "^1.0.181"
35+
serde_json = "1.0"
36+
tendermint-config = "0.34.0"
37+
tokio = {version = "1.8.2", features = ["rt"]}
38+
thiserror = "^1"
39+
wasm-bindgen = "0.2.86"
40+
wasm-bindgen-futures = "0.4.33"
41+
wasm-bindgen-rayon = { version = "1.0", optional = true }
42+
console_error_panic_hook = "0.1.6"
43+
zeroize = "1.6.0"
44+
hex = "0.4.3"
45+
reqwest = "0.11.25"
46+
subtle-encoding = "0.5.1"
47+
48+
[dependencies.web-sys]
49+
version = "0.3.4"
50+
features = [
51+
'console',
52+
'Document',
53+
'Event',
54+
'EventTarget',
55+
'CustomEvent',
56+
'CustomEventInit',
57+
'Headers',
58+
'Request',
59+
'RequestInit',
60+
'RequestMode',
61+
'Response',
62+
'Window',
63+
'WorkerGlobalScope'
64+
]
65+
66+
[dev-dependencies]
67+
wasm-bindgen-test = "0.3.13"
68+
69+
# https://doc.rust-lang.org/cargo/reference/profiles.html
70+
[profile.release]
71+
lto = true
72+
73+
[profile.dev]
74+
opt-level = 3
75+
lto = true
76+
77+
# wasm-pack specific configuration
78+
[package.metadata.wasm-pack.profile.release]
79+
# https://docs.rs/wasm-opt/latest/wasm_opt/
80+
wasm-opt = ['-O4']
81+
82+
[package.metadata.wasm-pack.profile.dev]
83+
wasm-opt = false
84+
85+
[package.metadata.wasm-pack.profile.dev.wasm-bindgen]
86+
omit-default-module-path = true
87+
# We set it to false as it checks if return type from setTimout is a number which is not true in the nodejs environment
88+
debug-js-glue = false
89+
90+
[package.metadata.wasm-pack.profile.release.wasm-bindgen]
91+
omit-default-module-path = true

packages/sdk/lib/LICENSE_MIT

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Copyright (c) 2018 Heliax Dev <info@heliax.dev>
2+
3+
Permission is hereby granted, free of charge, to any
4+
person obtaining a copy of this software and associated
5+
documentation files (the "Software"), to deal in the
6+
Software without restriction, including without
7+
limitation the rights to use, copy, modify, merge,
8+
publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software
10+
is furnished to do so, subject to the following
11+
conditions:
12+
13+
The above copyright notice and this permission notice
14+
shall be included in all copies or substantial portions
15+
of the Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
18+
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
19+
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
20+
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
21+
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
24+
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25+
DEALINGS IN THE SOFTWARE.

packages/sdk/lib/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# shared lib
2+
3+
Rust library for wrapping Namada types and functionality and compiling to wasm, as used by Namada Interface and the wallet extension.
4+
5+
## Usage
6+
7+
```bash
8+
# Install wasm-bindgen-cli
9+
cargo install -f wasm-bindgen-cli
10+
11+
# Build wasm
12+
../scripts/build.sh
13+
14+
# Build wasm to a NodeJS target (for testing)
15+
../scripts/build-test.sh
16+
```
17+
18+
## Testing
19+
20+
```bash
21+
cargo test
22+
23+
# Test wasm-specific features
24+
wasm-pack test --node
25+
```

packages/sdk/lib/rust-toolchain.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[toolchain]
2+
channel = "nightly-2024-09-08"
3+
components = ["rustc", "cargo", "rust-std", "rust-docs", "rls", "rust-src", "rust-analysis"]
4+
targets = ['wasm32-unknown-unknown']

packages/sdk/lib/src/lib.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//! # shared
2+
//!
3+
//! A library of functions to integrate shared functionality from the Namada ecosystem
4+
5+
pub mod query;
6+
pub mod rpc_client;
7+
pub mod sdk;
8+
pub mod types;
9+
mod utils;
10+
11+
#[cfg(feature = "multicore")]
12+
pub use wasm_bindgen_rayon::init_thread_pool;
13+
14+
// Empty function for non-multicore builds
15+
// Simplifies imports in js code
16+
#[cfg(not(feature = "multicore"))]
17+
use wasm_bindgen::prelude::wasm_bindgen;
18+
19+
#[cfg(not(feature = "multicore"))]
20+
#[allow(non_snake_case)]
21+
#[wasm_bindgen]
22+
pub async fn initThreadPool(_threads: u8) {}

0 commit comments

Comments
 (0)