@lifi/perps-sdk-provider-lighter 8.2.1 → 10.0.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 +14 -10
- package/dist/cjs/LighterProvider.d.ts +5 -10
- package/dist/cjs/LighterProvider.d.ts.map +1 -1
- package/dist/cjs/LighterProvider.js +31 -26
- package/dist/cjs/LighterProvider.js.map +1 -1
- package/dist/cjs/constants.d.ts +5 -8
- package/dist/cjs/constants.d.ts.map +1 -1
- package/dist/cjs/constants.js +15 -12
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/index.d.ts +3 -4
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +6 -5
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/signers/LighterSigner.d.ts +5 -7
- package/dist/cjs/signers/LighterSigner.d.ts.map +1 -1
- package/dist/cjs/signers/LighterSigner.js +30 -17
- package/dist/cjs/signers/LighterSigner.js.map +1 -1
- package/dist/cjs/signers/generated/wasmExecRuntime.d.ts +2 -0
- package/dist/cjs/signers/generated/wasmExecRuntime.d.ts.map +1 -0
- package/dist/cjs/signers/generated/wasmExecRuntime.js +569 -0
- package/dist/cjs/signers/generated/wasmExecRuntime.js.map +1 -0
- package/dist/cjs/signers/signActions.d.ts +2 -2
- package/dist/cjs/signers/signActions.d.ts.map +1 -1
- package/dist/cjs/signers/signActions.js +4 -10
- package/dist/cjs/signers/signActions.js.map +1 -1
- package/dist/cjs/signers/wasmBinaryUrl.js +11 -0
- package/dist/cjs/signers/wasmLoader.d.ts +1 -6
- package/dist/cjs/signers/wasmLoader.d.ts.map +1 -1
- package/dist/cjs/signers/wasmLoader.js +15 -69
- package/dist/cjs/signers/wasmLoader.js.map +1 -1
- package/dist/cjs/types/account.d.ts +4 -1
- package/dist/cjs/types/account.d.ts.map +1 -1
- package/dist/cjs/types/action.d.ts +4 -1
- package/dist/cjs/types/action.d.ts.map +1 -1
- package/dist/cjs/types/action.js.map +1 -1
- package/dist/cjs/utils/assetCollateral.d.ts +2 -1
- package/dist/cjs/utils/assetCollateral.d.ts.map +1 -1
- package/dist/cjs/utils/assetCollateral.js +1 -1
- package/dist/cjs/utils/assetCollateral.js.map +1 -1
- package/dist/cjs/utils/index.d.ts +1 -0
- package/dist/cjs/utils/index.d.ts.map +1 -1
- package/dist/cjs/utils/index.js +3 -1
- package/dist/cjs/utils/index.js.map +1 -1
- package/dist/cjs/utils/withdrawableBalances.d.ts +4 -0
- package/dist/cjs/utils/withdrawableBalances.d.ts.map +1 -0
- package/dist/cjs/utils/withdrawableBalances.js +21 -0
- package/dist/cjs/utils/withdrawableBalances.js.map +1 -0
- package/dist/esm/LighterProvider.d.ts +53 -56
- package/dist/esm/LighterProvider.d.ts.map +1 -1
- package/dist/esm/LighterProvider.js +74 -49
- package/dist/esm/LighterProvider.js.map +1 -1
- package/dist/esm/constants.d.ts +25 -36
- package/dist/esm/constants.d.ts.map +1 -1
- package/dist/esm/constants.js +31 -18
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/index.d.ts +6 -7
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +5 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/signers/LighterSigner.d.ts +10 -18
- package/dist/esm/signers/LighterSigner.d.ts.map +1 -1
- package/dist/esm/signers/LighterSigner.js +32 -25
- package/dist/esm/signers/LighterSigner.js.map +1 -1
- package/dist/esm/signers/generated/wasmExecRuntime.d.ts +8 -0
- package/dist/esm/signers/generated/wasmExecRuntime.d.ts.map +1 -0
- package/dist/esm/signers/generated/wasmExecRuntime.js +574 -0
- package/dist/esm/signers/generated/wasmExecRuntime.js.map +1 -0
- package/dist/esm/signers/signActions.d.ts +3 -5
- package/dist/esm/signers/signActions.d.ts.map +1 -1
- package/dist/esm/signers/signActions.js +4 -10
- package/dist/esm/signers/signActions.js.map +1 -1
- package/dist/esm/signers/wasmBinaryUrl.js +10 -0
- package/dist/esm/signers/wasmLoader.d.ts +7 -31
- package/dist/esm/signers/wasmLoader.d.ts.map +1 -1
- package/dist/esm/signers/wasmLoader.js +32 -108
- package/dist/esm/signers/wasmLoader.js.map +1 -1
- package/dist/esm/types/account.d.ts +17 -6
- package/dist/esm/types/account.d.ts.map +1 -1
- package/dist/esm/types/action.d.ts +14 -2
- package/dist/esm/types/action.d.ts.map +1 -1
- package/dist/esm/types/action.js.map +1 -1
- package/dist/esm/utils/assetCollateral.d.ts +3 -2
- package/dist/esm/utils/assetCollateral.d.ts.map +1 -1
- package/dist/esm/utils/assetCollateral.js +5 -5
- package/dist/esm/utils/assetCollateral.js.map +1 -1
- package/dist/esm/utils/index.d.ts +1 -0
- package/dist/esm/utils/index.d.ts.map +1 -1
- package/dist/esm/utils/index.js +1 -0
- package/dist/esm/utils/index.js.map +1 -1
- package/dist/esm/utils/withdrawableBalances.d.ts +12 -0
- package/dist/esm/utils/withdrawableBalances.d.ts.map +1 -0
- package/dist/esm/utils/withdrawableBalances.js +25 -0
- package/dist/esm/utils/withdrawableBalances.js.map +1 -0
- package/dist/types/LighterProvider.d.ts +53 -56
- package/dist/types/LighterProvider.d.ts.map +1 -1
- package/dist/types/constants.d.ts +25 -36
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/index.d.ts +6 -7
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/signers/LighterSigner.d.ts +10 -18
- package/dist/types/signers/LighterSigner.d.ts.map +1 -1
- package/dist/types/signers/generated/wasmExecRuntime.d.ts +8 -0
- package/dist/types/signers/generated/wasmExecRuntime.d.ts.map +1 -0
- package/dist/types/signers/signActions.d.ts +3 -5
- package/dist/types/signers/signActions.d.ts.map +1 -1
- package/dist/types/signers/wasmLoader.d.ts +7 -31
- package/dist/types/signers/wasmLoader.d.ts.map +1 -1
- package/dist/types/types/account.d.ts +17 -6
- package/dist/types/types/account.d.ts.map +1 -1
- package/dist/types/types/action.d.ts +14 -2
- package/dist/types/types/action.d.ts.map +1 -1
- package/dist/types/utils/assetCollateral.d.ts +3 -2
- package/dist/types/utils/assetCollateral.d.ts.map +1 -1
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/index.d.ts.map +1 -1
- package/dist/types/utils/withdrawableBalances.d.ts +12 -0
- package/dist/types/utils/withdrawableBalances.d.ts.map +1 -0
- package/package.json +3 -6
- package/src/LighterProvider.ts +112 -101
- package/src/constants.ts +35 -45
- package/src/index.ts +13 -10
- package/src/signers/LighterSigner.ts +47 -51
- package/src/signers/generated/wasmExecRuntime.ts +575 -0
- package/src/signers/signActions.ts +12 -30
- package/src/signers/wasmBinaryUrl.d.ts +7 -0
- package/src/signers/wasmLoader.ts +33 -152
- package/src/types/account.ts +18 -6
- package/src/types/action.ts +14 -2
- package/src/utils/assetCollateral.ts +8 -6
- package/src/utils/index.ts +1 -0
- package/src/utils/withdrawableBalances.ts +31 -0
- package/dist/cjs/signers/index.d.ts +0 -11
- package/dist/cjs/signers/index.d.ts.map +0 -1
- package/dist/cjs/signers/index.js +0 -18
- package/dist/cjs/signers/index.js.map +0 -1
- package/dist/esm/signers/index.d.ts +0 -11
- package/dist/esm/signers/index.d.ts.map +0 -1
- package/dist/esm/signers/index.js +0 -7
- package/dist/esm/signers/index.js.map +0 -1
- package/dist/types/signers/index.d.ts +0 -11
- package/dist/types/signers/index.d.ts.map +0 -1
- package/dist/wasm/wasm_exec.js +0 -561
- package/src/signers/index.ts +0 -35
- package/wasm/lighter-signer.wasm +0 -0
- package/wasm/wasm_exec.js +0 -561
|
@@ -0,0 +1,569 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WASM_EXEC_JS = void 0;
|
|
4
|
+
const WASM_EXEC_LINES = [
|
|
5
|
+
"// Copyright 2018 The Go Authors. All rights reserved.",
|
|
6
|
+
"// Use of this source code is governed by a BSD-style",
|
|
7
|
+
"// license that can be found in the LICENSE file.",
|
|
8
|
+
"",
|
|
9
|
+
"\"use strict\";",
|
|
10
|
+
"",
|
|
11
|
+
"(() => {",
|
|
12
|
+
"\tconst enosys = () => {",
|
|
13
|
+
"\t\tconst err = new Error(\"not implemented\");",
|
|
14
|
+
"\t\terr.code = \"ENOSYS\";",
|
|
15
|
+
"\t\treturn err;",
|
|
16
|
+
"\t};",
|
|
17
|
+
"",
|
|
18
|
+
"\tif (!globalThis.fs) {",
|
|
19
|
+
"\t\tlet outputBuf = \"\";",
|
|
20
|
+
"\t\tglobalThis.fs = {",
|
|
21
|
+
"\t\t\tconstants: { O_WRONLY: -1, O_RDWR: -1, O_CREAT: -1, O_TRUNC: -1, O_APPEND: -1, O_EXCL: -1 }, // unused",
|
|
22
|
+
"\t\t\twriteSync(fd, buf) {",
|
|
23
|
+
"\t\t\t\toutputBuf += decoder.decode(buf);",
|
|
24
|
+
"\t\t\t\tconst nl = outputBuf.lastIndexOf(\"\\n\");",
|
|
25
|
+
"\t\t\t\tif (nl != -1) {",
|
|
26
|
+
"\t\t\t\t\tconsole.log(outputBuf.substring(0, nl));",
|
|
27
|
+
"\t\t\t\t\toutputBuf = outputBuf.substring(nl + 1);",
|
|
28
|
+
"\t\t\t\t}",
|
|
29
|
+
"\t\t\t\treturn buf.length;",
|
|
30
|
+
"\t\t\t},",
|
|
31
|
+
"\t\t\twrite(fd, buf, offset, length, position, callback) {",
|
|
32
|
+
"\t\t\t\tif (offset !== 0 || length !== buf.length || position !== null) {",
|
|
33
|
+
"\t\t\t\t\tcallback(enosys());",
|
|
34
|
+
"\t\t\t\t\treturn;",
|
|
35
|
+
"\t\t\t\t}",
|
|
36
|
+
"\t\t\t\tconst n = this.writeSync(fd, buf);",
|
|
37
|
+
"\t\t\t\tcallback(null, n);",
|
|
38
|
+
"\t\t\t},",
|
|
39
|
+
"\t\t\tchmod(path, mode, callback) { callback(enosys()); },",
|
|
40
|
+
"\t\t\tchown(path, uid, gid, callback) { callback(enosys()); },",
|
|
41
|
+
"\t\t\tclose(fd, callback) { callback(enosys()); },",
|
|
42
|
+
"\t\t\tfchmod(fd, mode, callback) { callback(enosys()); },",
|
|
43
|
+
"\t\t\tfchown(fd, uid, gid, callback) { callback(enosys()); },",
|
|
44
|
+
"\t\t\tfstat(fd, callback) { callback(enosys()); },",
|
|
45
|
+
"\t\t\tfsync(fd, callback) { callback(null); },",
|
|
46
|
+
"\t\t\tftruncate(fd, length, callback) { callback(enosys()); },",
|
|
47
|
+
"\t\t\tlchown(path, uid, gid, callback) { callback(enosys()); },",
|
|
48
|
+
"\t\t\tlink(path, link, callback) { callback(enosys()); },",
|
|
49
|
+
"\t\t\tlstat(path, callback) { callback(enosys()); },",
|
|
50
|
+
"\t\t\tmkdir(path, perm, callback) { callback(enosys()); },",
|
|
51
|
+
"\t\t\topen(path, flags, mode, callback) { callback(enosys()); },",
|
|
52
|
+
"\t\t\tread(fd, buffer, offset, length, position, callback) { callback(enosys()); },",
|
|
53
|
+
"\t\t\treaddir(path, callback) { callback(enosys()); },",
|
|
54
|
+
"\t\t\treadlink(path, callback) { callback(enosys()); },",
|
|
55
|
+
"\t\t\trename(from, to, callback) { callback(enosys()); },",
|
|
56
|
+
"\t\t\trmdir(path, callback) { callback(enosys()); },",
|
|
57
|
+
"\t\t\tstat(path, callback) { callback(enosys()); },",
|
|
58
|
+
"\t\t\tsymlink(path, link, callback) { callback(enosys()); },",
|
|
59
|
+
"\t\t\ttruncate(path, length, callback) { callback(enosys()); },",
|
|
60
|
+
"\t\t\tunlink(path, callback) { callback(enosys()); },",
|
|
61
|
+
"\t\t\tutimes(path, atime, mtime, callback) { callback(enosys()); },",
|
|
62
|
+
"\t\t};",
|
|
63
|
+
"\t}",
|
|
64
|
+
"",
|
|
65
|
+
"\tif (!globalThis.process) {",
|
|
66
|
+
"\t\tglobalThis.process = {",
|
|
67
|
+
"\t\t\tgetuid() { return -1; },",
|
|
68
|
+
"\t\t\tgetgid() { return -1; },",
|
|
69
|
+
"\t\t\tgeteuid() { return -1; },",
|
|
70
|
+
"\t\t\tgetegid() { return -1; },",
|
|
71
|
+
"\t\t\tgetgroups() { throw enosys(); },",
|
|
72
|
+
"\t\t\tpid: -1,",
|
|
73
|
+
"\t\t\tppid: -1,",
|
|
74
|
+
"\t\t\tumask() { throw enosys(); },",
|
|
75
|
+
"\t\t\tcwd() { throw enosys(); },",
|
|
76
|
+
"\t\t\tchdir() { throw enosys(); },",
|
|
77
|
+
"\t\t}",
|
|
78
|
+
"\t}",
|
|
79
|
+
"",
|
|
80
|
+
"\tif (!globalThis.crypto) {",
|
|
81
|
+
"\t\tthrow new Error(\"globalThis.crypto is not available, polyfill required (crypto.getRandomValues only)\");",
|
|
82
|
+
"\t}",
|
|
83
|
+
"",
|
|
84
|
+
"\tif (!globalThis.performance) {",
|
|
85
|
+
"\t\tthrow new Error(\"globalThis.performance is not available, polyfill required (performance.now only)\");",
|
|
86
|
+
"\t}",
|
|
87
|
+
"",
|
|
88
|
+
"\tif (!globalThis.TextEncoder) {",
|
|
89
|
+
"\t\tthrow new Error(\"globalThis.TextEncoder is not available, polyfill required\");",
|
|
90
|
+
"\t}",
|
|
91
|
+
"",
|
|
92
|
+
"\tif (!globalThis.TextDecoder) {",
|
|
93
|
+
"\t\tthrow new Error(\"globalThis.TextDecoder is not available, polyfill required\");",
|
|
94
|
+
"\t}",
|
|
95
|
+
"",
|
|
96
|
+
"\tconst encoder = new TextEncoder(\"utf-8\");",
|
|
97
|
+
"\tconst decoder = new TextDecoder(\"utf-8\");",
|
|
98
|
+
"",
|
|
99
|
+
"\tglobalThis.Go = class {",
|
|
100
|
+
"\t\tconstructor() {",
|
|
101
|
+
"\t\t\tthis.argv = [\"js\"];",
|
|
102
|
+
"\t\t\tthis.env = {};",
|
|
103
|
+
"\t\t\tthis.exit = (code) => {",
|
|
104
|
+
"\t\t\t\tif (code !== 0) {",
|
|
105
|
+
"\t\t\t\t\tconsole.warn(\"exit code:\", code);",
|
|
106
|
+
"\t\t\t\t}",
|
|
107
|
+
"\t\t\t};",
|
|
108
|
+
"\t\t\tthis._exitPromise = new Promise((resolve) => {",
|
|
109
|
+
"\t\t\t\tthis._resolveExitPromise = resolve;",
|
|
110
|
+
"\t\t\t});",
|
|
111
|
+
"\t\t\tthis._pendingEvent = null;",
|
|
112
|
+
"\t\t\tthis._scheduledTimeouts = new Map();",
|
|
113
|
+
"\t\t\tthis._nextCallbackTimeoutID = 1;",
|
|
114
|
+
"",
|
|
115
|
+
"\t\t\tconst setInt64 = (addr, v) => {",
|
|
116
|
+
"\t\t\t\tthis.mem.setUint32(addr + 0, v, true);",
|
|
117
|
+
"\t\t\t\tthis.mem.setUint32(addr + 4, Math.floor(v / 4294967296), true);",
|
|
118
|
+
"\t\t\t}",
|
|
119
|
+
"",
|
|
120
|
+
"\t\t\tconst setInt32 = (addr, v) => {",
|
|
121
|
+
"\t\t\t\tthis.mem.setUint32(addr + 0, v, true);",
|
|
122
|
+
"\t\t\t}",
|
|
123
|
+
"",
|
|
124
|
+
"\t\t\tconst getInt64 = (addr) => {",
|
|
125
|
+
"\t\t\t\tconst low = this.mem.getUint32(addr + 0, true);",
|
|
126
|
+
"\t\t\t\tconst high = this.mem.getInt32(addr + 4, true);",
|
|
127
|
+
"\t\t\t\treturn low + high * 4294967296;",
|
|
128
|
+
"\t\t\t}",
|
|
129
|
+
"",
|
|
130
|
+
"\t\t\tconst loadValue = (addr) => {",
|
|
131
|
+
"\t\t\t\tconst f = this.mem.getFloat64(addr, true);",
|
|
132
|
+
"\t\t\t\tif (f === 0) {",
|
|
133
|
+
"\t\t\t\t\treturn undefined;",
|
|
134
|
+
"\t\t\t\t}",
|
|
135
|
+
"\t\t\t\tif (!isNaN(f)) {",
|
|
136
|
+
"\t\t\t\t\treturn f;",
|
|
137
|
+
"\t\t\t\t}",
|
|
138
|
+
"",
|
|
139
|
+
"\t\t\t\tconst id = this.mem.getUint32(addr, true);",
|
|
140
|
+
"\t\t\t\treturn this._values[id];",
|
|
141
|
+
"\t\t\t}",
|
|
142
|
+
"",
|
|
143
|
+
"\t\t\tconst storeValue = (addr, v) => {",
|
|
144
|
+
"\t\t\t\tconst nanHead = 0x7FF80000;",
|
|
145
|
+
"",
|
|
146
|
+
"\t\t\t\tif (typeof v === \"number\" && v !== 0) {",
|
|
147
|
+
"\t\t\t\t\tif (isNaN(v)) {",
|
|
148
|
+
"\t\t\t\t\t\tthis.mem.setUint32(addr + 4, nanHead, true);",
|
|
149
|
+
"\t\t\t\t\t\tthis.mem.setUint32(addr, 0, true);",
|
|
150
|
+
"\t\t\t\t\t\treturn;",
|
|
151
|
+
"\t\t\t\t\t}",
|
|
152
|
+
"\t\t\t\t\tthis.mem.setFloat64(addr, v, true);",
|
|
153
|
+
"\t\t\t\t\treturn;",
|
|
154
|
+
"\t\t\t\t}",
|
|
155
|
+
"",
|
|
156
|
+
"\t\t\t\tif (v === undefined) {",
|
|
157
|
+
"\t\t\t\t\tthis.mem.setFloat64(addr, 0, true);",
|
|
158
|
+
"\t\t\t\t\treturn;",
|
|
159
|
+
"\t\t\t\t}",
|
|
160
|
+
"",
|
|
161
|
+
"\t\t\t\tlet id = this._ids.get(v);",
|
|
162
|
+
"\t\t\t\tif (id === undefined) {",
|
|
163
|
+
"\t\t\t\t\tid = this._idPool.pop();",
|
|
164
|
+
"\t\t\t\t\tif (id === undefined) {",
|
|
165
|
+
"\t\t\t\t\t\tid = this._values.length;",
|
|
166
|
+
"\t\t\t\t\t}",
|
|
167
|
+
"\t\t\t\t\tthis._values[id] = v;",
|
|
168
|
+
"\t\t\t\t\tthis._goRefCounts[id] = 0;",
|
|
169
|
+
"\t\t\t\t\tthis._ids.set(v, id);",
|
|
170
|
+
"\t\t\t\t}",
|
|
171
|
+
"\t\t\t\tthis._goRefCounts[id]++;",
|
|
172
|
+
"\t\t\t\tlet typeFlag = 0;",
|
|
173
|
+
"\t\t\t\tswitch (typeof v) {",
|
|
174
|
+
"\t\t\t\t\tcase \"object\":",
|
|
175
|
+
"\t\t\t\t\t\tif (v !== null) {",
|
|
176
|
+
"\t\t\t\t\t\t\ttypeFlag = 1;",
|
|
177
|
+
"\t\t\t\t\t\t}",
|
|
178
|
+
"\t\t\t\t\t\tbreak;",
|
|
179
|
+
"\t\t\t\t\tcase \"string\":",
|
|
180
|
+
"\t\t\t\t\t\ttypeFlag = 2;",
|
|
181
|
+
"\t\t\t\t\t\tbreak;",
|
|
182
|
+
"\t\t\t\t\tcase \"symbol\":",
|
|
183
|
+
"\t\t\t\t\t\ttypeFlag = 3;",
|
|
184
|
+
"\t\t\t\t\t\tbreak;",
|
|
185
|
+
"\t\t\t\t\tcase \"function\":",
|
|
186
|
+
"\t\t\t\t\t\ttypeFlag = 4;",
|
|
187
|
+
"\t\t\t\t\t\tbreak;",
|
|
188
|
+
"\t\t\t\t}",
|
|
189
|
+
"\t\t\t\tthis.mem.setUint32(addr + 4, nanHead | typeFlag, true);",
|
|
190
|
+
"\t\t\t\tthis.mem.setUint32(addr, id, true);",
|
|
191
|
+
"\t\t\t}",
|
|
192
|
+
"",
|
|
193
|
+
"\t\t\tconst loadSlice = (addr) => {",
|
|
194
|
+
"\t\t\t\tconst array = getInt64(addr + 0);",
|
|
195
|
+
"\t\t\t\tconst len = getInt64(addr + 8);",
|
|
196
|
+
"\t\t\t\treturn new Uint8Array(this._inst.exports.mem.buffer, array, len);",
|
|
197
|
+
"\t\t\t}",
|
|
198
|
+
"",
|
|
199
|
+
"\t\t\tconst loadSliceOfValues = (addr) => {",
|
|
200
|
+
"\t\t\t\tconst array = getInt64(addr + 0);",
|
|
201
|
+
"\t\t\t\tconst len = getInt64(addr + 8);",
|
|
202
|
+
"\t\t\t\tconst a = new Array(len);",
|
|
203
|
+
"\t\t\t\tfor (let i = 0; i < len; i++) {",
|
|
204
|
+
"\t\t\t\t\ta[i] = loadValue(array + i * 8);",
|
|
205
|
+
"\t\t\t\t}",
|
|
206
|
+
"\t\t\t\treturn a;",
|
|
207
|
+
"\t\t\t}",
|
|
208
|
+
"",
|
|
209
|
+
"\t\t\tconst loadString = (addr) => {",
|
|
210
|
+
"\t\t\t\tconst saddr = getInt64(addr + 0);",
|
|
211
|
+
"\t\t\t\tconst len = getInt64(addr + 8);",
|
|
212
|
+
"\t\t\t\treturn decoder.decode(new DataView(this._inst.exports.mem.buffer, saddr, len));",
|
|
213
|
+
"\t\t\t}",
|
|
214
|
+
"",
|
|
215
|
+
"\t\t\tconst timeOrigin = Date.now() - performance.now();",
|
|
216
|
+
"\t\t\tthis.importObject = {",
|
|
217
|
+
"\t\t\t\t_gotest: {",
|
|
218
|
+
"\t\t\t\t\tadd: (a, b) => a + b,",
|
|
219
|
+
"\t\t\t\t},",
|
|
220
|
+
"\t\t\t\tgojs: {",
|
|
221
|
+
"\t\t\t\t\t// Go's SP does not change as long as no Go code is running. Some operations (e.g. calls, getters and setters)",
|
|
222
|
+
"\t\t\t\t\t// may synchronously trigger a Go event handler. This makes Go code get executed in the middle of the imported",
|
|
223
|
+
"\t\t\t\t\t// function. A goroutine can switch to a new stack if the current stack is too small (see morestack function).",
|
|
224
|
+
"\t\t\t\t\t// This changes the SP, thus we have to update the SP used by the imported function.",
|
|
225
|
+
"",
|
|
226
|
+
"\t\t\t\t\t// func wasmExit(code int32)",
|
|
227
|
+
"\t\t\t\t\t\"runtime.wasmExit\": (sp) => {",
|
|
228
|
+
"\t\t\t\t\t\tsp >>>= 0;",
|
|
229
|
+
"\t\t\t\t\t\tconst code = this.mem.getInt32(sp + 8, true);",
|
|
230
|
+
"\t\t\t\t\t\tthis.exited = true;",
|
|
231
|
+
"\t\t\t\t\t\tdelete this._inst;",
|
|
232
|
+
"\t\t\t\t\t\tdelete this._values;",
|
|
233
|
+
"\t\t\t\t\t\tdelete this._goRefCounts;",
|
|
234
|
+
"\t\t\t\t\t\tdelete this._ids;",
|
|
235
|
+
"\t\t\t\t\t\tdelete this._idPool;",
|
|
236
|
+
"\t\t\t\t\t\tthis.exit(code);",
|
|
237
|
+
"\t\t\t\t\t},",
|
|
238
|
+
"",
|
|
239
|
+
"\t\t\t\t\t// func wasmWrite(fd uintptr, p unsafe.Pointer, n int32)",
|
|
240
|
+
"\t\t\t\t\t\"runtime.wasmWrite\": (sp) => {",
|
|
241
|
+
"\t\t\t\t\t\tsp >>>= 0;",
|
|
242
|
+
"\t\t\t\t\t\tconst fd = getInt64(sp + 8);",
|
|
243
|
+
"\t\t\t\t\t\tconst p = getInt64(sp + 16);",
|
|
244
|
+
"\t\t\t\t\t\tconst n = this.mem.getInt32(sp + 24, true);",
|
|
245
|
+
"\t\t\t\t\t\tfs.writeSync(fd, new Uint8Array(this._inst.exports.mem.buffer, p, n));",
|
|
246
|
+
"\t\t\t\t\t},",
|
|
247
|
+
"",
|
|
248
|
+
"\t\t\t\t\t// func resetMemoryDataView()",
|
|
249
|
+
"\t\t\t\t\t\"runtime.resetMemoryDataView\": (sp) => {",
|
|
250
|
+
"\t\t\t\t\t\tsp >>>= 0;",
|
|
251
|
+
"\t\t\t\t\t\tthis.mem = new DataView(this._inst.exports.mem.buffer);",
|
|
252
|
+
"\t\t\t\t\t},",
|
|
253
|
+
"",
|
|
254
|
+
"\t\t\t\t\t// func nanotime1() int64",
|
|
255
|
+
"\t\t\t\t\t\"runtime.nanotime1\": (sp) => {",
|
|
256
|
+
"\t\t\t\t\t\tsp >>>= 0;",
|
|
257
|
+
"\t\t\t\t\t\tsetInt64(sp + 8, (timeOrigin + performance.now()) * 1000000);",
|
|
258
|
+
"\t\t\t\t\t},",
|
|
259
|
+
"",
|
|
260
|
+
"\t\t\t\t\t// func walltime() (sec int64, nsec int32)",
|
|
261
|
+
"\t\t\t\t\t\"runtime.walltime\": (sp) => {",
|
|
262
|
+
"\t\t\t\t\t\tsp >>>= 0;",
|
|
263
|
+
"\t\t\t\t\t\tconst msec = (new Date).getTime();",
|
|
264
|
+
"\t\t\t\t\t\tsetInt64(sp + 8, msec / 1000);",
|
|
265
|
+
"\t\t\t\t\t\tthis.mem.setInt32(sp + 16, (msec % 1000) * 1000000, true);",
|
|
266
|
+
"\t\t\t\t\t},",
|
|
267
|
+
"",
|
|
268
|
+
"\t\t\t\t\t// func scheduleTimeoutEvent(delay int64) int32",
|
|
269
|
+
"\t\t\t\t\t\"runtime.scheduleTimeoutEvent\": (sp) => {",
|
|
270
|
+
"\t\t\t\t\t\tsp >>>= 0;",
|
|
271
|
+
"\t\t\t\t\t\tconst id = this._nextCallbackTimeoutID;",
|
|
272
|
+
"\t\t\t\t\t\tthis._nextCallbackTimeoutID++;",
|
|
273
|
+
"\t\t\t\t\t\tthis._scheduledTimeouts.set(id, setTimeout(",
|
|
274
|
+
"\t\t\t\t\t\t\t() => {",
|
|
275
|
+
"\t\t\t\t\t\t\t\tthis._resume();",
|
|
276
|
+
"\t\t\t\t\t\t\t\twhile (this._scheduledTimeouts.has(id)) {",
|
|
277
|
+
"\t\t\t\t\t\t\t\t\t// for some reason Go failed to register the timeout event, log and try again",
|
|
278
|
+
"\t\t\t\t\t\t\t\t\t// (temporary workaround for https://github.com/golang/go/issues/28975)",
|
|
279
|
+
"\t\t\t\t\t\t\t\t\tconsole.warn(\"scheduleTimeoutEvent: missed timeout event\");",
|
|
280
|
+
"\t\t\t\t\t\t\t\t\tthis._resume();",
|
|
281
|
+
"\t\t\t\t\t\t\t\t}",
|
|
282
|
+
"\t\t\t\t\t\t\t},",
|
|
283
|
+
"\t\t\t\t\t\t\tgetInt64(sp + 8),",
|
|
284
|
+
"\t\t\t\t\t\t));",
|
|
285
|
+
"\t\t\t\t\t\tthis.mem.setInt32(sp + 16, id, true);",
|
|
286
|
+
"\t\t\t\t\t},",
|
|
287
|
+
"",
|
|
288
|
+
"\t\t\t\t\t// func clearTimeoutEvent(id int32)",
|
|
289
|
+
"\t\t\t\t\t\"runtime.clearTimeoutEvent\": (sp) => {",
|
|
290
|
+
"\t\t\t\t\t\tsp >>>= 0;",
|
|
291
|
+
"\t\t\t\t\t\tconst id = this.mem.getInt32(sp + 8, true);",
|
|
292
|
+
"\t\t\t\t\t\tclearTimeout(this._scheduledTimeouts.get(id));",
|
|
293
|
+
"\t\t\t\t\t\tthis._scheduledTimeouts.delete(id);",
|
|
294
|
+
"\t\t\t\t\t},",
|
|
295
|
+
"",
|
|
296
|
+
"\t\t\t\t\t// func getRandomData(r []byte)",
|
|
297
|
+
"\t\t\t\t\t\"runtime.getRandomData\": (sp) => {",
|
|
298
|
+
"\t\t\t\t\t\tsp >>>= 0;",
|
|
299
|
+
"\t\t\t\t\t\tcrypto.getRandomValues(loadSlice(sp + 8));",
|
|
300
|
+
"\t\t\t\t\t},",
|
|
301
|
+
"",
|
|
302
|
+
"\t\t\t\t\t// func finalizeRef(v ref)",
|
|
303
|
+
"\t\t\t\t\t\"syscall/js.finalizeRef\": (sp) => {",
|
|
304
|
+
"\t\t\t\t\t\tsp >>>= 0;",
|
|
305
|
+
"\t\t\t\t\t\tconst id = this.mem.getUint32(sp + 8, true);",
|
|
306
|
+
"\t\t\t\t\t\tthis._goRefCounts[id]--;",
|
|
307
|
+
"\t\t\t\t\t\tif (this._goRefCounts[id] === 0) {",
|
|
308
|
+
"\t\t\t\t\t\t\tconst v = this._values[id];",
|
|
309
|
+
"\t\t\t\t\t\t\tthis._values[id] = null;",
|
|
310
|
+
"\t\t\t\t\t\t\tthis._ids.delete(v);",
|
|
311
|
+
"\t\t\t\t\t\t\tthis._idPool.push(id);",
|
|
312
|
+
"\t\t\t\t\t\t}",
|
|
313
|
+
"\t\t\t\t\t},",
|
|
314
|
+
"",
|
|
315
|
+
"\t\t\t\t\t// func stringVal(value string) ref",
|
|
316
|
+
"\t\t\t\t\t\"syscall/js.stringVal\": (sp) => {",
|
|
317
|
+
"\t\t\t\t\t\tsp >>>= 0;",
|
|
318
|
+
"\t\t\t\t\t\tstoreValue(sp + 24, loadString(sp + 8));",
|
|
319
|
+
"\t\t\t\t\t},",
|
|
320
|
+
"",
|
|
321
|
+
"\t\t\t\t\t// func valueGet(v ref, p string) ref",
|
|
322
|
+
"\t\t\t\t\t\"syscall/js.valueGet\": (sp) => {",
|
|
323
|
+
"\t\t\t\t\t\tsp >>>= 0;",
|
|
324
|
+
"\t\t\t\t\t\tconst result = Reflect.get(loadValue(sp + 8), loadString(sp + 16));",
|
|
325
|
+
"\t\t\t\t\t\tsp = this._inst.exports.getsp() >>> 0; // see comment above",
|
|
326
|
+
"\t\t\t\t\t\tstoreValue(sp + 32, result);",
|
|
327
|
+
"\t\t\t\t\t},",
|
|
328
|
+
"",
|
|
329
|
+
"\t\t\t\t\t// func valueSet(v ref, p string, x ref)",
|
|
330
|
+
"\t\t\t\t\t\"syscall/js.valueSet\": (sp) => {",
|
|
331
|
+
"\t\t\t\t\t\tsp >>>= 0;",
|
|
332
|
+
"\t\t\t\t\t\tReflect.set(loadValue(sp + 8), loadString(sp + 16), loadValue(sp + 32));",
|
|
333
|
+
"\t\t\t\t\t},",
|
|
334
|
+
"",
|
|
335
|
+
"\t\t\t\t\t// func valueDelete(v ref, p string)",
|
|
336
|
+
"\t\t\t\t\t\"syscall/js.valueDelete\": (sp) => {",
|
|
337
|
+
"\t\t\t\t\t\tsp >>>= 0;",
|
|
338
|
+
"\t\t\t\t\t\tReflect.deleteProperty(loadValue(sp + 8), loadString(sp + 16));",
|
|
339
|
+
"\t\t\t\t\t},",
|
|
340
|
+
"",
|
|
341
|
+
"\t\t\t\t\t// func valueIndex(v ref, i int) ref",
|
|
342
|
+
"\t\t\t\t\t\"syscall/js.valueIndex\": (sp) => {",
|
|
343
|
+
"\t\t\t\t\t\tsp >>>= 0;",
|
|
344
|
+
"\t\t\t\t\t\tstoreValue(sp + 24, Reflect.get(loadValue(sp + 8), getInt64(sp + 16)));",
|
|
345
|
+
"\t\t\t\t\t},",
|
|
346
|
+
"",
|
|
347
|
+
"\t\t\t\t\t// valueSetIndex(v ref, i int, x ref)",
|
|
348
|
+
"\t\t\t\t\t\"syscall/js.valueSetIndex\": (sp) => {",
|
|
349
|
+
"\t\t\t\t\t\tsp >>>= 0;",
|
|
350
|
+
"\t\t\t\t\t\tReflect.set(loadValue(sp + 8), getInt64(sp + 16), loadValue(sp + 24));",
|
|
351
|
+
"\t\t\t\t\t},",
|
|
352
|
+
"",
|
|
353
|
+
"\t\t\t\t\t// func valueCall(v ref, m string, args []ref) (ref, bool)",
|
|
354
|
+
"\t\t\t\t\t\"syscall/js.valueCall\": (sp) => {",
|
|
355
|
+
"\t\t\t\t\t\tsp >>>= 0;",
|
|
356
|
+
"\t\t\t\t\t\ttry {",
|
|
357
|
+
"\t\t\t\t\t\t\tconst v = loadValue(sp + 8);",
|
|
358
|
+
"\t\t\t\t\t\t\tconst m = Reflect.get(v, loadString(sp + 16));",
|
|
359
|
+
"\t\t\t\t\t\t\tconst args = loadSliceOfValues(sp + 32);",
|
|
360
|
+
"\t\t\t\t\t\t\tconst result = Reflect.apply(m, v, args);",
|
|
361
|
+
"\t\t\t\t\t\t\tsp = this._inst.exports.getsp() >>> 0; // see comment above",
|
|
362
|
+
"\t\t\t\t\t\t\tstoreValue(sp + 56, result);",
|
|
363
|
+
"\t\t\t\t\t\t\tthis.mem.setUint8(sp + 64, 1);",
|
|
364
|
+
"\t\t\t\t\t\t} catch (err) {",
|
|
365
|
+
"\t\t\t\t\t\t\tsp = this._inst.exports.getsp() >>> 0; // see comment above",
|
|
366
|
+
"\t\t\t\t\t\t\tstoreValue(sp + 56, err);",
|
|
367
|
+
"\t\t\t\t\t\t\tthis.mem.setUint8(sp + 64, 0);",
|
|
368
|
+
"\t\t\t\t\t\t}",
|
|
369
|
+
"\t\t\t\t\t},",
|
|
370
|
+
"",
|
|
371
|
+
"\t\t\t\t\t// func valueInvoke(v ref, args []ref) (ref, bool)",
|
|
372
|
+
"\t\t\t\t\t\"syscall/js.valueInvoke\": (sp) => {",
|
|
373
|
+
"\t\t\t\t\t\tsp >>>= 0;",
|
|
374
|
+
"\t\t\t\t\t\ttry {",
|
|
375
|
+
"\t\t\t\t\t\t\tconst v = loadValue(sp + 8);",
|
|
376
|
+
"\t\t\t\t\t\t\tconst args = loadSliceOfValues(sp + 16);",
|
|
377
|
+
"\t\t\t\t\t\t\tconst result = Reflect.apply(v, undefined, args);",
|
|
378
|
+
"\t\t\t\t\t\t\tsp = this._inst.exports.getsp() >>> 0; // see comment above",
|
|
379
|
+
"\t\t\t\t\t\t\tstoreValue(sp + 40, result);",
|
|
380
|
+
"\t\t\t\t\t\t\tthis.mem.setUint8(sp + 48, 1);",
|
|
381
|
+
"\t\t\t\t\t\t} catch (err) {",
|
|
382
|
+
"\t\t\t\t\t\t\tsp = this._inst.exports.getsp() >>> 0; // see comment above",
|
|
383
|
+
"\t\t\t\t\t\t\tstoreValue(sp + 40, err);",
|
|
384
|
+
"\t\t\t\t\t\t\tthis.mem.setUint8(sp + 48, 0);",
|
|
385
|
+
"\t\t\t\t\t\t}",
|
|
386
|
+
"\t\t\t\t\t},",
|
|
387
|
+
"",
|
|
388
|
+
"\t\t\t\t\t// func valueNew(v ref, args []ref) (ref, bool)",
|
|
389
|
+
"\t\t\t\t\t\"syscall/js.valueNew\": (sp) => {",
|
|
390
|
+
"\t\t\t\t\t\tsp >>>= 0;",
|
|
391
|
+
"\t\t\t\t\t\ttry {",
|
|
392
|
+
"\t\t\t\t\t\t\tconst v = loadValue(sp + 8);",
|
|
393
|
+
"\t\t\t\t\t\t\tconst args = loadSliceOfValues(sp + 16);",
|
|
394
|
+
"\t\t\t\t\t\t\tconst result = Reflect.construct(v, args);",
|
|
395
|
+
"\t\t\t\t\t\t\tsp = this._inst.exports.getsp() >>> 0; // see comment above",
|
|
396
|
+
"\t\t\t\t\t\t\tstoreValue(sp + 40, result);",
|
|
397
|
+
"\t\t\t\t\t\t\tthis.mem.setUint8(sp + 48, 1);",
|
|
398
|
+
"\t\t\t\t\t\t} catch (err) {",
|
|
399
|
+
"\t\t\t\t\t\t\tsp = this._inst.exports.getsp() >>> 0; // see comment above",
|
|
400
|
+
"\t\t\t\t\t\t\tstoreValue(sp + 40, err);",
|
|
401
|
+
"\t\t\t\t\t\t\tthis.mem.setUint8(sp + 48, 0);",
|
|
402
|
+
"\t\t\t\t\t\t}",
|
|
403
|
+
"\t\t\t\t\t},",
|
|
404
|
+
"",
|
|
405
|
+
"\t\t\t\t\t// func valueLength(v ref) int",
|
|
406
|
+
"\t\t\t\t\t\"syscall/js.valueLength\": (sp) => {",
|
|
407
|
+
"\t\t\t\t\t\tsp >>>= 0;",
|
|
408
|
+
"\t\t\t\t\t\tsetInt64(sp + 16, parseInt(loadValue(sp + 8).length));",
|
|
409
|
+
"\t\t\t\t\t},",
|
|
410
|
+
"",
|
|
411
|
+
"\t\t\t\t\t// valuePrepareString(v ref) (ref, int)",
|
|
412
|
+
"\t\t\t\t\t\"syscall/js.valuePrepareString\": (sp) => {",
|
|
413
|
+
"\t\t\t\t\t\tsp >>>= 0;",
|
|
414
|
+
"\t\t\t\t\t\tconst str = encoder.encode(String(loadValue(sp + 8)));",
|
|
415
|
+
"\t\t\t\t\t\tstoreValue(sp + 16, str);",
|
|
416
|
+
"\t\t\t\t\t\tsetInt64(sp + 24, str.length);",
|
|
417
|
+
"\t\t\t\t\t},",
|
|
418
|
+
"",
|
|
419
|
+
"\t\t\t\t\t// valueLoadString(v ref, b []byte)",
|
|
420
|
+
"\t\t\t\t\t\"syscall/js.valueLoadString\": (sp) => {",
|
|
421
|
+
"\t\t\t\t\t\tsp >>>= 0;",
|
|
422
|
+
"\t\t\t\t\t\tconst str = loadValue(sp + 8);",
|
|
423
|
+
"\t\t\t\t\t\tloadSlice(sp + 16).set(str);",
|
|
424
|
+
"\t\t\t\t\t},",
|
|
425
|
+
"",
|
|
426
|
+
"\t\t\t\t\t// func valueInstanceOf(v ref, t ref) bool",
|
|
427
|
+
"\t\t\t\t\t\"syscall/js.valueInstanceOf\": (sp) => {",
|
|
428
|
+
"\t\t\t\t\t\tsp >>>= 0;",
|
|
429
|
+
"\t\t\t\t\t\tthis.mem.setUint8(sp + 24, (loadValue(sp + 8) instanceof loadValue(sp + 16)) ? 1 : 0);",
|
|
430
|
+
"\t\t\t\t\t},",
|
|
431
|
+
"",
|
|
432
|
+
"\t\t\t\t\t// func copyBytesToGo(dst []byte, src ref) (int, bool)",
|
|
433
|
+
"\t\t\t\t\t\"syscall/js.copyBytesToGo\": (sp) => {",
|
|
434
|
+
"\t\t\t\t\t\tsp >>>= 0;",
|
|
435
|
+
"\t\t\t\t\t\tconst dst = loadSlice(sp + 8);",
|
|
436
|
+
"\t\t\t\t\t\tconst src = loadValue(sp + 32);",
|
|
437
|
+
"\t\t\t\t\t\tif (!(src instanceof Uint8Array || src instanceof Uint8ClampedArray)) {",
|
|
438
|
+
"\t\t\t\t\t\t\tthis.mem.setUint8(sp + 48, 0);",
|
|
439
|
+
"\t\t\t\t\t\t\treturn;",
|
|
440
|
+
"\t\t\t\t\t\t}",
|
|
441
|
+
"\t\t\t\t\t\tconst toCopy = src.subarray(0, dst.length);",
|
|
442
|
+
"\t\t\t\t\t\tdst.set(toCopy);",
|
|
443
|
+
"\t\t\t\t\t\tsetInt64(sp + 40, toCopy.length);",
|
|
444
|
+
"\t\t\t\t\t\tthis.mem.setUint8(sp + 48, 1);",
|
|
445
|
+
"\t\t\t\t\t},",
|
|
446
|
+
"",
|
|
447
|
+
"\t\t\t\t\t// func copyBytesToJS(dst ref, src []byte) (int, bool)",
|
|
448
|
+
"\t\t\t\t\t\"syscall/js.copyBytesToJS\": (sp) => {",
|
|
449
|
+
"\t\t\t\t\t\tsp >>>= 0;",
|
|
450
|
+
"\t\t\t\t\t\tconst dst = loadValue(sp + 8);",
|
|
451
|
+
"\t\t\t\t\t\tconst src = loadSlice(sp + 16);",
|
|
452
|
+
"\t\t\t\t\t\tif (!(dst instanceof Uint8Array || dst instanceof Uint8ClampedArray)) {",
|
|
453
|
+
"\t\t\t\t\t\t\tthis.mem.setUint8(sp + 48, 0);",
|
|
454
|
+
"\t\t\t\t\t\t\treturn;",
|
|
455
|
+
"\t\t\t\t\t\t}",
|
|
456
|
+
"\t\t\t\t\t\tconst toCopy = src.subarray(0, dst.length);",
|
|
457
|
+
"\t\t\t\t\t\tdst.set(toCopy);",
|
|
458
|
+
"\t\t\t\t\t\tsetInt64(sp + 40, toCopy.length);",
|
|
459
|
+
"\t\t\t\t\t\tthis.mem.setUint8(sp + 48, 1);",
|
|
460
|
+
"\t\t\t\t\t},",
|
|
461
|
+
"",
|
|
462
|
+
"\t\t\t\t\t\"debug\": (value) => {",
|
|
463
|
+
"\t\t\t\t\t\tconsole.log(value);",
|
|
464
|
+
"\t\t\t\t\t},",
|
|
465
|
+
"\t\t\t\t}",
|
|
466
|
+
"\t\t\t};",
|
|
467
|
+
"\t\t}",
|
|
468
|
+
"",
|
|
469
|
+
"\t\tasync run(instance) {",
|
|
470
|
+
"\t\t\tif (!(instance instanceof WebAssembly.Instance)) {",
|
|
471
|
+
"\t\t\t\tthrow new Error(\"Go.run: WebAssembly.Instance expected\");",
|
|
472
|
+
"\t\t\t}",
|
|
473
|
+
"\t\t\tthis._inst = instance;",
|
|
474
|
+
"\t\t\tthis.mem = new DataView(this._inst.exports.mem.buffer);",
|
|
475
|
+
"\t\t\tthis._values = [ // JS values that Go currently has references to, indexed by reference id",
|
|
476
|
+
"\t\t\t\tNaN,",
|
|
477
|
+
"\t\t\t\t0,",
|
|
478
|
+
"\t\t\t\tnull,",
|
|
479
|
+
"\t\t\t\ttrue,",
|
|
480
|
+
"\t\t\t\tfalse,",
|
|
481
|
+
"\t\t\t\tglobalThis,",
|
|
482
|
+
"\t\t\t\tthis,",
|
|
483
|
+
"\t\t\t];",
|
|
484
|
+
"\t\t\tthis._goRefCounts = new Array(this._values.length).fill(Infinity); // number of references that Go has to a JS value, indexed by reference id",
|
|
485
|
+
"\t\t\tthis._ids = new Map([ // mapping from JS values to reference ids",
|
|
486
|
+
"\t\t\t\t[0, 1],",
|
|
487
|
+
"\t\t\t\t[null, 2],",
|
|
488
|
+
"\t\t\t\t[true, 3],",
|
|
489
|
+
"\t\t\t\t[false, 4],",
|
|
490
|
+
"\t\t\t\t[globalThis, 5],",
|
|
491
|
+
"\t\t\t\t[this, 6],",
|
|
492
|
+
"\t\t\t]);",
|
|
493
|
+
"\t\t\tthis._idPool = []; // unused ids that have been garbage collected",
|
|
494
|
+
"\t\t\tthis.exited = false; // whether the Go program has exited",
|
|
495
|
+
"",
|
|
496
|
+
"\t\t\t// Pass command line arguments and environment variables to WebAssembly by writing them to the linear memory.",
|
|
497
|
+
"\t\t\tlet offset = 4096;",
|
|
498
|
+
"",
|
|
499
|
+
"\t\t\tconst strPtr = (str) => {",
|
|
500
|
+
"\t\t\t\tconst ptr = offset;",
|
|
501
|
+
"\t\t\t\tconst bytes = encoder.encode(str + \"\\0\");",
|
|
502
|
+
"\t\t\t\tnew Uint8Array(this.mem.buffer, offset, bytes.length).set(bytes);",
|
|
503
|
+
"\t\t\t\toffset += bytes.length;",
|
|
504
|
+
"\t\t\t\tif (offset % 8 !== 0) {",
|
|
505
|
+
"\t\t\t\t\toffset += 8 - (offset % 8);",
|
|
506
|
+
"\t\t\t\t}",
|
|
507
|
+
"\t\t\t\treturn ptr;",
|
|
508
|
+
"\t\t\t};",
|
|
509
|
+
"",
|
|
510
|
+
"\t\t\tconst argc = this.argv.length;",
|
|
511
|
+
"",
|
|
512
|
+
"\t\t\tconst argvPtrs = [];",
|
|
513
|
+
"\t\t\tthis.argv.forEach((arg) => {",
|
|
514
|
+
"\t\t\t\targvPtrs.push(strPtr(arg));",
|
|
515
|
+
"\t\t\t});",
|
|
516
|
+
"\t\t\targvPtrs.push(0);",
|
|
517
|
+
"",
|
|
518
|
+
"\t\t\tconst keys = Object.keys(this.env).sort();",
|
|
519
|
+
"\t\t\tkeys.forEach((key) => {",
|
|
520
|
+
"\t\t\t\targvPtrs.push(strPtr(`${key}=${this.env[key]}`));",
|
|
521
|
+
"\t\t\t});",
|
|
522
|
+
"\t\t\targvPtrs.push(0);",
|
|
523
|
+
"",
|
|
524
|
+
"\t\t\tconst argv = offset;",
|
|
525
|
+
"\t\t\targvPtrs.forEach((ptr) => {",
|
|
526
|
+
"\t\t\t\tthis.mem.setUint32(offset, ptr, true);",
|
|
527
|
+
"\t\t\t\tthis.mem.setUint32(offset + 4, 0, true);",
|
|
528
|
+
"\t\t\t\toffset += 8;",
|
|
529
|
+
"\t\t\t});",
|
|
530
|
+
"",
|
|
531
|
+
"\t\t\t// The linker guarantees global data starts from at least wasmMinDataAddr.",
|
|
532
|
+
"\t\t\t// Keep in sync with cmd/link/internal/ld/data.go:wasmMinDataAddr.",
|
|
533
|
+
"\t\t\tconst wasmMinDataAddr = 4096 + 8192;",
|
|
534
|
+
"\t\t\tif (offset >= wasmMinDataAddr) {",
|
|
535
|
+
"\t\t\t\tthrow new Error(\"total length of command line and environment variables exceeds limit\");",
|
|
536
|
+
"\t\t\t}",
|
|
537
|
+
"",
|
|
538
|
+
"\t\t\tthis._inst.exports.run(argc, argv);",
|
|
539
|
+
"\t\t\tif (this.exited) {",
|
|
540
|
+
"\t\t\t\tthis._resolveExitPromise();",
|
|
541
|
+
"\t\t\t}",
|
|
542
|
+
"\t\t\tawait this._exitPromise;",
|
|
543
|
+
"\t\t}",
|
|
544
|
+
"",
|
|
545
|
+
"\t\t_resume() {",
|
|
546
|
+
"\t\t\tif (this.exited) {",
|
|
547
|
+
"\t\t\t\tthrow new Error(\"Go program has already exited\");",
|
|
548
|
+
"\t\t\t}",
|
|
549
|
+
"\t\t\tthis._inst.exports.resume();",
|
|
550
|
+
"\t\t\tif (this.exited) {",
|
|
551
|
+
"\t\t\t\tthis._resolveExitPromise();",
|
|
552
|
+
"\t\t\t}",
|
|
553
|
+
"\t\t}",
|
|
554
|
+
"",
|
|
555
|
+
"\t\t_makeFuncWrapper(id) {",
|
|
556
|
+
"\t\t\tconst go = this;",
|
|
557
|
+
"\t\t\treturn function () {",
|
|
558
|
+
"\t\t\t\tconst event = { id: id, this: this, args: arguments };",
|
|
559
|
+
"\t\t\t\tgo._pendingEvent = event;",
|
|
560
|
+
"\t\t\t\tgo._resume();",
|
|
561
|
+
"\t\t\t\treturn event.result;",
|
|
562
|
+
"\t\t\t};",
|
|
563
|
+
"\t\t}",
|
|
564
|
+
"\t}",
|
|
565
|
+
"})();",
|
|
566
|
+
"",
|
|
567
|
+
];
|
|
568
|
+
exports.WASM_EXEC_JS = WASM_EXEC_LINES.join('\n');
|
|
569
|
+
//# sourceMappingURL=wasmExecRuntime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wasmExecRuntime.js","sourceRoot":"","sources":["../../../../src/signers/generated/wasmExecRuntime.ts"],"names":[],"mappings":";;;AAGA,MAAM,eAAe,GAAsB;IACzC,wDAAwD;IACxD,uDAAuD;IACvD,mDAAmD;IACnD,EAAE;IACF,iBAAiB;IACjB,EAAE;IACF,UAAU;IACV,0BAA0B;IAC1B,iDAAiD;IACjD,4BAA4B;IAC5B,iBAAiB;IACjB,MAAM;IACN,EAAE;IACF,yBAAyB;IACzB,2BAA2B;IAC3B,uBAAuB;IACvB,8GAA8G;IAC9G,4BAA4B;IAC5B,2CAA2C;IAC3C,oDAAoD;IACpD,yBAAyB;IACzB,oDAAoD;IACpD,oDAAoD;IACpD,WAAW;IACX,4BAA4B;IAC5B,UAAU;IACV,4DAA4D;IAC5D,2EAA2E;IAC3E,+BAA+B;IAC/B,mBAAmB;IACnB,WAAW;IACX,4CAA4C;IAC5C,4BAA4B;IAC5B,UAAU;IACV,4DAA4D;IAC5D,gEAAgE;IAChE,oDAAoD;IACpD,2DAA2D;IAC3D,+DAA+D;IAC/D,oDAAoD;IACpD,gDAAgD;IAChD,gEAAgE;IAChE,iEAAiE;IACjE,2DAA2D;IAC3D,sDAAsD;IACtD,4DAA4D;IAC5D,kEAAkE;IAClE,qFAAqF;IACrF,wDAAwD;IACxD,yDAAyD;IACzD,2DAA2D;IAC3D,sDAAsD;IACtD,qDAAqD;IACrD,8DAA8D;IAC9D,iEAAiE;IACjE,uDAAuD;IACvD,qEAAqE;IACrE,QAAQ;IACR,KAAK;IACL,EAAE;IACF,8BAA8B;IAC9B,4BAA4B;IAC5B,gCAAgC;IAChC,gCAAgC;IAChC,iCAAiC;IACj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IACzB,EAAE;IACF,kDAAkD;IAClD,+BAA+B;IAC/B,2DAA2D;IAC3D,WAAW;IACX,yBAAyB;IACzB,EAAE;IACF,4BAA4B;IAC5B,mCAAmC;IACnC,gDAAgD;IAChD,kDAAkD;IAClD,sBAAsB;IACtB,WAAW;IACX,EAAE;IACF,kFAAkF;IAClF,0EAA0E;IAC1E,4CAA4C;IAC5C,wCAAwC;IACxC,oGAAoG;IACpG,SAAS;IACT,EAAE;IACF,2CAA2C;IAC3C,0BAA0B;IAC1B,qCAAqC;IACrC,SAAS;IACT,gCAAgC;IAChC,OAAO;IACP,EAAE;IACF,iBAAiB;IACjB,0BAA0B;IAC1B,6DAA6D;IAC7D,SAAS;IACT,oCAAoC;IACpC,0BAA0B;IAC1B,qCAAqC;IACrC,SAAS;IACT,OAAO;IACP,EAAE;IACF,4BAA4B;IAC5B,wBAAwB;IACxB,4BAA4B;IAC5B,gEAAgE;IAChE,mCAAmC;IACnC,uBAAuB;IACvB,8BAA8B;IAC9B,UAAU;IACV,OAAO;IACP,KAAK;IACL,OAAO;IACP,EAAE;CACH,CAAA;AAQY,QAAA,YAAY,GAAW,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA"}
|
|
@@ -6,8 +6,8 @@ import type { LighterApiClient } from '../utils/apiClient.js';
|
|
|
6
6
|
import type { LighterKeyStore } from './LighterKeyStore.js';
|
|
7
7
|
import type { LighterSigner } from './LighterSigner.js';
|
|
8
8
|
export interface LighterSignActionsDeps {
|
|
9
|
-
signer
|
|
10
|
-
keyStore
|
|
9
|
+
signer: LighterSigner;
|
|
10
|
+
keyStore: LighterKeyStore;
|
|
11
11
|
apiClient: LighterApiClient;
|
|
12
12
|
resolveAccountIndex(address: Address): Promise<number>;
|
|
13
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signActions.d.ts","sourceRoot":"","sources":["../../../src/signers/signActions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,kBAAkB,EAA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B,EAC5B,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,kBAAkB,EAAE,EAC3B,GAAG,EAAE,kBAAkB,GAAG,SAAS,GAClC,OAAO,CAAC,wBAAwB,EAAE,CAAC,CAgBrC;AA4RD,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,eAAe,EAAE,EACxB,GAAG,EAAE,kBAAkB,GAAG,SAAS,GAClC,OAAO,CAAC,qBAAqB,EAAE,CAAC,CA6ElC;AASD,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,sBAAsB,EAC5B,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,UAAU,EAAE,EACnB,OAAO,EAAE,OAAO,EAChB,GAAG,CAAC,EAAE,kBAAkB,GACvB,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAsB7B"}
|
|
@@ -11,25 +11,19 @@ const constants_js_1 = require("../constants.js");
|
|
|
11
11
|
const TOKEN_AUTH_MUTATION_KINDS = new Set(['changeAccountTier', 'referralUse']);
|
|
12
12
|
const TOKEN_AUTH_MUTATION_DEADLINE_SECONDS = 5 * 60;
|
|
13
13
|
async function signWasmBlobActions(deps, address, steps, ctx) {
|
|
14
|
-
const { signer, keyStore } = deps;
|
|
15
|
-
if (signer === undefined || keyStore === undefined) {
|
|
16
|
-
throw new perps_sdk_1.PerpsError(perps_types_1.PerpsErrorCode.SDKError, 'lighterProvider.signActions requires `signer` and `keyStore` to be ' +
|
|
17
|
-
'configured at construction.');
|
|
18
|
-
}
|
|
19
|
-
const wasmDeps = { ...deps, signer, keyStore };
|
|
20
14
|
const signed = [];
|
|
21
15
|
for (const step of steps) {
|
|
22
16
|
if (step.action === perps_types_1.ActionType.REGISTER_API_KEY) {
|
|
23
|
-
signed.push(await signRegisterApiKey(
|
|
17
|
+
signed.push(await signRegisterApiKey(deps, address, step, ctx));
|
|
24
18
|
}
|
|
25
19
|
else if (step.action === perps_types_1.ActionType.APPROVE_INTEGRATOR) {
|
|
26
|
-
signed.push(await signApproveIntegrator(
|
|
20
|
+
signed.push(await signApproveIntegrator(deps, address, step, ctx));
|
|
27
21
|
}
|
|
28
22
|
else if (TOKEN_AUTH_MUTATION_KINDS.has(step.wasmSignParams.kind)) {
|
|
29
|
-
await executeTokenAuthMutation(
|
|
23
|
+
await executeTokenAuthMutation(deps, address, step);
|
|
30
24
|
}
|
|
31
25
|
else {
|
|
32
|
-
signed.push(await signStandardWasmAction(
|
|
26
|
+
signed.push(await signStandardWasmAction(deps, address, step));
|
|
33
27
|
}
|
|
34
28
|
}
|
|
35
29
|
return signed;
|