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