using webworker on web app for wallet opening

Niko PLP 1 year ago
parent a84501c245
commit dcd76e3455
  1. BIN
      ng-app/dist-file.tar.gz
  2. 22
      ng-app/src/lib/Login.svelte
  3. 21
      ng-app/src/worker.js
  4. 12
      ng-app/vite.config.ts
  5. 4
      ngaccount/web/src/routes/Create.svelte

Binary file not shown.

@ -118,6 +118,7 @@
// open the wallet // open the wallet
try { try {
if (tauri_platform) {
let secret_wallet = await ng.wallet_open_wallet_with_pazzle( let secret_wallet = await ng.wallet_open_wallet_with_pazzle(
wallet, wallet,
pazzle, pazzle,
@ -128,6 +129,27 @@
wallet: secret_wallet, wallet: secret_wallet,
id: secret_wallet.V0.wallet_id, id: secret_wallet.V0.wallet_id,
}); });
} else {
let worker_file = await import("../worker.js?worker");
const myWorker = new worker_file.default();
myWorker.postMessage({ wallet, pazzle, pin_code });
myWorker.onmessage = (msg) => {
//console.log("Message received from worker", msg.data);
if (msg.data.success) {
step = "end";
dispatch("opened", {
wallet: msg.data.success,
id: msg.data.success.V0.wallet_id,
});
} else {
console.error(msg.data.error);
error = msg.data.error;
step = "end";
dispatch("error", { error: msg.data.error });
}
};
}
} catch (e) { } catch (e) {
console.error(e); console.error(e);
error = e; error = e;

@ -0,0 +1,21 @@
import {
default as ng,
} from "./api";
onmessage = (e) => {
//console.log("Message received by worker", e.data);
(async function() {
try {
let secret_wallet = await ng.wallet_open_wallet_with_pazzle(
e.data.wallet,
e.data.pazzle,
e.data.pin_code
);
postMessage({success:secret_wallet});
} catch (e) {
postMessage({error:e});
}
})();
};

@ -11,6 +11,13 @@ import topLevelAwait from "vite-plugin-top-level-await";
export default defineConfig(async () => { export default defineConfig(async () => {
const host = await internalIpV4() const host = await internalIpV4()
const config = { const config = {
worker: {
format: 'es',
plugins : [
wasm(),
topLevelAwait(),
]
},
plugins: [ plugins: [
wasm(), wasm(),
topLevelAwait(), topLevelAwait(),
@ -71,6 +78,9 @@ export default defineConfig(async () => {
sourcemap: !!process.env.TAURI_DEBUG, sourcemap: !!process.env.TAURI_DEBUG,
} }
} }
if (process.env.NG_APP_FILE) config.plugins.push(viteSingleFile()); if (process.env.NG_APP_FILE) {
config.plugins.push(viteSingleFile());
config.worker.plugins.push(viteSingleFile());
}
return config return config
}) })

@ -180,8 +180,8 @@
<div class=" max-w-6xl lg:px-8 mx-auto px-4"> <div class=" max-w-6xl lg:px-8 mx-auto px-4">
<p class="max-w-xl md:mx-auto lg:max-w-2xl"> <p class="max-w-xl md:mx-auto lg:max-w-2xl">
You would like to choose <b>{domain}</b> as your Broker Service You would like to choose <b>{domain}</b> as your Broker Service
Provider.<br />Please read carefully the Terms of Service here Provider.<br />Please read carefully the Terms of Service below,
below, before accepting them. before accepting them.
</p> </p>
</div> </div>
{/if} {/if}

Loading…
Cancel
Save