@gardenfi/wallet-connectors 2.0.4-beta.7 → 2.0.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/index4.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@catalogfi/utils"),p={testnet:{Mempool:"https://mempool.space/testnet4"},mainnet:{Mempool:"https://mempool.space",Blockstream:"https://blockstream.info"}
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@catalogfi/utils"),p={testnet:{Mempool:"https://mempool.space/testnet4"},mainnet:{Mempool:"https://mempool.space",Blockstream:"https://blockstream.info"}},u=async(n,m)=>{const t=p[m];if(!t)return o.Err("Invalid network");const r="Blockstream"in t?`${t.Blockstream}/api/address/${n}`:null,a=`${t.Mempool}/api/address/${n}`;try{const s=r?[r,a]:[a],e=await o.Fetcher.getWithFallback(s,{retryCount:3,retryDelay:1e3}),c=e.chain_stats.funded_txo_sum-e.chain_stats.spent_txo_sum,l=e.mempool_stats.funded_txo_sum-e.mempool_stats.spent_txo_sum,i=c+l;return o.Ok({confirmed:c,unconfirmed:l,total:i})}catch(s){return o.Err("Error while fetching balance",s)}};exports.getBalance=u;
|
package/dist/index4.js
CHANGED
|
@@ -1,28 +1,25 @@
|
|
|
1
|
-
import { Err as l, Fetcher as
|
|
2
|
-
const
|
|
1
|
+
import { Err as l, Fetcher as p, Ok as u } from "@catalogfi/utils";
|
|
2
|
+
const h = {
|
|
3
3
|
testnet: {
|
|
4
4
|
Mempool: "https://mempool.space/testnet4"
|
|
5
5
|
},
|
|
6
6
|
mainnet: {
|
|
7
7
|
Mempool: "https://mempool.space",
|
|
8
8
|
Blockstream: "https://blockstream.info"
|
|
9
|
-
},
|
|
10
|
-
localnet: {
|
|
11
|
-
Mempool: "http://localhost:30000"
|
|
12
9
|
}
|
|
13
10
|
}, d = async (s, m) => {
|
|
14
|
-
const t =
|
|
11
|
+
const t = h[m];
|
|
15
12
|
if (!t) return l("Invalid network");
|
|
16
|
-
const n = "Blockstream" in t ? `${t.Blockstream}/api/address/${s}` : null,
|
|
13
|
+
const n = "Blockstream" in t ? `${t.Blockstream}/api/address/${s}` : null, r = `${t.Mempool}/api/address/${s}`;
|
|
17
14
|
try {
|
|
18
|
-
const e = n ? [n,
|
|
15
|
+
const e = n ? [n, r] : [r], o = await p.getWithFallback(e, {
|
|
19
16
|
retryCount: 3,
|
|
20
17
|
retryDelay: 1e3
|
|
21
|
-
}),
|
|
22
|
-
return
|
|
23
|
-
confirmed:
|
|
18
|
+
}), a = o.chain_stats.funded_txo_sum - o.chain_stats.spent_txo_sum, c = o.mempool_stats.funded_txo_sum - o.mempool_stats.spent_txo_sum, i = a + c;
|
|
19
|
+
return u({
|
|
20
|
+
confirmed: a,
|
|
24
21
|
unconfirmed: c,
|
|
25
|
-
total:
|
|
22
|
+
total: i
|
|
26
23
|
});
|
|
27
24
|
} catch (e) {
|
|
28
25
|
return l("Error while fetching balance", e);
|
|
@@ -13,7 +13,7 @@ export declare class UnisatProvider implements IInjectedBitcoinProvider {
|
|
|
13
13
|
connect(network?: Network): AsyncResult<Connect, string>;
|
|
14
14
|
requestAccounts(): Promise<import('@catalogfi/utils').Result<string[], string>>;
|
|
15
15
|
getAccounts(): Promise<import('@catalogfi/utils').Result<string[], string>>;
|
|
16
|
-
getNetwork(): Promise<import('@catalogfi/utils').Result<Network
|
|
16
|
+
getNetwork(): Promise<import('@catalogfi/utils').Result<Network, string>>;
|
|
17
17
|
switchNetwork(): AsyncResult<Network, string>;
|
|
18
18
|
getBalance(): Promise<import('@catalogfi/utils').Result<{
|
|
19
19
|
confirmed: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gardenfi/wallet-connectors",
|
|
3
|
-
"version": "2.0.4
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "vite build",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@catalogfi/utils": "^0.1.11",
|
|
40
40
|
"@catalogfi/wallets": "^0.2.54",
|
|
41
|
-
"@gardenfi/utils": "2.1.3
|
|
41
|
+
"@gardenfi/utils": "2.1.3",
|
|
42
42
|
"axios": "^1.7.9",
|
|
43
43
|
"bitcoinjs-lib": "^7.0.0-rc.0",
|
|
44
44
|
"react": "^18.3.1",
|