separate list of emojis for wallet into ts and rs files, added display_pazzle

master
Niko 11 months ago
parent 9edfe806a5
commit 8cc441cb87
  1. 1
      Cargo.lock
  2. 1723
      ng-app/src/routes/Grid.svelte
  3. 1736
      ng-app/src/wallet_emojis.ts
  4. 3
      ng-wallet/Cargo.toml
  5. 1226
      ng-wallet/src/emojis.rs
  6. 30
      ng-wallet/src/lib.rs

1
Cargo.lock generated

@ -2535,6 +2535,7 @@ dependencies = [
"debug_print",
"getrandom 0.1.16",
"image",
"lazy_static",
"p2p-net",
"p2p-repo",
"rand 0.7.3",

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -26,4 +26,5 @@ safe-transmute = "0.11.2"
aes-gcm-siv = {version = "0.11.1", features = ["aes","heapless","getrandom","std"] }
base64-url = "2.0.0"
async-std = { version = "1.12.0", features = ["attributes","unstable"] }
web-time = "0.2.0"
web-time = "0.2.0"
lazy_static = "1.4.0"

File diff suppressed because it is too large Load Diff

@ -11,6 +11,8 @@
// extern crate slice_as_array;
#[macro_use]
extern crate p2p_net;
#[macro_use]
extern crate lazy_static;
use p2p_net::log;
@ -18,6 +20,8 @@ pub mod types;
pub mod bip39;
pub mod emojis;
use std::io::Cursor;
use crate::bip39::bip39_wordlist;
@ -261,13 +265,23 @@ pub fn display_mnemonic(mnemonic: &[u16; 12]) -> Vec<String> {
res
}
pub fn display_pazzle(pazzle: Vec<u8>) -> Vec<String> {
// let res: Vec<String> = pazzle
// .into_iter()
// .map(|i| String::from(bip39_wordlist[*i as usize]))
// .collect();
// res
unimplemented!();
use crate::emojis::{EMOJIS, EMOJI_CAT};
pub fn display_pazzle(pazzle: &Vec<u8>) -> Vec<String> {
let res: Vec<String> = pazzle
.into_iter()
.map(|i| {
let cat = i >> 4;
let idx = i & 15;
let cat_str = EMOJI_CAT[cat as usize];
String::from(format!(
"{}:{}",
cat_str,
EMOJIS.get(cat_str).unwrap()[idx as usize].code
))
})
.collect();
res
}
pub fn gen_shuffle_for_pazzle_opening(pazzle_length: u8) -> ShuffledPazzle {
@ -584,7 +598,7 @@ mod tests {
"wallet id: {:?}",
base64_url::encode(&res.wallet.id().slice())
);
log!("pazzle {:?}", res.pazzle);
log!("pazzle {:?}", display_pazzle(&res.pazzle));
log!("mnemonic {:?}", display_mnemonic(&res.mnemonic));
log!("pin {:?}", pin);

Loading…
Cancel
Save