@zubari/sdk 0.5.6 → 0.5.7
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/{TransactionService-DbNDRzXh.d.ts → TransactionService-BEkgF1T6.d.ts} +5 -9
- package/dist/{TransactionService-Cmw33HXX.d.mts → TransactionService-CF_C3Kqm.d.mts} +5 -9
- package/dist/{WalletManager-DIx8nENh.d.mts → WalletManager-BTewpMGA.d.mts} +131 -48
- package/dist/{WalletManager-CeLlZo2y.d.ts → WalletManager-BV1QA08D.d.ts} +131 -48
- package/dist/{contracts-JfZDzaV7.d.ts → contracts-CyIOTDtT.d.ts} +1 -1
- package/dist/{contracts-pugJnFzl.d.mts → contracts-i0GG-cBt.d.mts} +1 -1
- package/dist/index.d.mts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +59 -73
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +46 -60
- package/dist/index.mjs.map +1 -1
- package/dist/react/index.d.mts +4 -3
- package/dist/react/index.d.ts +4 -3
- package/dist/react/index.js +59 -73
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +46 -60
- package/dist/react/index.mjs.map +1 -1
- package/dist/services/index.d.mts +1 -1
- package/dist/services/index.d.ts +1 -1
- package/dist/services/index.js +59 -73
- package/dist/services/index.js.map +1 -1
- package/dist/services/index.mjs +46 -60
- package/dist/services/index.mjs.map +1 -1
- package/dist/wallet/index.d.mts +4 -3
- package/dist/wallet/index.d.ts +4 -3
- package/dist/wallet/index.js +59 -73
- package/dist/wallet/index.js.map +1 -1
- package/dist/wallet/index.mjs +46 -60
- package/dist/wallet/index.mjs.map +1 -1
- package/package.json +5 -4
package/dist/wallet/index.d.mts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export { Z as ZubariWallet } from '../contracts-
|
|
2
|
-
export { C as ChainBalance, M as MultiChainAddresses, S as SUPPORTED_CHAINS, b as WalletManager, W as WalletManagerConfig, a as WalletState } from '../WalletManager-
|
|
1
|
+
export { Z as ZubariWallet } from '../contracts-i0GG-cBt.mjs';
|
|
2
|
+
export { C as ChainBalance, M as MultiChainAddresses, S as SUPPORTED_CHAINS, b as WalletManager, W as WalletManagerConfig, a as WalletState } from '../WalletManager-BTewpMGA.mjs';
|
|
3
3
|
import '../index-c90msmwW.mjs';
|
|
4
|
-
import '
|
|
4
|
+
import 'node_modules/viem/_types/actions/siwe/verifySiweMessage';
|
|
5
|
+
import 'node_modules/viem/_types/utils/ccip';
|
|
5
6
|
import 'viem';
|
|
6
7
|
import 'ethers';
|
|
7
8
|
import '../SecureStorage-jO783AhC.mjs';
|
package/dist/wallet/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export { Z as ZubariWallet } from '../contracts-
|
|
2
|
-
export { C as ChainBalance, M as MultiChainAddresses, S as SUPPORTED_CHAINS, b as WalletManager, W as WalletManagerConfig, a as WalletState } from '../WalletManager-
|
|
1
|
+
export { Z as ZubariWallet } from '../contracts-CyIOTDtT.js';
|
|
2
|
+
export { C as ChainBalance, M as MultiChainAddresses, S as SUPPORTED_CHAINS, b as WalletManager, W as WalletManagerConfig, a as WalletState } from '../WalletManager-BV1QA08D.js';
|
|
3
3
|
import '../index-c90msmwW.js';
|
|
4
|
-
import '
|
|
4
|
+
import 'node_modules/viem/_types/actions/siwe/verifySiweMessage';
|
|
5
|
+
import 'node_modules/viem/_types/utils/ccip';
|
|
5
6
|
import 'viem';
|
|
6
7
|
import 'ethers';
|
|
7
8
|
import '../SecureStorage-jO783AhC.js';
|
package/dist/wallet/index.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var ethers = require('ethers');
|
|
4
|
+
var bip39 = require('@scure/bip39');
|
|
5
|
+
var english = require('@scure/bip39/wordlists/english');
|
|
6
|
+
var bip32 = require('@scure/bip32');
|
|
7
|
+
var base = require('@scure/base');
|
|
8
|
+
var sha256 = require('@noble/hashes/sha256');
|
|
9
|
+
var ripemd160 = require('@noble/hashes/ripemd160');
|
|
4
10
|
var viem = require('viem');
|
|
5
11
|
var chains = require('viem/chains');
|
|
6
12
|
|
|
@@ -396,50 +402,25 @@ var DERIVATION_PATHS2 = {
|
|
|
396
402
|
solana: `${DERIVATION_PATHS.solana}/0'`,
|
|
397
403
|
spark: `${DERIVATION_PATHS.spark}/0`
|
|
398
404
|
};
|
|
399
|
-
var _crypto = null;
|
|
400
|
-
async function loadCrypto() {
|
|
401
|
-
if (_crypto) return _crypto;
|
|
402
|
-
const [bip39, bip39Words, bip32, scureBase, sha256Mod, ripemd160Mod] = await Promise.all([
|
|
403
|
-
import('@scure/bip39'),
|
|
404
|
-
import('@scure/bip39/wordlists/english'),
|
|
405
|
-
import('@scure/bip32'),
|
|
406
|
-
import('@scure/base'),
|
|
407
|
-
import('@noble/hashes/sha256'),
|
|
408
|
-
import('@noble/hashes/ripemd160')
|
|
409
|
-
]);
|
|
410
|
-
_crypto = {
|
|
411
|
-
mnemonicToSeedSync: bip39.mnemonicToSeedSync,
|
|
412
|
-
validateMnemonic: bip39.validateMnemonic,
|
|
413
|
-
generateMnemonic: bip39.generateMnemonic,
|
|
414
|
-
wordlist: bip39Words.wordlist,
|
|
415
|
-
HDKey: bip32.HDKey,
|
|
416
|
-
bech32: scureBase.bech32,
|
|
417
|
-
base58check: scureBase.base58check,
|
|
418
|
-
sha256: sha256Mod.sha256,
|
|
419
|
-
ripemd160: ripemd160Mod.ripemd160
|
|
420
|
-
};
|
|
421
|
-
return _crypto;
|
|
422
|
-
}
|
|
423
405
|
function deriveEthereumAddress(seed) {
|
|
424
406
|
const hdNode = ethers.HDNodeWallet.fromPhrase(seed, void 0, DERIVATION_PATHS2.ethereum);
|
|
425
407
|
return hdNode.address;
|
|
426
408
|
}
|
|
427
|
-
|
|
409
|
+
function deriveBitcoinAddress(seed, network = "mainnet") {
|
|
428
410
|
try {
|
|
429
|
-
const
|
|
430
|
-
const
|
|
431
|
-
const hdKey = HDKey.fromMasterSeed(seedBytes);
|
|
411
|
+
const seedBytes = bip39.mnemonicToSeedSync(seed);
|
|
412
|
+
const hdKey = bip32.HDKey.fromMasterSeed(seedBytes);
|
|
432
413
|
const path = network === "testnet" ? DERIVATION_PATHS2.bitcoin_testnet : DERIVATION_PATHS2.bitcoin_mainnet;
|
|
433
414
|
const child = hdKey.derive(path);
|
|
434
415
|
if (!child.publicKey) {
|
|
435
416
|
throw new Error("Failed to derive public key");
|
|
436
417
|
}
|
|
437
|
-
const pubKeyHash = ripemd160(sha256(child.publicKey));
|
|
418
|
+
const pubKeyHash = ripemd160.ripemd160(sha256.sha256(child.publicKey));
|
|
438
419
|
const witnessVersion = 0;
|
|
439
|
-
const words = bech32.toWords(pubKeyHash);
|
|
420
|
+
const words = base.bech32.toWords(pubKeyHash);
|
|
440
421
|
words.unshift(witnessVersion);
|
|
441
422
|
const hrp = network === "testnet" ? "tb" : "bc";
|
|
442
|
-
const address = bech32.encode(hrp, words);
|
|
423
|
+
const address = base.bech32.encode(hrp, words);
|
|
443
424
|
return address;
|
|
444
425
|
} catch (error) {
|
|
445
426
|
console.error("Bitcoin address derivation failed:", error);
|
|
@@ -448,14 +429,13 @@ async function deriveBitcoinAddress(seed, network = "mainnet") {
|
|
|
448
429
|
}
|
|
449
430
|
async function deriveSolanaAddress(seed) {
|
|
450
431
|
try {
|
|
451
|
-
const [
|
|
452
|
-
loadCrypto(),
|
|
432
|
+
const [ed25519, nacl, bs58Module] = await Promise.all([
|
|
453
433
|
import('ed25519-hd-key'),
|
|
454
434
|
import('tweetnacl'),
|
|
455
435
|
import('bs58')
|
|
456
436
|
]);
|
|
457
437
|
const bs58 = bs58Module.default || bs58Module;
|
|
458
|
-
const seedBytes =
|
|
438
|
+
const seedBytes = bip39.mnemonicToSeedSync(seed);
|
|
459
439
|
const derived = ed25519.derivePath(DERIVATION_PATHS2.solana, Buffer.from(seedBytes).toString("hex"));
|
|
460
440
|
const keypair = nacl.sign.keyPair.fromSeed(new Uint8Array(derived.key));
|
|
461
441
|
return bs58.encode(keypair.publicKey);
|
|
@@ -466,18 +446,17 @@ async function deriveSolanaAddress(seed) {
|
|
|
466
446
|
}
|
|
467
447
|
async function deriveTonAddress(seed) {
|
|
468
448
|
try {
|
|
469
|
-
const [
|
|
470
|
-
loadCrypto(),
|
|
449
|
+
const [ed25519, nacl] = await Promise.all([
|
|
471
450
|
import('ed25519-hd-key'),
|
|
472
451
|
import('tweetnacl')
|
|
473
452
|
]);
|
|
474
|
-
const seedBytes =
|
|
453
|
+
const seedBytes = bip39.mnemonicToSeedSync(seed);
|
|
475
454
|
const derived = ed25519.derivePath(DERIVATION_PATHS2.ton, Buffer.from(seedBytes).toString("hex"));
|
|
476
455
|
const keypair = nacl.sign.keyPair.fromSeed(new Uint8Array(derived.key));
|
|
477
456
|
const publicKey = keypair.publicKey;
|
|
478
457
|
const workchain = 0;
|
|
479
458
|
const flags = 17;
|
|
480
|
-
const hash =
|
|
459
|
+
const hash = sha256.sha256(publicKey);
|
|
481
460
|
const addressData = new Uint8Array(34);
|
|
482
461
|
addressData[0] = flags;
|
|
483
462
|
addressData[1] = workchain;
|
|
@@ -505,9 +484,8 @@ function crc16(data) {
|
|
|
505
484
|
}
|
|
506
485
|
return crc;
|
|
507
486
|
}
|
|
508
|
-
|
|
487
|
+
function deriveTronAddress(seed) {
|
|
509
488
|
try {
|
|
510
|
-
const { sha256, base58check } = await loadCrypto();
|
|
511
489
|
const hdNode = ethers.HDNodeWallet.fromPhrase(seed, void 0, DERIVATION_PATHS2.tron);
|
|
512
490
|
const ethAddressHex = hdNode.address.slice(2).toLowerCase();
|
|
513
491
|
const addressBytes = new Uint8Array(21);
|
|
@@ -515,28 +493,27 @@ async function deriveTronAddress(seed) {
|
|
|
515
493
|
for (let i = 0; i < 20; i++) {
|
|
516
494
|
addressBytes[i + 1] = parseInt(ethAddressHex.slice(i * 2, i * 2 + 2), 16);
|
|
517
495
|
}
|
|
518
|
-
const tronBase58check = base58check(sha256);
|
|
496
|
+
const tronBase58check = base.base58check(sha256.sha256);
|
|
519
497
|
return tronBase58check.encode(addressBytes);
|
|
520
498
|
} catch (error) {
|
|
521
499
|
console.error("TRON address derivation failed:", error);
|
|
522
500
|
throw error;
|
|
523
501
|
}
|
|
524
502
|
}
|
|
525
|
-
|
|
503
|
+
function deriveSparkAddress(seed, network = "mainnet") {
|
|
526
504
|
try {
|
|
527
|
-
const
|
|
528
|
-
const
|
|
529
|
-
const hdKey = HDKey.fromMasterSeed(seedBytes);
|
|
505
|
+
const seedBytes = bip39.mnemonicToSeedSync(seed);
|
|
506
|
+
const hdKey = bip32.HDKey.fromMasterSeed(seedBytes);
|
|
530
507
|
const child = hdKey.derive(DERIVATION_PATHS2.spark);
|
|
531
508
|
if (!child.publicKey) {
|
|
532
509
|
throw new Error("Failed to derive public key");
|
|
533
510
|
}
|
|
534
|
-
const pubKeyHash = ripemd160(sha256(child.publicKey));
|
|
511
|
+
const pubKeyHash = ripemd160.ripemd160(sha256.sha256(child.publicKey));
|
|
535
512
|
const witnessVersion = 0;
|
|
536
|
-
const words = bech32.toWords(pubKeyHash);
|
|
513
|
+
const words = base.bech32.toWords(pubKeyHash);
|
|
537
514
|
words.unshift(witnessVersion);
|
|
538
515
|
const hrp = network === "testnet" ? "tsp" : "sp";
|
|
539
|
-
const address = bech32.encode(hrp, words);
|
|
516
|
+
const address = base.bech32.encode(hrp, words);
|
|
540
517
|
return address;
|
|
541
518
|
} catch (error) {
|
|
542
519
|
console.error("Spark address derivation failed:", error);
|
|
@@ -552,38 +529,47 @@ async function deriveAllAddresses(seed, network = "mainnet") {
|
|
|
552
529
|
solana: null,
|
|
553
530
|
spark: null
|
|
554
531
|
};
|
|
555
|
-
await loadCrypto();
|
|
556
532
|
try {
|
|
557
533
|
addresses.ethereum = deriveEthereumAddress(seed);
|
|
558
534
|
} catch (e) {
|
|
559
535
|
console.error("ETH derivation failed:", e);
|
|
560
536
|
}
|
|
561
|
-
|
|
562
|
-
deriveBitcoinAddress(seed, network)
|
|
563
|
-
|
|
564
|
-
|
|
537
|
+
try {
|
|
538
|
+
addresses.bitcoin = deriveBitcoinAddress(seed, network);
|
|
539
|
+
} catch (e) {
|
|
540
|
+
console.error("BTC derivation failed:", e);
|
|
541
|
+
}
|
|
542
|
+
try {
|
|
543
|
+
addresses.spark = deriveSparkAddress(seed, network);
|
|
544
|
+
} catch (e) {
|
|
545
|
+
console.error("Spark derivation failed:", e);
|
|
546
|
+
}
|
|
547
|
+
try {
|
|
548
|
+
addresses.tron = deriveTronAddress(seed);
|
|
549
|
+
} catch (e) {
|
|
550
|
+
console.error("TRON derivation failed:", e);
|
|
551
|
+
}
|
|
552
|
+
const [solResult, tonResult] = await Promise.allSettled([
|
|
565
553
|
deriveSolanaAddress(seed),
|
|
566
554
|
deriveTonAddress(seed)
|
|
567
555
|
]);
|
|
568
|
-
if (
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
else
|
|
576
|
-
|
|
577
|
-
|
|
556
|
+
if (solResult.status === "fulfilled") {
|
|
557
|
+
addresses.solana = solResult.value;
|
|
558
|
+
} else {
|
|
559
|
+
console.error("SOL derivation failed:", solResult.reason);
|
|
560
|
+
}
|
|
561
|
+
if (tonResult.status === "fulfilled") {
|
|
562
|
+
addresses.ton = tonResult.value;
|
|
563
|
+
} else {
|
|
564
|
+
console.error("TON derivation failed:", tonResult.reason);
|
|
565
|
+
}
|
|
578
566
|
return addresses;
|
|
579
567
|
}
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
return validateMnemonic(seed, wordlist);
|
|
568
|
+
function isValidSeed(seed) {
|
|
569
|
+
return bip39.validateMnemonic(seed, english.wordlist);
|
|
583
570
|
}
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
return generateMnemonic(wordlist);
|
|
571
|
+
function generateSeedPhrase() {
|
|
572
|
+
return bip39.generateMnemonic(english.wordlist);
|
|
587
573
|
}
|
|
588
574
|
|
|
589
575
|
// src/services/ZubariWdkService.ts
|
|
@@ -826,7 +812,7 @@ var ZubariWdkService = class {
|
|
|
826
812
|
};
|
|
827
813
|
if (!addresses.spark) {
|
|
828
814
|
try {
|
|
829
|
-
addresses.spark =
|
|
815
|
+
addresses.spark = deriveSparkAddress(seed, this.config.network);
|
|
830
816
|
} catch (e) {
|
|
831
817
|
console.warn("Browser Spark derivation fallback failed:", e);
|
|
832
818
|
}
|
|
@@ -1062,13 +1048,13 @@ var ZubariWdkService = class {
|
|
|
1062
1048
|
address = deriveEthereumAddress(seed);
|
|
1063
1049
|
break;
|
|
1064
1050
|
case "bitcoin":
|
|
1065
|
-
address =
|
|
1051
|
+
address = deriveBitcoinAddress(seed, this.config.network);
|
|
1066
1052
|
break;
|
|
1067
1053
|
case "tron":
|
|
1068
|
-
address =
|
|
1054
|
+
address = deriveTronAddress(seed);
|
|
1069
1055
|
break;
|
|
1070
1056
|
case "spark":
|
|
1071
|
-
address =
|
|
1057
|
+
address = deriveSparkAddress(seed, this.config.network);
|
|
1072
1058
|
break;
|
|
1073
1059
|
case "solana":
|
|
1074
1060
|
address = await deriveSolanaAddress(seed);
|