@zubari/sdk 0.5.7 → 0.5.9

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.
@@ -88,6 +88,12 @@ interface WalletManagerConfig {
88
88
  apiUrl?: string;
89
89
  /** Access token for authenticated API requests */
90
90
  accessToken?: string;
91
+ /** Per-chain RPC URL overrides (e.g. for Solana private RPC) */
92
+ chainRpcUrls?: Partial<Record<NetworkType, string>>;
93
+ /** TronGrid API key to avoid rate limiting */
94
+ tronApiKey?: string;
95
+ /** TON Center API key to avoid 429 rate limiting */
96
+ tonApiKey?: string;
91
97
  }
92
98
  /**
93
99
  * WalletManager - Handles BIP-39 seed generation, address derivation, and secure storage
@@ -88,6 +88,12 @@ interface WalletManagerConfig {
88
88
  apiUrl?: string;
89
89
  /** Access token for authenticated API requests */
90
90
  accessToken?: string;
91
+ /** Per-chain RPC URL overrides (e.g. for Solana private RPC) */
92
+ chainRpcUrls?: Partial<Record<NetworkType, string>>;
93
+ /** TronGrid API key to avoid rate limiting */
94
+ tronApiKey?: string;
95
+ /** TON Center API key to avoid 429 rate limiting */
96
+ tonApiKey?: string;
91
97
  }
92
98
  /**
93
99
  * WalletManager - Handles BIP-39 seed generation, address derivation, and secure storage
@@ -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-BTewpMGA.mjs';
2
+ import './WalletManager-DOjsIbb1.mjs';
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.js';
2
- import './WalletManager-BV1QA08D.js';
2
+ import './WalletManager-n5KdhSRd.js';
3
3
 
4
4
  /**
5
5
  * ZubariWallet - Multi-chain self-custodial wallet
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
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';
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-BWEndqf6.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-DOjsIbb1.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';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
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';
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-DtN5ys2L.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-n5KdhSRd.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';
package/dist/index.js CHANGED
@@ -2222,7 +2222,10 @@ var WalletManager = class _WalletManager {
2222
2222
  storage: config.storage || createSecureStorage(),
2223
2223
  enabledChains: config.enabledChains || SUPPORTED_CHAINS,
2224
2224
  apiUrl: config.apiUrl || process.env.NEXT_PUBLIC_API_URL || "https://ckgwifsxka.us-east-2.awsapprunner.com",
2225
- accessToken: config.accessToken
2225
+ accessToken: config.accessToken,
2226
+ chainRpcUrls: config.chainRpcUrls || {},
2227
+ tronApiKey: config.tronApiKey,
2228
+ tonApiKey: config.tonApiKey
2226
2229
  };
2227
2230
  this.storage = this.config.storage;
2228
2231
  this.wdkService = getZubariWdkService({
@@ -2784,7 +2787,7 @@ var WalletManager = class _WalletManager {
2784
2787
  }
2785
2788
  }
2786
2789
  } else if (chain === "solana") {
2787
- const rpcUrl = this.config.network === "mainnet" ? "https://api.mainnet-beta.solana.com" : "https://api.devnet.solana.com";
2790
+ const rpcUrl = this.config.chainRpcUrls.solana || (this.config.network === "mainnet" ? "https://api.mainnet-beta.solana.com" : "https://api.devnet.solana.com");
2788
2791
  try {
2789
2792
  const response = await fetch(rpcUrl, {
2790
2793
  method: "POST",
@@ -2837,12 +2840,40 @@ var WalletManager = class _WalletManager {
2837
2840
  console.warn("Failed to fetch Solana USDT balance:", error);
2838
2841
  }
2839
2842
  }
2843
+ if (balance === "0" && this.config.apiUrl && this.config.accessToken) {
2844
+ try {
2845
+ const fallbackResponse = await fetch(`${this.config.apiUrl}/api/wallets/wdk/balance`, {
2846
+ method: "POST",
2847
+ headers: {
2848
+ "Content-Type": "application/json",
2849
+ "Authorization": `Bearer ${this.config.accessToken}`
2850
+ },
2851
+ body: JSON.stringify({
2852
+ chain: "solana",
2853
+ address,
2854
+ network: this.config.network
2855
+ })
2856
+ });
2857
+ if (fallbackResponse.ok) {
2858
+ const fallbackData = await fallbackResponse.json();
2859
+ if (fallbackData.success && fallbackData.balance && fallbackData.balance !== "0") {
2860
+ balance = fallbackData.balance;
2861
+ }
2862
+ }
2863
+ } catch (fallbackError) {
2864
+ console.warn("Solana backend fallback failed:", fallbackError);
2865
+ }
2866
+ }
2840
2867
  } else if (chain === "tron") {
2841
2868
  const tronConfig = getNetworkConfig("tron", this.config.network !== "mainnet");
2842
2869
  const baseUrl = tronConfig.rpcUrl;
2843
2870
  try {
2871
+ const tronHeaders = { "Accept": "application/json" };
2872
+ if (this.config.tronApiKey) {
2873
+ tronHeaders["TRON-PRO-API-KEY"] = this.config.tronApiKey;
2874
+ }
2844
2875
  const response = await fetch(`${baseUrl}/v1/accounts/${address}`, {
2845
- headers: { "Accept": "application/json" }
2876
+ headers: tronHeaders
2846
2877
  });
2847
2878
  if (response.ok) {
2848
2879
  const data = await response.json();
@@ -2872,8 +2903,12 @@ var WalletManager = class _WalletManager {
2872
2903
  const isTestnet2 = this.config.network !== "mainnet";
2873
2904
  const baseUrl = isTestnet2 ? "https://testnet.toncenter.com/api/v2" : "https://toncenter.com/api/v2";
2874
2905
  try {
2906
+ const tonHeaders = { "Accept": "application/json" };
2907
+ if (this.config.tonApiKey) {
2908
+ tonHeaders["X-API-Key"] = this.config.tonApiKey;
2909
+ }
2875
2910
  const response = await fetch(`${baseUrl}/getAddressBalance?address=${address}`, {
2876
- headers: { "Accept": "application/json" }
2911
+ headers: tonHeaders
2877
2912
  });
2878
2913
  if (response.ok) {
2879
2914
  const data = await response.json();
@@ -2923,9 +2958,13 @@ var WalletManager = class _WalletManager {
2923
2958
  }
2924
2959
  } else if (chain === "spark") {
2925
2960
  try {
2961
+ const sparkHeaders = { "Content-Type": "application/json" };
2962
+ if (this.config.accessToken) {
2963
+ sparkHeaders["Authorization"] = `Bearer ${this.config.accessToken}`;
2964
+ }
2926
2965
  const response = await fetch(`${this.config.apiUrl}/api/wallets/wdk/balance`, {
2927
2966
  method: "POST",
2928
- headers: { "Content-Type": "application/json" },
2967
+ headers: sparkHeaders,
2929
2968
  body: JSON.stringify({
2930
2969
  chain: "spark",
2931
2970
  address,
@@ -2968,7 +3007,7 @@ var WalletManager = class _WalletManager {
2968
3007
  if (result.status === "fulfilled") {
2969
3008
  return result.value;
2970
3009
  }
2971
- console.error(`Failed to fetch balance for ${chain}:`, result.reason);
3010
+ console.warn(`Failed to fetch balance for ${chain}:`, result.reason);
2972
3011
  const networkConfig = this.getChainConfig(chain);
2973
3012
  return {
2974
3013
  chain,