@meshsdk/wallet 2.0.0-beta.4 → 2.0.0-beta.6

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/dist/index.js CHANGED
@@ -4,13 +4,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __getProtoOf = Object.getPrototypeOf;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
8
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
9
- }) : x)(function(x) {
10
- if (typeof require !== "undefined") return require.apply(this, arguments);
11
- throw Error('Dynamic require of "' + x + '" is not supported');
12
- });
13
- var __commonJS = (cb, mod) => function __require2() {
7
+ var __commonJS = (cb, mod) => function __require() {
14
8
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
15
9
  };
16
10
  var __copyProps = (to, from, except, desc) => {
@@ -30,14 +24,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
30
24
  mod
31
25
  ));
32
26
 
33
- // node_modules/@noble/hashes/cryptoNode.js
34
- var require_cryptoNode = __commonJS({
35
- "node_modules/@noble/hashes/cryptoNode.js"(exports) {
27
+ // node_modules/@noble/hashes/crypto.js
28
+ var require_crypto = __commonJS({
29
+ "node_modules/@noble/hashes/crypto.js"(exports) {
36
30
  "use strict";
37
31
  Object.defineProperty(exports, "__esModule", { value: true });
38
32
  exports.crypto = void 0;
39
- var nc = __require("crypto");
40
- exports.crypto = nc && typeof nc === "object" && "webcrypto" in nc ? nc.webcrypto : nc && typeof nc === "object" && "randomBytes" in nc ? nc : void 0;
33
+ exports.crypto = typeof globalThis === "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
41
34
  }
42
35
  });
43
36
 
@@ -74,7 +67,7 @@ var require_utils = __commonJS({
74
67
  exports.createOptHasher = createOptHasher;
75
68
  exports.createXOFer = createXOFer;
76
69
  exports.randomBytes = randomBytes;
77
- var crypto_1 = require_cryptoNode();
70
+ var crypto_1 = require_crypto();
78
71
  function isBytes2(a) {
79
72
  return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
80
73
  }
@@ -22185,122 +22178,715 @@ var require_nanoassert = __commonJS({
22185
22178
  }
22186
22179
  });
22187
22180
 
22188
- // node_modules/b4a/index.js
22189
- var require_b4a = __commonJS({
22190
- "node_modules/b4a/index.js"(exports, module) {
22181
+ // node_modules/b4a/lib/ascii.js
22182
+ var require_ascii = __commonJS({
22183
+ "node_modules/b4a/lib/ascii.js"(exports, module) {
22184
+ function byteLength(string) {
22185
+ return string.length;
22186
+ }
22187
+ function toString(buffer) {
22188
+ const len = buffer.byteLength;
22189
+ let result = "";
22190
+ for (let i = 0; i < len; i++) {
22191
+ result += String.fromCharCode(buffer[i] & 127);
22192
+ }
22193
+ return result;
22194
+ }
22195
+ function write(buffer, string) {
22196
+ const len = buffer.byteLength;
22197
+ for (let i = 0; i < len; i++) {
22198
+ buffer[i] = string.charCodeAt(i);
22199
+ }
22200
+ return len;
22201
+ }
22202
+ module.exports = {
22203
+ byteLength,
22204
+ toString,
22205
+ write
22206
+ };
22207
+ }
22208
+ });
22209
+
22210
+ // node_modules/b4a/lib/base64.js
22211
+ var require_base64 = __commonJS({
22212
+ "node_modules/b4a/lib/base64.js"(exports, module) {
22213
+ var alphabet2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
22214
+ var codes = new Uint8Array(256);
22215
+ for (let i = 0; i < alphabet2.length; i++) {
22216
+ codes[alphabet2.charCodeAt(i)] = i;
22217
+ }
22218
+ codes[
22219
+ /* - */
22220
+ 45
22221
+ ] = 62;
22222
+ codes[
22223
+ /* _ */
22224
+ 95
22225
+ ] = 63;
22226
+ function byteLength(string) {
22227
+ let len = string.length;
22228
+ if (string.charCodeAt(len - 1) === 61) len--;
22229
+ if (len > 1 && string.charCodeAt(len - 1) === 61) len--;
22230
+ return len * 3 >>> 2;
22231
+ }
22232
+ function toString(buffer) {
22233
+ const len = buffer.byteLength;
22234
+ let result = "";
22235
+ for (let i = 0; i < len; i += 3) {
22236
+ result += alphabet2[buffer[i] >> 2] + alphabet2[(buffer[i] & 3) << 4 | buffer[i + 1] >> 4] + alphabet2[(buffer[i + 1] & 15) << 2 | buffer[i + 2] >> 6] + alphabet2[buffer[i + 2] & 63];
22237
+ }
22238
+ if (len % 3 === 2) {
22239
+ result = result.substring(0, result.length - 1) + "=";
22240
+ } else if (len % 3 === 1) {
22241
+ result = result.substring(0, result.length - 2) + "==";
22242
+ }
22243
+ return result;
22244
+ }
22245
+ function write(buffer, string) {
22246
+ const len = buffer.byteLength;
22247
+ for (let i = 0, j = 0; j < len; i += 4) {
22248
+ const a = codes[string.charCodeAt(i)];
22249
+ const b = codes[string.charCodeAt(i + 1)];
22250
+ const c = codes[string.charCodeAt(i + 2)];
22251
+ const d = codes[string.charCodeAt(i + 3)];
22252
+ buffer[j++] = a << 2 | b >> 4;
22253
+ buffer[j++] = (b & 15) << 4 | c >> 2;
22254
+ buffer[j++] = (c & 3) << 6 | d & 63;
22255
+ }
22256
+ return len;
22257
+ }
22258
+ module.exports = {
22259
+ byteLength,
22260
+ toString,
22261
+ write
22262
+ };
22263
+ }
22264
+ });
22265
+
22266
+ // node_modules/b4a/lib/hex.js
22267
+ var require_hex = __commonJS({
22268
+ "node_modules/b4a/lib/hex.js"(exports, module) {
22269
+ function byteLength(string) {
22270
+ return string.length >>> 1;
22271
+ }
22272
+ function toString(buffer) {
22273
+ const len = buffer.byteLength;
22274
+ buffer = new DataView(buffer.buffer, buffer.byteOffset, len);
22275
+ let result = "";
22276
+ let i = 0;
22277
+ for (let n = len - len % 4; i < n; i += 4) {
22278
+ result += buffer.getUint32(i).toString(16).padStart(8, "0");
22279
+ }
22280
+ for (; i < len; i++) {
22281
+ result += buffer.getUint8(i).toString(16).padStart(2, "0");
22282
+ }
22283
+ return result;
22284
+ }
22285
+ function write(buffer, string) {
22286
+ const len = buffer.byteLength;
22287
+ for (let i = 0; i < len; i++) {
22288
+ const a = hexValue(string.charCodeAt(i * 2));
22289
+ const b = hexValue(string.charCodeAt(i * 2 + 1));
22290
+ if (a === void 0 || b === void 0) {
22291
+ return buffer.subarray(0, i);
22292
+ }
22293
+ buffer[i] = a << 4 | b;
22294
+ }
22295
+ return len;
22296
+ }
22297
+ module.exports = {
22298
+ byteLength,
22299
+ toString,
22300
+ write
22301
+ };
22302
+ function hexValue(char) {
22303
+ if (char >= 48 && char <= 57) return char - 48;
22304
+ if (char >= 65 && char <= 70) return char - 65 + 10;
22305
+ if (char >= 97 && char <= 102) return char - 97 + 10;
22306
+ }
22307
+ }
22308
+ });
22309
+
22310
+ // node_modules/b4a/lib/latin1.js
22311
+ var require_latin1 = __commonJS({
22312
+ "node_modules/b4a/lib/latin1.js"(exports, module) {
22313
+ function byteLength(string) {
22314
+ return string.length;
22315
+ }
22316
+ function toString(buffer) {
22317
+ const len = buffer.byteLength;
22318
+ let result = "";
22319
+ for (let i = 0; i < len; i++) {
22320
+ result += String.fromCharCode(buffer[i]);
22321
+ }
22322
+ return result;
22323
+ }
22324
+ function write(buffer, string) {
22325
+ const len = buffer.byteLength;
22326
+ for (let i = 0; i < len; i++) {
22327
+ buffer[i] = string.charCodeAt(i);
22328
+ }
22329
+ return len;
22330
+ }
22331
+ module.exports = {
22332
+ byteLength,
22333
+ toString,
22334
+ write
22335
+ };
22336
+ }
22337
+ });
22338
+
22339
+ // node_modules/b4a/lib/utf8.js
22340
+ var require_utf8 = __commonJS({
22341
+ "node_modules/b4a/lib/utf8.js"(exports, module) {
22342
+ function byteLength(string) {
22343
+ let length = 0;
22344
+ for (let i = 0, n = string.length; i < n; i++) {
22345
+ const code = string.charCodeAt(i);
22346
+ if (code >= 55296 && code <= 56319 && i + 1 < n) {
22347
+ const code2 = string.charCodeAt(i + 1);
22348
+ if (code2 >= 56320 && code2 <= 57343) {
22349
+ length += 4;
22350
+ i++;
22351
+ continue;
22352
+ }
22353
+ }
22354
+ if (code <= 127) length += 1;
22355
+ else if (code <= 2047) length += 2;
22356
+ else length += 3;
22357
+ }
22358
+ return length;
22359
+ }
22360
+ var toString;
22361
+ if (typeof TextDecoder !== "undefined") {
22362
+ const decoder = new TextDecoder();
22363
+ toString = function toString2(buffer) {
22364
+ return decoder.decode(buffer);
22365
+ };
22366
+ } else {
22367
+ toString = function toString2(buffer) {
22368
+ const len = buffer.byteLength;
22369
+ let output = "";
22370
+ let i = 0;
22371
+ while (i < len) {
22372
+ let byte = buffer[i];
22373
+ if (byte <= 127) {
22374
+ output += String.fromCharCode(byte);
22375
+ i++;
22376
+ continue;
22377
+ }
22378
+ let bytesNeeded = 0;
22379
+ let codePoint = 0;
22380
+ if (byte <= 223) {
22381
+ bytesNeeded = 1;
22382
+ codePoint = byte & 31;
22383
+ } else if (byte <= 239) {
22384
+ bytesNeeded = 2;
22385
+ codePoint = byte & 15;
22386
+ } else if (byte <= 244) {
22387
+ bytesNeeded = 3;
22388
+ codePoint = byte & 7;
22389
+ }
22390
+ if (len - i - bytesNeeded > 0) {
22391
+ let k = 0;
22392
+ while (k < bytesNeeded) {
22393
+ byte = buffer[i + k + 1];
22394
+ codePoint = codePoint << 6 | byte & 63;
22395
+ k += 1;
22396
+ }
22397
+ } else {
22398
+ codePoint = 65533;
22399
+ bytesNeeded = len - i;
22400
+ }
22401
+ output += String.fromCodePoint(codePoint);
22402
+ i += bytesNeeded + 1;
22403
+ }
22404
+ return output;
22405
+ };
22406
+ }
22407
+ var write;
22408
+ if (typeof TextEncoder !== "undefined") {
22409
+ const encoder = new TextEncoder();
22410
+ write = function write2(buffer, string) {
22411
+ return encoder.encodeInto(string, buffer).written;
22412
+ };
22413
+ } else {
22414
+ write = function write2(buffer, string) {
22415
+ const len = buffer.byteLength;
22416
+ let i = 0;
22417
+ let j = 0;
22418
+ while (i < string.length) {
22419
+ const code = string.codePointAt(i);
22420
+ if (code <= 127) {
22421
+ buffer[j++] = code;
22422
+ i++;
22423
+ continue;
22424
+ }
22425
+ let count = 0;
22426
+ let bits = 0;
22427
+ if (code <= 2047) {
22428
+ count = 6;
22429
+ bits = 192;
22430
+ } else if (code <= 65535) {
22431
+ count = 12;
22432
+ bits = 224;
22433
+ } else if (code <= 2097151) {
22434
+ count = 18;
22435
+ bits = 240;
22436
+ }
22437
+ buffer[j++] = bits | code >> count;
22438
+ count -= 6;
22439
+ while (count >= 0) {
22440
+ buffer[j++] = 128 | code >> count & 63;
22441
+ count -= 6;
22442
+ }
22443
+ i += code >= 65536 ? 2 : 1;
22444
+ }
22445
+ return len;
22446
+ };
22447
+ }
22448
+ module.exports = {
22449
+ byteLength,
22450
+ toString,
22451
+ write
22452
+ };
22453
+ }
22454
+ });
22455
+
22456
+ // node_modules/b4a/lib/utf16le.js
22457
+ var require_utf16le = __commonJS({
22458
+ "node_modules/b4a/lib/utf16le.js"(exports, module) {
22459
+ function byteLength(string) {
22460
+ return string.length * 2;
22461
+ }
22462
+ function toString(buffer) {
22463
+ const len = buffer.byteLength;
22464
+ let result = "";
22465
+ for (let i = 0; i < len - 1; i += 2) {
22466
+ result += String.fromCharCode(buffer[i] + buffer[i + 1] * 256);
22467
+ }
22468
+ return result;
22469
+ }
22470
+ function write(buffer, string) {
22471
+ const len = buffer.byteLength;
22472
+ let units = len;
22473
+ for (let i = 0; i < string.length; ++i) {
22474
+ if ((units -= 2) < 0) break;
22475
+ const c = string.charCodeAt(i);
22476
+ const hi = c >> 8;
22477
+ const lo = c % 256;
22478
+ buffer[i * 2] = lo;
22479
+ buffer[i * 2 + 1] = hi;
22480
+ }
22481
+ return len;
22482
+ }
22483
+ module.exports = {
22484
+ byteLength,
22485
+ toString,
22486
+ write
22487
+ };
22488
+ }
22489
+ });
22490
+
22491
+ // node_modules/b4a/browser.js
22492
+ var require_browser = __commonJS({
22493
+ "node_modules/b4a/browser.js"(exports, module) {
22494
+ var ascii = require_ascii();
22495
+ var base64 = require_base64();
22496
+ var hex = require_hex();
22497
+ var latin1 = require_latin1();
22498
+ var utf8 = require_utf8();
22499
+ var utf16le = require_utf16le();
22500
+ var LE = new Uint8Array(Uint16Array.of(255).buffer)[0] === 255;
22501
+ function codecFor(encoding) {
22502
+ switch (encoding) {
22503
+ case "ascii":
22504
+ return ascii;
22505
+ case "base64":
22506
+ return base64;
22507
+ case "hex":
22508
+ return hex;
22509
+ case "binary":
22510
+ case "latin1":
22511
+ return latin1;
22512
+ case "utf8":
22513
+ case "utf-8":
22514
+ case void 0:
22515
+ case null:
22516
+ return utf8;
22517
+ case "ucs2":
22518
+ case "ucs-2":
22519
+ case "utf16le":
22520
+ case "utf-16le":
22521
+ return utf16le;
22522
+ default:
22523
+ throw new Error(`Unknown encoding '${encoding}'`);
22524
+ }
22525
+ }
22191
22526
  function isBuffer(value) {
22192
- return Buffer.isBuffer(value) || value instanceof Uint8Array;
22527
+ return value instanceof Uint8Array;
22193
22528
  }
22194
22529
  function isEncoding(encoding) {
22195
- return Buffer.isEncoding(encoding);
22530
+ try {
22531
+ codecFor(encoding);
22532
+ return true;
22533
+ } catch {
22534
+ return false;
22535
+ }
22196
22536
  }
22197
22537
  function alloc(size, fill2, encoding) {
22198
- return Buffer.alloc(size, fill2, encoding);
22538
+ const buffer = new Uint8Array(size);
22539
+ if (fill2 !== void 0) {
22540
+ exports.fill(buffer, fill2, 0, buffer.byteLength, encoding);
22541
+ }
22542
+ return buffer;
22199
22543
  }
22200
22544
  function allocUnsafe(size) {
22201
- return Buffer.allocUnsafe(size);
22545
+ return new Uint8Array(size);
22202
22546
  }
22203
22547
  function allocUnsafeSlow(size) {
22204
- return Buffer.allocUnsafeSlow(size);
22548
+ return new Uint8Array(size);
22205
22549
  }
22206
22550
  function byteLength(string, encoding) {
22207
- return Buffer.byteLength(string, encoding);
22551
+ return codecFor(encoding).byteLength(string);
22208
22552
  }
22209
22553
  function compare(a, b) {
22210
- return Buffer.compare(a, b);
22554
+ if (a === b) return 0;
22555
+ const len = Math.min(a.byteLength, b.byteLength);
22556
+ a = new DataView(a.buffer, a.byteOffset, a.byteLength);
22557
+ b = new DataView(b.buffer, b.byteOffset, b.byteLength);
22558
+ let i = 0;
22559
+ for (let n = len - len % 4; i < n; i += 4) {
22560
+ const x = a.getUint32(i, LE);
22561
+ const y = b.getUint32(i, LE);
22562
+ if (x !== y) break;
22563
+ }
22564
+ for (; i < len; i++) {
22565
+ const x = a.getUint8(i);
22566
+ const y = b.getUint8(i);
22567
+ if (x < y) return -1;
22568
+ if (x > y) return 1;
22569
+ }
22570
+ return a.byteLength > b.byteLength ? 1 : a.byteLength < b.byteLength ? -1 : 0;
22211
22571
  }
22212
- function concat(buffers, totalLength) {
22213
- return Buffer.concat(buffers, totalLength);
22572
+ function concat(buffers, length) {
22573
+ if (length === void 0) {
22574
+ length = buffers.reduce((len, buffer) => len + buffer.byteLength, 0);
22575
+ }
22576
+ const result = new Uint8Array(length);
22577
+ let offset = 0;
22578
+ for (const buffer of buffers) {
22579
+ if (offset + buffer.byteLength > result.byteLength) {
22580
+ result.set(buffer.subarray(0, result.byteLength - offset), offset);
22581
+ return result;
22582
+ }
22583
+ result.set(buffer, offset);
22584
+ offset += buffer.byteLength;
22585
+ }
22586
+ return result;
22214
22587
  }
22215
- function copy(source, target, targetStart, start, end) {
22216
- return toBuffer(source).copy(target, targetStart, start, end);
22588
+ function copy(source, target, targetStart = 0, sourceStart = 0, sourceEnd = source.byteLength) {
22589
+ if (targetStart < 0) targetStart = 0;
22590
+ if (targetStart >= target.byteLength) return 0;
22591
+ const targetLength = target.byteLength - targetStart;
22592
+ if (sourceStart < 0) sourceStart = 0;
22593
+ if (sourceStart >= source.byteLength) return 0;
22594
+ if (sourceEnd <= sourceStart) return 0;
22595
+ if (sourceEnd > source.byteLength) sourceEnd = source.byteLength;
22596
+ if (sourceEnd - sourceStart > targetLength) {
22597
+ sourceEnd = sourceStart + targetLength;
22598
+ }
22599
+ const sourceLength = sourceEnd - sourceStart;
22600
+ if (source === target) {
22601
+ target.copyWithin(targetStart, sourceStart, sourceEnd);
22602
+ } else {
22603
+ if (sourceStart !== 0 || sourceEnd !== source.byteLength) {
22604
+ source = source.subarray(sourceStart, sourceEnd);
22605
+ }
22606
+ target.set(source, targetStart);
22607
+ }
22608
+ return sourceLength;
22217
22609
  }
22218
22610
  function equals(a, b) {
22219
- return toBuffer(a).equals(b);
22611
+ if (a === b) return true;
22612
+ if (a.byteLength !== b.byteLength) return false;
22613
+ return compare(a, b) === 0;
22220
22614
  }
22221
- function fill(buffer, value, offset, end, encoding) {
22222
- return toBuffer(buffer).fill(value, offset, end, encoding);
22615
+ function fill(buffer, value, offset = 0, end = buffer.byteLength, encoding = "utf8") {
22616
+ if (typeof value === "string") {
22617
+ if (typeof offset === "string") {
22618
+ encoding = offset;
22619
+ offset = 0;
22620
+ end = buffer.byteLength;
22621
+ } else if (typeof end === "string") {
22622
+ encoding = end;
22623
+ end = buffer.byteLength;
22624
+ }
22625
+ } else if (typeof value === "number") {
22626
+ value = value & 255;
22627
+ } else if (typeof value === "boolean") {
22628
+ value = +value;
22629
+ }
22630
+ if (offset < 0) offset = 0;
22631
+ if (offset >= buffer.byteLength) return buffer;
22632
+ if (end <= offset) return buffer;
22633
+ if (end > buffer.byteLength) end = buffer.byteLength;
22634
+ if (typeof value === "number") return buffer.fill(value, offset, end);
22635
+ if (typeof value === "string") value = exports.from(value, encoding);
22636
+ const len = value.byteLength;
22637
+ for (let i = 0, n = end - offset; i < n; ++i) {
22638
+ buffer[i + offset] = value[i % len];
22639
+ }
22640
+ return buffer;
22223
22641
  }
22224
22642
  function from(value, encodingOrOffset, length) {
22225
- return Buffer.from(value, encodingOrOffset, length);
22643
+ if (typeof value === "string") return fromString(value, encodingOrOffset);
22644
+ if (Array.isArray(value)) return fromArray(value);
22645
+ if (ArrayBuffer.isView(value)) return fromBuffer(value);
22646
+ return fromArrayBuffer(value, encodingOrOffset, length);
22647
+ }
22648
+ function fromString(string, encoding) {
22649
+ const codec = codecFor(encoding);
22650
+ const buffer = new Uint8Array(codec.byteLength(string));
22651
+ codec.write(buffer, string);
22652
+ return buffer;
22653
+ }
22654
+ function fromArray(array) {
22655
+ const buffer = new Uint8Array(array.length);
22656
+ buffer.set(array);
22657
+ return buffer;
22658
+ }
22659
+ function fromBuffer(buffer) {
22660
+ const copy2 = new Uint8Array(buffer.byteLength);
22661
+ copy2.set(buffer);
22662
+ return copy2;
22663
+ }
22664
+ function fromArrayBuffer(arrayBuffer, byteOffset, length) {
22665
+ return new Uint8Array(arrayBuffer, byteOffset, length);
22226
22666
  }
22227
22667
  function includes(buffer, value, byteOffset, encoding) {
22228
- return toBuffer(buffer).includes(value, byteOffset, encoding);
22668
+ return indexOf(buffer, value, byteOffset, encoding) !== -1;
22229
22669
  }
22230
- function indexOf(buffer, value, byfeOffset, encoding) {
22231
- return toBuffer(buffer).indexOf(value, byfeOffset, encoding);
22670
+ function indexOf(buffer, value, byteOffset, encoding) {
22671
+ return bidirectionalIndexOf(
22672
+ buffer,
22673
+ value,
22674
+ byteOffset,
22675
+ encoding,
22676
+ true
22677
+ /* first */
22678
+ );
22232
22679
  }
22233
22680
  function lastIndexOf(buffer, value, byteOffset, encoding) {
22234
- return toBuffer(buffer).lastIndexOf(value, byteOffset, encoding);
22681
+ return bidirectionalIndexOf(
22682
+ buffer,
22683
+ value,
22684
+ byteOffset,
22685
+ encoding,
22686
+ false
22687
+ /* last */
22688
+ );
22689
+ }
22690
+ function bidirectionalIndexOf(buffer, value, byteOffset, encoding, first) {
22691
+ if (buffer.byteLength === 0) return -1;
22692
+ if (typeof byteOffset === "string") {
22693
+ encoding = byteOffset;
22694
+ byteOffset = 0;
22695
+ } else if (byteOffset === void 0) {
22696
+ byteOffset = first ? 0 : buffer.length - 1;
22697
+ } else if (byteOffset < 0) {
22698
+ byteOffset += buffer.byteLength;
22699
+ }
22700
+ if (byteOffset >= buffer.byteLength) {
22701
+ if (first) return -1;
22702
+ else byteOffset = buffer.byteLength - 1;
22703
+ } else if (byteOffset < 0) {
22704
+ if (first) byteOffset = 0;
22705
+ else return -1;
22706
+ }
22707
+ if (typeof value === "string") {
22708
+ value = from(value, encoding);
22709
+ } else if (typeof value === "number") {
22710
+ value = value & 255;
22711
+ if (first) {
22712
+ return buffer.indexOf(value, byteOffset);
22713
+ } else {
22714
+ return buffer.lastIndexOf(value, byteOffset);
22715
+ }
22716
+ }
22717
+ if (value.byteLength === 0) return -1;
22718
+ if (first) {
22719
+ let foundIndex = -1;
22720
+ for (let i = byteOffset; i < buffer.byteLength; i++) {
22721
+ if (buffer[i] === value[foundIndex === -1 ? 0 : i - foundIndex]) {
22722
+ if (foundIndex === -1) foundIndex = i;
22723
+ if (i - foundIndex + 1 === value.byteLength) return foundIndex;
22724
+ } else {
22725
+ if (foundIndex !== -1) i -= i - foundIndex;
22726
+ foundIndex = -1;
22727
+ }
22728
+ }
22729
+ } else {
22730
+ if (byteOffset + value.byteLength > buffer.byteLength) {
22731
+ byteOffset = buffer.byteLength - value.byteLength;
22732
+ }
22733
+ for (let i = byteOffset; i >= 0; i--) {
22734
+ let found = true;
22735
+ for (let j = 0; j < value.byteLength; j++) {
22736
+ if (buffer[i + j] !== value[j]) {
22737
+ found = false;
22738
+ break;
22739
+ }
22740
+ }
22741
+ if (found) return i;
22742
+ }
22743
+ }
22744
+ return -1;
22745
+ }
22746
+ function swap(buffer, n, m) {
22747
+ const i = buffer[n];
22748
+ buffer[n] = buffer[m];
22749
+ buffer[m] = i;
22235
22750
  }
22236
22751
  function swap16(buffer) {
22237
- return toBuffer(buffer).swap16();
22752
+ const len = buffer.byteLength;
22753
+ if (len % 2 !== 0)
22754
+ throw new RangeError("Buffer size must be a multiple of 16-bits");
22755
+ for (let i = 0; i < len; i += 2) swap(buffer, i, i + 1);
22756
+ return buffer;
22238
22757
  }
22239
22758
  function swap32(buffer) {
22240
- return toBuffer(buffer).swap32();
22759
+ const len = buffer.byteLength;
22760
+ if (len % 4 !== 0)
22761
+ throw new RangeError("Buffer size must be a multiple of 32-bits");
22762
+ for (let i = 0; i < len; i += 4) {
22763
+ swap(buffer, i, i + 3);
22764
+ swap(buffer, i + 1, i + 2);
22765
+ }
22766
+ return buffer;
22241
22767
  }
22242
22768
  function swap64(buffer) {
22243
- return toBuffer(buffer).swap64();
22769
+ const len = buffer.byteLength;
22770
+ if (len % 8 !== 0)
22771
+ throw new RangeError("Buffer size must be a multiple of 64-bits");
22772
+ for (let i = 0; i < len; i += 8) {
22773
+ swap(buffer, i, i + 7);
22774
+ swap(buffer, i + 1, i + 6);
22775
+ swap(buffer, i + 2, i + 5);
22776
+ swap(buffer, i + 3, i + 4);
22777
+ }
22778
+ return buffer;
22244
22779
  }
22245
22780
  function toBuffer(buffer) {
22246
- if (Buffer.isBuffer(buffer)) return buffer;
22247
- return Buffer.from(buffer.buffer, buffer.byteOffset, buffer.byteLength);
22781
+ return buffer;
22248
22782
  }
22249
- function toString(buffer, encoding, start, end) {
22250
- return toBuffer(buffer).toString(encoding, start, end);
22783
+ function toString(buffer, encoding = "utf8", start = 0, end = buffer.byteLength) {
22784
+ if (arguments.length === 1) return utf8.toString(buffer);
22785
+ if (arguments.length === 2) return codecFor(encoding).toString(buffer);
22786
+ if (start < 0) start = 0;
22787
+ if (start >= buffer.byteLength) return "";
22788
+ if (end <= start) return "";
22789
+ if (end > buffer.byteLength) end = buffer.byteLength;
22790
+ if (start !== 0 || end !== buffer.byteLength) {
22791
+ buffer = buffer.subarray(start, end);
22792
+ }
22793
+ return codecFor(encoding).toString(buffer);
22251
22794
  }
22252
22795
  function write(buffer, string, offset, length, encoding) {
22253
- return toBuffer(buffer).write(string, offset, length, encoding);
22796
+ if (arguments.length === 2) return utf8.write(buffer, string);
22797
+ if (typeof offset === "string") {
22798
+ encoding = offset;
22799
+ offset = 0;
22800
+ length = buffer.byteLength;
22801
+ } else if (typeof length === "string") {
22802
+ encoding = length;
22803
+ length = buffer.byteLength - offset;
22804
+ }
22805
+ length = Math.min(length, exports.byteLength(string, encoding));
22806
+ let start = offset;
22807
+ if (start < 0) start = 0;
22808
+ if (start >= buffer.byteLength) return 0;
22809
+ let end = offset + length;
22810
+ if (end <= start) return 0;
22811
+ if (end > buffer.byteLength) end = buffer.byteLength;
22812
+ if (start !== 0 || end !== buffer.byteLength) {
22813
+ buffer = buffer.subarray(start, end);
22814
+ }
22815
+ return codecFor(encoding).write(buffer, string);
22254
22816
  }
22255
- function readDoubleBE(buffer, offset) {
22256
- return toBuffer(buffer).readDoubleBE(offset);
22817
+ function readDoubleBE(buffer, offset = 0) {
22818
+ const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
22819
+ return view.getFloat64(offset, false);
22257
22820
  }
22258
- function readDoubleLE(buffer, offset) {
22259
- return toBuffer(buffer).readDoubleLE(offset);
22821
+ function readDoubleLE(buffer, offset = 0) {
22822
+ const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
22823
+ return view.getFloat64(offset, true);
22260
22824
  }
22261
- function readFloatBE(buffer, offset) {
22262
- return toBuffer(buffer).readFloatBE(offset);
22825
+ function readFloatBE(buffer, offset = 0) {
22826
+ const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
22827
+ return view.getFloat32(offset, false);
22263
22828
  }
22264
- function readFloatLE(buffer, offset) {
22265
- return toBuffer(buffer).readFloatLE(offset);
22829
+ function readFloatLE(buffer, offset = 0) {
22830
+ const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
22831
+ return view.getFloat32(offset, true);
22266
22832
  }
22267
- function readInt32BE(buffer, offset) {
22268
- return toBuffer(buffer).readInt32BE(offset);
22833
+ function readInt32BE(buffer, offset = 0) {
22834
+ const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
22835
+ return view.getInt32(offset, false);
22269
22836
  }
22270
- function readInt32LE(buffer, offset) {
22271
- return toBuffer(buffer).readInt32LE(offset);
22837
+ function readInt32LE(buffer, offset = 0) {
22838
+ const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
22839
+ return view.getInt32(offset, true);
22272
22840
  }
22273
- function readUInt32BE(buffer, offset) {
22274
- return toBuffer(buffer).readUInt32BE(offset);
22841
+ function readUInt32BE(buffer, offset = 0) {
22842
+ const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
22843
+ return view.getUint32(offset, false);
22275
22844
  }
22276
- function readUInt32LE(buffer, offset) {
22277
- return toBuffer(buffer).readUInt32LE(offset);
22845
+ function readUInt32LE(buffer, offset = 0) {
22846
+ const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
22847
+ return view.getUint32(offset, true);
22278
22848
  }
22279
- function writeDoubleBE(buffer, value, offset) {
22280
- return toBuffer(buffer).writeDoubleBE(value, offset);
22849
+ function writeDoubleBE(buffer, value, offset = 0) {
22850
+ const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
22851
+ view.setFloat64(offset, value, false);
22852
+ return offset + 8;
22281
22853
  }
22282
- function writeDoubleLE(buffer, value, offset) {
22283
- return toBuffer(buffer).writeDoubleLE(value, offset);
22854
+ function writeDoubleLE(buffer, value, offset = 0) {
22855
+ const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
22856
+ view.setFloat64(offset, value, true);
22857
+ return offset + 8;
22284
22858
  }
22285
- function writeFloatBE(buffer, value, offset) {
22286
- return toBuffer(buffer).writeFloatBE(value, offset);
22859
+ function writeFloatBE(buffer, value, offset = 0) {
22860
+ const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
22861
+ view.setFloat32(offset, value, false);
22862
+ return offset + 4;
22287
22863
  }
22288
- function writeFloatLE(buffer, value, offset) {
22289
- return toBuffer(buffer).writeFloatLE(value, offset);
22864
+ function writeFloatLE(buffer, value, offset = 0) {
22865
+ const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
22866
+ view.setFloat32(offset, value, true);
22867
+ return offset + 4;
22290
22868
  }
22291
- function writeInt32BE(buffer, value, offset) {
22292
- return toBuffer(buffer).writeInt32BE(value, offset);
22869
+ function writeInt32BE(buffer, value, offset = 0) {
22870
+ const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
22871
+ view.setInt32(offset, value, false);
22872
+ return offset + 4;
22293
22873
  }
22294
- function writeInt32LE(buffer, value, offset) {
22295
- return toBuffer(buffer).writeInt32LE(value, offset);
22874
+ function writeInt32LE(buffer, value, offset = 0) {
22875
+ const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
22876
+ view.setInt32(offset, value, true);
22877
+ return offset + 4;
22296
22878
  }
22297
- function writeUInt32BE(buffer, value, offset) {
22298
- return toBuffer(buffer).writeUInt32BE(value, offset);
22879
+ function writeUInt32BE(buffer, value, offset = 0) {
22880
+ const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
22881
+ view.setUint32(offset, value, false);
22882
+ return offset + 4;
22299
22883
  }
22300
- function writeUInt32LE(buffer, value, offset) {
22301
- return toBuffer(buffer).writeUInt32LE(value, offset);
22884
+ function writeUInt32LE(buffer, value, offset = 0) {
22885
+ const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
22886
+ view.setUint32(offset, value, true);
22887
+ return offset + 4;
22302
22888
  }
22303
- module.exports = {
22889
+ module.exports = exports = {
22304
22890
  isBuffer,
22305
22891
  isEncoding,
22306
22892
  alloc,
@@ -22345,7 +22931,7 @@ var require_b4a = __commonJS({
22345
22931
  // node_modules/blake2b-wasm/blake2b.js
22346
22932
  var require_blake2b = __commonJS({
22347
22933
  "node_modules/blake2b-wasm/blake2b.js"(exports, module) {
22348
- var __commonJS2 = (cb, mod) => function __require2() {
22934
+ var __commonJS2 = (cb, mod) => function __require() {
22349
22935
  return mod || (0, cb[Object.keys(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
22350
22936
  };
22351
22937
  var __toBinary = /* @__PURE__ */ (() => {
@@ -22382,7 +22968,7 @@ var require_blake2b = __commonJS({
22382
22968
  var require_blake2b_wasm = __commonJS({
22383
22969
  "node_modules/blake2b-wasm/index.js"(exports, module) {
22384
22970
  var assert = require_nanoassert();
22385
- var b4a = require_b4a();
22971
+ var b4a = require_browser();
22386
22972
  var wasm = null;
22387
22973
  var wasmPromise = typeof WebAssembly !== "undefined" && require_blake2b()().then((mod) => {
22388
22974
  wasm = mod;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meshsdk/wallet",
3
- "version": "2.0.0-beta.4",
3
+ "version": "2.0.0-beta.6",
4
4
  "description": "Wallets - https://meshjs.dev/apis/wallets",
5
5
  "main": "./dist/index.cjs",
6
6
  "browser": "./dist/index.js",
@@ -18,7 +18,7 @@
18
18
  "dist/**"
19
19
  ],
20
20
  "scripts": {
21
- "build": "tsup src/index.ts --format esm,cjs --dts",
21
+ "build": "tsup",
22
22
  "build:demo": "tsup demo/src/main.ts --format esm --outDir demo/dist --clean",
23
23
  "dev:demo": "tsup demo/src/main.ts --format esm --outDir demo/dist --watch",
24
24
  "preview:demo": "npx serve demo -p 5173",
@@ -41,8 +41,8 @@
41
41
  "ts-node": "^10.9.2",
42
42
  "ts-jest": "^29.1.4",
43
43
  "dotenv": "^16.4.5",
44
- "@meshsdk/provider": "1.9.0-beta.90",
45
- "@meshsdk/common": "1.9.0-beta.90"
44
+ "@meshsdk/provider": "1.9.0-beta.99",
45
+ "@meshsdk/common": "1.9.0-beta.100"
46
46
  },
47
47
  "dependencies": {
48
48
  "@cardano-sdk/core": "0.46.11",
package/dist/index.d.cts DELETED
@@ -1,518 +0,0 @@
1
- import { DataSignature, Extension as Extension$1, UTxO, Asset, IFetcher, ISubmitter } from '@meshsdk/common';
2
-
3
- interface ISigner {
4
- getPublicKey(): Promise<string>;
5
- getPublicKeyHash(): Promise<string>;
6
- sign(data: string): Promise<string>;
7
- verify(data: string, signature: string): Promise<boolean>;
8
- }
9
-
10
- type DerivationPath = number[] | string;
11
- interface ISecretManager {
12
- getPublicKey(derivationPath: DerivationPath): Promise<string>;
13
- getSigner(derivationPath: DerivationPath): Promise<ISigner>;
14
- }
15
-
16
- declare class InMemoryBip32 implements ISecretManager {
17
- private bip32PrivateKey;
18
- private constructor();
19
- static fromMnemonic(mnemonic: string[], password?: string): Promise<InMemoryBip32>;
20
- static fromEntropy(entropy: string, password?: string): Promise<InMemoryBip32>;
21
- static fromKeyHex(keyHex: string): InMemoryBip32;
22
- static fromBech32(bech32: string): InMemoryBip32;
23
- /**
24
- * Get the Bip32 public key in hex format.
25
- * @returns {Promise<string>} A promise that resolves to the public key in hex format.
26
- */
27
- getPublicKey(): Promise<string>;
28
- /**
29
- * Get an ISigner instance initialized with the current Bip32 private key.
30
- * @returns {Promise<ISigner>} A promise that resolves to an ISigner instance initialized with the current Bip32 private key.
31
- */
32
- getSigner(derivationPath: DerivationPath): Promise<ISigner>;
33
- }
34
-
35
- /**
36
- * BaseSigner provides functionalities to sign and verify data using Ed25519 keys.
37
- * It supports construction from both extended and normal private key hex formats.
38
- */
39
- declare class BaseSigner implements ISigner {
40
- private ed25519PrivateKey;
41
- private constructor();
42
- /**
43
- * Create a BaseSigner instance from an Ed25519 private key in extended hex format.
44
- * @param keyHex Ed25519 private key in extended hex format
45
- * @returns {BaseSigner} A BaseSigner instance
46
- */
47
- static fromExtendedKeyHex(keyHex: string): BaseSigner;
48
- /**
49
- * Create a BaseSigner instance from an Ed25519 private key in normal hex format.
50
- * @param keyHex Ed25519 private key in normal hex format
51
- * @returns {BaseSigner} A BaseSigner instance
52
- */
53
- static fromNormalKeyHex(keyHex: string): BaseSigner;
54
- static fromKeyHex(keyHex: string): BaseSigner;
55
- /**
56
- * Get the Ed25519 public key in hex format.
57
- * @returns {Promise<string>} A promise that resolves to the public key in hex format.
58
- */
59
- getPublicKey(): Promise<string>;
60
- /**
61
- * Get the Ed25519 public key hash in hex format.
62
- * @returns {Promise<string>} A promise that resolves to the public key hash in hex format.
63
- */
64
- getPublicKeyHash(): Promise<string>;
65
- /**
66
- * Sign data using the Ed25519 private key.
67
- * @param data data to be signed in hex format
68
- * @returns {Promise<string>} A promise that resolves to the signature in hex format.
69
- */
70
- sign(data: string): Promise<string>;
71
- /**
72
- * Verify a signature using the Ed25519 public key.
73
- * @param data The original data in hex format.
74
- * @param signature The signature to verify in hex format.
75
- * @returns {Promise<boolean>} A promise that resolves to true if the signature is valid, false otherwise.
76
- */
77
- verify(data: string, signature: string): Promise<boolean>;
78
- }
79
-
80
- declare enum CredentialType {
81
- KeyHash = 0,
82
- ScriptHash = 1
83
- }
84
- type Credential = {
85
- type: CredentialType;
86
- hash: string;
87
- };
88
- declare enum AddressType {
89
- Enterprise = 0,
90
- Base = 1,
91
- Reward = 2
92
- }
93
- declare class CardanoAddress {
94
- addressType: AddressType;
95
- networkId: number;
96
- paymentCredential: Credential;
97
- stakeCredential?: Credential;
98
- constructor(addressType: AddressType, networkId: number, paymentCredential: Credential, stakeCredential?: Credential);
99
- getAddressBech32(): string;
100
- getAddressHex(): string;
101
- private getEnterpriseAddressBech32;
102
- private getEnterpriseAddressHex;
103
- private getBaseAddressBech32;
104
- private getBaseAddressHex;
105
- private getRewardAddressBech32;
106
- private getRewardAddressHex;
107
- }
108
-
109
- interface ICardanoWallet {
110
- getExtensions(): Promise<{
111
- cip: number;
112
- }[]>;
113
- getNetworkId(): Promise<number>;
114
- getUtxos(): Promise<string[]>;
115
- getCollateral(): Promise<string[]>;
116
- getBalance(): Promise<string>;
117
- getUsedAddresses(): Promise<string[]>;
118
- getUnusedAddresses(): Promise<string[]>;
119
- getRewardAddresses(): Promise<string[]>;
120
- getChangeAddress(): Promise<string>;
121
- signTx(data: string, partialSign: boolean): Promise<string>;
122
- signData(addressHex: string, data: string): Promise<DataSignature>;
123
- submitTx(tx: string): Promise<string>;
124
- }
125
-
126
- type Wallet = {
127
- id: string;
128
- name: string;
129
- icon: string;
130
- version: string;
131
- };
132
- type Cardano = {
133
- [key: string]: {
134
- name: string;
135
- icon: string;
136
- apiVersion: string;
137
- enable: (extensions?: {
138
- extensions: {
139
- cip: number;
140
- }[];
141
- }) => Promise<ICardanoWallet>;
142
- supportedExtensions?: {
143
- cip: number;
144
- }[];
145
- };
146
- };
147
- type Extension = {
148
- cip: number;
149
- };
150
- declare class CardanoBrowserWallet implements ICardanoWallet {
151
- walletInstance: ICardanoWallet;
152
- constructor(walletInstance: ICardanoWallet);
153
- getExtensions(): Promise<{
154
- cip: number;
155
- }[]>;
156
- getNetworkId(): Promise<number>;
157
- getUtxos(): Promise<string[]>;
158
- getCollateral(): Promise<string[]>;
159
- getBalance(): Promise<string>;
160
- getUsedAddresses(): Promise<string[]>;
161
- getUnusedAddresses(): Promise<string[]>;
162
- getRewardAddresses(): Promise<string[]>;
163
- getChangeAddress(): Promise<string>;
164
- signTx(data: string, partialSign: boolean): Promise<string>;
165
- signData(addressBech32: string, data: string): Promise<DataSignature>;
166
- submitTx(tx: string): Promise<string>;
167
- /**
168
- * Returns a list of wallets installed on user's device. Each wallet is an object with the following properties:
169
- * - A name is provided to display wallet's name on the user interface.
170
- * - A version is provided to display wallet's version on the user interface.
171
- * - An icon is provided to display wallet's icon on the user interface.
172
- *
173
- * @returns a list of wallet names
174
- */
175
- static getInstalledWallets(): Wallet[];
176
- /**
177
- * This is the entrypoint to start communication with the user's wallet. The wallet should request the user's permission to connect the web page to the user's wallet, and if permission has been granted, the wallet will be returned and exposing the full API for the app to use.
178
- *
179
- * Query BrowserWallet.getInstalledWallets() to get a list of available wallets, then provide the wallet name for which wallet the user would like to connect with.
180
- *
181
- * @param walletName - the name of the wallet to enable (e.g. "eternl", "begin")
182
- * @param extensions - optional, a list of CIPs that the wallet should support
183
- * @returns WalletInstance
184
- */
185
- static enable(walletName: string, extensions?: Extension[]): Promise<ICardanoWallet>;
186
- }
187
-
188
- declare class MeshCardanoBrowserWallet extends CardanoBrowserWallet {
189
- constructor(walletInstance: ICardanoWallet);
190
- static enable(walletName: string, extensions?: Extension$1[]): Promise<MeshCardanoBrowserWallet>;
191
- getUtxosMesh(): Promise<UTxO[]>;
192
- getCollateralMesh(): Promise<UTxO[]>;
193
- getBalanceMesh(): Promise<Asset[]>;
194
- getUsedAddressesBech32(): Promise<string[]>;
195
- getUnusedAddressesBech32(): Promise<string[]>;
196
- getChangeAddressBech32(): Promise<string>;
197
- getRewardAddressesBech32(): Promise<string[]>;
198
- signTxReturnFullTx(tx: string, partialSign?: boolean): Promise<string>;
199
- }
200
-
201
- type CredentialSource = {
202
- type: "signer";
203
- signer: ISigner;
204
- } | {
205
- type: "scriptHash";
206
- scriptHash: string;
207
- };
208
- interface AddressManagerConfig {
209
- addressSource: AddressSource;
210
- networkId: number;
211
- }
212
- type AddressSource = {
213
- type: "secretManager";
214
- secretManager: ISecretManager;
215
- } | {
216
- type: "credentials";
217
- paymentCredential: CredentialSource;
218
- stakeCredential?: CredentialSource;
219
- drepCredential?: CredentialSource;
220
- };
221
- declare class AddressManager {
222
- private readonly paymentCredential;
223
- private readonly stakeCredential;
224
- private readonly drepCredential;
225
- private readonly paymentSigner;
226
- private readonly stakeSigner?;
227
- private readonly drepSigner?;
228
- private readonly networkId;
229
- static create(config: AddressManagerConfig): Promise<AddressManager>;
230
- private constructor();
231
- getNextAddress(addressType: AddressType): Promise<CardanoAddress>;
232
- getChangeAddress(addressType: AddressType): Promise<CardanoAddress>;
233
- getRewardAccount(): Promise<CardanoAddress>;
234
- asyncGetAllUsedAddresses(): Promise<CardanoAddress[]>;
235
- getCredentialsSigners(pubkeyHashes: Set<string>): Promise<Map<string, ISigner>>;
236
- }
237
-
238
- type WalletAddressType = AddressType.Base | AddressType.Enterprise;
239
- /**
240
- * Configuration for creating a CardanoHeadlessWallet instance.
241
- */
242
- interface CardanoHeadlessWalletConfig {
243
- /**
244
- * The source for wallet's signing keys and addresses. Could either be a secret manager or explicit credentials.
245
- */
246
- addressSource: AddressSource;
247
- /**
248
- * The network ID (0 for testnet, 1 for mainnet).
249
- */
250
- networkId: number;
251
- /**
252
- * The type of wallet address to use (Base or Enterprise).
253
- * Base addresses include staking capabilities, while Enterprise addresses do not.
254
- */
255
- walletAddressType: WalletAddressType;
256
- /**
257
- * Optional fetcher instance for querying blockchain data (UTxOs, protocol parameters, etc.).
258
- */
259
- fetcher?: IFetcher;
260
- /**
261
- * Optional submitter instance for submitting transactions to the blockchain.
262
- */
263
- submitter?: ISubmitter;
264
- }
265
- declare class CardanoHeadlessWallet implements ICardanoWallet {
266
- protected networkId: number;
267
- protected addressManager: AddressManager;
268
- protected fetcher?: IFetcher;
269
- protected submitter?: ISubmitter;
270
- protected walletAddressType: WalletAddressType;
271
- protected constructor(networkId: number, addressManager: AddressManager, walletAddressType: WalletAddressType, fetcher?: IFetcher, submitter?: ISubmitter);
272
- static create(config: CardanoHeadlessWalletConfig): Promise<CardanoHeadlessWallet>;
273
- /**
274
- * Create a CardanoHeadlessWallet instance from a Bip32 root in Bech32 format.
275
- * @param config The configuration object
276
- * @returns {Promise<CardanoHeadlessWallet>} A promise that resolves to a CardanoHeadlessWallet instance
277
- */
278
- static fromBip32Root(config: Omit<CardanoHeadlessWalletConfig, "addressSource"> & {
279
- bech32: string;
280
- }): Promise<CardanoHeadlessWallet>;
281
- /**
282
- * Create a CardanoHeadlessWallet instance from a Bip32 root in hex format.
283
- * @param config The configuration object
284
- * @returns {Promise<CardanoHeadlessWallet>} A promise that resolves to a CardanoHeadlessWallet instance
285
- */
286
- static fromBip32RootHex(config: Omit<CardanoHeadlessWalletConfig, "addressSource"> & {
287
- hex: string;
288
- }): Promise<CardanoHeadlessWallet>;
289
- /**
290
- * Create a CardanoHeadlessWallet instance from a mnemonic phrase.
291
- * @param config The configuration object
292
- * @returns {Promise<CardanoHeadlessWallet>} A promise that resolves to a CardanoHeadlessWallet instance
293
- */
294
- static fromMnemonic(config: Omit<CardanoHeadlessWalletConfig, "addressSource"> & {
295
- mnemonic: string[];
296
- password?: string;
297
- }): Promise<CardanoHeadlessWallet>;
298
- static fromCredentialSources(config: Omit<CardanoHeadlessWalletConfig, "addressSource"> & {
299
- paymentCredentialSource: CredentialSource;
300
- stakeCredentialSource?: CredentialSource;
301
- drepCredentialSource?: CredentialSource;
302
- }): Promise<CardanoHeadlessWallet>;
303
- /**
304
- * Submit a transaction to the network, using the submitter instance.
305
- * @param tx The transaction in CBOR hex format
306
- * @returns {Promise<string>} A promise that resolves to the transaction ID
307
- */
308
- submitTx(tx: string): Promise<string>;
309
- /**
310
- * Get the list of extensions enabled for this wallet.
311
- * @returns {Promise<{ cip: number }[]>} A promise that resolves to an array of enabled extensions
312
- */
313
- getExtensions(): Promise<{
314
- cip: number;
315
- }[]>;
316
- /**
317
- * Get the network ID.
318
- * @returns {number} The network ID
319
- */
320
- getNetworkId(): Promise<number>;
321
- /**
322
- * Get the UTxOs for the wallet.
323
- *
324
- * NOTE: This method is only an approximation to CIP-30 getUtxos, as this wallet is completely
325
- * stateless and does not track which UTxOs are specifically set as collateral. Which means that there
326
- * will be overlap between getUtxos() and getCollateral() results. This can result in the collateral being
327
- * spent between transactions.
328
- *
329
- * The method also does not perform pagination, nor is there a coin selection mechanism.
330
- * @returns {Promise<string[]>} A promise that resolves to an array of UTxOs in CBOR hex format
331
- */
332
- getUtxos(): Promise<string[]>;
333
- /**
334
- * Get the collateral UTxOs for the wallet.
335
- *
336
- * NOTE: This method is only an approximation to CIP-30 getCollateral, as this wallet is completely
337
- * stateless and does not track which UTxOs are specifically set as collateral. Which means that there
338
- * will be overlap between getUtxos() and getCollateral() results.
339
- *
340
- * The basic strategy is to return the smallest pure ADA UTxO that is at least 5 ADA belonging to the wallet.
341
- * @returns {Promise<string[]>} A promise that resolves to an array of UTxOs in CBOR hex format
342
- */
343
- getCollateral(): Promise<string[]>;
344
- /**
345
- * Get the balance of the wallet.
346
- *
347
- * NOTE: This method is only an approximation to CIP-30 getBalance, as this wallet is completely
348
- * stateless and does not track which UTxOs are specifically set as collateral. Which means the balance
349
- * returned includes all UTxOs, including those that may be used as collateral.
350
- * @returns {Promise<string>} A promise that resolves to the balance in CBOR hex format
351
- */
352
- getBalance(): Promise<string>;
353
- /**
354
- * Get the used addresses for the wallet.
355
- *
356
- * NOTE: This method completely deviates from CIP-30 getUsedAddresses, as this wallet is stateless
357
- * it is impossible to track which addresses have been used. This method simply returns the wallet's main address.
358
- *
359
- * It will be effective to be used as a single address wallet.
360
- *
361
- * @returns {Promise<string[]>} A promise that resolves to an array of used addresses in hex format
362
- */
363
- getUsedAddresses(): Promise<string[]>;
364
- /**
365
- * Get the unused addresses for the wallet.
366
- *
367
- * NOTE: This method completely deviates from CIP-30 getUnusedAddresses, as this wallet is stateless
368
- * it is impossible to track which addresses have been used. This method simply returns the wallet's main address.
369
- *
370
- * It will be effective to be used as a single address wallet.
371
- *
372
- * @returns {Promise<string[]>} A promise that resolves to an array of unused addresses in hex format
373
- */
374
- getUnusedAddresses(): Promise<string[]>;
375
- /**
376
- * Get the change address for the wallet.
377
- * NOTE: This method deviates from CIP-30 getChangeAddress, as this wallet is stateless
378
- * it does not track which addresses has been previously used as change address. This method simply
379
- * returns the wallet's main address.
380
- *
381
- * It will be effective to be used as a single address wallet.
382
- *
383
- * @returns {Promise<string>} A promise that resolves to the change address in hex format
384
- */
385
- getChangeAddress(): Promise<string>;
386
- /**
387
- * Get the reward address for the wallet.
388
- *
389
- * @returns {Promise<string[]>} A promise that resolves an array of reward addresses in hex format
390
- */
391
- getRewardAddresses(): Promise<string[]>;
392
- /**
393
- * Sign a transaction with the wallet.
394
- *
395
- * NOTE: This method requires a fetcher to resolve input UTxOs for determining required signers.
396
- *
397
- * It is also only an approximation to CIP-30 signTx, as this wallet is stateless and does not repeatedly
398
- * derive keys, it is unable to sign for multiple derived key indexes.
399
- *
400
- * It will be effective to be used as a single address wallet.
401
- *
402
- * @param tx The transaction in CBOR hex format
403
- * @returns A promise that resolves to a witness set with the signatures in CBOR hex format
404
- */
405
- signTx(tx: string, partialSign?: boolean): Promise<string>;
406
- signData(addressBech32: string, data: string): Promise<DataSignature>;
407
- fetchAccountUtxos(): Promise<UTxO[]>;
408
- }
409
-
410
- /**
411
- * MeshCardanoHeadlessWallet provides additional convenience methods on top of CardanoHeadlessWallet,
412
- * such as returning results in Mesh-compatible formats and Bech32 addresses.
413
- */
414
- declare class MeshCardanoHeadlessWallet extends CardanoHeadlessWallet {
415
- static create(config: CardanoHeadlessWalletConfig): Promise<MeshCardanoHeadlessWallet>;
416
- static fromMnemonic(config: Omit<CardanoHeadlessWalletConfig, "addressSource"> & {
417
- mnemonic: string[];
418
- password?: string;
419
- }): Promise<MeshCardanoHeadlessWallet>;
420
- static fromBip32Root(config: Omit<CardanoHeadlessWalletConfig, "addressSource"> & {
421
- bech32: string;
422
- }): Promise<MeshCardanoHeadlessWallet>;
423
- static fromBip32RootHex(config: Omit<CardanoHeadlessWalletConfig, "addressSource"> & {
424
- hex: string;
425
- }): Promise<MeshCardanoHeadlessWallet>;
426
- static fromCredentialSources(config: Omit<CardanoHeadlessWalletConfig, "addressSource"> & {
427
- paymentCredentialSource: CredentialSource;
428
- stakeCredentialSource?: CredentialSource;
429
- drepCredentialSource?: CredentialSource;
430
- }): Promise<MeshCardanoHeadlessWallet>;
431
- /**
432
- * Get the UTxOs for the wallet.
433
- *
434
- * NOTE: This method is only an approximation to CIP-30 getUtxos, as this wallet is completely
435
- * stateless and does not track which UTxOs are specifically set as collateral. Which means that there
436
- * will be overlap between getUtxos() and getCollateral() results. This can result in the collateral being
437
- * spent between transactions.
438
- *
439
- * The method also does not perform pagination, nor is there a coin selection mechanism.
440
- * @returns {Promise<UTxO[]>} A promise that resolves to an array of UTxOs in the Mesh UTxO format
441
- */
442
- getUtxosMesh(): Promise<UTxO[]>;
443
- /**
444
- * Get the collateral UTxOs for the wallet.
445
- *
446
- * NOTE: This method is only an approximation to CIP-30 getCollateral, as this wallet is completely
447
- * stateless and does not track which UTxOs are specifically set as collateral. Which means that there
448
- * will be overlap between getUtxos() and getCollateral() results.
449
- *
450
- * The basic strategy is to return the smallest pure ADA UTxO that is at least 5 ADA belonging to the wallet.
451
- * @returns {Promise<UTxO[]>} A promise that resolves to an array of UTxOs in the Mesh UTxO format
452
- */
453
- getCollateralMesh(): Promise<UTxO[]>;
454
- /**
455
- * Get the balance of the wallet.
456
- *
457
- * NOTE: This method is only an approximation to CIP-30 getBalance, as this wallet is completely
458
- * stateless and does not track which UTxOs are specifically set as collateral. Which means the balance
459
- * returned includes all UTxOs, including those that may be used as collateral.
460
- * @returns {Promise<Asset[]>} A promise that resolves to the balance in the Mesh Asset format
461
- */
462
- getBalanceMesh(): Promise<Asset[]>;
463
- /**
464
- * Get the used addresses for the wallet.
465
- *
466
- * NOTE: This method completely deviates from CIP-30 getUsedAddresses, as this wallet is stateless
467
- * it is impossible to track which addresses have been used. This method simply returns the wallet's main address.
468
- *
469
- * It will be effective to be used as a single address wallet.
470
- *
471
- * @returns {Promise<string[]>} A promise that resolves to an array of used addresses in Bech32 format
472
- */
473
- getUsedAddressesBech32(): Promise<string[]>;
474
- /**
475
- * Get the unused addresses for the wallet.
476
- *
477
- * NOTE: This method completely deviates from CIP-30 getUnusedAddresses, as this wallet is stateless
478
- * it is impossible to track which addresses have been used. This method simply returns the wallet's main address.
479
- *
480
- * It will be effective to be used as a single address wallet.
481
- *
482
- * @returns {Promise<string[]>} A promise that resolves to an array of unused addresses in Bech32 format
483
- */
484
- getUnusedAddressesBech32(): Promise<string[]>;
485
- /**
486
- * Get the change address for the wallet.
487
- * NOTE: This method deviates from CIP-30 getChangeAddress, as this wallet is stateless
488
- * it does not track which addresses has been previously used as change address. This method simply
489
- * returns the wallet's main address.
490
- *
491
- * It will be effective to be used as a single address wallet.
492
- *
493
- * @returns {Promise<string>} A promise that resolves to the change address in Bech32 format
494
- */
495
- getChangeAddressBech32(): Promise<string>;
496
- /**
497
- * Get the reward address for the wallet.
498
- * @returns {Promise<string[]>} A promise that resolves an array of reward addresses in Bech32 format
499
- */
500
- getRewardAddressesBech32(): Promise<string[]>;
501
- /**
502
- * Sign a transaction with the wallet.
503
- *
504
- * NOTE: This method requires a fetcher to resolve input UTxOs for determining required signers.
505
- *
506
- * It is also only an approximation to CIP-30 signTx, as this wallet is stateless and does not repeatedly
507
- * derive keys, it is unable to sign for multiple derived key indexes.
508
- *
509
- * It will be effective to be used as a single address wallet.
510
- *
511
- * @param tx The transaction in CBOR hex format
512
- * @returns A promise that resolves to a full transaction with extra vkey witnesses added from the wallet
513
- * to the witness set in CBOR hex format
514
- */
515
- signTxReturnFullTx(tx: string, partialSign?: boolean): Promise<string>;
516
- }
517
-
518
- export { AddressType, BaseSigner, type Cardano, CardanoAddress, CardanoBrowserWallet, CardanoHeadlessWallet, type CardanoHeadlessWalletConfig, type Credential, type CredentialSource, CredentialType, type ICardanoWallet, InMemoryBip32, MeshCardanoBrowserWallet, MeshCardanoHeadlessWallet, type WalletAddressType };