@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.
@@ -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-BTewpMGA.mjs';
3
- export { S as SUPPORTED_CHAINS } from '../WalletManager-BTewpMGA.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-BV1QA08D.js';
3
- export { S as SUPPORTED_CHAINS } from '../WalletManager-BV1QA08D.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';
@@ -1468,7 +1468,10 @@ var WalletManager = class _WalletManager {
1468
1468
  storage: config.storage || createSecureStorage(),
1469
1469
  enabledChains: config.enabledChains || SUPPORTED_CHAINS,
1470
1470
  apiUrl: config.apiUrl || process.env.NEXT_PUBLIC_API_URL || "https://ckgwifsxka.us-east-2.awsapprunner.com",
1471
- accessToken: config.accessToken
1471
+ accessToken: config.accessToken,
1472
+ chainRpcUrls: config.chainRpcUrls || {},
1473
+ tronApiKey: config.tronApiKey,
1474
+ tonApiKey: config.tonApiKey
1472
1475
  };
1473
1476
  this.storage = this.config.storage;
1474
1477
  this.wdkService = getZubariWdkService({
@@ -2030,7 +2033,7 @@ var WalletManager = class _WalletManager {
2030
2033
  }
2031
2034
  }
2032
2035
  } else if (chain === "solana") {
2033
- const rpcUrl = this.config.network === "mainnet" ? "https://api.mainnet-beta.solana.com" : "https://api.devnet.solana.com";
2036
+ const rpcUrl = this.config.chainRpcUrls.solana || (this.config.network === "mainnet" ? "https://api.mainnet-beta.solana.com" : "https://api.devnet.solana.com");
2034
2037
  try {
2035
2038
  const response = await fetch(rpcUrl, {
2036
2039
  method: "POST",
@@ -2083,12 +2086,40 @@ var WalletManager = class _WalletManager {
2083
2086
  console.warn("Failed to fetch Solana USDT balance:", error);
2084
2087
  }
2085
2088
  }
2089
+ if (balance === "0" && this.config.apiUrl && this.config.accessToken) {
2090
+ try {
2091
+ const fallbackResponse = await fetch(`${this.config.apiUrl}/api/wallets/wdk/balance`, {
2092
+ method: "POST",
2093
+ headers: {
2094
+ "Content-Type": "application/json",
2095
+ "Authorization": `Bearer ${this.config.accessToken}`
2096
+ },
2097
+ body: JSON.stringify({
2098
+ chain: "solana",
2099
+ address,
2100
+ network: this.config.network
2101
+ })
2102
+ });
2103
+ if (fallbackResponse.ok) {
2104
+ const fallbackData = await fallbackResponse.json();
2105
+ if (fallbackData.success && fallbackData.balance && fallbackData.balance !== "0") {
2106
+ balance = fallbackData.balance;
2107
+ }
2108
+ }
2109
+ } catch (fallbackError) {
2110
+ console.warn("Solana backend fallback failed:", fallbackError);
2111
+ }
2112
+ }
2086
2113
  } else if (chain === "tron") {
2087
2114
  const tronConfig = getNetworkConfig("tron", this.config.network !== "mainnet");
2088
2115
  const baseUrl = tronConfig.rpcUrl;
2089
2116
  try {
2117
+ const tronHeaders = { "Accept": "application/json" };
2118
+ if (this.config.tronApiKey) {
2119
+ tronHeaders["TRON-PRO-API-KEY"] = this.config.tronApiKey;
2120
+ }
2090
2121
  const response = await fetch(`${baseUrl}/v1/accounts/${address}`, {
2091
- headers: { "Accept": "application/json" }
2122
+ headers: tronHeaders
2092
2123
  });
2093
2124
  if (response.ok) {
2094
2125
  const data = await response.json();
@@ -2118,8 +2149,12 @@ var WalletManager = class _WalletManager {
2118
2149
  const isTestnet = this.config.network !== "mainnet";
2119
2150
  const baseUrl = isTestnet ? "https://testnet.toncenter.com/api/v2" : "https://toncenter.com/api/v2";
2120
2151
  try {
2152
+ const tonHeaders = { "Accept": "application/json" };
2153
+ if (this.config.tonApiKey) {
2154
+ tonHeaders["X-API-Key"] = this.config.tonApiKey;
2155
+ }
2121
2156
  const response = await fetch(`${baseUrl}/getAddressBalance?address=${address}`, {
2122
- headers: { "Accept": "application/json" }
2157
+ headers: tonHeaders
2123
2158
  });
2124
2159
  if (response.ok) {
2125
2160
  const data = await response.json();
@@ -2169,9 +2204,13 @@ var WalletManager = class _WalletManager {
2169
2204
  }
2170
2205
  } else if (chain === "spark") {
2171
2206
  try {
2207
+ const sparkHeaders = { "Content-Type": "application/json" };
2208
+ if (this.config.accessToken) {
2209
+ sparkHeaders["Authorization"] = `Bearer ${this.config.accessToken}`;
2210
+ }
2172
2211
  const response = await fetch(`${this.config.apiUrl}/api/wallets/wdk/balance`, {
2173
2212
  method: "POST",
2174
- headers: { "Content-Type": "application/json" },
2213
+ headers: sparkHeaders,
2175
2214
  body: JSON.stringify({
2176
2215
  chain: "spark",
2177
2216
  address,
@@ -2214,7 +2253,7 @@ var WalletManager = class _WalletManager {
2214
2253
  if (result.status === "fulfilled") {
2215
2254
  return result.value;
2216
2255
  }
2217
- console.error(`Failed to fetch balance for ${chain}:`, result.reason);
2256
+ console.warn(`Failed to fetch balance for ${chain}:`, result.reason);
2218
2257
  const networkConfig = this.getChainConfig(chain);
2219
2258
  return {
2220
2259
  chain,