@zubari/sdk 0.5.8 → 0.5.10

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,6 +1,6 @@
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-i2BBu6uz.mjs';
3
- export { S as SUPPORTED_CHAINS } from '../WalletManager-i2BBu6uz.mjs';
2
+ import { W as WalletManagerConfig, a as WalletState, C as ChainBalance, M as MultiChainAddresses, b as WalletManager } from '../WalletManager-DOjsIbb1.mjs';
3
+ export { S as SUPPORTED_CHAINS } from '../WalletManager-DOjsIbb1.mjs';
4
4
  import 'node_modules/viem/_types/actions/siwe/verifySiweMessage';
5
5
  import 'node_modules/viem/_types/utils/ccip';
6
6
  import 'viem';
@@ -1,6 +1,6 @@
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-Csfokchy.js';
3
- export { S as SUPPORTED_CHAINS } from '../WalletManager-Csfokchy.js';
2
+ import { W as WalletManagerConfig, a as WalletState, C as ChainBalance, M as MultiChainAddresses, b as WalletManager } from '../WalletManager-n5KdhSRd.js';
3
+ export { S as SUPPORTED_CHAINS } from '../WalletManager-n5KdhSRd.js';
4
4
  import 'node_modules/viem/_types/actions/siwe/verifySiweMessage';
5
5
  import 'node_modules/viem/_types/utils/ccip';
6
6
  import 'viem';
@@ -576,7 +576,9 @@ function parseChainError(chain, errorMessage) {
576
576
  function isBrowser() {
577
577
  return typeof window !== "undefined" && typeof window.document !== "undefined";
578
578
  }
579
- var dynamicImport = new Function("specifier", "return import(specifier)");
579
+ async function dynamicImport(specifier) {
580
+ return import(specifier);
581
+ }
580
582
  async function canUseNativeWdk() {
581
583
  if (isBrowser()) {
582
584
  return false;
@@ -1470,7 +1472,8 @@ var WalletManager = class _WalletManager {
1470
1472
  apiUrl: config.apiUrl || process.env.NEXT_PUBLIC_API_URL || "https://ckgwifsxka.us-east-2.awsapprunner.com",
1471
1473
  accessToken: config.accessToken,
1472
1474
  chainRpcUrls: config.chainRpcUrls || {},
1473
- tronApiKey: config.tronApiKey
1475
+ tronApiKey: config.tronApiKey,
1476
+ tonApiKey: config.tonApiKey
1474
1477
  };
1475
1478
  this.storage = this.config.storage;
1476
1479
  this.wdkService = getZubariWdkService({
@@ -2085,6 +2088,30 @@ var WalletManager = class _WalletManager {
2085
2088
  console.warn("Failed to fetch Solana USDT balance:", error);
2086
2089
  }
2087
2090
  }
2091
+ if (balance === "0" && this.config.apiUrl && this.config.accessToken) {
2092
+ try {
2093
+ const fallbackResponse = await fetch(`${this.config.apiUrl}/api/wallets/wdk/balance`, {
2094
+ method: "POST",
2095
+ headers: {
2096
+ "Content-Type": "application/json",
2097
+ "Authorization": `Bearer ${this.config.accessToken}`
2098
+ },
2099
+ body: JSON.stringify({
2100
+ chain: "solana",
2101
+ address,
2102
+ network: this.config.network
2103
+ })
2104
+ });
2105
+ if (fallbackResponse.ok) {
2106
+ const fallbackData = await fallbackResponse.json();
2107
+ if (fallbackData.success && fallbackData.balance && fallbackData.balance !== "0") {
2108
+ balance = fallbackData.balance;
2109
+ }
2110
+ }
2111
+ } catch (fallbackError) {
2112
+ console.warn("Solana backend fallback failed:", fallbackError);
2113
+ }
2114
+ }
2088
2115
  } else if (chain === "tron") {
2089
2116
  const tronConfig = getNetworkConfig("tron", this.config.network !== "mainnet");
2090
2117
  const baseUrl = tronConfig.rpcUrl;
@@ -2124,8 +2151,12 @@ var WalletManager = class _WalletManager {
2124
2151
  const isTestnet = this.config.network !== "mainnet";
2125
2152
  const baseUrl = isTestnet ? "https://testnet.toncenter.com/api/v2" : "https://toncenter.com/api/v2";
2126
2153
  try {
2154
+ const tonHeaders = { "Accept": "application/json" };
2155
+ if (this.config.tonApiKey) {
2156
+ tonHeaders["X-API-Key"] = this.config.tonApiKey;
2157
+ }
2127
2158
  const response = await fetch(`${baseUrl}/getAddressBalance?address=${address}`, {
2128
- headers: { "Accept": "application/json" }
2159
+ headers: tonHeaders
2129
2160
  });
2130
2161
  if (response.ok) {
2131
2162
  const data = await response.json();
@@ -2175,9 +2206,13 @@ var WalletManager = class _WalletManager {
2175
2206
  }
2176
2207
  } else if (chain === "spark") {
2177
2208
  try {
2209
+ const sparkHeaders = { "Content-Type": "application/json" };
2210
+ if (this.config.accessToken) {
2211
+ sparkHeaders["Authorization"] = `Bearer ${this.config.accessToken}`;
2212
+ }
2178
2213
  const response = await fetch(`${this.config.apiUrl}/api/wallets/wdk/balance`, {
2179
2214
  method: "POST",
2180
- headers: { "Content-Type": "application/json" },
2215
+ headers: sparkHeaders,
2181
2216
  body: JSON.stringify({
2182
2217
  chain: "spark",
2183
2218
  address,