@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/react/index.mjs
CHANGED
|
@@ -3967,6 +3967,61 @@ var WalletManager = class _WalletManager {
|
|
|
3967
3967
|
} catch (error) {
|
|
3968
3968
|
console.warn(`Failed to fetch ${chain} balance:`, error);
|
|
3969
3969
|
}
|
|
3970
|
+
} else if (chain === "bitcoin") {
|
|
3971
|
+
const baseUrl = this.config.network === "mainnet" ? "https://blockstream.info/api" : "https://blockstream.info/testnet/api";
|
|
3972
|
+
try {
|
|
3973
|
+
const response = await fetch(`${baseUrl}/address/${address}`, {
|
|
3974
|
+
headers: { "Accept": "application/json" }
|
|
3975
|
+
});
|
|
3976
|
+
if (response.ok) {
|
|
3977
|
+
const data = await response.json();
|
|
3978
|
+
const chainFunded = data.chain_stats?.funded_txo_sum || 0;
|
|
3979
|
+
const chainSpent = data.chain_stats?.spent_txo_sum || 0;
|
|
3980
|
+
const mempoolFunded = data.mempool_stats?.funded_txo_sum || 0;
|
|
3981
|
+
const mempoolSpent = data.mempool_stats?.spent_txo_sum || 0;
|
|
3982
|
+
const satoshis = chainFunded - chainSpent + (mempoolFunded - mempoolSpent);
|
|
3983
|
+
balance = (satoshis / 1e8).toFixed(8);
|
|
3984
|
+
}
|
|
3985
|
+
} catch (error) {
|
|
3986
|
+
console.warn(`Failed to fetch ${chain} balance:`, error);
|
|
3987
|
+
}
|
|
3988
|
+
} else if (chain === "solana") {
|
|
3989
|
+
const rpcUrl = this.config.network === "mainnet" ? "https://api.mainnet-beta.solana.com" : "https://api.devnet.solana.com";
|
|
3990
|
+
try {
|
|
3991
|
+
const response = await fetch(rpcUrl, {
|
|
3992
|
+
method: "POST",
|
|
3993
|
+
headers: { "Content-Type": "application/json" },
|
|
3994
|
+
body: JSON.stringify({
|
|
3995
|
+
jsonrpc: "2.0",
|
|
3996
|
+
id: 1,
|
|
3997
|
+
method: "getBalance",
|
|
3998
|
+
params: [address]
|
|
3999
|
+
})
|
|
4000
|
+
});
|
|
4001
|
+
if (response.ok) {
|
|
4002
|
+
const data = await response.json();
|
|
4003
|
+
if (data.result?.value !== void 0) {
|
|
4004
|
+
balance = (data.result.value / 1e9).toFixed(9);
|
|
4005
|
+
}
|
|
4006
|
+
}
|
|
4007
|
+
} catch (error) {
|
|
4008
|
+
console.warn(`Failed to fetch ${chain} balance:`, error);
|
|
4009
|
+
}
|
|
4010
|
+
} else if (chain === "tron") {
|
|
4011
|
+
const baseUrl = this.config.network === "mainnet" ? "https://api.trongrid.io" : "https://api.shasta.trongrid.io";
|
|
4012
|
+
try {
|
|
4013
|
+
const response = await fetch(`${baseUrl}/v1/accounts/${address}`, {
|
|
4014
|
+
headers: { "Accept": "application/json" }
|
|
4015
|
+
});
|
|
4016
|
+
if (response.ok) {
|
|
4017
|
+
const data = await response.json();
|
|
4018
|
+
if (data.data?.[0]?.balance !== void 0) {
|
|
4019
|
+
balance = (data.data[0].balance / 1e6).toFixed(6);
|
|
4020
|
+
}
|
|
4021
|
+
}
|
|
4022
|
+
} catch (error) {
|
|
4023
|
+
console.warn(`Failed to fetch ${chain} balance:`, error);
|
|
4024
|
+
}
|
|
3970
4025
|
}
|
|
3971
4026
|
return {
|
|
3972
4027
|
chain,
|