@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.
@@ -1,5 +1,5 @@
1
1
  import { Z as ZubariWalletConfig, b as NetworkType, A as Account, c as NetworkBalance, e as SendParams, T as TxResult } from './index-c90msmwW.js';
2
- import './WalletManager-CeLlZo2y.js';
2
+ import './WalletManager-BV1QA08D.js';
3
3
 
4
4
  /**
5
5
  * ZubariWallet - Multi-chain self-custodial wallet
@@ -1,5 +1,5 @@
1
1
  import { Z as ZubariWalletConfig, b as NetworkType, A as Account, c as NetworkBalance, e as SendParams, T as TxResult } from './index-c90msmwW.mjs';
2
- import './WalletManager-DIx8nENh.mjs';
2
+ import './WalletManager-BTewpMGA.mjs';
3
3
 
4
4
  /**
5
5
  * ZubariWallet - Multi-chain self-custodial wallet
package/dist/index.d.mts CHANGED
@@ -1,10 +1,11 @@
1
- export { C as CURRENCY_ADDRESSES, l as ContractAddresses, D as DEFAULT_CONTRACTS, F as FeeWalletConfig, M as MAINNET_FEE_WALLETS, N as NFT_VOUCHER_DOMAIN, c as NFT_VOUCHER_TYPES, P as PLATFORM_CONFIG, S as SupportedFeeChain, T as TESTNET_FEE_WALLETS, b as ZERO_ADDRESS, a as ZUBARI_CONTRACTS, Z as ZubariWallet, k as getAllFeeWallets, g as getContractAddresses, d as getCurrentContractAddresses, i as getCurrentCurrencyAddresses, h as getCurrentFeeWallet, f as getCurrentFeeWallets, e as getDefaultSubscriptionAddress, j as getFeeWallet } from './contracts-pugJnFzl.mjs';
2
- export { D as DERIVATION_PATHS, N as NETWORKS, T as TESTNET_NETWORKS, b as WalletManager, W as WalletManagerConfig, a as WalletState, g as getNetworkConfig } from './WalletManager-DIx8nENh.mjs';
1
+ export { C as CURRENCY_ADDRESSES, l as ContractAddresses, D as DEFAULT_CONTRACTS, F as FeeWalletConfig, M as MAINNET_FEE_WALLETS, N as NFT_VOUCHER_DOMAIN, c as NFT_VOUCHER_TYPES, P as PLATFORM_CONFIG, S as SupportedFeeChain, T as TESTNET_FEE_WALLETS, b as ZERO_ADDRESS, a as ZUBARI_CONTRACTS, Z as ZubariWallet, k as getAllFeeWallets, g as getContractAddresses, d as getCurrentContractAddresses, i as getCurrentCurrencyAddresses, h as getCurrentFeeWallet, f as getCurrentFeeWallets, e as getDefaultSubscriptionAddress, j as getFeeWallet } from './contracts-i0GG-cBt.mjs';
2
+ export { D as DERIVATION_PATHS, N as NETWORKS, T as TESTNET_NETWORKS, b as WalletManager, W as WalletManagerConfig, a as WalletState, g as getNetworkConfig } from './WalletManager-BTewpMGA.mjs';
3
3
  export { M as MemoryStorageAdapter, S as SecureStorageAdapter, W as WebEncryptedStorageAdapter, c as createSecureStorage } from './SecureStorage-jO783AhC.mjs';
4
4
  export { a as ZubariMarketProtocol, Z as ZubariNFTProtocol, d as ZubariPayoutsProtocol, c as ZubariSubscriptionProtocol, b as ZubariTipsProtocol } from './PayoutsProtocol-DKEQhwYH.mjs';
5
5
  export { A as Account, B as BuyParams, h as CreateVoucherParams, E as EarningsBreakdown, L as LazyMintVoucher, k as Listing, j as ListingParams, i as NFT, f as NFTAttribute, N as NFTCurrency, g as NFTMetadata, c as NetworkBalance, b as NetworkType, R as RevenueSplit, e as SendParams, a as Subscription, S as SubscriptionPlan, q as SwapParams, p as SwapQuote, o as Tip, l as TipData, m as TipResult, n as TipStats, d as TokenBalance, T as TxResult, W as WatermarkingData, s as ZubariError, r as ZubariErrorCode, Z as ZubariWalletConfig } from './index-c90msmwW.mjs';
6
- export { B as BrowserAddressDerivation, l as ChainAddress, m as ChainBalance, w as FeeEstimate, F as FeeRates, M as MultiChainAddresses, k as SupportedChain, S as SwapService, v as TransactionHistoryItem, t as TransactionParams, u as TransactionResult, q as TransactionService, x as TransactionServiceConfig, W as WdkApiClient, Z as ZubariWdkService, p as ZubariWdkServiceConfig, s as createTransactionService, i as createZubariWdkService, r as getTransactionService, g as getWdkApiClient, h as getZubariWdkService, j as isBrowser } from './TransactionService-Cmw33HXX.mjs';
7
- import 'abitype';
6
+ export { B as BrowserAddressDerivation, l as ChainAddress, m as ChainBalance, w as FeeEstimate, F as FeeRates, M as MultiChainAddresses, k as SupportedChain, S as SwapService, v as TransactionHistoryItem, t as TransactionParams, u as TransactionResult, q as TransactionService, x as TransactionServiceConfig, W as WdkApiClient, Z as ZubariWdkService, p as ZubariWdkServiceConfig, s as createTransactionService, i as createZubariWdkService, r as getTransactionService, g as getWdkApiClient, h as getZubariWdkService, j as isBrowser } from './TransactionService-CF_C3Kqm.mjs';
7
+ import 'node_modules/viem/_types/actions/siwe/verifySiweMessage';
8
+ import 'node_modules/viem/_types/utils/ccip';
8
9
  import 'viem';
9
10
  import 'ethers';
10
11
 
package/dist/index.d.ts CHANGED
@@ -1,10 +1,11 @@
1
- export { C as CURRENCY_ADDRESSES, l as ContractAddresses, D as DEFAULT_CONTRACTS, F as FeeWalletConfig, M as MAINNET_FEE_WALLETS, N as NFT_VOUCHER_DOMAIN, c as NFT_VOUCHER_TYPES, P as PLATFORM_CONFIG, S as SupportedFeeChain, T as TESTNET_FEE_WALLETS, b as ZERO_ADDRESS, a as ZUBARI_CONTRACTS, Z as ZubariWallet, k as getAllFeeWallets, g as getContractAddresses, d as getCurrentContractAddresses, i as getCurrentCurrencyAddresses, h as getCurrentFeeWallet, f as getCurrentFeeWallets, e as getDefaultSubscriptionAddress, j as getFeeWallet } from './contracts-JfZDzaV7.js';
2
- export { D as DERIVATION_PATHS, N as NETWORKS, T as TESTNET_NETWORKS, b as WalletManager, W as WalletManagerConfig, a as WalletState, g as getNetworkConfig } from './WalletManager-CeLlZo2y.js';
1
+ export { C as CURRENCY_ADDRESSES, l as ContractAddresses, D as DEFAULT_CONTRACTS, F as FeeWalletConfig, M as MAINNET_FEE_WALLETS, N as NFT_VOUCHER_DOMAIN, c as NFT_VOUCHER_TYPES, P as PLATFORM_CONFIG, S as SupportedFeeChain, T as TESTNET_FEE_WALLETS, b as ZERO_ADDRESS, a as ZUBARI_CONTRACTS, Z as ZubariWallet, k as getAllFeeWallets, g as getContractAddresses, d as getCurrentContractAddresses, i as getCurrentCurrencyAddresses, h as getCurrentFeeWallet, f as getCurrentFeeWallets, e as getDefaultSubscriptionAddress, j as getFeeWallet } from './contracts-CyIOTDtT.js';
2
+ export { D as DERIVATION_PATHS, N as NETWORKS, T as TESTNET_NETWORKS, b as WalletManager, W as WalletManagerConfig, a as WalletState, g as getNetworkConfig } from './WalletManager-BV1QA08D.js';
3
3
  export { M as MemoryStorageAdapter, S as SecureStorageAdapter, W as WebEncryptedStorageAdapter, c as createSecureStorage } from './SecureStorage-jO783AhC.js';
4
4
  export { a as ZubariMarketProtocol, Z as ZubariNFTProtocol, d as ZubariPayoutsProtocol, c as ZubariSubscriptionProtocol, b as ZubariTipsProtocol } from './PayoutsProtocol-DAa-9A5C.js';
5
5
  export { A as Account, B as BuyParams, h as CreateVoucherParams, E as EarningsBreakdown, L as LazyMintVoucher, k as Listing, j as ListingParams, i as NFT, f as NFTAttribute, N as NFTCurrency, g as NFTMetadata, c as NetworkBalance, b as NetworkType, R as RevenueSplit, e as SendParams, a as Subscription, S as SubscriptionPlan, q as SwapParams, p as SwapQuote, o as Tip, l as TipData, m as TipResult, n as TipStats, d as TokenBalance, T as TxResult, W as WatermarkingData, s as ZubariError, r as ZubariErrorCode, Z as ZubariWalletConfig } from './index-c90msmwW.js';
6
- export { B as BrowserAddressDerivation, l as ChainAddress, m as ChainBalance, w as FeeEstimate, F as FeeRates, M as MultiChainAddresses, k as SupportedChain, S as SwapService, v as TransactionHistoryItem, t as TransactionParams, u as TransactionResult, q as TransactionService, x as TransactionServiceConfig, W as WdkApiClient, Z as ZubariWdkService, p as ZubariWdkServiceConfig, s as createTransactionService, i as createZubariWdkService, r as getTransactionService, g as getWdkApiClient, h as getZubariWdkService, j as isBrowser } from './TransactionService-DbNDRzXh.js';
7
- import 'abitype';
6
+ export { B as BrowserAddressDerivation, l as ChainAddress, m as ChainBalance, w as FeeEstimate, F as FeeRates, M as MultiChainAddresses, k as SupportedChain, S as SwapService, v as TransactionHistoryItem, t as TransactionParams, u as TransactionResult, q as TransactionService, x as TransactionServiceConfig, W as WdkApiClient, Z as ZubariWdkService, p as ZubariWdkServiceConfig, s as createTransactionService, i as createZubariWdkService, r as getTransactionService, g as getWdkApiClient, h as getZubariWdkService, j as isBrowser } from './TransactionService-BEkgF1T6.js';
7
+ import 'node_modules/viem/_types/actions/siwe/verifySiweMessage';
8
+ import 'node_modules/viem/_types/utils/ccip';
8
9
  import 'viem';
9
10
  import 'ethers';
10
11
 
package/dist/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
 
@@ -606,50 +612,25 @@ var DERIVATION_PATHS2 = {
606
612
  solana: `${DERIVATION_PATHS.solana}/0'`,
607
613
  spark: `${DERIVATION_PATHS.spark}/0`
608
614
  };
609
- var _crypto = null;
610
- async function loadCrypto() {
611
- if (_crypto) return _crypto;
612
- const [bip39, bip39Words, bip32, scureBase, sha256Mod, ripemd160Mod] = await Promise.all([
613
- import('@scure/bip39'),
614
- import('@scure/bip39/wordlists/english'),
615
- import('@scure/bip32'),
616
- import('@scure/base'),
617
- import('@noble/hashes/sha256'),
618
- import('@noble/hashes/ripemd160')
619
- ]);
620
- _crypto = {
621
- mnemonicToSeedSync: bip39.mnemonicToSeedSync,
622
- validateMnemonic: bip39.validateMnemonic,
623
- generateMnemonic: bip39.generateMnemonic,
624
- wordlist: bip39Words.wordlist,
625
- HDKey: bip32.HDKey,
626
- bech32: scureBase.bech32,
627
- base58check: scureBase.base58check,
628
- sha256: sha256Mod.sha256,
629
- ripemd160: ripemd160Mod.ripemd160
630
- };
631
- return _crypto;
632
- }
633
615
  function deriveEthereumAddress(seed) {
634
616
  const hdNode = ethers.HDNodeWallet.fromPhrase(seed, void 0, DERIVATION_PATHS2.ethereum);
635
617
  return hdNode.address;
636
618
  }
637
- async function deriveBitcoinAddress(seed, network = "mainnet") {
619
+ function deriveBitcoinAddress(seed, network = "mainnet") {
638
620
  try {
639
- const { mnemonicToSeedSync, HDKey, sha256, ripemd160, bech32 } = await loadCrypto();
640
- const seedBytes = mnemonicToSeedSync(seed);
641
- const hdKey = HDKey.fromMasterSeed(seedBytes);
621
+ const seedBytes = bip39.mnemonicToSeedSync(seed);
622
+ const hdKey = bip32.HDKey.fromMasterSeed(seedBytes);
642
623
  const path = network === "testnet" ? DERIVATION_PATHS2.bitcoin_testnet : DERIVATION_PATHS2.bitcoin_mainnet;
643
624
  const child = hdKey.derive(path);
644
625
  if (!child.publicKey) {
645
626
  throw new Error("Failed to derive public key");
646
627
  }
647
- const pubKeyHash = ripemd160(sha256(child.publicKey));
628
+ const pubKeyHash = ripemd160.ripemd160(sha256.sha256(child.publicKey));
648
629
  const witnessVersion = 0;
649
- const words = bech32.toWords(pubKeyHash);
630
+ const words = base.bech32.toWords(pubKeyHash);
650
631
  words.unshift(witnessVersion);
651
632
  const hrp = network === "testnet" ? "tb" : "bc";
652
- const address = bech32.encode(hrp, words);
633
+ const address = base.bech32.encode(hrp, words);
653
634
  return address;
654
635
  } catch (error) {
655
636
  console.error("Bitcoin address derivation failed:", error);
@@ -658,14 +639,13 @@ async function deriveBitcoinAddress(seed, network = "mainnet") {
658
639
  }
659
640
  async function deriveSolanaAddress(seed) {
660
641
  try {
661
- const [crypto2, ed25519, nacl, bs58Module] = await Promise.all([
662
- loadCrypto(),
642
+ const [ed25519, nacl, bs58Module] = await Promise.all([
663
643
  import('ed25519-hd-key'),
664
644
  import('tweetnacl'),
665
645
  import('bs58')
666
646
  ]);
667
647
  const bs58 = bs58Module.default || bs58Module;
668
- const seedBytes = crypto2.mnemonicToSeedSync(seed);
648
+ const seedBytes = bip39.mnemonicToSeedSync(seed);
669
649
  const derived = ed25519.derivePath(DERIVATION_PATHS2.solana, Buffer.from(seedBytes).toString("hex"));
670
650
  const keypair = nacl.sign.keyPair.fromSeed(new Uint8Array(derived.key));
671
651
  return bs58.encode(keypair.publicKey);
@@ -676,18 +656,17 @@ async function deriveSolanaAddress(seed) {
676
656
  }
677
657
  async function deriveTonAddress(seed) {
678
658
  try {
679
- const [crypto2, ed25519, nacl] = await Promise.all([
680
- loadCrypto(),
659
+ const [ed25519, nacl] = await Promise.all([
681
660
  import('ed25519-hd-key'),
682
661
  import('tweetnacl')
683
662
  ]);
684
- const seedBytes = crypto2.mnemonicToSeedSync(seed);
663
+ const seedBytes = bip39.mnemonicToSeedSync(seed);
685
664
  const derived = ed25519.derivePath(DERIVATION_PATHS2.ton, Buffer.from(seedBytes).toString("hex"));
686
665
  const keypair = nacl.sign.keyPair.fromSeed(new Uint8Array(derived.key));
687
666
  const publicKey = keypair.publicKey;
688
667
  const workchain = 0;
689
668
  const flags = 17;
690
- const hash = crypto2.sha256(publicKey);
669
+ const hash = sha256.sha256(publicKey);
691
670
  const addressData = new Uint8Array(34);
692
671
  addressData[0] = flags;
693
672
  addressData[1] = workchain;
@@ -715,9 +694,8 @@ function crc16(data) {
715
694
  }
716
695
  return crc;
717
696
  }
718
- async function deriveTronAddress(seed) {
697
+ function deriveTronAddress(seed) {
719
698
  try {
720
- const { sha256, base58check } = await loadCrypto();
721
699
  const hdNode = ethers.HDNodeWallet.fromPhrase(seed, void 0, DERIVATION_PATHS2.tron);
722
700
  const ethAddressHex = hdNode.address.slice(2).toLowerCase();
723
701
  const addressBytes = new Uint8Array(21);
@@ -725,28 +703,27 @@ async function deriveTronAddress(seed) {
725
703
  for (let i = 0; i < 20; i++) {
726
704
  addressBytes[i + 1] = parseInt(ethAddressHex.slice(i * 2, i * 2 + 2), 16);
727
705
  }
728
- const tronBase58check = base58check(sha256);
706
+ const tronBase58check = base.base58check(sha256.sha256);
729
707
  return tronBase58check.encode(addressBytes);
730
708
  } catch (error) {
731
709
  console.error("TRON address derivation failed:", error);
732
710
  throw error;
733
711
  }
734
712
  }
735
- async function deriveSparkAddress(seed, network = "mainnet") {
713
+ function deriveSparkAddress(seed, network = "mainnet") {
736
714
  try {
737
- const { mnemonicToSeedSync, HDKey, sha256, ripemd160, bech32 } = await loadCrypto();
738
- const seedBytes = mnemonicToSeedSync(seed);
739
- const hdKey = HDKey.fromMasterSeed(seedBytes);
715
+ const seedBytes = bip39.mnemonicToSeedSync(seed);
716
+ const hdKey = bip32.HDKey.fromMasterSeed(seedBytes);
740
717
  const child = hdKey.derive(DERIVATION_PATHS2.spark);
741
718
  if (!child.publicKey) {
742
719
  throw new Error("Failed to derive public key");
743
720
  }
744
- const pubKeyHash = ripemd160(sha256(child.publicKey));
721
+ const pubKeyHash = ripemd160.ripemd160(sha256.sha256(child.publicKey));
745
722
  const witnessVersion = 0;
746
- const words = bech32.toWords(pubKeyHash);
723
+ const words = base.bech32.toWords(pubKeyHash);
747
724
  words.unshift(witnessVersion);
748
725
  const hrp = network === "testnet" ? "tsp" : "sp";
749
- const address = bech32.encode(hrp, words);
726
+ const address = base.bech32.encode(hrp, words);
750
727
  return address;
751
728
  } catch (error) {
752
729
  console.error("Spark address derivation failed:", error);
@@ -762,38 +739,47 @@ async function deriveAllAddresses(seed, network = "mainnet") {
762
739
  solana: null,
763
740
  spark: null
764
741
  };
765
- await loadCrypto();
766
742
  try {
767
743
  addresses.ethereum = deriveEthereumAddress(seed);
768
744
  } catch (e) {
769
745
  console.error("ETH derivation failed:", e);
770
746
  }
771
- const [btcResult, sparkResult, tronResult, solResult, tonResult] = await Promise.allSettled([
772
- deriveBitcoinAddress(seed, network),
773
- deriveSparkAddress(seed, network),
774
- deriveTronAddress(seed),
747
+ try {
748
+ addresses.bitcoin = deriveBitcoinAddress(seed, network);
749
+ } catch (e) {
750
+ console.error("BTC derivation failed:", e);
751
+ }
752
+ try {
753
+ addresses.spark = deriveSparkAddress(seed, network);
754
+ } catch (e) {
755
+ console.error("Spark derivation failed:", e);
756
+ }
757
+ try {
758
+ addresses.tron = deriveTronAddress(seed);
759
+ } catch (e) {
760
+ console.error("TRON derivation failed:", e);
761
+ }
762
+ const [solResult, tonResult] = await Promise.allSettled([
775
763
  deriveSolanaAddress(seed),
776
764
  deriveTonAddress(seed)
777
765
  ]);
778
- if (btcResult.status === "fulfilled") addresses.bitcoin = btcResult.value;
779
- else console.error("BTC derivation failed:", btcResult.reason);
780
- if (sparkResult.status === "fulfilled") addresses.spark = sparkResult.value;
781
- else console.error("Spark derivation failed:", sparkResult.reason);
782
- if (tronResult.status === "fulfilled") addresses.tron = tronResult.value;
783
- else console.error("TRON derivation failed:", tronResult.reason);
784
- if (solResult.status === "fulfilled") addresses.solana = solResult.value;
785
- else console.error("SOL derivation failed:", solResult.reason);
786
- if (tonResult.status === "fulfilled") addresses.ton = tonResult.value;
787
- else console.error("TON derivation failed:", tonResult.reason);
766
+ if (solResult.status === "fulfilled") {
767
+ addresses.solana = solResult.value;
768
+ } else {
769
+ console.error("SOL derivation failed:", solResult.reason);
770
+ }
771
+ if (tonResult.status === "fulfilled") {
772
+ addresses.ton = tonResult.value;
773
+ } else {
774
+ console.error("TON derivation failed:", tonResult.reason);
775
+ }
788
776
  return addresses;
789
777
  }
790
- async function isValidSeed(seed) {
791
- const { validateMnemonic, wordlist } = await loadCrypto();
792
- return validateMnemonic(seed, wordlist);
778
+ function isValidSeed(seed) {
779
+ return bip39.validateMnemonic(seed, english.wordlist);
793
780
  }
794
- async function generateSeedPhrase() {
795
- const { generateMnemonic, wordlist } = await loadCrypto();
796
- return generateMnemonic(wordlist);
781
+ function generateSeedPhrase() {
782
+ return bip39.generateMnemonic(english.wordlist);
797
783
  }
798
784
 
799
785
  // src/services/ZubariWdkService.ts
@@ -1036,7 +1022,7 @@ var ZubariWdkService = class {
1036
1022
  };
1037
1023
  if (!addresses.spark) {
1038
1024
  try {
1039
- addresses.spark = await deriveSparkAddress(seed, this.config.network);
1025
+ addresses.spark = deriveSparkAddress(seed, this.config.network);
1040
1026
  } catch (e) {
1041
1027
  console.warn("Browser Spark derivation fallback failed:", e);
1042
1028
  }
@@ -1272,13 +1258,13 @@ var ZubariWdkService = class {
1272
1258
  address = deriveEthereumAddress(seed);
1273
1259
  break;
1274
1260
  case "bitcoin":
1275
- address = await deriveBitcoinAddress(seed, this.config.network);
1261
+ address = deriveBitcoinAddress(seed, this.config.network);
1276
1262
  break;
1277
1263
  case "tron":
1278
- address = await deriveTronAddress(seed);
1264
+ address = deriveTronAddress(seed);
1279
1265
  break;
1280
1266
  case "spark":
1281
- address = await deriveSparkAddress(seed, this.config.network);
1267
+ address = deriveSparkAddress(seed, this.config.network);
1282
1268
  break;
1283
1269
  case "solana":
1284
1270
  address = await deriveSolanaAddress(seed);