planetarium / lib9c-wasm

The experimental project to port Lib9c into JavaScript environment through WASM. Build your Nine Chronicles network transaction in your local at once.
https://planetarium.github.io/lib9c-wasm/
GNU General Public License v3.0
5 stars 2 forks source link

How to share global scope dotnet wasm instance throughout library? #18

Open Akamig opened 1 year ago

Akamig commented 1 year ago

There's problem with scope of initialized dotnet runtime in library, It's really vague problem.

TL;DR, this is the code we use when initialize dotnet instance.

const { setModuleImports, getAssemblyExports, getConfig } =
  await dotnet.create();
const config = getConfig();
const Lib9c = await getAssemblyExports(config.mainAssemblyName!);

This last const Lib9c contains all JS-interopable exported function calls from C#, ([JSExport]). As all example code provided from microsoft using this method, it's very hard to call this instance of constant Lib9c from other library when pre-initialized.

Also, since this resulting Lib9c method doesn't provide function parameter type abstract at compile time, it's making even harder to call from action generator.