@nockbox/iris-wasm 0.1.1 → 0.2.0-alpha.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/iris_wasm.d.ts +89 -22
- package/iris_wasm.js +307 -65
- package/iris_wasm_bg.wasm +0 -0
- package/package.json +1 -1
package/iris_wasm.d.ts
CHANGED
|
@@ -1,29 +1,33 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
-
/**
|
|
4
|
-
* Hash a public key to get its digest (for use in PKH)
|
|
5
|
-
*/
|
|
6
|
-
export function hashPublicKey(public_key_bytes: Uint8Array): string;
|
|
7
|
-
/**
|
|
8
|
-
* Derive master key from seed bytes
|
|
9
|
-
*/
|
|
10
|
-
export function deriveMasterKey(seed: Uint8Array): ExtendedKey;
|
|
11
3
|
/**
|
|
12
4
|
* Hash a noun (jam as input)
|
|
13
5
|
*/
|
|
14
6
|
export function hashNoun(noun: Uint8Array): string;
|
|
7
|
+
/**
|
|
8
|
+
* Sign a message string with a private key
|
|
9
|
+
*/
|
|
10
|
+
export function signMessage(private_key_bytes: Uint8Array, message: string): Signature;
|
|
15
11
|
/**
|
|
16
12
|
* Hash a u64 value
|
|
17
13
|
*/
|
|
18
14
|
export function hashU64(value: bigint): string;
|
|
15
|
+
/**
|
|
16
|
+
* Derive master key from seed bytes
|
|
17
|
+
*/
|
|
18
|
+
export function deriveMasterKey(seed: Uint8Array): ExtendedKey;
|
|
19
|
+
/**
|
|
20
|
+
* Verify a signature with a public key
|
|
21
|
+
*/
|
|
22
|
+
export function verifySignature(public_key_bytes: Uint8Array, signature: Signature, message: string): boolean;
|
|
19
23
|
/**
|
|
20
24
|
* Derive master key from BIP39 mnemonic phrase
|
|
21
25
|
*/
|
|
22
26
|
export function deriveMasterKeyFromMnemonic(mnemonic: string, passphrase?: string | null): ExtendedKey;
|
|
23
27
|
/**
|
|
24
|
-
*
|
|
28
|
+
* Hash a public key to get its digest (for use in PKH)
|
|
25
29
|
*/
|
|
26
|
-
export function
|
|
30
|
+
export function hashPublicKey(public_key_bytes: Uint8Array): string;
|
|
27
31
|
/**
|
|
28
32
|
* The `ReadableStreamType` enum.
|
|
29
33
|
*
|
|
@@ -168,12 +172,39 @@ export class Note {
|
|
|
168
172
|
* Expects response.notes[i].note (handles version internally)
|
|
169
173
|
*/
|
|
170
174
|
static fromProtobuf(pb_note: any): Note;
|
|
175
|
+
/**
|
|
176
|
+
* Create a new V1 note (the default for new notes)
|
|
177
|
+
*/
|
|
171
178
|
constructor(version: Version, origin_page: bigint, name: Name, note_data: NoteData, assets: bigint);
|
|
172
179
|
hash(): Digest;
|
|
180
|
+
/**
|
|
181
|
+
* Create a new V0 (legacy) note
|
|
182
|
+
*
|
|
183
|
+
* V0 notes are legacy notes that use public keys directly instead of spend conditions.
|
|
184
|
+
* - `origin_page`: Block height where the note originated
|
|
185
|
+
* - `sig_m`: Number of required signatures (m-of-n)
|
|
186
|
+
* - `sig_pubkeys`: Public keys as 97-byte arrays (big-endian format)
|
|
187
|
+
* - `source_hash`: Hash of the source (seeds that created this note)
|
|
188
|
+
* - `is_coinbase`: Whether this is a coinbase note
|
|
189
|
+
* - `timelock`: Optional timelock constraints (must have at least one constraint if provided)
|
|
190
|
+
* - `assets`: Amount of nicks in this note
|
|
191
|
+
*/
|
|
192
|
+
static newV0(origin_page: bigint, sig_m: bigint, sig_pubkeys: Uint8Array[], source_hash: Digest, is_coinbase: boolean, timelock: Timelock | null | undefined, assets: bigint): Note;
|
|
173
193
|
readonly originPage: bigint;
|
|
174
194
|
readonly name: Name;
|
|
195
|
+
/**
|
|
196
|
+
* Check if this is a V0 (legacy) note
|
|
197
|
+
*/
|
|
198
|
+
readonly isV0: boolean;
|
|
199
|
+
/**
|
|
200
|
+
* Check if this is a V1 note
|
|
201
|
+
*/
|
|
202
|
+
readonly isV1: boolean;
|
|
175
203
|
readonly assets: bigint;
|
|
176
204
|
readonly version: Version;
|
|
205
|
+
/**
|
|
206
|
+
* Returns note data. For V0 notes this returns empty NoteData since V0 doesn't have this field.
|
|
207
|
+
*/
|
|
177
208
|
readonly noteData: NoteData;
|
|
178
209
|
}
|
|
179
210
|
export class NoteData {
|
|
@@ -195,6 +226,15 @@ export class NoteDataEntry {
|
|
|
195
226
|
readonly key: string;
|
|
196
227
|
readonly blob: Uint8Array;
|
|
197
228
|
}
|
|
229
|
+
export class Noun {
|
|
230
|
+
private constructor();
|
|
231
|
+
free(): void;
|
|
232
|
+
[Symbol.dispose](): void;
|
|
233
|
+
static cue(jam: Uint8Array): Noun;
|
|
234
|
+
jam(): Uint8Array;
|
|
235
|
+
static fromJs(value: any): Noun;
|
|
236
|
+
toJs(): any;
|
|
237
|
+
}
|
|
198
238
|
export class Pkh {
|
|
199
239
|
free(): void;
|
|
200
240
|
[Symbol.dispose](): void;
|
|
@@ -241,9 +281,9 @@ export class Seed {
|
|
|
241
281
|
gift: bigint;
|
|
242
282
|
}
|
|
243
283
|
export class Signature {
|
|
244
|
-
private constructor();
|
|
245
284
|
free(): void;
|
|
246
285
|
[Symbol.dispose](): void;
|
|
286
|
+
constructor(c: Uint8Array, s: Uint8Array);
|
|
247
287
|
readonly c: Uint8Array;
|
|
248
288
|
readonly s: Uint8Array;
|
|
249
289
|
}
|
|
@@ -301,7 +341,7 @@ export class SpendBuilder {
|
|
|
301
341
|
/**
|
|
302
342
|
* Create a new `SpendBuilder` with a given note and spend condition
|
|
303
343
|
*/
|
|
304
|
-
constructor(note: Note, spend_condition
|
|
344
|
+
constructor(note: Note, spend_condition?: SpendCondition | null, refund_lock?: SpendCondition | null);
|
|
305
345
|
/**
|
|
306
346
|
* Add seed to this spend
|
|
307
347
|
*
|
|
@@ -326,6 +366,19 @@ export class SpendCondition {
|
|
|
326
366
|
hash(): Digest;
|
|
327
367
|
static newPkh(pkh: Pkh): SpendCondition;
|
|
328
368
|
}
|
|
369
|
+
/**
|
|
370
|
+
* Timelock for V0 (legacy) notes
|
|
371
|
+
*
|
|
372
|
+
* This is similar to LockTim but used for v0 notes' timelock constraints.
|
|
373
|
+
* At least one constraint (min or max in either rel or abs) must be set.
|
|
374
|
+
*/
|
|
375
|
+
export class Timelock {
|
|
376
|
+
free(): void;
|
|
377
|
+
[Symbol.dispose](): void;
|
|
378
|
+
constructor(rel: TimelockRange, abs: TimelockRange);
|
|
379
|
+
readonly abs: TimelockRange;
|
|
380
|
+
readonly rel: TimelockRange;
|
|
381
|
+
}
|
|
329
382
|
export class TimelockRange {
|
|
330
383
|
free(): void;
|
|
331
384
|
[Symbol.dispose](): void;
|
|
@@ -470,6 +523,7 @@ export interface InitOutput {
|
|
|
470
523
|
readonly __wbg_source_free: (a: number, b: number) => void;
|
|
471
524
|
readonly __wbg_spendbuilder_free: (a: number, b: number) => void;
|
|
472
525
|
readonly __wbg_spendcondition_free: (a: number, b: number) => void;
|
|
526
|
+
readonly __wbg_timelock_free: (a: number, b: number) => void;
|
|
473
527
|
readonly __wbg_timelockrange_free: (a: number, b: number) => void;
|
|
474
528
|
readonly __wbg_txbuilder_free: (a: number, b: number) => void;
|
|
475
529
|
readonly __wbg_txnotes_free: (a: number, b: number) => void;
|
|
@@ -510,9 +564,12 @@ export interface InitOutput {
|
|
|
510
564
|
readonly nockchaintx_version: (a: number) => number;
|
|
511
565
|
readonly note_assets: (a: number) => bigint;
|
|
512
566
|
readonly note_fromProtobuf: (a: any) => [number, number, number];
|
|
513
|
-
readonly note_hash: (a: number) =>
|
|
567
|
+
readonly note_hash: (a: number) => number;
|
|
568
|
+
readonly note_isV0: (a: number) => number;
|
|
569
|
+
readonly note_isV1: (a: number) => number;
|
|
514
570
|
readonly note_name: (a: number) => number;
|
|
515
|
-
readonly note_new: (a: number, b: bigint, c: number, d: number, e: bigint) => number;
|
|
571
|
+
readonly note_new: (a: number, b: bigint, c: number, d: number, e: bigint) => [number, number, number];
|
|
572
|
+
readonly note_newV0: (a: bigint, b: bigint, c: number, d: number, e: number, f: number, g: number, h: bigint) => [number, number, number];
|
|
516
573
|
readonly note_noteData: (a: number) => number;
|
|
517
574
|
readonly note_originPage: (a: number) => bigint;
|
|
518
575
|
readonly note_toProtobuf: (a: number) => [number, number, number];
|
|
@@ -540,7 +597,7 @@ export interface InitOutput {
|
|
|
540
597
|
readonly rawtx_name: (a: number) => [number, number];
|
|
541
598
|
readonly rawtx_outputs: (a: number) => [number, number];
|
|
542
599
|
readonly rawtx_toJam: (a: number) => any;
|
|
543
|
-
readonly rawtx_toNockchainTx: (a: number) => number;
|
|
600
|
+
readonly rawtx_toNockchainTx: (a: number) => [number, number, number];
|
|
544
601
|
readonly rawtx_toProtobuf: (a: number) => [number, number, number];
|
|
545
602
|
readonly rawtx_version: (a: number) => number;
|
|
546
603
|
readonly seed_gift: (a: number) => bigint;
|
|
@@ -573,11 +630,12 @@ export interface InitOutput {
|
|
|
573
630
|
readonly spendcondition_new: (a: number, b: number) => number;
|
|
574
631
|
readonly spendcondition_newPkh: (a: number) => number;
|
|
575
632
|
readonly spendcondition_toProtobuf: (a: number) => [number, number, number];
|
|
633
|
+
readonly timelock_new: (a: number, b: number) => [number, number, number];
|
|
576
634
|
readonly timelockrange_max: (a: number) => [number, bigint];
|
|
577
635
|
readonly timelockrange_min: (a: number) => [number, bigint];
|
|
578
636
|
readonly timelockrange_new: (a: number, b: bigint, c: number, d: bigint) => number;
|
|
579
637
|
readonly txbuilder_addPreimage: (a: number, b: number, c: number) => [number, number, number];
|
|
580
|
-
readonly txbuilder_allNotes: (a: number) => number;
|
|
638
|
+
readonly txbuilder_allNotes: (a: number) => [number, number, number];
|
|
581
639
|
readonly txbuilder_allSpends: (a: number) => [number, number];
|
|
582
640
|
readonly txbuilder_build: (a: number) => [number, number, number];
|
|
583
641
|
readonly txbuilder_calcFee: (a: number) => bigint;
|
|
@@ -598,7 +656,11 @@ export interface InitOutput {
|
|
|
598
656
|
readonly wasmseed_fromProtobuf: (a: any) => [number, number, number];
|
|
599
657
|
readonly wasmseed_toProtobuf: (a: number) => [number, number, number];
|
|
600
658
|
readonly version_new: (a: number) => number;
|
|
659
|
+
readonly timelock_abs: (a: number) => number;
|
|
660
|
+
readonly timelock_rel: (a: number) => number;
|
|
601
661
|
readonly __wbg_extendedkey_free: (a: number, b: number) => void;
|
|
662
|
+
readonly __wbg_grpcclient_free: (a: number, b: number) => void;
|
|
663
|
+
readonly __wbg_noun_free: (a: number, b: number) => void;
|
|
602
664
|
readonly __wbg_signature_free: (a: number, b: number) => void;
|
|
603
665
|
readonly deriveMasterKey: (a: number, b: number) => number;
|
|
604
666
|
readonly deriveMasterKeyFromMnemonic: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
@@ -606,18 +668,23 @@ export interface InitOutput {
|
|
|
606
668
|
readonly extendedkey_deriveChild: (a: number, b: number) => [number, number, number];
|
|
607
669
|
readonly extendedkey_privateKey: (a: number) => [number, number];
|
|
608
670
|
readonly extendedkey_publicKey: (a: number) => [number, number];
|
|
671
|
+
readonly grpcclient_getBalanceByAddress: (a: number, b: number, c: number) => any;
|
|
672
|
+
readonly grpcclient_getBalanceByFirstName: (a: number, b: number, c: number) => any;
|
|
673
|
+
readonly grpcclient_new: (a: number, b: number) => number;
|
|
674
|
+
readonly grpcclient_sendTransaction: (a: number, b: any) => any;
|
|
675
|
+
readonly grpcclient_transactionAccepted: (a: number, b: number, c: number) => any;
|
|
609
676
|
readonly hashNoun: (a: number, b: number) => [number, number, number, number];
|
|
610
677
|
readonly hashPublicKey: (a: number, b: number) => [number, number, number, number];
|
|
611
678
|
readonly hashU64: (a: bigint) => [number, number];
|
|
679
|
+
readonly noun_cue: (a: number, b: number) => [number, number, number];
|
|
680
|
+
readonly noun_fromJs: (a: any) => [number, number, number];
|
|
681
|
+
readonly noun_jam: (a: number) => [number, number, number, number];
|
|
682
|
+
readonly noun_toJs: (a: number) => [number, number, number];
|
|
612
683
|
readonly signMessage: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
613
684
|
readonly signature_c: (a: number) => [number, number];
|
|
685
|
+
readonly signature_new: (a: number, b: number, c: number, d: number) => number;
|
|
614
686
|
readonly signature_s: (a: number) => [number, number];
|
|
615
|
-
readonly
|
|
616
|
-
readonly grpcclient_getBalanceByAddress: (a: number, b: number, c: number) => any;
|
|
617
|
-
readonly grpcclient_getBalanceByFirstName: (a: number, b: number, c: number) => any;
|
|
618
|
-
readonly grpcclient_new: (a: number, b: number) => number;
|
|
619
|
-
readonly grpcclient_sendTransaction: (a: number, b: any) => any;
|
|
620
|
-
readonly grpcclient_transactionAccepted: (a: number, b: number, c: number) => any;
|
|
687
|
+
readonly verifySignature: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
|
|
621
688
|
readonly __wbg_intounderlyingsource_free: (a: number, b: number) => void;
|
|
622
689
|
readonly intounderlyingsource_cancel: (a: number) => void;
|
|
623
690
|
readonly intounderlyingsource_pull: (a: number, b: any) => any;
|
package/iris_wasm.js
CHANGED
|
@@ -254,17 +254,17 @@ function passArray8ToWasm0(arg, malloc) {
|
|
|
254
254
|
return ptr;
|
|
255
255
|
}
|
|
256
256
|
/**
|
|
257
|
-
* Hash a
|
|
258
|
-
* @param {Uint8Array}
|
|
257
|
+
* Hash a noun (jam as input)
|
|
258
|
+
* @param {Uint8Array} noun
|
|
259
259
|
* @returns {string}
|
|
260
260
|
*/
|
|
261
|
-
export function
|
|
261
|
+
export function hashNoun(noun) {
|
|
262
262
|
let deferred3_0;
|
|
263
263
|
let deferred3_1;
|
|
264
264
|
try {
|
|
265
|
-
const ptr0 = passArray8ToWasm0(
|
|
265
|
+
const ptr0 = passArray8ToWasm0(noun, wasm.__wbindgen_malloc);
|
|
266
266
|
const len0 = WASM_VECTOR_LEN;
|
|
267
|
-
const ret = wasm.
|
|
267
|
+
const ret = wasm.hashNoun(ptr0, len0);
|
|
268
268
|
var ptr2 = ret[0];
|
|
269
269
|
var len2 = ret[1];
|
|
270
270
|
if (ret[3]) {
|
|
@@ -280,41 +280,21 @@ export function hashPublicKey(public_key_bytes) {
|
|
|
280
280
|
}
|
|
281
281
|
|
|
282
282
|
/**
|
|
283
|
-
*
|
|
284
|
-
* @param {Uint8Array}
|
|
285
|
-
* @
|
|
283
|
+
* Sign a message string with a private key
|
|
284
|
+
* @param {Uint8Array} private_key_bytes
|
|
285
|
+
* @param {string} message
|
|
286
|
+
* @returns {Signature}
|
|
286
287
|
*/
|
|
287
|
-
export function
|
|
288
|
-
const ptr0 = passArray8ToWasm0(
|
|
288
|
+
export function signMessage(private_key_bytes, message) {
|
|
289
|
+
const ptr0 = passArray8ToWasm0(private_key_bytes, wasm.__wbindgen_malloc);
|
|
289
290
|
const len0 = WASM_VECTOR_LEN;
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
* Hash a noun (jam as input)
|
|
296
|
-
* @param {Uint8Array} noun
|
|
297
|
-
* @returns {string}
|
|
298
|
-
*/
|
|
299
|
-
export function hashNoun(noun) {
|
|
300
|
-
let deferred3_0;
|
|
301
|
-
let deferred3_1;
|
|
302
|
-
try {
|
|
303
|
-
const ptr0 = passArray8ToWasm0(noun, wasm.__wbindgen_malloc);
|
|
304
|
-
const len0 = WASM_VECTOR_LEN;
|
|
305
|
-
const ret = wasm.hashNoun(ptr0, len0);
|
|
306
|
-
var ptr2 = ret[0];
|
|
307
|
-
var len2 = ret[1];
|
|
308
|
-
if (ret[3]) {
|
|
309
|
-
ptr2 = 0; len2 = 0;
|
|
310
|
-
throw takeFromExternrefTable0(ret[2]);
|
|
311
|
-
}
|
|
312
|
-
deferred3_0 = ptr2;
|
|
313
|
-
deferred3_1 = len2;
|
|
314
|
-
return getStringFromWasm0(ptr2, len2);
|
|
315
|
-
} finally {
|
|
316
|
-
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
291
|
+
const ptr1 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
292
|
+
const len1 = WASM_VECTOR_LEN;
|
|
293
|
+
const ret = wasm.signMessage(ptr0, len0, ptr1, len1);
|
|
294
|
+
if (ret[2]) {
|
|
295
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
317
296
|
}
|
|
297
|
+
return Signature.__wrap(ret[0]);
|
|
318
298
|
}
|
|
319
299
|
|
|
320
300
|
/**
|
|
@@ -335,6 +315,38 @@ export function hashU64(value) {
|
|
|
335
315
|
}
|
|
336
316
|
}
|
|
337
317
|
|
|
318
|
+
/**
|
|
319
|
+
* Derive master key from seed bytes
|
|
320
|
+
* @param {Uint8Array} seed
|
|
321
|
+
* @returns {ExtendedKey}
|
|
322
|
+
*/
|
|
323
|
+
export function deriveMasterKey(seed) {
|
|
324
|
+
const ptr0 = passArray8ToWasm0(seed, wasm.__wbindgen_malloc);
|
|
325
|
+
const len0 = WASM_VECTOR_LEN;
|
|
326
|
+
const ret = wasm.deriveMasterKey(ptr0, len0);
|
|
327
|
+
return ExtendedKey.__wrap(ret);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Verify a signature with a public key
|
|
332
|
+
* @param {Uint8Array} public_key_bytes
|
|
333
|
+
* @param {Signature} signature
|
|
334
|
+
* @param {string} message
|
|
335
|
+
* @returns {boolean}
|
|
336
|
+
*/
|
|
337
|
+
export function verifySignature(public_key_bytes, signature, message) {
|
|
338
|
+
const ptr0 = passArray8ToWasm0(public_key_bytes, wasm.__wbindgen_malloc);
|
|
339
|
+
const len0 = WASM_VECTOR_LEN;
|
|
340
|
+
_assertClass(signature, Signature);
|
|
341
|
+
const ptr1 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
342
|
+
const len1 = WASM_VECTOR_LEN;
|
|
343
|
+
const ret = wasm.verifySignature(ptr0, len0, signature.__wbg_ptr, ptr1, len1);
|
|
344
|
+
if (ret[2]) {
|
|
345
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
346
|
+
}
|
|
347
|
+
return ret[0] !== 0;
|
|
348
|
+
}
|
|
349
|
+
|
|
338
350
|
/**
|
|
339
351
|
* Derive master key from BIP39 mnemonic phrase
|
|
340
352
|
* @param {string} mnemonic
|
|
@@ -354,21 +366,29 @@ export function deriveMasterKeyFromMnemonic(mnemonic, passphrase) {
|
|
|
354
366
|
}
|
|
355
367
|
|
|
356
368
|
/**
|
|
357
|
-
*
|
|
358
|
-
* @param {Uint8Array}
|
|
359
|
-
* @
|
|
360
|
-
* @returns {Signature}
|
|
369
|
+
* Hash a public key to get its digest (for use in PKH)
|
|
370
|
+
* @param {Uint8Array} public_key_bytes
|
|
371
|
+
* @returns {string}
|
|
361
372
|
*/
|
|
362
|
-
export function
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
373
|
+
export function hashPublicKey(public_key_bytes) {
|
|
374
|
+
let deferred3_0;
|
|
375
|
+
let deferred3_1;
|
|
376
|
+
try {
|
|
377
|
+
const ptr0 = passArray8ToWasm0(public_key_bytes, wasm.__wbindgen_malloc);
|
|
378
|
+
const len0 = WASM_VECTOR_LEN;
|
|
379
|
+
const ret = wasm.hashPublicKey(ptr0, len0);
|
|
380
|
+
var ptr2 = ret[0];
|
|
381
|
+
var len2 = ret[1];
|
|
382
|
+
if (ret[3]) {
|
|
383
|
+
ptr2 = 0; len2 = 0;
|
|
384
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
385
|
+
}
|
|
386
|
+
deferred3_0 = ptr2;
|
|
387
|
+
deferred3_1 = len2;
|
|
388
|
+
return getStringFromWasm0(ptr2, len2);
|
|
389
|
+
} finally {
|
|
390
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
370
391
|
}
|
|
371
|
-
return Signature.__wrap(ret[0]);
|
|
372
392
|
}
|
|
373
393
|
|
|
374
394
|
function wasm_bindgen__convert__closures_____invoke__hbf186e27576c509b(arg0, arg1, arg2) {
|
|
@@ -1284,6 +1304,7 @@ export class Note {
|
|
|
1284
1304
|
return Note.__wrap(ret[0]);
|
|
1285
1305
|
}
|
|
1286
1306
|
/**
|
|
1307
|
+
* Create a new V1 note (the default for new notes)
|
|
1287
1308
|
* @param {Version} version
|
|
1288
1309
|
* @param {bigint} origin_page
|
|
1289
1310
|
* @param {Name} name
|
|
@@ -1298,7 +1319,10 @@ export class Note {
|
|
|
1298
1319
|
_assertClass(note_data, NoteData);
|
|
1299
1320
|
var ptr2 = note_data.__destroy_into_raw();
|
|
1300
1321
|
const ret = wasm.note_new(ptr0, origin_page, ptr1, ptr2, assets);
|
|
1301
|
-
|
|
1322
|
+
if (ret[2]) {
|
|
1323
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1324
|
+
}
|
|
1325
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
1302
1326
|
NoteFinalization.register(this, this.__wbg_ptr, this);
|
|
1303
1327
|
return this;
|
|
1304
1328
|
}
|
|
@@ -1307,10 +1331,7 @@ export class Note {
|
|
|
1307
1331
|
*/
|
|
1308
1332
|
hash() {
|
|
1309
1333
|
const ret = wasm.note_hash(this.__wbg_ptr);
|
|
1310
|
-
|
|
1311
|
-
throw takeFromExternrefTable0(ret[1]);
|
|
1312
|
-
}
|
|
1313
|
-
return Digest.__wrap(ret[0]);
|
|
1334
|
+
return Digest.__wrap(ret);
|
|
1314
1335
|
}
|
|
1315
1336
|
/**
|
|
1316
1337
|
* @returns {Name}
|
|
@@ -1319,6 +1340,22 @@ export class Note {
|
|
|
1319
1340
|
const ret = wasm.note_name(this.__wbg_ptr);
|
|
1320
1341
|
return Name.__wrap(ret);
|
|
1321
1342
|
}
|
|
1343
|
+
/**
|
|
1344
|
+
* Check if this is a V0 (legacy) note
|
|
1345
|
+
* @returns {boolean}
|
|
1346
|
+
*/
|
|
1347
|
+
get isV0() {
|
|
1348
|
+
const ret = wasm.note_isV0(this.__wbg_ptr);
|
|
1349
|
+
return ret !== 0;
|
|
1350
|
+
}
|
|
1351
|
+
/**
|
|
1352
|
+
* Check if this is a V1 note
|
|
1353
|
+
* @returns {boolean}
|
|
1354
|
+
*/
|
|
1355
|
+
get isV1() {
|
|
1356
|
+
const ret = wasm.note_isV1(this.__wbg_ptr);
|
|
1357
|
+
return ret !== 0;
|
|
1358
|
+
}
|
|
1322
1359
|
/**
|
|
1323
1360
|
* @returns {bigint}
|
|
1324
1361
|
*/
|
|
@@ -1326,6 +1363,42 @@ export class Note {
|
|
|
1326
1363
|
const ret = wasm.note_assets(this.__wbg_ptr);
|
|
1327
1364
|
return BigInt.asUintN(64, ret);
|
|
1328
1365
|
}
|
|
1366
|
+
/**
|
|
1367
|
+
* Create a new V0 (legacy) note
|
|
1368
|
+
*
|
|
1369
|
+
* V0 notes are legacy notes that use public keys directly instead of spend conditions.
|
|
1370
|
+
* - `origin_page`: Block height where the note originated
|
|
1371
|
+
* - `sig_m`: Number of required signatures (m-of-n)
|
|
1372
|
+
* - `sig_pubkeys`: Public keys as 97-byte arrays (big-endian format)
|
|
1373
|
+
* - `source_hash`: Hash of the source (seeds that created this note)
|
|
1374
|
+
* - `is_coinbase`: Whether this is a coinbase note
|
|
1375
|
+
* - `timelock`: Optional timelock constraints (must have at least one constraint if provided)
|
|
1376
|
+
* - `assets`: Amount of nicks in this note
|
|
1377
|
+
* @param {bigint} origin_page
|
|
1378
|
+
* @param {bigint} sig_m
|
|
1379
|
+
* @param {Uint8Array[]} sig_pubkeys
|
|
1380
|
+
* @param {Digest} source_hash
|
|
1381
|
+
* @param {boolean} is_coinbase
|
|
1382
|
+
* @param {Timelock | null | undefined} timelock
|
|
1383
|
+
* @param {bigint} assets
|
|
1384
|
+
* @returns {Note}
|
|
1385
|
+
*/
|
|
1386
|
+
static newV0(origin_page, sig_m, sig_pubkeys, source_hash, is_coinbase, timelock, assets) {
|
|
1387
|
+
const ptr0 = passArrayJsValueToWasm0(sig_pubkeys, wasm.__wbindgen_malloc);
|
|
1388
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1389
|
+
_assertClass(source_hash, Digest);
|
|
1390
|
+
var ptr1 = source_hash.__destroy_into_raw();
|
|
1391
|
+
let ptr2 = 0;
|
|
1392
|
+
if (!isLikeNone(timelock)) {
|
|
1393
|
+
_assertClass(timelock, Timelock);
|
|
1394
|
+
ptr2 = timelock.__destroy_into_raw();
|
|
1395
|
+
}
|
|
1396
|
+
const ret = wasm.note_newV0(origin_page, sig_m, ptr0, len0, ptr1, is_coinbase, ptr2, assets);
|
|
1397
|
+
if (ret[2]) {
|
|
1398
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1399
|
+
}
|
|
1400
|
+
return Note.__wrap(ret[0]);
|
|
1401
|
+
}
|
|
1329
1402
|
/**
|
|
1330
1403
|
* @returns {Version}
|
|
1331
1404
|
*/
|
|
@@ -1334,6 +1407,7 @@ export class Note {
|
|
|
1334
1407
|
return Version.__wrap(ret);
|
|
1335
1408
|
}
|
|
1336
1409
|
/**
|
|
1410
|
+
* Returns note data. For V0 notes this returns empty NoteData since V0 doesn't have this field.
|
|
1337
1411
|
* @returns {NoteData}
|
|
1338
1412
|
*/
|
|
1339
1413
|
get noteData() {
|
|
@@ -1526,6 +1600,80 @@ export class NoteDataEntry {
|
|
|
1526
1600
|
}
|
|
1527
1601
|
if (Symbol.dispose) NoteDataEntry.prototype[Symbol.dispose] = NoteDataEntry.prototype.free;
|
|
1528
1602
|
|
|
1603
|
+
const NounFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1604
|
+
? { register: () => {}, unregister: () => {} }
|
|
1605
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_noun_free(ptr >>> 0, 1));
|
|
1606
|
+
|
|
1607
|
+
export class Noun {
|
|
1608
|
+
|
|
1609
|
+
static __wrap(ptr) {
|
|
1610
|
+
ptr = ptr >>> 0;
|
|
1611
|
+
const obj = Object.create(Noun.prototype);
|
|
1612
|
+
obj.__wbg_ptr = ptr;
|
|
1613
|
+
NounFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
1614
|
+
return obj;
|
|
1615
|
+
}
|
|
1616
|
+
|
|
1617
|
+
__destroy_into_raw() {
|
|
1618
|
+
const ptr = this.__wbg_ptr;
|
|
1619
|
+
this.__wbg_ptr = 0;
|
|
1620
|
+
NounFinalization.unregister(this);
|
|
1621
|
+
return ptr;
|
|
1622
|
+
}
|
|
1623
|
+
|
|
1624
|
+
free() {
|
|
1625
|
+
const ptr = this.__destroy_into_raw();
|
|
1626
|
+
wasm.__wbg_noun_free(ptr, 0);
|
|
1627
|
+
}
|
|
1628
|
+
/**
|
|
1629
|
+
* @param {Uint8Array} jam
|
|
1630
|
+
* @returns {Noun}
|
|
1631
|
+
*/
|
|
1632
|
+
static cue(jam) {
|
|
1633
|
+
const ptr0 = passArray8ToWasm0(jam, wasm.__wbindgen_malloc);
|
|
1634
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1635
|
+
const ret = wasm.noun_cue(ptr0, len0);
|
|
1636
|
+
if (ret[2]) {
|
|
1637
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1638
|
+
}
|
|
1639
|
+
return Noun.__wrap(ret[0]);
|
|
1640
|
+
}
|
|
1641
|
+
/**
|
|
1642
|
+
* @returns {Uint8Array}
|
|
1643
|
+
*/
|
|
1644
|
+
jam() {
|
|
1645
|
+
const ret = wasm.noun_jam(this.__wbg_ptr);
|
|
1646
|
+
if (ret[3]) {
|
|
1647
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
1648
|
+
}
|
|
1649
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
1650
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1651
|
+
return v1;
|
|
1652
|
+
}
|
|
1653
|
+
/**
|
|
1654
|
+
* @param {any} value
|
|
1655
|
+
* @returns {Noun}
|
|
1656
|
+
*/
|
|
1657
|
+
static fromJs(value) {
|
|
1658
|
+
const ret = wasm.noun_fromJs(value);
|
|
1659
|
+
if (ret[2]) {
|
|
1660
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1661
|
+
}
|
|
1662
|
+
return Noun.__wrap(ret[0]);
|
|
1663
|
+
}
|
|
1664
|
+
/**
|
|
1665
|
+
* @returns {any}
|
|
1666
|
+
*/
|
|
1667
|
+
toJs() {
|
|
1668
|
+
const ret = wasm.noun_toJs(this.__wbg_ptr);
|
|
1669
|
+
if (ret[2]) {
|
|
1670
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1671
|
+
}
|
|
1672
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
if (Symbol.dispose) Noun.prototype[Symbol.dispose] = Noun.prototype.free;
|
|
1676
|
+
|
|
1529
1677
|
const PkhFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1530
1678
|
? { register: () => {}, unregister: () => {} }
|
|
1531
1679
|
: new FinalizationRegistry(ptr => wasm.__wbg_pkh_free(ptr >>> 0, 1));
|
|
@@ -1665,7 +1813,10 @@ export class RawTx {
|
|
|
1665
1813
|
*/
|
|
1666
1814
|
toNockchainTx() {
|
|
1667
1815
|
const ret = wasm.rawtx_toNockchainTx(this.__wbg_ptr);
|
|
1668
|
-
|
|
1816
|
+
if (ret[2]) {
|
|
1817
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1818
|
+
}
|
|
1819
|
+
return NockchainTx.__wrap(ret[0]);
|
|
1669
1820
|
}
|
|
1670
1821
|
/**
|
|
1671
1822
|
* @returns {Digest}
|
|
@@ -1919,6 +2070,20 @@ export class Signature {
|
|
|
1919
2070
|
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
1920
2071
|
return v1;
|
|
1921
2072
|
}
|
|
2073
|
+
/**
|
|
2074
|
+
* @param {Uint8Array} c
|
|
2075
|
+
* @param {Uint8Array} s
|
|
2076
|
+
*/
|
|
2077
|
+
constructor(c, s) {
|
|
2078
|
+
const ptr0 = passArray8ToWasm0(c, wasm.__wbindgen_malloc);
|
|
2079
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2080
|
+
const ptr1 = passArray8ToWasm0(s, wasm.__wbindgen_malloc);
|
|
2081
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2082
|
+
const ret = wasm.signature_new(ptr0, len0, ptr1, len1);
|
|
2083
|
+
this.__wbg_ptr = ret >>> 0;
|
|
2084
|
+
SignatureFinalization.register(this, this.__wbg_ptr, this);
|
|
2085
|
+
return this;
|
|
2086
|
+
}
|
|
1922
2087
|
}
|
|
1923
2088
|
if (Symbol.dispose) Signature.prototype[Symbol.dispose] = Signature.prototype.free;
|
|
1924
2089
|
|
|
@@ -2068,14 +2233,17 @@ export class SpendBuilder {
|
|
|
2068
2233
|
/**
|
|
2069
2234
|
* Create a new `SpendBuilder` with a given note and spend condition
|
|
2070
2235
|
* @param {Note} note
|
|
2071
|
-
* @param {SpendCondition} spend_condition
|
|
2236
|
+
* @param {SpendCondition | null} [spend_condition]
|
|
2072
2237
|
* @param {SpendCondition | null} [refund_lock]
|
|
2073
2238
|
*/
|
|
2074
2239
|
constructor(note, spend_condition, refund_lock) {
|
|
2075
2240
|
_assertClass(note, Note);
|
|
2076
2241
|
var ptr0 = note.__destroy_into_raw();
|
|
2077
|
-
|
|
2078
|
-
|
|
2242
|
+
let ptr1 = 0;
|
|
2243
|
+
if (!isLikeNone(spend_condition)) {
|
|
2244
|
+
_assertClass(spend_condition, SpendCondition);
|
|
2245
|
+
ptr1 = spend_condition.__destroy_into_raw();
|
|
2246
|
+
}
|
|
2079
2247
|
let ptr2 = 0;
|
|
2080
2248
|
if (!isLikeNone(refund_lock)) {
|
|
2081
2249
|
_assertClass(refund_lock, SpendCondition);
|
|
@@ -2220,6 +2388,62 @@ export class SpendCondition {
|
|
|
2220
2388
|
}
|
|
2221
2389
|
if (Symbol.dispose) SpendCondition.prototype[Symbol.dispose] = SpendCondition.prototype.free;
|
|
2222
2390
|
|
|
2391
|
+
const TimelockFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
2392
|
+
? { register: () => {}, unregister: () => {} }
|
|
2393
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_timelock_free(ptr >>> 0, 1));
|
|
2394
|
+
/**
|
|
2395
|
+
* Timelock for V0 (legacy) notes
|
|
2396
|
+
*
|
|
2397
|
+
* This is similar to LockTim but used for v0 notes' timelock constraints.
|
|
2398
|
+
* At least one constraint (min or max in either rel or abs) must be set.
|
|
2399
|
+
*/
|
|
2400
|
+
export class Timelock {
|
|
2401
|
+
|
|
2402
|
+
__destroy_into_raw() {
|
|
2403
|
+
const ptr = this.__wbg_ptr;
|
|
2404
|
+
this.__wbg_ptr = 0;
|
|
2405
|
+
TimelockFinalization.unregister(this);
|
|
2406
|
+
return ptr;
|
|
2407
|
+
}
|
|
2408
|
+
|
|
2409
|
+
free() {
|
|
2410
|
+
const ptr = this.__destroy_into_raw();
|
|
2411
|
+
wasm.__wbg_timelock_free(ptr, 0);
|
|
2412
|
+
}
|
|
2413
|
+
/**
|
|
2414
|
+
* @returns {TimelockRange}
|
|
2415
|
+
*/
|
|
2416
|
+
get abs() {
|
|
2417
|
+
const ret = wasm.locktim_abs(this.__wbg_ptr);
|
|
2418
|
+
return TimelockRange.__wrap(ret);
|
|
2419
|
+
}
|
|
2420
|
+
/**
|
|
2421
|
+
* @param {TimelockRange} rel
|
|
2422
|
+
* @param {TimelockRange} abs
|
|
2423
|
+
*/
|
|
2424
|
+
constructor(rel, abs) {
|
|
2425
|
+
_assertClass(rel, TimelockRange);
|
|
2426
|
+
var ptr0 = rel.__destroy_into_raw();
|
|
2427
|
+
_assertClass(abs, TimelockRange);
|
|
2428
|
+
var ptr1 = abs.__destroy_into_raw();
|
|
2429
|
+
const ret = wasm.timelock_new(ptr0, ptr1);
|
|
2430
|
+
if (ret[2]) {
|
|
2431
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2432
|
+
}
|
|
2433
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
2434
|
+
TimelockFinalization.register(this, this.__wbg_ptr, this);
|
|
2435
|
+
return this;
|
|
2436
|
+
}
|
|
2437
|
+
/**
|
|
2438
|
+
* @returns {TimelockRange}
|
|
2439
|
+
*/
|
|
2440
|
+
get rel() {
|
|
2441
|
+
const ret = wasm.locktim_rel(this.__wbg_ptr);
|
|
2442
|
+
return TimelockRange.__wrap(ret);
|
|
2443
|
+
}
|
|
2444
|
+
}
|
|
2445
|
+
if (Symbol.dispose) Timelock.prototype[Symbol.dispose] = Timelock.prototype.free;
|
|
2446
|
+
|
|
2223
2447
|
const TimelockRangeFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
2224
2448
|
? { register: () => {}, unregister: () => {} }
|
|
2225
2449
|
: new FinalizationRegistry(ptr => wasm.__wbg_timelockrange_free(ptr >>> 0, 1));
|
|
@@ -2509,7 +2733,10 @@ export class TxBuilder {
|
|
|
2509
2733
|
*/
|
|
2510
2734
|
allNotes() {
|
|
2511
2735
|
const ret = wasm.txbuilder_allNotes(this.__wbg_ptr);
|
|
2512
|
-
|
|
2736
|
+
if (ret[2]) {
|
|
2737
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
2738
|
+
}
|
|
2739
|
+
return TxNotes.__wrap(ret[0]);
|
|
2513
2740
|
}
|
|
2514
2741
|
}
|
|
2515
2742
|
if (Symbol.dispose) TxBuilder.prototype[Symbol.dispose] = TxBuilder.prototype.free;
|
|
@@ -2897,6 +3124,16 @@ function __wbg_get_imports() {
|
|
|
2897
3124
|
const ret = result;
|
|
2898
3125
|
return ret;
|
|
2899
3126
|
};
|
|
3127
|
+
imports.wbg.__wbg_instanceof_Map_8579b5e2ab5437c7 = function(arg0) {
|
|
3128
|
+
let result;
|
|
3129
|
+
try {
|
|
3130
|
+
result = arg0 instanceof Map;
|
|
3131
|
+
} catch (_) {
|
|
3132
|
+
result = false;
|
|
3133
|
+
}
|
|
3134
|
+
const ret = result;
|
|
3135
|
+
return ret;
|
|
3136
|
+
};
|
|
2900
3137
|
imports.wbg.__wbg_instanceof_Uint8Array_20c8e73002f7af98 = function(arg0) {
|
|
2901
3138
|
let result;
|
|
2902
3139
|
try {
|
|
@@ -3129,16 +3366,21 @@ function __wbg_get_imports() {
|
|
|
3129
3366
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
3130
3367
|
return ret;
|
|
3131
3368
|
};
|
|
3132
|
-
imports.wbg.__wbindgen_cast_23e23d31be9a5d3c = function(arg0, arg1) {
|
|
3133
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx: 252, function: Function { arguments: [Externref], shim_idx: 253, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
3134
|
-
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h20e54f17b0de8c43, wasm_bindgen__convert__closures_____invoke__hbf186e27576c509b);
|
|
3135
|
-
return ret;
|
|
3136
|
-
};
|
|
3137
3369
|
imports.wbg.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
|
|
3138
3370
|
// Cast intrinsic for `U64 -> Externref`.
|
|
3139
3371
|
const ret = BigInt.asUintN(64, arg0);
|
|
3140
3372
|
return ret;
|
|
3141
3373
|
};
|
|
3374
|
+
imports.wbg.__wbindgen_cast_8b855ba391b91225 = function(arg0, arg1) {
|
|
3375
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 285, function: Function { arguments: [Externref], shim_idx: 286, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
3376
|
+
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h20e54f17b0de8c43, wasm_bindgen__convert__closures_____invoke__hbf186e27576c509b);
|
|
3377
|
+
return ret;
|
|
3378
|
+
};
|
|
3379
|
+
imports.wbg.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
|
|
3380
|
+
// Cast intrinsic for `I64 -> Externref`.
|
|
3381
|
+
const ret = arg0;
|
|
3382
|
+
return ret;
|
|
3383
|
+
};
|
|
3142
3384
|
imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
|
|
3143
3385
|
// Cast intrinsic for `F64 -> Externref`.
|
|
3144
3386
|
const ret = arg0;
|
package/iris_wasm_bg.wasm
CHANGED
|
Binary file
|