remove commented code

This commit is contained in:
Gala
2023-12-14 13:42:20 +01:00
committed by Jędrzej Stuczyński
parent ea6f009c01
commit d5cc31b7f0
4 changed files with 18 additions and 38 deletions
+3
View File
@@ -18,6 +18,9 @@
"clients/validator",
"sdk/typescript/packages/**",
"sdk/typescript/examples/**",
"sdk/typescript/codegen/**",
"sdk/typescript/packages/**",
"sdk/typescript/examples/**",
"sdk/typescript/codegen/**"
],
"scripts": {
@@ -5,6 +5,7 @@ async function main() {
const mnemonic = document.getElementById('mnemonic') as HTMLInputElement;
const coin = document.getElementById('coin') as HTMLInputElement;
const button = document.getElementById('button') as HTMLButtonElement;
const client = await createNymCredentialsClient({ isSandbox: true }); // options: {isSandbox?: boolean; networkDetails?: {}}
const generateCredential = async () => {
@@ -1,14 +1,6 @@
import * as Comlink from 'comlink';
import InlineWasmWebWorker from 'web-worker:./worker';
import {
EventKinds,
CredentialClientOpts,
INymCredentialClientWebWorker,
NymCredentialsClient,
} from './types';
const mnemonic =
'summer under connect sadness unveil region charge feed tank grant drift mass side ramp winter fit verb rare huge high garment moment achieve since';
import { EventKinds, CredentialClientOpts, INymCredentialClientWebWorker, NymCredentialsClient } from './types';
export const createNymCredentialsClient = async (options?: CredentialClientOpts): Promise<NymCredentialsClient> => {
// eslint-disable-next-line @typescript-eslint/no-use-before-define
@@ -18,28 +10,6 @@ export const createNymCredentialsClient = async (options?: CredentialClientOpts)
const comlink = Comlink.wrap<INymCredentialClientWebWorker>(worker);
return { comlink };
// pass the client interop and subscription manage back to the caller
// return {
// init(mnemonic) { // TODO: maybe? could also be passed in acquireCred
// comlink.setMnemonic(mnemonic);
// },
// async acquireCredential(coin, mnemonic, options) {
// // TODO: wire up promise and event handlers
// const handler = (msg: any) => {
// if (msg.data && msg.data.kind) {
// worker.removeEventListener('message', handler);
// return msg.data.credential; // return path in promise
// }
// worker.removeEventListener('message', handler);
// };
// worker.addEventListener('message', handler);
// // fire message
// comlink.acquireCredential(coin);
// },
// };
};
/**
@@ -8,9 +8,9 @@ import * as Comlink from 'comlink';
// @ts-ignore
// eslint-disable-next-line import/no-extraneous-dependencies
import wasmBytes from '@nymproject/nym-credential-client-wasm/nym_credential_client_wasm_bg.wasm';
import type { INymCredentialClientWebWorker, CredentialClientOpts } from './types';
import { EventKinds, LoadedEvent } from './types';
import init, { acquireCredential } from '@nymproject/nym-credential-client-wasm/nym_credential_client_wasm';
import type { INymCredentialClientWebWorker, CredentialClientOpts, LoadedEvent } from './types';
import { EventKinds } from './types';
/**
* Helper method to send typed messages.
@@ -19,12 +19,19 @@ import init, { acquireCredential } from '@nymproject/nym-credential-client-wasm/
// eslint-disable-next-line no-restricted-globals
const postMessageWithType = <E>(event: E) => self.postMessage(event);
console.log('[Nym WASM client] Starting Nym WASM web worker...');
console.log('[Nym WASM client for Credentials] Starting Nym WASM web worker...');
// load WASM binary
async function main() {
const importResult = await init(wasmBytes());
importResult.set_panic_hook();
// rollup with provide a function to get the mixFetch WASM bytes
const bytes = await wasmBytes();
// load rust WASM package
const wasmPackage = await init(bytes);
console.log('Loaded RUST WASM');
wasmPackage.set_panic_hook();
const webWorker: INymCredentialClientWebWorker = {
async acquireCredential(coin: string, mnemonic: string, opts: CredentialClientOpts) {
@@ -40,5 +47,4 @@ async function main() {
postMessageWithType<LoadedEvent>({ kind: EventKinds.Loaded, args: { loaded: true } });
}
main();
main().catch((e: any) => console.error('Unhandled exception in credential worker', e));;