add build script of wasm

This commit is contained in:
zhl 2023-01-10 14:40:53 +08:00
parent a855f7f5ba
commit 7e4bc1a637
4 changed files with 6 additions and 0 deletions

1
Cargo.lock generated
View File

@ -375,6 +375,7 @@ dependencies = [
"serde_json",
"shamir_secret_sharing",
"tiny-keccak",
"wasm-bindgen",
]
[[package]]

View File

@ -24,4 +24,6 @@ shamir_secret_sharing = "0.1.1"
tiny-keccak = "1.5"
primitive-types = "0.12.1"
getrandom = { version = "0.2.7", features = ["js"]}
[target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-bindgen = "0.2.83"

1
scripts/wasm_build.sh Normal file
View File

@ -0,0 +1 @@
AR=/opt/homebrew/opt/llvm/bin/llvm-ar CC=/opt/homebrew/opt/llvm/bin/clang wasm-pack build --target web

View File

@ -7,6 +7,7 @@
use std::ffi::{CStr, CString};
use std::os::raw::c_char;
use wasm_bindgen::prelude::*;
mod wallet;
use wallet_impl::Wallet;
@ -112,6 +113,7 @@ pub unsafe extern "C" fn free_cwallet(cw: CWallet) {
}
#[no_mangle]
#[wasm_bindgen]
pub unsafe extern "C" fn get_address(
msg_key: *const c_char,
master_key: *const c_char,