@dynamic-labs/bitcoin 3.0.0-alpha.1 → 3.0.0-alpha.10
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 +124 -0
- package/package.json +5 -5
- package/src/bitcoinProviderHelper.d.ts +4 -0
- package/src/connectors/BitcoinSatsConnectConnector/BitcoinSatsConnectConnector.cjs +14 -11
- package/src/connectors/BitcoinSatsConnectConnector/BitcoinSatsConnectConnector.js +14 -11
- package/src/connectors/BitcoinWalletConnector.cjs +16 -2
- package/src/connectors/BitcoinWalletConnector.d.ts +3 -0
- package/src/connectors/BitcoinWalletConnector.js +16 -2
- package/src/connectors/FallbackBitcoinConnector/FallbackBitcoinConnector.cjs +38 -0
- package/src/connectors/FallbackBitcoinConnector/FallbackBitcoinConnector.d.ts +12 -0
- package/src/connectors/FallbackBitcoinConnector/FallbackBitcoinConnector.js +34 -0
- package/src/connectors/FallbackBitcoinConnector/index.d.ts +1 -0
- package/src/connectors/OkxConnector/OkxConnector.cjs +1 -1
- package/src/connectors/OkxConnector/OkxConnector.js +1 -1
- package/src/connectors/UnisatConnector/UnisatConnector.cjs +9 -0
- package/src/connectors/UnisatConnector/UnisatConnector.d.ts +1 -0
- package/src/connectors/UnisatConnector/UnisatConnector.js +9 -0
- package/src/connectors/index.d.ts +1 -0
- package/src/index.cjs +3 -1
- package/src/index.js +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,128 @@
|
|
|
1
1
|
|
|
2
|
+
## [3.0.0-alpha.10](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.9...v3.0.0-alpha.10) (2024-06-24)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* clear expiresAt from local storage on logout ([#6110](https://github.com/dynamic-labs/DynamicAuth/issues/6110)) ([cbda893](https://github.com/dynamic-labs/DynamicAuth/commit/cbda893441154b6880a5419ce62a353b80f05e55))
|
|
8
|
+
* show SOL amount for complex transactions and better error display ([#6068](https://github.com/dynamic-labs/DynamicAuth/issues/6068)) ([454a3a0](https://github.com/dynamic-labs/DynamicAuth/commit/454a3a0a50805b3d63f44c2ef8c1dc766617eb2b))
|
|
9
|
+
|
|
10
|
+
## [3.0.0-alpha.9](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.8...v3.0.0-alpha.9) (2024-06-21)
|
|
11
|
+
|
|
12
|
+
## [3.0.0-alpha.8](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.7...v3.0.0-alpha.8) (2024-06-21)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### ⚠ BREAKING CHANGES
|
|
16
|
+
|
|
17
|
+
* break out turnkey package into 3 separate packages (#6015)
|
|
18
|
+
|
|
19
|
+
### Features
|
|
20
|
+
|
|
21
|
+
* add reinitialize hook ([#6098](https://github.com/dynamic-labs/DynamicAuth/issues/6098)) ([d978baa](https://github.com/dynamic-labs/DynamicAuth/commit/d978baa404d34064c36cc549229b1fcea1f20df0))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Bug Fixes
|
|
25
|
+
|
|
26
|
+
* always reconnect the wallet provider when calling getAddress ([#6097](https://github.com/dynamic-labs/DynamicAuth/issues/6097)) ([0f3d497](https://github.com/dynamic-labs/DynamicAuth/commit/0f3d497cedb38239fa9ada2bb25c6b4eaa72d7b1))
|
|
27
|
+
* break out turnkey package into 3 separate packages ([#6015](https://github.com/dynamic-labs/DynamicAuth/issues/6015)) ([a86fbef](https://github.com/dynamic-labs/DynamicAuth/commit/a86fbefe97558363b085e6f752af32d2943f91fa)), closes [#6017](https://github.com/dynamic-labs/DynamicAuth/issues/6017) [#6059](https://github.com/dynamic-labs/DynamicAuth/issues/6059)
|
|
28
|
+
* set latest blockhash on solana transactions if tx confirmation ui is disabled ([#6102](https://github.com/dynamic-labs/DynamicAuth/issues/6102)) ([b8035a3](https://github.com/dynamic-labs/DynamicAuth/commit/b8035a328e47409bf0416d3a01b2f17914488748))
|
|
29
|
+
* silently query unisat accounts ([#6101](https://github.com/dynamic-labs/DynamicAuth/issues/6101)) ([#6104](https://github.com/dynamic-labs/DynamicAuth/issues/6104)) ([643e704](https://github.com/dynamic-labs/DynamicAuth/commit/643e7048ff8610b31e6397e10b160ad456a45d11))
|
|
30
|
+
* stop querying magiceden solana accounts ([#6103](https://github.com/dynamic-labs/DynamicAuth/issues/6103)) ([#6108](https://github.com/dynamic-labs/DynamicAuth/issues/6108)) ([3cfdbc3](https://github.com/dynamic-labs/DynamicAuth/commit/3cfdbc3bc82bfe9bf53bf4236f7892a5440fcb86))
|
|
31
|
+
* trigger sign when linking an already linked unknown wallet ([#6105](https://github.com/dynamic-labs/DynamicAuth/issues/6105)) ([9e9c03b](https://github.com/dynamic-labs/DynamicAuth/commit/9e9c03bf615991c4f1183bf85c4d75c9a7773c85))
|
|
32
|
+
|
|
33
|
+
## [3.0.0-alpha.7](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.6...v3.0.0-alpha.7) (2024-06-19)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
### ⚠ BREAKING CHANGES
|
|
37
|
+
|
|
38
|
+
* add selectedTabIndex and helpers (#6040)
|
|
39
|
+
|
|
40
|
+
### Features
|
|
41
|
+
|
|
42
|
+
* add selectedTabIndex and helpers ([#6040](https://github.com/dynamic-labs/DynamicAuth/issues/6040)) ([ae20b80](https://github.com/dynamic-labs/DynamicAuth/commit/ae20b8081376dce97b18fa69c81c9ab73c1ff317))
|
|
43
|
+
* add useRefreshUser to trigger a user state refresh ([#6079](https://github.com/dynamic-labs/DynamicAuth/issues/6079)) ([1236d35](https://github.com/dynamic-labs/DynamicAuth/commit/1236d35fe9fab44ed2114ad9f3c8c6dca7ec27be))
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
### Bug Fixes
|
|
47
|
+
|
|
48
|
+
* always return userWallets when available ([#6080](https://github.com/dynamic-labs/DynamicAuth/issues/6080)) ([#6083](https://github.com/dynamic-labs/DynamicAuth/issues/6083)) ([11992d2](https://github.com/dynamic-labs/DynamicAuth/commit/11992d2af5a401ba4ff1dc6904e2a9f8ef5904ca))
|
|
49
|
+
* less solana rpc calls and improve fee fetching ([#6019](https://github.com/dynamic-labs/DynamicAuth/issues/6019)) ([e2609db](https://github.com/dynamic-labs/DynamicAuth/commit/e2609db962c7708ff5b127cb23260a25bc5032e3))
|
|
50
|
+
* make account change idemopotent ([#6061](https://github.com/dynamic-labs/DynamicAuth/issues/6061)) ([8c87513](https://github.com/dynamic-labs/DynamicAuth/commit/8c8751390ea14888c4889679895e2f06d75717b9))
|
|
51
|
+
* only run multi wallet prompt when user profile or auth flow are open ([#6073](https://github.com/dynamic-labs/DynamicAuth/issues/6073)) ([d48ca10](https://github.com/dynamic-labs/DynamicAuth/commit/d48ca105359018457a78588fd8d9aa8a91583a02))
|
|
52
|
+
* recompute multiwallet state after merging accounts ([#6078](https://github.com/dynamic-labs/DynamicAuth/issues/6078)) ([e08a274](https://github.com/dynamic-labs/DynamicAuth/commit/e08a274c4d848f2a8360be7106cfbfa00b9a8f9b))
|
|
53
|
+
* stop querying okx for accounts while locked ([#6081](https://github.com/dynamic-labs/DynamicAuth/issues/6081)) ([#6084](https://github.com/dynamic-labs/DynamicAuth/issues/6084)) ([34365ac](https://github.com/dynamic-labs/DynamicAuth/commit/34365ac1981fe020b03e666c24535a247645d2ad))
|
|
54
|
+
* update copy for primary wallet not connected modal ([#6069](https://github.com/dynamic-labs/DynamicAuth/issues/6069)) ([4a3f43c](https://github.com/dynamic-labs/DynamicAuth/commit/4a3f43ce5585983f7fea0c5b97e812c0ade80e2c))
|
|
55
|
+
|
|
56
|
+
## [3.0.0-alpha.6](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.5...v3.0.0-alpha.6) (2024-06-18)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
### Features
|
|
60
|
+
|
|
61
|
+
* implement useExternalAuth hook to signin using external jwt auth ([#6039](https://github.com/dynamic-labs/DynamicAuth/issues/6039)) ([ba90908](https://github.com/dynamic-labs/DynamicAuth/commit/ba90908509ec21f708a4a0782a7f94861fc3b484))
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
### Bug Fixes
|
|
65
|
+
|
|
66
|
+
* allow sign-in with different ME BTC wallet after initial connection ([a527b46](https://github.com/dynamic-labs/DynamicAuth/commit/a527b464f321b4fc27730f57c3812e996b5ed878))
|
|
67
|
+
* close sign modal when signing in with a wallet when embedded wallet is enabled ([#6013](https://github.com/dynamic-labs/DynamicAuth/issues/6013)) ([0f4f3c8](https://github.com/dynamic-labs/DynamicAuth/commit/0f4f3c83db162f7a1794a3549b60bbad6b03e2c0))
|
|
68
|
+
* custom network without a valid icon should still display its name in network picker ([#6018](https://github.com/dynamic-labs/DynamicAuth/issues/6018)) ([0b10df6](https://github.com/dynamic-labs/DynamicAuth/commit/0b10df68950bfc9b8492443158a6bb030dc1122c))
|
|
69
|
+
* e2e: remove page pause ([#6045](https://github.com/dynamic-labs/DynamicAuth/issues/6045)) ([55bba00](https://github.com/dynamic-labs/DynamicAuth/commit/55bba0034255055d6ae266b1296542f47ed48e2b))
|
|
70
|
+
* more fixes for connect starknet button ([#6046](https://github.com/dynamic-labs/DynamicAuth/issues/6046)) ([0fb570a](https://github.com/dynamic-labs/DynamicAuth/commit/0fb570a44e65f8dd6d4d2bf5edb2ee54985ec9d4))
|
|
71
|
+
* set verified credentials on embedded wallet creation ([#6044](https://github.com/dynamic-labs/DynamicAuth/issues/6044)) ([b52a96d](https://github.com/dynamic-labs/DynamicAuth/commit/b52a96d321e7efdb30dce9cdb3f6f176c24ceb81))
|
|
72
|
+
|
|
73
|
+
## [3.0.0-alpha.5](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.4...v3.0.0-alpha.5) (2024-06-14)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
### ⚠ BREAKING CHANGES
|
|
77
|
+
|
|
78
|
+
* remove viem dependency from non-evm packages (#5508)
|
|
79
|
+
* move rpc providers into their own packages (#5981)
|
|
80
|
+
|
|
81
|
+
### Features
|
|
82
|
+
|
|
83
|
+
* add in-app browser navigation support for sats-connect ([#5988](https://github.com/dynamic-labs/DynamicAuth/issues/5988)) ([be27d2d](https://github.com/dynamic-labs/DynamicAuth/commit/be27d2d4030bbe2157e879497d8e6a00b4a3e404))
|
|
84
|
+
* move rpc providers into their own packages ([#5981](https://github.com/dynamic-labs/DynamicAuth/issues/5981)) ([d7a62d6](https://github.com/dynamic-labs/DynamicAuth/commit/d7a62d60e79dfa6d6651b0fa103e90b6f8a9ccf3))
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
### Bug Fixes
|
|
88
|
+
|
|
89
|
+
* embedded solana wallets can send SPL tokens and estimate gas ([#5982](https://github.com/dynamic-labs/DynamicAuth/issues/5982)) ([36623eb](https://github.com/dynamic-labs/DynamicAuth/commit/36623eb99d1d1dfebfd8b6f3194eeff31e7de2bf))
|
|
90
|
+
* improve logic related to turnkey and emailVerifcation ([#5946](https://github.com/dynamic-labs/DynamicAuth/issues/5946)) ([dd0b2dc](https://github.com/dynamic-labs/DynamicAuth/commit/dd0b2dc6d93a8bbbcb6eef88732e62b747005bb3))
|
|
91
|
+
* show linked wallets with unavailable providers in user wallets list ([#5992](https://github.com/dynamic-labs/DynamicAuth/issues/5992)) ([996079c](https://github.com/dynamic-labs/DynamicAuth/commit/996079ced360651c7b1eb5273548e0548f6f9f3a))
|
|
92
|
+
* switch network modal not closing after switching to a supported network ([#5979](https://github.com/dynamic-labs/DynamicAuth/issues/5979)) ([f239952](https://github.com/dynamic-labs/DynamicAuth/commit/f2399523dd82bb28046992cac4582688b688bdc0))
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
* remove viem dependency from non-evm packages ([#5508](https://github.com/dynamic-labs/DynamicAuth/issues/5508)) ([0299dc3](https://github.com/dynamic-labs/DynamicAuth/commit/0299dc3cbb611182d763e9a89d1270c2e2f32df5))
|
|
96
|
+
|
|
97
|
+
## [3.0.0-alpha.4](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.3...v3.0.0-alpha.4) (2024-06-12)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
### Bug Fixes
|
|
101
|
+
|
|
102
|
+
* cache getGenesisHash call to prevent over calling ([#5966](https://github.com/dynamic-labs/DynamicAuth/issues/5966)) ([b4d542f](https://github.com/dynamic-labs/DynamicAuth/commit/b4d542f0a85f5ba8c5b8f02f287caee45b4b6feb))
|
|
103
|
+
* handle raw messages in embedded wallet sign message modal ([#5815](https://github.com/dynamic-labs/DynamicAuth/issues/5815)) ([9adc289](https://github.com/dynamic-labs/DynamicAuth/commit/9adc28993b57c1c7f03c4ce6d500288dcf60881e))
|
|
104
|
+
|
|
105
|
+
## [3.0.0-alpha.3](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.2...v3.0.0-alpha.3) (2024-06-11)
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
### Bug Fixes
|
|
109
|
+
|
|
110
|
+
* only navigate to mfa backup codes when needed ([#5965](https://github.com/dynamic-labs/DynamicAuth/issues/5965)) ([edc462f](https://github.com/dynamic-labs/DynamicAuth/commit/edc462f20768885db1883a2c8d005e07044092d5))
|
|
111
|
+
|
|
112
|
+
## [3.0.0-alpha.2](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.1...v3.0.0-alpha.2) (2024-06-11)
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
### Features
|
|
116
|
+
|
|
117
|
+
* add silent signing ([#5712](https://github.com/dynamic-labs/DynamicAuth/issues/5712)) ([17f06f2](https://github.com/dynamic-labs/DynamicAuth/commit/17f06f24d9f576b4d3d879e14de73dc6e9ab2118)), closes [#5807](https://github.com/dynamic-labs/DynamicAuth/issues/5807) [#5908](https://github.com/dynamic-labs/DynamicAuth/issues/5908) [#5932](https://github.com/dynamic-labs/DynamicAuth/issues/5932) [#5937](https://github.com/dynamic-labs/DynamicAuth/issues/5937) [#5949](https://github.com/dynamic-labs/DynamicAuth/issues/5949)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
### Bug Fixes
|
|
121
|
+
|
|
122
|
+
* ensure backup code acknowledgement can be shown async ([#5955](https://github.com/dynamic-labs/DynamicAuth/issues/5955)) ([6e4d053](https://github.com/dynamic-labs/DynamicAuth/commit/6e4d0536f4d5eafc93fc6986d3ad8dc66bccd143))
|
|
123
|
+
* ensure sign message will not show 2 times ([#5938](https://github.com/dynamic-labs/DynamicAuth/issues/5938)) ([8b5a16b](https://github.com/dynamic-labs/DynamicAuth/commit/8b5a16bab201ff0a74d6f5065d454ba62131a761))
|
|
124
|
+
* process undefined in browser context ([#5920](https://github.com/dynamic-labs/DynamicAuth/issues/5920)) ([02fed81](https://github.com/dynamic-labs/DynamicAuth/commit/02fed811c53f7d14c91aab47d0b69ea2697619a7))
|
|
125
|
+
|
|
2
126
|
## [3.0.0-alpha.1](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.0...v3.0.0-alpha.1) (2024-06-10)
|
|
3
127
|
|
|
4
128
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/bitcoin",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.10",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/dynamic-labs/dynamic-auth.git",
|
|
@@ -27,14 +27,14 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@btckit/types": "0.0.19",
|
|
30
|
-
"@dynamic-labs/sdk-api-core": "0.0.
|
|
30
|
+
"@dynamic-labs/sdk-api-core": "0.0.470",
|
|
31
31
|
"@wallet-standard/app": "1.0.1",
|
|
32
32
|
"@wallet-standard/base": "1.0.1",
|
|
33
33
|
"bitcoinjs-lib": "6.1.5",
|
|
34
34
|
"sats-connect": "2.0.0",
|
|
35
|
-
"@dynamic-labs/utils": "3.0.0-alpha.
|
|
36
|
-
"@dynamic-labs/wallet-book": "3.0.0-alpha.
|
|
37
|
-
"@dynamic-labs/wallet-connector-core": "3.0.0-alpha.
|
|
35
|
+
"@dynamic-labs/utils": "3.0.0-alpha.10",
|
|
36
|
+
"@dynamic-labs/wallet-book": "3.0.0-alpha.10",
|
|
37
|
+
"@dynamic-labs/wallet-connector-core": "3.0.0-alpha.10",
|
|
38
38
|
"stream": "0.0.2"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {}
|
|
@@ -15,6 +15,10 @@ export declare class BitcoinProviderHelper {
|
|
|
15
15
|
features: string[];
|
|
16
16
|
name: string;
|
|
17
17
|
} | undefined;
|
|
18
|
+
walletStandardLocators?: {
|
|
19
|
+
name: string;
|
|
20
|
+
locator: string;
|
|
21
|
+
}[] | undefined;
|
|
18
22
|
windowLocations?: string[] | undefined;
|
|
19
23
|
} | undefined;
|
|
20
24
|
getProvider(): any;
|
|
@@ -6,9 +6,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
6
6
|
var _tslib = require('../../../_virtual/_tslib.cjs');
|
|
7
7
|
var bitcoinjsLib = require('bitcoinjs-lib');
|
|
8
8
|
var satsConnect = require('sats-connect');
|
|
9
|
-
var
|
|
9
|
+
var utils = require('@dynamic-labs/utils');
|
|
10
|
+
var walletBook = require('@dynamic-labs/wallet-book');
|
|
10
11
|
var _const = require('../../const.cjs');
|
|
11
|
-
require('@dynamic-labs/utils');
|
|
12
12
|
require('@dynamic-labs/wallet-connector-core');
|
|
13
13
|
var BitcoinWalletConnector = require('../BitcoinWalletConnector.cjs');
|
|
14
14
|
var validatePsbt = require('../../utils/psbt/validator/validatePsbt.cjs');
|
|
@@ -20,10 +20,9 @@ class BitcoinSatsConnectConnector extends BitcoinWalletConnector.BitcoinWalletCo
|
|
|
20
20
|
constructor(opts) {
|
|
21
21
|
super(opts);
|
|
22
22
|
this.currentNetwork = satsConnect.BitcoinNetworkType.Mainnet;
|
|
23
|
-
|
|
24
|
-
//
|
|
25
|
-
|
|
26
|
-
this.canFetchConnectedAccounts = this.key !== 'xverse';
|
|
23
|
+
// satsconnect wallets don't support fetching connected accounts without prompting
|
|
24
|
+
// for a connection, so we handle getConnectedAccounts differently.
|
|
25
|
+
this.canFetchConnectedAccounts = false;
|
|
27
26
|
}
|
|
28
27
|
getAddress() {
|
|
29
28
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
@@ -36,11 +35,15 @@ class BitcoinSatsConnectConnector extends BitcoinWalletConnector.BitcoinWalletCo
|
|
|
36
35
|
if (!supportsSatsConnect.supportsSatsConnect(this)) {
|
|
37
36
|
return;
|
|
38
37
|
}
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
38
|
+
const wallet = walletBook.findWalletBookWallet(this.walletBook, this.key);
|
|
39
|
+
const inAppBrowserUrl = (_a = wallet === null || wallet === void 0 ? void 0 : wallet.mobile) === null || _a === void 0 ? void 0 : _a.inAppBrowser;
|
|
40
|
+
if (utils.isMobile() && !this.isInstalledOnBrowser() && inAppBrowserUrl) {
|
|
41
|
+
const inAppBrowserTemplate = utils.template(inAppBrowserUrl);
|
|
42
|
+
const deepLink = inAppBrowserTemplate({
|
|
43
|
+
encodedDappURI: encodeURIComponent(window.location.toString()),
|
|
44
|
+
});
|
|
45
|
+
window.location.href = deepLink;
|
|
46
|
+
return;
|
|
44
47
|
}
|
|
45
48
|
return new Promise((resolve, reject) => {
|
|
46
49
|
satsConnect.getAddress({
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import { __awaiter } from '../../../_virtual/_tslib.js';
|
|
3
3
|
import { Psbt } from 'bitcoinjs-lib';
|
|
4
4
|
import { BitcoinNetworkType, getAddress, AddressPurpose, signMessage, sendBtcTransaction, signTransaction } from 'sats-connect';
|
|
5
|
-
import {
|
|
5
|
+
import { isMobile, template } from '@dynamic-labs/utils';
|
|
6
|
+
import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
|
|
6
7
|
import { SATSCONNECT_FEATURE } from '../../const.js';
|
|
7
|
-
import '@dynamic-labs/utils';
|
|
8
8
|
import '@dynamic-labs/wallet-connector-core';
|
|
9
9
|
import { BitcoinWalletConnector } from '../BitcoinWalletConnector.js';
|
|
10
10
|
import { validatePsbt } from '../../utils/psbt/validator/validatePsbt.js';
|
|
@@ -16,10 +16,9 @@ class BitcoinSatsConnectConnector extends BitcoinWalletConnector {
|
|
|
16
16
|
constructor(opts) {
|
|
17
17
|
super(opts);
|
|
18
18
|
this.currentNetwork = BitcoinNetworkType.Mainnet;
|
|
19
|
-
|
|
20
|
-
//
|
|
21
|
-
|
|
22
|
-
this.canFetchConnectedAccounts = this.key !== 'xverse';
|
|
19
|
+
// satsconnect wallets don't support fetching connected accounts without prompting
|
|
20
|
+
// for a connection, so we handle getConnectedAccounts differently.
|
|
21
|
+
this.canFetchConnectedAccounts = false;
|
|
23
22
|
}
|
|
24
23
|
getAddress() {
|
|
25
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -32,11 +31,15 @@ class BitcoinSatsConnectConnector extends BitcoinWalletConnector {
|
|
|
32
31
|
if (!supportsSatsConnect(this)) {
|
|
33
32
|
return;
|
|
34
33
|
}
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
|
|
34
|
+
const wallet = findWalletBookWallet(this.walletBook, this.key);
|
|
35
|
+
const inAppBrowserUrl = (_a = wallet === null || wallet === void 0 ? void 0 : wallet.mobile) === null || _a === void 0 ? void 0 : _a.inAppBrowser;
|
|
36
|
+
if (isMobile() && !this.isInstalledOnBrowser() && inAppBrowserUrl) {
|
|
37
|
+
const inAppBrowserTemplate = template(inAppBrowserUrl);
|
|
38
|
+
const deepLink = inAppBrowserTemplate({
|
|
39
|
+
encodedDappURI: encodeURIComponent(window.location.toString()),
|
|
40
|
+
});
|
|
41
|
+
window.location.href = deepLink;
|
|
42
|
+
return;
|
|
40
43
|
}
|
|
41
44
|
return new Promise((resolve, reject) => {
|
|
42
45
|
getAddress({
|
|
@@ -33,6 +33,12 @@ class BitcoinWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
33
33
|
}
|
|
34
34
|
this.cache = new BitcoinLocalStorageCache.BitcoinLocalStorageCache(this.overrideKey);
|
|
35
35
|
}
|
|
36
|
+
isSameAccountChangeRequest(to) {
|
|
37
|
+
return this.lastAccountChange === to;
|
|
38
|
+
}
|
|
39
|
+
setLastAccountChangeRequest(to) {
|
|
40
|
+
this.lastAccountChange = to;
|
|
41
|
+
}
|
|
36
42
|
clearConnectedAccounts() {
|
|
37
43
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
38
44
|
yield this.cache.clearConnectedAcccounts();
|
|
@@ -53,7 +59,10 @@ class BitcoinWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
53
59
|
}
|
|
54
60
|
endSession() {
|
|
55
61
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
56
|
-
yield
|
|
62
|
+
yield Promise.all([
|
|
63
|
+
this.cache.clearConnectedAcccounts(),
|
|
64
|
+
this.cache.clearLastBalance(),
|
|
65
|
+
]);
|
|
57
66
|
});
|
|
58
67
|
}
|
|
59
68
|
getBalance() {
|
|
@@ -234,9 +243,14 @@ class BitcoinWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
234
243
|
}
|
|
235
244
|
const currentConnectedAccounts = yield this.getConnectedAccountsFromCache();
|
|
236
245
|
// don't do anything if the connected accounts haven't changed
|
|
237
|
-
if
|
|
246
|
+
// or if the account change request is the same as previous request
|
|
247
|
+
if (currentConnectedAccounts[0] === connectedAccounts[0] ||
|
|
248
|
+
this.isSameAccountChangeRequest(connectedAccounts[0])) {
|
|
238
249
|
return;
|
|
239
250
|
}
|
|
251
|
+
// set the last account change request with the from and to addresses
|
|
252
|
+
// to ensure that the requests are not duplicated
|
|
253
|
+
this.setLastAccountChangeRequest(connectedAccounts[0]);
|
|
240
254
|
handleAccountChange(connectedAccounts);
|
|
241
255
|
});
|
|
242
256
|
provider.on('accountsChanged', handleBitcoinAccountChange);
|
|
@@ -23,7 +23,10 @@ export declare abstract class BitcoinWalletConnector extends WalletConnectorBase
|
|
|
23
23
|
canFetchConnectedAccounts: boolean;
|
|
24
24
|
isHardwareWalletEnabled: boolean;
|
|
25
25
|
verifiedCredentials: JwtVerifiedCredential[];
|
|
26
|
+
private lastAccountChange;
|
|
26
27
|
constructor(opts: BitcoinWalletConnectorOpts);
|
|
28
|
+
private isSameAccountChangeRequest;
|
|
29
|
+
private setLastAccountChangeRequest;
|
|
27
30
|
clearConnectedAccounts(): Promise<void>;
|
|
28
31
|
canConnectWithHardwareWallet(): boolean;
|
|
29
32
|
isInstalledOnBrowser(): boolean;
|
|
@@ -29,6 +29,12 @@ class BitcoinWalletConnector extends WalletConnectorBase {
|
|
|
29
29
|
}
|
|
30
30
|
this.cache = new BitcoinLocalStorageCache(this.overrideKey);
|
|
31
31
|
}
|
|
32
|
+
isSameAccountChangeRequest(to) {
|
|
33
|
+
return this.lastAccountChange === to;
|
|
34
|
+
}
|
|
35
|
+
setLastAccountChangeRequest(to) {
|
|
36
|
+
this.lastAccountChange = to;
|
|
37
|
+
}
|
|
32
38
|
clearConnectedAccounts() {
|
|
33
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
34
40
|
yield this.cache.clearConnectedAcccounts();
|
|
@@ -49,7 +55,10 @@ class BitcoinWalletConnector extends WalletConnectorBase {
|
|
|
49
55
|
}
|
|
50
56
|
endSession() {
|
|
51
57
|
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
-
yield
|
|
58
|
+
yield Promise.all([
|
|
59
|
+
this.cache.clearConnectedAcccounts(),
|
|
60
|
+
this.cache.clearLastBalance(),
|
|
61
|
+
]);
|
|
53
62
|
});
|
|
54
63
|
}
|
|
55
64
|
getBalance() {
|
|
@@ -230,9 +239,14 @@ class BitcoinWalletConnector extends WalletConnectorBase {
|
|
|
230
239
|
}
|
|
231
240
|
const currentConnectedAccounts = yield this.getConnectedAccountsFromCache();
|
|
232
241
|
// don't do anything if the connected accounts haven't changed
|
|
233
|
-
if
|
|
242
|
+
// or if the account change request is the same as previous request
|
|
243
|
+
if (currentConnectedAccounts[0] === connectedAccounts[0] ||
|
|
244
|
+
this.isSameAccountChangeRequest(connectedAccounts[0])) {
|
|
234
245
|
return;
|
|
235
246
|
}
|
|
247
|
+
// set the last account change request with the from and to addresses
|
|
248
|
+
// to ensure that the requests are not duplicated
|
|
249
|
+
this.setLastAccountChangeRequest(connectedAccounts[0]);
|
|
236
250
|
handleAccountChange(connectedAccounts);
|
|
237
251
|
});
|
|
238
252
|
provider.on('accountsChanged', handleBitcoinAccountChange);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../_virtual/_tslib.cjs');
|
|
7
|
+
var BitcoinWalletConnector = require('../BitcoinWalletConnector.cjs');
|
|
8
|
+
|
|
9
|
+
class FallbackBitcoinConnector extends BitcoinWalletConnector.BitcoinWalletConnector {
|
|
10
|
+
constructor(opts) {
|
|
11
|
+
super(Object.assign(Object.assign({}, opts), { overrideKey: 'fallbackconnector' }));
|
|
12
|
+
this.name = 'Fallback Connector';
|
|
13
|
+
this.overrideKey = 'fallbackconnector';
|
|
14
|
+
this.isAvailable = false;
|
|
15
|
+
this.canFetchConnectedAccounts = false;
|
|
16
|
+
}
|
|
17
|
+
getAddress() {
|
|
18
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
return;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
signPsbt(
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
24
|
+
_request) {
|
|
25
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
return;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
sendBitcoin(
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
31
|
+
_transaction) {
|
|
32
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
return;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
exports.FallbackBitcoinConnector = FallbackBitcoinConnector;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BitcoinSignPsbtRequest, BitcoinSignPsbtResponse, BitcoinTransaction } from '../../types';
|
|
2
|
+
import { BitcoinWalletConnector, BitcoinWalletConnectorOpts } from '../BitcoinWalletConnector';
|
|
3
|
+
export declare class FallbackBitcoinConnector extends BitcoinWalletConnector {
|
|
4
|
+
name: string;
|
|
5
|
+
overrideKey: string;
|
|
6
|
+
isAvailable: boolean;
|
|
7
|
+
canFetchConnectedAccounts: boolean;
|
|
8
|
+
constructor(opts: BitcoinWalletConnectorOpts);
|
|
9
|
+
getAddress(): Promise<string | undefined>;
|
|
10
|
+
signPsbt(_request: BitcoinSignPsbtRequest): Promise<BitcoinSignPsbtResponse | undefined>;
|
|
11
|
+
sendBitcoin(_transaction: BitcoinTransaction): Promise<string | undefined>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../_virtual/_tslib.js';
|
|
3
|
+
import { BitcoinWalletConnector } from '../BitcoinWalletConnector.js';
|
|
4
|
+
|
|
5
|
+
class FallbackBitcoinConnector extends BitcoinWalletConnector {
|
|
6
|
+
constructor(opts) {
|
|
7
|
+
super(Object.assign(Object.assign({}, opts), { overrideKey: 'fallbackconnector' }));
|
|
8
|
+
this.name = 'Fallback Connector';
|
|
9
|
+
this.overrideKey = 'fallbackconnector';
|
|
10
|
+
this.isAvailable = false;
|
|
11
|
+
this.canFetchConnectedAccounts = false;
|
|
12
|
+
}
|
|
13
|
+
getAddress() {
|
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
return;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
signPsbt(
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
20
|
+
_request) {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
return;
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
sendBitcoin(
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
27
|
+
_transaction) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
return;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { FallbackBitcoinConnector };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FallbackBitcoinConnector } from './FallbackBitcoinConnector';
|
|
@@ -13,7 +13,7 @@ class OkxConnector extends BitcoinWalletConnector.BitcoinWalletConnector {
|
|
|
13
13
|
constructor(opts) {
|
|
14
14
|
super(Object.assign(Object.assign({}, opts), { overrideKey: 'okxwalletbtc' }));
|
|
15
15
|
this.name = 'OKX Wallet';
|
|
16
|
-
this.canFetchConnectedAccounts =
|
|
16
|
+
this.canFetchConnectedAccounts = false;
|
|
17
17
|
}
|
|
18
18
|
get walletBookWallet() {
|
|
19
19
|
return this.walletBook.wallets[this.key];
|
|
@@ -9,7 +9,7 @@ class OkxConnector extends BitcoinWalletConnector {
|
|
|
9
9
|
constructor(opts) {
|
|
10
10
|
super(Object.assign(Object.assign({}, opts), { overrideKey: 'okxwalletbtc' }));
|
|
11
11
|
this.name = 'OKX Wallet';
|
|
12
|
-
this.canFetchConnectedAccounts =
|
|
12
|
+
this.canFetchConnectedAccounts = false;
|
|
13
13
|
}
|
|
14
14
|
get walletBookWallet() {
|
|
15
15
|
return this.walletBook.wallets[this.key];
|
|
@@ -65,6 +65,15 @@ class UnisatConnector extends BitcoinWalletConnector.BitcoinWalletConnector {
|
|
|
65
65
|
return { signedPsbt: bitcoinjsLib.Psbt.fromHex(signedPsbtHex).toBase64() };
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
|
+
getConnectedAccounts() {
|
|
69
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
const provider = this.getProvider();
|
|
71
|
+
if (!provider) {
|
|
72
|
+
return [];
|
|
73
|
+
}
|
|
74
|
+
return provider.getAccounts();
|
|
75
|
+
});
|
|
76
|
+
}
|
|
68
77
|
}
|
|
69
78
|
|
|
70
79
|
exports.UnisatConnector = UnisatConnector;
|
|
@@ -9,4 +9,5 @@ export declare class UnisatConnector extends BitcoinWalletConnector {
|
|
|
9
9
|
signMessage(messageToSign: string): Promise<string | undefined>;
|
|
10
10
|
sendBitcoin(transaction: BitcoinTransaction): Promise<string | undefined>;
|
|
11
11
|
signPsbt(request: BitcoinSignPsbtRequest): Promise<BitcoinSignPsbtResponse | undefined>;
|
|
12
|
+
getConnectedAccounts(): Promise<string[]>;
|
|
12
13
|
}
|
|
@@ -61,6 +61,15 @@ class UnisatConnector extends BitcoinWalletConnector {
|
|
|
61
61
|
return { signedPsbt: Psbt.fromHex(signedPsbtHex).toBase64() };
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
|
+
getConnectedAccounts() {
|
|
65
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
const provider = this.getProvider();
|
|
67
|
+
if (!provider) {
|
|
68
|
+
return [];
|
|
69
|
+
}
|
|
70
|
+
return provider.getAccounts();
|
|
71
|
+
});
|
|
72
|
+
}
|
|
64
73
|
}
|
|
65
74
|
|
|
66
75
|
export { UnisatConnector };
|
package/src/index.cjs
CHANGED
|
@@ -9,7 +9,7 @@ require('sats-connect');
|
|
|
9
9
|
require('bitcoinjs-lib');
|
|
10
10
|
require('@dynamic-labs/wallet-connector-core');
|
|
11
11
|
require('@dynamic-labs/utils');
|
|
12
|
-
require('@dynamic-labs/
|
|
12
|
+
require('@dynamic-labs/wallet-book');
|
|
13
13
|
var fetchBtcKitConnectors = require('./utils/fetchBtcKitConnectors/fetchBtcKitConnectors.cjs');
|
|
14
14
|
var fetchSatsConnectConnectors = require('./utils/fetchSatsConnectConnectors/fetchSatsConnectConnectors.cjs');
|
|
15
15
|
var hasSatsConnectFeature = require('./utils/hasSatsConnectFeature.cjs');
|
|
@@ -19,6 +19,7 @@ var PhantomConnector = require('./connectors/PhantomConnector/PhantomConnector.c
|
|
|
19
19
|
var OkxConnector = require('./connectors/OkxConnector/OkxConnector.cjs');
|
|
20
20
|
var UnisatConnector = require('./connectors/UnisatConnector/UnisatConnector.cjs');
|
|
21
21
|
var UnknownInjected = require('./connectors/UnknownInjected/UnknownInjected.cjs');
|
|
22
|
+
var FallbackBitcoinConnector = require('./connectors/FallbackBitcoinConnector/FallbackBitcoinConnector.cjs');
|
|
22
23
|
|
|
23
24
|
const BitcoinWalletConnectors = (props) => [
|
|
24
25
|
...fetchSatsConnectConnectors.fetchSatsConnectConnectors(props),
|
|
@@ -27,6 +28,7 @@ const BitcoinWalletConnectors = (props) => [
|
|
|
27
28
|
OkxConnector.OkxConnector,
|
|
28
29
|
UnisatConnector.UnisatConnector,
|
|
29
30
|
UnknownInjected.UnknownInjectedConnector,
|
|
31
|
+
FallbackBitcoinConnector.FallbackBitcoinConnector,
|
|
30
32
|
];
|
|
31
33
|
|
|
32
34
|
exports.BitcoinWalletConnector = BitcoinWalletConnector.BitcoinWalletConnector;
|
package/src/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import 'sats-connect';
|
|
|
5
5
|
import 'bitcoinjs-lib';
|
|
6
6
|
import '@dynamic-labs/wallet-connector-core';
|
|
7
7
|
import '@dynamic-labs/utils';
|
|
8
|
-
import '@dynamic-labs/
|
|
8
|
+
import '@dynamic-labs/wallet-book';
|
|
9
9
|
import { fetchBtcKitConnectors } from './utils/fetchBtcKitConnectors/fetchBtcKitConnectors.js';
|
|
10
10
|
export { fetchBtcKitConnectors } from './utils/fetchBtcKitConnectors/fetchBtcKitConnectors.js';
|
|
11
11
|
import { fetchSatsConnectConnectors } from './utils/fetchSatsConnectConnectors/fetchSatsConnectConnectors.js';
|
|
@@ -17,6 +17,7 @@ import { PhantomConnector } from './connectors/PhantomConnector/PhantomConnector
|
|
|
17
17
|
import { OkxConnector } from './connectors/OkxConnector/OkxConnector.js';
|
|
18
18
|
import { UnisatConnector } from './connectors/UnisatConnector/UnisatConnector.js';
|
|
19
19
|
import { UnknownInjectedConnector } from './connectors/UnknownInjected/UnknownInjected.js';
|
|
20
|
+
import { FallbackBitcoinConnector } from './connectors/FallbackBitcoinConnector/FallbackBitcoinConnector.js';
|
|
20
21
|
|
|
21
22
|
const BitcoinWalletConnectors = (props) => [
|
|
22
23
|
...fetchSatsConnectConnectors(props),
|
|
@@ -25,6 +26,7 @@ const BitcoinWalletConnectors = (props) => [
|
|
|
25
26
|
OkxConnector,
|
|
26
27
|
UnisatConnector,
|
|
27
28
|
UnknownInjectedConnector,
|
|
29
|
+
FallbackBitcoinConnector,
|
|
28
30
|
];
|
|
29
31
|
|
|
30
32
|
export { BitcoinWalletConnectors };
|