-
Notifications
You must be signed in to change notification settings - Fork 16
/
wasm.js
21 lines (16 loc) · 839 Bytes
/
wasm.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// ISC, Copyright 2017-2018 Jaco Greeff
// @flow
import type { ConfigType } from '@polkadot/client/types';
import type { DbInterface } from '@polkadot/client-db/types';
import type { WasmExtraImports } from './types';
const createRuntime = require('@polkadot/client-wasm-runtime');
const { createImports, createInstance, createMemory, createModule, createTable } = require('./create');
module.exports = function wasm ({ wasm: { memoryInitial, memoryMaximum } }: ConfigType, db: DbInterface, bytecode: Uint8Array, imports?: WasmExtraImports = {}): WebAssemblyInstance$Exports {
const memory = createMemory(memoryInitial, memoryMaximum);
const table = createTable();
const runtime = createRuntime(memory, db);
return createInstance(
createModule(bytecode),
createImports(memory, table, runtime, imports)
).exports;
};