@dynamic-labs/starknet 3.0.0-alpha.5 → 3.0.0-alpha.50
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 +463 -0
- package/package.json +8 -6
- package/src/index.cjs +2 -0
- package/src/index.js +2 -0
- package/src/starknetWalletConnector.cjs +31 -15
- package/src/starknetWalletConnector.d.ts +18 -1
- package/src/starknetWalletConnector.js +31 -15
- package/src/types.d.ts +1 -1
- package/src/utils/starknetSnap.cjs +92 -0
- package/src/utils/starknetSnap.d.ts +8 -0
- package/src/utils/starknetSnap.js +88 -0
- package/src/wallets/metamask.cjs +121 -0
- package/src/wallets/metamask.d.ts +14 -0
- package/src/wallets/metamask.js +117 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,467 @@
|
|
|
1
1
|
|
|
2
|
+
## [3.0.0-alpha.50](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.49...v3.0.0-alpha.50) (2024-08-22)
|
|
3
|
+
|
|
4
|
+
## [3.0.0-alpha.49](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.48...v3.0.0-alpha.49) (2024-08-22)
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
### ⚠ BREAKING CHANGES
|
|
8
|
+
|
|
9
|
+
* rename viem-utils package to ethereum-core (#6677)
|
|
10
|
+
* remove ethers-v5 package (#6661)
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* force ui on global transactions and fix zerodev global ([#6673](https://github.com/dynamic-labs/DynamicAuth/issues/6673)) ([7317e44](https://github.com/dynamic-labs/DynamicAuth/commit/7317e449044fe4f87d67714afd36bec596d0cece))
|
|
15
|
+
* remove sync call in getWalletClient getSigner methods ([#6678](https://github.com/dynamic-labs/DynamicAuth/issues/6678)) ([a231337](https://github.com/dynamic-labs/DynamicAuth/commit/a231337f81be54d92715044b7dc8bb35c57087bb))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
* remove ethers-v5 package ([#6661](https://github.com/dynamic-labs/DynamicAuth/issues/6661)) ([61cc31b](https://github.com/dynamic-labs/DynamicAuth/commit/61cc31ba4b8346b86a154aabf8842fd38396d632))
|
|
19
|
+
* rename viem-utils package to ethereum-core ([#6677](https://github.com/dynamic-labs/DynamicAuth/issues/6677)) ([ba7fd43](https://github.com/dynamic-labs/DynamicAuth/commit/ba7fd432e332b9f20a4f7aa9403f94722331cde6))
|
|
20
|
+
|
|
21
|
+
## [3.0.0-alpha.48](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.47...v3.0.0-alpha.48) (2024-08-21)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Bug Fixes
|
|
25
|
+
|
|
26
|
+
* collect user data to work when no wallet is selected ([#6670](https://github.com/dynamic-labs/DynamicAuth/issues/6670)) ([b86aae8](https://github.com/dynamic-labs/DynamicAuth/commit/b86aae8e7ceb35793f792941a34cabd19b9e65d4))
|
|
27
|
+
* disable cookie when running on native mobile ([#6668](https://github.com/dynamic-labs/DynamicAuth/issues/6668)) ([e52a3d9](https://github.com/dynamic-labs/DynamicAuth/commit/e52a3d94a9028e36525be2e80a9f0916efad4320))
|
|
28
|
+
* prevent external auth blocking pending user requirements views ([#6669](https://github.com/dynamic-labs/DynamicAuth/issues/6669)) ([848356c](https://github.com/dynamic-labs/DynamicAuth/commit/848356c57e730a8516c642da84274a236e026f40))
|
|
29
|
+
|
|
30
|
+
## [3.0.0-alpha.47](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.46...v3.0.0-alpha.47) (2024-08-21)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### ⚠ BREAKING CHANGES
|
|
34
|
+
|
|
35
|
+
* rename useSelectWalletOption to useWalletOptions (#6616)
|
|
36
|
+
* stop exposing walletConnectorOptions from dynamic context (#6622)
|
|
37
|
+
|
|
38
|
+
### Features
|
|
39
|
+
|
|
40
|
+
* add support for base.eth ens resolution ([#6655](https://github.com/dynamic-labs/DynamicAuth/issues/6655)) ([e2fb1c0](https://github.com/dynamic-labs/DynamicAuth/commit/e2fb1c0ca8410e85b7464d032abc6686bd46149f))
|
|
41
|
+
* expose wallet options from useWalletOptions hook ([#6624](https://github.com/dynamic-labs/DynamicAuth/issues/6624)) ([7287359](https://github.com/dynamic-labs/DynamicAuth/commit/7287359d1564564b87e82bf182edef8ef02c16f1))
|
|
42
|
+
* global wallet chain switching ([#6648](https://github.com/dynamic-labs/DynamicAuth/issues/6648)) ([10179fc](https://github.com/dynamic-labs/DynamicAuth/commit/10179fcddc747977c7dd250abd78bad0ec375f8f))
|
|
43
|
+
* implement Apple Sign-In for mobile ([#6632](https://github.com/dynamic-labs/DynamicAuth/issues/6632)) ([e68b088](https://github.com/dynamic-labs/DynamicAuth/commit/e68b088b1c13c1140b43a6d0c215383455a71a4a))
|
|
44
|
+
* surface mfa rate limit error ([#6658](https://github.com/dynamic-labs/DynamicAuth/issues/6658)) ([5fbcbc2](https://github.com/dynamic-labs/DynamicAuth/commit/5fbcbc2382ebcf2721a308d8e87bc8b2b5cb38cf))
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
### Bug Fixes
|
|
48
|
+
|
|
49
|
+
* update bottom nav border radius ([#6651](https://github.com/dynamic-labs/DynamicAuth/issues/6651)) ([79212c2](https://github.com/dynamic-labs/DynamicAuth/commit/79212c26735eb06f31655e8b98a3d9c2c8371489))
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
* rename useSelectWalletOption to useWalletOptions ([#6616](https://github.com/dynamic-labs/DynamicAuth/issues/6616)) ([3850dad](https://github.com/dynamic-labs/DynamicAuth/commit/3850dad47f847ace84aadc63a84c4e62f84f7df2))
|
|
53
|
+
* stop exposing walletConnectorOptions from dynamic context ([#6622](https://github.com/dynamic-labs/DynamicAuth/issues/6622)) ([b9da7db](https://github.com/dynamic-labs/DynamicAuth/commit/b9da7dbfc4020913ba3d95ec496811e9d8ee17b8))
|
|
54
|
+
|
|
55
|
+
## [3.0.0-alpha.46](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.45...v3.0.0-alpha.46) (2024-08-19)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
### Features
|
|
59
|
+
|
|
60
|
+
* add overrides for chain info ([#6614](https://github.com/dynamic-labs/DynamicAuth/issues/6614)) ([07b76a0](https://github.com/dynamic-labs/DynamicAuth/commit/07b76a0887d3147a00d93a37bdf49a83bfec0ceb))
|
|
61
|
+
* add use token balances state in global store ([#6598](https://github.com/dynamic-labs/DynamicAuth/issues/6598)) ([05baefe](https://github.com/dynamic-labs/DynamicAuth/commit/05baefe7155f197c048557b15240ad93556a8604))
|
|
62
|
+
* refresh token balances ([#6578](https://github.com/dynamic-labs/DynamicAuth/issues/6578)) ([0768857](https://github.com/dynamic-labs/DynamicAuth/commit/0768857c924ce0e01b736173e50ea85b956ab067))
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
### Bug Fixes
|
|
66
|
+
|
|
67
|
+
* createEmbeddedWalletAccount ([#6642](https://github.com/dynamic-labs/DynamicAuth/issues/6642)) ([bce08de](https://github.com/dynamic-labs/DynamicAuth/commit/bce08deaa4a5e1ea0b134efb5c4d252c82af5eec))
|
|
68
|
+
* jwt x error when singing with embedded wallet ([#6633](https://github.com/dynamic-labs/DynamicAuth/issues/6633)) ([7d1a6d4](https://github.com/dynamic-labs/DynamicAuth/commit/7d1a6d432807c5b361ff31e6feac2e10d0145d90))
|
|
69
|
+
|
|
70
|
+
## [3.0.0-alpha.45](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.44...v3.0.0-alpha.45) (2024-08-16)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
### Bug Fixes
|
|
74
|
+
|
|
75
|
+
* always check for dynamicOauthCode and use during signin or verify ([#6618](https://github.com/dynamic-labs/DynamicAuth/issues/6618)) ([dd33231](https://github.com/dynamic-labs/DynamicAuth/commit/dd332310c9fdfa7bb593b7f567751133a93c6938))
|
|
76
|
+
* display qr code when no primary is selected ([#6605](https://github.com/dynamic-labs/DynamicAuth/issues/6605)) ([406afa3](https://github.com/dynamic-labs/DynamicAuth/commit/406afa32b38a29a2d8ce96803ae45ab35adb5ce3))
|
|
77
|
+
|
|
78
|
+
## [3.0.0-alpha.44](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.43...v3.0.0-alpha.44) (2024-08-15)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
### Bug Fixes
|
|
82
|
+
|
|
83
|
+
* populate wallet new isPrimary flag ([#6597](https://github.com/dynamic-labs/DynamicAuth/issues/6597)) ([7809f81](https://github.com/dynamic-labs/DynamicAuth/commit/7809f81c9743b8bf7bc27dc34cf45923cf9baf99))
|
|
84
|
+
* twitter should no longer rely polling for oauth flow ([#6603](https://github.com/dynamic-labs/DynamicAuth/issues/6603)) ([09aea8b](https://github.com/dynamic-labs/DynamicAuth/commit/09aea8b3f197c25dcfb5bc72049b90859df246f3))
|
|
85
|
+
|
|
86
|
+
## [3.0.0-alpha.43](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.42...v3.0.0-alpha.43) (2024-08-15)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
### ⚠ BREAKING CHANGES
|
|
90
|
+
|
|
91
|
+
* removes walletConnector from dynamic context (#6579)
|
|
92
|
+
* removed deprecated props from user profile (#6589)
|
|
93
|
+
|
|
94
|
+
### Features
|
|
95
|
+
|
|
96
|
+
* optimize solana embedded transactions ([#6582](https://github.com/dynamic-labs/DynamicAuth/issues/6582)) ([419aff9](https://github.com/dynamic-labs/DynamicAuth/commit/419aff96d312892d7db520e94ecc6956b8de771d))
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
### Bug Fixes
|
|
100
|
+
|
|
101
|
+
* check if wallet is connected using normalized addresses ([#6594](https://github.com/dynamic-labs/DynamicAuth/issues/6594)) ([44aabae](https://github.com/dynamic-labs/DynamicAuth/commit/44aabae8ee72261bf0f7e308ed4adf0f42760ed2))
|
|
102
|
+
* minor sdk ui updates ([#6590](https://github.com/dynamic-labs/DynamicAuth/issues/6590)) ([8619e40](https://github.com/dynamic-labs/DynamicAuth/commit/8619e40e1afff8d68357138f3b5b9b89989140fd))
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
* removed deprecated props from user profile ([#6589](https://github.com/dynamic-labs/DynamicAuth/issues/6589)) ([b621da8](https://github.com/dynamic-labs/DynamicAuth/commit/b621da8a0703eb8228a5b10131af2717f314fd2e))
|
|
106
|
+
* removes walletConnector from dynamic context ([#6579](https://github.com/dynamic-labs/DynamicAuth/issues/6579)) ([51d69fe](https://github.com/dynamic-labs/DynamicAuth/commit/51d69feebab71158ad2aa69f11001623a0aaa80a))
|
|
107
|
+
|
|
108
|
+
## [3.0.0-alpha.42](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.41...v3.0.0-alpha.42) (2024-08-14)
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
### Bug Fixes
|
|
112
|
+
|
|
113
|
+
* isEmbeddedWallet condition in AuthProviderIcon ([#6581](https://github.com/dynamic-labs/DynamicAuth/issues/6581)) ([afe33ab](https://github.com/dynamic-labs/DynamicAuth/commit/afe33aba1cc8abefd0566bf4e9c0a4f199d64ef7))
|
|
114
|
+
* update text on MFA backup codes acknowledgement ([#6559](https://github.com/dynamic-labs/DynamicAuth/issues/6559)) ([98b5475](https://github.com/dynamic-labs/DynamicAuth/commit/98b5475df73039061d593318cb26140075de69e1))
|
|
115
|
+
|
|
116
|
+
## [3.0.0-alpha.41](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.40...v3.0.0-alpha.41) (2024-08-13)
|
|
117
|
+
|
|
118
|
+
## [3.0.0-alpha.40](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.39...v3.0.0-alpha.40) (2024-08-13)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
### Features
|
|
122
|
+
|
|
123
|
+
* add log out button to mfa screens ([#6557](https://github.com/dynamic-labs/DynamicAuth/issues/6557)) ([a006f6a](https://github.com/dynamic-labs/DynamicAuth/commit/a006f6a3f801a93d305fbd8151a51c7b08b73983))
|
|
124
|
+
* signIn/link using dynamicOauthState ([#6523](https://github.com/dynamic-labs/DynamicAuth/issues/6523)) ([b72e98f](https://github.com/dynamic-labs/DynamicAuth/commit/b72e98f0d243591c1a8ca14c3a4a6e5024560141))
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
### Bug Fixes
|
|
128
|
+
|
|
129
|
+
* clicking back on MFA verification view should take you to MFA secure device view ([#6556](https://github.com/dynamic-labs/DynamicAuth/issues/6556)) ([7ae39c9](https://github.com/dynamic-labs/DynamicAuth/commit/7ae39c9b073b42a14d3e77fba28217905a1dbf0c))
|
|
130
|
+
* mfa design feedback ([#6551](https://github.com/dynamic-labs/DynamicAuth/issues/6551)) ([c367e38](https://github.com/dynamic-labs/DynamicAuth/commit/c367e3836e331a2dc24496ea81436b6bd57460a1))
|
|
131
|
+
* remove 2 factor authenticator header unless there is an applicable security option available ([#6545](https://github.com/dynamic-labs/DynamicAuth/issues/6545)) ([11f7f5a](https://github.com/dynamic-labs/DynamicAuth/commit/11f7f5ae87bf26be783c353607b39943e4a2b796))
|
|
132
|
+
|
|
133
|
+
## [3.0.0-alpha.39](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.38...v3.0.0-alpha.39) (2024-08-09)
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
### Features
|
|
137
|
+
|
|
138
|
+
* add MFA settings ([e5a5755](https://github.com/dynamic-labs/DynamicAuth/commit/e5a5755a6349d3076c0e4fb8bab0853784bef9cc))
|
|
139
|
+
|
|
140
|
+
## [3.0.0-alpha.38](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.37...v3.0.0-alpha.38) (2024-08-09)
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
### Features
|
|
144
|
+
|
|
145
|
+
* add dynamic footer options switcher ([#6528](https://github.com/dynamic-labs/DynamicAuth/issues/6528)) ([7d8a7ff](https://github.com/dynamic-labs/DynamicAuth/commit/7d8a7ff5c7d07e3ac2a916bd8b37e87e7cbfdaa2))
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
### Bug Fixes
|
|
149
|
+
|
|
150
|
+
* hcaptcha for mobile login ([#6525](https://github.com/dynamic-labs/DynamicAuth/issues/6525)) ([146888e](https://github.com/dynamic-labs/DynamicAuth/commit/146888e91add7f3be3ed4defafc038107648c20a))
|
|
151
|
+
|
|
152
|
+
## [3.0.0-alpha.37](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.36...v3.0.0-alpha.37) (2024-08-08)
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
### Bug Fixes
|
|
156
|
+
|
|
157
|
+
* normalize wallet address before comparing on wallet sync ([#6514](https://github.com/dynamic-labs/DynamicAuth/issues/6514)) ([49d9dcf](https://github.com/dynamic-labs/DynamicAuth/commit/49d9dcf300b360f46ac6618756f6741fffce47a7))
|
|
158
|
+
|
|
159
|
+
## [3.0.0-alpha.36](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.35...v3.0.0-alpha.36) (2024-08-06)
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
### Bug Fixes
|
|
163
|
+
|
|
164
|
+
* emb wallet export with silent signing ([#6493](https://github.com/dynamic-labs/DynamicAuth/issues/6493)) ([af69c3a](https://github.com/dynamic-labs/DynamicAuth/commit/af69c3a85d8c1db6a0bf9b42c1310bf3183f9360))
|
|
165
|
+
* use correct redirect url override when connecting with social ([#6502](https://github.com/dynamic-labs/DynamicAuth/issues/6502)) ([e27a0de](https://github.com/dynamic-labs/DynamicAuth/commit/e27a0ded2ad2d95b80a2ad354accaf57f5228691))
|
|
166
|
+
* wagmi account sync issues when switching wallets ([#6441](https://github.com/dynamic-labs/DynamicAuth/issues/6441)) ([4536f88](https://github.com/dynamic-labs/DynamicAuth/commit/4536f88d41bf4a30cf114e8cd7efd7a211c00889))
|
|
167
|
+
|
|
168
|
+
## [3.0.0-alpha.35](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.34...v3.0.0-alpha.35) (2024-08-06)
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
### Bug Fixes
|
|
172
|
+
|
|
173
|
+
* allow mfa sync to rerun after logout ([#6503](https://github.com/dynamic-labs/DynamicAuth/issues/6503)) ([74377e8](https://github.com/dynamic-labs/DynamicAuth/commit/74377e844a84da422173289a10561eb7acf4f8b9))
|
|
174
|
+
|
|
175
|
+
## [3.0.0-alpha.34](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.33...v3.0.0-alpha.34) (2024-08-02)
|
|
176
|
+
|
|
177
|
+
## [3.0.0-alpha.33](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.32...v3.0.0-alpha.33) (2024-08-02)
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
### Features
|
|
181
|
+
|
|
182
|
+
* add async handler for mfa enrollment and completion ([#6481](https://github.com/dynamic-labs/DynamicAuth/issues/6481)) ([63ce10d](https://github.com/dynamic-labs/DynamicAuth/commit/63ce10dd9f9aa58f43411455d6bbeb2f440ddcac))
|
|
183
|
+
|
|
184
|
+
## [3.0.0-alpha.32](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.31...v3.0.0-alpha.32) (2024-07-30)
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
### Bug Fixes
|
|
188
|
+
|
|
189
|
+
* react native flicker when redirecting back from farcaster ([#6338](https://github.com/dynamic-labs/DynamicAuth/issues/6338)) ([6ab8464](https://github.com/dynamic-labs/DynamicAuth/commit/6ab846476f7961564445223dd12a552ed4c0f0c8))
|
|
190
|
+
* stop unnecessary phantom btc popup when disconnecting - Revert ([#6439](https://github.com/dynamic-labs/DynamicAuth/issues/6439)) ([79ba97d](https://github.com/dynamic-labs/DynamicAuth/commit/79ba97d82c4eb89f0118a925e4dc899853e04550)), closes [#6188](https://github.com/dynamic-labs/DynamicAuth/issues/6188)
|
|
191
|
+
|
|
192
|
+
## [3.0.0-alpha.31](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.30...v3.0.0-alpha.31) (2024-07-27)
|
|
193
|
+
|
|
194
|
+
## [3.0.0-alpha.30](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.29...v3.0.0-alpha.30) (2024-07-27)
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
### Bug Fixes
|
|
198
|
+
|
|
199
|
+
* don't filter out bitcoin.com when searching for bitcoin ([#6408](https://github.com/dynamic-labs/DynamicAuth/issues/6408)) ([6af5456](https://github.com/dynamic-labs/DynamicAuth/commit/6af54567faa430660b2443638adc103e829eb49d))
|
|
200
|
+
* improve metamask starknet snap network polling interval management ([#6424](https://github.com/dynamic-labs/DynamicAuth/issues/6424)) ([22c4376](https://github.com/dynamic-labs/DynamicAuth/commit/22c4376596d5e07d1da30190baf159c43a8956c6))
|
|
201
|
+
* isCookieEnabled should check externalAuth.cookieName ([#6433](https://github.com/dynamic-labs/DynamicAuth/issues/6433)) ([91d95e5](https://github.com/dynamic-labs/DynamicAuth/commit/91d95e5664f70c2eb306082419d6fece9753f220))
|
|
202
|
+
* phantom ledger works on safari ([#6428](https://github.com/dynamic-labs/DynamicAuth/issues/6428)) ([a8a81f6](https://github.com/dynamic-labs/DynamicAuth/commit/a8a81f6fd4d8ae5ba04525ef6ff6a84a1732a03a))
|
|
203
|
+
|
|
204
|
+
## [3.0.0-alpha.29](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.28...v3.0.0-alpha.29) (2024-07-25)
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
### Features
|
|
208
|
+
|
|
209
|
+
* add link to starknet snap companion app in network switch modal ([#6417](https://github.com/dynamic-labs/DynamicAuth/issues/6417)) ([132a3f8](https://github.com/dynamic-labs/DynamicAuth/commit/132a3f84af62930583f042f35e9616bc837ee49d))
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
### Bug Fixes
|
|
213
|
+
|
|
214
|
+
* improve network switch ux for starknet snap on login ([#6376](https://github.com/dynamic-labs/DynamicAuth/issues/6376)) ([db4af65](https://github.com/dynamic-labs/DynamicAuth/commit/db4af6576dc164876750ad6e13f4624d8a11a1a3))
|
|
215
|
+
|
|
216
|
+
## [3.0.0-alpha.28](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.27...v3.0.0-alpha.28) (2024-07-25)
|
|
217
|
+
|
|
218
|
+
## [3.0.0-alpha.27](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.26...v3.0.0-alpha.27) (2024-07-24)
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
### Features
|
|
222
|
+
|
|
223
|
+
* add ability to use a different ecdsa validator ([#6407](https://github.com/dynamic-labs/DynamicAuth/issues/6407)) ([a3e99e1](https://github.com/dynamic-labs/DynamicAuth/commit/a3e99e1b2cdcadbce35ff0cacfb8fb82778c0216))
|
|
224
|
+
|
|
225
|
+
## [3.0.0-alpha.26](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.25...v3.0.0-alpha.26) (2024-07-24)
|
|
226
|
+
|
|
227
|
+
## [3.0.0-alpha.25](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.24...v3.0.0-alpha.25) (2024-07-24)
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
### Features
|
|
231
|
+
|
|
232
|
+
* add ability to specify mobileExperience on a wallet by wallet ([#6195](https://github.com/dynamic-labs/DynamicAuth/issues/6195)) ([947fd0a](https://github.com/dynamic-labs/DynamicAuth/commit/947fd0ab864d1995a1ef35a51c77a585649fd43f))
|
|
233
|
+
* global wallet new package ([#6385](https://github.com/dynamic-labs/DynamicAuth/issues/6385)) ([230a0f3](https://github.com/dynamic-labs/DynamicAuth/commit/230a0f380c2bc8c69619daed0c7f3280da8b8bb9))
|
|
234
|
+
* solana send balance modal for injected ([#6405](https://github.com/dynamic-labs/DynamicAuth/issues/6405)) ([b8aa84b](https://github.com/dynamic-labs/DynamicAuth/commit/b8aa84b58eb71791405bf68b6c46c40bebb170f8))
|
|
235
|
+
|
|
236
|
+
## [3.0.0-alpha.24](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.23...v3.0.0-alpha.24) (2024-07-20)
|
|
237
|
+
|
|
238
|
+
## [3.0.0-alpha.23](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.22...v3.0.0-alpha.23) (2024-07-19)
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
### Features
|
|
242
|
+
|
|
243
|
+
* show custom labels in the sdk ([#6352](https://github.com/dynamic-labs/DynamicAuth/issues/6352)) ([6eec9b2](https://github.com/dynamic-labs/DynamicAuth/commit/6eec9b26dbfd25c5138378aa92de8379a5cd0ddc))
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
### Bug Fixes
|
|
247
|
+
|
|
248
|
+
* add missing await to viem controller ([#6354](https://github.com/dynamic-labs/DynamicAuth/issues/6354)) ([32c7362](https://github.com/dynamic-labs/DynamicAuth/commit/32c73625c5575f9134edd541c7221aba08a741b5))
|
|
249
|
+
* allow for react-native 0.74.x ([#6371](https://github.com/dynamic-labs/DynamicAuth/issues/6371)) ([37e08b6](https://github.com/dynamic-labs/DynamicAuth/commit/37e08b6b32bcaef7b7f6a4dedc45b2321f3f64a6))
|
|
250
|
+
* not able to switch to secondary wallet ([#6373](https://github.com/dynamic-labs/DynamicAuth/issues/6373)) ([f85ed10](https://github.com/dynamic-labs/DynamicAuth/commit/f85ed10aca8bf41658eb1418cd87e1c5061d4b1b))
|
|
251
|
+
|
|
252
|
+
## [3.0.0-alpha.22](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.21...v3.0.0-alpha.22) (2024-07-18)
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
### Features
|
|
256
|
+
|
|
257
|
+
* add support for aa kernel 3.1 ([#6333](https://github.com/dynamic-labs/DynamicAuth/issues/6333)) ([93c743a](https://github.com/dynamic-labs/DynamicAuth/commit/93c743a74d1af79f15baec343d15212a2feeac39))
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
### Bug Fixes
|
|
261
|
+
|
|
262
|
+
* ensure retryableFn props are passed through ([#6357](https://github.com/dynamic-labs/DynamicAuth/issues/6357)) ([246da78](https://github.com/dynamic-labs/DynamicAuth/commit/246da78ebaa0e623843d93fc990d8a0f3298af54))
|
|
263
|
+
* removes wallet connect qr code from magic eden ([#6360](https://github.com/dynamic-labs/DynamicAuth/issues/6360)) ([5968c2e](https://github.com/dynamic-labs/DynamicAuth/commit/5968c2e220f98b0995a2067e6f5397f27da4dfb0))
|
|
264
|
+
|
|
265
|
+
## [3.0.0-alpha.21](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.20...v3.0.0-alpha.21) (2024-07-17)
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
### Bug Fixes
|
|
269
|
+
|
|
270
|
+
* invalid email error appears ([#6348](https://github.com/dynamic-labs/DynamicAuth/issues/6348)) ([01bcfd2](https://github.com/dynamic-labs/DynamicAuth/commit/01bcfd2f3cc37083c47c0f26e3398f974f6b6a17))
|
|
271
|
+
* stop unnecessary phantom btc popup when disconnecting ([#6188](https://github.com/dynamic-labs/DynamicAuth/issues/6188)) ([15c2eb5](https://github.com/dynamic-labs/DynamicAuth/commit/15c2eb5da90be93ab917e7c61a873a0e9a568211))
|
|
272
|
+
|
|
273
|
+
## [3.0.0-alpha.20](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.19...v3.0.0-alpha.20) (2024-07-15)
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
### Bug Fixes
|
|
277
|
+
|
|
278
|
+
* show/hide confirmation ui for aa session key wallets ([#6334](https://github.com/dynamic-labs/DynamicAuth/issues/6334)) ([6e17162](https://github.com/dynamic-labs/DynamicAuth/commit/6e17162e31915620b622f3ec5b4f8b7087f1728c))
|
|
279
|
+
|
|
280
|
+
## [3.0.0-alpha.19](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.18...v3.0.0-alpha.19) (2024-07-13)
|
|
281
|
+
|
|
282
|
+
## [3.0.0-alpha.18](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.17...v3.0.0-alpha.18) (2024-07-12)
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
### Bug Fixes
|
|
286
|
+
|
|
287
|
+
* hide confirmation ui triggers passkey creation ([#6322](https://github.com/dynamic-labs/DynamicAuth/issues/6322)) ([c66f282](https://github.com/dynamic-labs/DynamicAuth/commit/c66f282cf8d64f19d7f5a7355aaaec980afbe245))
|
|
288
|
+
|
|
289
|
+
## [3.0.0-alpha.17](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.16...v3.0.0-alpha.17) (2024-07-11)
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
### Features
|
|
293
|
+
|
|
294
|
+
* add new hook to select wallet option to connect ([#6301](https://github.com/dynamic-labs/DynamicAuth/issues/6301)) ([833d71d](https://github.com/dynamic-labs/DynamicAuth/commit/833d71de164c57bfa22898c3425641a83a12e135))
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
### Bug Fixes
|
|
298
|
+
|
|
299
|
+
* refresh session keys correctly for solana embedded wallets ([#6309](https://github.com/dynamic-labs/DynamicAuth/issues/6309)) ([4b28e8a](https://github.com/dynamic-labs/DynamicAuth/commit/4b28e8ae231567754b6cfd07a7d41e86f1c73daa))
|
|
300
|
+
|
|
301
|
+
## [3.0.0-alpha.16](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.15...v3.0.0-alpha.16) (2024-07-11)
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
### ⚠ BREAKING CHANGES
|
|
305
|
+
|
|
306
|
+
* remove isConnected prop from wallets and have it as a method instead (#6265)
|
|
307
|
+
|
|
308
|
+
### Features
|
|
309
|
+
|
|
310
|
+
* add bundlerRpc and paymasterRpc parameters to zerodev ([#6304](https://github.com/dynamic-labs/DynamicAuth/issues/6304)) ([156469b](https://github.com/dynamic-labs/DynamicAuth/commit/156469bf703f0c7fa455a24b8e4e328d3a0c58fc))
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
### Bug Fixes
|
|
314
|
+
|
|
315
|
+
* headless embedded wallet export session refresh ([#6307](https://github.com/dynamic-labs/DynamicAuth/issues/6307)) ([5423cc1](https://github.com/dynamic-labs/DynamicAuth/commit/5423cc14c370968acf718b7deff6ea8df9228189))
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
* remove isConnected prop from wallets and have it as a method instead ([#6265](https://github.com/dynamic-labs/DynamicAuth/issues/6265)) ([652dcc2](https://github.com/dynamic-labs/DynamicAuth/commit/652dcc2d34c9a9719238606c67f600e40621183b))
|
|
319
|
+
|
|
320
|
+
## [3.0.0-alpha.15](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.14...v3.0.0-alpha.15) (2024-07-11)
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
### Bug Fixes
|
|
324
|
+
|
|
325
|
+
* catch third party wallet construction errors ([#6268](https://github.com/dynamic-labs/DynamicAuth/issues/6268)) ([badef39](https://github.com/dynamic-labs/DynamicAuth/commit/badef39d753c7d29925c6c8680053027bd99b69b))
|
|
326
|
+
* decode all solana transactions ([#6294](https://github.com/dynamic-labs/DynamicAuth/issues/6294)) ([5220ab2](https://github.com/dynamic-labs/DynamicAuth/commit/5220ab29381f3a7f1afc7043332b5a018b47eb0a))
|
|
327
|
+
* passkey cta ([#6255](https://github.com/dynamic-labs/DynamicAuth/issues/6255)) ([1b1b152](https://github.com/dynamic-labs/DynamicAuth/commit/1b1b152a24b409c5d941a9c92a003daf0bbe48a1))
|
|
328
|
+
|
|
329
|
+
## [3.0.0-alpha.14](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.13...v3.0.0-alpha.14) (2024-07-09)
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
### ⚠ BREAKING CHANGES
|
|
333
|
+
|
|
334
|
+
* remove setPrimaryWallet in favor of useSwitchWallet (#6212)
|
|
335
|
+
* move getBalance method to wallet so it can be fetched for any wallet not just the active one (#6200)
|
|
336
|
+
* make Wallet a class instead of just a type (#6094)
|
|
337
|
+
|
|
338
|
+
### Features
|
|
339
|
+
|
|
340
|
+
* add @dynamic-labs/solana-extension ([#6140](https://github.com/dynamic-labs/DynamicAuth/issues/6140)) ([c0e2a06](https://github.com/dynamic-labs/DynamicAuth/commit/c0e2a067dd83163094b58a15696df8654da47c65))
|
|
341
|
+
* add solana support for multi-asset ([#6222](https://github.com/dynamic-labs/DynamicAuth/issues/6222)) ([9660d79](https://github.com/dynamic-labs/DynamicAuth/commit/9660d7962f1fb01011d68397bb367fdfc5335ca9))
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
### Bug Fixes
|
|
345
|
+
|
|
346
|
+
* allow closing re-connect wallet modal ([#6250](https://github.com/dynamic-labs/DynamicAuth/issues/6250)) ([55ba25b](https://github.com/dynamic-labs/DynamicAuth/commit/55ba25bd3e907629aaa26e788885bfa38f8fe350))
|
|
347
|
+
* move getBalance method to wallet so it can be fetched for any wallet not just the active one ([#6200](https://github.com/dynamic-labs/DynamicAuth/issues/6200)) ([ee94773](https://github.com/dynamic-labs/DynamicAuth/commit/ee94773df9b31462a325666760fcf1fc70dec68a))
|
|
348
|
+
* move getNameService method to wallet so name service data can be fetched for any wallet ([#6205](https://github.com/dynamic-labs/DynamicAuth/issues/6205)) ([6671ae9](https://github.com/dynamic-labs/DynamicAuth/commit/6671ae92532ffc1889e24519e75f47d336ac0da6))
|
|
349
|
+
* relax phone number length validation ([#6226](https://github.com/dynamic-labs/DynamicAuth/issues/6226)) ([f0969b4](https://github.com/dynamic-labs/DynamicAuth/commit/f0969b4fbdafde07125cddecb16b4bfd011ea65e))
|
|
350
|
+
* sdkHasLoaded flipping back to false with otp ([#6242](https://github.com/dynamic-labs/DynamicAuth/issues/6242)) ([32ad9dd](https://github.com/dynamic-labs/DynamicAuth/commit/32ad9dd2dae7775f494506773fb343fe1a249c65))
|
|
351
|
+
* send transaction demo undefined address/value ([#6248](https://github.com/dynamic-labs/DynamicAuth/issues/6248)) ([036a511](https://github.com/dynamic-labs/DynamicAuth/commit/036a511fb848ef461edd9b7a5d79d478b0f1cf23))
|
|
352
|
+
* set last active account on accountChange request ([#6218](https://github.com/dynamic-labs/DynamicAuth/issues/6218)) ([05797d2](https://github.com/dynamic-labs/DynamicAuth/commit/05797d292aab8b4de02555594d4d1bbd4c9543eb))
|
|
353
|
+
* show ledger toggle when linking wallet ([#6202](https://github.com/dynamic-labs/DynamicAuth/issues/6202)) ([a449c0b](https://github.com/dynamic-labs/DynamicAuth/commit/a449c0bfc4e3a75ccd7084b930c48fbd6c14f691))
|
|
354
|
+
* show user wallet in profile view on single wallet mode even if it's not primary ([#6187](https://github.com/dynamic-labs/DynamicAuth/issues/6187)) ([ffaaeb2](https://github.com/dynamic-labs/DynamicAuth/commit/ffaaeb2c6cbb2868a381d85451ae5574024156bb))
|
|
355
|
+
* stop auto-switching to connected secondary wallet if primary wallet is not connected ([#6196](https://github.com/dynamic-labs/DynamicAuth/issues/6196)) ([4e8bcd2](https://github.com/dynamic-labs/DynamicAuth/commit/4e8bcd2d02d3fca54a0ed29c45b386ae99266b84))
|
|
356
|
+
* stop coinbase and solflare popups when secondary ([#6225](https://github.com/dynamic-labs/DynamicAuth/issues/6225)) ([7e9c104](https://github.com/dynamic-labs/DynamicAuth/commit/7e9c1049a09c9fd513c9a2a746d6baac916f1bf4))
|
|
357
|
+
* stop sending double sign request on network switch ([e325709](https://github.com/dynamic-labs/DynamicAuth/commit/e325709bb5d2d1331fe16cc705398fc7b1cc292a))
|
|
358
|
+
* tunrkey solana signer accept uint8array message ([#6137](https://github.com/dynamic-labs/DynamicAuth/issues/6137)) ([70f89ce](https://github.com/dynamic-labs/DynamicAuth/commit/70f89ce0dafa4c99b318c9c5adce59083cd6d284))
|
|
359
|
+
* update formatting of phantom bitcoin publickey ([#6210](https://github.com/dynamic-labs/DynamicAuth/issues/6210)) ([f58cea9](https://github.com/dynamic-labs/DynamicAuth/commit/f58cea99333fd7c6af8f56f637ee32f1f7ce8d76))
|
|
360
|
+
* use white color in farcaster qr code when in dark mode ([#6245](https://github.com/dynamic-labs/DynamicAuth/issues/6245)) ([a91958d](https://github.com/dynamic-labs/DynamicAuth/commit/a91958d8773be138da8f54791c4c67866257bbad))
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
* make Wallet a class instead of just a type ([#6094](https://github.com/dynamic-labs/DynamicAuth/issues/6094)) ([6dc4672](https://github.com/dynamic-labs/DynamicAuth/commit/6dc4672951cfadc22a6c569e74eae3485bd472f3))
|
|
364
|
+
* remove setPrimaryWallet in favor of useSwitchWallet ([#6212](https://github.com/dynamic-labs/DynamicAuth/issues/6212)) ([de125e1](https://github.com/dynamic-labs/DynamicAuth/commit/de125e1ebbc20507e4ec07f337f5f5fd13aabcbe))
|
|
365
|
+
|
|
366
|
+
## [3.0.0-alpha.13](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.12...v3.0.0-alpha.13) (2024-06-27)
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
### Bug Fixes
|
|
370
|
+
|
|
371
|
+
* coinbase smart wallet better handling in iframes ([#6184](https://github.com/dynamic-labs/DynamicAuth/issues/6184)) ([2c4befe](https://github.com/dynamic-labs/DynamicAuth/commit/2c4befedd09e6a432139cb3d08ea61004c3896d5))
|
|
372
|
+
* show connected network name when icon url is missing ([#6191](https://github.com/dynamic-labs/DynamicAuth/issues/6191)) ([dafd9e3](https://github.com/dynamic-labs/DynamicAuth/commit/dafd9e323f47ca3d61556e9a8c84ba3bfd27af8f))
|
|
373
|
+
* use correct account when creating wallet client ([#6179](https://github.com/dynamic-labs/DynamicAuth/issues/6179)) ([4e45a15](https://github.com/dynamic-labs/DynamicAuth/commit/4e45a15b2d7221ec80df919aa93468a75a94bed3))
|
|
374
|
+
|
|
375
|
+
## [3.0.0-alpha.12](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.11...v3.0.0-alpha.12) (2024-06-27)
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
### ⚠ BREAKING CHANGES
|
|
379
|
+
|
|
380
|
+
* return Transaction type from signTransaction and update solana … (#6180)
|
|
381
|
+
|
|
382
|
+
### Bug Fixes
|
|
383
|
+
|
|
384
|
+
* return Transaction type from signTransaction and update solana … ([#6180](https://github.com/dynamic-labs/DynamicAuth/issues/6180)) ([07798b2](https://github.com/dynamic-labs/DynamicAuth/commit/07798b241a13f35a62e4ca0172a57a8d0cd98cf9))
|
|
385
|
+
|
|
386
|
+
## [3.0.0-alpha.11](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.10...v3.0.0-alpha.11) (2024-06-26)
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
### Bug Fixes
|
|
390
|
+
|
|
391
|
+
* prevent unwanted magiceden solana popups ([#6158](https://github.com/dynamic-labs/DynamicAuth/issues/6158)) ([b3c8208](https://github.com/dynamic-labs/DynamicAuth/commit/b3c820887eb5ec2badcfce3b19ec4dd874e90811))
|
|
392
|
+
* status icon for embedded wallets ([#6149](https://github.com/dynamic-labs/DynamicAuth/issues/6149)) ([135fd72](https://github.com/dynamic-labs/DynamicAuth/commit/135fd7274f4a6b2dcab98248f7bfe34a09e79f01))
|
|
393
|
+
|
|
394
|
+
## [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)
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
### Bug Fixes
|
|
398
|
+
|
|
399
|
+
* 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))
|
|
400
|
+
* 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))
|
|
401
|
+
|
|
402
|
+
## [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)
|
|
403
|
+
|
|
404
|
+
## [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)
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
### ⚠ BREAKING CHANGES
|
|
408
|
+
|
|
409
|
+
* break out turnkey package into 3 separate packages (#6015)
|
|
410
|
+
|
|
411
|
+
### Features
|
|
412
|
+
|
|
413
|
+
* add reinitialize hook ([#6098](https://github.com/dynamic-labs/DynamicAuth/issues/6098)) ([d978baa](https://github.com/dynamic-labs/DynamicAuth/commit/d978baa404d34064c36cc549229b1fcea1f20df0))
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
### Bug Fixes
|
|
417
|
+
|
|
418
|
+
* 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))
|
|
419
|
+
* 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)
|
|
420
|
+
* 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))
|
|
421
|
+
* 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))
|
|
422
|
+
* 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))
|
|
423
|
+
* 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))
|
|
424
|
+
|
|
425
|
+
## [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)
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
### ⚠ BREAKING CHANGES
|
|
429
|
+
|
|
430
|
+
* add selectedTabIndex and helpers (#6040)
|
|
431
|
+
|
|
432
|
+
### Features
|
|
433
|
+
|
|
434
|
+
* add selectedTabIndex and helpers ([#6040](https://github.com/dynamic-labs/DynamicAuth/issues/6040)) ([ae20b80](https://github.com/dynamic-labs/DynamicAuth/commit/ae20b8081376dce97b18fa69c81c9ab73c1ff317))
|
|
435
|
+
* 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))
|
|
436
|
+
|
|
437
|
+
|
|
438
|
+
### Bug Fixes
|
|
439
|
+
|
|
440
|
+
* 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))
|
|
441
|
+
* 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))
|
|
442
|
+
* make account change idemopotent ([#6061](https://github.com/dynamic-labs/DynamicAuth/issues/6061)) ([8c87513](https://github.com/dynamic-labs/DynamicAuth/commit/8c8751390ea14888c4889679895e2f06d75717b9))
|
|
443
|
+
* 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))
|
|
444
|
+
* recompute multiwallet state after merging accounts ([#6078](https://github.com/dynamic-labs/DynamicAuth/issues/6078)) ([e08a274](https://github.com/dynamic-labs/DynamicAuth/commit/e08a274c4d848f2a8360be7106cfbfa00b9a8f9b))
|
|
445
|
+
* 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))
|
|
446
|
+
* 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))
|
|
447
|
+
|
|
448
|
+
## [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)
|
|
449
|
+
|
|
450
|
+
|
|
451
|
+
### Features
|
|
452
|
+
|
|
453
|
+
* 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))
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
### Bug Fixes
|
|
457
|
+
|
|
458
|
+
* allow sign-in with different ME BTC wallet after initial connection ([a527b46](https://github.com/dynamic-labs/DynamicAuth/commit/a527b464f321b4fc27730f57c3812e996b5ed878))
|
|
459
|
+
* 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))
|
|
460
|
+
* 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))
|
|
461
|
+
* e2e: remove page pause ([#6045](https://github.com/dynamic-labs/DynamicAuth/issues/6045)) ([55bba00](https://github.com/dynamic-labs/DynamicAuth/commit/55bba0034255055d6ae266b1296542f47ed48e2b))
|
|
462
|
+
* more fixes for connect starknet button ([#6046](https://github.com/dynamic-labs/DynamicAuth/issues/6046)) ([0fb570a](https://github.com/dynamic-labs/DynamicAuth/commit/0fb570a44e65f8dd6d4d2bf5edb2ee54985ec9d4))
|
|
463
|
+
* 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))
|
|
464
|
+
|
|
2
465
|
## [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)
|
|
3
466
|
|
|
4
467
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/starknet",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.50",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/dynamic-labs/dynamic-auth.git",
|
|
@@ -30,11 +30,13 @@
|
|
|
30
30
|
"get-starknet-core": "3.2.0",
|
|
31
31
|
"text-encoding": "0.7.0",
|
|
32
32
|
"starknetkit": "1.1.3",
|
|
33
|
-
"@dynamic-labs/sdk-api-core": "0.0.
|
|
34
|
-
"@
|
|
35
|
-
"@dynamic-labs/
|
|
36
|
-
"@dynamic-labs/
|
|
37
|
-
"@dynamic-labs/
|
|
33
|
+
"@dynamic-labs/sdk-api-core": "0.0.519",
|
|
34
|
+
"@module-federation/runtime": "0.1.18",
|
|
35
|
+
"@dynamic-labs/logger": "3.0.0-alpha.50",
|
|
36
|
+
"@dynamic-labs/rpc-provider-starknet": "3.0.0-alpha.50",
|
|
37
|
+
"@dynamic-labs/utils": "3.0.0-alpha.50",
|
|
38
|
+
"@dynamic-labs/wallet-book": "3.0.0-alpha.50",
|
|
39
|
+
"@dynamic-labs/wallet-connector-core": "3.0.0-alpha.50"
|
|
38
40
|
},
|
|
39
41
|
"peerDependencies": {}
|
|
40
42
|
}
|
package/src/index.cjs
CHANGED
|
@@ -9,6 +9,7 @@ var argentxMobile = require('./wallets/argentxMobile.cjs');
|
|
|
9
9
|
var argentxWeb = require('./wallets/argentxWeb.cjs');
|
|
10
10
|
var bitget = require('./wallets/bitget.cjs');
|
|
11
11
|
var okx = require('./wallets/okx.cjs');
|
|
12
|
+
var metamask = require('./wallets/metamask.cjs');
|
|
12
13
|
require('@dynamic-labs/rpc-provider-starknet');
|
|
13
14
|
|
|
14
15
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
@@ -19,6 +20,7 @@ const StarknetWalletConnectors = (props) => [
|
|
|
19
20
|
argentxWeb.ArgentXWeb,
|
|
20
21
|
okx.Okx,
|
|
21
22
|
bitget.Bitget,
|
|
23
|
+
metamask.MetaMask,
|
|
22
24
|
];
|
|
23
25
|
|
|
24
26
|
exports.StarknetWalletConnectors = StarknetWalletConnectors;
|
package/src/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import { ArgentXMobile } from './wallets/argentxMobile.js';
|
|
|
5
5
|
import { ArgentXWeb } from './wallets/argentxWeb.js';
|
|
6
6
|
import { Bitget } from './wallets/bitget.js';
|
|
7
7
|
import { Okx } from './wallets/okx.js';
|
|
8
|
+
import { MetaMask } from './wallets/metamask.js';
|
|
8
9
|
import '@dynamic-labs/rpc-provider-starknet';
|
|
9
10
|
|
|
10
11
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
@@ -15,6 +16,7 @@ const StarknetWalletConnectors = (props) => [
|
|
|
15
16
|
ArgentXWeb,
|
|
16
17
|
Okx,
|
|
17
18
|
Bitget,
|
|
19
|
+
MetaMask,
|
|
18
20
|
];
|
|
19
21
|
|
|
20
22
|
export { StarknetWalletConnectors };
|
|
@@ -22,6 +22,8 @@ class StarknetWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
22
22
|
this.connectedChain = 'STARK';
|
|
23
23
|
this.supportedChains = ['STARK'];
|
|
24
24
|
this.switchNetworkOnlyFromWallet = true;
|
|
25
|
+
// required for metamask snap integration as MM snaps don't have event listeners
|
|
26
|
+
this.canSetEventListeners = true;
|
|
25
27
|
this.name = name;
|
|
26
28
|
this.windowKey = windowKey;
|
|
27
29
|
this.starknetNetworks = opts.starknetNetworks;
|
|
@@ -91,7 +93,8 @@ class StarknetWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
91
93
|
if (!this.isInstalledOnBrowser() &&
|
|
92
94
|
utils.isMobile() &&
|
|
93
95
|
this.walletBookWallet.mobile &&
|
|
94
|
-
this.walletBookWallet.mobile.inAppBrowser
|
|
96
|
+
this.walletBookWallet.mobile.inAppBrowser &&
|
|
97
|
+
this.mobileExperience === 'in-app-browser') {
|
|
95
98
|
const inAppBrowserCompiledTemplate = utils.template(this.walletBookWallet.mobile.inAppBrowser);
|
|
96
99
|
const deepLink = inAppBrowserCompiledTemplate({
|
|
97
100
|
encodedDappURI: encodeURIComponent(window.location.toString()),
|
|
@@ -131,17 +134,16 @@ class StarknetWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
131
134
|
return signature === null || signature === void 0 ? void 0 : signature.join(',');
|
|
132
135
|
});
|
|
133
136
|
}
|
|
134
|
-
getBalance() {
|
|
137
|
+
getBalance(address) {
|
|
135
138
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
136
|
-
const walletAddress = yield this.getAddress();
|
|
137
139
|
const provider = yield this.getWalletClient();
|
|
138
|
-
if (!
|
|
139
|
-
walletConnectorCore.logger.error('Could not
|
|
140
|
+
if (!provider) {
|
|
141
|
+
walletConnectorCore.logger.error('Could not find provider for getting balance');
|
|
140
142
|
return undefined;
|
|
141
143
|
}
|
|
142
144
|
const contract = new starknet.Contract(ethereumContractAbi, constants.ETH_STARKNET_ADDRESS, provider);
|
|
143
145
|
try {
|
|
144
|
-
const { balance } = yield contract.balanceOf(
|
|
146
|
+
const { balance } = yield contract.balanceOf(address);
|
|
145
147
|
/**
|
|
146
148
|
* Dividing by 1e18 as the returned balance is a Gwei number.
|
|
147
149
|
* Read more here: https://www.investopedia.com/terms/g/gwei-ethereum.asp#toc-what-is-gwei
|
|
@@ -182,6 +184,24 @@ class StarknetWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
182
184
|
if (!wallet) {
|
|
183
185
|
return [];
|
|
184
186
|
}
|
|
187
|
+
try {
|
|
188
|
+
yield this.reconnectIfNeeded(wallet);
|
|
189
|
+
}
|
|
190
|
+
catch (e) {
|
|
191
|
+
return [];
|
|
192
|
+
}
|
|
193
|
+
const getSelectedAddress = () => wallet.selectedAddress
|
|
194
|
+
? Promise.resolve([wallet.selectedAddress])
|
|
195
|
+
: Promise.reject();
|
|
196
|
+
return utils.retryableFn(getSelectedAddress, {
|
|
197
|
+
fallbackValue: [],
|
|
198
|
+
retryIntervalMs: 100,
|
|
199
|
+
retryStrategy: 'timeout-and-rejection',
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
reconnectIfNeeded(wallet) {
|
|
204
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
185
205
|
const needsReconnection = !this.isProviderConnected() && (yield wallet.isPreauthorized());
|
|
186
206
|
if (needsReconnection) {
|
|
187
207
|
/**
|
|
@@ -199,24 +219,18 @@ class StarknetWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
199
219
|
}
|
|
200
220
|
catch (_a) {
|
|
201
221
|
localStorage.removeItem('dynamic_should_have_wallet');
|
|
202
|
-
|
|
222
|
+
throw new Error('Could not reconnect');
|
|
203
223
|
}
|
|
204
224
|
}
|
|
205
225
|
else {
|
|
206
226
|
yield this.connect();
|
|
207
227
|
}
|
|
208
228
|
}
|
|
209
|
-
const getSelectedAddress = () => wallet.selectedAddress
|
|
210
|
-
? Promise.resolve([wallet.selectedAddress])
|
|
211
|
-
: Promise.reject();
|
|
212
|
-
return utils.retryableFn(getSelectedAddress, {
|
|
213
|
-
fallbackValue: [],
|
|
214
|
-
retryIntervalMs: 100,
|
|
215
|
-
retryStrategy: 'timeout-and-rejection',
|
|
216
|
-
});
|
|
217
229
|
});
|
|
218
230
|
}
|
|
219
231
|
setupEventListeners() {
|
|
232
|
+
if (!this.canSetEventListeners)
|
|
233
|
+
return;
|
|
220
234
|
const wallet = this.getWallet();
|
|
221
235
|
if (!wallet) {
|
|
222
236
|
return walletConnectorCore.logger.error('Wallet has not been found');
|
|
@@ -245,6 +259,8 @@ class StarknetWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
245
259
|
}
|
|
246
260
|
teardownEventListeners() {
|
|
247
261
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
262
|
+
if (!this.canSetEventListeners)
|
|
263
|
+
return;
|
|
248
264
|
const wallet = this.getWallet();
|
|
249
265
|
if (this.handleAccountChange) {
|
|
250
266
|
wallet === null || wallet === void 0 ? void 0 : wallet.off(ACCOUNT_CHANGED_EVENT_LISTENER, this.handleAccountChange);
|
|
@@ -23,6 +23,7 @@ declare abstract class StarknetWalletConnector extends WalletConnectorBase {
|
|
|
23
23
|
handleNetworkChange: NetworkChangeEventHandler | undefined;
|
|
24
24
|
switchNetworkOnlyFromWallet: boolean;
|
|
25
25
|
starknetNetworks: NetworkConfiguration[];
|
|
26
|
+
canSetEventListeners: boolean;
|
|
26
27
|
constructor(name: string, windowKey: StarknetWalletKey, opts: {
|
|
27
28
|
chainRpcProviders: IChainRpcProviders;
|
|
28
29
|
starknetNetworks: NetworkConfiguration[];
|
|
@@ -63,6 +64,10 @@ declare abstract class StarknetWalletConnector extends WalletConnectorBase {
|
|
|
63
64
|
features: string[];
|
|
64
65
|
name: string;
|
|
65
66
|
} | undefined;
|
|
67
|
+
walletStandardLocators?: {
|
|
68
|
+
name: string;
|
|
69
|
+
locator: string;
|
|
70
|
+
}[] | undefined;
|
|
66
71
|
windowLocations?: string[] | undefined;
|
|
67
72
|
}[] | undefined;
|
|
68
73
|
mobile?: {
|
|
@@ -74,6 +79,7 @@ declare abstract class StarknetWalletConnector extends WalletConnectorBase {
|
|
|
74
79
|
native?: string | undefined;
|
|
75
80
|
universal?: string | undefined;
|
|
76
81
|
} | undefined;
|
|
82
|
+
mobileExperience?: "in-app-browser" | "redirect" | undefined;
|
|
77
83
|
shortName?: string | undefined;
|
|
78
84
|
showOnlyIfInstalled?: boolean | undefined;
|
|
79
85
|
switchNetworkOnlyFromWallet?: boolean | undefined;
|
|
@@ -81,6 +87,16 @@ declare abstract class StarknetWalletConnector extends WalletConnectorBase {
|
|
|
81
87
|
sdks?: string[] | undefined;
|
|
82
88
|
} | undefined;
|
|
83
89
|
walletGroup?: string | undefined;
|
|
90
|
+
walletLimitations?: {
|
|
91
|
+
browserExtension?: {
|
|
92
|
+
unsupportedEvents?: string[] | undefined;
|
|
93
|
+
unsupportedMethods?: string[] | undefined;
|
|
94
|
+
} | undefined;
|
|
95
|
+
mobile?: {
|
|
96
|
+
unsupportedEvents?: string[] | undefined;
|
|
97
|
+
unsupportedMethods?: string[] | undefined;
|
|
98
|
+
} | undefined;
|
|
99
|
+
} | undefined;
|
|
84
100
|
};
|
|
85
101
|
isProviderConnected(): boolean;
|
|
86
102
|
getPublicClient(): Promise<RpcProvider | undefined>;
|
|
@@ -93,11 +109,12 @@ declare abstract class StarknetWalletConnector extends WalletConnectorBase {
|
|
|
93
109
|
getSigner(): Promise<AccountInterface | undefined>;
|
|
94
110
|
getWalletClient(): Promise<ProviderInterface | undefined>;
|
|
95
111
|
signMessage(messageToSign: string): Promise<string | undefined>;
|
|
96
|
-
getBalance(): Promise<string | undefined>;
|
|
112
|
+
getBalance(address: string): Promise<string | undefined>;
|
|
97
113
|
endSession(): Promise<void>;
|
|
98
114
|
getWallet(): StarknetWindowObject | undefined;
|
|
99
115
|
isInstalledOnBrowser(): boolean;
|
|
100
116
|
getConnectedAccounts(): Promise<string[]>;
|
|
117
|
+
reconnectIfNeeded(wallet: StarknetWindowObject): Promise<Promise<Promise<void>>>;
|
|
101
118
|
setupEventListeners(): void;
|
|
102
119
|
teardownEventListeners(): Promise<void>;
|
|
103
120
|
mapNetworkNameToChainId(networkNameOrChainId: string): constants.StarknetChainId | undefined;
|
|
@@ -18,6 +18,8 @@ class StarknetWalletConnector extends WalletConnectorBase {
|
|
|
18
18
|
this.connectedChain = 'STARK';
|
|
19
19
|
this.supportedChains = ['STARK'];
|
|
20
20
|
this.switchNetworkOnlyFromWallet = true;
|
|
21
|
+
// required for metamask snap integration as MM snaps don't have event listeners
|
|
22
|
+
this.canSetEventListeners = true;
|
|
21
23
|
this.name = name;
|
|
22
24
|
this.windowKey = windowKey;
|
|
23
25
|
this.starknetNetworks = opts.starknetNetworks;
|
|
@@ -87,7 +89,8 @@ class StarknetWalletConnector extends WalletConnectorBase {
|
|
|
87
89
|
if (!this.isInstalledOnBrowser() &&
|
|
88
90
|
isMobile() &&
|
|
89
91
|
this.walletBookWallet.mobile &&
|
|
90
|
-
this.walletBookWallet.mobile.inAppBrowser
|
|
92
|
+
this.walletBookWallet.mobile.inAppBrowser &&
|
|
93
|
+
this.mobileExperience === 'in-app-browser') {
|
|
91
94
|
const inAppBrowserCompiledTemplate = template(this.walletBookWallet.mobile.inAppBrowser);
|
|
92
95
|
const deepLink = inAppBrowserCompiledTemplate({
|
|
93
96
|
encodedDappURI: encodeURIComponent(window.location.toString()),
|
|
@@ -127,17 +130,16 @@ class StarknetWalletConnector extends WalletConnectorBase {
|
|
|
127
130
|
return signature === null || signature === void 0 ? void 0 : signature.join(',');
|
|
128
131
|
});
|
|
129
132
|
}
|
|
130
|
-
getBalance() {
|
|
133
|
+
getBalance(address) {
|
|
131
134
|
return __awaiter(this, void 0, void 0, function* () {
|
|
132
|
-
const walletAddress = yield this.getAddress();
|
|
133
135
|
const provider = yield this.getWalletClient();
|
|
134
|
-
if (!
|
|
135
|
-
logger.error('Could not
|
|
136
|
+
if (!provider) {
|
|
137
|
+
logger.error('Could not find provider for getting balance');
|
|
136
138
|
return undefined;
|
|
137
139
|
}
|
|
138
140
|
const contract = new Contract(ETH_CONTRACT_ABI, ETH_STARKNET_ADDRESS, provider);
|
|
139
141
|
try {
|
|
140
|
-
const { balance } = yield contract.balanceOf(
|
|
142
|
+
const { balance } = yield contract.balanceOf(address);
|
|
141
143
|
/**
|
|
142
144
|
* Dividing by 1e18 as the returned balance is a Gwei number.
|
|
143
145
|
* Read more here: https://www.investopedia.com/terms/g/gwei-ethereum.asp#toc-what-is-gwei
|
|
@@ -178,6 +180,24 @@ class StarknetWalletConnector extends WalletConnectorBase {
|
|
|
178
180
|
if (!wallet) {
|
|
179
181
|
return [];
|
|
180
182
|
}
|
|
183
|
+
try {
|
|
184
|
+
yield this.reconnectIfNeeded(wallet);
|
|
185
|
+
}
|
|
186
|
+
catch (e) {
|
|
187
|
+
return [];
|
|
188
|
+
}
|
|
189
|
+
const getSelectedAddress = () => wallet.selectedAddress
|
|
190
|
+
? Promise.resolve([wallet.selectedAddress])
|
|
191
|
+
: Promise.reject();
|
|
192
|
+
return retryableFn(getSelectedAddress, {
|
|
193
|
+
fallbackValue: [],
|
|
194
|
+
retryIntervalMs: 100,
|
|
195
|
+
retryStrategy: 'timeout-and-rejection',
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
reconnectIfNeeded(wallet) {
|
|
200
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
181
201
|
const needsReconnection = !this.isProviderConnected() && (yield wallet.isPreauthorized());
|
|
182
202
|
if (needsReconnection) {
|
|
183
203
|
/**
|
|
@@ -195,24 +215,18 @@ class StarknetWalletConnector extends WalletConnectorBase {
|
|
|
195
215
|
}
|
|
196
216
|
catch (_a) {
|
|
197
217
|
localStorage.removeItem('dynamic_should_have_wallet');
|
|
198
|
-
|
|
218
|
+
throw new Error('Could not reconnect');
|
|
199
219
|
}
|
|
200
220
|
}
|
|
201
221
|
else {
|
|
202
222
|
yield this.connect();
|
|
203
223
|
}
|
|
204
224
|
}
|
|
205
|
-
const getSelectedAddress = () => wallet.selectedAddress
|
|
206
|
-
? Promise.resolve([wallet.selectedAddress])
|
|
207
|
-
: Promise.reject();
|
|
208
|
-
return retryableFn(getSelectedAddress, {
|
|
209
|
-
fallbackValue: [],
|
|
210
|
-
retryIntervalMs: 100,
|
|
211
|
-
retryStrategy: 'timeout-and-rejection',
|
|
212
|
-
});
|
|
213
225
|
});
|
|
214
226
|
}
|
|
215
227
|
setupEventListeners() {
|
|
228
|
+
if (!this.canSetEventListeners)
|
|
229
|
+
return;
|
|
216
230
|
const wallet = this.getWallet();
|
|
217
231
|
if (!wallet) {
|
|
218
232
|
return logger.error('Wallet has not been found');
|
|
@@ -241,6 +255,8 @@ class StarknetWalletConnector extends WalletConnectorBase {
|
|
|
241
255
|
}
|
|
242
256
|
teardownEventListeners() {
|
|
243
257
|
return __awaiter(this, void 0, void 0, function* () {
|
|
258
|
+
if (!this.canSetEventListeners)
|
|
259
|
+
return;
|
|
244
260
|
const wallet = this.getWallet();
|
|
245
261
|
if (this.handleAccountChange) {
|
|
246
262
|
wallet === null || wallet === void 0 ? void 0 : wallet.off(ACCOUNT_CHANGED_EVENT_LISTENER, this.handleAccountChange);
|
package/src/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { StarknetWindowObject } from 'get-starknet-core';
|
|
2
|
-
export type StarknetWalletKey = 'braavos' | 'argentX' | 'argentXMobile' | 'argentWebWallet' | 'okxwallet' | 'bitkeep';
|
|
2
|
+
export type StarknetWalletKey = 'braavos' | 'argentX' | 'argentXMobile' | 'argentWebWallet' | 'okxwallet' | 'bitkeep' | 'metamask_snap';
|
|
3
3
|
export type StarknetWindowKey = `starknet_${StarknetWalletKey}` | 'starknet';
|
|
4
4
|
type StarknetWindow = {
|
|
5
5
|
[key in StarknetWindowKey]: StarknetWindowObject;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
7
|
+
var index_cjs_js = require('@module-federation/runtime/dist/index.cjs.js');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @param {IEthereum} provider the metamask window provider object
|
|
12
|
+
* @returns {StarknetWindowObject} the metamask provider wrapper formed into starknet window object
|
|
13
|
+
*/
|
|
14
|
+
const createMetaMaskProviderWrapper = (provider) => {
|
|
15
|
+
let metaMaskSnapWallet;
|
|
16
|
+
// using @module-federation to load the get-starknet remoteEntry, as recommended
|
|
17
|
+
// by the starknet team. this file is a small wrapper around the metamask snap api
|
|
18
|
+
// to communicate with starknet, which we then wrap into a starknet window object
|
|
19
|
+
// and use in our starknet connector, just like braavos and argent
|
|
20
|
+
const initMetaMaskSnapWallet = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
+
if (!metaMaskSnapWallet) {
|
|
22
|
+
index_cjs_js.init({
|
|
23
|
+
name: 'MetaMaskStarknetSnapWallet',
|
|
24
|
+
remotes: [
|
|
25
|
+
{
|
|
26
|
+
alias: 'MetaMaskStarknetSnapWallet',
|
|
27
|
+
entry: 'https://snaps.consensys.io/starknet/get-starknet/v1/remoteEntry.js',
|
|
28
|
+
name: 'MetaMaskStarknetSnapWallet',
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
});
|
|
32
|
+
const result = yield index_cjs_js.loadRemote('MetaMaskStarknetSnapWallet/index');
|
|
33
|
+
const { MetaMaskSnapWallet } = result;
|
|
34
|
+
metaMaskSnapWallet = new MetaMaskSnapWallet(provider, '*');
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
const metaMaskProviderWrapper = {
|
|
38
|
+
get account() {
|
|
39
|
+
return metaMaskSnapWallet === null || metaMaskSnapWallet === void 0 ? void 0 : metaMaskSnapWallet.account;
|
|
40
|
+
},
|
|
41
|
+
get chainId() {
|
|
42
|
+
return metaMaskSnapWallet === null || metaMaskSnapWallet === void 0 ? void 0 : metaMaskSnapWallet.chainId;
|
|
43
|
+
},
|
|
44
|
+
enable: () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
45
|
+
yield initMetaMaskSnapWallet();
|
|
46
|
+
if (!metaMaskSnapWallet) {
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
49
|
+
return metaMaskSnapWallet.enable();
|
|
50
|
+
}),
|
|
51
|
+
icon: '',
|
|
52
|
+
id: 'MetaMaskStarknetSnapWallet',
|
|
53
|
+
get isConnected() {
|
|
54
|
+
return metaMaskSnapWallet === null || metaMaskSnapWallet === void 0 ? void 0 : metaMaskSnapWallet.isConnected;
|
|
55
|
+
},
|
|
56
|
+
isPreauthorized: () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
57
|
+
var _a;
|
|
58
|
+
yield initMetaMaskSnapWallet();
|
|
59
|
+
return (_a = (yield (metaMaskSnapWallet === null || metaMaskSnapWallet === void 0 ? void 0 : metaMaskSnapWallet.isPreauthorized()))) !== null && _a !== void 0 ? _a : false;
|
|
60
|
+
}),
|
|
61
|
+
name: 'MetaMaskStarknetSnapWallet',
|
|
62
|
+
off: (
|
|
63
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
64
|
+
event,
|
|
65
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
66
|
+
handleEvent) => undefined,
|
|
67
|
+
on: (
|
|
68
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
69
|
+
event,
|
|
70
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
71
|
+
handleEvent) => undefined,
|
|
72
|
+
get provider() {
|
|
73
|
+
return metaMaskSnapWallet === null || metaMaskSnapWallet === void 0 ? void 0 : metaMaskSnapWallet.provider;
|
|
74
|
+
},
|
|
75
|
+
request: (call) => {
|
|
76
|
+
if (!metaMaskSnapWallet) {
|
|
77
|
+
throw new Error('Wallet not enabled');
|
|
78
|
+
}
|
|
79
|
+
return metaMaskSnapWallet.request(call);
|
|
80
|
+
},
|
|
81
|
+
get selectedAddress() {
|
|
82
|
+
return metaMaskSnapWallet === null || metaMaskSnapWallet === void 0 ? void 0 : metaMaskSnapWallet.selectedAddress;
|
|
83
|
+
},
|
|
84
|
+
get version() {
|
|
85
|
+
var _a;
|
|
86
|
+
return (_a = metaMaskSnapWallet === null || metaMaskSnapWallet === void 0 ? void 0 : metaMaskSnapWallet.version) !== null && _a !== void 0 ? _a : '0.0.0';
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
return metaMaskProviderWrapper;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
exports.createMetaMaskProviderWrapper = createMetaMaskProviderWrapper;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { StarknetWindowObject } from 'get-starknet-core';
|
|
2
|
+
import { IEthereum } from '@dynamic-labs/utils';
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {IEthereum} provider the metamask window provider object
|
|
6
|
+
* @returns {StarknetWindowObject} the metamask provider wrapper formed into starknet window object
|
|
7
|
+
*/
|
|
8
|
+
export declare const createMetaMaskProviderWrapper: (provider: IEthereum) => StarknetWindowObject;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
3
|
+
import { init, loadRemote } from '@module-federation/runtime/dist/index.cjs.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param {IEthereum} provider the metamask window provider object
|
|
8
|
+
* @returns {StarknetWindowObject} the metamask provider wrapper formed into starknet window object
|
|
9
|
+
*/
|
|
10
|
+
const createMetaMaskProviderWrapper = (provider) => {
|
|
11
|
+
let metaMaskSnapWallet;
|
|
12
|
+
// using @module-federation to load the get-starknet remoteEntry, as recommended
|
|
13
|
+
// by the starknet team. this file is a small wrapper around the metamask snap api
|
|
14
|
+
// to communicate with starknet, which we then wrap into a starknet window object
|
|
15
|
+
// and use in our starknet connector, just like braavos and argent
|
|
16
|
+
const initMetaMaskSnapWallet = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
if (!metaMaskSnapWallet) {
|
|
18
|
+
init({
|
|
19
|
+
name: 'MetaMaskStarknetSnapWallet',
|
|
20
|
+
remotes: [
|
|
21
|
+
{
|
|
22
|
+
alias: 'MetaMaskStarknetSnapWallet',
|
|
23
|
+
entry: 'https://snaps.consensys.io/starknet/get-starknet/v1/remoteEntry.js',
|
|
24
|
+
name: 'MetaMaskStarknetSnapWallet',
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
});
|
|
28
|
+
const result = yield loadRemote('MetaMaskStarknetSnapWallet/index');
|
|
29
|
+
const { MetaMaskSnapWallet } = result;
|
|
30
|
+
metaMaskSnapWallet = new MetaMaskSnapWallet(provider, '*');
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
const metaMaskProviderWrapper = {
|
|
34
|
+
get account() {
|
|
35
|
+
return metaMaskSnapWallet === null || metaMaskSnapWallet === void 0 ? void 0 : metaMaskSnapWallet.account;
|
|
36
|
+
},
|
|
37
|
+
get chainId() {
|
|
38
|
+
return metaMaskSnapWallet === null || metaMaskSnapWallet === void 0 ? void 0 : metaMaskSnapWallet.chainId;
|
|
39
|
+
},
|
|
40
|
+
enable: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
41
|
+
yield initMetaMaskSnapWallet();
|
|
42
|
+
if (!metaMaskSnapWallet) {
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
return metaMaskSnapWallet.enable();
|
|
46
|
+
}),
|
|
47
|
+
icon: '',
|
|
48
|
+
id: 'MetaMaskStarknetSnapWallet',
|
|
49
|
+
get isConnected() {
|
|
50
|
+
return metaMaskSnapWallet === null || metaMaskSnapWallet === void 0 ? void 0 : metaMaskSnapWallet.isConnected;
|
|
51
|
+
},
|
|
52
|
+
isPreauthorized: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
53
|
+
var _a;
|
|
54
|
+
yield initMetaMaskSnapWallet();
|
|
55
|
+
return (_a = (yield (metaMaskSnapWallet === null || metaMaskSnapWallet === void 0 ? void 0 : metaMaskSnapWallet.isPreauthorized()))) !== null && _a !== void 0 ? _a : false;
|
|
56
|
+
}),
|
|
57
|
+
name: 'MetaMaskStarknetSnapWallet',
|
|
58
|
+
off: (
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
60
|
+
event,
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
62
|
+
handleEvent) => undefined,
|
|
63
|
+
on: (
|
|
64
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
65
|
+
event,
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
67
|
+
handleEvent) => undefined,
|
|
68
|
+
get provider() {
|
|
69
|
+
return metaMaskSnapWallet === null || metaMaskSnapWallet === void 0 ? void 0 : metaMaskSnapWallet.provider;
|
|
70
|
+
},
|
|
71
|
+
request: (call) => {
|
|
72
|
+
if (!metaMaskSnapWallet) {
|
|
73
|
+
throw new Error('Wallet not enabled');
|
|
74
|
+
}
|
|
75
|
+
return metaMaskSnapWallet.request(call);
|
|
76
|
+
},
|
|
77
|
+
get selectedAddress() {
|
|
78
|
+
return metaMaskSnapWallet === null || metaMaskSnapWallet === void 0 ? void 0 : metaMaskSnapWallet.selectedAddress;
|
|
79
|
+
},
|
|
80
|
+
get version() {
|
|
81
|
+
var _a;
|
|
82
|
+
return (_a = metaMaskSnapWallet === null || metaMaskSnapWallet === void 0 ? void 0 : metaMaskSnapWallet.version) !== null && _a !== void 0 ? _a : '0.0.0';
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
return metaMaskProviderWrapper;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export { createMetaMaskProviderWrapper };
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
7
|
+
var utils = require('@dynamic-labs/utils');
|
|
8
|
+
var logger$1 = require('@dynamic-labs/logger');
|
|
9
|
+
var starknetWalletConnector = require('../starknetWalletConnector.cjs');
|
|
10
|
+
var starknetSnap = require('../utils/starknetSnap.cjs');
|
|
11
|
+
|
|
12
|
+
const logger = new logger$1.Logger('MetaMask Starknet Snap', logger$1.LogLevel.INFO);
|
|
13
|
+
class MetaMask extends starknetWalletConnector["default"] {
|
|
14
|
+
constructor(opts) {
|
|
15
|
+
super('MetaMask Starknet', 'metamask_snap', opts);
|
|
16
|
+
this.overrideKey = 'metamaskstarknet';
|
|
17
|
+
const { providers } = utils.Eip6963ProviderSingleton.get();
|
|
18
|
+
const metamaskProvider = providers.find((p) => ['io.metamask', 'io.metamask.flask'].includes(p.info.rdns));
|
|
19
|
+
if (metamaskProvider) {
|
|
20
|
+
this.provider = metamaskProvider.provider;
|
|
21
|
+
}
|
|
22
|
+
if (!window.starknet_metamask_snap && metamaskProvider) {
|
|
23
|
+
window.starknet_metamask_snap = starknetSnap.createMetaMaskProviderWrapper(metamaskProvider.provider);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
getNetwork() {
|
|
27
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
if (!this.provider) {
|
|
29
|
+
logger.error('[getNetwork] - No provider found, returning undefined');
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
logger.info('[getNetwork] - trying to fetch network using provider');
|
|
34
|
+
// we are using this method to get the network so that we always "see" the absolute
|
|
35
|
+
// active network in the companion site. when using the snap wrapper to get the network,
|
|
36
|
+
// we don't "see" the actual active network in the companion site – instead we see the
|
|
37
|
+
// network that was active at the time of the snap initialization
|
|
38
|
+
const result = yield this.provider.request({
|
|
39
|
+
method: 'wallet_invokeSnap',
|
|
40
|
+
params: {
|
|
41
|
+
request: {
|
|
42
|
+
method: 'starkNet_getCurrentNetwork',
|
|
43
|
+
params: {},
|
|
44
|
+
},
|
|
45
|
+
snapId: 'npm:@consensys/starknet-snap',
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
if (!('chainId' in result) || typeof result.chainId !== 'string') {
|
|
49
|
+
logger.error(`[getNetwork] - result.chainId should be a string, but got: ${
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
51
|
+
result.chainId}`);
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
if (result.chainId !== this.currentChainId) {
|
|
55
|
+
const resultChainName = this.mapChainIdToNetworkName(result.chainId);
|
|
56
|
+
const currentChainName = this.currentChainId
|
|
57
|
+
? this.mapChainIdToNetworkName(this.currentChainId)
|
|
58
|
+
: undefined;
|
|
59
|
+
logger.info(`[getNetwork] - emitting chainChange event. got chainId: ${result.chainId} (${resultChainName}). current chainId: ${this.currentChainId} (${currentChainName})`);
|
|
60
|
+
this.emit('chainChange', { chain: result.chainId });
|
|
61
|
+
}
|
|
62
|
+
this.currentChainId = result.chainId;
|
|
63
|
+
return this.currentChainId;
|
|
64
|
+
}
|
|
65
|
+
catch (e) {
|
|
66
|
+
logger.error('[getNetwork] - network fetch request failed, returning undefined', e);
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
setupEventListeners() {
|
|
72
|
+
if (this.intervalId) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
this.intervalId = setInterval(() => {
|
|
76
|
+
this.getNetwork().then((chainId) => {
|
|
77
|
+
if (!chainId) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const resultChainName = this.mapChainIdToNetworkName(chainId);
|
|
81
|
+
const currentChainName = this.currentChainId
|
|
82
|
+
? this.mapChainIdToNetworkName(this.currentChainId)
|
|
83
|
+
: undefined;
|
|
84
|
+
logger.info(`[setupEventListeners] - got network: ${chainId} (${resultChainName}). current network: ${this.currentChainId} (${currentChainName})`);
|
|
85
|
+
if (chainId !== this.currentChainId) {
|
|
86
|
+
logger.info(`[setupEventListeners] - emitting chainChange event: ${chainId}`);
|
|
87
|
+
this.emit('chainChange', { chain: chainId });
|
|
88
|
+
this.currentChainId = chainId;
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}, 5000);
|
|
92
|
+
}
|
|
93
|
+
teardownEventListeners() {
|
|
94
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
95
|
+
clearInterval(this.intervalId);
|
|
96
|
+
this.intervalId = undefined;
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
endSession() {
|
|
100
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
101
|
+
this.teardownEventListeners();
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
getConnectedAccounts() {
|
|
105
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
106
|
+
const wallet = this.getWallet();
|
|
107
|
+
if (!wallet) {
|
|
108
|
+
return [];
|
|
109
|
+
}
|
|
110
|
+
const isProviderConnected = this.isProviderConnected();
|
|
111
|
+
const isPreauthorized = yield wallet.isPreauthorized();
|
|
112
|
+
const shouldReconnect = !isProviderConnected && isPreauthorized;
|
|
113
|
+
if (shouldReconnect) {
|
|
114
|
+
yield this.connect();
|
|
115
|
+
}
|
|
116
|
+
return wallet.selectedAddress ? [wallet.selectedAddress] : [];
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
exports.MetaMask = MetaMask;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type WalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
2
|
+
import StarknetProvider from '../starknetWalletConnector';
|
|
3
|
+
export declare class MetaMask extends StarknetProvider implements WalletConnector {
|
|
4
|
+
overrideKey: string;
|
|
5
|
+
private currentChainId;
|
|
6
|
+
private intervalId;
|
|
7
|
+
private provider;
|
|
8
|
+
constructor(opts: any);
|
|
9
|
+
getNetwork(): Promise<string | undefined>;
|
|
10
|
+
setupEventListeners(): void;
|
|
11
|
+
teardownEventListeners(): Promise<void>;
|
|
12
|
+
endSession(): Promise<void>;
|
|
13
|
+
getConnectedAccounts(): Promise<string[]>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
3
|
+
import { Eip6963ProviderSingleton } from '@dynamic-labs/utils';
|
|
4
|
+
import { Logger, LogLevel } from '@dynamic-labs/logger';
|
|
5
|
+
import StarknetWalletConnector from '../starknetWalletConnector.js';
|
|
6
|
+
import { createMetaMaskProviderWrapper } from '../utils/starknetSnap.js';
|
|
7
|
+
|
|
8
|
+
const logger = new Logger('MetaMask Starknet Snap', LogLevel.INFO);
|
|
9
|
+
class MetaMask extends StarknetWalletConnector {
|
|
10
|
+
constructor(opts) {
|
|
11
|
+
super('MetaMask Starknet', 'metamask_snap', opts);
|
|
12
|
+
this.overrideKey = 'metamaskstarknet';
|
|
13
|
+
const { providers } = Eip6963ProviderSingleton.get();
|
|
14
|
+
const metamaskProvider = providers.find((p) => ['io.metamask', 'io.metamask.flask'].includes(p.info.rdns));
|
|
15
|
+
if (metamaskProvider) {
|
|
16
|
+
this.provider = metamaskProvider.provider;
|
|
17
|
+
}
|
|
18
|
+
if (!window.starknet_metamask_snap && metamaskProvider) {
|
|
19
|
+
window.starknet_metamask_snap = createMetaMaskProviderWrapper(metamaskProvider.provider);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
getNetwork() {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
if (!this.provider) {
|
|
25
|
+
logger.error('[getNetwork] - No provider found, returning undefined');
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
logger.info('[getNetwork] - trying to fetch network using provider');
|
|
30
|
+
// we are using this method to get the network so that we always "see" the absolute
|
|
31
|
+
// active network in the companion site. when using the snap wrapper to get the network,
|
|
32
|
+
// we don't "see" the actual active network in the companion site – instead we see the
|
|
33
|
+
// network that was active at the time of the snap initialization
|
|
34
|
+
const result = yield this.provider.request({
|
|
35
|
+
method: 'wallet_invokeSnap',
|
|
36
|
+
params: {
|
|
37
|
+
request: {
|
|
38
|
+
method: 'starkNet_getCurrentNetwork',
|
|
39
|
+
params: {},
|
|
40
|
+
},
|
|
41
|
+
snapId: 'npm:@consensys/starknet-snap',
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
if (!('chainId' in result) || typeof result.chainId !== 'string') {
|
|
45
|
+
logger.error(`[getNetwork] - result.chainId should be a string, but got: ${
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
|
+
result.chainId}`);
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
if (result.chainId !== this.currentChainId) {
|
|
51
|
+
const resultChainName = this.mapChainIdToNetworkName(result.chainId);
|
|
52
|
+
const currentChainName = this.currentChainId
|
|
53
|
+
? this.mapChainIdToNetworkName(this.currentChainId)
|
|
54
|
+
: undefined;
|
|
55
|
+
logger.info(`[getNetwork] - emitting chainChange event. got chainId: ${result.chainId} (${resultChainName}). current chainId: ${this.currentChainId} (${currentChainName})`);
|
|
56
|
+
this.emit('chainChange', { chain: result.chainId });
|
|
57
|
+
}
|
|
58
|
+
this.currentChainId = result.chainId;
|
|
59
|
+
return this.currentChainId;
|
|
60
|
+
}
|
|
61
|
+
catch (e) {
|
|
62
|
+
logger.error('[getNetwork] - network fetch request failed, returning undefined', e);
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
setupEventListeners() {
|
|
68
|
+
if (this.intervalId) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
this.intervalId = setInterval(() => {
|
|
72
|
+
this.getNetwork().then((chainId) => {
|
|
73
|
+
if (!chainId) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const resultChainName = this.mapChainIdToNetworkName(chainId);
|
|
77
|
+
const currentChainName = this.currentChainId
|
|
78
|
+
? this.mapChainIdToNetworkName(this.currentChainId)
|
|
79
|
+
: undefined;
|
|
80
|
+
logger.info(`[setupEventListeners] - got network: ${chainId} (${resultChainName}). current network: ${this.currentChainId} (${currentChainName})`);
|
|
81
|
+
if (chainId !== this.currentChainId) {
|
|
82
|
+
logger.info(`[setupEventListeners] - emitting chainChange event: ${chainId}`);
|
|
83
|
+
this.emit('chainChange', { chain: chainId });
|
|
84
|
+
this.currentChainId = chainId;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}, 5000);
|
|
88
|
+
}
|
|
89
|
+
teardownEventListeners() {
|
|
90
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
clearInterval(this.intervalId);
|
|
92
|
+
this.intervalId = undefined;
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
endSession() {
|
|
96
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
97
|
+
this.teardownEventListeners();
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
getConnectedAccounts() {
|
|
101
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
102
|
+
const wallet = this.getWallet();
|
|
103
|
+
if (!wallet) {
|
|
104
|
+
return [];
|
|
105
|
+
}
|
|
106
|
+
const isProviderConnected = this.isProviderConnected();
|
|
107
|
+
const isPreauthorized = yield wallet.isPreauthorized();
|
|
108
|
+
const shouldReconnect = !isProviderConnected && isPreauthorized;
|
|
109
|
+
if (shouldReconnect) {
|
|
110
|
+
yield this.connect();
|
|
111
|
+
}
|
|
112
|
+
return wallet.selectedAddress ? [wallet.selectedAddress] : [];
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export { MetaMask };
|