@chainfoundry/chaincodec-wasm-node 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/chaincodec_wasm.d.ts +88 -0
- package/chaincodec_wasm.js +561 -0
- package/chaincodec_wasm_bg.wasm +0 -0
- package/package.json +13 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
export class Eip712Parser {
|
|
5
|
+
free(): void;
|
|
6
|
+
[Symbol.dispose](): void;
|
|
7
|
+
/**
|
|
8
|
+
* Compute the domain separator hash. Returns hex string.
|
|
9
|
+
*/
|
|
10
|
+
domainSeparator(json: string): string;
|
|
11
|
+
constructor();
|
|
12
|
+
/**
|
|
13
|
+
* Parse EIP-712 typed data JSON. Returns parsed structure as JSON string.
|
|
14
|
+
*/
|
|
15
|
+
parseJson(json: string): string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export class EvmCallDecoder {
|
|
19
|
+
private constructor();
|
|
20
|
+
free(): void;
|
|
21
|
+
[Symbol.dispose](): void;
|
|
22
|
+
/**
|
|
23
|
+
* Decode calldata. Returns JSON string.
|
|
24
|
+
*/
|
|
25
|
+
decodeCallJson(calldata_hex: string, function_name?: string | null): string;
|
|
26
|
+
/**
|
|
27
|
+
* Create from Ethereum ABI JSON string.
|
|
28
|
+
*/
|
|
29
|
+
static fromAbiJson(abi_json: string): EvmCallDecoder;
|
|
30
|
+
/**
|
|
31
|
+
* Returns function names as JSON array.
|
|
32
|
+
*/
|
|
33
|
+
functionNamesJson(): string;
|
|
34
|
+
/**
|
|
35
|
+
* Returns the 4-byte selector for a function.
|
|
36
|
+
*/
|
|
37
|
+
selectorFor(name: string): string | undefined;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export class EvmDecoder {
|
|
41
|
+
free(): void;
|
|
42
|
+
[Symbol.dispose](): void;
|
|
43
|
+
/**
|
|
44
|
+
* Decode a batch of events. Input/output are JSON strings.
|
|
45
|
+
*/
|
|
46
|
+
decodeBatchJson(raws_json: string, registry: MemoryRegistry): string;
|
|
47
|
+
/**
|
|
48
|
+
* Decode a single event. Input/output are JSON strings.
|
|
49
|
+
*/
|
|
50
|
+
decodeEventJson(raw_json: string, registry: MemoryRegistry): string;
|
|
51
|
+
/**
|
|
52
|
+
* Compute event fingerprint from raw event JSON.
|
|
53
|
+
*/
|
|
54
|
+
fingerprintJson(raw_json: string): string;
|
|
55
|
+
constructor();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export class EvmEncoder {
|
|
59
|
+
private constructor();
|
|
60
|
+
free(): void;
|
|
61
|
+
[Symbol.dispose](): void;
|
|
62
|
+
/**
|
|
63
|
+
* Encode a function call. `args_json` is a JSON array of NormalizedValues.
|
|
64
|
+
* Returns 0x-prefixed hex calldata.
|
|
65
|
+
*/
|
|
66
|
+
encodeCall(function_name: string, args_json: string): string;
|
|
67
|
+
static fromAbiJson(abi_json: string): EvmEncoder;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export class MemoryRegistry {
|
|
71
|
+
free(): void;
|
|
72
|
+
[Symbol.dispose](): void;
|
|
73
|
+
/**
|
|
74
|
+
* Load schemas from a CSDL YAML string.
|
|
75
|
+
*/
|
|
76
|
+
loadCsdl(csdl: string): number;
|
|
77
|
+
constructor();
|
|
78
|
+
/**
|
|
79
|
+
* Returns all schema names as a JSON array string.
|
|
80
|
+
*/
|
|
81
|
+
schemaNamesJson(): string;
|
|
82
|
+
/**
|
|
83
|
+
* Returns the number of registered schemas.
|
|
84
|
+
*/
|
|
85
|
+
readonly schemaCount: number;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function init_panic_hook(): void;
|
|
@@ -0,0 +1,561 @@
|
|
|
1
|
+
/* @ts-self-types="./chaincodec_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
class Eip712Parser {
|
|
4
|
+
__destroy_into_raw() {
|
|
5
|
+
const ptr = this.__wbg_ptr;
|
|
6
|
+
this.__wbg_ptr = 0;
|
|
7
|
+
Eip712ParserFinalization.unregister(this);
|
|
8
|
+
return ptr;
|
|
9
|
+
}
|
|
10
|
+
free() {
|
|
11
|
+
const ptr = this.__destroy_into_raw();
|
|
12
|
+
wasm.__wbg_eip712parser_free(ptr, 0);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Compute the domain separator hash. Returns hex string.
|
|
16
|
+
* @param {string} json
|
|
17
|
+
* @returns {string}
|
|
18
|
+
*/
|
|
19
|
+
domainSeparator(json) {
|
|
20
|
+
let deferred3_0;
|
|
21
|
+
let deferred3_1;
|
|
22
|
+
try {
|
|
23
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
24
|
+
const len0 = WASM_VECTOR_LEN;
|
|
25
|
+
const ret = wasm.eip712parser_domainSeparator(this.__wbg_ptr, ptr0, len0);
|
|
26
|
+
var ptr2 = ret[0];
|
|
27
|
+
var len2 = ret[1];
|
|
28
|
+
if (ret[3]) {
|
|
29
|
+
ptr2 = 0; len2 = 0;
|
|
30
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
31
|
+
}
|
|
32
|
+
deferred3_0 = ptr2;
|
|
33
|
+
deferred3_1 = len2;
|
|
34
|
+
return getStringFromWasm0(ptr2, len2);
|
|
35
|
+
} finally {
|
|
36
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
constructor() {
|
|
40
|
+
const ret = wasm.eip712parser_new();
|
|
41
|
+
this.__wbg_ptr = ret >>> 0;
|
|
42
|
+
Eip712ParserFinalization.register(this, this.__wbg_ptr, this);
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Parse EIP-712 typed data JSON. Returns parsed structure as JSON string.
|
|
47
|
+
* @param {string} json
|
|
48
|
+
* @returns {string}
|
|
49
|
+
*/
|
|
50
|
+
parseJson(json) {
|
|
51
|
+
let deferred3_0;
|
|
52
|
+
let deferred3_1;
|
|
53
|
+
try {
|
|
54
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
55
|
+
const len0 = WASM_VECTOR_LEN;
|
|
56
|
+
const ret = wasm.eip712parser_parseJson(this.__wbg_ptr, ptr0, len0);
|
|
57
|
+
var ptr2 = ret[0];
|
|
58
|
+
var len2 = ret[1];
|
|
59
|
+
if (ret[3]) {
|
|
60
|
+
ptr2 = 0; len2 = 0;
|
|
61
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
62
|
+
}
|
|
63
|
+
deferred3_0 = ptr2;
|
|
64
|
+
deferred3_1 = len2;
|
|
65
|
+
return getStringFromWasm0(ptr2, len2);
|
|
66
|
+
} finally {
|
|
67
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (Symbol.dispose) Eip712Parser.prototype[Symbol.dispose] = Eip712Parser.prototype.free;
|
|
72
|
+
exports.Eip712Parser = Eip712Parser;
|
|
73
|
+
|
|
74
|
+
class EvmCallDecoder {
|
|
75
|
+
static __wrap(ptr) {
|
|
76
|
+
ptr = ptr >>> 0;
|
|
77
|
+
const obj = Object.create(EvmCallDecoder.prototype);
|
|
78
|
+
obj.__wbg_ptr = ptr;
|
|
79
|
+
EvmCallDecoderFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
80
|
+
return obj;
|
|
81
|
+
}
|
|
82
|
+
__destroy_into_raw() {
|
|
83
|
+
const ptr = this.__wbg_ptr;
|
|
84
|
+
this.__wbg_ptr = 0;
|
|
85
|
+
EvmCallDecoderFinalization.unregister(this);
|
|
86
|
+
return ptr;
|
|
87
|
+
}
|
|
88
|
+
free() {
|
|
89
|
+
const ptr = this.__destroy_into_raw();
|
|
90
|
+
wasm.__wbg_evmcalldecoder_free(ptr, 0);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Decode calldata. Returns JSON string.
|
|
94
|
+
* @param {string} calldata_hex
|
|
95
|
+
* @param {string | null} [function_name]
|
|
96
|
+
* @returns {string}
|
|
97
|
+
*/
|
|
98
|
+
decodeCallJson(calldata_hex, function_name) {
|
|
99
|
+
let deferred4_0;
|
|
100
|
+
let deferred4_1;
|
|
101
|
+
try {
|
|
102
|
+
const ptr0 = passStringToWasm0(calldata_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
103
|
+
const len0 = WASM_VECTOR_LEN;
|
|
104
|
+
var ptr1 = isLikeNone(function_name) ? 0 : passStringToWasm0(function_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
105
|
+
var len1 = WASM_VECTOR_LEN;
|
|
106
|
+
const ret = wasm.evmcalldecoder_decodeCallJson(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
107
|
+
var ptr3 = ret[0];
|
|
108
|
+
var len3 = ret[1];
|
|
109
|
+
if (ret[3]) {
|
|
110
|
+
ptr3 = 0; len3 = 0;
|
|
111
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
112
|
+
}
|
|
113
|
+
deferred4_0 = ptr3;
|
|
114
|
+
deferred4_1 = len3;
|
|
115
|
+
return getStringFromWasm0(ptr3, len3);
|
|
116
|
+
} finally {
|
|
117
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Create from Ethereum ABI JSON string.
|
|
122
|
+
* @param {string} abi_json
|
|
123
|
+
* @returns {EvmCallDecoder}
|
|
124
|
+
*/
|
|
125
|
+
static fromAbiJson(abi_json) {
|
|
126
|
+
const ptr0 = passStringToWasm0(abi_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
127
|
+
const len0 = WASM_VECTOR_LEN;
|
|
128
|
+
const ret = wasm.evmcalldecoder_fromAbiJson(ptr0, len0);
|
|
129
|
+
if (ret[2]) {
|
|
130
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
131
|
+
}
|
|
132
|
+
return EvmCallDecoder.__wrap(ret[0]);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Returns function names as JSON array.
|
|
136
|
+
* @returns {string}
|
|
137
|
+
*/
|
|
138
|
+
functionNamesJson() {
|
|
139
|
+
let deferred1_0;
|
|
140
|
+
let deferred1_1;
|
|
141
|
+
try {
|
|
142
|
+
const ret = wasm.evmcalldecoder_functionNamesJson(this.__wbg_ptr);
|
|
143
|
+
deferred1_0 = ret[0];
|
|
144
|
+
deferred1_1 = ret[1];
|
|
145
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
146
|
+
} finally {
|
|
147
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Returns the 4-byte selector for a function.
|
|
152
|
+
* @param {string} name
|
|
153
|
+
* @returns {string | undefined}
|
|
154
|
+
*/
|
|
155
|
+
selectorFor(name) {
|
|
156
|
+
const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
157
|
+
const len0 = WASM_VECTOR_LEN;
|
|
158
|
+
const ret = wasm.evmcalldecoder_selectorFor(this.__wbg_ptr, ptr0, len0);
|
|
159
|
+
let v2;
|
|
160
|
+
if (ret[0] !== 0) {
|
|
161
|
+
v2 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
162
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
163
|
+
}
|
|
164
|
+
return v2;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
if (Symbol.dispose) EvmCallDecoder.prototype[Symbol.dispose] = EvmCallDecoder.prototype.free;
|
|
168
|
+
exports.EvmCallDecoder = EvmCallDecoder;
|
|
169
|
+
|
|
170
|
+
class EvmDecoder {
|
|
171
|
+
__destroy_into_raw() {
|
|
172
|
+
const ptr = this.__wbg_ptr;
|
|
173
|
+
this.__wbg_ptr = 0;
|
|
174
|
+
EvmDecoderFinalization.unregister(this);
|
|
175
|
+
return ptr;
|
|
176
|
+
}
|
|
177
|
+
free() {
|
|
178
|
+
const ptr = this.__destroy_into_raw();
|
|
179
|
+
wasm.__wbg_evmdecoder_free(ptr, 0);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Decode a batch of events. Input/output are JSON strings.
|
|
183
|
+
* @param {string} raws_json
|
|
184
|
+
* @param {MemoryRegistry} registry
|
|
185
|
+
* @returns {string}
|
|
186
|
+
*/
|
|
187
|
+
decodeBatchJson(raws_json, registry) {
|
|
188
|
+
let deferred3_0;
|
|
189
|
+
let deferred3_1;
|
|
190
|
+
try {
|
|
191
|
+
const ptr0 = passStringToWasm0(raws_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
192
|
+
const len0 = WASM_VECTOR_LEN;
|
|
193
|
+
_assertClass(registry, MemoryRegistry);
|
|
194
|
+
const ret = wasm.evmdecoder_decodeBatchJson(this.__wbg_ptr, ptr0, len0, registry.__wbg_ptr);
|
|
195
|
+
var ptr2 = ret[0];
|
|
196
|
+
var len2 = ret[1];
|
|
197
|
+
if (ret[3]) {
|
|
198
|
+
ptr2 = 0; len2 = 0;
|
|
199
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
200
|
+
}
|
|
201
|
+
deferred3_0 = ptr2;
|
|
202
|
+
deferred3_1 = len2;
|
|
203
|
+
return getStringFromWasm0(ptr2, len2);
|
|
204
|
+
} finally {
|
|
205
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Decode a single event. Input/output are JSON strings.
|
|
210
|
+
* @param {string} raw_json
|
|
211
|
+
* @param {MemoryRegistry} registry
|
|
212
|
+
* @returns {string}
|
|
213
|
+
*/
|
|
214
|
+
decodeEventJson(raw_json, registry) {
|
|
215
|
+
let deferred3_0;
|
|
216
|
+
let deferred3_1;
|
|
217
|
+
try {
|
|
218
|
+
const ptr0 = passStringToWasm0(raw_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
219
|
+
const len0 = WASM_VECTOR_LEN;
|
|
220
|
+
_assertClass(registry, MemoryRegistry);
|
|
221
|
+
const ret = wasm.evmdecoder_decodeEventJson(this.__wbg_ptr, ptr0, len0, registry.__wbg_ptr);
|
|
222
|
+
var ptr2 = ret[0];
|
|
223
|
+
var len2 = ret[1];
|
|
224
|
+
if (ret[3]) {
|
|
225
|
+
ptr2 = 0; len2 = 0;
|
|
226
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
227
|
+
}
|
|
228
|
+
deferred3_0 = ptr2;
|
|
229
|
+
deferred3_1 = len2;
|
|
230
|
+
return getStringFromWasm0(ptr2, len2);
|
|
231
|
+
} finally {
|
|
232
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Compute event fingerprint from raw event JSON.
|
|
237
|
+
* @param {string} raw_json
|
|
238
|
+
* @returns {string}
|
|
239
|
+
*/
|
|
240
|
+
fingerprintJson(raw_json) {
|
|
241
|
+
let deferred3_0;
|
|
242
|
+
let deferred3_1;
|
|
243
|
+
try {
|
|
244
|
+
const ptr0 = passStringToWasm0(raw_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
245
|
+
const len0 = WASM_VECTOR_LEN;
|
|
246
|
+
const ret = wasm.evmdecoder_fingerprintJson(this.__wbg_ptr, ptr0, len0);
|
|
247
|
+
var ptr2 = ret[0];
|
|
248
|
+
var len2 = ret[1];
|
|
249
|
+
if (ret[3]) {
|
|
250
|
+
ptr2 = 0; len2 = 0;
|
|
251
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
252
|
+
}
|
|
253
|
+
deferred3_0 = ptr2;
|
|
254
|
+
deferred3_1 = len2;
|
|
255
|
+
return getStringFromWasm0(ptr2, len2);
|
|
256
|
+
} finally {
|
|
257
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
constructor() {
|
|
261
|
+
const ret = wasm.evmdecoder_new();
|
|
262
|
+
this.__wbg_ptr = ret >>> 0;
|
|
263
|
+
EvmDecoderFinalization.register(this, this.__wbg_ptr, this);
|
|
264
|
+
return this;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
if (Symbol.dispose) EvmDecoder.prototype[Symbol.dispose] = EvmDecoder.prototype.free;
|
|
268
|
+
exports.EvmDecoder = EvmDecoder;
|
|
269
|
+
|
|
270
|
+
class EvmEncoder {
|
|
271
|
+
static __wrap(ptr) {
|
|
272
|
+
ptr = ptr >>> 0;
|
|
273
|
+
const obj = Object.create(EvmEncoder.prototype);
|
|
274
|
+
obj.__wbg_ptr = ptr;
|
|
275
|
+
EvmEncoderFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
276
|
+
return obj;
|
|
277
|
+
}
|
|
278
|
+
__destroy_into_raw() {
|
|
279
|
+
const ptr = this.__wbg_ptr;
|
|
280
|
+
this.__wbg_ptr = 0;
|
|
281
|
+
EvmEncoderFinalization.unregister(this);
|
|
282
|
+
return ptr;
|
|
283
|
+
}
|
|
284
|
+
free() {
|
|
285
|
+
const ptr = this.__destroy_into_raw();
|
|
286
|
+
wasm.__wbg_evmencoder_free(ptr, 0);
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Encode a function call. `args_json` is a JSON array of NormalizedValues.
|
|
290
|
+
* Returns 0x-prefixed hex calldata.
|
|
291
|
+
* @param {string} function_name
|
|
292
|
+
* @param {string} args_json
|
|
293
|
+
* @returns {string}
|
|
294
|
+
*/
|
|
295
|
+
encodeCall(function_name, args_json) {
|
|
296
|
+
let deferred4_0;
|
|
297
|
+
let deferred4_1;
|
|
298
|
+
try {
|
|
299
|
+
const ptr0 = passStringToWasm0(function_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
300
|
+
const len0 = WASM_VECTOR_LEN;
|
|
301
|
+
const ptr1 = passStringToWasm0(args_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
302
|
+
const len1 = WASM_VECTOR_LEN;
|
|
303
|
+
const ret = wasm.evmencoder_encodeCall(this.__wbg_ptr, ptr0, len0, ptr1, len1);
|
|
304
|
+
var ptr3 = ret[0];
|
|
305
|
+
var len3 = ret[1];
|
|
306
|
+
if (ret[3]) {
|
|
307
|
+
ptr3 = 0; len3 = 0;
|
|
308
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
309
|
+
}
|
|
310
|
+
deferred4_0 = ptr3;
|
|
311
|
+
deferred4_1 = len3;
|
|
312
|
+
return getStringFromWasm0(ptr3, len3);
|
|
313
|
+
} finally {
|
|
314
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* @param {string} abi_json
|
|
319
|
+
* @returns {EvmEncoder}
|
|
320
|
+
*/
|
|
321
|
+
static fromAbiJson(abi_json) {
|
|
322
|
+
const ptr0 = passStringToWasm0(abi_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
323
|
+
const len0 = WASM_VECTOR_LEN;
|
|
324
|
+
const ret = wasm.evmencoder_fromAbiJson(ptr0, len0);
|
|
325
|
+
if (ret[2]) {
|
|
326
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
327
|
+
}
|
|
328
|
+
return EvmEncoder.__wrap(ret[0]);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
if (Symbol.dispose) EvmEncoder.prototype[Symbol.dispose] = EvmEncoder.prototype.free;
|
|
332
|
+
exports.EvmEncoder = EvmEncoder;
|
|
333
|
+
|
|
334
|
+
class MemoryRegistry {
|
|
335
|
+
__destroy_into_raw() {
|
|
336
|
+
const ptr = this.__wbg_ptr;
|
|
337
|
+
this.__wbg_ptr = 0;
|
|
338
|
+
MemoryRegistryFinalization.unregister(this);
|
|
339
|
+
return ptr;
|
|
340
|
+
}
|
|
341
|
+
free() {
|
|
342
|
+
const ptr = this.__destroy_into_raw();
|
|
343
|
+
wasm.__wbg_memoryregistry_free(ptr, 0);
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Load schemas from a CSDL YAML string.
|
|
347
|
+
* @param {string} csdl
|
|
348
|
+
* @returns {number}
|
|
349
|
+
*/
|
|
350
|
+
loadCsdl(csdl) {
|
|
351
|
+
const ptr0 = passStringToWasm0(csdl, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
352
|
+
const len0 = WASM_VECTOR_LEN;
|
|
353
|
+
const ret = wasm.memoryregistry_loadCsdl(this.__wbg_ptr, ptr0, len0);
|
|
354
|
+
if (ret[2]) {
|
|
355
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
356
|
+
}
|
|
357
|
+
return ret[0] >>> 0;
|
|
358
|
+
}
|
|
359
|
+
constructor() {
|
|
360
|
+
const ret = wasm.memoryregistry_new();
|
|
361
|
+
this.__wbg_ptr = ret >>> 0;
|
|
362
|
+
MemoryRegistryFinalization.register(this, this.__wbg_ptr, this);
|
|
363
|
+
return this;
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Returns the number of registered schemas.
|
|
367
|
+
* @returns {number}
|
|
368
|
+
*/
|
|
369
|
+
get schemaCount() {
|
|
370
|
+
const ret = wasm.memoryregistry_schemaCount(this.__wbg_ptr);
|
|
371
|
+
return ret >>> 0;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Returns all schema names as a JSON array string.
|
|
375
|
+
* @returns {string}
|
|
376
|
+
*/
|
|
377
|
+
schemaNamesJson() {
|
|
378
|
+
let deferred1_0;
|
|
379
|
+
let deferred1_1;
|
|
380
|
+
try {
|
|
381
|
+
const ret = wasm.memoryregistry_schemaNamesJson(this.__wbg_ptr);
|
|
382
|
+
deferred1_0 = ret[0];
|
|
383
|
+
deferred1_1 = ret[1];
|
|
384
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
385
|
+
} finally {
|
|
386
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
if (Symbol.dispose) MemoryRegistry.prototype[Symbol.dispose] = MemoryRegistry.prototype.free;
|
|
391
|
+
exports.MemoryRegistry = MemoryRegistry;
|
|
392
|
+
|
|
393
|
+
function init_panic_hook() {
|
|
394
|
+
wasm.init_panic_hook();
|
|
395
|
+
}
|
|
396
|
+
exports.init_panic_hook = init_panic_hook;
|
|
397
|
+
|
|
398
|
+
function __wbg_get_imports() {
|
|
399
|
+
const import0 = {
|
|
400
|
+
__proto__: null,
|
|
401
|
+
__wbg_Error_83742b46f01ce22d: function(arg0, arg1) {
|
|
402
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
403
|
+
return ret;
|
|
404
|
+
},
|
|
405
|
+
__wbg___wbindgen_throw_6ddd609b62940d55: function(arg0, arg1) {
|
|
406
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
407
|
+
},
|
|
408
|
+
__wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {
|
|
409
|
+
let deferred0_0;
|
|
410
|
+
let deferred0_1;
|
|
411
|
+
try {
|
|
412
|
+
deferred0_0 = arg0;
|
|
413
|
+
deferred0_1 = arg1;
|
|
414
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
415
|
+
} finally {
|
|
416
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
417
|
+
}
|
|
418
|
+
},
|
|
419
|
+
__wbg_new_227d7c05414eb861: function() {
|
|
420
|
+
const ret = new Error();
|
|
421
|
+
return ret;
|
|
422
|
+
},
|
|
423
|
+
__wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
|
|
424
|
+
const ret = arg1.stack;
|
|
425
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
426
|
+
const len1 = WASM_VECTOR_LEN;
|
|
427
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
428
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
429
|
+
},
|
|
430
|
+
__wbindgen_init_externref_table: function() {
|
|
431
|
+
const table = wasm.__wbindgen_externrefs;
|
|
432
|
+
const offset = table.grow(4);
|
|
433
|
+
table.set(0, undefined);
|
|
434
|
+
table.set(offset + 0, undefined);
|
|
435
|
+
table.set(offset + 1, null);
|
|
436
|
+
table.set(offset + 2, true);
|
|
437
|
+
table.set(offset + 3, false);
|
|
438
|
+
},
|
|
439
|
+
};
|
|
440
|
+
return {
|
|
441
|
+
__proto__: null,
|
|
442
|
+
"./chaincodec_wasm_bg.js": import0,
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
const Eip712ParserFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
447
|
+
? { register: () => {}, unregister: () => {} }
|
|
448
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_eip712parser_free(ptr >>> 0, 1));
|
|
449
|
+
const EvmCallDecoderFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
450
|
+
? { register: () => {}, unregister: () => {} }
|
|
451
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_evmcalldecoder_free(ptr >>> 0, 1));
|
|
452
|
+
const EvmDecoderFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
453
|
+
? { register: () => {}, unregister: () => {} }
|
|
454
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_evmdecoder_free(ptr >>> 0, 1));
|
|
455
|
+
const EvmEncoderFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
456
|
+
? { register: () => {}, unregister: () => {} }
|
|
457
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_evmencoder_free(ptr >>> 0, 1));
|
|
458
|
+
const MemoryRegistryFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
459
|
+
? { register: () => {}, unregister: () => {} }
|
|
460
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_memoryregistry_free(ptr >>> 0, 1));
|
|
461
|
+
|
|
462
|
+
function _assertClass(instance, klass) {
|
|
463
|
+
if (!(instance instanceof klass)) {
|
|
464
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
let cachedDataViewMemory0 = null;
|
|
469
|
+
function getDataViewMemory0() {
|
|
470
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
471
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
472
|
+
}
|
|
473
|
+
return cachedDataViewMemory0;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
function getStringFromWasm0(ptr, len) {
|
|
477
|
+
ptr = ptr >>> 0;
|
|
478
|
+
return decodeText(ptr, len);
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
let cachedUint8ArrayMemory0 = null;
|
|
482
|
+
function getUint8ArrayMemory0() {
|
|
483
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
484
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
485
|
+
}
|
|
486
|
+
return cachedUint8ArrayMemory0;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
function isLikeNone(x) {
|
|
490
|
+
return x === undefined || x === null;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
494
|
+
if (realloc === undefined) {
|
|
495
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
496
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
497
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
498
|
+
WASM_VECTOR_LEN = buf.length;
|
|
499
|
+
return ptr;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
let len = arg.length;
|
|
503
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
504
|
+
|
|
505
|
+
const mem = getUint8ArrayMemory0();
|
|
506
|
+
|
|
507
|
+
let offset = 0;
|
|
508
|
+
|
|
509
|
+
for (; offset < len; offset++) {
|
|
510
|
+
const code = arg.charCodeAt(offset);
|
|
511
|
+
if (code > 0x7F) break;
|
|
512
|
+
mem[ptr + offset] = code;
|
|
513
|
+
}
|
|
514
|
+
if (offset !== len) {
|
|
515
|
+
if (offset !== 0) {
|
|
516
|
+
arg = arg.slice(offset);
|
|
517
|
+
}
|
|
518
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
519
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
520
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
521
|
+
|
|
522
|
+
offset += ret.written;
|
|
523
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
WASM_VECTOR_LEN = offset;
|
|
527
|
+
return ptr;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
function takeFromExternrefTable0(idx) {
|
|
531
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
532
|
+
wasm.__externref_table_dealloc(idx);
|
|
533
|
+
return value;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
537
|
+
cachedTextDecoder.decode();
|
|
538
|
+
function decodeText(ptr, len) {
|
|
539
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
const cachedTextEncoder = new TextEncoder();
|
|
543
|
+
|
|
544
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
545
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
546
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
547
|
+
view.set(buf);
|
|
548
|
+
return {
|
|
549
|
+
read: arg.length,
|
|
550
|
+
written: buf.length
|
|
551
|
+
};
|
|
552
|
+
};
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
let WASM_VECTOR_LEN = 0;
|
|
556
|
+
|
|
557
|
+
const wasmPath = `${__dirname}/chaincodec_wasm_bg.wasm`;
|
|
558
|
+
const wasmBytes = require('fs').readFileSync(wasmPath);
|
|
559
|
+
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
560
|
+
let wasm = new WebAssembly.Instance(wasmModule, __wbg_get_imports()).exports;
|
|
561
|
+
wasm.__wbindgen_start();
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@chainfoundry/chaincodec-wasm-node",
|
|
3
|
+
"description": "WebAssembly bindings for chaincodec — Node.js CJS bundle",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"files": [
|
|
7
|
+
"chaincodec_wasm_bg.wasm",
|
|
8
|
+
"chaincodec_wasm.js",
|
|
9
|
+
"chaincodec_wasm.d.ts"
|
|
10
|
+
],
|
|
11
|
+
"main": "chaincodec_wasm.js",
|
|
12
|
+
"types": "chaincodec_wasm.d.ts"
|
|
13
|
+
}
|