niors 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/niors.js ADDED
@@ -0,0 +1,3048 @@
1
+ /* @ts-self-types="./niors.d.ts" */
2
+
3
+ /**
4
+ * Progress callback for wallet actions (delegation, voting, etc.).
5
+ *
6
+ * JS consumers pass a function `(progress: ActionProgress) => void`.
7
+ */
8
+ export class ActionProgress {
9
+ static __wrap(ptr) {
10
+ ptr = ptr >>> 0;
11
+ const obj = Object.create(ActionProgress.prototype);
12
+ obj.__wbg_ptr = ptr;
13
+ ActionProgressFinalization.register(obj, obj.__wbg_ptr, obj);
14
+ return obj;
15
+ }
16
+ __destroy_into_raw() {
17
+ const ptr = this.__wbg_ptr;
18
+ this.__wbg_ptr = 0;
19
+ ActionProgressFinalization.unregister(this);
20
+ return ptr;
21
+ }
22
+ free() {
23
+ const ptr = this.__destroy_into_raw();
24
+ wasm.__wbg_actionprogress_free(ptr, 0);
25
+ }
26
+ /**
27
+ * @returns {string}
28
+ */
29
+ get detail() {
30
+ let deferred1_0;
31
+ let deferred1_1;
32
+ try {
33
+ const ret = wasm.actionprogress_detail(this.__wbg_ptr);
34
+ deferred1_0 = ret[0];
35
+ deferred1_1 = ret[1];
36
+ return getStringFromWasm0(ret[0], ret[1]);
37
+ } finally {
38
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
39
+ }
40
+ }
41
+ /**
42
+ * @returns {string}
43
+ */
44
+ get step() {
45
+ let deferred1_0;
46
+ let deferred1_1;
47
+ try {
48
+ const ret = wasm.actionprogress_step(this.__wbg_ptr);
49
+ deferred1_0 = ret[0];
50
+ deferred1_1 = ret[1];
51
+ return getStringFromWasm0(ret[0], ret[1]);
52
+ } finally {
53
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
54
+ }
55
+ }
56
+ /**
57
+ * @returns {string | undefined}
58
+ */
59
+ get tx_hash() {
60
+ const ret = wasm.actionprogress_tx_hash(this.__wbg_ptr);
61
+ let v1;
62
+ if (ret[0] !== 0) {
63
+ v1 = getStringFromWasm0(ret[0], ret[1]).slice();
64
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
65
+ }
66
+ return v1;
67
+ }
68
+ }
69
+ if (Symbol.dispose) ActionProgress.prototype[Symbol.dispose] = ActionProgress.prototype.free;
70
+
71
+ /**
72
+ * CIP-30 error codes.
73
+ * @enum {-1 | -2 | -3 | -4}
74
+ */
75
+ export const Cip30ErrorCode = Object.freeze({
76
+ InvalidRequest: -1, "-1": "InvalidRequest",
77
+ InternalError: -2, "-2": "InternalError",
78
+ Refused: -3, "-3": "Refused",
79
+ AccountChange: -4, "-4": "AccountChange",
80
+ });
81
+
82
+ /**
83
+ * CIP-0008 data signature returned by signData.
84
+ */
85
+ export class DataSignature {
86
+ static __wrap(ptr) {
87
+ ptr = ptr >>> 0;
88
+ const obj = Object.create(DataSignature.prototype);
89
+ obj.__wbg_ptr = ptr;
90
+ DataSignatureFinalization.register(obj, obj.__wbg_ptr, obj);
91
+ return obj;
92
+ }
93
+ __destroy_into_raw() {
94
+ const ptr = this.__wbg_ptr;
95
+ this.__wbg_ptr = 0;
96
+ DataSignatureFinalization.unregister(this);
97
+ return ptr;
98
+ }
99
+ free() {
100
+ const ptr = this.__destroy_into_raw();
101
+ wasm.__wbg_datasignature_free(ptr, 0);
102
+ }
103
+ /**
104
+ * @returns {string}
105
+ */
106
+ get key() {
107
+ let deferred1_0;
108
+ let deferred1_1;
109
+ try {
110
+ const ret = wasm.datasignature_key(this.__wbg_ptr);
111
+ deferred1_0 = ret[0];
112
+ deferred1_1 = ret[1];
113
+ return getStringFromWasm0(ret[0], ret[1]);
114
+ } finally {
115
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
116
+ }
117
+ }
118
+ /**
119
+ * @returns {string}
120
+ */
121
+ get signature() {
122
+ let deferred1_0;
123
+ let deferred1_1;
124
+ try {
125
+ const ret = wasm.datasignature_signature(this.__wbg_ptr);
126
+ deferred1_0 = ret[0];
127
+ deferred1_1 = ret[1];
128
+ return getStringFromWasm0(ret[0], ret[1]);
129
+ } finally {
130
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
131
+ }
132
+ }
133
+ }
134
+ if (Symbol.dispose) DataSignature.prototype[Symbol.dispose] = DataSignature.prototype.free;
135
+
136
+ /**
137
+ * CIP-30 wallet extension descriptor.
138
+ */
139
+ export class Extension {
140
+ __destroy_into_raw() {
141
+ const ptr = this.__wbg_ptr;
142
+ this.__wbg_ptr = 0;
143
+ ExtensionFinalization.unregister(this);
144
+ return ptr;
145
+ }
146
+ free() {
147
+ const ptr = this.__destroy_into_raw();
148
+ wasm.__wbg_extension_free(ptr, 0);
149
+ }
150
+ /**
151
+ * @returns {number}
152
+ */
153
+ get cip() {
154
+ const ret = wasm.extension_cip(this.__wbg_ptr);
155
+ return ret >>> 0;
156
+ }
157
+ /**
158
+ * @param {number} cip
159
+ */
160
+ constructor(cip) {
161
+ const ret = wasm.extension_new(cip);
162
+ this.__wbg_ptr = ret >>> 0;
163
+ ExtensionFinalization.register(this, this.__wbg_ptr, this);
164
+ return this;
165
+ }
166
+ }
167
+ if (Symbol.dispose) Extension.prototype[Symbol.dispose] = Extension.prototype.free;
168
+
169
+ /**
170
+ * Cardano network identifier.
171
+ * @enum {0 | 1}
172
+ */
173
+ export const NetworkId = Object.freeze({
174
+ Testnet: 0, "0": "Testnet",
175
+ Mainnet: 1, "1": "Mainnet",
176
+ });
177
+
178
+ /**
179
+ * A Cardano address (Base, Enterprise, Reward, Pointer, or Byron).
180
+ */
181
+ export class NioAddress {
182
+ static __wrap(ptr) {
183
+ ptr = ptr >>> 0;
184
+ const obj = Object.create(NioAddress.prototype);
185
+ obj.__wbg_ptr = ptr;
186
+ NioAddressFinalization.register(obj, obj.__wbg_ptr, obj);
187
+ return obj;
188
+ }
189
+ __destroy_into_raw() {
190
+ const ptr = this.__wbg_ptr;
191
+ this.__wbg_ptr = 0;
192
+ NioAddressFinalization.unregister(this);
193
+ return ptr;
194
+ }
195
+ free() {
196
+ const ptr = this.__destroy_into_raw();
197
+ wasm.__wbg_nioaddress_free(ptr, 0);
198
+ }
199
+ /**
200
+ * Create from a bech32 string (e.g. "addr1q..." or "addr_test1q...").
201
+ * @param {string} bech32
202
+ */
203
+ constructor(bech32) {
204
+ const ptr0 = passStringToWasm0(bech32, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
205
+ const len0 = WASM_VECTOR_LEN;
206
+ const ret = wasm.nioaddress_from_bech32(ptr0, len0);
207
+ if (ret[2]) {
208
+ throw takeFromExternrefTable0(ret[1]);
209
+ }
210
+ this.__wbg_ptr = ret[0] >>> 0;
211
+ NioAddressFinalization.register(this, this.__wbg_ptr, this);
212
+ return this;
213
+ }
214
+ /**
215
+ * Deserialize from CBOR hex (as returned by CIP-30 wallet APIs).
216
+ * @param {string} hex_str
217
+ * @returns {NioAddress}
218
+ */
219
+ static from_cbor_hex(hex_str) {
220
+ const ptr0 = passStringToWasm0(hex_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
221
+ const len0 = WASM_VECTOR_LEN;
222
+ const ret = wasm.nioaddress_from_cbor_hex(ptr0, len0);
223
+ if (ret[2]) {
224
+ throw takeFromExternrefTable0(ret[1]);
225
+ }
226
+ return NioAddress.__wrap(ret[0]);
227
+ }
228
+ /**
229
+ * Deserialize from raw bytes hex.
230
+ * @param {string} hex_str
231
+ * @returns {NioAddress}
232
+ */
233
+ static from_raw_bytes_hex(hex_str) {
234
+ const ptr0 = passStringToWasm0(hex_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
235
+ const len0 = WASM_VECTOR_LEN;
236
+ const ret = wasm.nioaddress_from_raw_bytes_hex(ptr0, len0);
237
+ if (ret[2]) {
238
+ throw takeFromExternrefTable0(ret[1]);
239
+ }
240
+ return NioAddress.__wrap(ret[0]);
241
+ }
242
+ /**
243
+ * Get the network ID (0 = testnet, 1 = mainnet).
244
+ * @returns {number}
245
+ */
246
+ network_id() {
247
+ const ret = wasm.nioaddress_network_id(this.__wbg_ptr);
248
+ if (ret[2]) {
249
+ throw takeFromExternrefTable0(ret[1]);
250
+ }
251
+ return ret[0];
252
+ }
253
+ /**
254
+ * Get the payment credential, if present.
255
+ * @returns {NioCredential | undefined}
256
+ */
257
+ payment_credential() {
258
+ const ret = wasm.nioaddress_payment_credential(this.__wbg_ptr);
259
+ return ret === 0 ? undefined : NioCredential.__wrap(ret);
260
+ }
261
+ /**
262
+ * Get the staking/delegation credential, if present.
263
+ * @returns {NioCredential | undefined}
264
+ */
265
+ staking_credential() {
266
+ const ret = wasm.nioaddress_staking_credential(this.__wbg_ptr);
267
+ return ret === 0 ? undefined : NioCredential.__wrap(ret);
268
+ }
269
+ /**
270
+ * Serialize to bech32 string.
271
+ * @returns {string}
272
+ */
273
+ to_bech32() {
274
+ let deferred2_0;
275
+ let deferred2_1;
276
+ try {
277
+ const ret = wasm.nioaddress_to_bech32(this.__wbg_ptr);
278
+ var ptr1 = ret[0];
279
+ var len1 = ret[1];
280
+ if (ret[3]) {
281
+ ptr1 = 0; len1 = 0;
282
+ throw takeFromExternrefTable0(ret[2]);
283
+ }
284
+ deferred2_0 = ptr1;
285
+ deferred2_1 = len1;
286
+ return getStringFromWasm0(ptr1, len1);
287
+ } finally {
288
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
289
+ }
290
+ }
291
+ /**
292
+ * Serialize to CBOR hex.
293
+ * @returns {string}
294
+ */
295
+ to_cbor_hex() {
296
+ let deferred1_0;
297
+ let deferred1_1;
298
+ try {
299
+ const ret = wasm.nioaddress_to_cbor_hex(this.__wbg_ptr);
300
+ deferred1_0 = ret[0];
301
+ deferred1_1 = ret[1];
302
+ return getStringFromWasm0(ret[0], ret[1]);
303
+ } finally {
304
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
305
+ }
306
+ }
307
+ /**
308
+ * Serialize to raw bytes hex.
309
+ * @returns {string}
310
+ */
311
+ to_raw_bytes_hex() {
312
+ let deferred1_0;
313
+ let deferred1_1;
314
+ try {
315
+ const ret = wasm.nioaddress_to_raw_bytes_hex(this.__wbg_ptr);
316
+ deferred1_0 = ret[0];
317
+ deferred1_1 = ret[1];
318
+ return getStringFromWasm0(ret[0], ret[1]);
319
+ } finally {
320
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
321
+ }
322
+ }
323
+ }
324
+ if (Symbol.dispose) NioAddress.prototype[Symbol.dispose] = NioAddress.prototype.free;
325
+
326
+ /**
327
+ * A wrapped Cardano certificate.
328
+ */
329
+ export class NioCertificate {
330
+ static __wrap(ptr) {
331
+ ptr = ptr >>> 0;
332
+ const obj = Object.create(NioCertificate.prototype);
333
+ obj.__wbg_ptr = ptr;
334
+ NioCertificateFinalization.register(obj, obj.__wbg_ptr, obj);
335
+ return obj;
336
+ }
337
+ __destroy_into_raw() {
338
+ const ptr = this.__wbg_ptr;
339
+ this.__wbg_ptr = 0;
340
+ NioCertificateFinalization.unregister(this);
341
+ return ptr;
342
+ }
343
+ free() {
344
+ const ptr = this.__destroy_into_raw();
345
+ wasm.__wbg_niocertificate_free(ptr, 0);
346
+ }
347
+ }
348
+ if (Symbol.dispose) NioCertificate.prototype[Symbol.dispose] = NioCertificate.prototype.free;
349
+
350
+ /**
351
+ * Factory for creating Cardano certificates.
352
+ */
353
+ export class NioCertificateFactory {
354
+ __destroy_into_raw() {
355
+ const ptr = this.__wbg_ptr;
356
+ this.__wbg_ptr = 0;
357
+ NioCertificateFactoryFinalization.unregister(this);
358
+ return ptr;
359
+ }
360
+ free() {
361
+ const ptr = this.__destroy_into_raw();
362
+ wasm.__wbg_niocertificatefactory_free(ptr, 0);
363
+ }
364
+ /**
365
+ * Create a Conway-era registration certificate (with deposit).
366
+ * @param {string} stake_credential_hex
367
+ * @param {boolean} is_script
368
+ * @param {bigint} deposit
369
+ * @returns {NioCertificate}
370
+ */
371
+ static reg_cert(stake_credential_hex, is_script, deposit) {
372
+ const ptr0 = passStringToWasm0(stake_credential_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
373
+ const len0 = WASM_VECTOR_LEN;
374
+ const ret = wasm.niocertificatefactory_reg_cert(ptr0, len0, is_script, deposit);
375
+ if (ret[2]) {
376
+ throw takeFromExternrefTable0(ret[1]);
377
+ }
378
+ return NioCertificate.__wrap(ret[0]);
379
+ }
380
+ /**
381
+ * Register a DRep.
382
+ * @param {string} drep_credential_hex
383
+ * @param {boolean} is_script
384
+ * @param {bigint} deposit
385
+ * @param {string | null} [anchor_url]
386
+ * @param {string | null} [anchor_hash_hex]
387
+ * @returns {NioCertificate}
388
+ */
389
+ static reg_drep_cert(drep_credential_hex, is_script, deposit, anchor_url, anchor_hash_hex) {
390
+ const ptr0 = passStringToWasm0(drep_credential_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
391
+ const len0 = WASM_VECTOR_LEN;
392
+ var ptr1 = isLikeNone(anchor_url) ? 0 : passStringToWasm0(anchor_url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
393
+ var len1 = WASM_VECTOR_LEN;
394
+ var ptr2 = isLikeNone(anchor_hash_hex) ? 0 : passStringToWasm0(anchor_hash_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
395
+ var len2 = WASM_VECTOR_LEN;
396
+ const ret = wasm.niocertificatefactory_reg_drep_cert(ptr0, len0, is_script, deposit, ptr1, len1, ptr2, len2);
397
+ if (ret[2]) {
398
+ throw takeFromExternrefTable0(ret[1]);
399
+ }
400
+ return NioCertificate.__wrap(ret[0]);
401
+ }
402
+ /**
403
+ * Create a stake delegation certificate to a pool.
404
+ * @param {string} stake_credential_hex
405
+ * @param {boolean} is_script
406
+ * @param {string} pool_keyhash_hex
407
+ * @returns {NioCertificate}
408
+ */
409
+ static stake_delegation(stake_credential_hex, is_script, pool_keyhash_hex) {
410
+ const ptr0 = passStringToWasm0(stake_credential_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
411
+ const len0 = WASM_VECTOR_LEN;
412
+ const ptr1 = passStringToWasm0(pool_keyhash_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
413
+ const len1 = WASM_VECTOR_LEN;
414
+ const ret = wasm.niocertificatefactory_stake_delegation(ptr0, len0, is_script, ptr1, len1);
415
+ if (ret[2]) {
416
+ throw takeFromExternrefTable0(ret[1]);
417
+ }
418
+ return NioCertificate.__wrap(ret[0]);
419
+ }
420
+ /**
421
+ * Create a stake deregistration certificate (legacy, no deposit refund).
422
+ * @param {string} stake_credential_hex
423
+ * @param {boolean} is_script
424
+ * @returns {NioCertificate}
425
+ */
426
+ static stake_deregistration(stake_credential_hex, is_script) {
427
+ const ptr0 = passStringToWasm0(stake_credential_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
428
+ const len0 = WASM_VECTOR_LEN;
429
+ const ret = wasm.niocertificatefactory_stake_deregistration(ptr0, len0, is_script);
430
+ if (ret[2]) {
431
+ throw takeFromExternrefTable0(ret[1]);
432
+ }
433
+ return NioCertificate.__wrap(ret[0]);
434
+ }
435
+ /**
436
+ * Create a stake registration certificate (legacy, no deposit).
437
+ * @param {string} stake_credential_hex
438
+ * @param {boolean} is_script
439
+ * @returns {NioCertificate}
440
+ */
441
+ static stake_registration(stake_credential_hex, is_script) {
442
+ const ptr0 = passStringToWasm0(stake_credential_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
443
+ const len0 = WASM_VECTOR_LEN;
444
+ const ret = wasm.niocertificatefactory_stake_registration(ptr0, len0, is_script);
445
+ if (ret[2]) {
446
+ throw takeFromExternrefTable0(ret[1]);
447
+ }
448
+ return NioCertificate.__wrap(ret[0]);
449
+ }
450
+ /**
451
+ * Create a combined stake + vote delegation certificate.
452
+ * @param {string} stake_credential_hex
453
+ * @param {boolean} is_script
454
+ * @param {string} pool_keyhash_hex
455
+ * @param {NioDRep} drep
456
+ * @returns {NioCertificate}
457
+ */
458
+ static stake_vote_deleg_cert(stake_credential_hex, is_script, pool_keyhash_hex, drep) {
459
+ const ptr0 = passStringToWasm0(stake_credential_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
460
+ const len0 = WASM_VECTOR_LEN;
461
+ const ptr1 = passStringToWasm0(pool_keyhash_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
462
+ const len1 = WASM_VECTOR_LEN;
463
+ _assertClass(drep, NioDRep);
464
+ const ret = wasm.niocertificatefactory_stake_vote_deleg_cert(ptr0, len0, is_script, ptr1, len1, drep.__wbg_ptr);
465
+ if (ret[2]) {
466
+ throw takeFromExternrefTable0(ret[1]);
467
+ }
468
+ return NioCertificate.__wrap(ret[0]);
469
+ }
470
+ /**
471
+ * Create a Conway-era unregistration certificate (with deposit refund).
472
+ * @param {string} stake_credential_hex
473
+ * @param {boolean} is_script
474
+ * @param {bigint} deposit
475
+ * @returns {NioCertificate}
476
+ */
477
+ static unreg_cert(stake_credential_hex, is_script, deposit) {
478
+ const ptr0 = passStringToWasm0(stake_credential_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
479
+ const len0 = WASM_VECTOR_LEN;
480
+ const ret = wasm.niocertificatefactory_unreg_cert(ptr0, len0, is_script, deposit);
481
+ if (ret[2]) {
482
+ throw takeFromExternrefTable0(ret[1]);
483
+ }
484
+ return NioCertificate.__wrap(ret[0]);
485
+ }
486
+ /**
487
+ * Unregister a DRep.
488
+ * @param {string} drep_credential_hex
489
+ * @param {boolean} is_script
490
+ * @param {bigint} deposit
491
+ * @returns {NioCertificate}
492
+ */
493
+ static unreg_drep_cert(drep_credential_hex, is_script, deposit) {
494
+ const ptr0 = passStringToWasm0(drep_credential_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
495
+ const len0 = WASM_VECTOR_LEN;
496
+ const ret = wasm.niocertificatefactory_unreg_drep_cert(ptr0, len0, is_script, deposit);
497
+ if (ret[2]) {
498
+ throw takeFromExternrefTable0(ret[1]);
499
+ }
500
+ return NioCertificate.__wrap(ret[0]);
501
+ }
502
+ /**
503
+ * Update a DRep.
504
+ * @param {string} drep_credential_hex
505
+ * @param {boolean} is_script
506
+ * @param {string | null} [anchor_url]
507
+ * @param {string | null} [anchor_hash_hex]
508
+ * @returns {NioCertificate}
509
+ */
510
+ static update_drep_cert(drep_credential_hex, is_script, anchor_url, anchor_hash_hex) {
511
+ const ptr0 = passStringToWasm0(drep_credential_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
512
+ const len0 = WASM_VECTOR_LEN;
513
+ var ptr1 = isLikeNone(anchor_url) ? 0 : passStringToWasm0(anchor_url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
514
+ var len1 = WASM_VECTOR_LEN;
515
+ var ptr2 = isLikeNone(anchor_hash_hex) ? 0 : passStringToWasm0(anchor_hash_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
516
+ var len2 = WASM_VECTOR_LEN;
517
+ const ret = wasm.niocertificatefactory_update_drep_cert(ptr0, len0, is_script, ptr1, len1, ptr2, len2);
518
+ if (ret[2]) {
519
+ throw takeFromExternrefTable0(ret[1]);
520
+ }
521
+ return NioCertificate.__wrap(ret[0]);
522
+ }
523
+ /**
524
+ * Create a vote delegation certificate.
525
+ * @param {string} stake_credential_hex
526
+ * @param {boolean} is_script
527
+ * @param {NioDRep} drep
528
+ * @returns {NioCertificate}
529
+ */
530
+ static vote_deleg_cert(stake_credential_hex, is_script, drep) {
531
+ const ptr0 = passStringToWasm0(stake_credential_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
532
+ const len0 = WASM_VECTOR_LEN;
533
+ _assertClass(drep, NioDRep);
534
+ const ret = wasm.niocertificatefactory_vote_deleg_cert(ptr0, len0, is_script, drep.__wbg_ptr);
535
+ if (ret[2]) {
536
+ throw takeFromExternrefTable0(ret[1]);
537
+ }
538
+ return NioCertificate.__wrap(ret[0]);
539
+ }
540
+ }
541
+ if (Symbol.dispose) NioCertificateFactory.prototype[Symbol.dispose] = NioCertificateFactory.prototype.free;
542
+
543
+ /**
544
+ * A credential (key hash or script hash).
545
+ */
546
+ export class NioCredential {
547
+ static __wrap(ptr) {
548
+ ptr = ptr >>> 0;
549
+ const obj = Object.create(NioCredential.prototype);
550
+ obj.__wbg_ptr = ptr;
551
+ NioCredentialFinalization.register(obj, obj.__wbg_ptr, obj);
552
+ return obj;
553
+ }
554
+ __destroy_into_raw() {
555
+ const ptr = this.__wbg_ptr;
556
+ this.__wbg_ptr = 0;
557
+ NioCredentialFinalization.unregister(this);
558
+ return ptr;
559
+ }
560
+ free() {
561
+ const ptr = this.__destroy_into_raw();
562
+ wasm.__wbg_niocredential_free(ptr, 0);
563
+ }
564
+ /**
565
+ * Create a key-hash credential from a hex-encoded Ed25519 key hash.
566
+ * @param {string} hex_str
567
+ * @returns {NioCredential}
568
+ */
569
+ static from_keyhash(hex_str) {
570
+ const ptr0 = passStringToWasm0(hex_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
571
+ const len0 = WASM_VECTOR_LEN;
572
+ const ret = wasm.niocredential_from_keyhash(ptr0, len0);
573
+ if (ret[2]) {
574
+ throw takeFromExternrefTable0(ret[1]);
575
+ }
576
+ return NioCredential.__wrap(ret[0]);
577
+ }
578
+ /**
579
+ * Create a script-hash credential from a hex-encoded script hash.
580
+ * @param {string} hex_str
581
+ * @returns {NioCredential}
582
+ */
583
+ static from_scripthash(hex_str) {
584
+ const ptr0 = passStringToWasm0(hex_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
585
+ const len0 = WASM_VECTOR_LEN;
586
+ const ret = wasm.niocredential_from_scripthash(ptr0, len0);
587
+ if (ret[2]) {
588
+ throw takeFromExternrefTable0(ret[1]);
589
+ }
590
+ return NioCredential.__wrap(ret[0]);
591
+ }
592
+ /**
593
+ * Check if this is a key-hash credential.
594
+ * @returns {boolean}
595
+ */
596
+ is_key() {
597
+ const ret = wasm.niocredential_is_key(this.__wbg_ptr);
598
+ return ret !== 0;
599
+ }
600
+ /**
601
+ * Check if this is a script-hash credential.
602
+ * @returns {boolean}
603
+ */
604
+ is_script() {
605
+ const ret = wasm.niocredential_is_script(this.__wbg_ptr);
606
+ return ret !== 0;
607
+ }
608
+ /**
609
+ * Get the hash as hex string.
610
+ * @returns {string}
611
+ */
612
+ to_hex() {
613
+ let deferred1_0;
614
+ let deferred1_1;
615
+ try {
616
+ const ret = wasm.niocredential_to_hex(this.__wbg_ptr);
617
+ deferred1_0 = ret[0];
618
+ deferred1_1 = ret[1];
619
+ return getStringFromWasm0(ret[0], ret[1]);
620
+ } finally {
621
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
622
+ }
623
+ }
624
+ }
625
+ if (Symbol.dispose) NioCredential.prototype[Symbol.dispose] = NioCredential.prototype.free;
626
+
627
+ /**
628
+ * A Delegation Representative (DRep) for governance voting.
629
+ */
630
+ export class NioDRep {
631
+ static __wrap(ptr) {
632
+ ptr = ptr >>> 0;
633
+ const obj = Object.create(NioDRep.prototype);
634
+ obj.__wbg_ptr = ptr;
635
+ NioDRepFinalization.register(obj, obj.__wbg_ptr, obj);
636
+ return obj;
637
+ }
638
+ __destroy_into_raw() {
639
+ const ptr = this.__wbg_ptr;
640
+ this.__wbg_ptr = 0;
641
+ NioDRepFinalization.unregister(this);
642
+ return ptr;
643
+ }
644
+ free() {
645
+ const ptr = this.__destroy_into_raw();
646
+ wasm.__wbg_niodrep_free(ptr, 0);
647
+ }
648
+ /**
649
+ * Always-Abstain DRep.
650
+ * @returns {NioDRep}
651
+ */
652
+ static always_abstain() {
653
+ const ret = wasm.niodrep_always_abstain();
654
+ return NioDRep.__wrap(ret);
655
+ }
656
+ /**
657
+ * Always-NoConfidence DRep.
658
+ * @returns {NioDRep}
659
+ */
660
+ static always_no_confidence() {
661
+ const ret = wasm.niodrep_always_no_confidence();
662
+ return NioDRep.__wrap(ret);
663
+ }
664
+ /**
665
+ * DRep from a key hash.
666
+ * @param {string} hex_str
667
+ * @returns {NioDRep}
668
+ */
669
+ static from_keyhash(hex_str) {
670
+ const ptr0 = passStringToWasm0(hex_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
671
+ const len0 = WASM_VECTOR_LEN;
672
+ const ret = wasm.niodrep_from_keyhash(ptr0, len0);
673
+ if (ret[2]) {
674
+ throw takeFromExternrefTable0(ret[1]);
675
+ }
676
+ return NioDRep.__wrap(ret[0]);
677
+ }
678
+ /**
679
+ * DRep from a script hash.
680
+ * @param {string} hex_str
681
+ * @returns {NioDRep}
682
+ */
683
+ static from_scripthash(hex_str) {
684
+ const ptr0 = passStringToWasm0(hex_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
685
+ const len0 = WASM_VECTOR_LEN;
686
+ const ret = wasm.niodrep_from_scripthash(ptr0, len0);
687
+ if (ret[2]) {
688
+ throw takeFromExternrefTable0(ret[1]);
689
+ }
690
+ return NioDRep.__wrap(ret[0]);
691
+ }
692
+ }
693
+ if (Symbol.dispose) NioDRep.prototype[Symbol.dispose] = NioDRep.prototype.free;
694
+
695
+ /**
696
+ * Execution units for Plutus script evaluation.
697
+ */
698
+ export class NioExUnits {
699
+ __destroy_into_raw() {
700
+ const ptr = this.__wbg_ptr;
701
+ this.__wbg_ptr = 0;
702
+ NioExUnitsFinalization.unregister(this);
703
+ return ptr;
704
+ }
705
+ free() {
706
+ const ptr = this.__destroy_into_raw();
707
+ wasm.__wbg_nioexunits_free(ptr, 0);
708
+ }
709
+ /**
710
+ * @returns {bigint}
711
+ */
712
+ mem() {
713
+ const ret = wasm.nioexunits_mem(this.__wbg_ptr);
714
+ return BigInt.asUintN(64, ret);
715
+ }
716
+ /**
717
+ * @param {bigint} mem
718
+ * @param {bigint} steps
719
+ */
720
+ constructor(mem, steps) {
721
+ const ret = wasm.nioexunits_new(mem, steps);
722
+ this.__wbg_ptr = ret >>> 0;
723
+ NioExUnitsFinalization.register(this, this.__wbg_ptr, this);
724
+ return this;
725
+ }
726
+ /**
727
+ * @returns {bigint}
728
+ */
729
+ steps() {
730
+ const ret = wasm.nioexunits_steps(this.__wbg_ptr);
731
+ return BigInt.asUintN(64, ret);
732
+ }
733
+ }
734
+ if (Symbol.dispose) NioExUnits.prototype[Symbol.dispose] = NioExUnits.prototype.free;
735
+
736
+ /**
737
+ * A governance action ID (transaction hash + index).
738
+ */
739
+ export class NioGovActionId {
740
+ __destroy_into_raw() {
741
+ const ptr = this.__wbg_ptr;
742
+ this.__wbg_ptr = 0;
743
+ NioGovActionIdFinalization.unregister(this);
744
+ return ptr;
745
+ }
746
+ free() {
747
+ const ptr = this.__destroy_into_raw();
748
+ wasm.__wbg_niogovactionid_free(ptr, 0);
749
+ }
750
+ /**
751
+ * @param {string} tx_hash_hex
752
+ * @param {bigint} index
753
+ */
754
+ constructor(tx_hash_hex, index) {
755
+ const ptr0 = passStringToWasm0(tx_hash_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
756
+ const len0 = WASM_VECTOR_LEN;
757
+ const ret = wasm.niogovactionid_new(ptr0, len0, index);
758
+ if (ret[2]) {
759
+ throw takeFromExternrefTable0(ret[1]);
760
+ }
761
+ this.__wbg_ptr = ret[0] >>> 0;
762
+ NioGovActionIdFinalization.register(this, this.__wbg_ptr, this);
763
+ return this;
764
+ }
765
+ }
766
+ if (Symbol.dispose) NioGovActionId.prototype[Symbol.dispose] = NioGovActionId.prototype.free;
767
+
768
+ /**
769
+ * Transaction metadata (auxiliary data).
770
+ */
771
+ export class NioMetadata {
772
+ static __wrap(ptr) {
773
+ ptr = ptr >>> 0;
774
+ const obj = Object.create(NioMetadata.prototype);
775
+ obj.__wbg_ptr = ptr;
776
+ NioMetadataFinalization.register(obj, obj.__wbg_ptr, obj);
777
+ return obj;
778
+ }
779
+ __destroy_into_raw() {
780
+ const ptr = this.__wbg_ptr;
781
+ this.__wbg_ptr = 0;
782
+ NioMetadataFinalization.unregister(this);
783
+ return ptr;
784
+ }
785
+ free() {
786
+ const ptr = this.__destroy_into_raw();
787
+ wasm.__wbg_niometadata_free(ptr, 0);
788
+ }
789
+ /**
790
+ * Deserialize from CBOR hex.
791
+ * @param {string} hex_str
792
+ * @returns {NioMetadata}
793
+ */
794
+ static from_cbor_hex(hex_str) {
795
+ const ptr0 = passStringToWasm0(hex_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
796
+ const len0 = WASM_VECTOR_LEN;
797
+ const ret = wasm.niometadata_from_cbor_hex(ptr0, len0);
798
+ if (ret[2]) {
799
+ throw takeFromExternrefTable0(ret[1]);
800
+ }
801
+ return NioMetadata.__wrap(ret[0]);
802
+ }
803
+ /**
804
+ * Create empty metadata.
805
+ */
806
+ constructor() {
807
+ const ret = wasm.niometadata_new();
808
+ this.__wbg_ptr = ret >>> 0;
809
+ NioMetadataFinalization.register(this, this.__wbg_ptr, this);
810
+ return this;
811
+ }
812
+ /**
813
+ * Set bytes (hex-encoded) at the given label.
814
+ * @param {bigint} label
815
+ * @param {string} hex_str
816
+ */
817
+ set_bytes(label, hex_str) {
818
+ const ptr0 = passStringToWasm0(hex_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
819
+ const len0 = WASM_VECTOR_LEN;
820
+ const ret = wasm.niometadata_set_bytes(this.__wbg_ptr, label, ptr0, len0);
821
+ if (ret[1]) {
822
+ throw takeFromExternrefTable0(ret[0]);
823
+ }
824
+ }
825
+ /**
826
+ * Set an integer at the given label.
827
+ * @param {bigint} label
828
+ * @param {bigint} value
829
+ */
830
+ set_int(label, value) {
831
+ wasm.niometadata_set_int(this.__wbg_ptr, label, value);
832
+ }
833
+ /**
834
+ * Set a text string at the given label.
835
+ * @param {bigint} label
836
+ * @param {string} text
837
+ */
838
+ set_text(label, text) {
839
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
840
+ const len0 = WASM_VECTOR_LEN;
841
+ const ret = wasm.niometadata_set_text(this.__wbg_ptr, label, ptr0, len0);
842
+ if (ret[1]) {
843
+ throw takeFromExternrefTable0(ret[0]);
844
+ }
845
+ }
846
+ /**
847
+ * Serialize to CBOR hex.
848
+ * @returns {string}
849
+ */
850
+ to_cbor_hex() {
851
+ let deferred1_0;
852
+ let deferred1_1;
853
+ try {
854
+ const ret = wasm.niometadata_to_cbor_hex(this.__wbg_ptr);
855
+ deferred1_0 = ret[0];
856
+ deferred1_1 = ret[1];
857
+ return getStringFromWasm0(ret[0], ret[1]);
858
+ } finally {
859
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
860
+ }
861
+ }
862
+ }
863
+ if (Symbol.dispose) NioMetadata.prototype[Symbol.dispose] = NioMetadata.prototype.free;
864
+
865
+ /**
866
+ * PlutusData — the data type used in Cardano smart contracts.
867
+ */
868
+ export class NioPlutusData {
869
+ static __wrap(ptr) {
870
+ ptr = ptr >>> 0;
871
+ const obj = Object.create(NioPlutusData.prototype);
872
+ obj.__wbg_ptr = ptr;
873
+ NioPlutusDataFinalization.register(obj, obj.__wbg_ptr, obj);
874
+ return obj;
875
+ }
876
+ static __unwrap(jsValue) {
877
+ if (!(jsValue instanceof NioPlutusData)) {
878
+ return 0;
879
+ }
880
+ return jsValue.__destroy_into_raw();
881
+ }
882
+ __destroy_into_raw() {
883
+ const ptr = this.__wbg_ptr;
884
+ this.__wbg_ptr = 0;
885
+ NioPlutusDataFinalization.unregister(this);
886
+ return ptr;
887
+ }
888
+ free() {
889
+ const ptr = this.__destroy_into_raw();
890
+ wasm.__wbg_nioplutusdata_free(ptr, 0);
891
+ }
892
+ /**
893
+ * Deserialize from CBOR hex.
894
+ * @param {string} hex_str
895
+ * @returns {NioPlutusData}
896
+ */
897
+ static from_cbor_hex(hex_str) {
898
+ const ptr0 = passStringToWasm0(hex_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
899
+ const len0 = WASM_VECTOR_LEN;
900
+ const ret = wasm.nioplutusdata_from_cbor_hex(ptr0, len0);
901
+ if (ret[2]) {
902
+ throw takeFromExternrefTable0(ret[1]);
903
+ }
904
+ return NioPlutusData.__wrap(ret[0]);
905
+ }
906
+ /**
907
+ * Create a bytes PlutusData from hex-encoded bytes.
908
+ * @param {string} hex_str
909
+ * @returns {NioPlutusData}
910
+ */
911
+ static new_bytes(hex_str) {
912
+ const ptr0 = passStringToWasm0(hex_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
913
+ const len0 = WASM_VECTOR_LEN;
914
+ const ret = wasm.nioplutusdata_new_bytes(ptr0, len0);
915
+ if (ret[2]) {
916
+ throw takeFromExternrefTable0(ret[1]);
917
+ }
918
+ return NioPlutusData.__wrap(ret[0]);
919
+ }
920
+ /**
921
+ * Create a constructor-tagged PlutusData (Constr alternative data).
922
+ * @param {bigint} alternative
923
+ * @param {NioPlutusData[]} fields
924
+ * @returns {NioPlutusData}
925
+ */
926
+ static new_constr(alternative, fields) {
927
+ const ptr0 = passArrayJsValueToWasm0(fields, wasm.__wbindgen_malloc);
928
+ const len0 = WASM_VECTOR_LEN;
929
+ const ret = wasm.nioplutusdata_new_constr(alternative, ptr0, len0);
930
+ return NioPlutusData.__wrap(ret);
931
+ }
932
+ /**
933
+ * Create an integer PlutusData.
934
+ * @param {bigint} value
935
+ * @returns {NioPlutusData}
936
+ */
937
+ static new_integer(value) {
938
+ const ret = wasm.nioplutusdata_new_integer(value);
939
+ return NioPlutusData.__wrap(ret);
940
+ }
941
+ /**
942
+ * Create a list PlutusData.
943
+ * @param {NioPlutusData[]} items
944
+ * @returns {NioPlutusData}
945
+ */
946
+ static new_list(items) {
947
+ const ptr0 = passArrayJsValueToWasm0(items, wasm.__wbindgen_malloc);
948
+ const len0 = WASM_VECTOR_LEN;
949
+ const ret = wasm.nioplutusdata_new_list(ptr0, len0);
950
+ return NioPlutusData.__wrap(ret);
951
+ }
952
+ /**
953
+ * Create a map PlutusData.
954
+ * @param {NioPlutusData[]} keys
955
+ * @param {NioPlutusData[]} values
956
+ * @returns {NioPlutusData}
957
+ */
958
+ static new_map(keys, values) {
959
+ const ptr0 = passArrayJsValueToWasm0(keys, wasm.__wbindgen_malloc);
960
+ const len0 = WASM_VECTOR_LEN;
961
+ const ptr1 = passArrayJsValueToWasm0(values, wasm.__wbindgen_malloc);
962
+ const len1 = WASM_VECTOR_LEN;
963
+ const ret = wasm.nioplutusdata_new_map(ptr0, len0, ptr1, len1);
964
+ if (ret[2]) {
965
+ throw takeFromExternrefTable0(ret[1]);
966
+ }
967
+ return NioPlutusData.__wrap(ret[0]);
968
+ }
969
+ /**
970
+ * Serialize to CBOR hex.
971
+ * @returns {string}
972
+ */
973
+ to_cbor_hex() {
974
+ let deferred1_0;
975
+ let deferred1_1;
976
+ try {
977
+ const ret = wasm.nioplutusdata_to_cbor_hex(this.__wbg_ptr);
978
+ deferred1_0 = ret[0];
979
+ deferred1_1 = ret[1];
980
+ return getStringFromWasm0(ret[0], ret[1]);
981
+ } finally {
982
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
983
+ }
984
+ }
985
+ }
986
+ if (Symbol.dispose) NioPlutusData.prototype[Symbol.dispose] = NioPlutusData.prototype.free;
987
+
988
+ /**
989
+ * A Plutus script (V1, V2, or V3).
990
+ */
991
+ export class NioPlutusScript {
992
+ __destroy_into_raw() {
993
+ const ptr = this.__wbg_ptr;
994
+ this.__wbg_ptr = 0;
995
+ NioPlutusScriptFinalization.unregister(this);
996
+ return ptr;
997
+ }
998
+ free() {
999
+ const ptr = this.__destroy_into_raw();
1000
+ wasm.__wbg_nioplutusscript_free(ptr, 0);
1001
+ }
1002
+ /**
1003
+ * Create a Plutus script from CBOR hex and version.
1004
+ * @param {string} cbor_hex
1005
+ * @param {NioPlutusVersion} version
1006
+ */
1007
+ constructor(cbor_hex, version) {
1008
+ const ptr0 = passStringToWasm0(cbor_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1009
+ const len0 = WASM_VECTOR_LEN;
1010
+ const ret = wasm.nioplutusscript_new(ptr0, len0, version);
1011
+ if (ret[2]) {
1012
+ throw takeFromExternrefTable0(ret[1]);
1013
+ }
1014
+ this.__wbg_ptr = ret[0] >>> 0;
1015
+ NioPlutusScriptFinalization.register(this, this.__wbg_ptr, this);
1016
+ return this;
1017
+ }
1018
+ /**
1019
+ * @returns {string}
1020
+ */
1021
+ to_cbor_hex() {
1022
+ let deferred1_0;
1023
+ let deferred1_1;
1024
+ try {
1025
+ const ret = wasm.nioplutusscript_to_cbor_hex(this.__wbg_ptr);
1026
+ deferred1_0 = ret[0];
1027
+ deferred1_1 = ret[1];
1028
+ return getStringFromWasm0(ret[0], ret[1]);
1029
+ } finally {
1030
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1031
+ }
1032
+ }
1033
+ /**
1034
+ * @returns {NioPlutusVersion}
1035
+ */
1036
+ version() {
1037
+ const ret = wasm.nioplutusscript_version(this.__wbg_ptr);
1038
+ return ret;
1039
+ }
1040
+ }
1041
+ if (Symbol.dispose) NioPlutusScript.prototype[Symbol.dispose] = NioPlutusScript.prototype.free;
1042
+
1043
+ /**
1044
+ * @enum {1 | 2 | 3}
1045
+ */
1046
+ export const NioPlutusVersion = Object.freeze({
1047
+ V1: 1, "1": "V1",
1048
+ V2: 2, "2": "V2",
1049
+ V3: 3, "3": "V3",
1050
+ });
1051
+
1052
+ /**
1053
+ * A governance proposal procedure.
1054
+ */
1055
+ export class NioProposalProcedure {
1056
+ static __wrap(ptr) {
1057
+ ptr = ptr >>> 0;
1058
+ const obj = Object.create(NioProposalProcedure.prototype);
1059
+ obj.__wbg_ptr = ptr;
1060
+ NioProposalProcedureFinalization.register(obj, obj.__wbg_ptr, obj);
1061
+ return obj;
1062
+ }
1063
+ __destroy_into_raw() {
1064
+ const ptr = this.__wbg_ptr;
1065
+ this.__wbg_ptr = 0;
1066
+ NioProposalProcedureFinalization.unregister(this);
1067
+ return ptr;
1068
+ }
1069
+ free() {
1070
+ const ptr = this.__destroy_into_raw();
1071
+ wasm.__wbg_nioproposalprocedure_free(ptr, 0);
1072
+ }
1073
+ /**
1074
+ * Create an Info governance action proposal.
1075
+ *
1076
+ * - `deposit`: required deposit in lovelace
1077
+ * - `reward_account_hex`: reward account address in raw bytes hex
1078
+ * - `anchor_url`: URL to the proposal document
1079
+ * - `anchor_hash_hex`: Blake2b-256 hash of the proposal document
1080
+ * @param {bigint} deposit
1081
+ * @param {string} reward_account_hex
1082
+ * @param {string} anchor_url
1083
+ * @param {string} anchor_hash_hex
1084
+ * @returns {NioProposalProcedure}
1085
+ */
1086
+ static new_info_action(deposit, reward_account_hex, anchor_url, anchor_hash_hex) {
1087
+ const ptr0 = passStringToWasm0(reward_account_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1088
+ const len0 = WASM_VECTOR_LEN;
1089
+ const ptr1 = passStringToWasm0(anchor_url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1090
+ const len1 = WASM_VECTOR_LEN;
1091
+ const ptr2 = passStringToWasm0(anchor_hash_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1092
+ const len2 = WASM_VECTOR_LEN;
1093
+ const ret = wasm.nioproposalprocedure_new_info_action(deposit, ptr0, len0, ptr1, len1, ptr2, len2);
1094
+ if (ret[2]) {
1095
+ throw takeFromExternrefTable0(ret[1]);
1096
+ }
1097
+ return NioProposalProcedure.__wrap(ret[0]);
1098
+ }
1099
+ }
1100
+ if (Symbol.dispose) NioProposalProcedure.prototype[Symbol.dispose] = NioProposalProcedure.prototype.free;
1101
+
1102
+ /**
1103
+ * Protocol parameters required for transaction building and fee calculation.
1104
+ */
1105
+ export class NioProtocolParameters {
1106
+ static __wrap(ptr) {
1107
+ ptr = ptr >>> 0;
1108
+ const obj = Object.create(NioProtocolParameters.prototype);
1109
+ obj.__wbg_ptr = ptr;
1110
+ NioProtocolParametersFinalization.register(obj, obj.__wbg_ptr, obj);
1111
+ return obj;
1112
+ }
1113
+ __destroy_into_raw() {
1114
+ const ptr = this.__wbg_ptr;
1115
+ this.__wbg_ptr = 0;
1116
+ NioProtocolParametersFinalization.unregister(this);
1117
+ return ptr;
1118
+ }
1119
+ free() {
1120
+ const ptr = this.__destroy_into_raw();
1121
+ wasm.__wbg_nioprotocolparameters_free(ptr, 0);
1122
+ }
1123
+ /**
1124
+ * @returns {bigint}
1125
+ */
1126
+ get coins_per_utxo_byte() {
1127
+ const ret = wasm.nioprotocolparameters_coins_per_utxo_byte(this.__wbg_ptr);
1128
+ return BigInt.asUintN(64, ret);
1129
+ }
1130
+ /**
1131
+ * @returns {number}
1132
+ */
1133
+ get collateral_percentage() {
1134
+ const ret = wasm.nioprotocolparameters_collateral_percentage(this.__wbg_ptr);
1135
+ return ret >>> 0;
1136
+ }
1137
+ /**
1138
+ * @returns {bigint}
1139
+ */
1140
+ get drep_deposit() {
1141
+ const ret = wasm.nioprotocolparameters_drep_deposit(this.__wbg_ptr);
1142
+ return BigInt.asUintN(64, ret);
1143
+ }
1144
+ /**
1145
+ * Create protocol parameters from a JSON string (e.g. Blockfrost API response).
1146
+ * @param {string} json
1147
+ * @returns {NioProtocolParameters}
1148
+ */
1149
+ static from_json(json) {
1150
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1151
+ const len0 = WASM_VECTOR_LEN;
1152
+ const ret = wasm.nioprotocolparameters_from_json(ptr0, len0);
1153
+ if (ret[2]) {
1154
+ throw takeFromExternrefTable0(ret[1]);
1155
+ }
1156
+ return NioProtocolParameters.__wrap(ret[0]);
1157
+ }
1158
+ /**
1159
+ * @returns {bigint}
1160
+ */
1161
+ get key_deposit() {
1162
+ const ret = wasm.nioprotocolparameters_key_deposit(this.__wbg_ptr);
1163
+ return BigInt.asUintN(64, ret);
1164
+ }
1165
+ /**
1166
+ * @returns {number}
1167
+ */
1168
+ get max_collateral_inputs() {
1169
+ const ret = wasm.nioprotocolparameters_max_collateral_inputs(this.__wbg_ptr);
1170
+ return ret >>> 0;
1171
+ }
1172
+ /**
1173
+ * @returns {number}
1174
+ */
1175
+ get max_tx_size() {
1176
+ const ret = wasm.nioprotocolparameters_max_tx_size(this.__wbg_ptr);
1177
+ return ret >>> 0;
1178
+ }
1179
+ /**
1180
+ * @returns {number}
1181
+ */
1182
+ get max_value_size() {
1183
+ const ret = wasm.nioprotocolparameters_max_value_size(this.__wbg_ptr);
1184
+ return ret >>> 0;
1185
+ }
1186
+ /**
1187
+ * @returns {bigint}
1188
+ */
1189
+ get min_fee_a() {
1190
+ const ret = wasm.nioprotocolparameters_min_fee_a(this.__wbg_ptr);
1191
+ return BigInt.asUintN(64, ret);
1192
+ }
1193
+ /**
1194
+ * @returns {bigint}
1195
+ */
1196
+ get min_fee_b() {
1197
+ const ret = wasm.nioprotocolparameters_min_fee_b(this.__wbg_ptr);
1198
+ return BigInt.asUintN(64, ret);
1199
+ }
1200
+ /**
1201
+ * @param {bigint} min_fee_a
1202
+ * @param {bigint} min_fee_b
1203
+ * @param {number} max_tx_size
1204
+ * @param {number} max_value_size
1205
+ * @param {bigint} coins_per_utxo_byte
1206
+ * @param {bigint} key_deposit
1207
+ * @param {bigint} pool_deposit
1208
+ * @param {bigint} drep_deposit
1209
+ * @param {number} collateral_percentage
1210
+ * @param {number} max_collateral_inputs
1211
+ */
1212
+ constructor(min_fee_a, min_fee_b, max_tx_size, max_value_size, coins_per_utxo_byte, key_deposit, pool_deposit, drep_deposit, collateral_percentage, max_collateral_inputs) {
1213
+ const ret = wasm.nioprotocolparameters_new(min_fee_a, min_fee_b, max_tx_size, max_value_size, coins_per_utxo_byte, key_deposit, pool_deposit, drep_deposit, collateral_percentage, max_collateral_inputs);
1214
+ this.__wbg_ptr = ret >>> 0;
1215
+ NioProtocolParametersFinalization.register(this, this.__wbg_ptr, this);
1216
+ return this;
1217
+ }
1218
+ /**
1219
+ * @returns {bigint}
1220
+ */
1221
+ get pool_deposit() {
1222
+ const ret = wasm.nioprotocolparameters_pool_deposit(this.__wbg_ptr);
1223
+ return BigInt.asUintN(64, ret);
1224
+ }
1225
+ }
1226
+ if (Symbol.dispose) NioProtocolParameters.prototype[Symbol.dispose] = NioProtocolParameters.prototype.free;
1227
+
1228
+ /**
1229
+ * Redeemer tag indicating the purpose of a redeemer.
1230
+ * @enum {0 | 1 | 2 | 3 | 4 | 5}
1231
+ */
1232
+ export const NioRedeemerTag = Object.freeze({
1233
+ Spend: 0, "0": "Spend",
1234
+ Mint: 1, "1": "Mint",
1235
+ Cert: 2, "2": "Cert",
1236
+ Reward: 3, "3": "Reward",
1237
+ Voting: 4, "4": "Voting",
1238
+ Proposing: 5, "5": "Proposing",
1239
+ });
1240
+
1241
+ /**
1242
+ * A complete Cardano transaction (body + witness set + auxiliary data).
1243
+ */
1244
+ export class NioTransaction {
1245
+ static __wrap(ptr) {
1246
+ ptr = ptr >>> 0;
1247
+ const obj = Object.create(NioTransaction.prototype);
1248
+ obj.__wbg_ptr = ptr;
1249
+ NioTransactionFinalization.register(obj, obj.__wbg_ptr, obj);
1250
+ return obj;
1251
+ }
1252
+ __destroy_into_raw() {
1253
+ const ptr = this.__wbg_ptr;
1254
+ this.__wbg_ptr = 0;
1255
+ NioTransactionFinalization.unregister(this);
1256
+ return ptr;
1257
+ }
1258
+ free() {
1259
+ const ptr = this.__destroy_into_raw();
1260
+ wasm.__wbg_niotransaction_free(ptr, 0);
1261
+ }
1262
+ /**
1263
+ * Get the fee in lovelace.
1264
+ * @returns {bigint}
1265
+ */
1266
+ fee() {
1267
+ const ret = wasm.niotransaction_fee(this.__wbg_ptr);
1268
+ return BigInt.asUintN(64, ret);
1269
+ }
1270
+ /**
1271
+ * Deserialize from CBOR hex string.
1272
+ * @param {string} hex_str
1273
+ * @returns {NioTransaction}
1274
+ */
1275
+ static from_cbor_hex(hex_str) {
1276
+ const ptr0 = passStringToWasm0(hex_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1277
+ const len0 = WASM_VECTOR_LEN;
1278
+ const ret = wasm.niotransaction_from_cbor_hex(ptr0, len0);
1279
+ if (ret[2]) {
1280
+ throw takeFromExternrefTable0(ret[1]);
1281
+ }
1282
+ return NioTransaction.__wrap(ret[0]);
1283
+ }
1284
+ /**
1285
+ * Get the transaction hash (Blake2b-256 of the body).
1286
+ * @returns {string}
1287
+ */
1288
+ hash() {
1289
+ let deferred1_0;
1290
+ let deferred1_1;
1291
+ try {
1292
+ const ret = wasm.niotransaction_hash(this.__wbg_ptr);
1293
+ deferred1_0 = ret[0];
1294
+ deferred1_1 = ret[1];
1295
+ return getStringFromWasm0(ret[0], ret[1]);
1296
+ } finally {
1297
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1298
+ }
1299
+ }
1300
+ /**
1301
+ * Serialize to CBOR hex string.
1302
+ * @returns {string}
1303
+ */
1304
+ to_cbor_hex() {
1305
+ let deferred1_0;
1306
+ let deferred1_1;
1307
+ try {
1308
+ const ret = wasm.niotransaction_to_cbor_hex(this.__wbg_ptr);
1309
+ deferred1_0 = ret[0];
1310
+ deferred1_1 = ret[1];
1311
+ return getStringFromWasm0(ret[0], ret[1]);
1312
+ } finally {
1313
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1314
+ }
1315
+ }
1316
+ }
1317
+ if (Symbol.dispose) NioTransaction.prototype[Symbol.dispose] = NioTransaction.prototype.free;
1318
+
1319
+ /**
1320
+ * High-level transaction builder wrapping CML's TransactionBuilder.
1321
+ *
1322
+ * Provides UTXO selection, fee estimation, change handling, and a fluent API.
1323
+ */
1324
+ export class NioTransactionBuilder {
1325
+ __destroy_into_raw() {
1326
+ const ptr = this.__wbg_ptr;
1327
+ this.__wbg_ptr = 0;
1328
+ NioTransactionBuilderFinalization.unregister(this);
1329
+ return ptr;
1330
+ }
1331
+ free() {
1332
+ const ptr = this.__destroy_into_raw();
1333
+ wasm.__wbg_niotransactionbuilder_free(ptr, 0);
1334
+ }
1335
+ /**
1336
+ * Add a certificate to the transaction.
1337
+ * @param {NioCertificate} cert
1338
+ */
1339
+ add_certificate(cert) {
1340
+ _assertClass(cert, NioCertificate);
1341
+ const ret = wasm.niotransactionbuilder_add_certificate(this.__wbg_ptr, cert.__wbg_ptr);
1342
+ if (ret[1]) {
1343
+ throw takeFromExternrefTable0(ret[0]);
1344
+ }
1345
+ }
1346
+ /**
1347
+ * Add a collateral UTXO (for Plutus script transactions).
1348
+ * @param {NioUtxo} utxo
1349
+ */
1350
+ add_collateral(utxo) {
1351
+ _assertClass(utxo, NioUtxo);
1352
+ const ret = wasm.niotransactionbuilder_add_collateral(this.__wbg_ptr, utxo.__wbg_ptr);
1353
+ if (ret[1]) {
1354
+ throw takeFromExternrefTable0(ret[0]);
1355
+ }
1356
+ }
1357
+ /**
1358
+ * Add a specific input (UTXO to spend).
1359
+ * @param {NioUtxo} utxo
1360
+ */
1361
+ add_input(utxo) {
1362
+ _assertClass(utxo, NioUtxo);
1363
+ const ret = wasm.niotransactionbuilder_add_input(this.__wbg_ptr, utxo.__wbg_ptr);
1364
+ if (ret[1]) {
1365
+ throw takeFromExternrefTable0(ret[0]);
1366
+ }
1367
+ }
1368
+ /**
1369
+ * Add an output (destination address + value).
1370
+ * @param {NioAddress} address
1371
+ * @param {bigint} coin
1372
+ */
1373
+ add_output_to(address, coin) {
1374
+ _assertClass(address, NioAddress);
1375
+ const ret = wasm.niotransactionbuilder_add_output_to(this.__wbg_ptr, address.__wbg_ptr, coin);
1376
+ if (ret[1]) {
1377
+ throw takeFromExternrefTable0(ret[0]);
1378
+ }
1379
+ }
1380
+ /**
1381
+ * Add a required signer (Ed25519 key hash hex).
1382
+ * @param {string} keyhash_hex
1383
+ */
1384
+ add_required_signer(keyhash_hex) {
1385
+ const ptr0 = passStringToWasm0(keyhash_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1386
+ const len0 = WASM_VECTOR_LEN;
1387
+ const ret = wasm.niotransactionbuilder_add_required_signer(this.__wbg_ptr, ptr0, len0);
1388
+ if (ret[1]) {
1389
+ throw takeFromExternrefTable0(ret[0]);
1390
+ }
1391
+ }
1392
+ /**
1393
+ * Add UTXOs to the available pool for automatic coin selection.
1394
+ * @param {NioUtxo[]} utxos
1395
+ */
1396
+ add_utxos_from(utxos) {
1397
+ const ptr0 = passArrayJsValueToWasm0(utxos, wasm.__wbindgen_malloc);
1398
+ const len0 = WASM_VECTOR_LEN;
1399
+ wasm.niotransactionbuilder_add_utxos_from(this.__wbg_ptr, ptr0, len0);
1400
+ }
1401
+ /**
1402
+ * Build the transaction with automatic UTXO selection and fee estimation.
1403
+ * @returns {NioTransaction}
1404
+ */
1405
+ build() {
1406
+ const ret = wasm.niotransactionbuilder_build(this.__wbg_ptr);
1407
+ if (ret[2]) {
1408
+ throw takeFromExternrefTable0(ret[1]);
1409
+ }
1410
+ return NioTransaction.__wrap(ret[0]);
1411
+ }
1412
+ /**
1413
+ * Create a new transaction builder with the given protocol parameters.
1414
+ * @param {NioProtocolParameters} params
1415
+ */
1416
+ constructor(params) {
1417
+ _assertClass(params, NioProtocolParameters);
1418
+ const ret = wasm.niotransactionbuilder_new(params.__wbg_ptr);
1419
+ if (ret[2]) {
1420
+ throw takeFromExternrefTable0(ret[1]);
1421
+ }
1422
+ this.__wbg_ptr = ret[0] >>> 0;
1423
+ NioTransactionBuilderFinalization.register(this, this.__wbg_ptr, this);
1424
+ return this;
1425
+ }
1426
+ /**
1427
+ * Set the change address (where leftover ADA goes).
1428
+ * @param {NioAddress} address
1429
+ */
1430
+ set_change_address(address) {
1431
+ _assertClass(address, NioAddress);
1432
+ wasm.niotransactionbuilder_set_change_address(this.__wbg_ptr, address.__wbg_ptr);
1433
+ }
1434
+ /**
1435
+ * Set transaction metadata.
1436
+ * @param {NioMetadata} metadata
1437
+ */
1438
+ set_metadata(metadata) {
1439
+ _assertClass(metadata, NioMetadata);
1440
+ wasm.niotransactionbuilder_set_metadata(this.__wbg_ptr, metadata.__wbg_ptr);
1441
+ }
1442
+ /**
1443
+ * Set the transaction time-to-live (TTL) in slots.
1444
+ * @param {bigint} ttl
1445
+ */
1446
+ set_ttl(ttl) {
1447
+ wasm.niotransactionbuilder_set_ttl(this.__wbg_ptr, ttl);
1448
+ }
1449
+ /**
1450
+ * Set the validity start interval in slots.
1451
+ * @param {bigint} slot
1452
+ */
1453
+ set_validity_start(slot) {
1454
+ wasm.niotransactionbuilder_set_validity_start(this.__wbg_ptr, slot);
1455
+ }
1456
+ }
1457
+ if (Symbol.dispose) NioTransactionBuilder.prototype[Symbol.dispose] = NioTransactionBuilder.prototype.free;
1458
+
1459
+ /**
1460
+ * A transaction input (reference to a previous output).
1461
+ */
1462
+ export class NioTransactionInput {
1463
+ static __wrap(ptr) {
1464
+ ptr = ptr >>> 0;
1465
+ const obj = Object.create(NioTransactionInput.prototype);
1466
+ obj.__wbg_ptr = ptr;
1467
+ NioTransactionInputFinalization.register(obj, obj.__wbg_ptr, obj);
1468
+ return obj;
1469
+ }
1470
+ __destroy_into_raw() {
1471
+ const ptr = this.__wbg_ptr;
1472
+ this.__wbg_ptr = 0;
1473
+ NioTransactionInputFinalization.unregister(this);
1474
+ return ptr;
1475
+ }
1476
+ free() {
1477
+ const ptr = this.__destroy_into_raw();
1478
+ wasm.__wbg_niotransactioninput_free(ptr, 0);
1479
+ }
1480
+ /**
1481
+ * Deserialize from CBOR hex.
1482
+ * @param {string} hex_str
1483
+ * @returns {NioTransactionInput}
1484
+ */
1485
+ static from_cbor_hex(hex_str) {
1486
+ const ptr0 = passStringToWasm0(hex_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1487
+ const len0 = WASM_VECTOR_LEN;
1488
+ const ret = wasm.niotransactioninput_from_cbor_hex(ptr0, len0);
1489
+ if (ret[2]) {
1490
+ throw takeFromExternrefTable0(ret[1]);
1491
+ }
1492
+ return NioTransactionInput.__wrap(ret[0]);
1493
+ }
1494
+ /**
1495
+ * Get the output index.
1496
+ * @returns {bigint}
1497
+ */
1498
+ index() {
1499
+ const ret = wasm.niotransactioninput_index(this.__wbg_ptr);
1500
+ return BigInt.asUintN(64, ret);
1501
+ }
1502
+ /**
1503
+ * Create from a transaction hash and output index.
1504
+ * @param {string} transaction_id
1505
+ * @param {bigint} index
1506
+ */
1507
+ constructor(transaction_id, index) {
1508
+ const ptr0 = passStringToWasm0(transaction_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1509
+ const len0 = WASM_VECTOR_LEN;
1510
+ const ret = wasm.niotransactioninput_new(ptr0, len0, index);
1511
+ if (ret[2]) {
1512
+ throw takeFromExternrefTable0(ret[1]);
1513
+ }
1514
+ this.__wbg_ptr = ret[0] >>> 0;
1515
+ NioTransactionInputFinalization.register(this, this.__wbg_ptr, this);
1516
+ return this;
1517
+ }
1518
+ /**
1519
+ * Serialize to CBOR hex.
1520
+ * @returns {string}
1521
+ */
1522
+ to_cbor_hex() {
1523
+ let deferred1_0;
1524
+ let deferred1_1;
1525
+ try {
1526
+ const ret = wasm.niotransactioninput_to_cbor_hex(this.__wbg_ptr);
1527
+ deferred1_0 = ret[0];
1528
+ deferred1_1 = ret[1];
1529
+ return getStringFromWasm0(ret[0], ret[1]);
1530
+ } finally {
1531
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1532
+ }
1533
+ }
1534
+ /**
1535
+ * Get the transaction hash as hex.
1536
+ * @returns {string}
1537
+ */
1538
+ transaction_id() {
1539
+ let deferred1_0;
1540
+ let deferred1_1;
1541
+ try {
1542
+ const ret = wasm.niotransactioninput_transaction_id(this.__wbg_ptr);
1543
+ deferred1_0 = ret[0];
1544
+ deferred1_1 = ret[1];
1545
+ return getStringFromWasm0(ret[0], ret[1]);
1546
+ } finally {
1547
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1548
+ }
1549
+ }
1550
+ }
1551
+ if (Symbol.dispose) NioTransactionInput.prototype[Symbol.dispose] = NioTransactionInput.prototype.free;
1552
+
1553
+ /**
1554
+ * A transaction output (address + value + optional datum/script).
1555
+ */
1556
+ export class NioTransactionOutput {
1557
+ static __wrap(ptr) {
1558
+ ptr = ptr >>> 0;
1559
+ const obj = Object.create(NioTransactionOutput.prototype);
1560
+ obj.__wbg_ptr = ptr;
1561
+ NioTransactionOutputFinalization.register(obj, obj.__wbg_ptr, obj);
1562
+ return obj;
1563
+ }
1564
+ __destroy_into_raw() {
1565
+ const ptr = this.__wbg_ptr;
1566
+ this.__wbg_ptr = 0;
1567
+ NioTransactionOutputFinalization.unregister(this);
1568
+ return ptr;
1569
+ }
1570
+ free() {
1571
+ const ptr = this.__destroy_into_raw();
1572
+ wasm.__wbg_niotransactionoutput_free(ptr, 0);
1573
+ }
1574
+ /**
1575
+ * Get the output address as bech32.
1576
+ * @returns {string}
1577
+ */
1578
+ address_bech32() {
1579
+ let deferred2_0;
1580
+ let deferred2_1;
1581
+ try {
1582
+ const ret = wasm.niotransactionoutput_address_bech32(this.__wbg_ptr);
1583
+ var ptr1 = ret[0];
1584
+ var len1 = ret[1];
1585
+ if (ret[3]) {
1586
+ ptr1 = 0; len1 = 0;
1587
+ throw takeFromExternrefTable0(ret[2]);
1588
+ }
1589
+ deferred2_0 = ptr1;
1590
+ deferred2_1 = len1;
1591
+ return getStringFromWasm0(ptr1, len1);
1592
+ } finally {
1593
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1594
+ }
1595
+ }
1596
+ /**
1597
+ * Deserialize from CBOR hex.
1598
+ * @param {string} hex_str
1599
+ * @returns {NioTransactionOutput}
1600
+ */
1601
+ static from_cbor_hex(hex_str) {
1602
+ const ptr0 = passStringToWasm0(hex_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1603
+ const len0 = WASM_VECTOR_LEN;
1604
+ const ret = wasm.niotransactionoutput_from_cbor_hex(ptr0, len0);
1605
+ if (ret[2]) {
1606
+ throw takeFromExternrefTable0(ret[1]);
1607
+ }
1608
+ return NioTransactionOutput.__wrap(ret[0]);
1609
+ }
1610
+ /**
1611
+ * Serialize to CBOR hex.
1612
+ * @returns {string}
1613
+ */
1614
+ to_cbor_hex() {
1615
+ let deferred1_0;
1616
+ let deferred1_1;
1617
+ try {
1618
+ const ret = wasm.niotransactionoutput_to_cbor_hex(this.__wbg_ptr);
1619
+ deferred1_0 = ret[0];
1620
+ deferred1_1 = ret[1];
1621
+ return getStringFromWasm0(ret[0], ret[1]);
1622
+ } finally {
1623
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1624
+ }
1625
+ }
1626
+ }
1627
+ if (Symbol.dispose) NioTransactionOutput.prototype[Symbol.dispose] = NioTransactionOutput.prototype.free;
1628
+
1629
+ /**
1630
+ * An unspent transaction output (UTXO) — input + output pair.
1631
+ */
1632
+ export class NioUtxo {
1633
+ static __wrap(ptr) {
1634
+ ptr = ptr >>> 0;
1635
+ const obj = Object.create(NioUtxo.prototype);
1636
+ obj.__wbg_ptr = ptr;
1637
+ NioUtxoFinalization.register(obj, obj.__wbg_ptr, obj);
1638
+ return obj;
1639
+ }
1640
+ static __unwrap(jsValue) {
1641
+ if (!(jsValue instanceof NioUtxo)) {
1642
+ return 0;
1643
+ }
1644
+ return jsValue.__destroy_into_raw();
1645
+ }
1646
+ __destroy_into_raw() {
1647
+ const ptr = this.__wbg_ptr;
1648
+ this.__wbg_ptr = 0;
1649
+ NioUtxoFinalization.unregister(this);
1650
+ return ptr;
1651
+ }
1652
+ free() {
1653
+ const ptr = this.__destroy_into_raw();
1654
+ wasm.__wbg_nioutxo_free(ptr, 0);
1655
+ }
1656
+ /**
1657
+ * Deserialize from CBOR hex (as returned by CIP-30 getUtxos).
1658
+ * @param {string} hex_str
1659
+ * @returns {NioUtxo}
1660
+ */
1661
+ static from_cbor_hex(hex_str) {
1662
+ const ptr0 = passStringToWasm0(hex_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1663
+ const len0 = WASM_VECTOR_LEN;
1664
+ const ret = wasm.nioutxo_from_cbor_hex(ptr0, len0);
1665
+ if (ret[2]) {
1666
+ throw takeFromExternrefTable0(ret[1]);
1667
+ }
1668
+ return NioUtxo.__wrap(ret[0]);
1669
+ }
1670
+ /**
1671
+ * Get the transaction input.
1672
+ * @returns {NioTransactionInput}
1673
+ */
1674
+ input() {
1675
+ const ret = wasm.nioutxo_input(this.__wbg_ptr);
1676
+ return NioTransactionInput.__wrap(ret);
1677
+ }
1678
+ /**
1679
+ * Get the transaction output.
1680
+ * @returns {NioTransactionOutput}
1681
+ */
1682
+ output() {
1683
+ const ret = wasm.nioutxo_output(this.__wbg_ptr);
1684
+ return NioTransactionOutput.__wrap(ret);
1685
+ }
1686
+ /**
1687
+ * Serialize to CBOR hex.
1688
+ * @returns {string}
1689
+ */
1690
+ to_cbor_hex() {
1691
+ let deferred1_0;
1692
+ let deferred1_1;
1693
+ try {
1694
+ const ret = wasm.nioutxo_to_cbor_hex(this.__wbg_ptr);
1695
+ deferred1_0 = ret[0];
1696
+ deferred1_1 = ret[1];
1697
+ return getStringFromWasm0(ret[0], ret[1]);
1698
+ } finally {
1699
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1700
+ }
1701
+ }
1702
+ }
1703
+ if (Symbol.dispose) NioUtxo.prototype[Symbol.dispose] = NioUtxo.prototype.free;
1704
+
1705
+ /**
1706
+ * A Cardano value (ADA coin amount + optional multi-asset tokens).
1707
+ */
1708
+ export class NioValue {
1709
+ static __wrap(ptr) {
1710
+ ptr = ptr >>> 0;
1711
+ const obj = Object.create(NioValue.prototype);
1712
+ obj.__wbg_ptr = ptr;
1713
+ NioValueFinalization.register(obj, obj.__wbg_ptr, obj);
1714
+ return obj;
1715
+ }
1716
+ __destroy_into_raw() {
1717
+ const ptr = this.__wbg_ptr;
1718
+ this.__wbg_ptr = 0;
1719
+ NioValueFinalization.unregister(this);
1720
+ return ptr;
1721
+ }
1722
+ free() {
1723
+ const ptr = this.__destroy_into_raw();
1724
+ wasm.__wbg_niovalue_free(ptr, 0);
1725
+ }
1726
+ /**
1727
+ * Get the ADA amount in lovelace.
1728
+ * @returns {bigint}
1729
+ */
1730
+ coin() {
1731
+ const ret = wasm.niovalue_coin(this.__wbg_ptr);
1732
+ return BigInt.asUintN(64, ret);
1733
+ }
1734
+ /**
1735
+ * Deserialize from CBOR hex (as returned by CIP-30 getBalance).
1736
+ * @param {string} hex_str
1737
+ * @returns {NioValue}
1738
+ */
1739
+ static from_cbor_hex(hex_str) {
1740
+ const ptr0 = passStringToWasm0(hex_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1741
+ const len0 = WASM_VECTOR_LEN;
1742
+ const ret = wasm.niovalue_from_cbor_hex(ptr0, len0);
1743
+ if (ret[2]) {
1744
+ throw takeFromExternrefTable0(ret[1]);
1745
+ }
1746
+ return NioValue.__wrap(ret[0]);
1747
+ }
1748
+ /**
1749
+ * Create from a coin amount only (no multi-assets).
1750
+ * @param {bigint} coin
1751
+ * @returns {NioValue}
1752
+ */
1753
+ static from_coin(coin) {
1754
+ const ret = wasm.niovalue_from_coin(coin);
1755
+ return NioValue.__wrap(ret);
1756
+ }
1757
+ /**
1758
+ * Check if this value contains multi-asset tokens.
1759
+ * @returns {boolean}
1760
+ */
1761
+ has_multiassets() {
1762
+ const ret = wasm.niovalue_has_multiassets(this.__wbg_ptr);
1763
+ return ret !== 0;
1764
+ }
1765
+ /**
1766
+ * Get the multi-asset portion as a JSON string.
1767
+ * Format: `[{"policy_id": "hex", "assets": [{"name": "hex", "quantity": "string"}]}]`
1768
+ * @returns {string}
1769
+ */
1770
+ multiassets_json() {
1771
+ let deferred1_0;
1772
+ let deferred1_1;
1773
+ try {
1774
+ const ret = wasm.niovalue_multiassets_json(this.__wbg_ptr);
1775
+ deferred1_0 = ret[0];
1776
+ deferred1_1 = ret[1];
1777
+ return getStringFromWasm0(ret[0], ret[1]);
1778
+ } finally {
1779
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1780
+ }
1781
+ }
1782
+ /**
1783
+ * Create a value with only ADA (in lovelace).
1784
+ * @param {bigint} coin
1785
+ */
1786
+ constructor(coin) {
1787
+ const ret = wasm.niovalue_from_coin(coin);
1788
+ this.__wbg_ptr = ret >>> 0;
1789
+ NioValueFinalization.register(this, this.__wbg_ptr, this);
1790
+ return this;
1791
+ }
1792
+ /**
1793
+ * Serialize to CBOR hex.
1794
+ * @returns {string}
1795
+ */
1796
+ to_cbor_hex() {
1797
+ let deferred1_0;
1798
+ let deferred1_1;
1799
+ try {
1800
+ const ret = wasm.niovalue_to_cbor_hex(this.__wbg_ptr);
1801
+ deferred1_0 = ret[0];
1802
+ deferred1_1 = ret[1];
1803
+ return getStringFromWasm0(ret[0], ret[1]);
1804
+ } finally {
1805
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1806
+ }
1807
+ }
1808
+ }
1809
+ if (Symbol.dispose) NioValue.prototype[Symbol.dispose] = NioValue.prototype.free;
1810
+
1811
+ /**
1812
+ * A voter identity for governance.
1813
+ */
1814
+ export class NioVoter {
1815
+ static __wrap(ptr) {
1816
+ ptr = ptr >>> 0;
1817
+ const obj = Object.create(NioVoter.prototype);
1818
+ obj.__wbg_ptr = ptr;
1819
+ NioVoterFinalization.register(obj, obj.__wbg_ptr, obj);
1820
+ return obj;
1821
+ }
1822
+ __destroy_into_raw() {
1823
+ const ptr = this.__wbg_ptr;
1824
+ this.__wbg_ptr = 0;
1825
+ NioVoterFinalization.unregister(this);
1826
+ return ptr;
1827
+ }
1828
+ free() {
1829
+ const ptr = this.__destroy_into_raw();
1830
+ wasm.__wbg_niovoter_free(ptr, 0);
1831
+ }
1832
+ /**
1833
+ * Create a DRep voter from a key hash.
1834
+ * @param {string} keyhash_hex
1835
+ * @returns {NioVoter}
1836
+ */
1837
+ static drep_key(keyhash_hex) {
1838
+ const ptr0 = passStringToWasm0(keyhash_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1839
+ const len0 = WASM_VECTOR_LEN;
1840
+ const ret = wasm.niovoter_drep_key(ptr0, len0);
1841
+ if (ret[2]) {
1842
+ throw takeFromExternrefTable0(ret[1]);
1843
+ }
1844
+ return NioVoter.__wrap(ret[0]);
1845
+ }
1846
+ /**
1847
+ * Create a DRep voter from a script hash.
1848
+ * @param {string} scripthash_hex
1849
+ * @returns {NioVoter}
1850
+ */
1851
+ static drep_script(scripthash_hex) {
1852
+ const ptr0 = passStringToWasm0(scripthash_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1853
+ const len0 = WASM_VECTOR_LEN;
1854
+ const ret = wasm.niovoter_drep_script(ptr0, len0);
1855
+ if (ret[2]) {
1856
+ throw takeFromExternrefTable0(ret[1]);
1857
+ }
1858
+ return NioVoter.__wrap(ret[0]);
1859
+ }
1860
+ /**
1861
+ * Create a staking pool voter.
1862
+ * @param {string} pool_keyhash_hex
1863
+ * @returns {NioVoter}
1864
+ */
1865
+ static staking_pool(pool_keyhash_hex) {
1866
+ const ptr0 = passStringToWasm0(pool_keyhash_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1867
+ const len0 = WASM_VECTOR_LEN;
1868
+ const ret = wasm.niovoter_staking_pool(ptr0, len0);
1869
+ if (ret[2]) {
1870
+ throw takeFromExternrefTable0(ret[1]);
1871
+ }
1872
+ return NioVoter.__wrap(ret[0]);
1873
+ }
1874
+ }
1875
+ if (Symbol.dispose) NioVoter.prototype[Symbol.dispose] = NioVoter.prototype.free;
1876
+
1877
+ /**
1878
+ * Voting procedure for governance actions.
1879
+ */
1880
+ export class NioVotingProcedure {
1881
+ __destroy_into_raw() {
1882
+ const ptr = this.__wbg_ptr;
1883
+ this.__wbg_ptr = 0;
1884
+ NioVotingProcedureFinalization.unregister(this);
1885
+ return ptr;
1886
+ }
1887
+ free() {
1888
+ const ptr = this.__destroy_into_raw();
1889
+ wasm.__wbg_niovotingprocedure_free(ptr, 0);
1890
+ }
1891
+ /**
1892
+ * Create a voting procedure.
1893
+ *
1894
+ * - `vote`: 0 = No, 1 = Yes, 2 = Abstain
1895
+ * - `anchor_url` / `anchor_hash_hex`: optional rationale reference
1896
+ * @param {number} vote
1897
+ * @param {string | null} [anchor_url]
1898
+ * @param {string | null} [anchor_hash_hex]
1899
+ */
1900
+ constructor(vote, anchor_url, anchor_hash_hex) {
1901
+ var ptr0 = isLikeNone(anchor_url) ? 0 : passStringToWasm0(anchor_url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1902
+ var len0 = WASM_VECTOR_LEN;
1903
+ var ptr1 = isLikeNone(anchor_hash_hex) ? 0 : passStringToWasm0(anchor_hash_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1904
+ var len1 = WASM_VECTOR_LEN;
1905
+ const ret = wasm.niovotingprocedure_new(vote, ptr0, len0, ptr1, len1);
1906
+ if (ret[2]) {
1907
+ throw takeFromExternrefTable0(ret[1]);
1908
+ }
1909
+ this.__wbg_ptr = ret[0] >>> 0;
1910
+ NioVotingProcedureFinalization.register(this, this.__wbg_ptr, this);
1911
+ return this;
1912
+ }
1913
+ }
1914
+ if (Symbol.dispose) NioVotingProcedure.prototype[Symbol.dispose] = NioVotingProcedure.prototype.free;
1915
+
1916
+ /**
1917
+ * A transaction witness set (signatures, scripts, redeemers, datums).
1918
+ */
1919
+ export class NioWitnessSet {
1920
+ static __wrap(ptr) {
1921
+ ptr = ptr >>> 0;
1922
+ const obj = Object.create(NioWitnessSet.prototype);
1923
+ obj.__wbg_ptr = ptr;
1924
+ NioWitnessSetFinalization.register(obj, obj.__wbg_ptr, obj);
1925
+ return obj;
1926
+ }
1927
+ __destroy_into_raw() {
1928
+ const ptr = this.__wbg_ptr;
1929
+ this.__wbg_ptr = 0;
1930
+ NioWitnessSetFinalization.unregister(this);
1931
+ return ptr;
1932
+ }
1933
+ free() {
1934
+ const ptr = this.__destroy_into_raw();
1935
+ wasm.__wbg_niowitnessset_free(ptr, 0);
1936
+ }
1937
+ /**
1938
+ * Deserialize from CBOR hex (as returned by CIP-30 signTx).
1939
+ * @param {string} hex_str
1940
+ * @returns {NioWitnessSet}
1941
+ */
1942
+ static from_cbor_hex(hex_str) {
1943
+ const ptr0 = passStringToWasm0(hex_str, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1944
+ const len0 = WASM_VECTOR_LEN;
1945
+ const ret = wasm.niowitnessset_from_cbor_hex(ptr0, len0);
1946
+ if (ret[2]) {
1947
+ throw takeFromExternrefTable0(ret[1]);
1948
+ }
1949
+ return NioWitnessSet.__wrap(ret[0]);
1950
+ }
1951
+ /**
1952
+ * Serialize to CBOR hex.
1953
+ * @returns {string}
1954
+ */
1955
+ to_cbor_hex() {
1956
+ let deferred1_0;
1957
+ let deferred1_1;
1958
+ try {
1959
+ const ret = wasm.niowitnessset_to_cbor_hex(this.__wbg_ptr);
1960
+ deferred1_0 = ret[0];
1961
+ deferred1_1 = ret[1];
1962
+ return getStringFromWasm0(ret[0], ret[1]);
1963
+ } finally {
1964
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1965
+ }
1966
+ }
1967
+ }
1968
+ if (Symbol.dispose) NioWitnessSet.prototype[Symbol.dispose] = NioWitnessSet.prototype.free;
1969
+
1970
+ /**
1971
+ * CIP-30 transaction send error codes.
1972
+ * @enum {1 | 2}
1973
+ */
1974
+ export const TxSendErrorCode = Object.freeze({
1975
+ Refused: 1, "1": "Refused",
1976
+ Failure: 2, "2": "Failure",
1977
+ });
1978
+
1979
+ /**
1980
+ * CIP-30 transaction sign error codes.
1981
+ * @enum {1 | 2}
1982
+ */
1983
+ export const TxSignErrorCode = Object.freeze({
1984
+ ProofGeneration: 1, "1": "ProofGeneration",
1985
+ UserDeclined: 2, "2": "UserDeclined",
1986
+ });
1987
+
1988
+ /**
1989
+ * The full CIP-30 wallet API handle (returned after enable).
1990
+ */
1991
+ export class WalletApi {
1992
+ static __wrap(ptr) {
1993
+ ptr = ptr >>> 0;
1994
+ const obj = Object.create(WalletApi.prototype);
1995
+ obj.__wbg_ptr = ptr;
1996
+ WalletApiFinalization.register(obj, obj.__wbg_ptr, obj);
1997
+ return obj;
1998
+ }
1999
+ __destroy_into_raw() {
2000
+ const ptr = this.__wbg_ptr;
2001
+ this.__wbg_ptr = 0;
2002
+ WalletApiFinalization.unregister(this);
2003
+ return ptr;
2004
+ }
2005
+ free() {
2006
+ const ptr = this.__destroy_into_raw();
2007
+ wasm.__wbg_walletapi_free(ptr, 0);
2008
+ }
2009
+ /**
2010
+ * Get the wallet balance as a NioValue.
2011
+ * @returns {Promise<NioValue>}
2012
+ */
2013
+ get_balance() {
2014
+ const ret = wasm.walletapi_get_balance(this.__wbg_ptr);
2015
+ return ret;
2016
+ }
2017
+ /**
2018
+ * Get the change address.
2019
+ * @returns {Promise<NioAddress>}
2020
+ */
2021
+ get_change_address() {
2022
+ const ret = wasm.walletapi_get_change_address(this.__wbg_ptr);
2023
+ return ret;
2024
+ }
2025
+ /**
2026
+ * Get collateral UTXOs for script execution.
2027
+ * @returns {Promise<NioUtxo[]>}
2028
+ */
2029
+ get_collateral() {
2030
+ const ret = wasm.walletapi_get_collateral(this.__wbg_ptr);
2031
+ return ret;
2032
+ }
2033
+ /**
2034
+ * Get wallet extensions (CIP-30).
2035
+ * @returns {Promise<Uint32Array>}
2036
+ */
2037
+ get_extensions() {
2038
+ const ret = wasm.walletapi_get_extensions(this.__wbg_ptr);
2039
+ return ret;
2040
+ }
2041
+ /**
2042
+ * Get the network ID (0 = testnet, 1 = mainnet).
2043
+ * @returns {Promise<number>}
2044
+ */
2045
+ get_network_id() {
2046
+ const ret = wasm.walletapi_get_network_id(this.__wbg_ptr);
2047
+ return ret;
2048
+ }
2049
+ /**
2050
+ * Get reward addresses (stake addresses).
2051
+ * @returns {Promise<NioAddress[]>}
2052
+ */
2053
+ get_reward_addresses() {
2054
+ const ret = wasm.walletapi_get_reward_addresses(this.__wbg_ptr);
2055
+ return ret;
2056
+ }
2057
+ /**
2058
+ * Get unused addresses.
2059
+ * @returns {Promise<NioAddress[]>}
2060
+ */
2061
+ get_unused_addresses() {
2062
+ const ret = wasm.walletapi_get_unused_addresses(this.__wbg_ptr);
2063
+ return ret;
2064
+ }
2065
+ /**
2066
+ * Get used addresses.
2067
+ * @returns {Promise<NioAddress[]>}
2068
+ */
2069
+ get_used_addresses() {
2070
+ const ret = wasm.walletapi_get_used_addresses(this.__wbg_ptr);
2071
+ return ret;
2072
+ }
2073
+ /**
2074
+ * Get all UTXOs from the wallet.
2075
+ * @returns {Promise<NioUtxo[]>}
2076
+ */
2077
+ get_utxos() {
2078
+ const ret = wasm.walletapi_get_utxos(this.__wbg_ptr);
2079
+ return ret;
2080
+ }
2081
+ /**
2082
+ * Sign arbitrary data (CIP-0008). Returns a DataSignature.
2083
+ * @param {string} addr_hex
2084
+ * @param {string} payload_hex
2085
+ * @returns {Promise<DataSignature>}
2086
+ */
2087
+ sign_data(addr_hex, payload_hex) {
2088
+ const ptr0 = passStringToWasm0(addr_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2089
+ const len0 = WASM_VECTOR_LEN;
2090
+ const ptr1 = passStringToWasm0(payload_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2091
+ const len1 = WASM_VECTOR_LEN;
2092
+ const ret = wasm.walletapi_sign_data(this.__wbg_ptr, ptr0, len0, ptr1, len1);
2093
+ return ret;
2094
+ }
2095
+ /**
2096
+ * Sign a transaction. Returns the CBOR hex of the witness set.
2097
+ *
2098
+ * - `tx_cbor_hex`: the CBOR-hex encoded unsigned transaction
2099
+ * - `partial_sign`: if true, only signs with keys the wallet controls
2100
+ * @param {string} tx_cbor_hex
2101
+ * @param {boolean} partial_sign
2102
+ * @returns {Promise<string>}
2103
+ */
2104
+ sign_tx(tx_cbor_hex, partial_sign) {
2105
+ const ptr0 = passStringToWasm0(tx_cbor_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2106
+ const len0 = WASM_VECTOR_LEN;
2107
+ const ret = wasm.walletapi_sign_tx(this.__wbg_ptr, ptr0, len0, partial_sign);
2108
+ return ret;
2109
+ }
2110
+ /**
2111
+ * Submit a signed transaction. Returns the transaction hash.
2112
+ * @param {string} tx_cbor_hex
2113
+ * @returns {Promise<string>}
2114
+ */
2115
+ submit_tx(tx_cbor_hex) {
2116
+ const ptr0 = passStringToWasm0(tx_cbor_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2117
+ const len0 = WASM_VECTOR_LEN;
2118
+ const ret = wasm.walletapi_submit_tx(this.__wbg_ptr, ptr0, len0);
2119
+ return ret;
2120
+ }
2121
+ }
2122
+ if (Symbol.dispose) WalletApi.prototype[Symbol.dispose] = WalletApi.prototype.free;
2123
+
2124
+ /**
2125
+ * A CIP-30 wallet provider discovered via `window.cardano`.
2126
+ */
2127
+ export class WalletProvider {
2128
+ static __wrap(ptr) {
2129
+ ptr = ptr >>> 0;
2130
+ const obj = Object.create(WalletProvider.prototype);
2131
+ obj.__wbg_ptr = ptr;
2132
+ WalletProviderFinalization.register(obj, obj.__wbg_ptr, obj);
2133
+ return obj;
2134
+ }
2135
+ __destroy_into_raw() {
2136
+ const ptr = this.__wbg_ptr;
2137
+ this.__wbg_ptr = 0;
2138
+ WalletProviderFinalization.unregister(this);
2139
+ return ptr;
2140
+ }
2141
+ free() {
2142
+ const ptr = this.__destroy_into_raw();
2143
+ wasm.__wbg_walletprovider_free(ptr, 0);
2144
+ }
2145
+ /**
2146
+ * @returns {string}
2147
+ */
2148
+ get api_version() {
2149
+ let deferred1_0;
2150
+ let deferred1_1;
2151
+ try {
2152
+ const ret = wasm.walletprovider_api_version(this.__wbg_ptr);
2153
+ deferred1_0 = ret[0];
2154
+ deferred1_1 = ret[1];
2155
+ return getStringFromWasm0(ret[0], ret[1]);
2156
+ } finally {
2157
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2158
+ }
2159
+ }
2160
+ /**
2161
+ * Enable this wallet, returning the full CIP-30 API handle.
2162
+ * @returns {Promise<WalletApi>}
2163
+ */
2164
+ enable() {
2165
+ const ret = wasm.walletprovider_enable(this.__wbg_ptr);
2166
+ return ret;
2167
+ }
2168
+ /**
2169
+ * Enable this wallet with CIP-95 governance extension.
2170
+ * @returns {Promise<WalletApi>}
2171
+ */
2172
+ enable_with_cip95() {
2173
+ const ret = wasm.walletprovider_enable_with_cip95(this.__wbg_ptr);
2174
+ return ret;
2175
+ }
2176
+ /**
2177
+ * @returns {string}
2178
+ */
2179
+ get icon() {
2180
+ let deferred1_0;
2181
+ let deferred1_1;
2182
+ try {
2183
+ const ret = wasm.walletprovider_icon(this.__wbg_ptr);
2184
+ deferred1_0 = ret[0];
2185
+ deferred1_1 = ret[1];
2186
+ return getStringFromWasm0(ret[0], ret[1]);
2187
+ } finally {
2188
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2189
+ }
2190
+ }
2191
+ /**
2192
+ * Check if this wallet extension is already enabled.
2193
+ * @returns {Promise<boolean>}
2194
+ */
2195
+ is_enabled() {
2196
+ const ret = wasm.walletprovider_is_enabled(this.__wbg_ptr);
2197
+ return ret;
2198
+ }
2199
+ /**
2200
+ * @returns {string}
2201
+ */
2202
+ get name() {
2203
+ let deferred1_0;
2204
+ let deferred1_1;
2205
+ try {
2206
+ const ret = wasm.walletprovider_name(this.__wbg_ptr);
2207
+ deferred1_0 = ret[0];
2208
+ deferred1_1 = ret[1];
2209
+ return getStringFromWasm0(ret[0], ret[1]);
2210
+ } finally {
2211
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2212
+ }
2213
+ }
2214
+ }
2215
+ if (Symbol.dispose) WalletProvider.prototype[Symbol.dispose] = WalletProvider.prototype.free;
2216
+
2217
+ /**
2218
+ * Delegate stake to a pool.
2219
+ *
2220
+ * Full flow:
2221
+ * 1. Get wallet addresses and UTXOs
2222
+ * 2. Build transaction with StakeRegistration (if needed) + StakeDelegation
2223
+ * 3. Sign via CIP-30 wallet
2224
+ * 4. Submit and return transaction hash
2225
+ * @param {WalletApi} wallet
2226
+ * @param {NioProtocolParameters} protocol_params
2227
+ * @param {string} pool_id_hex
2228
+ * @param {any} callback
2229
+ * @returns {Promise<string>}
2230
+ */
2231
+ export function delegate_stake_pool(wallet, protocol_params, pool_id_hex, callback) {
2232
+ _assertClass(wallet, WalletApi);
2233
+ _assertClass(protocol_params, NioProtocolParameters);
2234
+ const ptr0 = passStringToWasm0(pool_id_hex, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2235
+ const len0 = WASM_VECTOR_LEN;
2236
+ const ret = wasm.delegate_stake_pool(wallet.__wbg_ptr, protocol_params.__wbg_ptr, ptr0, len0, callback);
2237
+ return ret;
2238
+ }
2239
+
2240
+ /**
2241
+ * Discover all available CIP-30 wallet providers from `window.cardano`.
2242
+ * @returns {Promise<WalletProvider[]>}
2243
+ */
2244
+ export function discover_wallets() {
2245
+ const ret = wasm.discover_wallets();
2246
+ return ret;
2247
+ }
2248
+
2249
+ export function init() {
2250
+ wasm.init();
2251
+ }
2252
+
2253
+ /**
2254
+ * Delegate voting power to a DRep.
2255
+ *
2256
+ * Full flow:
2257
+ * 1. Get wallet addresses and UTXOs
2258
+ * 2. Build transaction with VoteDelegCert
2259
+ * 3. Sign via CIP-30 wallet
2260
+ * 4. Submit and return transaction hash
2261
+ * @param {WalletApi} wallet
2262
+ * @param {NioProtocolParameters} protocol_params
2263
+ * @param {NioDRep} drep
2264
+ * @param {any} callback
2265
+ * @returns {Promise<string>}
2266
+ */
2267
+ export function vote_delegation(wallet, protocol_params, drep, callback) {
2268
+ _assertClass(wallet, WalletApi);
2269
+ _assertClass(protocol_params, NioProtocolParameters);
2270
+ _assertClass(drep, NioDRep);
2271
+ const ret = wasm.vote_delegation(wallet.__wbg_ptr, protocol_params.__wbg_ptr, drep.__wbg_ptr, callback);
2272
+ return ret;
2273
+ }
2274
+
2275
+ function __wbg_get_imports() {
2276
+ const import0 = {
2277
+ __proto__: null,
2278
+ __wbg_Error_8c4e43fe74559d73: function(arg0, arg1) {
2279
+ const ret = Error(getStringFromWasm0(arg0, arg1));
2280
+ return ret;
2281
+ },
2282
+ __wbg___wbindgen_boolean_get_bbbb1c18aa2f5e25: function(arg0) {
2283
+ const v = arg0;
2284
+ const ret = typeof(v) === 'boolean' ? v : undefined;
2285
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
2286
+ },
2287
+ __wbg___wbindgen_debug_string_0bc8482c6e3508ae: function(arg0, arg1) {
2288
+ const ret = debugString(arg1);
2289
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2290
+ const len1 = WASM_VECTOR_LEN;
2291
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2292
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2293
+ },
2294
+ __wbg___wbindgen_is_function_0095a73b8b156f76: function(arg0) {
2295
+ const ret = typeof(arg0) === 'function';
2296
+ return ret;
2297
+ },
2298
+ __wbg___wbindgen_is_null_ac34f5003991759a: function(arg0) {
2299
+ const ret = arg0 === null;
2300
+ return ret;
2301
+ },
2302
+ __wbg___wbindgen_is_object_5ae8e5880f2c1fbd: function(arg0) {
2303
+ const val = arg0;
2304
+ const ret = typeof(val) === 'object' && val !== null;
2305
+ return ret;
2306
+ },
2307
+ __wbg___wbindgen_is_string_cd444516edc5b180: function(arg0) {
2308
+ const ret = typeof(arg0) === 'string';
2309
+ return ret;
2310
+ },
2311
+ __wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
2312
+ const ret = arg0 === undefined;
2313
+ return ret;
2314
+ },
2315
+ __wbg___wbindgen_number_get_8ff4255516ccad3e: function(arg0, arg1) {
2316
+ const obj = arg1;
2317
+ const ret = typeof(obj) === 'number' ? obj : undefined;
2318
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
2319
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
2320
+ },
2321
+ __wbg___wbindgen_string_get_72fb696202c56729: function(arg0, arg1) {
2322
+ const obj = arg1;
2323
+ const ret = typeof(obj) === 'string' ? obj : undefined;
2324
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2325
+ var len1 = WASM_VECTOR_LEN;
2326
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2327
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2328
+ },
2329
+ __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
2330
+ throw new Error(getStringFromWasm0(arg0, arg1));
2331
+ },
2332
+ __wbg__wbg_cb_unref_d9b87ff7982e3b21: function(arg0) {
2333
+ arg0._wbg_cb_unref();
2334
+ },
2335
+ __wbg_actionprogress_new: function(arg0) {
2336
+ const ret = ActionProgress.__wrap(arg0);
2337
+ return ret;
2338
+ },
2339
+ __wbg_apply_ada2ee1a60ac7b3c: function() { return handleError(function (arg0, arg1, arg2) {
2340
+ const ret = arg0.apply(arg1, arg2);
2341
+ return ret;
2342
+ }, arguments); },
2343
+ __wbg_call_389efe28435a9388: function() { return handleError(function (arg0, arg1) {
2344
+ const ret = arg0.call(arg1);
2345
+ return ret;
2346
+ }, arguments); },
2347
+ __wbg_call_4708e0c13bdc8e95: function() { return handleError(function (arg0, arg1, arg2) {
2348
+ const ret = arg0.call(arg1, arg2);
2349
+ return ret;
2350
+ }, arguments); },
2351
+ __wbg_crypto_86f2631e91b51511: function(arg0) {
2352
+ const ret = arg0.crypto;
2353
+ return ret;
2354
+ },
2355
+ __wbg_datasignature_new: function(arg0) {
2356
+ const ret = DataSignature.__wrap(arg0);
2357
+ return ret;
2358
+ },
2359
+ __wbg_getRandomValues_b3f15fcbfabb0f8b: function() { return handleError(function (arg0, arg1) {
2360
+ arg0.getRandomValues(arg1);
2361
+ }, arguments); },
2362
+ __wbg_get_9b94d73e6221f75c: function(arg0, arg1) {
2363
+ const ret = arg0[arg1 >>> 0];
2364
+ return ret;
2365
+ },
2366
+ __wbg_get_b3ed3ad4be2bc8ac: function() { return handleError(function (arg0, arg1) {
2367
+ const ret = Reflect.get(arg0, arg1);
2368
+ return ret;
2369
+ }, arguments); },
2370
+ __wbg_instanceof_Object_1c6af87502b733ed: function(arg0) {
2371
+ let result;
2372
+ try {
2373
+ result = arg0 instanceof Object;
2374
+ } catch (_) {
2375
+ result = false;
2376
+ }
2377
+ const ret = result;
2378
+ return ret;
2379
+ },
2380
+ __wbg_instanceof_Promise_0094681e3519d6ec: function(arg0) {
2381
+ let result;
2382
+ try {
2383
+ result = arg0 instanceof Promise;
2384
+ } catch (_) {
2385
+ result = false;
2386
+ }
2387
+ const ret = result;
2388
+ return ret;
2389
+ },
2390
+ __wbg_instanceof_Window_ed49b2db8df90359: function(arg0) {
2391
+ let result;
2392
+ try {
2393
+ result = arg0 instanceof Window;
2394
+ } catch (_) {
2395
+ result = false;
2396
+ }
2397
+ const ret = result;
2398
+ return ret;
2399
+ },
2400
+ __wbg_isArray_d314bb98fcf08331: function(arg0) {
2401
+ const ret = Array.isArray(arg0);
2402
+ return ret;
2403
+ },
2404
+ __wbg_keys_b50a709a76add04e: function(arg0) {
2405
+ const ret = Object.keys(arg0);
2406
+ return ret;
2407
+ },
2408
+ __wbg_length_32ed9a279acd054c: function(arg0) {
2409
+ const ret = arg0.length;
2410
+ return ret;
2411
+ },
2412
+ __wbg_length_35a7bace40f36eac: function(arg0) {
2413
+ const ret = arg0.length;
2414
+ return ret;
2415
+ },
2416
+ __wbg_msCrypto_d562bbe83e0d4b91: function(arg0) {
2417
+ const ret = arg0.msCrypto;
2418
+ return ret;
2419
+ },
2420
+ __wbg_new_361308b2356cecd0: function() {
2421
+ const ret = new Object();
2422
+ return ret;
2423
+ },
2424
+ __wbg_new_3eb36ae241fe6f44: function() {
2425
+ const ret = new Array();
2426
+ return ret;
2427
+ },
2428
+ __wbg_new_b5d9e2fb389fef91: function(arg0, arg1) {
2429
+ try {
2430
+ var state0 = {a: arg0, b: arg1};
2431
+ var cb0 = (arg0, arg1) => {
2432
+ const a = state0.a;
2433
+ state0.a = 0;
2434
+ try {
2435
+ return wasm_bindgen__convert__closures_____invoke__h14edc2e78c1d66d9(a, state0.b, arg0, arg1);
2436
+ } finally {
2437
+ state0.a = a;
2438
+ }
2439
+ };
2440
+ const ret = new Promise(cb0);
2441
+ return ret;
2442
+ } finally {
2443
+ state0.a = state0.b = 0;
2444
+ }
2445
+ },
2446
+ __wbg_new_no_args_1c7c842f08d00ebb: function(arg0, arg1) {
2447
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
2448
+ return ret;
2449
+ },
2450
+ __wbg_new_with_length_a2c39cbe88fd8ff1: function(arg0) {
2451
+ const ret = new Uint8Array(arg0 >>> 0);
2452
+ return ret;
2453
+ },
2454
+ __wbg_nioaddress_new: function(arg0) {
2455
+ const ret = NioAddress.__wrap(arg0);
2456
+ return ret;
2457
+ },
2458
+ __wbg_nioplutusdata_unwrap: function(arg0) {
2459
+ const ret = NioPlutusData.__unwrap(arg0);
2460
+ return ret;
2461
+ },
2462
+ __wbg_nioutxo_new: function(arg0) {
2463
+ const ret = NioUtxo.__wrap(arg0);
2464
+ return ret;
2465
+ },
2466
+ __wbg_nioutxo_unwrap: function(arg0) {
2467
+ const ret = NioUtxo.__unwrap(arg0);
2468
+ return ret;
2469
+ },
2470
+ __wbg_niovalue_new: function(arg0) {
2471
+ const ret = NioValue.__wrap(arg0);
2472
+ return ret;
2473
+ },
2474
+ __wbg_node_e1f24f89a7336c2e: function(arg0) {
2475
+ const ret = arg0.node;
2476
+ return ret;
2477
+ },
2478
+ __wbg_process_3975fd6c72f520aa: function(arg0) {
2479
+ const ret = arg0.process;
2480
+ return ret;
2481
+ },
2482
+ __wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
2483
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
2484
+ },
2485
+ __wbg_push_8ffdcb2063340ba5: function(arg0, arg1) {
2486
+ const ret = arg0.push(arg1);
2487
+ return ret;
2488
+ },
2489
+ __wbg_queueMicrotask_0aa0a927f78f5d98: function(arg0) {
2490
+ const ret = arg0.queueMicrotask;
2491
+ return ret;
2492
+ },
2493
+ __wbg_queueMicrotask_5bb536982f78a56f: function(arg0) {
2494
+ queueMicrotask(arg0);
2495
+ },
2496
+ __wbg_randomFillSync_f8c153b79f285817: function() { return handleError(function (arg0, arg1) {
2497
+ arg0.randomFillSync(arg1);
2498
+ }, arguments); },
2499
+ __wbg_require_b74f47fc2d022fd6: function() { return handleError(function () {
2500
+ const ret = module.require;
2501
+ return ret;
2502
+ }, arguments); },
2503
+ __wbg_resolve_002c4b7d9d8f6b64: function(arg0) {
2504
+ const ret = Promise.resolve(arg0);
2505
+ return ret;
2506
+ },
2507
+ __wbg_set_6cb8631f80447a67: function() { return handleError(function (arg0, arg1, arg2) {
2508
+ const ret = Reflect.set(arg0, arg1, arg2);
2509
+ return ret;
2510
+ }, arguments); },
2511
+ __wbg_static_accessor_GLOBAL_12837167ad935116: function() {
2512
+ const ret = typeof global === 'undefined' ? null : global;
2513
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
2514
+ },
2515
+ __wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f: function() {
2516
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
2517
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
2518
+ },
2519
+ __wbg_static_accessor_SELF_a621d3dfbb60d0ce: function() {
2520
+ const ret = typeof self === 'undefined' ? null : self;
2521
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
2522
+ },
2523
+ __wbg_static_accessor_WINDOW_f8727f0cf888e0bd: function() {
2524
+ const ret = typeof window === 'undefined' ? null : window;
2525
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
2526
+ },
2527
+ __wbg_subarray_a96e1fef17ed23cb: function(arg0, arg1, arg2) {
2528
+ const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
2529
+ return ret;
2530
+ },
2531
+ __wbg_then_0d9fe2c7b1857d32: function(arg0, arg1, arg2) {
2532
+ const ret = arg0.then(arg1, arg2);
2533
+ return ret;
2534
+ },
2535
+ __wbg_then_b9e7b3b5f1a9e1b5: function(arg0, arg1) {
2536
+ const ret = arg0.then(arg1);
2537
+ return ret;
2538
+ },
2539
+ __wbg_versions_4e31226f5e8dc909: function(arg0) {
2540
+ const ret = arg0.versions;
2541
+ return ret;
2542
+ },
2543
+ __wbg_walletapi_new: function(arg0) {
2544
+ const ret = WalletApi.__wrap(arg0);
2545
+ return ret;
2546
+ },
2547
+ __wbg_walletprovider_new: function(arg0) {
2548
+ const ret = WalletProvider.__wrap(arg0);
2549
+ return ret;
2550
+ },
2551
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
2552
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 180, function: Function { arguments: [Externref], shim_idx: 181, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2553
+ const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__haa43d5c6a389c195, wasm_bindgen__convert__closures_____invoke__hd58e0b50222c8226);
2554
+ return ret;
2555
+ },
2556
+ __wbindgen_cast_0000000000000002: function(arg0) {
2557
+ // Cast intrinsic for `F64 -> Externref`.
2558
+ const ret = arg0;
2559
+ return ret;
2560
+ },
2561
+ __wbindgen_cast_0000000000000003: function(arg0, arg1) {
2562
+ // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
2563
+ const ret = getArrayU8FromWasm0(arg0, arg1);
2564
+ return ret;
2565
+ },
2566
+ __wbindgen_cast_0000000000000004: function(arg0, arg1) {
2567
+ // Cast intrinsic for `Ref(String) -> Externref`.
2568
+ const ret = getStringFromWasm0(arg0, arg1);
2569
+ return ret;
2570
+ },
2571
+ __wbindgen_cast_0000000000000005: function(arg0, arg1) {
2572
+ var v0 = getArrayJsValueFromWasm0(arg0, arg1).slice();
2573
+ wasm.__wbindgen_free(arg0, arg1 * 4, 4);
2574
+ // Cast intrinsic for `Vector(NamedExternref("NioAddress")) -> Externref`.
2575
+ const ret = v0;
2576
+ return ret;
2577
+ },
2578
+ __wbindgen_cast_0000000000000006: function(arg0, arg1) {
2579
+ var v0 = getArrayJsValueFromWasm0(arg0, arg1).slice();
2580
+ wasm.__wbindgen_free(arg0, arg1 * 4, 4);
2581
+ // Cast intrinsic for `Vector(NamedExternref("NioUtxo")) -> Externref`.
2582
+ const ret = v0;
2583
+ return ret;
2584
+ },
2585
+ __wbindgen_cast_0000000000000007: function(arg0, arg1) {
2586
+ var v0 = getArrayJsValueFromWasm0(arg0, arg1).slice();
2587
+ wasm.__wbindgen_free(arg0, arg1 * 4, 4);
2588
+ // Cast intrinsic for `Vector(NamedExternref("WalletProvider")) -> Externref`.
2589
+ const ret = v0;
2590
+ return ret;
2591
+ },
2592
+ __wbindgen_cast_0000000000000008: function(arg0, arg1) {
2593
+ var v0 = getArrayU32FromWasm0(arg0, arg1).slice();
2594
+ wasm.__wbindgen_free(arg0, arg1 * 4, 4);
2595
+ // Cast intrinsic for `Vector(U32) -> Externref`.
2596
+ const ret = v0;
2597
+ return ret;
2598
+ },
2599
+ __wbindgen_init_externref_table: function() {
2600
+ const table = wasm.__wbindgen_externrefs;
2601
+ const offset = table.grow(4);
2602
+ table.set(0, undefined);
2603
+ table.set(offset + 0, undefined);
2604
+ table.set(offset + 1, null);
2605
+ table.set(offset + 2, true);
2606
+ table.set(offset + 3, false);
2607
+ },
2608
+ };
2609
+ return {
2610
+ __proto__: null,
2611
+ "./niors_bg.js": import0,
2612
+ };
2613
+ }
2614
+
2615
+ function wasm_bindgen__convert__closures_____invoke__hd58e0b50222c8226(arg0, arg1, arg2) {
2616
+ wasm.wasm_bindgen__convert__closures_____invoke__hd58e0b50222c8226(arg0, arg1, arg2);
2617
+ }
2618
+
2619
+ function wasm_bindgen__convert__closures_____invoke__h14edc2e78c1d66d9(arg0, arg1, arg2, arg3) {
2620
+ wasm.wasm_bindgen__convert__closures_____invoke__h14edc2e78c1d66d9(arg0, arg1, arg2, arg3);
2621
+ }
2622
+
2623
+ const ActionProgressFinalization = (typeof FinalizationRegistry === 'undefined')
2624
+ ? { register: () => {}, unregister: () => {} }
2625
+ : new FinalizationRegistry(ptr => wasm.__wbg_actionprogress_free(ptr >>> 0, 1));
2626
+ const DataSignatureFinalization = (typeof FinalizationRegistry === 'undefined')
2627
+ ? { register: () => {}, unregister: () => {} }
2628
+ : new FinalizationRegistry(ptr => wasm.__wbg_datasignature_free(ptr >>> 0, 1));
2629
+ const ExtensionFinalization = (typeof FinalizationRegistry === 'undefined')
2630
+ ? { register: () => {}, unregister: () => {} }
2631
+ : new FinalizationRegistry(ptr => wasm.__wbg_extension_free(ptr >>> 0, 1));
2632
+ const NioAddressFinalization = (typeof FinalizationRegistry === 'undefined')
2633
+ ? { register: () => {}, unregister: () => {} }
2634
+ : new FinalizationRegistry(ptr => wasm.__wbg_nioaddress_free(ptr >>> 0, 1));
2635
+ const NioCertificateFinalization = (typeof FinalizationRegistry === 'undefined')
2636
+ ? { register: () => {}, unregister: () => {} }
2637
+ : new FinalizationRegistry(ptr => wasm.__wbg_niocertificate_free(ptr >>> 0, 1));
2638
+ const NioCertificateFactoryFinalization = (typeof FinalizationRegistry === 'undefined')
2639
+ ? { register: () => {}, unregister: () => {} }
2640
+ : new FinalizationRegistry(ptr => wasm.__wbg_niocertificatefactory_free(ptr >>> 0, 1));
2641
+ const NioCredentialFinalization = (typeof FinalizationRegistry === 'undefined')
2642
+ ? { register: () => {}, unregister: () => {} }
2643
+ : new FinalizationRegistry(ptr => wasm.__wbg_niocredential_free(ptr >>> 0, 1));
2644
+ const NioDRepFinalization = (typeof FinalizationRegistry === 'undefined')
2645
+ ? { register: () => {}, unregister: () => {} }
2646
+ : new FinalizationRegistry(ptr => wasm.__wbg_niodrep_free(ptr >>> 0, 1));
2647
+ const NioExUnitsFinalization = (typeof FinalizationRegistry === 'undefined')
2648
+ ? { register: () => {}, unregister: () => {} }
2649
+ : new FinalizationRegistry(ptr => wasm.__wbg_nioexunits_free(ptr >>> 0, 1));
2650
+ const NioGovActionIdFinalization = (typeof FinalizationRegistry === 'undefined')
2651
+ ? { register: () => {}, unregister: () => {} }
2652
+ : new FinalizationRegistry(ptr => wasm.__wbg_niogovactionid_free(ptr >>> 0, 1));
2653
+ const NioMetadataFinalization = (typeof FinalizationRegistry === 'undefined')
2654
+ ? { register: () => {}, unregister: () => {} }
2655
+ : new FinalizationRegistry(ptr => wasm.__wbg_niometadata_free(ptr >>> 0, 1));
2656
+ const NioPlutusDataFinalization = (typeof FinalizationRegistry === 'undefined')
2657
+ ? { register: () => {}, unregister: () => {} }
2658
+ : new FinalizationRegistry(ptr => wasm.__wbg_nioplutusdata_free(ptr >>> 0, 1));
2659
+ const NioPlutusScriptFinalization = (typeof FinalizationRegistry === 'undefined')
2660
+ ? { register: () => {}, unregister: () => {} }
2661
+ : new FinalizationRegistry(ptr => wasm.__wbg_nioplutusscript_free(ptr >>> 0, 1));
2662
+ const NioProposalProcedureFinalization = (typeof FinalizationRegistry === 'undefined')
2663
+ ? { register: () => {}, unregister: () => {} }
2664
+ : new FinalizationRegistry(ptr => wasm.__wbg_nioproposalprocedure_free(ptr >>> 0, 1));
2665
+ const NioProtocolParametersFinalization = (typeof FinalizationRegistry === 'undefined')
2666
+ ? { register: () => {}, unregister: () => {} }
2667
+ : new FinalizationRegistry(ptr => wasm.__wbg_nioprotocolparameters_free(ptr >>> 0, 1));
2668
+ const NioTransactionFinalization = (typeof FinalizationRegistry === 'undefined')
2669
+ ? { register: () => {}, unregister: () => {} }
2670
+ : new FinalizationRegistry(ptr => wasm.__wbg_niotransaction_free(ptr >>> 0, 1));
2671
+ const NioTransactionBuilderFinalization = (typeof FinalizationRegistry === 'undefined')
2672
+ ? { register: () => {}, unregister: () => {} }
2673
+ : new FinalizationRegistry(ptr => wasm.__wbg_niotransactionbuilder_free(ptr >>> 0, 1));
2674
+ const NioTransactionInputFinalization = (typeof FinalizationRegistry === 'undefined')
2675
+ ? { register: () => {}, unregister: () => {} }
2676
+ : new FinalizationRegistry(ptr => wasm.__wbg_niotransactioninput_free(ptr >>> 0, 1));
2677
+ const NioTransactionOutputFinalization = (typeof FinalizationRegistry === 'undefined')
2678
+ ? { register: () => {}, unregister: () => {} }
2679
+ : new FinalizationRegistry(ptr => wasm.__wbg_niotransactionoutput_free(ptr >>> 0, 1));
2680
+ const NioUtxoFinalization = (typeof FinalizationRegistry === 'undefined')
2681
+ ? { register: () => {}, unregister: () => {} }
2682
+ : new FinalizationRegistry(ptr => wasm.__wbg_nioutxo_free(ptr >>> 0, 1));
2683
+ const NioValueFinalization = (typeof FinalizationRegistry === 'undefined')
2684
+ ? { register: () => {}, unregister: () => {} }
2685
+ : new FinalizationRegistry(ptr => wasm.__wbg_niovalue_free(ptr >>> 0, 1));
2686
+ const NioVoterFinalization = (typeof FinalizationRegistry === 'undefined')
2687
+ ? { register: () => {}, unregister: () => {} }
2688
+ : new FinalizationRegistry(ptr => wasm.__wbg_niovoter_free(ptr >>> 0, 1));
2689
+ const NioVotingProcedureFinalization = (typeof FinalizationRegistry === 'undefined')
2690
+ ? { register: () => {}, unregister: () => {} }
2691
+ : new FinalizationRegistry(ptr => wasm.__wbg_niovotingprocedure_free(ptr >>> 0, 1));
2692
+ const NioWitnessSetFinalization = (typeof FinalizationRegistry === 'undefined')
2693
+ ? { register: () => {}, unregister: () => {} }
2694
+ : new FinalizationRegistry(ptr => wasm.__wbg_niowitnessset_free(ptr >>> 0, 1));
2695
+ const WalletApiFinalization = (typeof FinalizationRegistry === 'undefined')
2696
+ ? { register: () => {}, unregister: () => {} }
2697
+ : new FinalizationRegistry(ptr => wasm.__wbg_walletapi_free(ptr >>> 0, 1));
2698
+ const WalletProviderFinalization = (typeof FinalizationRegistry === 'undefined')
2699
+ ? { register: () => {}, unregister: () => {} }
2700
+ : new FinalizationRegistry(ptr => wasm.__wbg_walletprovider_free(ptr >>> 0, 1));
2701
+
2702
+ function addToExternrefTable0(obj) {
2703
+ const idx = wasm.__externref_table_alloc();
2704
+ wasm.__wbindgen_externrefs.set(idx, obj);
2705
+ return idx;
2706
+ }
2707
+
2708
+ function _assertClass(instance, klass) {
2709
+ if (!(instance instanceof klass)) {
2710
+ throw new Error(`expected instance of ${klass.name}`);
2711
+ }
2712
+ }
2713
+
2714
+ const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
2715
+ ? { register: () => {}, unregister: () => {} }
2716
+ : new FinalizationRegistry(state => state.dtor(state.a, state.b));
2717
+
2718
+ function debugString(val) {
2719
+ // primitive types
2720
+ const type = typeof val;
2721
+ if (type == 'number' || type == 'boolean' || val == null) {
2722
+ return `${val}`;
2723
+ }
2724
+ if (type == 'string') {
2725
+ return `"${val}"`;
2726
+ }
2727
+ if (type == 'symbol') {
2728
+ const description = val.description;
2729
+ if (description == null) {
2730
+ return 'Symbol';
2731
+ } else {
2732
+ return `Symbol(${description})`;
2733
+ }
2734
+ }
2735
+ if (type == 'function') {
2736
+ const name = val.name;
2737
+ if (typeof name == 'string' && name.length > 0) {
2738
+ return `Function(${name})`;
2739
+ } else {
2740
+ return 'Function';
2741
+ }
2742
+ }
2743
+ // objects
2744
+ if (Array.isArray(val)) {
2745
+ const length = val.length;
2746
+ let debug = '[';
2747
+ if (length > 0) {
2748
+ debug += debugString(val[0]);
2749
+ }
2750
+ for(let i = 1; i < length; i++) {
2751
+ debug += ', ' + debugString(val[i]);
2752
+ }
2753
+ debug += ']';
2754
+ return debug;
2755
+ }
2756
+ // Test for built-in
2757
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
2758
+ let className;
2759
+ if (builtInMatches && builtInMatches.length > 1) {
2760
+ className = builtInMatches[1];
2761
+ } else {
2762
+ // Failed to match the standard '[object ClassName]'
2763
+ return toString.call(val);
2764
+ }
2765
+ if (className == 'Object') {
2766
+ // we're a user defined class or Object
2767
+ // JSON.stringify avoids problems with cycles, and is generally much
2768
+ // easier than looping through ownProperties of `val`.
2769
+ try {
2770
+ return 'Object(' + JSON.stringify(val) + ')';
2771
+ } catch (_) {
2772
+ return 'Object';
2773
+ }
2774
+ }
2775
+ // errors
2776
+ if (val instanceof Error) {
2777
+ return `${val.name}: ${val.message}\n${val.stack}`;
2778
+ }
2779
+ // TODO we could test for more things here, like `Set`s and `Map`s.
2780
+ return className;
2781
+ }
2782
+
2783
+ function getArrayJsValueFromWasm0(ptr, len) {
2784
+ ptr = ptr >>> 0;
2785
+ const mem = getDataViewMemory0();
2786
+ const result = [];
2787
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
2788
+ result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
2789
+ }
2790
+ wasm.__externref_drop_slice(ptr, len);
2791
+ return result;
2792
+ }
2793
+
2794
+ function getArrayU32FromWasm0(ptr, len) {
2795
+ ptr = ptr >>> 0;
2796
+ return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
2797
+ }
2798
+
2799
+ function getArrayU8FromWasm0(ptr, len) {
2800
+ ptr = ptr >>> 0;
2801
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
2802
+ }
2803
+
2804
+ let cachedDataViewMemory0 = null;
2805
+ function getDataViewMemory0() {
2806
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
2807
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
2808
+ }
2809
+ return cachedDataViewMemory0;
2810
+ }
2811
+
2812
+ function getStringFromWasm0(ptr, len) {
2813
+ ptr = ptr >>> 0;
2814
+ return decodeText(ptr, len);
2815
+ }
2816
+
2817
+ let cachedUint32ArrayMemory0 = null;
2818
+ function getUint32ArrayMemory0() {
2819
+ if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
2820
+ cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
2821
+ }
2822
+ return cachedUint32ArrayMemory0;
2823
+ }
2824
+
2825
+ let cachedUint8ArrayMemory0 = null;
2826
+ function getUint8ArrayMemory0() {
2827
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
2828
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
2829
+ }
2830
+ return cachedUint8ArrayMemory0;
2831
+ }
2832
+
2833
+ function handleError(f, args) {
2834
+ try {
2835
+ return f.apply(this, args);
2836
+ } catch (e) {
2837
+ const idx = addToExternrefTable0(e);
2838
+ wasm.__wbindgen_exn_store(idx);
2839
+ }
2840
+ }
2841
+
2842
+ function isLikeNone(x) {
2843
+ return x === undefined || x === null;
2844
+ }
2845
+
2846
+ function makeMutClosure(arg0, arg1, dtor, f) {
2847
+ const state = { a: arg0, b: arg1, cnt: 1, dtor };
2848
+ const real = (...args) => {
2849
+
2850
+ // First up with a closure we increment the internal reference
2851
+ // count. This ensures that the Rust closure environment won't
2852
+ // be deallocated while we're invoking it.
2853
+ state.cnt++;
2854
+ const a = state.a;
2855
+ state.a = 0;
2856
+ try {
2857
+ return f(a, state.b, ...args);
2858
+ } finally {
2859
+ state.a = a;
2860
+ real._wbg_cb_unref();
2861
+ }
2862
+ };
2863
+ real._wbg_cb_unref = () => {
2864
+ if (--state.cnt === 0) {
2865
+ state.dtor(state.a, state.b);
2866
+ state.a = 0;
2867
+ CLOSURE_DTORS.unregister(state);
2868
+ }
2869
+ };
2870
+ CLOSURE_DTORS.register(real, state, state);
2871
+ return real;
2872
+ }
2873
+
2874
+ function passArrayJsValueToWasm0(array, malloc) {
2875
+ const ptr = malloc(array.length * 4, 4) >>> 0;
2876
+ for (let i = 0; i < array.length; i++) {
2877
+ const add = addToExternrefTable0(array[i]);
2878
+ getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
2879
+ }
2880
+ WASM_VECTOR_LEN = array.length;
2881
+ return ptr;
2882
+ }
2883
+
2884
+ function passStringToWasm0(arg, malloc, realloc) {
2885
+ if (realloc === undefined) {
2886
+ const buf = cachedTextEncoder.encode(arg);
2887
+ const ptr = malloc(buf.length, 1) >>> 0;
2888
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
2889
+ WASM_VECTOR_LEN = buf.length;
2890
+ return ptr;
2891
+ }
2892
+
2893
+ let len = arg.length;
2894
+ let ptr = malloc(len, 1) >>> 0;
2895
+
2896
+ const mem = getUint8ArrayMemory0();
2897
+
2898
+ let offset = 0;
2899
+
2900
+ for (; offset < len; offset++) {
2901
+ const code = arg.charCodeAt(offset);
2902
+ if (code > 0x7F) break;
2903
+ mem[ptr + offset] = code;
2904
+ }
2905
+ if (offset !== len) {
2906
+ if (offset !== 0) {
2907
+ arg = arg.slice(offset);
2908
+ }
2909
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
2910
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
2911
+ const ret = cachedTextEncoder.encodeInto(arg, view);
2912
+
2913
+ offset += ret.written;
2914
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
2915
+ }
2916
+
2917
+ WASM_VECTOR_LEN = offset;
2918
+ return ptr;
2919
+ }
2920
+
2921
+ function takeFromExternrefTable0(idx) {
2922
+ const value = wasm.__wbindgen_externrefs.get(idx);
2923
+ wasm.__externref_table_dealloc(idx);
2924
+ return value;
2925
+ }
2926
+
2927
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
2928
+ cachedTextDecoder.decode();
2929
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
2930
+ let numBytesDecoded = 0;
2931
+ function decodeText(ptr, len) {
2932
+ numBytesDecoded += len;
2933
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
2934
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
2935
+ cachedTextDecoder.decode();
2936
+ numBytesDecoded = len;
2937
+ }
2938
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
2939
+ }
2940
+
2941
+ const cachedTextEncoder = new TextEncoder();
2942
+
2943
+ if (!('encodeInto' in cachedTextEncoder)) {
2944
+ cachedTextEncoder.encodeInto = function (arg, view) {
2945
+ const buf = cachedTextEncoder.encode(arg);
2946
+ view.set(buf);
2947
+ return {
2948
+ read: arg.length,
2949
+ written: buf.length
2950
+ };
2951
+ };
2952
+ }
2953
+
2954
+ let WASM_VECTOR_LEN = 0;
2955
+
2956
+ let wasmModule, wasm;
2957
+ function __wbg_finalize_init(instance, module) {
2958
+ wasm = instance.exports;
2959
+ wasmModule = module;
2960
+ cachedDataViewMemory0 = null;
2961
+ cachedUint32ArrayMemory0 = null;
2962
+ cachedUint8ArrayMemory0 = null;
2963
+ wasm.__wbindgen_start();
2964
+ return wasm;
2965
+ }
2966
+
2967
+ async function __wbg_load(module, imports) {
2968
+ if (typeof Response === 'function' && module instanceof Response) {
2969
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
2970
+ try {
2971
+ return await WebAssembly.instantiateStreaming(module, imports);
2972
+ } catch (e) {
2973
+ const validResponse = module.ok && expectedResponseType(module.type);
2974
+
2975
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
2976
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
2977
+
2978
+ } else { throw e; }
2979
+ }
2980
+ }
2981
+
2982
+ const bytes = await module.arrayBuffer();
2983
+ return await WebAssembly.instantiate(bytes, imports);
2984
+ } else {
2985
+ const instance = await WebAssembly.instantiate(module, imports);
2986
+
2987
+ if (instance instanceof WebAssembly.Instance) {
2988
+ return { instance, module };
2989
+ } else {
2990
+ return instance;
2991
+ }
2992
+ }
2993
+
2994
+ function expectedResponseType(type) {
2995
+ switch (type) {
2996
+ case 'basic': case 'cors': case 'default': return true;
2997
+ }
2998
+ return false;
2999
+ }
3000
+ }
3001
+
3002
+ function initSync(module) {
3003
+ if (wasm !== undefined) return wasm;
3004
+
3005
+
3006
+ if (module !== undefined) {
3007
+ if (Object.getPrototypeOf(module) === Object.prototype) {
3008
+ ({module} = module)
3009
+ } else {
3010
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
3011
+ }
3012
+ }
3013
+
3014
+ const imports = __wbg_get_imports();
3015
+ if (!(module instanceof WebAssembly.Module)) {
3016
+ module = new WebAssembly.Module(module);
3017
+ }
3018
+ const instance = new WebAssembly.Instance(module, imports);
3019
+ return __wbg_finalize_init(instance, module);
3020
+ }
3021
+
3022
+ async function __wbg_init(module_or_path) {
3023
+ if (wasm !== undefined) return wasm;
3024
+
3025
+
3026
+ if (module_or_path !== undefined) {
3027
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
3028
+ ({module_or_path} = module_or_path)
3029
+ } else {
3030
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
3031
+ }
3032
+ }
3033
+
3034
+ if (module_or_path === undefined) {
3035
+ module_or_path = new URL('niors_bg.wasm', import.meta.url);
3036
+ }
3037
+ const imports = __wbg_get_imports();
3038
+
3039
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
3040
+ module_or_path = fetch(module_or_path);
3041
+ }
3042
+
3043
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
3044
+
3045
+ return __wbg_finalize_init(instance, module);
3046
+ }
3047
+
3048
+ export { initSync, __wbg_init as default };