@spirobel/monero-wallet-api 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -0
- package/dist/api.d.ts +55 -0
- package/dist/api.js +103 -0
- package/dist/cli.js +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +23 -0
- package/dist/node-interaction/binaryEndpoints.d.ts +60 -0
- package/dist/node-interaction/binaryEndpoints.js +109 -0
- package/dist/node-interaction/jsonEndpoints.d.ts +281 -0
- package/dist/node-interaction/jsonEndpoints.js +82 -0
- package/dist/wasi.d.ts +26 -0
- package/dist/wasi.js +174 -0
- package/dist/wasm-processing/wasi.d.ts +26 -0
- package/dist/wasm-processing/wasi.js +174 -0
- package/dist/wasm-processing/wasmFile.d.ts +1 -0
- package/dist/wasm-processing/wasmFile.js +3 -0
- package/dist/wasm-processing/wasmProcessor.d.ts +78 -0
- package/dist/wasm-processing/wasmProcessor.js +116 -0
- package/dist/wasmFile.d.ts +1 -0
- package/dist/wasmFile.js +8 -0
- package/package.json +30 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import * as crypto from "crypto";
|
|
2
|
+
//vendored from https://github.com/qrdate/tinywasi/blob/main/src/TinyWASI.ts
|
|
3
|
+
export class TinyWASI {
|
|
4
|
+
instance = undefined;
|
|
5
|
+
WASI_ERRNO_SUCCESS = 0;
|
|
6
|
+
WASI_ERRNO_BADF = 8;
|
|
7
|
+
WASI_ERRNO_NOSYS = 52;
|
|
8
|
+
WASI_ERRNO_INVAL = 28;
|
|
9
|
+
WASI_FILETYPE_CHARACTER_DEVICE = 2;
|
|
10
|
+
WASI_RIGHTS_FD_SYNC = 1 << 4;
|
|
11
|
+
WASI_RIGHTS_FD_WRITE = 1 << 6;
|
|
12
|
+
WASI_RIGHTS_FD_FILESTAT_GET = 1 << 21;
|
|
13
|
+
WASI_FDFLAGS_APPEND = 1 << 0;
|
|
14
|
+
nameSpaces = {
|
|
15
|
+
wasi_snapshot_preview1: {
|
|
16
|
+
args_get: undefined, // ((param i32 i32) (result i32))
|
|
17
|
+
args_sizes_get: undefined, // ((param i32 i32) (result i32))
|
|
18
|
+
clock_res_get: this.clock_res_get, // ((param i32 i32) (result i32))
|
|
19
|
+
clock_time_get: this.clock_time_get, // ((param i32 i64 i32) (result i32))
|
|
20
|
+
environ_get: undefined, // ((param i32 i32) (result i32))
|
|
21
|
+
environ_sizes_get: this.environ_sizes_get, // ((param i32 i32) (result i32))
|
|
22
|
+
fd_advise: undefined, // ((param i32 i64 i64 i32) (result i32))
|
|
23
|
+
fd_allocate: undefined, // ((param i32 i64 i64) (result i32))
|
|
24
|
+
fd_close: undefined, // ((param i32) (result i32))
|
|
25
|
+
fd_datasync: undefined, // ((param i32) (result i32))
|
|
26
|
+
fd_fdstat_get: this.fd_fdstat_get, // ((param i32 i32) (result i32))
|
|
27
|
+
fd_fdstat_set_flags: undefined, // ((param i32 i32) (result i32))
|
|
28
|
+
fd_fdstat_set_rights: undefined, // ((param i32 i64 i64) (result i32))
|
|
29
|
+
fd_filestat_get: undefined, // ((param i32 i32) (result i32))
|
|
30
|
+
fd_filestat_set_size: undefined, // ((param i32 i64) (result i32))
|
|
31
|
+
fd_filestat_set_times: undefined, // ((param i32 i64 i64 i32) (result i32))
|
|
32
|
+
fd_pread: undefined, // ((param i32 i32 i32 i64 i32) (result i32))
|
|
33
|
+
fd_prestat_dir_name: undefined, // ((param i32 i32 i32) (result i32))
|
|
34
|
+
fd_prestat_get: undefined, // ((param i32 i32) (result i32))
|
|
35
|
+
fd_pwrite: undefined, // ((param i32 i32 i32 i64 i32) (result i32))
|
|
36
|
+
fd_read: undefined, // ((param i32 i32 i32 i32) (result i32))
|
|
37
|
+
fd_readdir: undefined, // ((param i32 i32 i32 i64 i32) (result i32))
|
|
38
|
+
fd_renumber: undefined, // ((param i32 i32) (result i32))
|
|
39
|
+
fd_seek: undefined, // ((param i32 i64 i32 i32) (result i32))
|
|
40
|
+
fd_sync: undefined, // ((param i32) (result i32))
|
|
41
|
+
fd_tell: undefined, // ((param i32 i32) (result i32))
|
|
42
|
+
fd_write: this.fd_write, // ((param i32 i32 i32 i32) (result i32))
|
|
43
|
+
path_create_directory: undefined, // ((param i32 i32 i32) (result i32))
|
|
44
|
+
path_filestat_get: undefined, // ((param i32 i32 i32 i32 i32) (result i32))
|
|
45
|
+
path_filestat_set_times: undefined, // ((param i32 i32 i32 i32 i64 i64 i32) (result i32))
|
|
46
|
+
path_link: undefined, // ((param i32 i32 i32 i32 i32 i32 i32) (result i32))
|
|
47
|
+
path_open: undefined, // ((param i32 i32 i32 i32 i32 i64 i64 i32 i32) (result i32))
|
|
48
|
+
path_readlink: undefined, // ((param i32 i32 i32 i32 i32 i32) (result i32))
|
|
49
|
+
path_remove_directory: undefined, // ((param i32 i32 i32) (result i32))
|
|
50
|
+
path_rename: undefined, // ((param i32 i32 i32 i32 i32 i32) (result i32))
|
|
51
|
+
path_symlink: undefined, // ((param i32 i32 i32 i32 i32) (result i32))
|
|
52
|
+
path_unlink_file: undefined, // ((param i32 i32 i32) (result i32))
|
|
53
|
+
poll_oneoff: undefined, // ((param i32 i32 i32 i32) (result i32))
|
|
54
|
+
proc_exit: undefined, // ((param i32))
|
|
55
|
+
proc_raise: undefined, // ((param i32) (result i32))
|
|
56
|
+
random_get: this.random_get, // ((param i32 i32) (result i32))
|
|
57
|
+
sched_yield: undefined, // ((result i32))
|
|
58
|
+
sock_recv: undefined, // ((param i32 i32 i32 i32 i32 i32) (result i32))
|
|
59
|
+
sock_send: undefined, // ((param i32 i32 i32 i32 i32) (result i32))
|
|
60
|
+
sock_shutdown: undefined, // ((param i32 i32) (result i32))
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
constructor(trace) {
|
|
64
|
+
for (const ns of Object.keys(this.nameSpaces)) {
|
|
65
|
+
const nameSpace = this.nameSpaces[ns];
|
|
66
|
+
for (const fn of Object.keys(nameSpace)) {
|
|
67
|
+
let func = nameSpace[fn] || this.nosys(fn);
|
|
68
|
+
func = func.bind(this);
|
|
69
|
+
if (trace)
|
|
70
|
+
func = this.trace(fn, func).bind(this);
|
|
71
|
+
nameSpace[fn] = func;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
initialize(instance) {
|
|
76
|
+
this.instance = instance;
|
|
77
|
+
}
|
|
78
|
+
get imports() {
|
|
79
|
+
return this.nameSpaces;
|
|
80
|
+
}
|
|
81
|
+
getMemory() {
|
|
82
|
+
if (this.instance)
|
|
83
|
+
return this.instance.exports.memory;
|
|
84
|
+
else
|
|
85
|
+
throw new Error("Attempt to access instance before initialisation!");
|
|
86
|
+
}
|
|
87
|
+
getDataView() {
|
|
88
|
+
if (this.instance)
|
|
89
|
+
return new DataView(this.instance.exports.memory.buffer);
|
|
90
|
+
else
|
|
91
|
+
throw new Error("Attempt to access instance before initialisation!");
|
|
92
|
+
}
|
|
93
|
+
trace(name, origFunc) {
|
|
94
|
+
return (...args) => {
|
|
95
|
+
const result = origFunc(...args);
|
|
96
|
+
console.log(`Trace: ${name}(${args.toString()}) -> ${result}`);
|
|
97
|
+
return result;
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
nosys(name) {
|
|
101
|
+
return (...args) => {
|
|
102
|
+
console.error(`Unimplemented call to ${name}(${args.toString()})`);
|
|
103
|
+
return this.WASI_ERRNO_NOSYS;
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
clock_res_get(id, resOut) {
|
|
107
|
+
if (id !== 0)
|
|
108
|
+
return this.WASI_ERRNO_INVAL;
|
|
109
|
+
const view = this.getDataView();
|
|
110
|
+
view.setUint32(resOut, 1000000.0 % 0x100000000, true);
|
|
111
|
+
view.setUint32(resOut + 4, 1000000.0 / 0x100000000, true);
|
|
112
|
+
return this.WASI_ERRNO_SUCCESS;
|
|
113
|
+
}
|
|
114
|
+
clock_time_get(id, precision, timeOut) {
|
|
115
|
+
if (id !== 0)
|
|
116
|
+
return this.WASI_ERRNO_INVAL;
|
|
117
|
+
const view = this.getDataView();
|
|
118
|
+
const now = new Date().getTime();
|
|
119
|
+
view.setUint32(timeOut, (now * 1000000.0) % 0x100000000, true);
|
|
120
|
+
view.setUint32(timeOut + 4, (now * 1000000.0) / 0x100000000, true);
|
|
121
|
+
return this.WASI_ERRNO_SUCCESS;
|
|
122
|
+
}
|
|
123
|
+
fd_fdstat_get(fd, fdstat) {
|
|
124
|
+
if (fd > 2)
|
|
125
|
+
return this.WASI_ERRNO_BADF;
|
|
126
|
+
const view = this.getDataView();
|
|
127
|
+
view.setUint8(fdstat, this.WASI_FILETYPE_CHARACTER_DEVICE);
|
|
128
|
+
view.setUint16(fdstat + 2, this.WASI_FDFLAGS_APPEND, true);
|
|
129
|
+
view.setUint16(fdstat + 8, this.WASI_RIGHTS_FD_SYNC |
|
|
130
|
+
this.WASI_RIGHTS_FD_WRITE |
|
|
131
|
+
this.WASI_RIGHTS_FD_FILESTAT_GET, true);
|
|
132
|
+
view.setUint16(fdstat + 16, 0, true);
|
|
133
|
+
return this.WASI_ERRNO_SUCCESS;
|
|
134
|
+
}
|
|
135
|
+
fd_write(fd, iovs, iovsLen, nwritten) {
|
|
136
|
+
if (fd > 2)
|
|
137
|
+
return this.WASI_ERRNO_BADF;
|
|
138
|
+
const view = this.getDataView();
|
|
139
|
+
const memory = this.getMemory();
|
|
140
|
+
const buffers = [];
|
|
141
|
+
for (let i = 0; i < iovsLen; i++) {
|
|
142
|
+
const iov = iovs + i * 8;
|
|
143
|
+
const offset = view.getUint32(iov, true);
|
|
144
|
+
const len = view.getUint32(iov + 4, true);
|
|
145
|
+
buffers.push(new Uint8Array(memory.buffer, offset, len));
|
|
146
|
+
}
|
|
147
|
+
const length = buffers.reduce((s, b) => s + b.length, 0);
|
|
148
|
+
const buffer = new Uint8Array(length);
|
|
149
|
+
let offset = 0;
|
|
150
|
+
buffers.forEach((b) => {
|
|
151
|
+
buffer.set(b, offset);
|
|
152
|
+
offset += b.length;
|
|
153
|
+
});
|
|
154
|
+
const string = new TextDecoder("utf-8").decode(buffer).replace(/\n$/, "");
|
|
155
|
+
if (fd === 1)
|
|
156
|
+
console.log(string);
|
|
157
|
+
else
|
|
158
|
+
console.error(string);
|
|
159
|
+
view.setUint32(nwritten, buffer.length, true);
|
|
160
|
+
return this.WASI_ERRNO_SUCCESS;
|
|
161
|
+
}
|
|
162
|
+
random_get(pointer, size) {
|
|
163
|
+
const memory = this.getMemory();
|
|
164
|
+
const buffer = new Uint8Array(memory.buffer, pointer, size);
|
|
165
|
+
crypto.randomFillSync(buffer);
|
|
166
|
+
return this.WASI_ERRNO_SUCCESS;
|
|
167
|
+
}
|
|
168
|
+
environ_sizes_get(environCount, environBufSize) {
|
|
169
|
+
var view = this.getDataView();
|
|
170
|
+
view.setUint32(environCount, 0, !0);
|
|
171
|
+
view.setUint32(environBufSize, 0, !0);
|
|
172
|
+
return this.WASI_ERRNO_SUCCESS;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const monero_wallet_api_wasm: Uint8Array;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { TinyWASI } from "./wasi";
|
|
2
|
+
export type MemoryCallback = (ptr: number, len: number) => void;
|
|
3
|
+
export declare class WasmProcessor {
|
|
4
|
+
tinywasi: TinyWASI;
|
|
5
|
+
node_url: string;
|
|
6
|
+
/**
|
|
7
|
+
* This method is invoked whenever a Rust function expects an array or string parameter.
|
|
8
|
+
* You should use `writeArray` or `writeString` within the function assigned to this callback
|
|
9
|
+
* to write the data into WebAssembly (Wasm) memory before calling the corresponding Wasm method.
|
|
10
|
+
*
|
|
11
|
+
* @param ptr - The WebAssembly memory address where the data should be written.
|
|
12
|
+
* @param len - The number of bytes to write starting from the specified `ptr`.
|
|
13
|
+
*/
|
|
14
|
+
writeToWasmMemory: MemoryCallback;
|
|
15
|
+
/**
|
|
16
|
+
* This method is invoked whenever a Rust function wants to return an array or string.
|
|
17
|
+
* You should use `readArray` or `readString` within the function assigned to this callback
|
|
18
|
+
* to read the data from WebAssembly (Wasm) memory after the corresponding Wasm method has written it.
|
|
19
|
+
*
|
|
20
|
+
* @param ptr - The WebAssembly memory address from which the data should be read.
|
|
21
|
+
* @param len - The number of bytes to read starting from the specified `ptr`.
|
|
22
|
+
*/
|
|
23
|
+
readFromWasmMemory: MemoryCallback;
|
|
24
|
+
/**
|
|
25
|
+
* Writes an array of bytes to a specified offset in WebAssembly memory.
|
|
26
|
+
*
|
|
27
|
+
* This method is typically used within `writeToWasmMemory` to write data into Wasm memory.
|
|
28
|
+
* For more details, see {@link writeToWasmMemory}.
|
|
29
|
+
*
|
|
30
|
+
* @param ptr - The WebAssembly memory address where the data should be written.
|
|
31
|
+
* @param len - The number of bytes to write starting from the specified `ptr`.
|
|
32
|
+
* @param arr - The array of bytes to write into WebAssembly memory.
|
|
33
|
+
*
|
|
34
|
+
* @see {@link writeToWasmMemory}
|
|
35
|
+
*/
|
|
36
|
+
writeArray: (ptr: number, len: number, arr: Uint8Array) => void;
|
|
37
|
+
/**
|
|
38
|
+
* Writes a string to a specified offset in WebAssembly memory.
|
|
39
|
+
*
|
|
40
|
+
* This method is typically used within `writeToWasmMemory` to write string data into Wasm memory.
|
|
41
|
+
* For more details, see {@link writeToWasmMemory}.
|
|
42
|
+
*
|
|
43
|
+
* @param ptr - The WebAssembly memory address where the data should be written.
|
|
44
|
+
* @param len - The number of bytes to write starting from the specified `ptr`.
|
|
45
|
+
* @param str - The string to write into WebAssembly memory.
|
|
46
|
+
*
|
|
47
|
+
* @see {@link writeToWasmMemory}
|
|
48
|
+
*/
|
|
49
|
+
writeString: (ptr: number, len: number, str: string) => void;
|
|
50
|
+
/**
|
|
51
|
+
* Reads an array of bytes from a specified offset in WebAssembly memory.
|
|
52
|
+
*
|
|
53
|
+
* This method is typically used within the function assigned to `readFromWasmMemory`
|
|
54
|
+
* callback to read data written by Rust functions into Wasm memory.
|
|
55
|
+
*
|
|
56
|
+
* @param ptr - The WebAssembly memory address from which the data should be read.
|
|
57
|
+
* @param len - The number of bytes to read starting from the specified `ptr`.
|
|
58
|
+
* @returns A Uint8Array containing the bytes read from WebAssembly memory.
|
|
59
|
+
*
|
|
60
|
+
* @see {@link readFromWasmMemory}
|
|
61
|
+
*/
|
|
62
|
+
readArray: (ptr: number, len: number) => Uint8Array;
|
|
63
|
+
/**
|
|
64
|
+
* Reads a string from a specified offset in WebAssembly memory.
|
|
65
|
+
*
|
|
66
|
+
* This method is typically used within `readFromWasmMemory` to read string data from Wasm memory.
|
|
67
|
+
* For more details, see {@link readFromWasmMemory}.
|
|
68
|
+
*
|
|
69
|
+
* @param ptr - The WebAssembly memory address where the data should be read from.
|
|
70
|
+
* @param len - The number of bytes to read starting from the specified `ptr`.
|
|
71
|
+
* @param str - The string to read from WebAssembly memory.
|
|
72
|
+
*
|
|
73
|
+
* @see {@link readFromWasmMemory}
|
|
74
|
+
*/
|
|
75
|
+
readString: (ptr: number, len: number) => string;
|
|
76
|
+
protected constructor(tinywasi: TinyWASI, node_url: string);
|
|
77
|
+
initWasmModule(): Promise<TinyWASI>;
|
|
78
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { TinyWASI } from "./wasi";
|
|
2
|
+
import { monero_wallet_api_wasm } from "./wasmFile";
|
|
3
|
+
export class WasmProcessor {
|
|
4
|
+
tinywasi;
|
|
5
|
+
node_url;
|
|
6
|
+
/**
|
|
7
|
+
* This method is invoked whenever a Rust function expects an array or string parameter.
|
|
8
|
+
* You should use `writeArray` or `writeString` within the function assigned to this callback
|
|
9
|
+
* to write the data into WebAssembly (Wasm) memory before calling the corresponding Wasm method.
|
|
10
|
+
*
|
|
11
|
+
* @param ptr - The WebAssembly memory address where the data should be written.
|
|
12
|
+
* @param len - The number of bytes to write starting from the specified `ptr`.
|
|
13
|
+
*/
|
|
14
|
+
writeToWasmMemory = (ptr, len) => { };
|
|
15
|
+
/**
|
|
16
|
+
* This method is invoked whenever a Rust function wants to return an array or string.
|
|
17
|
+
* You should use `readArray` or `readString` within the function assigned to this callback
|
|
18
|
+
* to read the data from WebAssembly (Wasm) memory after the corresponding Wasm method has written it.
|
|
19
|
+
*
|
|
20
|
+
* @param ptr - The WebAssembly memory address from which the data should be read.
|
|
21
|
+
* @param len - The number of bytes to read starting from the specified `ptr`.
|
|
22
|
+
*/
|
|
23
|
+
readFromWasmMemory = (ptr, len) => { };
|
|
24
|
+
/**
|
|
25
|
+
* Writes an array of bytes to a specified offset in WebAssembly memory.
|
|
26
|
+
*
|
|
27
|
+
* This method is typically used within `writeToWasmMemory` to write data into Wasm memory.
|
|
28
|
+
* For more details, see {@link writeToWasmMemory}.
|
|
29
|
+
*
|
|
30
|
+
* @param ptr - The WebAssembly memory address where the data should be written.
|
|
31
|
+
* @param len - The number of bytes to write starting from the specified `ptr`.
|
|
32
|
+
* @param arr - The array of bytes to write into WebAssembly memory.
|
|
33
|
+
*
|
|
34
|
+
* @see {@link writeToWasmMemory}
|
|
35
|
+
*/
|
|
36
|
+
writeArray = (ptr, len, arr) => {
|
|
37
|
+
const view = this.tinywasi.getDataView();
|
|
38
|
+
for (let i = 0; i < arr.length; i++) {
|
|
39
|
+
const offset = i + ptr;
|
|
40
|
+
view.setUint8(offset, arr[i]);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Writes a string to a specified offset in WebAssembly memory.
|
|
45
|
+
*
|
|
46
|
+
* This method is typically used within `writeToWasmMemory` to write string data into Wasm memory.
|
|
47
|
+
* For more details, see {@link writeToWasmMemory}.
|
|
48
|
+
*
|
|
49
|
+
* @param ptr - The WebAssembly memory address where the data should be written.
|
|
50
|
+
* @param len - The number of bytes to write starting from the specified `ptr`.
|
|
51
|
+
* @param str - The string to write into WebAssembly memory.
|
|
52
|
+
*
|
|
53
|
+
* @see {@link writeToWasmMemory}
|
|
54
|
+
*/
|
|
55
|
+
writeString = (ptr, len, str) => {
|
|
56
|
+
const encoder = new TextEncoder();
|
|
57
|
+
const arr = encoder.encode(str);
|
|
58
|
+
this.writeArray(ptr, len, arr);
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Reads an array of bytes from a specified offset in WebAssembly memory.
|
|
62
|
+
*
|
|
63
|
+
* This method is typically used within the function assigned to `readFromWasmMemory`
|
|
64
|
+
* callback to read data written by Rust functions into Wasm memory.
|
|
65
|
+
*
|
|
66
|
+
* @param ptr - The WebAssembly memory address from which the data should be read.
|
|
67
|
+
* @param len - The number of bytes to read starting from the specified `ptr`.
|
|
68
|
+
* @returns A Uint8Array containing the bytes read from WebAssembly memory.
|
|
69
|
+
*
|
|
70
|
+
* @see {@link readFromWasmMemory}
|
|
71
|
+
*/
|
|
72
|
+
readArray = (ptr, len) => {
|
|
73
|
+
const memory = this.tinywasi.getMemory();
|
|
74
|
+
return new Uint8Array(memory.buffer, ptr, len);
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Reads a string from a specified offset in WebAssembly memory.
|
|
78
|
+
*
|
|
79
|
+
* This method is typically used within `readFromWasmMemory` to read string data from Wasm memory.
|
|
80
|
+
* For more details, see {@link readFromWasmMemory}.
|
|
81
|
+
*
|
|
82
|
+
* @param ptr - The WebAssembly memory address where the data should be read from.
|
|
83
|
+
* @param len - The number of bytes to read starting from the specified `ptr`.
|
|
84
|
+
* @param str - The string to read from WebAssembly memory.
|
|
85
|
+
*
|
|
86
|
+
* @see {@link readFromWasmMemory}
|
|
87
|
+
*/
|
|
88
|
+
readString = (ptr, len) => {
|
|
89
|
+
const array = this.readArray(ptr, len);
|
|
90
|
+
const decoder = new TextDecoder();
|
|
91
|
+
const str = decoder.decode(array);
|
|
92
|
+
return str;
|
|
93
|
+
};
|
|
94
|
+
constructor(tinywasi, node_url) {
|
|
95
|
+
this.tinywasi = tinywasi;
|
|
96
|
+
this.node_url = node_url;
|
|
97
|
+
}
|
|
98
|
+
async initWasmModule() {
|
|
99
|
+
const tinywasi = new TinyWASI();
|
|
100
|
+
this.tinywasi = tinywasi;
|
|
101
|
+
const imports = {
|
|
102
|
+
env: {
|
|
103
|
+
input: (ptr, len) => {
|
|
104
|
+
this.writeToWasmMemory(ptr, len);
|
|
105
|
+
},
|
|
106
|
+
output: (ptr, len) => {
|
|
107
|
+
this.readFromWasmMemory(ptr, len);
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
...tinywasi.imports,
|
|
111
|
+
};
|
|
112
|
+
const { module, instance } = await WebAssembly.instantiate(monero_wallet_api_wasm, imports);
|
|
113
|
+
tinywasi.initialize(instance);
|
|
114
|
+
return tinywasi;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const monero_wallet_api_wasm: Uint8Array;
|