fix and more examples

pull/31/head^2
Niko PLP 4 months ago
parent fb0c161f7d
commit b06b31916e
  1. 7
      nextgraph/src/local_broker.rs
  2. 12
      ng-app/src/routes/WalletInfo.svelte
  3. 8
      ng-app/src/routes/WalletLogin.svelte
  4. 5
      ng-net/src/actor.rs

@ -1613,23 +1613,20 @@ pub async fn wallet_export_get_textcode(session_id: u64) -> Result<String, NgErr
match broker.wallets.get(&wallet_name) {
None => Err(NgError::WalletNotFound),
Some(lws) => {
let broker = lws.bootstrap.servers().first().unwrap();
//let broker = lws.bootstrap.servers().first().unwrap();
let wallet = &lws.wallet;
let secret_key = SymKey::random();
let rendezvous = SymKey::random();
let code = NgQRCode::V0(NgQRCodeV0 {
broker: broker.clone(),
broker: NEXTGRAPH_EU.clone(),
rendezvous: rendezvous.clone(),
secret_key: secret_key.clone(),
is_rendezvous: false
});
let code_string = code.to_code();
let mut wallet_ser = serde_bare::to_vec(wallet)?;
encrypt_in_place(&mut wallet_ser,*secret_key.slice(), [0;12]);
let exported_wallet = ExportedWallet(serde_bytes::ByteBuf::from(wallet_ser));
match session.verifier.client_request::<WalletPutExport, ()>(WalletPutExport::V0(WalletPutExportV0{wallet:exported_wallet, rendezvous_id:rendezvous, is_rendezvous:false})).await {
Err(e) => Err(e),
Ok(SoS::Stream(_)) => Err(NgError::InvalidResponse),

@ -53,6 +53,7 @@
await scrollToTop();
}
text_code = await ng.wallet_export_get_textcode($active_session.session_id);
qr_code = await ng.wallet_export_get_qrcode($active_session.session_id, 250);
});
let downloading = false;
@ -80,11 +81,16 @@
}
let text_code;
let qr_code;
let wallet_remove_modal_open = false;
async function remove_wallet_clicked() {
//wallet_remove_modal_open = true;
await ng.wallet_export_rendezvous($active_session.session_id, "AABAOAAAAHNb4y7hdWADqFWDgER3J0xvD3K5D9pZ1wd7Bja4c9cWAGLFmUlRYG3D2ULZKhHltZY9IhE2wzBbOqRL-PLw7ZiKAJPyRr_TGnHd-9Uh2Zsv9ahfOWD6tB3q8tVPUS54qdrdAQ");
try {
await ng.wallet_export_rendezvous($active_session.session_id, "AABAOAAAAHNb4y7hdWADqFWDgER3J0xvD3K5D9pZ1wd7Bja4c9cWAGpnQYDjun-jOFI8XookNLWKfgpQIkDS21VruUzizWahAH6fStLoA0kBMVR5ZMPHMv7RpQITUGZmZsjlWjnxCRZBAQ");
} catch (e) {
console.error(e);
}
}
const close_modal = () => {
@ -215,8 +221,12 @@
<li class="break-all">
{text_code}
{#if qr_code}
{@html qr_code}
{/if}
</li>
<!-- Remove Wallet -->
<li
tabindex="0"

@ -379,6 +379,14 @@
</button>
</a>
<button
on:click={async () => {
try {
wallet = await ng.wallet_import_from_code("AABAOAAAAHNb4y7hdWADqFWDgER3J0xvD3K5D9pZ1wd7Bja4c9cWAOFNpmUIZOFRro0UIpZWr5Ah8U7PlRFe1GFZSKuIextFAA8A45zZUJmUPhfdBrcho1vYPfgda0BAgIT1qjzgEkBQAA");
importing = true;
} catch (e) {
error = e;
}
}}
style="min-width: 250px;justify-content: left;"
class="mt-1 text-primary-700 bg-primary-100 hover:bg-primary-100/90 focus:ring-4 focus:ring-primary-700/50 font-medium rounded-lg text-lg px-5 py-2.5 text-center inline-flex items-center dark:focus:ring-primary-100/55 mb-2"
>

@ -58,6 +58,7 @@ pub(crate) struct Actor<
//initiator: bool,
}
#[derive(Debug)]
pub enum SoS<B> {
Single(B),
Stream(Receiver<B>),
@ -185,6 +186,10 @@ impl<
}
fsm.lock().await.remove_actor(self.id).await;
let server_error: Result<ServerError, NgError> = (&msg).try_into();
//log_debug!("server_error {:?}", server_error);
if server_error.is_ok() {
return Err(NgError::ServerError(server_error.unwrap()));
}
let response: B = match msg.try_into() {
Ok(b) => b,
Err(ProtocolError::ServerError) => {

Loading…
Cancel
Save