@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/wallet/index.js
CHANGED
|
@@ -4269,6 +4269,61 @@ var WalletManager = class _WalletManager {
|
|
|
4269
4269
|
} catch (error) {
|
|
4270
4270
|
console.warn(`Failed to fetch ${chain} balance:`, error);
|
|
4271
4271
|
}
|
|
4272
|
+
} else if (chain === "bitcoin") {
|
|
4273
|
+
const baseUrl = this.config.network === "mainnet" ? "https://blockstream.info/api" : "https://blockstream.info/testnet/api";
|
|
4274
|
+
try {
|
|
4275
|
+
const response = await fetch(`${baseUrl}/address/${address}`, {
|
|
4276
|
+
headers: { "Accept": "application/json" }
|
|
4277
|
+
});
|
|
4278
|
+
if (response.ok) {
|
|
4279
|
+
const data = await response.json();
|
|
4280
|
+
const chainFunded = data.chain_stats?.funded_txo_sum || 0;
|
|
4281
|
+
const chainSpent = data.chain_stats?.spent_txo_sum || 0;
|
|
4282
|
+
const mempoolFunded = data.mempool_stats?.funded_txo_sum || 0;
|
|
4283
|
+
const mempoolSpent = data.mempool_stats?.spent_txo_sum || 0;
|
|
4284
|
+
const satoshis = chainFunded - chainSpent + (mempoolFunded - mempoolSpent);
|
|
4285
|
+
balance = (satoshis / 1e8).toFixed(8);
|
|
4286
|
+
}
|
|
4287
|
+
} catch (error) {
|
|
4288
|
+
console.warn(`Failed to fetch ${chain} balance:`, error);
|
|
4289
|
+
}
|
|
4290
|
+
} else if (chain === "solana") {
|
|
4291
|
+
const rpcUrl = this.config.network === "mainnet" ? "https://api.mainnet-beta.solana.com" : "https://api.devnet.solana.com";
|
|
4292
|
+
try {
|
|
4293
|
+
const response = await fetch(rpcUrl, {
|
|
4294
|
+
method: "POST",
|
|
4295
|
+
headers: { "Content-Type": "application/json" },
|
|
4296
|
+
body: JSON.stringify({
|
|
4297
|
+
jsonrpc: "2.0",
|
|
4298
|
+
id: 1,
|
|
4299
|
+
method: "getBalance",
|
|
4300
|
+
params: [address]
|
|
4301
|
+
})
|
|
4302
|
+
});
|
|
4303
|
+
if (response.ok) {
|
|
4304
|
+
const data = await response.json();
|
|
4305
|
+
if (data.result?.value !== void 0) {
|
|
4306
|
+
balance = (data.result.value / 1e9).toFixed(9);
|
|
4307
|
+
}
|
|
4308
|
+
}
|
|
4309
|
+
} catch (error) {
|
|
4310
|
+
console.warn(`Failed to fetch ${chain} balance:`, error);
|
|
4311
|
+
}
|
|
4312
|
+
} else if (chain === "tron") {
|
|
4313
|
+
const baseUrl = this.config.network === "mainnet" ? "https://api.trongrid.io" : "https://api.shasta.trongrid.io";
|
|
4314
|
+
try {
|
|
4315
|
+
const response = await fetch(`${baseUrl}/v1/accounts/${address}`, {
|
|
4316
|
+
headers: { "Accept": "application/json" }
|
|
4317
|
+
});
|
|
4318
|
+
if (response.ok) {
|
|
4319
|
+
const data = await response.json();
|
|
4320
|
+
if (data.data?.[0]?.balance !== void 0) {
|
|
4321
|
+
balance = (data.data[0].balance / 1e6).toFixed(6);
|
|
4322
|
+
}
|
|
4323
|
+
}
|
|
4324
|
+
} catch (error) {
|
|
4325
|
+
console.warn(`Failed to fetch ${chain} balance:`, error);
|
|
4326
|
+
}
|
|
4272
4327
|
}
|
|
4273
4328
|
return {
|
|
4274
4329
|
chain,
|