@dynamic-labs/bitcoin 1.1.0-alpha.9 → 1.1.0
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 +198 -0
- package/_virtual/_tslib.cjs +6 -1
- package/_virtual/_tslib.js +6 -1
- package/package.json +8 -4
- package/src/BitcoinBtcKitConnector.cjs +108 -0
- package/src/BitcoinBtcKitConnector.d.ts +17 -0
- package/src/BitcoinBtcKitConnector.js +104 -0
- package/src/BitcoinLocalStorageCache.cjs +45 -13
- package/src/BitcoinLocalStorageCache.d.ts +21 -8
- package/src/BitcoinLocalStorageCache.js +45 -13
- package/src/BitcoinSatsConnectConnector.cjs +81 -14
- package/src/BitcoinSatsConnectConnector.d.ts +5 -3
- package/src/BitcoinSatsConnectConnector.js +82 -15
- package/src/BitcoinWalletConnector.cjs +121 -31
- package/src/BitcoinWalletConnector.d.ts +17 -7
- package/src/BitcoinWalletConnector.js +123 -33
- package/src/OkxConnector.cjs +63 -0
- package/src/OkxConnector.d.ts +11 -0
- package/src/OkxConnector.js +59 -0
- package/src/UnisatConnector.cjs +64 -0
- package/src/UnisatConnector.d.ts +11 -0
- package/src/UnisatConnector.js +60 -0
- package/src/bitcoinProviderHelper.cjs +9 -14
- package/src/bitcoinProviderHelper.d.ts +2 -1
- package/src/bitcoinProviderHelper.js +9 -14
- package/src/const.cjs +6 -2
- package/src/const.d.ts +3 -2
- package/src/const.js +4 -2
- package/src/index.cjs +13 -5
- package/src/index.d.ts +4 -3
- package/src/index.js +11 -3
- package/src/types.d.ts +43 -4
- package/src/utils/fetchBtcKitConnectors/fetchBtcKitConnectors.cjs +31 -0
- package/src/utils/fetchBtcKitConnectors/fetchBtcKitConnectors.d.ts +5 -0
- package/src/utils/fetchBtcKitConnectors/fetchBtcKitConnectors.js +27 -0
- package/src/utils/fetchBtcKitConnectors/index.d.ts +1 -0
- package/src/{fetchSatsConnectConnectors.cjs → utils/fetchSatsConnectConnectors/fetchSatsConnectConnectors.cjs} +2 -2
- package/src/{fetchSatsConnectConnectors.js → utils/fetchSatsConnectConnectors/fetchSatsConnectConnectors.js} +2 -2
- package/src/utils/fetchSatsConnectConnectors/index.d.ts +1 -0
- package/src/utils/getMempoolApiUrl.cjs +9 -0
- package/src/utils/getMempoolApiUrl.d.ts +1 -0
- package/src/utils/getMempoolApiUrl.js +5 -0
- package/src/utils/index.d.ts +3 -1
- package/src/utils/psbt/bitcoinNetworkTypeToNetworks.cjs +13 -0
- package/src/utils/psbt/bitcoinNetworkTypeToNetworks.d.ts +3 -0
- package/src/utils/psbt/bitcoinNetworkTypeToNetworks.js +9 -0
- package/src/utils/psbt/createSignPsbtOptions.cjs +33 -0
- package/src/utils/psbt/createSignPsbtOptions.d.ts +3 -0
- package/src/utils/psbt/createSignPsbtOptions.js +29 -0
- package/src/utils/psbt/extractAddressFromInput.cjs +34 -0
- package/src/utils/psbt/extractAddressFromInput.d.ts +6 -0
- package/src/utils/psbt/extractAddressFromInput.js +30 -0
- package/src/utils/psbt/getSigHashType.cjs +35 -0
- package/src/utils/psbt/getSigHashType.d.ts +8 -0
- package/src/utils/psbt/getSigHashType.js +31 -0
- package/src/utils/psbt/index.d.ts +4 -0
- package/src/utils/psbt/validator/index.d.ts +1 -0
- package/src/utils/psbt/validator/validateAddress.cjs +18 -0
- package/src/utils/psbt/validator/validateAddress.d.ts +2 -0
- package/src/utils/psbt/validator/validateAddress.js +14 -0
- package/src/utils/psbt/validator/validatePsbt.cjs +40 -0
- package/src/utils/psbt/validator/validatePsbt.d.ts +11 -0
- package/src/utils/psbt/validator/validatePsbt.js +36 -0
- package/src/utils/psbt/validator/validateSigHash.cjs +15 -0
- package/src/utils/psbt/validator/validateSigHash.d.ts +2 -0
- package/src/utils/psbt/validator/validateSigHash.js +11 -0
- package/src/utils/supportsSatsConnect.cjs +8 -0
- package/src/utils/supportsSatsConnect.js +8 -0
- package/src/utils/isBitcoinConnector.cjs +0 -7
- package/src/utils/isBitcoinConnector.d.ts +0 -3
- package/src/utils/isBitcoinConnector.js +0 -3
- /package/src/{fetchSatsConnectConnectors.d.ts → utils/fetchSatsConnectConnectors/fetchSatsConnectConnectors.d.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,202 @@
|
|
|
1
1
|
|
|
2
|
+
## [1.1.0](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.25...v1.1.0) (2024-02-07)
|
|
3
|
+
|
|
4
|
+
Check out our changelog here: https://docs.dynamic.xyz/changelog/v1-1
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* add retry when using magic ([#4579](https://github.com/dynamic-labs/DynamicAuth/issues/4579)) ([183561c](https://github.com/dynamic-labs/DynamicAuth/commit/183561cc64f083fd1489c38a8cc8b1c4c51d2924))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* bug where deprecated fields were still being used in the SDK ([#4604](https://github.com/dynamic-labs/DynamicAuth/issues/4604)) ([4fd15fc](https://github.com/dynamic-labs/DynamicAuth/commit/4fd15fc4daa9c5b7bbc81ce05a3b046c80a6d5b4))
|
|
15
|
+
* log magic RPC error and update magic network error ([#4606](https://github.com/dynamic-labs/DynamicAuth/issues/4606)) ([2206961](https://github.com/dynamic-labs/DynamicAuth/commit/22069618a317bc40b1a17fd521eadf0956983de4))
|
|
16
|
+
* onConnect is properly called for additional connected wallets ([#4607](https://github.com/dynamic-labs/DynamicAuth/issues/4607)) ([23241f4](https://github.com/dynamic-labs/DynamicAuth/commit/23241f4d5dc91ac9ca1251710161efbfce42dc40))
|
|
17
|
+
|
|
18
|
+
## [1.1.0-alpha.25](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.24...v1.1.0-alpha.25) (2024-02-05)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Features
|
|
22
|
+
|
|
23
|
+
* add signin with coinbase to sdk ([#4581](https://github.com/dynamic-labs/DynamicAuth/issues/4581)) ([08a31ed](https://github.com/dynamic-labs/DynamicAuth/commit/08a31ed3552c48645b398881f184440800af21ec))
|
|
24
|
+
* exposing hook for creating either one-time code or passkeys authenticators ([#4591](https://github.com/dynamic-labs/DynamicAuth/issues/4591)) ([864d755](https://github.com/dynamic-labs/DynamicAuth/commit/864d75576152a10f73f5901bc06e2d66892b63ab))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Bug Fixes
|
|
28
|
+
|
|
29
|
+
* solana wallet sign message with one-time code session ([#4588](https://github.com/dynamic-labs/DynamicAuth/issues/4588)) ([a738d10](https://github.com/dynamic-labs/DynamicAuth/commit/a738d10814dc5058158b9c0c59a399a375c69c10))
|
|
30
|
+
|
|
31
|
+
## [1.1.0-alpha.24](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.23...v1.1.0-alpha.24) (2024-02-02)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
### Bug Fixes
|
|
35
|
+
|
|
36
|
+
* remove isFullyConnected when unable to restore wallet ([#4575](https://github.com/dynamic-labs/DynamicAuth/issues/4575)) ([4504ff0](https://github.com/dynamic-labs/DynamicAuth/commit/4504ff03f594cd9a60055e6f52b7ea8001542bbe))
|
|
37
|
+
|
|
38
|
+
## [1.1.0-alpha.23](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.22...v1.1.0-alpha.23) (2024-02-01)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
### Features
|
|
42
|
+
|
|
43
|
+
* bitcoin signPsbt ([3c964de](https://github.com/dynamic-labs/DynamicAuth/commit/3c964dea8a55debaf184c5a94f0f5fabdda3c877))
|
|
44
|
+
* embedded wallet email auth flow ([#4353](https://github.com/dynamic-labs/DynamicAuth/issues/4353)) ([4875da3](https://github.com/dynamic-labs/DynamicAuth/commit/4875da32c47c27facef1b1cdbdc214566bbfd171))
|
|
45
|
+
|
|
46
|
+
## [1.1.0-alpha.22](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.21...v1.1.0-alpha.22) (2024-02-01)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
### Bug Fixes
|
|
50
|
+
|
|
51
|
+
* onAuthFlowClose not being called ([#4563](https://github.com/dynamic-labs/DynamicAuth/issues/4563)) ([c4b2648](https://github.com/dynamic-labs/DynamicAuth/commit/c4b264885b7dba6e204ef49bf642d25c7d287b04))
|
|
52
|
+
|
|
53
|
+
## [1.1.0-alpha.21](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.20...v1.1.0-alpha.21) (2024-02-01)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
### Features
|
|
57
|
+
|
|
58
|
+
* add phantom redirect handling context ([#4479](https://github.com/dynamic-labs/DynamicAuth/issues/4479)) ([e0218ee](https://github.com/dynamic-labs/DynamicAuth/commit/e0218eec1a67787f5c0e7483d542a5f773e911ef))
|
|
59
|
+
* add signPsbt method to bitcoin wallet connectors ([dfdc0fe](https://github.com/dynamic-labs/DynamicAuth/commit/dfdc0fe0e6894c1307b286e89b43a4c58a8808f3))
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
### Bug Fixes
|
|
63
|
+
|
|
64
|
+
* relax passkey feature detection check in sdk to avoid false nega… ([#4556](https://github.com/dynamic-labs/DynamicAuth/issues/4556)) ([4554f7d](https://github.com/dynamic-labs/DynamicAuth/commit/4554f7d7c5339859481cdecca95a9c07fae4ba5c))
|
|
65
|
+
* workaround braavos undefined selectedWallet on chainChange event ([#4552](https://github.com/dynamic-labs/DynamicAuth/issues/4552)) ([aa35df0](https://github.com/dynamic-labs/DynamicAuth/commit/aa35df0e894feafa0606aa1c87bd3d3879ebc594))
|
|
66
|
+
|
|
67
|
+
## [1.1.0-alpha.20](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.19...v1.1.0-alpha.20) (2024-01-31)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
### Bug Fixes
|
|
71
|
+
|
|
72
|
+
* return all enabled chains in getSupportedNetworks instead of undefined ([#4547](https://github.com/dynamic-labs/DynamicAuth/issues/4547)) ([08e7889](https://github.com/dynamic-labs/DynamicAuth/commit/08e78896e045f24bbd96e39416a7f58006929da0))
|
|
73
|
+
* show modal for existing social account from other signin provider ([#4535](https://github.com/dynamic-labs/DynamicAuth/issues/4535)) ([282914a](https://github.com/dynamic-labs/DynamicAuth/commit/282914ac94b3ef5bd66e0b2265d9e414203a7406))
|
|
74
|
+
|
|
75
|
+
## [1.1.0-alpha.19](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.18...v1.1.0-alpha.19) (2024-01-31)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
### Features
|
|
79
|
+
|
|
80
|
+
* add PhantomRedirect connector ([#4467](https://github.com/dynamic-labs/DynamicAuth/issues/4467)) ([75d6c95](https://github.com/dynamic-labs/DynamicAuth/commit/75d6c95940fcec185a699c2100b3e2d21a8233d5))
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
### Bug Fixes
|
|
84
|
+
|
|
85
|
+
* lock starknet to 5.25.0 since 5.27.0 breaks the build ([#4541](https://github.com/dynamic-labs/DynamicAuth/issues/4541)) ([00b4799](https://github.com/dynamic-labs/DynamicAuth/commit/00b479977f768cb067480e2e565eabf45e1000a2))
|
|
86
|
+
|
|
87
|
+
## [1.1.0-alpha.18](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.17...v1.1.0-alpha.18) (2024-01-30)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
### Bug Fixes
|
|
91
|
+
|
|
92
|
+
* catch email_associated_with_different_provider from response ([#4532](https://github.com/dynamic-labs/DynamicAuth/issues/4532)) ([52be1b4](https://github.com/dynamic-labs/DynamicAuth/commit/52be1b45af46c2b70972b99d73387eb4d7161ec6))
|
|
93
|
+
|
|
94
|
+
## [1.1.0-alpha.17](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.16...v1.1.0-alpha.17) (2024-01-30)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
### Features
|
|
98
|
+
|
|
99
|
+
* add sendRawTransaction to BitcoinWalletConnector ([2e86c5a](https://github.com/dynamic-labs/DynamicAuth/commit/2e86c5a5245bd0fc29162ef1f7fe2fbd65245fe1))
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
### Bug Fixes
|
|
103
|
+
|
|
104
|
+
* properly handle AccountExistsError for signInOAuth ([#4529](https://github.com/dynamic-labs/DynamicAuth/issues/4529)) ([d37fdc3](https://github.com/dynamic-labs/DynamicAuth/commit/d37fdc310fe4b70f8948fd5ed3d058342afbe08f))
|
|
105
|
+
|
|
106
|
+
## [1.1.0-alpha.16](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.15...v1.1.0-alpha.16) (2024-01-30)
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
### Bug Fixes
|
|
110
|
+
|
|
111
|
+
* add fallback to getWalletBookWallet for customers still passing in name, add deprecation warn ([#4518](https://github.com/dynamic-labs/DynamicAuth/issues/4518)) ([b233ea1](https://github.com/dynamic-labs/DynamicAuth/commit/b233ea1cd640d8d9d94c52ab230787f3d869151a))
|
|
112
|
+
* handle braavos network change to account which doesn not exist ([#4519](https://github.com/dynamic-labs/DynamicAuth/issues/4519)) ([486020f](https://github.com/dynamic-labs/DynamicAuth/commit/486020fb09a274388ba34c8d1b37ac3a1ff3dba6))
|
|
113
|
+
|
|
114
|
+
## [1.1.0-alpha.15](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.14...v1.1.0-alpha.15) (2024-01-28)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
### Features
|
|
118
|
+
|
|
119
|
+
* add wallet group override to wallet book ([#4488](https://github.com/dynamic-labs/DynamicAuth/issues/4488)) ([cb19ad3](https://github.com/dynamic-labs/DynamicAuth/commit/cb19ad3ea82de488752ceceeaf0e1458a388df6e))
|
|
120
|
+
* enable solana embedded wallets ([#4457](https://github.com/dynamic-labs/DynamicAuth/issues/4457)) ([b0c47f4](https://github.com/dynamic-labs/DynamicAuth/commit/b0c47f4475baa12f52076da46ef993c13bd2c243))
|
|
121
|
+
* group ArgentX wallets ([#4495](https://github.com/dynamic-labs/DynamicAuth/issues/4495)) ([b10d79a](https://github.com/dynamic-labs/DynamicAuth/commit/b10d79a668efecedca37ddb358e6adf95319650d))
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
### Bug Fixes
|
|
125
|
+
|
|
126
|
+
* add support for newest backpack extension ([#4468](https://github.com/dynamic-labs/DynamicAuth/issues/4468)) ([a219f32](https://github.com/dynamic-labs/DynamicAuth/commit/a219f325be672599e50b07f6751234a7fc98286e))
|
|
127
|
+
* bump timeout for slower connections ([#4475](https://github.com/dynamic-labs/DynamicAuth/issues/4475)) ([7a07ff5](https://github.com/dynamic-labs/DynamicAuth/commit/7a07ff589eaaf3b28a94d277df3eedabbca60702))
|
|
128
|
+
* change out getWalletBookWallet for findWalletBookWallet to avoid throwing during lookup ([#4477](https://github.com/dynamic-labs/DynamicAuth/issues/4477)) ([4648040](https://github.com/dynamic-labs/DynamicAuth/commit/4648040c166e73dd2c31b0e27897713339436c2f))
|
|
129
|
+
* connect to wallet with wallet connect even if network is not supported ([#4465](https://github.com/dynamic-labs/DynamicAuth/issues/4465)) ([9dbca3e](https://github.com/dynamic-labs/DynamicAuth/commit/9dbca3eb4d4990ee4be642677c1604170b425dc3))
|
|
130
|
+
* pass id to wagmi chain override ([#4512](https://github.com/dynamic-labs/DynamicAuth/issues/4512)) ([2bf2f04](https://github.com/dynamic-labs/DynamicAuth/commit/2bf2f0487f5b1be936dd279107c11fe5d2b42666))
|
|
131
|
+
* switching wallet in extension caused connected flag to be false temporarily ([#4454](https://github.com/dynamic-labs/DynamicAuth/issues/4454)) ([3650f6e](https://github.com/dynamic-labs/DynamicAuth/commit/3650f6ec471a7c779f4d304ab94c9350dd55055b))
|
|
132
|
+
|
|
133
|
+
## [1.1.0-alpha.14](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.13...v1.1.0-alpha.14) (2024-01-23)
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
### Features
|
|
137
|
+
|
|
138
|
+
* add wallet-book retryable ([#4462](https://github.com/dynamic-labs/DynamicAuth/issues/4462)) ([513b1a6](https://github.com/dynamic-labs/DynamicAuth/commit/513b1a67d6c49624398ad4b0cdca4f5618c9583f))
|
|
139
|
+
|
|
140
|
+
## [1.1.0-alpha.13](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.12...v1.1.0-alpha.13) (2024-01-23)
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
### Features
|
|
144
|
+
|
|
145
|
+
* add createWalletClientFromWallet helper function ([#4416](https://github.com/dynamic-labs/DynamicAuth/issues/4416)) ([b384898](https://github.com/dynamic-labs/DynamicAuth/commit/b384898061bb3f9b38b2ed670b6650cfc1d4b429))
|
|
146
|
+
* add hardware wallets to wallet book ([#4445](https://github.com/dynamic-labs/DynamicAuth/issues/4445)) ([66c0f5b](https://github.com/dynamic-labs/DynamicAuth/commit/66c0f5b29a6a700099bb95a6f7622f6178e0bccf))
|
|
147
|
+
* add support for Argent Web and Mobile ([#4328](https://github.com/dynamic-labs/DynamicAuth/issues/4328)) ([bce20b8](https://github.com/dynamic-labs/DynamicAuth/commit/bce20b8f35a8630f2621f53a541a1acb06a38fc0))
|
|
148
|
+
* enable ledger for glow, solflare and backpack ([#4392](https://github.com/dynamic-labs/DynamicAuth/issues/4392)) ([fa7b992](https://github.com/dynamic-labs/DynamicAuth/commit/fa7b992f87ebc43560f87b43ac56f2cd9909b306))
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
### Bug Fixes
|
|
152
|
+
|
|
153
|
+
* breaking changes script ([#4440](https://github.com/dynamic-labs/DynamicAuth/issues/4440)) ([446173d](https://github.com/dynamic-labs/DynamicAuth/commit/446173d074d652d81856c6412e304b46b1565320))
|
|
154
|
+
* broken help icon in create passkey view ([#4428](https://github.com/dynamic-labs/DynamicAuth/issues/4428)) ([e0ffc02](https://github.com/dynamic-labs/DynamicAuth/commit/e0ffc02ffea34b7ac3198ff6e1baf7f9907acddd))
|
|
155
|
+
* infinite loop when connecting with trust wallet ([#4448](https://github.com/dynamic-labs/DynamicAuth/issues/4448)) ([4e20edf](https://github.com/dynamic-labs/DynamicAuth/commit/4e20edf9abaabf20e5e9f9167b44d7f691e844f1))
|
|
156
|
+
* render wagmi elements based on react version ([#4453](https://github.com/dynamic-labs/DynamicAuth/issues/4453)) ([43c624c](https://github.com/dynamic-labs/DynamicAuth/commit/43c624ca996b0c51de1454910f19fdf908149938))
|
|
157
|
+
|
|
158
|
+
## [1.1.0-alpha.12](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.11...v1.1.0-alpha.12) (2024-01-18)
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
### Features
|
|
162
|
+
|
|
163
|
+
* expose setAuthMode method ([#4419](https://github.com/dynamic-labs/DynamicAuth/issues/4419)) ([7d156b3](https://github.com/dynamic-labs/DynamicAuth/commit/7d156b3e0eab9b9a80f70ff1c5201d90693ae755))
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
### Bug Fixes
|
|
167
|
+
|
|
168
|
+
* call onUnlinkSuccess in headless mode too ([#4412](https://github.com/dynamic-labs/DynamicAuth/issues/4412)) ([4c76af9](https://github.com/dynamic-labs/DynamicAuth/commit/4c76af9ac7c7b43883742d1289558dfcb5d612ca))
|
|
169
|
+
* correctly map keplr chain ids from project settings ([#4418](https://github.com/dynamic-labs/DynamicAuth/issues/4418)) ([7046364](https://github.com/dynamic-labs/DynamicAuth/commit/7046364a316f7551f0b995eaae7afea13502eb9b))
|
|
170
|
+
* logging in with an email linked to a third party wallet gets stuck on otp view ([#4407](https://github.com/dynamic-labs/DynamicAuth/issues/4407)) ([35bf142](https://github.com/dynamic-labs/DynamicAuth/commit/35bf142e74efeef866dbd7b8157a049cd36eeccb))
|
|
171
|
+
|
|
172
|
+
## [1.1.0-alpha.11](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.10...v1.1.0-alpha.11) (2024-01-17)
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
### Features
|
|
176
|
+
|
|
177
|
+
* add Leather wallet and BtcKit connector ([#4335](https://github.com/dynamic-labs/DynamicAuth/issues/4335)) ([fe3316b](https://github.com/dynamic-labs/DynamicAuth/commit/fe3316b5be9ef17eea885e99cf925ccd0f271da7))
|
|
178
|
+
* add solana injected wallet configuration to walletbook ([#4375](https://github.com/dynamic-labs/DynamicAuth/issues/4375)) ([3677ce5](https://github.com/dynamic-labs/DynamicAuth/commit/3677ce5ff40d0c00bfaf0daa0d5d67bc40706ee0))
|
|
179
|
+
* add support for unisat wallet ([#4355](https://github.com/dynamic-labs/DynamicAuth/issues/4355)) ([5b7d6b0](https://github.com/dynamic-labs/DynamicAuth/commit/5b7d6b0a9ea84811a8252b3cdf30a3a8e410180c))
|
|
180
|
+
* add walletbook configurations for solana injected wallets ([#4360](https://github.com/dynamic-labs/DynamicAuth/issues/4360)) ([cdc8e5f](https://github.com/dynamic-labs/DynamicAuth/commit/cdc8e5f4878cb84e26e5b33299aa8547b84b6667))
|
|
181
|
+
* passkey renaming frontend ([#4331](https://github.com/dynamic-labs/DynamicAuth/issues/4331)) ([4551013](https://github.com/dynamic-labs/DynamicAuth/commit/4551013d577c914cb3aedfe458ab9eaa018aceb4))
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
### Bug Fixes
|
|
185
|
+
|
|
186
|
+
* correctly update wallets connected flag after wallet switch ([#4397](https://github.com/dynamic-labs/DynamicAuth/issues/4397)) ([543a830](https://github.com/dynamic-labs/DynamicAuth/commit/543a830574f0d5a78fedbb9b18233e8dfbaddd86))
|
|
187
|
+
* export modal header ([#4401](https://github.com/dynamic-labs/DynamicAuth/issues/4401)) ([77cf016](https://github.com/dynamic-labs/DynamicAuth/commit/77cf016fc742458988864647870149a56e991ee4))
|
|
188
|
+
* trigger onAuthSuccess before embedded wallet creation ([4aa341a](https://github.com/dynamic-labs/DynamicAuth/commit/4aa341a1d08332a121daddb7c2dcb09a804a4de7))
|
|
189
|
+
* ui issues on react 17 ([#4373](https://github.com/dynamic-labs/DynamicAuth/issues/4373)) ([93096d6](https://github.com/dynamic-labs/DynamicAuth/commit/93096d6017816a4f0ed299bf618b130d90c81514))
|
|
190
|
+
|
|
191
|
+
## [1.1.0-alpha.10](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.9...v1.1.0-alpha.10) (2024-01-06)
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
### Bug Fixes
|
|
195
|
+
|
|
196
|
+
* pass flow network to magic client ([#4322](https://github.com/dynamic-labs/DynamicAuth/issues/4322)) ([f3adccf](https://github.com/dynamic-labs/DynamicAuth/commit/f3adccf9f8d835f6b04e4767acd0fbd2ac238379))
|
|
197
|
+
* prevent error message when mobile wallet app is open ([#4301](https://github.com/dynamic-labs/DynamicAuth/issues/4301)) ([2a66dcf](https://github.com/dynamic-labs/DynamicAuth/commit/2a66dcfaf8100b3d910c559d35d8b731b1cb380e))
|
|
198
|
+
* turnkeyWalletConnector is not an email otp connector and uses dynamic otp ([#4313](https://github.com/dynamic-labs/DynamicAuth/issues/4313)) ([e4ea56f](https://github.com/dynamic-labs/DynamicAuth/commit/e4ea56f40fdf97b3f5440b016ebd95501089cebe))
|
|
199
|
+
|
|
2
200
|
## [1.1.0-alpha.9](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.8...v1.1.0-alpha.9) (2024-01-04)
|
|
3
201
|
|
|
4
202
|
|
package/_virtual/_tslib.cjs
CHANGED
|
@@ -25,6 +25,11 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
25
25
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
26
26
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
27
27
|
});
|
|
28
|
-
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
31
|
+
var e = new Error(message);
|
|
32
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
33
|
+
};
|
|
29
34
|
|
|
30
35
|
exports.__awaiter = __awaiter;
|
package/_virtual/_tslib.js
CHANGED
|
@@ -21,6 +21,11 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
21
21
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
22
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
23
|
});
|
|
24
|
-
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
27
|
+
var e = new Error(message);
|
|
28
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
29
|
+
};
|
|
25
30
|
|
|
26
31
|
export { __awaiter };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/bitcoin",
|
|
3
|
-
"version": "1.1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/dynamic-labs/DynamicAuth.git",
|
|
@@ -26,12 +26,16 @@
|
|
|
26
26
|
"./package.json": "./package.json"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
+
"@btckit/types": "^0.0.19",
|
|
30
|
+
"@dynamic-labs/sdk-api": "0.0.363",
|
|
29
31
|
"@wallet-standard/app": "^1.0.1",
|
|
30
32
|
"@wallet-standard/base": "^1.0.1",
|
|
33
|
+
"bitcoinjs-lib": "^6.1.5",
|
|
31
34
|
"sats-connect": "^1.1.2",
|
|
32
|
-
"@dynamic-labs/utils": "1.1.0
|
|
33
|
-
"@dynamic-labs/wallet-book": "1.1.0
|
|
34
|
-
"@dynamic-labs/wallet-connector-core": "1.1.0
|
|
35
|
+
"@dynamic-labs/utils": "1.1.0",
|
|
36
|
+
"@dynamic-labs/wallet-book": "1.1.0",
|
|
37
|
+
"@dynamic-labs/wallet-connector-core": "1.1.0",
|
|
38
|
+
"stream": "0.0.2"
|
|
35
39
|
},
|
|
36
40
|
"peerDependencies": {}
|
|
37
41
|
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _tslib = require('../_virtual/_tslib.cjs');
|
|
6
|
+
var satsConnect = require('sats-connect');
|
|
7
|
+
var bitcoinjsLib = require('bitcoinjs-lib');
|
|
8
|
+
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
9
|
+
var BitcoinWalletConnector = require('./BitcoinWalletConnector.cjs');
|
|
10
|
+
var validatePsbt = require('./utils/psbt/validator/validatePsbt.cjs');
|
|
11
|
+
var bitcoinNetworkTypeToNetworks = require('./utils/psbt/bitcoinNetworkTypeToNetworks.cjs');
|
|
12
|
+
|
|
13
|
+
class BitcoinBtcKitConnector extends BitcoinWalletConnector.BitcoinWalletConnector {
|
|
14
|
+
constructor(opts, btcKit) {
|
|
15
|
+
super(opts);
|
|
16
|
+
this.currentNetwork = satsConnect.BitcoinNetworkType.Mainnet;
|
|
17
|
+
this.btcKit = btcKit;
|
|
18
|
+
}
|
|
19
|
+
fetchPublicAddress() {
|
|
20
|
+
var _a;
|
|
21
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
const [connectedAccount] = yield this.getConnectedAccounts();
|
|
23
|
+
if (connectedAccount) {
|
|
24
|
+
return connectedAccount;
|
|
25
|
+
}
|
|
26
|
+
const response = yield this.btcKit.request('getAddresses', {
|
|
27
|
+
types: ['p2tr', 'p2wpkh'],
|
|
28
|
+
});
|
|
29
|
+
if (!('result' in response)) {
|
|
30
|
+
walletConnectorCore.logger.error('Fetch public address error', response);
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
const { addresses } = response.result;
|
|
34
|
+
const ordinalsAccount = addresses === null || addresses === void 0 ? void 0 : addresses.find((address) => address.type === 'p2tr');
|
|
35
|
+
const paymentAccount = addresses === null || addresses === void 0 ? void 0 : addresses.find((address) => address.type === 'p2wpkh');
|
|
36
|
+
const mainAddress = (_a = ordinalsAccount === null || ordinalsAccount === void 0 ? void 0 : ordinalsAccount.address) !== null && _a !== void 0 ? _a : paymentAccount === null || paymentAccount === void 0 ? void 0 : paymentAccount.address;
|
|
37
|
+
yield this.setConnectedAccountWithAddresses(mainAddress, ordinalsAccount, paymentAccount, true);
|
|
38
|
+
return mainAddress;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
signMessage(messageToSign) {
|
|
42
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
if (!(yield this.getConnectedAccounts()).length)
|
|
44
|
+
return undefined;
|
|
45
|
+
const response = yield this.btcKit
|
|
46
|
+
.request('signMessage', {
|
|
47
|
+
message: messageToSign,
|
|
48
|
+
paymentType: 'p2tr',
|
|
49
|
+
})
|
|
50
|
+
.catch(({ error }) => {
|
|
51
|
+
throw error;
|
|
52
|
+
});
|
|
53
|
+
if (!('result' in response)) {
|
|
54
|
+
walletConnectorCore.logger.error('Signature error', response);
|
|
55
|
+
throw new Error('Failed to sign message');
|
|
56
|
+
}
|
|
57
|
+
return response.result.signature;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
sendBitcoin(transaction) {
|
|
61
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
const connectedAddress = yield this.fetchPublicAddress();
|
|
63
|
+
if (!connectedAddress || !this.btcKit) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const response = yield this.btcKit.request('sendTransfer', {
|
|
67
|
+
address: transaction.recipientAddress,
|
|
68
|
+
amount: transaction.amount,
|
|
69
|
+
});
|
|
70
|
+
if (!('result' in response)) {
|
|
71
|
+
walletConnectorCore.logger.error('Transaction error', response);
|
|
72
|
+
throw new Error('Failed to send transaction');
|
|
73
|
+
}
|
|
74
|
+
return response.result.txid;
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
signPsbt(request) {
|
|
78
|
+
var _a, _b;
|
|
79
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
const connectedAddress = yield this.fetchPublicAddress();
|
|
81
|
+
if (!connectedAddress || !this.btcKit) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const network = bitcoinNetworkTypeToNetworks.convertNetworkTypeForPsbt(this.currentNetwork);
|
|
85
|
+
const psbtFromBase64 = bitcoinjsLib.Psbt.fromBase64(request.unsignedPsbtBase64, {
|
|
86
|
+
network,
|
|
87
|
+
});
|
|
88
|
+
if ((_a = request.signature) === null || _a === void 0 ? void 0 : _a.length) {
|
|
89
|
+
validatePsbt.validatePsbt(psbtFromBase64, request.allowedSighash, request.signature);
|
|
90
|
+
}
|
|
91
|
+
const signPsbtRequestParams = {
|
|
92
|
+
allowedSighash: request.allowedSighash,
|
|
93
|
+
hex: psbtFromBase64.toHex(),
|
|
94
|
+
signAtIndex: (_b = request.signature) === null || _b === void 0 ? void 0 : _b.flatMap((sig) => sig.signingIndexes).filter(Number.isInteger),
|
|
95
|
+
};
|
|
96
|
+
const signedPsbtResponse = (yield this.btcKit.request('signPsbt', Object.assign({ broadcast: false, network }, signPsbtRequestParams)));
|
|
97
|
+
if (!signedPsbtResponse ||
|
|
98
|
+
!('result' in signedPsbtResponse) ||
|
|
99
|
+
!('hex' in signedPsbtResponse.result)) {
|
|
100
|
+
throw new Error('signPsbt - failed to sign PSBT');
|
|
101
|
+
}
|
|
102
|
+
const psbtHex = signedPsbtResponse.result.hex;
|
|
103
|
+
return { signedPsbt: bitcoinjsLib.Psbt.fromHex(psbtHex, { network }).toBase64() };
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
exports.BitcoinBtcKitConnector = BitcoinBtcKitConnector;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { BtcKitListenFn, BtcKitRequestFn } from '@btckit/types';
|
|
2
|
+
import { BitcoinNetworkType } from 'sats-connect';
|
|
3
|
+
import { BitcoinWalletConnector, BitcoinWalletConnectorOpts } from './BitcoinWalletConnector';
|
|
4
|
+
import { BitcoinTransaction, BitcoinSignPsbtRequest, BitcoinSignPsbtResponse } from './types';
|
|
5
|
+
export type BtcKitProvider = {
|
|
6
|
+
request: BtcKitRequestFn;
|
|
7
|
+
listen: BtcKitListenFn;
|
|
8
|
+
};
|
|
9
|
+
export declare abstract class BitcoinBtcKitConnector extends BitcoinWalletConnector {
|
|
10
|
+
currentNetwork: BitcoinNetworkType;
|
|
11
|
+
private btcKit;
|
|
12
|
+
constructor(opts: BitcoinWalletConnectorOpts, btcKit: BtcKitProvider);
|
|
13
|
+
fetchPublicAddress(): Promise<string | undefined>;
|
|
14
|
+
signMessage(messageToSign: string): Promise<string | undefined>;
|
|
15
|
+
sendBitcoin(transaction: BitcoinTransaction): Promise<string | undefined>;
|
|
16
|
+
signPsbt(request: BitcoinSignPsbtRequest): Promise<BitcoinSignPsbtResponse | undefined>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { __awaiter } from '../_virtual/_tslib.js';
|
|
2
|
+
import { BitcoinNetworkType } from 'sats-connect';
|
|
3
|
+
import { Psbt } from 'bitcoinjs-lib';
|
|
4
|
+
import { logger } from '@dynamic-labs/wallet-connector-core';
|
|
5
|
+
import { BitcoinWalletConnector } from './BitcoinWalletConnector.js';
|
|
6
|
+
import { validatePsbt } from './utils/psbt/validator/validatePsbt.js';
|
|
7
|
+
import { convertNetworkTypeForPsbt } from './utils/psbt/bitcoinNetworkTypeToNetworks.js';
|
|
8
|
+
|
|
9
|
+
class BitcoinBtcKitConnector extends BitcoinWalletConnector {
|
|
10
|
+
constructor(opts, btcKit) {
|
|
11
|
+
super(opts);
|
|
12
|
+
this.currentNetwork = BitcoinNetworkType.Mainnet;
|
|
13
|
+
this.btcKit = btcKit;
|
|
14
|
+
}
|
|
15
|
+
fetchPublicAddress() {
|
|
16
|
+
var _a;
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
const [connectedAccount] = yield this.getConnectedAccounts();
|
|
19
|
+
if (connectedAccount) {
|
|
20
|
+
return connectedAccount;
|
|
21
|
+
}
|
|
22
|
+
const response = yield this.btcKit.request('getAddresses', {
|
|
23
|
+
types: ['p2tr', 'p2wpkh'],
|
|
24
|
+
});
|
|
25
|
+
if (!('result' in response)) {
|
|
26
|
+
logger.error('Fetch public address error', response);
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
const { addresses } = response.result;
|
|
30
|
+
const ordinalsAccount = addresses === null || addresses === void 0 ? void 0 : addresses.find((address) => address.type === 'p2tr');
|
|
31
|
+
const paymentAccount = addresses === null || addresses === void 0 ? void 0 : addresses.find((address) => address.type === 'p2wpkh');
|
|
32
|
+
const mainAddress = (_a = ordinalsAccount === null || ordinalsAccount === void 0 ? void 0 : ordinalsAccount.address) !== null && _a !== void 0 ? _a : paymentAccount === null || paymentAccount === void 0 ? void 0 : paymentAccount.address;
|
|
33
|
+
yield this.setConnectedAccountWithAddresses(mainAddress, ordinalsAccount, paymentAccount, true);
|
|
34
|
+
return mainAddress;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
signMessage(messageToSign) {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
if (!(yield this.getConnectedAccounts()).length)
|
|
40
|
+
return undefined;
|
|
41
|
+
const response = yield this.btcKit
|
|
42
|
+
.request('signMessage', {
|
|
43
|
+
message: messageToSign,
|
|
44
|
+
paymentType: 'p2tr',
|
|
45
|
+
})
|
|
46
|
+
.catch(({ error }) => {
|
|
47
|
+
throw error;
|
|
48
|
+
});
|
|
49
|
+
if (!('result' in response)) {
|
|
50
|
+
logger.error('Signature error', response);
|
|
51
|
+
throw new Error('Failed to sign message');
|
|
52
|
+
}
|
|
53
|
+
return response.result.signature;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
sendBitcoin(transaction) {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
const connectedAddress = yield this.fetchPublicAddress();
|
|
59
|
+
if (!connectedAddress || !this.btcKit) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const response = yield this.btcKit.request('sendTransfer', {
|
|
63
|
+
address: transaction.recipientAddress,
|
|
64
|
+
amount: transaction.amount,
|
|
65
|
+
});
|
|
66
|
+
if (!('result' in response)) {
|
|
67
|
+
logger.error('Transaction error', response);
|
|
68
|
+
throw new Error('Failed to send transaction');
|
|
69
|
+
}
|
|
70
|
+
return response.result.txid;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
signPsbt(request) {
|
|
74
|
+
var _a, _b;
|
|
75
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
const connectedAddress = yield this.fetchPublicAddress();
|
|
77
|
+
if (!connectedAddress || !this.btcKit) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const network = convertNetworkTypeForPsbt(this.currentNetwork);
|
|
81
|
+
const psbtFromBase64 = Psbt.fromBase64(request.unsignedPsbtBase64, {
|
|
82
|
+
network,
|
|
83
|
+
});
|
|
84
|
+
if ((_a = request.signature) === null || _a === void 0 ? void 0 : _a.length) {
|
|
85
|
+
validatePsbt(psbtFromBase64, request.allowedSighash, request.signature);
|
|
86
|
+
}
|
|
87
|
+
const signPsbtRequestParams = {
|
|
88
|
+
allowedSighash: request.allowedSighash,
|
|
89
|
+
hex: psbtFromBase64.toHex(),
|
|
90
|
+
signAtIndex: (_b = request.signature) === null || _b === void 0 ? void 0 : _b.flatMap((sig) => sig.signingIndexes).filter(Number.isInteger),
|
|
91
|
+
};
|
|
92
|
+
const signedPsbtResponse = (yield this.btcKit.request('signPsbt', Object.assign({ broadcast: false, network }, signPsbtRequestParams)));
|
|
93
|
+
if (!signedPsbtResponse ||
|
|
94
|
+
!('result' in signedPsbtResponse) ||
|
|
95
|
+
!('hex' in signedPsbtResponse.result)) {
|
|
96
|
+
throw new Error('signPsbt - failed to sign PSBT');
|
|
97
|
+
}
|
|
98
|
+
const psbtHex = signedPsbtResponse.result.hex;
|
|
99
|
+
return { signedPsbt: Psbt.fromHex(psbtHex, { network }).toBase64() };
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export { BitcoinBtcKitConnector };
|
|
@@ -7,32 +7,64 @@ var utils = require('@dynamic-labs/utils');
|
|
|
7
7
|
|
|
8
8
|
class BitcoinLocalStorageCache {
|
|
9
9
|
constructor(key) {
|
|
10
|
-
this.
|
|
10
|
+
this.CONNECTED_ACCOUNTS_KEY = `bitcoin_${key}_connectedAccounts`;
|
|
11
11
|
this.LAST_BALANCE_KEY = `bitcoin_${key}_lastBalance`;
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
getActiveAccount() {
|
|
14
14
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
15
|
-
const
|
|
16
|
-
|
|
15
|
+
const connectedAccounts = yield utils.getItemAsync(this.CONNECTED_ACCOUNTS_KEY);
|
|
16
|
+
if (!connectedAccounts) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const activeAddress = Object.keys(connectedAccounts).find((key) => connectedAccounts[key].active);
|
|
20
|
+
if (!activeAddress) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
additionalAddresses: connectedAccounts[activeAddress].additionalAddresses,
|
|
25
|
+
address: activeAddress,
|
|
26
|
+
};
|
|
17
27
|
});
|
|
18
28
|
}
|
|
19
|
-
|
|
29
|
+
getConnectedAccounts() {
|
|
20
30
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
|
|
31
|
+
const connectedAccounts = yield utils.getItemAsync(this.CONNECTED_ACCOUNTS_KEY);
|
|
32
|
+
return connectedAccounts;
|
|
22
33
|
});
|
|
23
34
|
}
|
|
24
|
-
|
|
35
|
+
getConnectedAccount(address) {
|
|
25
36
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
|
|
37
|
+
const connectedAccounts = yield utils.getItemAsync(this.CONNECTED_ACCOUNTS_KEY);
|
|
38
|
+
return connectedAccounts === null || connectedAccounts === void 0 ? void 0 : connectedAccounts[address];
|
|
27
39
|
});
|
|
28
40
|
}
|
|
29
|
-
|
|
41
|
+
setConnectedAccount(addess, account) {
|
|
30
42
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
31
|
-
|
|
32
|
-
if (!
|
|
33
|
-
|
|
43
|
+
let connectedAccounts = yield utils.getItemAsync(this.CONNECTED_ACCOUNTS_KEY);
|
|
44
|
+
if (!connectedAccounts) {
|
|
45
|
+
connectedAccounts = {};
|
|
34
46
|
}
|
|
35
|
-
|
|
47
|
+
// if current account is active, reset all other accounts to inactive
|
|
48
|
+
if (account.active) {
|
|
49
|
+
Object.keys(connectedAccounts).forEach((key) => {
|
|
50
|
+
if (connectedAccounts) {
|
|
51
|
+
connectedAccounts[key].active = false;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
// add new account to map or override existing one
|
|
56
|
+
connectedAccounts[addess] = account;
|
|
57
|
+
return utils.setItemAsync(this.CONNECTED_ACCOUNTS_KEY, connectedAccounts);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
clearConnectedAcccounts() {
|
|
61
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
return utils.removeItemAsync(this.CONNECTED_ACCOUNTS_KEY);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
getLastBalance() {
|
|
66
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
return utils.getItemAsync(this.LAST_BALANCE_KEY);
|
|
36
68
|
});
|
|
37
69
|
}
|
|
38
70
|
setLastBalance(balance) {
|
|
@@ -1,20 +1,33 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { WalletAdditionalAddress } from '@dynamic-labs/sdk-api';
|
|
2
|
+
import { BitcoinConnectedAccount } from './types';
|
|
3
|
+
type BitcoinConnectedAccounts = {
|
|
4
|
+
[key: string]: BitcoinConnectedAccount;
|
|
5
|
+
};
|
|
6
|
+
type BitcoinActiveAccount = {
|
|
7
|
+
address: string;
|
|
8
|
+
additionalAddresses: WalletAdditionalAddress[];
|
|
9
|
+
};
|
|
2
10
|
export declare class BitcoinLocalStorageCache implements IBitcoinSessionCache {
|
|
3
|
-
private readonly
|
|
11
|
+
private readonly CONNECTED_ACCOUNTS_KEY;
|
|
4
12
|
private readonly LAST_BALANCE_KEY;
|
|
5
13
|
constructor(key: string);
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
14
|
+
getActiveAccount(): Promise<BitcoinActiveAccount | undefined>;
|
|
15
|
+
getConnectedAccounts(): Promise<BitcoinConnectedAccounts | undefined>;
|
|
16
|
+
getConnectedAccount(address: string): Promise<BitcoinConnectedAccount | undefined>;
|
|
17
|
+
setConnectedAccount(addess: string, account: BitcoinConnectedAccount): Promise<void>;
|
|
18
|
+
clearConnectedAcccounts(): Promise<void>;
|
|
9
19
|
getLastBalance(): Promise<string | undefined>;
|
|
10
20
|
setLastBalance(balance: string): Promise<void>;
|
|
11
21
|
clearLastBalance(): Promise<void>;
|
|
12
22
|
}
|
|
13
23
|
export interface IBitcoinSessionCache {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
24
|
+
clearConnectedAcccounts(): Promise<void>;
|
|
25
|
+
getActiveAccount(): Promise<BitcoinActiveAccount | undefined>;
|
|
26
|
+
getConnectedAccount(address: string): Promise<BitcoinConnectedAccount | undefined>;
|
|
27
|
+
getConnectedAccounts(): Promise<BitcoinConnectedAccounts | undefined>;
|
|
28
|
+
setConnectedAccount(addess: string, account: BitcoinConnectedAccount): Promise<void>;
|
|
17
29
|
clearLastBalance(): Promise<void>;
|
|
18
30
|
getLastBalance(): Promise<string | undefined>;
|
|
19
31
|
setLastBalance(balance: string): Promise<void>;
|
|
20
32
|
}
|
|
33
|
+
export {};
|