mirror of
https://github.com/RoboSats/robo-identities.git
synced 2026-01-05 06:35:27 +00:00
Rename wasm crate and fix integration tests
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
members = [
|
||||
"robohash",
|
||||
"robonames",
|
||||
"wasm"
|
||||
"robo-identities-wasm"
|
||||
]
|
||||
|
||||
[profile.release]
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "robo-identities"
|
||||
name = "robo-identities-wasm"
|
||||
version = "0.1.0"
|
||||
authors = ["Reckless_Satoshi <reckless.satoshi@protonmail.com>"]
|
||||
edition = "2021"
|
||||
32
robo-identities-wasm/src/lib.rs
Normal file
32
robo-identities-wasm/src/lib.rs
Normal file
@ -0,0 +1,32 @@
|
||||
mod utils;
|
||||
|
||||
use robohash::RoboHashBuilder;
|
||||
use robonames::generate_nickname;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen]
|
||||
extern "C" {
|
||||
pub fn alert(s: &str);
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn generate_robohash(initial_string: &str) -> String {
|
||||
let size = 256;
|
||||
|
||||
// build
|
||||
let robohash = RoboHashBuilder::new(initial_string)
|
||||
.with_background(&true)
|
||||
.with_size(size, size)
|
||||
.build()
|
||||
.expect("Should build RoboHash generator");
|
||||
|
||||
match robohash.assemble_base64() {
|
||||
Ok(base64_string) => base64_string,
|
||||
Err(_) => "".to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn generate_roboname(initial_string: &str) -> String {
|
||||
generate_nickname(initial_string).to_string()
|
||||
}
|
||||
25
robo-identities-wasm/tests/web.rs
Normal file
25
robo-identities-wasm/tests/web.rs
Normal file
File diff suppressed because one or more lines are too long
@ -1,24 +0,0 @@
|
||||
mod utils;
|
||||
|
||||
use robohash::RoboHashBuilder;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen]
|
||||
extern "C" {
|
||||
pub fn alert(s: &str);
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn generate_robohash(_hash: &str) -> String {
|
||||
let initial_string = "reckless";
|
||||
let size = 256;
|
||||
|
||||
// build
|
||||
let robo_hash = RoboHashBuilder::new(initial_string)
|
||||
.with_background(&true)
|
||||
.with_size(size, size)
|
||||
.build()
|
||||
.unwrap();
|
||||
|
||||
robo_hash.assemble_base64().unwrap()
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user