Skip to content

Commit

Permalink
Add a barebone WASM crate
Browse files Browse the repository at this point in the history
  • Loading branch information
andiflabs committed Nov 11, 2024
1 parent c0468f0 commit 965e008
Show file tree
Hide file tree
Showing 8 changed files with 136 additions and 16 deletions.
36 changes: 24 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ members = [
"benchmarks",
"ironfish-rust",
"ironfish-rust-nodejs",
"ironfish-rust-wasm",
"ironfish-zkp",
]

Expand Down
19 changes: 19 additions & 0 deletions ironfish-rust-wasm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "ironfish-wasm"
version = "0.1.0"
license = "MPL-2.0"

authors.workspace = true
edition.workspace = true
homepage.workspace = true
repository.workspace = true

publish = false

[lib]
crate-type = ["cdylib"]

[dependencies]
getrandom = { version = "0.2.8", features = ["js"] } # need to explicitly enable the `js` feature in order to run in a browser
ironfish = { version = "0.3.0", path = "../ironfish-rust" }
wasm-bindgen = "0.2.95"
26 changes: 26 additions & 0 deletions ironfish-rust-wasm/src/errors.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use wasm_bindgen::prelude::*;

#[wasm_bindgen]
#[derive(Debug)]
pub struct IronfishError(ironfish::errors::IronfishError);

impl<T> From<T> for IronfishError
where
ironfish::errors::IronfishError: From<T>,
{
fn from(e: T) -> Self {
Self(ironfish::errors::IronfishError::from(e))
}
}

impl AsRef<ironfish::errors::IronfishError> for IronfishError {
fn as_ref(&self) -> &ironfish::errors::IronfishError {
&self.0
}
}

impl AsRef<ironfish::errors::IronfishErrorKind> for IronfishError {
fn as_ref(&self) -> &ironfish::errors::IronfishErrorKind {
&self.0.kind
}
}
12 changes: 12 additions & 0 deletions ironfish-rust-wasm/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#![warn(clippy::dbg_macro)]
#![warn(clippy::print_stderr)]
#![warn(clippy::print_stdout)]
#![warn(unreachable_pub)]
#![warn(unused_crate_dependencies)]
#![warn(unused_macro_rules)]
#![warn(unused_qualifications)]

// The getrandom dependency exists only to ensure that the `js` feature is enabled
use getrandom as _;

pub mod errors;
30 changes: 30 additions & 0 deletions supply-chain/audits.toml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,36 @@ who = "Andrea <[email protected]>"
criteria = "safe-to-deploy"
version = "1.0.0"

[[audits.wasm-bindgen]]
who = "andrea <[email protected]>"
criteria = "safe-to-deploy"
delta = "0.2.84 -> 0.2.95"
notes = "New features and removed code; some new unsafe blocks and they all look benign"

[[audits.wasm-bindgen-backend]]
who = "andrea <[email protected]>"
criteria = "safe-to-deploy"
delta = "0.2.84 -> 0.2.95"
notes = "New features and bug fixes; there's are new/changed unsafe blocks and they all look benign"

[[audits.wasm-bindgen-macro]]
who = "andrea <[email protected]>"
criteria = "safe-to-deploy"
delta = "0.2.84 -> 0.2.95"
notes = "Minor changes and a lot of removed code"

[[audits.wasm-bindgen-macro-support]]
who = "andrea <[email protected]>"
criteria = "safe-to-deploy"
delta = "0.2.92 -> 0.2.95"
notes = "New features and bug fixes; no new unsafe code or system calls introduced"

[[audits.wasm-bindgen-shared]]
who = "andrea <[email protected]>"
criteria = "safe-to-deploy"
delta = "0.2.92 -> 0.2.95"
notes = "Only minor changes; no new unsafe code or system calls introduced"

[[trusted.reddsa]]
criteria = "safe-to-deploy"
user-id = 6289 # Jack Grigg (str4d)
Expand Down
4 changes: 0 additions & 4 deletions supply-chain/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -776,10 +776,6 @@ criteria = "safe-to-deploy"
version = "0.2.84"
criteria = "safe-to-deploy"

[[exemptions.wasm-bindgen-macro-support]]
version = "0.2.84"
criteria = "safe-to-deploy"

[[exemptions.web-sys]]
version = "0.3.61"
criteria = "safe-to-deploy"
Expand Down
24 changes: 24 additions & 0 deletions supply-chain/imports.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1297,9 +1297,33 @@ delta = "0.4.1 -> 0.5.0"
notes = "I checked correctness of to_blocks which uses unsafe code in a safe function."
aggregated-from = "https://raw.githubusercontent.com/zcash/zcash/master/qa/supply-chain/audits.toml"

[[audits.zcash.audits.wasm-bindgen-macro-support]]
who = "Daira-Emma Hopwood <[email protected]>"
criteria = "safe-to-deploy"
version = "0.2.92"
aggregated-from = "https://raw.githubusercontent.com/zcash/zcash/master/qa/supply-chain/audits.toml"

[[audits.zcash.audits.wasm-bindgen-shared]]
who = "Jack Grigg <[email protected]>"
criteria = "safe-to-deploy"
delta = "0.2.83 -> 0.2.84"
notes = "Bumps the schema version to add `linked_modules`."
aggregated-from = "https://raw.githubusercontent.com/zcash/zcash/master/qa/supply-chain/audits.toml"

[[audits.zcash.audits.wasm-bindgen-shared]]
who = "Jack Grigg <[email protected]>"
criteria = "safe-to-deploy"
delta = "0.2.84 -> 0.2.87"
aggregated-from = "https://raw.githubusercontent.com/zcash/zcash/master/qa/supply-chain/audits.toml"

[[audits.zcash.audits.wasm-bindgen-shared]]
who = "Jack Grigg <[email protected]>"
criteria = "safe-to-deploy"
delta = "0.2.87 -> 0.2.89"
aggregated-from = "https://raw.githubusercontent.com/zcash/zcash/master/qa/supply-chain/audits.toml"

[[audits.zcash.audits.wasm-bindgen-shared]]
who = "Daira-Emma Hopwood <[email protected]>"
criteria = "safe-to-deploy"
delta = "0.2.89 -> 0.2.92"
aggregated-from = "https://raw.githubusercontent.com/zcash/zcash/master/qa/supply-chain/audits.toml"

0 comments on commit 965e008

Please sign in to comment.