@zubari/sdk 0.5.2 → 0.5.3

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.
@@ -1,12 +1,9 @@
1
1
  import { HDNodeWallet } from 'ethers';
2
2
  import { mnemonicToSeedSync, validateMnemonic, generateMnemonic } from '@scure/bip39';
3
3
  import { wordlist } from '@scure/bip39/wordlists/english';
4
- import { secp256k1 } from '@noble/curves/secp256k1.js';
5
- import { hmac } from '@noble/hashes/hmac.js';
6
- import { ripemd160 as ripemd160$1 } from '@noble/hashes/legacy.js';
7
- import { sha256, sha512 } from '@noble/hashes/sha2.js';
8
- import { createView, concatBytes, abytes } from '@noble/hashes/utils.js';
9
- import { sha256 as sha256$1 } from '@noble/hashes/sha256';
4
+ import { HDKey } from '@scure/bip32';
5
+ import { bech32, base58check } from '@scure/base';
6
+ import { sha256 } from '@noble/hashes/sha256';
10
7
  import { ripemd160 } from '@noble/hashes/ripemd160';
11
8
 
12
9
  var __defProp = Object.defineProperty;
@@ -266,14 +263,14 @@ var WdkApiClient = class {
266
263
  /**
267
264
  * Derive address for a specific chain using Tether WDK
268
265
  */
269
- async deriveAddress(seed, chain2, network = "mainnet") {
266
+ async deriveAddress(seed, chain, network = "mainnet") {
270
267
  try {
271
268
  const response = await fetch(`${this.config.baseUrl}/api/wallets/wdk/derive-address`, {
272
269
  method: "POST",
273
270
  headers: {
274
271
  "Content-Type": "application/json"
275
272
  },
276
- body: JSON.stringify({ seed, chain: chain2, network })
273
+ body: JSON.stringify({ seed, chain, network })
277
274
  });
278
275
  return await response.json();
279
276
  } catch (error) {
@@ -306,14 +303,14 @@ var WdkApiClient = class {
306
303
  /**
307
304
  * Send a transaction on a specific chain using Tether WDK
308
305
  */
309
- async sendTransaction(seed, chain2, to, amount, network = "mainnet") {
306
+ async sendTransaction(seed, chain, to, amount, network = "mainnet") {
310
307
  try {
311
308
  const response = await fetch(`${this.config.baseUrl}/api/wallets/wdk/send`, {
312
309
  method: "POST",
313
310
  headers: {
314
311
  "Content-Type": "application/json"
315
312
  },
316
- body: JSON.stringify({ seed, chain: chain2, to, amount, network })
313
+ body: JSON.stringify({ seed, chain, to, amount, network })
317
314
  });
318
315
  return await response.json();
319
316
  } catch (error) {
@@ -327,14 +324,14 @@ var WdkApiClient = class {
327
324
  * Get transaction history for an address on a specific chain
328
325
  * Fetches from blockchain explorers (Etherscan, mempool.space, etc.)
329
326
  */
330
- async getTransactionHistory(seed, chain2, network = "mainnet", limit = 10) {
327
+ async getTransactionHistory(seed, chain, network = "mainnet", limit = 10) {
331
328
  try {
332
329
  const response = await fetch(`${this.config.baseUrl}/api/wallets/wdk/history`, {
333
330
  method: "POST",
334
331
  headers: {
335
332
  "Content-Type": "application/json"
336
333
  },
337
- body: JSON.stringify({ seed, chain: chain2, network, limit })
334
+ body: JSON.stringify({ seed, chain, network, limit })
338
335
  });
339
336
  return await response.json();
340
337
  } catch (error) {
@@ -348,14 +345,14 @@ var WdkApiClient = class {
348
345
  * Get transaction status by hash
349
346
  * Fetches from blockchain explorers to check confirmation status
350
347
  */
351
- async getTransactionStatus(txHash, chain2, network = "mainnet") {
348
+ async getTransactionStatus(txHash, chain, network = "mainnet") {
352
349
  try {
353
350
  const response = await fetch(`${this.config.baseUrl}/api/wallets/wdk/tx-status`, {
354
351
  method: "POST",
355
352
  headers: {
356
353
  "Content-Type": "application/json"
357
354
  },
358
- body: JSON.stringify({ txHash, chain: chain2, network })
355
+ body: JSON.stringify({ txHash, chain, network })
359
356
  });
360
357
  return await response.json();
361
358
  } catch (error) {
@@ -1075,589 +1072,6 @@ __export(BrowserAddressDerivation_exports, {
1075
1072
  generateSeedPhrase: () => generateSeedPhrase,
1076
1073
  isValidSeed: () => isValidSeed
1077
1074
  });
1078
-
1079
- // node_modules/@scure/base/index.js
1080
- function isBytes(a) {
1081
- return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
1082
- }
1083
- function isArrayOf(isString, arr) {
1084
- if (!Array.isArray(arr))
1085
- return false;
1086
- if (arr.length === 0)
1087
- return true;
1088
- if (isString) {
1089
- return arr.every((item) => typeof item === "string");
1090
- } else {
1091
- return arr.every((item) => Number.isSafeInteger(item));
1092
- }
1093
- }
1094
- function afn(input) {
1095
- if (typeof input !== "function")
1096
- throw new Error("function expected");
1097
- return true;
1098
- }
1099
- function astr(label, input) {
1100
- if (typeof input !== "string")
1101
- throw new Error(`${label}: string expected`);
1102
- return true;
1103
- }
1104
- function anumber(n) {
1105
- if (!Number.isSafeInteger(n))
1106
- throw new Error(`invalid integer: ${n}`);
1107
- }
1108
- function aArr(input) {
1109
- if (!Array.isArray(input))
1110
- throw new Error("array expected");
1111
- }
1112
- function astrArr(label, input) {
1113
- if (!isArrayOf(true, input))
1114
- throw new Error(`${label}: array of strings expected`);
1115
- }
1116
- function anumArr(label, input) {
1117
- if (!isArrayOf(false, input))
1118
- throw new Error(`${label}: array of numbers expected`);
1119
- }
1120
- // @__NO_SIDE_EFFECTS__
1121
- function chain(...args) {
1122
- const id = (a) => a;
1123
- const wrap = (a, b) => (c) => a(b(c));
1124
- const encode = args.map((x) => x.encode).reduceRight(wrap, id);
1125
- const decode = args.map((x) => x.decode).reduce(wrap, id);
1126
- return { encode, decode };
1127
- }
1128
- // @__NO_SIDE_EFFECTS__
1129
- function alphabet(letters) {
1130
- const lettersA = typeof letters === "string" ? letters.split("") : letters;
1131
- const len = lettersA.length;
1132
- astrArr("alphabet", lettersA);
1133
- const indexes = new Map(lettersA.map((l, i) => [l, i]));
1134
- return {
1135
- encode: (digits) => {
1136
- aArr(digits);
1137
- return digits.map((i) => {
1138
- if (!Number.isSafeInteger(i) || i < 0 || i >= len)
1139
- throw new Error(`alphabet.encode: digit index outside alphabet "${i}". Allowed: ${letters}`);
1140
- return lettersA[i];
1141
- });
1142
- },
1143
- decode: (input) => {
1144
- aArr(input);
1145
- return input.map((letter) => {
1146
- astr("alphabet.decode", letter);
1147
- const i = indexes.get(letter);
1148
- if (i === void 0)
1149
- throw new Error(`Unknown letter: "${letter}". Allowed: ${letters}`);
1150
- return i;
1151
- });
1152
- }
1153
- };
1154
- }
1155
- // @__NO_SIDE_EFFECTS__
1156
- function join(separator = "") {
1157
- astr("join", separator);
1158
- return {
1159
- encode: (from) => {
1160
- astrArr("join.decode", from);
1161
- return from.join(separator);
1162
- },
1163
- decode: (to) => {
1164
- astr("join.decode", to);
1165
- return to.split(separator);
1166
- }
1167
- };
1168
- }
1169
- function convertRadix(data, from, to) {
1170
- if (from < 2)
1171
- throw new Error(`convertRadix: invalid from=${from}, base cannot be less than 2`);
1172
- if (to < 2)
1173
- throw new Error(`convertRadix: invalid to=${to}, base cannot be less than 2`);
1174
- aArr(data);
1175
- if (!data.length)
1176
- return [];
1177
- let pos = 0;
1178
- const res = [];
1179
- const digits = Array.from(data, (d) => {
1180
- anumber(d);
1181
- if (d < 0 || d >= from)
1182
- throw new Error(`invalid integer: ${d}`);
1183
- return d;
1184
- });
1185
- const dlen = digits.length;
1186
- while (true) {
1187
- let carry = 0;
1188
- let done = true;
1189
- for (let i = pos; i < dlen; i++) {
1190
- const digit = digits[i];
1191
- const fromCarry = from * carry;
1192
- const digitBase = fromCarry + digit;
1193
- if (!Number.isSafeInteger(digitBase) || fromCarry / from !== carry || digitBase - digit !== fromCarry) {
1194
- throw new Error("convertRadix: carry overflow");
1195
- }
1196
- const div = digitBase / to;
1197
- carry = digitBase % to;
1198
- const rounded = Math.floor(div);
1199
- digits[i] = rounded;
1200
- if (!Number.isSafeInteger(rounded) || rounded * to + carry !== digitBase)
1201
- throw new Error("convertRadix: carry overflow");
1202
- if (!done)
1203
- continue;
1204
- else if (!rounded)
1205
- pos = i;
1206
- else
1207
- done = false;
1208
- }
1209
- res.push(carry);
1210
- if (done)
1211
- break;
1212
- }
1213
- for (let i = 0; i < data.length - 1 && data[i] === 0; i++)
1214
- res.push(0);
1215
- return res.reverse();
1216
- }
1217
- var gcd = (a, b) => b === 0 ? a : gcd(b, a % b);
1218
- var radix2carry = /* @__NO_SIDE_EFFECTS__ */ (from, to) => from + (to - gcd(from, to));
1219
- var powers = /* @__PURE__ */ (() => {
1220
- let res = [];
1221
- for (let i = 0; i < 40; i++)
1222
- res.push(2 ** i);
1223
- return res;
1224
- })();
1225
- function convertRadix2(data, from, to, padding) {
1226
- aArr(data);
1227
- if (from <= 0 || from > 32)
1228
- throw new Error(`convertRadix2: wrong from=${from}`);
1229
- if (to <= 0 || to > 32)
1230
- throw new Error(`convertRadix2: wrong to=${to}`);
1231
- if (/* @__PURE__ */ radix2carry(from, to) > 32) {
1232
- throw new Error(`convertRadix2: carry overflow from=${from} to=${to} carryBits=${/* @__PURE__ */ radix2carry(from, to)}`);
1233
- }
1234
- let carry = 0;
1235
- let pos = 0;
1236
- const max = powers[from];
1237
- const mask = powers[to] - 1;
1238
- const res = [];
1239
- for (const n of data) {
1240
- anumber(n);
1241
- if (n >= max)
1242
- throw new Error(`convertRadix2: invalid data word=${n} from=${from}`);
1243
- carry = carry << from | n;
1244
- if (pos + from > 32)
1245
- throw new Error(`convertRadix2: carry overflow pos=${pos} from=${from}`);
1246
- pos += from;
1247
- for (; pos >= to; pos -= to)
1248
- res.push((carry >> pos - to & mask) >>> 0);
1249
- const pow = powers[pos];
1250
- if (pow === void 0)
1251
- throw new Error("invalid carry");
1252
- carry &= pow - 1;
1253
- }
1254
- carry = carry << to - pos & mask;
1255
- if (!padding && pos >= from)
1256
- throw new Error("Excess padding");
1257
- if (!padding && carry > 0)
1258
- throw new Error(`Non-zero padding: ${carry}`);
1259
- if (padding && pos > 0)
1260
- res.push(carry >>> 0);
1261
- return res;
1262
- }
1263
- // @__NO_SIDE_EFFECTS__
1264
- function radix(num) {
1265
- anumber(num);
1266
- const _256 = 2 ** 8;
1267
- return {
1268
- encode: (bytes) => {
1269
- if (!isBytes(bytes))
1270
- throw new Error("radix.encode input should be Uint8Array");
1271
- return convertRadix(Array.from(bytes), _256, num);
1272
- },
1273
- decode: (digits) => {
1274
- anumArr("radix.decode", digits);
1275
- return Uint8Array.from(convertRadix(digits, num, _256));
1276
- }
1277
- };
1278
- }
1279
- // @__NO_SIDE_EFFECTS__
1280
- function radix2(bits, revPadding = false) {
1281
- anumber(bits);
1282
- if (/* @__PURE__ */ radix2carry(8, bits) > 32 || /* @__PURE__ */ radix2carry(bits, 8) > 32)
1283
- throw new Error("radix2: carry overflow");
1284
- return {
1285
- encode: (bytes) => {
1286
- if (!isBytes(bytes))
1287
- throw new Error("radix2.encode input should be Uint8Array");
1288
- return convertRadix2(Array.from(bytes), 8, bits, !revPadding);
1289
- },
1290
- decode: (digits) => {
1291
- anumArr("radix2.decode", digits);
1292
- return Uint8Array.from(convertRadix2(digits, bits, 8, revPadding));
1293
- }
1294
- };
1295
- }
1296
- function unsafeWrapper(fn) {
1297
- afn(fn);
1298
- return function(...args) {
1299
- try {
1300
- return fn.apply(null, args);
1301
- } catch (e) {
1302
- }
1303
- };
1304
- }
1305
- function checksum(len, fn) {
1306
- anumber(len);
1307
- afn(fn);
1308
- return {
1309
- encode(data) {
1310
- if (!isBytes(data))
1311
- throw new Error("checksum.encode: input should be Uint8Array");
1312
- const sum = fn(data).slice(0, len);
1313
- const res = new Uint8Array(data.length + len);
1314
- res.set(data);
1315
- res.set(sum, data.length);
1316
- return res;
1317
- },
1318
- decode(data) {
1319
- if (!isBytes(data))
1320
- throw new Error("checksum.decode: input should be Uint8Array");
1321
- const payload = data.slice(0, -len);
1322
- const oldChecksum = data.slice(-len);
1323
- const newChecksum = fn(payload).slice(0, len);
1324
- for (let i = 0; i < len; i++)
1325
- if (newChecksum[i] !== oldChecksum[i])
1326
- throw new Error("Invalid checksum");
1327
- return payload;
1328
- }
1329
- };
1330
- }
1331
- var genBase58 = /* @__NO_SIDE_EFFECTS__ */ (abc) => /* @__PURE__ */ chain(/* @__PURE__ */ radix(58), /* @__PURE__ */ alphabet(abc), /* @__PURE__ */ join(""));
1332
- var base58 = /* @__PURE__ */ genBase58("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
1333
- var createBase58check = (sha2563) => /* @__PURE__ */ chain(checksum(4, (data) => sha2563(sha2563(data))), base58);
1334
- var base58check = createBase58check;
1335
- var BECH_ALPHABET = /* @__PURE__ */ chain(/* @__PURE__ */ alphabet("qpzry9x8gf2tvdw0s3jn54khce6mua7l"), /* @__PURE__ */ join(""));
1336
- var POLYMOD_GENERATORS = [996825010, 642813549, 513874426, 1027748829, 705979059];
1337
- function bech32Polymod(pre) {
1338
- const b = pre >> 25;
1339
- let chk = (pre & 33554431) << 5;
1340
- for (let i = 0; i < POLYMOD_GENERATORS.length; i++) {
1341
- if ((b >> i & 1) === 1)
1342
- chk ^= POLYMOD_GENERATORS[i];
1343
- }
1344
- return chk;
1345
- }
1346
- function bechChecksum(prefix, words, encodingConst = 1) {
1347
- const len = prefix.length;
1348
- let chk = 1;
1349
- for (let i = 0; i < len; i++) {
1350
- const c = prefix.charCodeAt(i);
1351
- if (c < 33 || c > 126)
1352
- throw new Error(`Invalid prefix (${prefix})`);
1353
- chk = bech32Polymod(chk) ^ c >> 5;
1354
- }
1355
- chk = bech32Polymod(chk);
1356
- for (let i = 0; i < len; i++)
1357
- chk = bech32Polymod(chk) ^ prefix.charCodeAt(i) & 31;
1358
- for (let v of words)
1359
- chk = bech32Polymod(chk) ^ v;
1360
- for (let i = 0; i < 6; i++)
1361
- chk = bech32Polymod(chk);
1362
- chk ^= encodingConst;
1363
- return BECH_ALPHABET.encode(convertRadix2([chk % powers[30]], 30, 5, false));
1364
- }
1365
- // @__NO_SIDE_EFFECTS__
1366
- function genBech32(encoding) {
1367
- const ENCODING_CONST = 1 ;
1368
- const _words = /* @__PURE__ */ radix2(5);
1369
- const fromWords = _words.decode;
1370
- const toWords = _words.encode;
1371
- const fromWordsUnsafe = unsafeWrapper(fromWords);
1372
- function encode(prefix, words, limit = 90) {
1373
- astr("bech32.encode prefix", prefix);
1374
- if (isBytes(words))
1375
- words = Array.from(words);
1376
- anumArr("bech32.encode", words);
1377
- const plen = prefix.length;
1378
- if (plen === 0)
1379
- throw new TypeError(`Invalid prefix length ${plen}`);
1380
- const actualLength = plen + 7 + words.length;
1381
- if (limit !== false && actualLength > limit)
1382
- throw new TypeError(`Length ${actualLength} exceeds limit ${limit}`);
1383
- const lowered = prefix.toLowerCase();
1384
- const sum = bechChecksum(lowered, words, ENCODING_CONST);
1385
- return `${lowered}1${BECH_ALPHABET.encode(words)}${sum}`;
1386
- }
1387
- function decode(str, limit = 90) {
1388
- astr("bech32.decode input", str);
1389
- const slen = str.length;
1390
- if (slen < 8 || limit !== false && slen > limit)
1391
- throw new TypeError(`invalid string length: ${slen} (${str}). Expected (8..${limit})`);
1392
- const lowered = str.toLowerCase();
1393
- if (str !== lowered && str !== str.toUpperCase())
1394
- throw new Error(`String must be lowercase or uppercase`);
1395
- const sepIndex = lowered.lastIndexOf("1");
1396
- if (sepIndex === 0 || sepIndex === -1)
1397
- throw new Error(`Letter "1" must be present between prefix and data only`);
1398
- const prefix = lowered.slice(0, sepIndex);
1399
- const data = lowered.slice(sepIndex + 1);
1400
- if (data.length < 6)
1401
- throw new Error("Data must be at least 6 characters long");
1402
- const words = BECH_ALPHABET.decode(data).slice(0, -6);
1403
- const sum = bechChecksum(prefix, words, ENCODING_CONST);
1404
- if (!data.endsWith(sum))
1405
- throw new Error(`Invalid checksum in ${str}: expected "${sum}"`);
1406
- return { prefix, words };
1407
- }
1408
- const decodeUnsafe = unsafeWrapper(decode);
1409
- function decodeToBytes(str) {
1410
- const { prefix, words } = decode(str, false);
1411
- return { prefix, words, bytes: fromWords(words) };
1412
- }
1413
- function encodeFromBytes(prefix, bytes) {
1414
- return encode(prefix, toWords(bytes));
1415
- }
1416
- return {
1417
- encode,
1418
- decode,
1419
- encodeFromBytes,
1420
- decodeToBytes,
1421
- decodeUnsafe,
1422
- fromWords,
1423
- fromWordsUnsafe,
1424
- toWords
1425
- };
1426
- }
1427
- var bech32 = /* @__PURE__ */ genBech32();
1428
-
1429
- // node_modules/@scure/bip32/index.js
1430
- var Point = secp256k1.Point;
1431
- var { Fn } = Point;
1432
- var base58check2 = createBase58check(sha256);
1433
- var MASTER_SECRET = Uint8Array.from("Bitcoin seed".split(""), (char) => char.charCodeAt(0));
1434
- var BITCOIN_VERSIONS = { private: 76066276, public: 76067358 };
1435
- var HARDENED_OFFSET = 2147483648;
1436
- var hash160 = (data) => ripemd160$1(sha256(data));
1437
- var fromU32 = (data) => createView(data).getUint32(0, false);
1438
- var toU32 = (n) => {
1439
- if (!Number.isSafeInteger(n) || n < 0 || n > 2 ** 32 - 1) {
1440
- throw new Error("invalid number, should be from 0 to 2**32-1, got " + n);
1441
- }
1442
- const buf = new Uint8Array(4);
1443
- createView(buf).setUint32(0, n, false);
1444
- return buf;
1445
- };
1446
- var HDKey = class _HDKey {
1447
- get fingerprint() {
1448
- if (!this.pubHash) {
1449
- throw new Error("No publicKey set!");
1450
- }
1451
- return fromU32(this.pubHash);
1452
- }
1453
- get identifier() {
1454
- return this.pubHash;
1455
- }
1456
- get pubKeyHash() {
1457
- return this.pubHash;
1458
- }
1459
- get privateKey() {
1460
- return this._privateKey || null;
1461
- }
1462
- get publicKey() {
1463
- return this._publicKey || null;
1464
- }
1465
- get privateExtendedKey() {
1466
- const priv = this._privateKey;
1467
- if (!priv) {
1468
- throw new Error("No private key");
1469
- }
1470
- return base58check2.encode(this.serialize(this.versions.private, concatBytes(Uint8Array.of(0), priv)));
1471
- }
1472
- get publicExtendedKey() {
1473
- if (!this._publicKey) {
1474
- throw new Error("No public key");
1475
- }
1476
- return base58check2.encode(this.serialize(this.versions.public, this._publicKey));
1477
- }
1478
- static fromMasterSeed(seed, versions = BITCOIN_VERSIONS) {
1479
- abytes(seed);
1480
- if (8 * seed.length < 128 || 8 * seed.length > 512) {
1481
- throw new Error("HDKey: seed length must be between 128 and 512 bits; 256 bits is advised, got " + seed.length);
1482
- }
1483
- const I = hmac(sha512, MASTER_SECRET, seed);
1484
- const privateKey = I.slice(0, 32);
1485
- const chainCode = I.slice(32);
1486
- return new _HDKey({ versions, chainCode, privateKey });
1487
- }
1488
- static fromExtendedKey(base58key, versions = BITCOIN_VERSIONS) {
1489
- const keyBuffer = base58check2.decode(base58key);
1490
- const keyView = createView(keyBuffer);
1491
- const version = keyView.getUint32(0, false);
1492
- const opt = {
1493
- versions,
1494
- depth: keyBuffer[4],
1495
- parentFingerprint: keyView.getUint32(5, false),
1496
- index: keyView.getUint32(9, false),
1497
- chainCode: keyBuffer.slice(13, 45)
1498
- };
1499
- const key = keyBuffer.slice(45);
1500
- const isPriv = key[0] === 0;
1501
- if (version !== versions[isPriv ? "private" : "public"]) {
1502
- throw new Error("Version mismatch");
1503
- }
1504
- if (isPriv) {
1505
- return new _HDKey({ ...opt, privateKey: key.slice(1) });
1506
- } else {
1507
- return new _HDKey({ ...opt, publicKey: key });
1508
- }
1509
- }
1510
- static fromJSON(json) {
1511
- return _HDKey.fromExtendedKey(json.xpriv);
1512
- }
1513
- versions;
1514
- depth = 0;
1515
- index = 0;
1516
- chainCode = null;
1517
- parentFingerprint = 0;
1518
- _privateKey;
1519
- _publicKey;
1520
- pubHash;
1521
- constructor(opt) {
1522
- if (!opt || typeof opt !== "object") {
1523
- throw new Error("HDKey.constructor must not be called directly");
1524
- }
1525
- this.versions = opt.versions || BITCOIN_VERSIONS;
1526
- this.depth = opt.depth || 0;
1527
- this.chainCode = opt.chainCode || null;
1528
- this.index = opt.index || 0;
1529
- this.parentFingerprint = opt.parentFingerprint || 0;
1530
- if (!this.depth) {
1531
- if (this.parentFingerprint || this.index) {
1532
- throw new Error("HDKey: zero depth with non-zero index/parent fingerprint");
1533
- }
1534
- }
1535
- if (this.depth > 255) {
1536
- throw new Error("HDKey: depth exceeds the serializable value 255");
1537
- }
1538
- if (opt.publicKey && opt.privateKey) {
1539
- throw new Error("HDKey: publicKey and privateKey at same time.");
1540
- }
1541
- if (opt.privateKey) {
1542
- if (!secp256k1.utils.isValidSecretKey(opt.privateKey))
1543
- throw new Error("Invalid private key");
1544
- this._privateKey = opt.privateKey;
1545
- this._publicKey = secp256k1.getPublicKey(opt.privateKey, true);
1546
- } else if (opt.publicKey) {
1547
- this._publicKey = Point.fromBytes(opt.publicKey).toBytes(true);
1548
- } else {
1549
- throw new Error("HDKey: no public or private key provided");
1550
- }
1551
- this.pubHash = hash160(this._publicKey);
1552
- }
1553
- derive(path) {
1554
- if (!/^[mM]'?/.test(path)) {
1555
- throw new Error('Path must start with "m" or "M"');
1556
- }
1557
- if (/^[mM]'?$/.test(path)) {
1558
- return this;
1559
- }
1560
- const parts = path.replace(/^[mM]'?\//, "").split("/");
1561
- let child = this;
1562
- for (const c of parts) {
1563
- const m = /^(\d+)('?)$/.exec(c);
1564
- const m1 = m && m[1];
1565
- if (!m || m.length !== 3 || typeof m1 !== "string")
1566
- throw new Error("invalid child index: " + c);
1567
- let idx = +m1;
1568
- if (!Number.isSafeInteger(idx) || idx >= HARDENED_OFFSET) {
1569
- throw new Error("Invalid index");
1570
- }
1571
- if (m[2] === "'") {
1572
- idx += HARDENED_OFFSET;
1573
- }
1574
- child = child.deriveChild(idx);
1575
- }
1576
- return child;
1577
- }
1578
- deriveChild(index) {
1579
- if (!this._publicKey || !this.chainCode) {
1580
- throw new Error("No publicKey or chainCode set");
1581
- }
1582
- let data = toU32(index);
1583
- if (index >= HARDENED_OFFSET) {
1584
- const priv = this._privateKey;
1585
- if (!priv) {
1586
- throw new Error("Could not derive hardened child key");
1587
- }
1588
- data = concatBytes(Uint8Array.of(0), priv, data);
1589
- } else {
1590
- data = concatBytes(this._publicKey, data);
1591
- }
1592
- const I = hmac(sha512, this.chainCode, data);
1593
- const childTweak = I.slice(0, 32);
1594
- const chainCode = I.slice(32);
1595
- if (!secp256k1.utils.isValidSecretKey(childTweak)) {
1596
- throw new Error("Tweak bigger than curve order");
1597
- }
1598
- const opt = {
1599
- versions: this.versions,
1600
- chainCode,
1601
- depth: this.depth + 1,
1602
- parentFingerprint: this.fingerprint,
1603
- index
1604
- };
1605
- const ctweak = Fn.fromBytes(childTweak);
1606
- try {
1607
- if (this._privateKey) {
1608
- const added = Fn.create(Fn.fromBytes(this._privateKey) + ctweak);
1609
- if (!Fn.isValidNot0(added)) {
1610
- throw new Error("The tweak was out of range or the resulted private key is invalid");
1611
- }
1612
- opt.privateKey = Fn.toBytes(added);
1613
- } else {
1614
- const added = Point.fromBytes(this._publicKey).add(Point.BASE.multiply(ctweak));
1615
- if (added.equals(Point.ZERO)) {
1616
- throw new Error("The tweak was equal to negative P, which made the result key invalid");
1617
- }
1618
- opt.publicKey = added.toBytes(true);
1619
- }
1620
- return new _HDKey(opt);
1621
- } catch (err) {
1622
- return this.deriveChild(index + 1);
1623
- }
1624
- }
1625
- sign(hash) {
1626
- if (!this._privateKey) {
1627
- throw new Error("No privateKey set!");
1628
- }
1629
- abytes(hash, 32);
1630
- return secp256k1.sign(hash, this._privateKey, { prehash: false });
1631
- }
1632
- verify(hash, signature) {
1633
- abytes(hash, 32);
1634
- abytes(signature, 64);
1635
- if (!this._publicKey) {
1636
- throw new Error("No publicKey set!");
1637
- }
1638
- return secp256k1.verify(signature, hash, this._publicKey, { prehash: false });
1639
- }
1640
- wipePrivateData() {
1641
- if (this._privateKey) {
1642
- this._privateKey.fill(0);
1643
- this._privateKey = void 0;
1644
- }
1645
- return this;
1646
- }
1647
- toJSON() {
1648
- return {
1649
- xpriv: this.privateExtendedKey,
1650
- xpub: this.publicExtendedKey
1651
- };
1652
- }
1653
- serialize(version, key) {
1654
- if (!this.chainCode) {
1655
- throw new Error("No chainCode set");
1656
- }
1657
- abytes(key, 33);
1658
- return concatBytes(toU32(version), new Uint8Array([this.depth]), toU32(this.parentFingerprint), toU32(this.index), this.chainCode, key);
1659
- }
1660
- };
1661
1075
  var DERIVATION_PATHS = {
1662
1076
  ethereum: "m/44'/60'/0'/0/0",
1663
1077
  bitcoin_mainnet: "m/84'/0'/0'/0/0",
@@ -1680,7 +1094,7 @@ function deriveBitcoinAddress(seed, network = "mainnet") {
1680
1094
  if (!child.publicKey) {
1681
1095
  throw new Error("Failed to derive public key");
1682
1096
  }
1683
- const pubKeyHash = ripemd160(sha256$1(child.publicKey));
1097
+ const pubKeyHash = ripemd160(sha256(child.publicKey));
1684
1098
  const witnessVersion = 0;
1685
1099
  const words = bech32.toWords(pubKeyHash);
1686
1100
  words.unshift(witnessVersion);
@@ -1721,7 +1135,7 @@ async function deriveTonAddress(seed) {
1721
1135
  const publicKey = keypair.publicKey;
1722
1136
  const workchain = 0;
1723
1137
  const flags = 17;
1724
- const hash = sha256$1(publicKey);
1138
+ const hash = sha256(publicKey);
1725
1139
  const addressData = new Uint8Array(34);
1726
1140
  addressData[0] = flags;
1727
1141
  addressData[1] = workchain;
@@ -1758,7 +1172,7 @@ function deriveTronAddress(seed) {
1758
1172
  for (let i = 0; i < 20; i++) {
1759
1173
  addressBytes[i + 1] = parseInt(ethAddressHex.slice(i * 2, i * 2 + 2), 16);
1760
1174
  }
1761
- const tronBase58check = base58check(sha256$1);
1175
+ const tronBase58check = base58check(sha256);
1762
1176
  return tronBase58check.encode(addressBytes);
1763
1177
  } catch (error) {
1764
1178
  console.error("TRON address derivation failed:", error);
@@ -1773,7 +1187,7 @@ function deriveSparkAddress(seed, network = "mainnet") {
1773
1187
  if (!child.publicKey) {
1774
1188
  throw new Error("Failed to derive public key");
1775
1189
  }
1776
- const pubKeyHash = ripemd160(sha256$1(child.publicKey));
1190
+ const pubKeyHash = ripemd160(sha256(child.publicKey));
1777
1191
  const witnessVersion = 0;
1778
1192
  const words = bech32.toWords(pubKeyHash);
1779
1193
  words.unshift(witnessVersion);
@@ -1874,9 +1288,9 @@ var CHAIN_ERROR_MESSAGES = {
1874
1288
  "no route": "NETWORK_ERROR"
1875
1289
  }
1876
1290
  };
1877
- function parseChainError(chain2, errorMessage) {
1291
+ function parseChainError(chain, errorMessage) {
1878
1292
  const errorLower = errorMessage.toLowerCase();
1879
- const chainErrors = CHAIN_ERROR_MESSAGES[chain2];
1293
+ const chainErrors = CHAIN_ERROR_MESSAGES[chain];
1880
1294
  for (const [pattern, code] of Object.entries(chainErrors)) {
1881
1295
  if (errorLower.includes(pattern)) {
1882
1296
  return code;
@@ -2014,38 +1428,38 @@ var ZubariWdkService = class {
2014
1428
  * For Ethereum, falls back to local derivation if API fails.
2015
1429
  * For other chains, WDK API is required - no placeholder fallback.
2016
1430
  */
2017
- async deriveAddress(seed, chain2) {
1431
+ async deriveAddress(seed, chain) {
2018
1432
  await this.initialize();
2019
- const path = this.getDerivationPath(chain2);
1433
+ const path = this.getDerivationPath(chain);
2020
1434
  try {
2021
- const response = await this.apiClient.deriveAddress(seed, chain2, this.config.network);
1435
+ const response = await this.apiClient.deriveAddress(seed, chain, this.config.network);
2022
1436
  if (response.success && response.address) {
2023
1437
  return {
2024
- chain: chain2,
1438
+ chain,
2025
1439
  address: response.address,
2026
1440
  path: response.path || path
2027
1441
  };
2028
1442
  }
2029
1443
  } catch (error) {
2030
- console.warn(`API address derivation failed for ${chain2}:`, error);
2031
- if (chain2 === "ethereum") {
2032
- return this.deriveBrowserAddress(seed, chain2);
1444
+ console.warn(`API address derivation failed for ${chain}:`, error);
1445
+ if (chain === "ethereum") {
1446
+ return this.deriveBrowserAddress(seed, chain);
2033
1447
  }
2034
1448
  }
2035
1449
  if (this.useNativeWdk && this.nativeWdkService) {
2036
1450
  try {
2037
1451
  const wdk = this.nativeWdkService;
2038
1452
  await wdk.initialize(seed);
2039
- return await wdk.deriveAddress(chain2);
1453
+ return await wdk.deriveAddress(chain);
2040
1454
  } catch (error) {
2041
- console.warn(`Native WDK address derivation failed for ${chain2}:`, error);
1455
+ console.warn(`Native WDK address derivation failed for ${chain}:`, error);
2042
1456
  }
2043
1457
  }
2044
- if (chain2 === "ethereum") {
2045
- return this.deriveBrowserAddress(seed, chain2);
1458
+ if (chain === "ethereum") {
1459
+ return this.deriveBrowserAddress(seed, chain);
2046
1460
  }
2047
1461
  throw new Error(
2048
- `WDK API required for ${chain2} address derivation. Ensure the backend is running.`
1462
+ `WDK API required for ${chain} address derivation. Ensure the backend is running.`
2049
1463
  );
2050
1464
  }
2051
1465
  /**
@@ -2125,13 +1539,13 @@ var ZubariWdkService = class {
2125
1539
  /**
2126
1540
  * Get fee rates for a chain
2127
1541
  */
2128
- async getFeeRates(seed, chain2) {
1542
+ async getFeeRates(seed, chain) {
2129
1543
  await this.initialize();
2130
1544
  try {
2131
1545
  const response = await fetch(`${this.config.apiUrl}/api/wallets/wdk/fee-rates`, {
2132
1546
  method: "POST",
2133
1547
  headers: { "Content-Type": "application/json" },
2134
- body: JSON.stringify({ seed, chain: chain2, network: this.config.network })
1548
+ body: JSON.stringify({ seed, chain, network: this.config.network })
2135
1549
  });
2136
1550
  if (response.ok) {
2137
1551
  const data = await response.json();
@@ -2140,20 +1554,20 @@ var ZubariWdkService = class {
2140
1554
  }
2141
1555
  }
2142
1556
  } catch (error) {
2143
- console.warn(`Failed to fetch fee rates for ${chain2}:`, error);
1557
+ console.warn(`Failed to fetch fee rates for ${chain}:`, error);
2144
1558
  }
2145
1559
  return { slow: "0", normal: "0", fast: "0" };
2146
1560
  }
2147
1561
  /**
2148
1562
  * Estimate transaction fee
2149
1563
  */
2150
- async estimateFee(seed, chain2, to, amount) {
1564
+ async estimateFee(seed, chain, to, amount) {
2151
1565
  await this.initialize();
2152
1566
  try {
2153
1567
  const response = await fetch(`${this.config.apiUrl}/api/wallets/wdk/estimate-fee`, {
2154
1568
  method: "POST",
2155
1569
  headers: { "Content-Type": "application/json" },
2156
- body: JSON.stringify({ seed, chain: chain2, to, amount, network: this.config.network })
1570
+ body: JSON.stringify({ seed, chain, to, amount, network: this.config.network })
2157
1571
  });
2158
1572
  if (response.ok) {
2159
1573
  const data = await response.json();
@@ -2162,9 +1576,9 @@ var ZubariWdkService = class {
2162
1576
  }
2163
1577
  }
2164
1578
  } catch (error) {
2165
- console.warn(`Failed to estimate fee for ${chain2}:`, error);
1579
+ console.warn(`Failed to estimate fee for ${chain}:`, error);
2166
1580
  }
2167
- return { fee: "0", symbol: this.getChainSymbol(chain2) };
1581
+ return { fee: "0", symbol: this.getChainSymbol(chain) };
2168
1582
  }
2169
1583
  /**
2170
1584
  * Send a transaction on any supported chain
@@ -2175,10 +1589,10 @@ var ZubariWdkService = class {
2175
1589
  * @param amount - Amount to send (in native units: ETH, BTC, SOL, etc.)
2176
1590
  * @returns Transaction result with hash on success, or error details on failure
2177
1591
  */
2178
- async sendTransaction(seed, chain2, to, amount) {
1592
+ async sendTransaction(seed, chain, to, amount) {
2179
1593
  await this.initialize();
2180
1594
  const startTime = Date.now();
2181
- console.log(`[ZubariWdkService] Sending ${chain2} transaction`, {
1595
+ console.log(`[ZubariWdkService] Sending ${chain} transaction`, {
2182
1596
  to: `${to.slice(0, 10)}...${to.slice(-6)}`,
2183
1597
  amount,
2184
1598
  network: this.config.network
@@ -2187,7 +1601,7 @@ var ZubariWdkService = class {
2187
1601
  const response = await fetch(`${this.config.apiUrl}/api/wallets/wdk/send`, {
2188
1602
  method: "POST",
2189
1603
  headers: { "Content-Type": "application/json" },
2190
- body: JSON.stringify({ seed, chain: chain2, to, amount, network: this.config.network })
1604
+ body: JSON.stringify({ seed, chain, to, amount, network: this.config.network })
2191
1605
  });
2192
1606
  const elapsed = Date.now() - startTime;
2193
1607
  if (response.ok) {
@@ -2197,22 +1611,22 @@ var ZubariWdkService = class {
2197
1611
  txHash = txHash.hash;
2198
1612
  }
2199
1613
  if (txHash) {
2200
- const isValid = this.validateTxHash(chain2, txHash);
1614
+ const isValid = this.validateTxHash(chain, txHash);
2201
1615
  if (!isValid) {
2202
- console.warn(`[ZubariWdkService] Invalid ${chain2} tx hash format:`, txHash);
1616
+ console.warn(`[ZubariWdkService] Invalid ${chain} tx hash format:`, txHash);
2203
1617
  }
2204
1618
  }
2205
- console.log(`[ZubariWdkService] ${chain2} transaction ${data.success ? "SUCCESS" : "FAILED"}`, {
1619
+ console.log(`[ZubariWdkService] ${chain} transaction ${data.success ? "SUCCESS" : "FAILED"}`, {
2206
1620
  txHash: txHash ? `${txHash.slice(0, 16)}...` : "N/A",
2207
1621
  elapsed: `${elapsed}ms`
2208
1622
  });
2209
1623
  if (!data.success) {
2210
- const errorCode2 = parseChainError(chain2, data.error || "");
1624
+ const errorCode2 = parseChainError(chain, data.error || "");
2211
1625
  return {
2212
1626
  success: false,
2213
1627
  error: data.error,
2214
1628
  errorCode: errorCode2,
2215
- chain: chain2
1629
+ chain
2216
1630
  };
2217
1631
  }
2218
1632
  return {
@@ -2221,14 +1635,14 @@ var ZubariWdkService = class {
2221
1635
  from: data.from,
2222
1636
  to: data.to,
2223
1637
  amount: data.amount,
2224
- chain: data.chain || chain2,
1638
+ chain: data.chain || chain,
2225
1639
  network: data.network || this.config.network
2226
1640
  };
2227
1641
  }
2228
1642
  const errorData = await response.json().catch(() => ({}));
2229
1643
  const errorMessage = errorData.error || `HTTP ${response.status}`;
2230
- const errorCode = parseChainError(chain2, errorMessage);
2231
- console.error(`[ZubariWdkService] ${chain2} transaction FAILED`, {
1644
+ const errorCode = parseChainError(chain, errorMessage);
1645
+ console.error(`[ZubariWdkService] ${chain} transaction FAILED`, {
2232
1646
  status: response.status,
2233
1647
  error: errorMessage,
2234
1648
  errorCode,
@@ -2238,13 +1652,13 @@ var ZubariWdkService = class {
2238
1652
  success: false,
2239
1653
  error: errorMessage,
2240
1654
  errorCode,
2241
- chain: chain2
1655
+ chain
2242
1656
  };
2243
1657
  } catch (error) {
2244
1658
  const elapsed = Date.now() - startTime;
2245
1659
  const errorMessage = error instanceof Error ? error.message : "Transaction failed";
2246
- const errorCode = parseChainError(chain2, errorMessage);
2247
- console.error(`[ZubariWdkService] ${chain2} transaction ERROR`, {
1660
+ const errorCode = parseChainError(chain, errorMessage);
1661
+ console.error(`[ZubariWdkService] ${chain} transaction ERROR`, {
2248
1662
  error: errorMessage,
2249
1663
  errorCode,
2250
1664
  elapsed: `${elapsed}ms`
@@ -2253,15 +1667,15 @@ var ZubariWdkService = class {
2253
1667
  success: false,
2254
1668
  error: errorMessage,
2255
1669
  errorCode,
2256
- chain: chain2
1670
+ chain
2257
1671
  };
2258
1672
  }
2259
1673
  }
2260
1674
  /**
2261
1675
  * Validate transaction hash format for a specific chain
2262
1676
  */
2263
- validateTxHash(chain2, txHash) {
2264
- switch (chain2) {
1677
+ validateTxHash(chain, txHash) {
1678
+ switch (chain) {
2265
1679
  case "ethereum":
2266
1680
  return /^0x[a-fA-F0-9]{64}$/.test(txHash);
2267
1681
  case "bitcoin":
@@ -2293,7 +1707,7 @@ var ZubariWdkService = class {
2293
1707
  // ==========================================
2294
1708
  // Private Helper Methods
2295
1709
  // ==========================================
2296
- getDerivationPath(chain2) {
1710
+ getDerivationPath(chain) {
2297
1711
  const paths = {
2298
1712
  bitcoin: this.config.network === "testnet" ? "m/84'/1'/0'/0/0" : "m/84'/0'/0'/0/0",
2299
1713
  ethereum: "m/44'/60'/0'/0/0",
@@ -2302,9 +1716,9 @@ var ZubariWdkService = class {
2302
1716
  solana: "m/44'/501'/0'/0'",
2303
1717
  spark: "m/44'/998'/0'/0/0"
2304
1718
  };
2305
- return paths[chain2];
1719
+ return paths[chain];
2306
1720
  }
2307
- getChainSymbol(chain2) {
1721
+ getChainSymbol(chain) {
2308
1722
  const symbols = {
2309
1723
  ethereum: "ETH",
2310
1724
  bitcoin: "BTC",
@@ -2313,16 +1727,16 @@ var ZubariWdkService = class {
2313
1727
  solana: "SOL",
2314
1728
  spark: "SAT"
2315
1729
  };
2316
- return symbols[chain2];
1730
+ return symbols[chain];
2317
1731
  }
2318
1732
  /**
2319
1733
  * Derive address using browser-compatible libraries
2320
1734
  */
2321
- async deriveBrowserAddress(seed, chain2) {
2322
- const path = this.getDerivationPath(chain2);
1735
+ async deriveBrowserAddress(seed, chain) {
1736
+ const path = this.getDerivationPath(chain);
2323
1737
  try {
2324
1738
  let address;
2325
- switch (chain2) {
1739
+ switch (chain) {
2326
1740
  case "ethereum":
2327
1741
  address = deriveEthereumAddress(seed);
2328
1742
  break;
@@ -2342,11 +1756,11 @@ var ZubariWdkService = class {
2342
1756
  address = await deriveTonAddress(seed);
2343
1757
  break;
2344
1758
  default:
2345
- throw new Error(`Unsupported chain: ${chain2}`);
1759
+ throw new Error(`Unsupported chain: ${chain}`);
2346
1760
  }
2347
- return { chain: chain2, address, path };
1761
+ return { chain, address, path };
2348
1762
  } catch (error) {
2349
- console.error(`Browser derivation failed for ${chain2}:`, error);
1763
+ console.error(`Browser derivation failed for ${chain}:`, error);
2350
1764
  throw error;
2351
1765
  }
2352
1766
  }
@@ -2359,7 +1773,7 @@ var ZubariWdkService = class {
2359
1773
  };
2360
1774
  var defaultService = null;
2361
1775
  function getZubariWdkService(config) {
2362
- if (!defaultService || config && config.network !== defaultService.getNetwork()) {
1776
+ if (!defaultService || config && (config.network !== defaultService.getNetwork() || config.apiUrl && config.apiUrl !== defaultService.getApiUrl())) {
2363
1777
  defaultService = new ZubariWdkService(config);
2364
1778
  }
2365
1779
  return defaultService;
@@ -2404,8 +1818,8 @@ async function fetchPrices() {
2404
1818
  if (response.ok) {
2405
1819
  const data = await response.json();
2406
1820
  const prices = {};
2407
- for (const [chain2, geckoId] of Object.entries(COINGECKO_IDS)) {
2408
- prices[chain2] = data[geckoId]?.usd || 0;
1821
+ for (const [chain, geckoId] of Object.entries(COINGECKO_IDS)) {
1822
+ prices[chain] = data[geckoId]?.usd || 0;
2409
1823
  }
2410
1824
  priceCache = { prices, timestamp: Date.now() };
2411
1825
  return prices;
@@ -2415,9 +1829,9 @@ async function fetchPrices() {
2415
1829
  }
2416
1830
  return priceCache?.prices || {};
2417
1831
  }
2418
- async function getPriceForChain(chain2) {
1832
+ async function getPriceForChain(chain) {
2419
1833
  const prices = await fetchPrices();
2420
- return prices[chain2] || 0;
1834
+ return prices[chain] || 0;
2421
1835
  }
2422
1836
  var dynamicImport2 = new Function("specifier", "return import(specifier)");
2423
1837
  async function loadWdkModules() {
@@ -2507,19 +1921,19 @@ var TransactionService = class {
2507
1921
  /**
2508
1922
  * Get RPC URL for a chain
2509
1923
  */
2510
- getRpcUrl(chain2) {
1924
+ getRpcUrl(chain) {
2511
1925
  const networkUrls = DEFAULT_RPC_URLS[this.config.network];
2512
- if (this.config.rpcUrls?.[chain2]) {
2513
- return this.config.rpcUrls[chain2];
1926
+ if (this.config.rpcUrls?.[chain]) {
1927
+ return this.config.rpcUrls[chain];
2514
1928
  }
2515
- return networkUrls[chain2] || "";
1929
+ return networkUrls[chain] || "";
2516
1930
  }
2517
1931
  /**
2518
1932
  * Get explorer URL for a transaction
2519
1933
  */
2520
- getExplorerUrl(chain2, txHash) {
1934
+ getExplorerUrl(chain, txHash) {
2521
1935
  const explorers = EXPLORER_URLS[this.config.network];
2522
- const baseUrl = explorers[chain2] || "";
1936
+ const baseUrl = explorers[chain] || "";
2523
1937
  return `${baseUrl}${txHash}`;
2524
1938
  }
2525
1939
  /**
@@ -2543,27 +1957,27 @@ var TransactionService = class {
2543
1957
  * Get or create wallet instance for a specific chain
2544
1958
  */
2545
1959
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2546
- async getWallet(chain2) {
1960
+ async getWallet(chain) {
2547
1961
  if (!this.seed) {
2548
1962
  throw new Error("TransactionService not initialized. Call initialize() first.");
2549
1963
  }
2550
- if (this.wallets[chain2]) {
2551
- return this.wallets[chain2];
1964
+ if (this.wallets[chain]) {
1965
+ return this.wallets[chain];
2552
1966
  }
2553
1967
  const isTestnet = this.config.network === "testnet";
2554
1968
  try {
2555
- switch (chain2) {
1969
+ switch (chain) {
2556
1970
  case "ethereum": {
2557
1971
  const rpcUrl = this.getRpcUrl("ethereum");
2558
1972
  const wallet = new WalletManagerEvm(this.seed, { provider: rpcUrl });
2559
- this.wallets[chain2] = wallet;
1973
+ this.wallets[chain] = wallet;
2560
1974
  return wallet;
2561
1975
  }
2562
1976
  case "bitcoin": {
2563
1977
  const wallet = new WalletManagerBtc(this.seed, {
2564
1978
  network: isTestnet ? "testnet" : "bitcoin"
2565
1979
  });
2566
- this.wallets[chain2] = wallet;
1980
+ this.wallets[chain] = wallet;
2567
1981
  return wallet;
2568
1982
  }
2569
1983
  case "solana": {
@@ -2571,7 +1985,7 @@ var TransactionService = class {
2571
1985
  const wallet = new WalletManagerSolana(this.seed, {
2572
1986
  rpcUrl
2573
1987
  });
2574
- this.wallets[chain2] = wallet;
1988
+ this.wallets[chain] = wallet;
2575
1989
  return wallet;
2576
1990
  }
2577
1991
  case "ton": {
@@ -2579,7 +1993,7 @@ var TransactionService = class {
2579
1993
  const wallet = new WalletManagerTon(this.seed, {
2580
1994
  tonClient: { url }
2581
1995
  });
2582
- this.wallets[chain2] = wallet;
1996
+ this.wallets[chain] = wallet;
2583
1997
  return wallet;
2584
1998
  }
2585
1999
  case "tron": {
@@ -2587,32 +2001,32 @@ var TransactionService = class {
2587
2001
  const wallet = new WalletManagerTron(this.seed, {
2588
2002
  provider: fullHost
2589
2003
  });
2590
- this.wallets[chain2] = wallet;
2004
+ this.wallets[chain] = wallet;
2591
2005
  return wallet;
2592
2006
  }
2593
2007
  case "spark": {
2594
2008
  const wallet = new WalletManagerSpark(this.seed, {
2595
2009
  network: isTestnet ? "TESTNET" : "MAINNET"
2596
2010
  });
2597
- this.wallets[chain2] = wallet;
2011
+ this.wallets[chain] = wallet;
2598
2012
  return wallet;
2599
2013
  }
2600
2014
  default:
2601
- throw new Error(`Unsupported chain: ${chain2}`);
2015
+ throw new Error(`Unsupported chain: ${chain}`);
2602
2016
  }
2603
2017
  } catch (error) {
2604
- console.error(`Failed to initialize ${chain2} wallet:`, error);
2018
+ console.error(`Failed to initialize ${chain} wallet:`, error);
2605
2019
  throw error;
2606
2020
  }
2607
2021
  }
2608
2022
  /**
2609
2023
  * Estimate transaction fee
2610
2024
  */
2611
- async estimateFee(chain2, params) {
2612
- const wallet = await this.getWallet(chain2);
2025
+ async estimateFee(chain, params) {
2026
+ const wallet = await this.getWallet(chain);
2613
2027
  try {
2614
2028
  const feeRates = await wallet.getFeeRates();
2615
- if (chain2 === "ethereum") {
2029
+ if (chain === "ethereum") {
2616
2030
  return {
2617
2031
  slow: {
2618
2032
  fee: `${feeRates.slow || "0"} Gwei`,
@@ -2627,7 +2041,7 @@ var TransactionService = class {
2627
2041
  estimatedTime: "~30 sec"
2628
2042
  }
2629
2043
  };
2630
- } else if (chain2 === "bitcoin") {
2044
+ } else if (chain === "bitcoin") {
2631
2045
  return {
2632
2046
  slow: {
2633
2047
  fee: `${feeRates.slow || feeRates.low || "0"} sat/vB`,
@@ -2659,7 +2073,7 @@ var TransactionService = class {
2659
2073
  };
2660
2074
  }
2661
2075
  } catch (error) {
2662
- console.error(`Error estimating fee for ${chain2}:`, error);
2076
+ console.error(`Error estimating fee for ${chain}:`, error);
2663
2077
  return {
2664
2078
  slow: { fee: "0", estimatedTime: "Unknown" },
2665
2079
  medium: { fee: "0", estimatedTime: "Unknown" },
@@ -2670,8 +2084,8 @@ var TransactionService = class {
2670
2084
  /**
2671
2085
  * Send a transaction
2672
2086
  */
2673
- async send(chain2, params) {
2674
- const wallet = await this.getWallet(chain2);
2087
+ async send(chain, params) {
2088
+ const wallet = await this.getWallet(chain);
2675
2089
  const account = await wallet.getAccount(0);
2676
2090
  const timestamp = Date.now();
2677
2091
  try {
@@ -2691,17 +2105,17 @@ var TransactionService = class {
2691
2105
  }
2692
2106
  return {
2693
2107
  hash: txHash,
2694
- network: chain2,
2108
+ network: chain,
2695
2109
  status: "pending",
2696
- explorerUrl: this.getExplorerUrl(chain2, txHash),
2110
+ explorerUrl: this.getExplorerUrl(chain, txHash),
2697
2111
  timestamp
2698
2112
  };
2699
2113
  } catch (error) {
2700
2114
  const errorMessage = error instanceof Error ? error.message : "Transaction failed";
2701
- console.error(`Transaction failed on ${chain2}:`, error);
2115
+ console.error(`Transaction failed on ${chain}:`, error);
2702
2116
  return {
2703
2117
  hash: "",
2704
- network: chain2,
2118
+ network: chain,
2705
2119
  status: "failed",
2706
2120
  error: errorMessage,
2707
2121
  timestamp
@@ -2711,27 +2125,27 @@ var TransactionService = class {
2711
2125
  /**
2712
2126
  * Get transaction status
2713
2127
  */
2714
- async getTransactionStatus(chain2, txHash) {
2715
- const wallet = await this.getWallet(chain2);
2128
+ async getTransactionStatus(chain, txHash) {
2129
+ const wallet = await this.getWallet(chain);
2716
2130
  try {
2717
2131
  const tx = await wallet.getTransaction(txHash);
2718
2132
  return {
2719
2133
  hash: txHash,
2720
- network: chain2,
2134
+ network: chain,
2721
2135
  status: tx.confirmed ? "confirmed" : "pending",
2722
2136
  blockNumber: tx.blockNumber,
2723
2137
  gasUsed: tx.gasUsed?.toString(),
2724
2138
  fee: tx.fee?.toString(),
2725
- explorerUrl: this.getExplorerUrl(chain2, txHash),
2139
+ explorerUrl: this.getExplorerUrl(chain, txHash),
2726
2140
  timestamp: tx.timestamp || Date.now()
2727
2141
  };
2728
2142
  } catch (error) {
2729
2143
  console.error(`Error getting transaction status for ${txHash}:`, error);
2730
2144
  return {
2731
2145
  hash: txHash,
2732
- network: chain2,
2146
+ network: chain,
2733
2147
  status: "pending",
2734
- explorerUrl: this.getExplorerUrl(chain2, txHash),
2148
+ explorerUrl: this.getExplorerUrl(chain, txHash),
2735
2149
  timestamp: Date.now()
2736
2150
  };
2737
2151
  }
@@ -2739,14 +2153,14 @@ var TransactionService = class {
2739
2153
  /**
2740
2154
  * Get transaction history for an address
2741
2155
  */
2742
- async getTransactionHistory(chain2, limit = 10) {
2743
- const wallet = await this.getWallet(chain2);
2156
+ async getTransactionHistory(chain, limit = 10) {
2157
+ const wallet = await this.getWallet(chain);
2744
2158
  const account = await wallet.getAccount(0);
2745
2159
  try {
2746
2160
  const history = await account.getTransactions({ limit });
2747
2161
  return history.map((tx) => ({
2748
2162
  hash: tx.hash || tx.txHash,
2749
- network: chain2,
2163
+ network: chain,
2750
2164
  type: tx.type || (tx.from === account.address ? "send" : "receive"),
2751
2165
  from: tx.from,
2752
2166
  to: tx.to,
@@ -2758,20 +2172,20 @@ var TransactionService = class {
2758
2172
  blockNumber: tx.blockNumber
2759
2173
  }));
2760
2174
  } catch (error) {
2761
- console.error(`Error getting transaction history for ${chain2}:`, error);
2175
+ console.error(`Error getting transaction history for ${chain}:`, error);
2762
2176
  return [];
2763
2177
  }
2764
2178
  }
2765
2179
  /**
2766
2180
  * Get balance for a specific chain
2767
2181
  */
2768
- async getBalance(chain2) {
2769
- const wallet = await this.getWallet(chain2);
2182
+ async getBalance(chain) {
2183
+ const wallet = await this.getWallet(chain);
2770
2184
  const account = await wallet.getAccount(0);
2771
2185
  try {
2772
2186
  const balance = await account.getBalance();
2773
2187
  const balanceStr = balance.toString();
2774
- const priceUsd = await getPriceForChain(chain2);
2188
+ const priceUsd = await getPriceForChain(chain);
2775
2189
  const balanceNum = parseFloat(balanceStr) || 0;
2776
2190
  const balanceUsd = balanceNum * priceUsd;
2777
2191
  return {
@@ -2779,7 +2193,7 @@ var TransactionService = class {
2779
2193
  balanceUsd
2780
2194
  };
2781
2195
  } catch (error) {
2782
- console.error(`Error getting balance for ${chain2}:`, error);
2196
+ console.error(`Error getting balance for ${chain}:`, error);
2783
2197
  return { balance: "0", balanceUsd: 0 };
2784
2198
  }
2785
2199
  }
@@ -2815,14 +2229,6 @@ function getTransactionService(config) {
2815
2229
  function createTransactionService(config) {
2816
2230
  return new TransactionService(config);
2817
2231
  }
2818
- /*! Bundled license information:
2819
-
2820
- @scure/base/index.js:
2821
- (*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
2822
-
2823
- @scure/bip32/index.js:
2824
- (*! scure-bip32 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) *)
2825
- */
2826
2232
 
2827
2233
  export { BrowserAddressDerivation_exports as BrowserAddressDerivation, SwapService, TransactionService, WdkApiClient, ZubariApiClient, ZubariWdkService, createTransactionService, createZubariApiClient, createZubariWdkService, getTransactionService, getWdkApiClient, getZubariApiClient, getZubariWdkService, isBrowser };
2828
2234
  //# sourceMappingURL=index.mjs.map