@zubari/sdk 0.1.3 → 0.1.4

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/index.js CHANGED
@@ -4295,6 +4295,61 @@ var WalletManager = class _WalletManager {
4295
4295
  } catch (error) {
4296
4296
  console.warn(`Failed to fetch ${chain} balance:`, error);
4297
4297
  }
4298
+ } else if (chain === "bitcoin") {
4299
+ const baseUrl = this.config.network === "mainnet" ? "https://blockstream.info/api" : "https://blockstream.info/testnet/api";
4300
+ try {
4301
+ const response = await fetch(`${baseUrl}/address/${address}`, {
4302
+ headers: { "Accept": "application/json" }
4303
+ });
4304
+ if (response.ok) {
4305
+ const data = await response.json();
4306
+ const chainFunded = data.chain_stats?.funded_txo_sum || 0;
4307
+ const chainSpent = data.chain_stats?.spent_txo_sum || 0;
4308
+ const mempoolFunded = data.mempool_stats?.funded_txo_sum || 0;
4309
+ const mempoolSpent = data.mempool_stats?.spent_txo_sum || 0;
4310
+ const satoshis = chainFunded - chainSpent + (mempoolFunded - mempoolSpent);
4311
+ balance = (satoshis / 1e8).toFixed(8);
4312
+ }
4313
+ } catch (error) {
4314
+ console.warn(`Failed to fetch ${chain} balance:`, error);
4315
+ }
4316
+ } else if (chain === "solana") {
4317
+ const rpcUrl = this.config.network === "mainnet" ? "https://api.mainnet-beta.solana.com" : "https://api.devnet.solana.com";
4318
+ try {
4319
+ const response = await fetch(rpcUrl, {
4320
+ method: "POST",
4321
+ headers: { "Content-Type": "application/json" },
4322
+ body: JSON.stringify({
4323
+ jsonrpc: "2.0",
4324
+ id: 1,
4325
+ method: "getBalance",
4326
+ params: [address]
4327
+ })
4328
+ });
4329
+ if (response.ok) {
4330
+ const data = await response.json();
4331
+ if (data.result?.value !== void 0) {
4332
+ balance = (data.result.value / 1e9).toFixed(9);
4333
+ }
4334
+ }
4335
+ } catch (error) {
4336
+ console.warn(`Failed to fetch ${chain} balance:`, error);
4337
+ }
4338
+ } else if (chain === "tron") {
4339
+ const baseUrl = this.config.network === "mainnet" ? "https://api.trongrid.io" : "https://api.shasta.trongrid.io";
4340
+ try {
4341
+ const response = await fetch(`${baseUrl}/v1/accounts/${address}`, {
4342
+ headers: { "Accept": "application/json" }
4343
+ });
4344
+ if (response.ok) {
4345
+ const data = await response.json();
4346
+ if (data.data?.[0]?.balance !== void 0) {
4347
+ balance = (data.data[0].balance / 1e6).toFixed(6);
4348
+ }
4349
+ }
4350
+ } catch (error) {
4351
+ console.warn(`Failed to fetch ${chain} balance:`, error);
4352
+ }
4298
4353
  }
4299
4354
  return {
4300
4355
  chain,