@dynamic-labs/bitcoin 4.91.2 → 4.91.3
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/CHANGELOG.md +12 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +8 -8
- package/src/connectors/BitcoinWalletConnector.cjs +13 -2
- package/src/connectors/BitcoinWalletConnector.js +13 -2
- package/src/connectors/DynamicWaasBitcoinConnector/DynamicWaasBitcoinConnector.cjs +1 -0
- package/src/connectors/DynamicWaasBitcoinConnector/DynamicWaasBitcoinConnector.js +1 -0
- package/src/index.cjs +1 -0
- package/src/index.js +1 -1
- package/src/utils/fetchSatsConnectConnectors/fetchSatsConnectConnectors.cjs +75 -4
- package/src/utils/fetchSatsConnectConnectors/fetchSatsConnectConnectors.d.ts +5 -0
- package/src/utils/fetchSatsConnectConnectors/fetchSatsConnectConnectors.js +75 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
|
|
2
|
+
### [4.91.3](https://github.com/dynamic-labs/dynamic-auth/compare/v4.91.2...v4.91.3) (2026-06-30)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* **bitcoin:** detect late-registering wallet-standard wallets (DYNT-1210) ([#11747](https://github.com/dynamic-labs/dynamic-auth/issues/11747)) ([17809f6](https://github.com/dynamic-labs/dynamic-auth/commit/17809f6e811fe101367cc31a2d899a8d0b0d107e))
|
|
8
|
+
* fetch onramp providers lazily instead of eagerly on mount ([#11767](https://github.com/dynamic-labs/dynamic-auth/issues/11767)) ([3ee6708](https://github.com/dynamic-labs/dynamic-auth/commit/3ee67087142ae1942f865e0ab37b7108700b3327))
|
|
9
|
+
* **iframe-setup:** sync parent URL to iframe on pushState/replaceState ([#11751](https://github.com/dynamic-labs/dynamic-auth/issues/11751)) ([c8be3af](https://github.com/dynamic-labs/dynamic-auth/commit/c8be3afc301f77b349f23398bed940ce40f93b73))
|
|
10
|
+
* **nonce:** fetch nonce on demand when missing before wallet verification ([#11753](https://github.com/dynamic-labs/dynamic-auth/issues/11753)) ([4f01a21](https://github.com/dynamic-labs/dynamic-auth/commit/4f01a21b6081c852f32868c8a5e04d70aaf280a2)), closes [#1](https://github.com/dynamic-labs/dynamic-auth/issues/1)
|
|
11
|
+
* **react-native-extension:** arm loading timer before setUrl to cover pre-onLoadStart gap ([#11764](https://github.com/dynamic-labs/dynamic-auth/issues/11764)) ([31f2015](https://github.com/dynamic-labs/dynamic-auth/commit/31f20151a4b59279f9c133b723e50de771b06436))
|
|
12
|
+
* **webview-controller:** unwrap ZeroDev smart wallet for native gasless ([#11758](https://github.com/dynamic-labs/dynamic-auth/issues/11758)) ([989714e](https://github.com/dynamic-labs/dynamic-auth/commit/989714e414556868c8e0c54401aac1ed7354331b))
|
|
13
|
+
|
|
2
14
|
### [4.91.2](https://github.com/dynamic-labs/dynamic-auth/compare/v4.91.1...v4.91.2) (2026-06-26)
|
|
3
15
|
|
|
4
16
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/bitcoin",
|
|
3
|
-
"version": "4.91.
|
|
3
|
+
"version": "4.91.3",
|
|
4
4
|
"description": "A React SDK for implementing wallet web3 authentication and authorization to your website.",
|
|
5
5
|
"author": "Dynamic Labs, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -29,13 +29,13 @@
|
|
|
29
29
|
"ecpair": "2.1.0",
|
|
30
30
|
"sats-connect": "4.2.1",
|
|
31
31
|
"jsontokens": "4.0.1",
|
|
32
|
-
"@dynamic-labs/assert-package-version": "4.91.
|
|
33
|
-
"@dynamic-labs/logger": "4.91.
|
|
34
|
-
"@dynamic-labs/types": "4.91.
|
|
35
|
-
"@dynamic-labs/utils": "4.91.
|
|
36
|
-
"@dynamic-labs/waas": "4.91.
|
|
37
|
-
"@dynamic-labs/wallet-book": "4.91.
|
|
38
|
-
"@dynamic-labs/wallet-connector-core": "4.91.
|
|
32
|
+
"@dynamic-labs/assert-package-version": "4.91.3",
|
|
33
|
+
"@dynamic-labs/logger": "4.91.3",
|
|
34
|
+
"@dynamic-labs/types": "4.91.3",
|
|
35
|
+
"@dynamic-labs/utils": "4.91.3",
|
|
36
|
+
"@dynamic-labs/waas": "4.91.3",
|
|
37
|
+
"@dynamic-labs/wallet-book": "4.91.3",
|
|
38
|
+
"@dynamic-labs/wallet-connector-core": "4.91.3",
|
|
39
39
|
"eventemitter3": "5.0.1"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {}
|
|
@@ -54,8 +54,19 @@ class BitcoinWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
54
54
|
return Boolean((_a = this.metadata.supportedHardwareWallets) === null || _a === void 0 ? void 0 : _a.includes('ledger'));
|
|
55
55
|
}
|
|
56
56
|
isInstalledOnBrowser() {
|
|
57
|
-
var _a;
|
|
58
|
-
|
|
57
|
+
var _a, _b, _c;
|
|
58
|
+
// Re-run the wallet-standard lookup on each call so that a wallet which
|
|
59
|
+
// registered after the constructor ran (late injection via wallet-standard)
|
|
60
|
+
// is picked up by the existing useReconcileInstalledWallets poll.
|
|
61
|
+
if (!this.wallet) {
|
|
62
|
+
const found = (_a = this.bitcoinProviderHelper) === null || _a === void 0 ? void 0 : _a.findWallet();
|
|
63
|
+
if (found) {
|
|
64
|
+
this.wallet = found;
|
|
65
|
+
this.walletMethods =
|
|
66
|
+
(_b = this.bitcoinProviderHelper) === null || _b === void 0 ? void 0 : _b.getWalletMethods(found);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return (Boolean(this.wallet) || Boolean((_c = this.bitcoinProviderHelper) === null || _c === void 0 ? void 0 : _c.getProvider()));
|
|
59
70
|
}
|
|
60
71
|
getDeepLink() {
|
|
61
72
|
return undefined;
|
|
@@ -50,8 +50,19 @@ class BitcoinWalletConnector extends WalletConnectorBase {
|
|
|
50
50
|
return Boolean((_a = this.metadata.supportedHardwareWallets) === null || _a === void 0 ? void 0 : _a.includes('ledger'));
|
|
51
51
|
}
|
|
52
52
|
isInstalledOnBrowser() {
|
|
53
|
-
var _a;
|
|
54
|
-
|
|
53
|
+
var _a, _b, _c;
|
|
54
|
+
// Re-run the wallet-standard lookup on each call so that a wallet which
|
|
55
|
+
// registered after the constructor ran (late injection via wallet-standard)
|
|
56
|
+
// is picked up by the existing useReconcileInstalledWallets poll.
|
|
57
|
+
if (!this.wallet) {
|
|
58
|
+
const found = (_a = this.bitcoinProviderHelper) === null || _a === void 0 ? void 0 : _a.findWallet();
|
|
59
|
+
if (found) {
|
|
60
|
+
this.wallet = found;
|
|
61
|
+
this.walletMethods =
|
|
62
|
+
(_b = this.bitcoinProviderHelper) === null || _b === void 0 ? void 0 : _b.getWalletMethods(found);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return (Boolean(this.wallet) || Boolean((_c = this.bitcoinProviderHelper) === null || _c === void 0 ? void 0 : _c.getProvider()));
|
|
55
66
|
}
|
|
56
67
|
getDeepLink() {
|
|
57
68
|
return undefined;
|
|
@@ -14,6 +14,7 @@ var MempoolApiService = require('../../services/MempoolApiService.cjs');
|
|
|
14
14
|
var PsbtBuilderService = require('../../services/PsbtBuilderService.cjs');
|
|
15
15
|
require('sats-connect');
|
|
16
16
|
var BitcoinWalletConnector = require('../BitcoinWalletConnector.cjs');
|
|
17
|
+
require('@wallet-standard/app');
|
|
17
18
|
require('jsontokens');
|
|
18
19
|
var btcToSatoshis = require('../../utils/btcToSatoshis/btcToSatoshis.cjs');
|
|
19
20
|
var PsbtParser = require('../../utils/psbtParser/PsbtParser.cjs');
|
|
@@ -10,6 +10,7 @@ import { MempoolApiService } from '../../services/MempoolApiService.js';
|
|
|
10
10
|
import { PsbtBuilderService } from '../../services/PsbtBuilderService.js';
|
|
11
11
|
import 'sats-connect';
|
|
12
12
|
import { BitcoinWalletConnector } from '../BitcoinWalletConnector.js';
|
|
13
|
+
import '@wallet-standard/app';
|
|
13
14
|
import 'jsontokens';
|
|
14
15
|
import { btcToSatoshis } from '../../utils/btcToSatoshis/btcToSatoshis.js';
|
|
15
16
|
import { PsbtParser } from '../../utils/psbtParser/PsbtParser.js';
|
package/src/index.cjs
CHANGED
|
@@ -58,6 +58,7 @@ exports.UnisatConnector = UnisatConnector.UnisatConnector;
|
|
|
58
58
|
exports.DynamicWaasBitcoinConnector = DynamicWaasBitcoinConnector.DynamicWaasBitcoinConnector;
|
|
59
59
|
exports.fetchBtcKitConnectors = fetchBtcKitConnectors.fetchBtcKitConnectors;
|
|
60
60
|
exports.fetchSatsConnectConnectors = fetchSatsConnectConnectors.fetchSatsConnectConnectors;
|
|
61
|
+
exports.stopBitcoinSatsConnectDiscovery = fetchSatsConnectConnectors.stopBitcoinSatsConnectDiscovery;
|
|
61
62
|
exports.hasSatsConnectFeature = hasSatsConnectFeature.hasSatsConnectFeature;
|
|
62
63
|
exports.getMempoolApiUrl = getMempoolApiUrl.getMempoolApiUrl;
|
|
63
64
|
exports.createPsbtOptions = createSignPsbtOptions.createPsbtOptions;
|
package/src/index.js
CHANGED
|
@@ -23,7 +23,7 @@ import { BitgetConnector } from './connectors/BitgetConnector/BitgetConnector.js
|
|
|
23
23
|
import { fetchBtcKitConnectors } from './utils/fetchBtcKitConnectors/fetchBtcKitConnectors.js';
|
|
24
24
|
export { fetchBtcKitConnectors } from './utils/fetchBtcKitConnectors/fetchBtcKitConnectors.js';
|
|
25
25
|
import { fetchSatsConnectConnectors } from './utils/fetchSatsConnectConnectors/fetchSatsConnectConnectors.js';
|
|
26
|
-
export { fetchSatsConnectConnectors } from './utils/fetchSatsConnectConnectors/fetchSatsConnectConnectors.js';
|
|
26
|
+
export { fetchSatsConnectConnectors, stopBitcoinSatsConnectDiscovery } from './utils/fetchSatsConnectConnectors/fetchSatsConnectConnectors.js';
|
|
27
27
|
export { hasSatsConnectFeature } from './utils/hasSatsConnectFeature.js';
|
|
28
28
|
export { getMempoolApiUrl } from './utils/getMempoolApiUrl.js';
|
|
29
29
|
export { createPsbtOptions } from './utils/psbt/createSignPsbtOptions.js';
|
|
@@ -3,22 +3,92 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
+
var app = require('@wallet-standard/app');
|
|
7
|
+
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
6
8
|
require('../../../_virtual/_tslib.cjs');
|
|
7
9
|
require('sats-connect');
|
|
8
|
-
require('@dynamic-labs/wallet-connector-core');
|
|
9
10
|
require('@dynamic-labs/wallet-book');
|
|
10
11
|
require('@dynamic-labs/utils');
|
|
11
12
|
require('@dynamic-labs/sdk-api-core');
|
|
12
|
-
require('@wallet-standard/app');
|
|
13
13
|
var _const = require('../../const.cjs');
|
|
14
14
|
require('bitcoinjs-lib');
|
|
15
15
|
var BitcoinSatsConnectConnector = require('../../connectors/BitcoinSatsConnectConnector/BitcoinSatsConnectConnector.cjs');
|
|
16
16
|
require('jsontokens');
|
|
17
17
|
require('../../connectors/DynamicWaasBitcoinConnector/DynamicWaasBitcoinConnector.cjs');
|
|
18
|
+
var hasSatsConnectFeature = require('../hasSatsConnectFeature.cjs');
|
|
18
19
|
|
|
20
|
+
const BITCOIN_SATSCONNECT_POLL_INTERVAL_MS = 300;
|
|
21
|
+
const BITCOIN_SATSCONNECT_POLL_DURATION_MS = 5000;
|
|
22
|
+
let teardownBitcoinSatsConnectDiscovery = null;
|
|
23
|
+
/**
|
|
24
|
+
* Stops the active SatsConnect wallet-standard discovery (register listener + poll).
|
|
25
|
+
* @internal - Exposed for test cleanup.
|
|
26
|
+
*/
|
|
27
|
+
const stopBitcoinSatsConnectDiscovery = () => {
|
|
28
|
+
teardownBitcoinSatsConnectDiscovery === null || teardownBitcoinSatsConnectDiscovery === void 0 ? void 0 : teardownBitcoinSatsConnectDiscovery();
|
|
29
|
+
teardownBitcoinSatsConnectDiscovery = null;
|
|
30
|
+
};
|
|
31
|
+
const findSatsConnectWalletBookEntry = (walletName, walletBook) => {
|
|
32
|
+
var _a;
|
|
33
|
+
return Object.entries((_a = walletBook === null || walletBook === void 0 ? void 0 : walletBook.wallets) !== null && _a !== void 0 ? _a : {}).find(([, walletData]) => {
|
|
34
|
+
var _a;
|
|
35
|
+
return (_a = walletData.injectedConfig) === null || _a === void 0 ? void 0 : _a.some((config) => {
|
|
36
|
+
var _a, _b;
|
|
37
|
+
return config.chain === 'btc' &&
|
|
38
|
+
((_a = config.walletStandard) === null || _a === void 0 ? void 0 : _a.features.includes(_const.SATSCONNECT_FEATURE)) &&
|
|
39
|
+
((_b = config.walletStandard) === null || _b === void 0 ? void 0 : _b.providerId) &&
|
|
40
|
+
walletData.name === walletName;
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
const setupBitcoinSatsConnectDiscovery = (walletBook) => {
|
|
45
|
+
if (typeof window === 'undefined')
|
|
46
|
+
return;
|
|
47
|
+
teardownBitcoinSatsConnectDiscovery === null || teardownBitcoinSatsConnectDiscovery === void 0 ? void 0 : teardownBitcoinSatsConnectDiscovery();
|
|
48
|
+
const discoveredWallets = new Set();
|
|
49
|
+
const { get, on } = app.getWallets();
|
|
50
|
+
const initialWallets = get();
|
|
51
|
+
// Seed already-present wallets so the listener and poll skip them.
|
|
52
|
+
initialWallets.forEach((wallet) => {
|
|
53
|
+
if (hasSatsConnectFeature.hasSatsConnectFeature(wallet.features) &&
|
|
54
|
+
findSatsConnectWalletBookEntry(wallet.name, walletBook)) {
|
|
55
|
+
discoveredWallets.add(wallet.name);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
const handleWallet = (wallet) => {
|
|
59
|
+
if (discoveredWallets.has(wallet.name))
|
|
60
|
+
return;
|
|
61
|
+
if (!hasSatsConnectFeature.hasSatsConnectFeature(wallet.features))
|
|
62
|
+
return;
|
|
63
|
+
const entry = findSatsConnectWalletBookEntry(wallet.name, walletBook);
|
|
64
|
+
if (!entry)
|
|
65
|
+
return;
|
|
66
|
+
discoveredWallets.add(wallet.name);
|
|
67
|
+
const [key, walletData] = entry;
|
|
68
|
+
const connectorName = walletData.shortName || walletData.name;
|
|
69
|
+
const injectedConnectorConstructor = class extends BitcoinSatsConnectConnector.BitcoinSatsConnectConnector {
|
|
70
|
+
constructor(props) {
|
|
71
|
+
super(Object.assign(Object.assign({}, props), { overrideKey: key, walletData }));
|
|
72
|
+
this.name = connectorName;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
walletConnectorCore.walletConnectorEvents.emit('providerInjected', {
|
|
76
|
+
injectedConnectorConstructor,
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
const removeRegisterListener = on('register', handleWallet);
|
|
80
|
+
const pollIntervalId = setInterval(() => get().forEach(handleWallet), BITCOIN_SATSCONNECT_POLL_INTERVAL_MS);
|
|
81
|
+
const pollTimeoutId = setTimeout(() => clearInterval(pollIntervalId), BITCOIN_SATSCONNECT_POLL_DURATION_MS);
|
|
82
|
+
teardownBitcoinSatsConnectDiscovery = () => {
|
|
83
|
+
removeRegisterListener === null || removeRegisterListener === void 0 ? void 0 : removeRegisterListener();
|
|
84
|
+
clearInterval(pollIntervalId);
|
|
85
|
+
clearTimeout(pollTimeoutId);
|
|
86
|
+
};
|
|
87
|
+
};
|
|
19
88
|
const fetchSatsConnectConnectors = ({ walletBook, }) => {
|
|
20
89
|
var _a;
|
|
21
|
-
|
|
90
|
+
setupBitcoinSatsConnectDiscovery(walletBook);
|
|
91
|
+
return (Object.entries((_a = walletBook === null || walletBook === void 0 ? void 0 : walletBook.wallets) !== null && _a !== void 0 ? _a : {})
|
|
22
92
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
23
93
|
.filter(([_, wallet]) => {
|
|
24
94
|
var _a;
|
|
@@ -38,7 +108,8 @@ const fetchSatsConnectConnectors = ({ walletBook, }) => {
|
|
|
38
108
|
this.name = name;
|
|
39
109
|
}
|
|
40
110
|
};
|
|
41
|
-
});
|
|
111
|
+
}));
|
|
42
112
|
};
|
|
43
113
|
|
|
44
114
|
exports.fetchSatsConnectConnectors = fetchSatsConnectConnectors;
|
|
115
|
+
exports.stopBitcoinSatsConnectDiscovery = stopBitcoinSatsConnectDiscovery;
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { WalletBookSchema } from '@dynamic-labs/wallet-book';
|
|
2
2
|
import { WalletConnectorConstructor } from '@dynamic-labs/wallet-connector-core';
|
|
3
|
+
/**
|
|
4
|
+
* Stops the active SatsConnect wallet-standard discovery (register listener + poll).
|
|
5
|
+
* @internal - Exposed for test cleanup.
|
|
6
|
+
*/
|
|
7
|
+
export declare const stopBitcoinSatsConnectDiscovery: () => void;
|
|
3
8
|
export declare const fetchSatsConnectConnectors: ({ walletBook, }: {
|
|
4
9
|
walletBook: WalletBookSchema;
|
|
5
10
|
}) => WalletConnectorConstructor[];
|
|
@@ -1,20 +1,90 @@
|
|
|
1
1
|
'use client'
|
|
2
|
+
import { getWallets } from '@wallet-standard/app';
|
|
3
|
+
import { walletConnectorEvents } from '@dynamic-labs/wallet-connector-core';
|
|
2
4
|
import '../../../_virtual/_tslib.js';
|
|
3
5
|
import 'sats-connect';
|
|
4
|
-
import '@dynamic-labs/wallet-connector-core';
|
|
5
6
|
import '@dynamic-labs/wallet-book';
|
|
6
7
|
import '@dynamic-labs/utils';
|
|
7
8
|
import '@dynamic-labs/sdk-api-core';
|
|
8
|
-
import '@wallet-standard/app';
|
|
9
9
|
import { SATSCONNECT_FEATURE } from '../../const.js';
|
|
10
10
|
import 'bitcoinjs-lib';
|
|
11
11
|
import { BitcoinSatsConnectConnector } from '../../connectors/BitcoinSatsConnectConnector/BitcoinSatsConnectConnector.js';
|
|
12
12
|
import 'jsontokens';
|
|
13
13
|
import '../../connectors/DynamicWaasBitcoinConnector/DynamicWaasBitcoinConnector.js';
|
|
14
|
+
import { hasSatsConnectFeature } from '../hasSatsConnectFeature.js';
|
|
14
15
|
|
|
16
|
+
const BITCOIN_SATSCONNECT_POLL_INTERVAL_MS = 300;
|
|
17
|
+
const BITCOIN_SATSCONNECT_POLL_DURATION_MS = 5000;
|
|
18
|
+
let teardownBitcoinSatsConnectDiscovery = null;
|
|
19
|
+
/**
|
|
20
|
+
* Stops the active SatsConnect wallet-standard discovery (register listener + poll).
|
|
21
|
+
* @internal - Exposed for test cleanup.
|
|
22
|
+
*/
|
|
23
|
+
const stopBitcoinSatsConnectDiscovery = () => {
|
|
24
|
+
teardownBitcoinSatsConnectDiscovery === null || teardownBitcoinSatsConnectDiscovery === void 0 ? void 0 : teardownBitcoinSatsConnectDiscovery();
|
|
25
|
+
teardownBitcoinSatsConnectDiscovery = null;
|
|
26
|
+
};
|
|
27
|
+
const findSatsConnectWalletBookEntry = (walletName, walletBook) => {
|
|
28
|
+
var _a;
|
|
29
|
+
return Object.entries((_a = walletBook === null || walletBook === void 0 ? void 0 : walletBook.wallets) !== null && _a !== void 0 ? _a : {}).find(([, walletData]) => {
|
|
30
|
+
var _a;
|
|
31
|
+
return (_a = walletData.injectedConfig) === null || _a === void 0 ? void 0 : _a.some((config) => {
|
|
32
|
+
var _a, _b;
|
|
33
|
+
return config.chain === 'btc' &&
|
|
34
|
+
((_a = config.walletStandard) === null || _a === void 0 ? void 0 : _a.features.includes(SATSCONNECT_FEATURE)) &&
|
|
35
|
+
((_b = config.walletStandard) === null || _b === void 0 ? void 0 : _b.providerId) &&
|
|
36
|
+
walletData.name === walletName;
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
const setupBitcoinSatsConnectDiscovery = (walletBook) => {
|
|
41
|
+
if (typeof window === 'undefined')
|
|
42
|
+
return;
|
|
43
|
+
teardownBitcoinSatsConnectDiscovery === null || teardownBitcoinSatsConnectDiscovery === void 0 ? void 0 : teardownBitcoinSatsConnectDiscovery();
|
|
44
|
+
const discoveredWallets = new Set();
|
|
45
|
+
const { get, on } = getWallets();
|
|
46
|
+
const initialWallets = get();
|
|
47
|
+
// Seed already-present wallets so the listener and poll skip them.
|
|
48
|
+
initialWallets.forEach((wallet) => {
|
|
49
|
+
if (hasSatsConnectFeature(wallet.features) &&
|
|
50
|
+
findSatsConnectWalletBookEntry(wallet.name, walletBook)) {
|
|
51
|
+
discoveredWallets.add(wallet.name);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
const handleWallet = (wallet) => {
|
|
55
|
+
if (discoveredWallets.has(wallet.name))
|
|
56
|
+
return;
|
|
57
|
+
if (!hasSatsConnectFeature(wallet.features))
|
|
58
|
+
return;
|
|
59
|
+
const entry = findSatsConnectWalletBookEntry(wallet.name, walletBook);
|
|
60
|
+
if (!entry)
|
|
61
|
+
return;
|
|
62
|
+
discoveredWallets.add(wallet.name);
|
|
63
|
+
const [key, walletData] = entry;
|
|
64
|
+
const connectorName = walletData.shortName || walletData.name;
|
|
65
|
+
const injectedConnectorConstructor = class extends BitcoinSatsConnectConnector {
|
|
66
|
+
constructor(props) {
|
|
67
|
+
super(Object.assign(Object.assign({}, props), { overrideKey: key, walletData }));
|
|
68
|
+
this.name = connectorName;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
walletConnectorEvents.emit('providerInjected', {
|
|
72
|
+
injectedConnectorConstructor,
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
const removeRegisterListener = on('register', handleWallet);
|
|
76
|
+
const pollIntervalId = setInterval(() => get().forEach(handleWallet), BITCOIN_SATSCONNECT_POLL_INTERVAL_MS);
|
|
77
|
+
const pollTimeoutId = setTimeout(() => clearInterval(pollIntervalId), BITCOIN_SATSCONNECT_POLL_DURATION_MS);
|
|
78
|
+
teardownBitcoinSatsConnectDiscovery = () => {
|
|
79
|
+
removeRegisterListener === null || removeRegisterListener === void 0 ? void 0 : removeRegisterListener();
|
|
80
|
+
clearInterval(pollIntervalId);
|
|
81
|
+
clearTimeout(pollTimeoutId);
|
|
82
|
+
};
|
|
83
|
+
};
|
|
15
84
|
const fetchSatsConnectConnectors = ({ walletBook, }) => {
|
|
16
85
|
var _a;
|
|
17
|
-
|
|
86
|
+
setupBitcoinSatsConnectDiscovery(walletBook);
|
|
87
|
+
return (Object.entries((_a = walletBook === null || walletBook === void 0 ? void 0 : walletBook.wallets) !== null && _a !== void 0 ? _a : {})
|
|
18
88
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
19
89
|
.filter(([_, wallet]) => {
|
|
20
90
|
var _a;
|
|
@@ -34,7 +104,7 @@ const fetchSatsConnectConnectors = ({ walletBook, }) => {
|
|
|
34
104
|
this.name = name;
|
|
35
105
|
}
|
|
36
106
|
};
|
|
37
|
-
});
|
|
107
|
+
}));
|
|
38
108
|
};
|
|
39
109
|
|
|
40
|
-
export { fetchSatsConnectConnectors };
|
|
110
|
+
export { fetchSatsConnectConnectors, stopBitcoinSatsConnectDiscovery };
|