@dynamic-labs/bitcoin 4.91.1 → 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 +36 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +9 -9
- 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.d.ts +16 -16
- 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,40 @@
|
|
|
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
|
+
|
|
14
|
+
### [4.91.2](https://github.com/dynamic-labs/dynamic-auth/compare/v4.91.1...v4.91.2) (2026-06-26)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### ⚠ BREAKING CHANGES
|
|
18
|
+
|
|
19
|
+
* **waas:** require expectedAddresses on migrateFromFireblocks (#11730)
|
|
20
|
+
|
|
21
|
+
### Features
|
|
22
|
+
|
|
23
|
+
* **midnight:** support shielded/unshielded transfers and dust states in the embedded Send flow ([#11731](https://github.com/dynamic-labs/dynamic-auth/issues/11731)) ([663d171](https://github.com/dynamic-labs/dynamic-auth/commit/663d171a9628c634586831ee35c234e9331e3f80))
|
|
24
|
+
* **react-native-extension:** instrument all embedded webview failure paths ([#11737](https://github.com/dynamic-labs/dynamic-auth/issues/11737)) ([172998b](https://github.com/dynamic-labs/dynamic-auth/commit/172998b56e9bee04fbb8da71e83ce8885bc378ff))
|
|
25
|
+
* **waas:** migrateFromFireblocks connector method + demo panel (browser-wallet-client 1.0.46) ([#11702](https://github.com/dynamic-labs/dynamic-auth/issues/11702)) ([6bfc844](https://github.com/dynamic-labs/dynamic-auth/commit/6bfc8443fbaedabe1e7bee0ed78742cbbe5d0084))
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Bug Fixes
|
|
29
|
+
|
|
30
|
+
* add coverage for scenario with passkey re-login and smart account ([#11726](https://github.com/dynamic-labs/dynamic-auth/issues/11726)) ([5364a72](https://github.com/dynamic-labs/dynamic-auth/commit/5364a72a750d835b9b2da602a91e8b5d7d305db7))
|
|
31
|
+
* remediate high-severity dependency vulnerabilities ([#11721](https://github.com/dynamic-labs/dynamic-auth/issues/11721)) ([cdb9306](https://github.com/dynamic-labs/dynamic-auth/commit/cdb93061365a20b8f73a1f8bea8352332e282c1e))
|
|
32
|
+
* replace node-fetch v2 with native fetch to fix Node 22 stream failure ([#11732](https://github.com/dynamic-labs/dynamic-auth/issues/11732)) ([b98f801](https://github.com/dynamic-labs/dynamic-auth/commit/b98f801e307b52dbd7e4b241a9a4a2d34d89118e))
|
|
33
|
+
* **zerodev-extension:** derive kernel 7702 vs 4337 per-wallet, not from global dashboard flag ([#11735](https://github.com/dynamic-labs/dynamic-auth/issues/11735)) ([72cf6a7](https://github.com/dynamic-labs/dynamic-auth/commit/72cf6a70a4857a4ea469faa555c485dbad8d0217))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
* **waas:** require expectedAddresses on migrateFromFireblocks ([#11730](https://github.com/dynamic-labs/dynamic-auth/issues/11730)) ([c94824e](https://github.com/dynamic-labs/dynamic-auth/commit/c94824ebe11e0433a6ffbd2a5a9dd4283aeed31e))
|
|
37
|
+
|
|
2
38
|
### [4.91.1](https://github.com/dynamic-labs/dynamic-auth/compare/v4.91.0...v4.91.1) (2026-06-24)
|
|
3
39
|
|
|
4
40
|
|
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",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"homepage": "https://www.dynamic.xyz/",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@dynamic-labs-wallet/browser-wallet-client": "1.0.
|
|
21
|
+
"@dynamic-labs-wallet/browser-wallet-client": "1.0.48",
|
|
22
22
|
"@dynamic-labs-wallet/forward-mpc-client": "0.12.0",
|
|
23
23
|
"@bitcoinerlab/secp256k1": "1.1.1",
|
|
24
24
|
"@btckit/types": "0.0.19",
|
|
@@ -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');
|
|
@@ -80,16 +80,22 @@ declare const DynamicWaasBitcoinConnector_base: (abstract new (...args: any[]) =
|
|
|
80
80
|
legacyWalletId?: string | undefined;
|
|
81
81
|
password?: string | undefined;
|
|
82
82
|
}): Promise<void>;
|
|
83
|
+
migrateFromFireblocks({ deviceId, jwt, walletPassword, ncwStorage, expectedAddresses, coinTypes, password, }: {
|
|
84
|
+
deviceId: string;
|
|
85
|
+
jwt: string;
|
|
86
|
+
walletPassword: string;
|
|
87
|
+
ncwStorage: Record<string, string>;
|
|
88
|
+
expectedAddresses: Record<string, string>;
|
|
89
|
+
coinTypes?: Record<string, number> | undefined;
|
|
90
|
+
password?: string | undefined;
|
|
91
|
+
}): Promise<import("@dynamic-labs-wallet/browser-wallet-client").MigrateFromFireblocksResponse>;
|
|
83
92
|
exportPrivateKey({ accountAddress, displayContainer, password, }?: {
|
|
84
93
|
accountAddress?: string | undefined;
|
|
85
94
|
displayContainer?: HTMLIFrameElement | undefined;
|
|
86
95
|
password?: string | undefined;
|
|
87
96
|
} | undefined): Promise<void>;
|
|
88
97
|
getExportHandler(): {
|
|
89
|
-
clear: () => void;
|
|
90
|
-
* Gets all connected account addresses
|
|
91
|
-
* @returns Array of connected account addresses (currently returns single active address)
|
|
92
|
-
*/
|
|
98
|
+
clear: () => void;
|
|
93
99
|
};
|
|
94
100
|
exportClientKeyshares({ accountAddress, password, }: {
|
|
95
101
|
accountAddress: string;
|
|
@@ -114,7 +120,11 @@ declare const DynamicWaasBitcoinConnector_base: (abstract new (...args: any[]) =
|
|
|
114
120
|
hideICloudSignIn(): Promise<void>;
|
|
115
121
|
isICloudAuthenticated(): Promise<boolean>;
|
|
116
122
|
refreshWalletAccountShares({ accountAddress, password, }: {
|
|
117
|
-
accountAddress: string;
|
|
123
|
+
accountAddress: string; /**
|
|
124
|
+
* Gets block explorer URLs for the current network
|
|
125
|
+
* Returns mempool.space for Bitcoin transactions
|
|
126
|
+
* @returns Array containing mempool.space URL
|
|
127
|
+
*/
|
|
118
128
|
password?: string | undefined;
|
|
119
129
|
}): Promise<void>;
|
|
120
130
|
reshareWalletAccountShares({ accountAddress, thresholdSignatureScheme, password, }: {
|
|
@@ -134,11 +144,7 @@ declare const DynamicWaasBitcoinConnector_base: (abstract new (...args: any[]) =
|
|
|
134
144
|
setPassword({ accountAddress, newPassword, }: {
|
|
135
145
|
accountAddress: string;
|
|
136
146
|
newPassword: string;
|
|
137
|
-
}): Promise<void>;
|
|
138
|
-
* Signs a message using the wallet UI utils for user interaction
|
|
139
|
-
* @param message - The message to sign
|
|
140
|
-
* @returns The signed message as a string
|
|
141
|
-
*/
|
|
147
|
+
}): Promise<void>;
|
|
142
148
|
signRawMessage({ accountAddress, message, password, }: {
|
|
143
149
|
accountAddress: string;
|
|
144
150
|
message: string;
|
|
@@ -165,12 +171,6 @@ declare const DynamicWaasBitcoinConnector_base: (abstract new (...args: any[]) =
|
|
|
165
171
|
errorType?: undefined;
|
|
166
172
|
};
|
|
167
173
|
instrument(message: string, context: import("@dynamic-labs/logger").InstrumentOptions & import("dist/packages/waas/utils/instrumentation").InstrumentContext & Record<string, any>): void;
|
|
168
|
-
/**
|
|
169
|
-
* Sends a raw Bitcoin transaction to the mempool
|
|
170
|
-
* @param rawTransaction - The raw transaction in hex format
|
|
171
|
-
* @returns The transaction ID
|
|
172
|
-
* @throws {DynamicError} If no transaction is specified or sending fails
|
|
173
|
-
*/
|
|
174
174
|
instrumentAsync<T_1>({ operation, resource, fn, context, }: {
|
|
175
175
|
operation: string;
|
|
176
176
|
resource: string;
|
|
@@ -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 };
|