@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/react/index.d.mts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { b as NetworkType } from '../index-c90msmwW.mjs';
|
|
2
|
-
import { W as WalletManagerConfig, a as WalletState, C as ChainBalance, M as MultiChainAddresses, b as WalletManager } from '../WalletManager-
|
|
3
|
-
export { S as SUPPORTED_CHAINS } from '../WalletManager-
|
|
4
|
-
import '
|
|
2
|
+
import { W as WalletManagerConfig, a as WalletState, C as ChainBalance, M as MultiChainAddresses, b as WalletManager } from '../WalletManager-BTewpMGA.mjs';
|
|
3
|
+
export { S as SUPPORTED_CHAINS } from '../WalletManager-BTewpMGA.mjs';
|
|
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/react/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { b as NetworkType } from '../index-c90msmwW.js';
|
|
2
|
-
import { W as WalletManagerConfig, a as WalletState, C as ChainBalance, M as MultiChainAddresses, b as WalletManager } from '../WalletManager-
|
|
3
|
-
export { S as SUPPORTED_CHAINS } from '../WalletManager-
|
|
4
|
-
import '
|
|
2
|
+
import { W as WalletManagerConfig, a as WalletState, C as ChainBalance, M as MultiChainAddresses, b as WalletManager } from '../WalletManager-BV1QA08D.js';
|
|
3
|
+
export { S as SUPPORTED_CHAINS } from '../WalletManager-BV1QA08D.js';
|
|
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/react/index.js
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
var react = require('react');
|
|
4
4
|
var ethers = require('ethers');
|
|
5
|
+
var bip39 = require('@scure/bip39');
|
|
6
|
+
var english = require('@scure/bip39/wordlists/english');
|
|
7
|
+
var bip32 = require('@scure/bip32');
|
|
8
|
+
var base = require('@scure/base');
|
|
9
|
+
var sha256 = require('@noble/hashes/sha256');
|
|
10
|
+
var ripemd160 = require('@noble/hashes/ripemd160');
|
|
5
11
|
var viem = require('viem');
|
|
6
12
|
var chains = require('viem/chains');
|
|
7
13
|
|
|
@@ -341,50 +347,25 @@ var DERIVATION_PATHS2 = {
|
|
|
341
347
|
solana: `${DERIVATION_PATHS.solana}/0'`,
|
|
342
348
|
spark: `${DERIVATION_PATHS.spark}/0`
|
|
343
349
|
};
|
|
344
|
-
var _crypto = null;
|
|
345
|
-
async function loadCrypto() {
|
|
346
|
-
if (_crypto) return _crypto;
|
|
347
|
-
const [bip39, bip39Words, bip32, scureBase, sha256Mod, ripemd160Mod] = await Promise.all([
|
|
348
|
-
import('@scure/bip39'),
|
|
349
|
-
import('@scure/bip39/wordlists/english'),
|
|
350
|
-
import('@scure/bip32'),
|
|
351
|
-
import('@scure/base'),
|
|
352
|
-
import('@noble/hashes/sha256'),
|
|
353
|
-
import('@noble/hashes/ripemd160')
|
|
354
|
-
]);
|
|
355
|
-
_crypto = {
|
|
356
|
-
mnemonicToSeedSync: bip39.mnemonicToSeedSync,
|
|
357
|
-
validateMnemonic: bip39.validateMnemonic,
|
|
358
|
-
generateMnemonic: bip39.generateMnemonic,
|
|
359
|
-
wordlist: bip39Words.wordlist,
|
|
360
|
-
HDKey: bip32.HDKey,
|
|
361
|
-
bech32: scureBase.bech32,
|
|
362
|
-
base58check: scureBase.base58check,
|
|
363
|
-
sha256: sha256Mod.sha256,
|
|
364
|
-
ripemd160: ripemd160Mod.ripemd160
|
|
365
|
-
};
|
|
366
|
-
return _crypto;
|
|
367
|
-
}
|
|
368
350
|
function deriveEthereumAddress(seed) {
|
|
369
351
|
const hdNode = ethers.HDNodeWallet.fromPhrase(seed, void 0, DERIVATION_PATHS2.ethereum);
|
|
370
352
|
return hdNode.address;
|
|
371
353
|
}
|
|
372
|
-
|
|
354
|
+
function deriveBitcoinAddress(seed, network = "mainnet") {
|
|
373
355
|
try {
|
|
374
|
-
const
|
|
375
|
-
const
|
|
376
|
-
const hdKey = HDKey.fromMasterSeed(seedBytes);
|
|
356
|
+
const seedBytes = bip39.mnemonicToSeedSync(seed);
|
|
357
|
+
const hdKey = bip32.HDKey.fromMasterSeed(seedBytes);
|
|
377
358
|
const path = network === "testnet" ? DERIVATION_PATHS2.bitcoin_testnet : DERIVATION_PATHS2.bitcoin_mainnet;
|
|
378
359
|
const child = hdKey.derive(path);
|
|
379
360
|
if (!child.publicKey) {
|
|
380
361
|
throw new Error("Failed to derive public key");
|
|
381
362
|
}
|
|
382
|
-
const pubKeyHash = ripemd160(sha256(child.publicKey));
|
|
363
|
+
const pubKeyHash = ripemd160.ripemd160(sha256.sha256(child.publicKey));
|
|
383
364
|
const witnessVersion = 0;
|
|
384
|
-
const words = bech32.toWords(pubKeyHash);
|
|
365
|
+
const words = base.bech32.toWords(pubKeyHash);
|
|
385
366
|
words.unshift(witnessVersion);
|
|
386
367
|
const hrp = network === "testnet" ? "tb" : "bc";
|
|
387
|
-
const address = bech32.encode(hrp, words);
|
|
368
|
+
const address = base.bech32.encode(hrp, words);
|
|
388
369
|
return address;
|
|
389
370
|
} catch (error) {
|
|
390
371
|
console.error("Bitcoin address derivation failed:", error);
|
|
@@ -393,14 +374,13 @@ async function deriveBitcoinAddress(seed, network = "mainnet") {
|
|
|
393
374
|
}
|
|
394
375
|
async function deriveSolanaAddress(seed) {
|
|
395
376
|
try {
|
|
396
|
-
const [
|
|
397
|
-
loadCrypto(),
|
|
377
|
+
const [ed25519, nacl, bs58Module] = await Promise.all([
|
|
398
378
|
import('ed25519-hd-key'),
|
|
399
379
|
import('tweetnacl'),
|
|
400
380
|
import('bs58')
|
|
401
381
|
]);
|
|
402
382
|
const bs58 = bs58Module.default || bs58Module;
|
|
403
|
-
const seedBytes =
|
|
383
|
+
const seedBytes = bip39.mnemonicToSeedSync(seed);
|
|
404
384
|
const derived = ed25519.derivePath(DERIVATION_PATHS2.solana, Buffer.from(seedBytes).toString("hex"));
|
|
405
385
|
const keypair = nacl.sign.keyPair.fromSeed(new Uint8Array(derived.key));
|
|
406
386
|
return bs58.encode(keypair.publicKey);
|
|
@@ -411,18 +391,17 @@ async function deriveSolanaAddress(seed) {
|
|
|
411
391
|
}
|
|
412
392
|
async function deriveTonAddress(seed) {
|
|
413
393
|
try {
|
|
414
|
-
const [
|
|
415
|
-
loadCrypto(),
|
|
394
|
+
const [ed25519, nacl] = await Promise.all([
|
|
416
395
|
import('ed25519-hd-key'),
|
|
417
396
|
import('tweetnacl')
|
|
418
397
|
]);
|
|
419
|
-
const seedBytes =
|
|
398
|
+
const seedBytes = bip39.mnemonicToSeedSync(seed);
|
|
420
399
|
const derived = ed25519.derivePath(DERIVATION_PATHS2.ton, Buffer.from(seedBytes).toString("hex"));
|
|
421
400
|
const keypair = nacl.sign.keyPair.fromSeed(new Uint8Array(derived.key));
|
|
422
401
|
const publicKey = keypair.publicKey;
|
|
423
402
|
const workchain = 0;
|
|
424
403
|
const flags = 17;
|
|
425
|
-
const hash =
|
|
404
|
+
const hash = sha256.sha256(publicKey);
|
|
426
405
|
const addressData = new Uint8Array(34);
|
|
427
406
|
addressData[0] = flags;
|
|
428
407
|
addressData[1] = workchain;
|
|
@@ -450,9 +429,8 @@ function crc16(data) {
|
|
|
450
429
|
}
|
|
451
430
|
return crc;
|
|
452
431
|
}
|
|
453
|
-
|
|
432
|
+
function deriveTronAddress(seed) {
|
|
454
433
|
try {
|
|
455
|
-
const { sha256, base58check } = await loadCrypto();
|
|
456
434
|
const hdNode = ethers.HDNodeWallet.fromPhrase(seed, void 0, DERIVATION_PATHS2.tron);
|
|
457
435
|
const ethAddressHex = hdNode.address.slice(2).toLowerCase();
|
|
458
436
|
const addressBytes = new Uint8Array(21);
|
|
@@ -460,28 +438,27 @@ async function deriveTronAddress(seed) {
|
|
|
460
438
|
for (let i = 0; i < 20; i++) {
|
|
461
439
|
addressBytes[i + 1] = parseInt(ethAddressHex.slice(i * 2, i * 2 + 2), 16);
|
|
462
440
|
}
|
|
463
|
-
const tronBase58check = base58check(sha256);
|
|
441
|
+
const tronBase58check = base.base58check(sha256.sha256);
|
|
464
442
|
return tronBase58check.encode(addressBytes);
|
|
465
443
|
} catch (error) {
|
|
466
444
|
console.error("TRON address derivation failed:", error);
|
|
467
445
|
throw error;
|
|
468
446
|
}
|
|
469
447
|
}
|
|
470
|
-
|
|
448
|
+
function deriveSparkAddress(seed, network = "mainnet") {
|
|
471
449
|
try {
|
|
472
|
-
const
|
|
473
|
-
const
|
|
474
|
-
const hdKey = HDKey.fromMasterSeed(seedBytes);
|
|
450
|
+
const seedBytes = bip39.mnemonicToSeedSync(seed);
|
|
451
|
+
const hdKey = bip32.HDKey.fromMasterSeed(seedBytes);
|
|
475
452
|
const child = hdKey.derive(DERIVATION_PATHS2.spark);
|
|
476
453
|
if (!child.publicKey) {
|
|
477
454
|
throw new Error("Failed to derive public key");
|
|
478
455
|
}
|
|
479
|
-
const pubKeyHash = ripemd160(sha256(child.publicKey));
|
|
456
|
+
const pubKeyHash = ripemd160.ripemd160(sha256.sha256(child.publicKey));
|
|
480
457
|
const witnessVersion = 0;
|
|
481
|
-
const words = bech32.toWords(pubKeyHash);
|
|
458
|
+
const words = base.bech32.toWords(pubKeyHash);
|
|
482
459
|
words.unshift(witnessVersion);
|
|
483
460
|
const hrp = network === "testnet" ? "tsp" : "sp";
|
|
484
|
-
const address = bech32.encode(hrp, words);
|
|
461
|
+
const address = base.bech32.encode(hrp, words);
|
|
485
462
|
return address;
|
|
486
463
|
} catch (error) {
|
|
487
464
|
console.error("Spark address derivation failed:", error);
|
|
@@ -497,38 +474,47 @@ async function deriveAllAddresses(seed, network = "mainnet") {
|
|
|
497
474
|
solana: null,
|
|
498
475
|
spark: null
|
|
499
476
|
};
|
|
500
|
-
await loadCrypto();
|
|
501
477
|
try {
|
|
502
478
|
addresses.ethereum = deriveEthereumAddress(seed);
|
|
503
479
|
} catch (e) {
|
|
504
480
|
console.error("ETH derivation failed:", e);
|
|
505
481
|
}
|
|
506
|
-
|
|
507
|
-
deriveBitcoinAddress(seed, network)
|
|
508
|
-
|
|
509
|
-
|
|
482
|
+
try {
|
|
483
|
+
addresses.bitcoin = deriveBitcoinAddress(seed, network);
|
|
484
|
+
} catch (e) {
|
|
485
|
+
console.error("BTC derivation failed:", e);
|
|
486
|
+
}
|
|
487
|
+
try {
|
|
488
|
+
addresses.spark = deriveSparkAddress(seed, network);
|
|
489
|
+
} catch (e) {
|
|
490
|
+
console.error("Spark derivation failed:", e);
|
|
491
|
+
}
|
|
492
|
+
try {
|
|
493
|
+
addresses.tron = deriveTronAddress(seed);
|
|
494
|
+
} catch (e) {
|
|
495
|
+
console.error("TRON derivation failed:", e);
|
|
496
|
+
}
|
|
497
|
+
const [solResult, tonResult] = await Promise.allSettled([
|
|
510
498
|
deriveSolanaAddress(seed),
|
|
511
499
|
deriveTonAddress(seed)
|
|
512
500
|
]);
|
|
513
|
-
if (
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
else
|
|
521
|
-
|
|
522
|
-
|
|
501
|
+
if (solResult.status === "fulfilled") {
|
|
502
|
+
addresses.solana = solResult.value;
|
|
503
|
+
} else {
|
|
504
|
+
console.error("SOL derivation failed:", solResult.reason);
|
|
505
|
+
}
|
|
506
|
+
if (tonResult.status === "fulfilled") {
|
|
507
|
+
addresses.ton = tonResult.value;
|
|
508
|
+
} else {
|
|
509
|
+
console.error("TON derivation failed:", tonResult.reason);
|
|
510
|
+
}
|
|
523
511
|
return addresses;
|
|
524
512
|
}
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
return validateMnemonic(seed, wordlist);
|
|
513
|
+
function isValidSeed(seed) {
|
|
514
|
+
return bip39.validateMnemonic(seed, english.wordlist);
|
|
528
515
|
}
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
return generateMnemonic(wordlist);
|
|
516
|
+
function generateSeedPhrase() {
|
|
517
|
+
return bip39.generateMnemonic(english.wordlist);
|
|
532
518
|
}
|
|
533
519
|
|
|
534
520
|
// src/services/ZubariWdkService.ts
|
|
@@ -771,7 +757,7 @@ var ZubariWdkService = class {
|
|
|
771
757
|
};
|
|
772
758
|
if (!addresses.spark) {
|
|
773
759
|
try {
|
|
774
|
-
addresses.spark =
|
|
760
|
+
addresses.spark = deriveSparkAddress(seed, this.config.network);
|
|
775
761
|
} catch (e) {
|
|
776
762
|
console.warn("Browser Spark derivation fallback failed:", e);
|
|
777
763
|
}
|
|
@@ -1007,13 +993,13 @@ var ZubariWdkService = class {
|
|
|
1007
993
|
address = deriveEthereumAddress(seed);
|
|
1008
994
|
break;
|
|
1009
995
|
case "bitcoin":
|
|
1010
|
-
address =
|
|
996
|
+
address = deriveBitcoinAddress(seed, this.config.network);
|
|
1011
997
|
break;
|
|
1012
998
|
case "tron":
|
|
1013
|
-
address =
|
|
999
|
+
address = deriveTronAddress(seed);
|
|
1014
1000
|
break;
|
|
1015
1001
|
case "spark":
|
|
1016
|
-
address =
|
|
1002
|
+
address = deriveSparkAddress(seed, this.config.network);
|
|
1017
1003
|
break;
|
|
1018
1004
|
case "solana":
|
|
1019
1005
|
address = await deriveSolanaAddress(seed);
|