@dynamic-labs/wagmi-connector 0.17.0-RC.9 → 0.17.1
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 +330 -0
- package/package.json +7 -5
- package/src/lib/Connector.js +2 -1
- package/src/lib/DynamicWagmiConnector.d.ts +3 -3
- package/src/lib/DynamicWagmiConnector.js +8 -12
- package/src/lib/SyncDynamicWagmi.js +9 -9
- package/src/lib/getConnector.d.ts +3 -0
- package/src/lib/getConnector.js +9 -0
- package/src/lib/getWagmiChainsFromDynamicChains.d.ts +2 -2
- package/src/lib/getWagmiProvidersFromDynamicChains.d.ts +2 -2
- package/src/lib/getWagmiProvidersFromDynamicChains.js +35 -14
- package/src/lib/hooks/index.d.ts +2 -0
- package/src/lib/hooks/useSyncConnectState/index.d.ts +1 -0
- package/src/lib/hooks/useSyncConnectState/usePrevious.d.ts +19 -0
- package/src/lib/hooks/useSyncConnectState/usePrevious.js +29 -0
- package/src/lib/hooks/useSyncConnectState/useSyncConnectState.d.ts +11 -0
- package/src/lib/hooks/useSyncConnectState/useSyncConnectState.js +28 -0
- package/src/lib/hooks/useWalletConnectorEverPresent/index.d.ts +1 -0
- package/src/lib/hooks/useWalletConnectorEverPresent/useWalletConnectorEverPresent.d.ts +2 -0
- package/src/lib/hooks/useWalletConnectorEverPresent/useWalletConnectorEverPresent.js +13 -0
- package/src/lib/mappers/chain.d.ts +2 -2
- package/src/lib/mappers/chain.js +29 -34
- package/src/lib/types.d.ts +25 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,334 @@
|
|
|
1
1
|
|
|
2
|
+
### [0.17.1](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.0...v0.17.1) (2023-06-14)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* display social icons in correct order ([#2320](https://github.com/dynamic-labs/DynamicAuth/issues/2320)) ([#2325](https://github.com/dynamic-labs/DynamicAuth/issues/2325)) ([6012bd9](https://github.com/dynamic-labs/DynamicAuth/commit/6012bd95030ff5076ce8a82d490c2e617eb05bdb))
|
|
8
|
+
* set min-height on social overlay modal
|
|
9
|
+
|
|
10
|
+
## [0.17.0](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.0-RC.33...v0.17.0) (2023-06-13)
|
|
11
|
+
|
|
12
|
+
Dynamic is excited to announce our most amazing SDK update yet (at least since 0.16.0 :-))!
|
|
13
|
+
We have some great things in this version, here are the highlights:
|
|
14
|
+
|
|
15
|
+
### Breaking Changes
|
|
16
|
+
- In favor of supporting MagicLink Wallets we removed the support for Fortmatic.
|
|
17
|
+
|
|
18
|
+
### Deprecations
|
|
19
|
+
- `chainName` on EvmNetwork is deprecated in favor of `name`. If you're passing `evmNetworks` to `DynamicContextProvider` or `DynamicWagmiConnector`, you should update your code like so:
|
|
20
|
+
```ts
|
|
21
|
+
<DynamicContextProvider
|
|
22
|
+
settings={{
|
|
23
|
+
environmentId: 'YOUR_ENV_ID',
|
|
24
|
+
evmNetworks: [
|
|
25
|
+
{
|
|
26
|
+
blockExplorerUrls: [],
|
|
27
|
+
chainId: 1,
|
|
28
|
+
iconUrls: [],
|
|
29
|
+
- chainName: 'Ethereum',
|
|
30
|
+
+ name: 'Ethereum',
|
|
31
|
+
nativeCurrency: {
|
|
32
|
+
decimals: 18,
|
|
33
|
+
name: 'Ether',
|
|
34
|
+
symbol: 'ETH',
|
|
35
|
+
},
|
|
36
|
+
networkId: 1,
|
|
37
|
+
rpcUrls: [],
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
}}
|
|
41
|
+
>
|
|
42
|
+
<HomePage />
|
|
43
|
+
</DynamicContextProvider>
|
|
44
|
+
```
|
|
45
|
+
- the `multiWallet` prop on DynamicContextProvider is deprecated in favor of the Dashboard settings. See [here](https://docs.dynamic.xyz/docs/multi-wallet#setup) for more info
|
|
46
|
+
|
|
47
|
+
### Highlighted Features
|
|
48
|
+
- Package splitting. You asked for it, and here it is!
|
|
49
|
+
If you want to reduce your package size to include only the chains and the wallets that your app needs, you now have the option to customize your build [See instructions](https://docs.dynamic.xyz/docs/reduce-bundle-size-with-modular-sdk)
|
|
50
|
+
|
|
51
|
+
- Two cool features for Magic Wallets:
|
|
52
|
+
- Support for [social login](https://docs.dynamic.xyz/docs/magic#enable-social-sign-in)
|
|
53
|
+
- Modal for supporting [send balance](https://docs.dynamic.xyz/docs/send-balance-ui).
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
- Generic types on various connector methods. For example, if you know you are working with an EVM network, you can typecast with `walletConnector.getNetwork<number>()` to work nicely in typescript.
|
|
57
|
+
|
|
58
|
+
- [onRamp with Banxa](https://docs.dynamic.xyz/docs/onramps) (please reach out to us to enable the feature)
|
|
59
|
+
|
|
60
|
+
- Ability to support multiple RPCs with fallbacks when providing the URL to network prop.
|
|
61
|
+
|
|
62
|
+
- Added suffix to the local storage key, in case you are testing multiple local environments locally at the same time.
|
|
63
|
+
|
|
64
|
+
- We have a new global loading state that you can now easily use to tell when the SDK completed loading (`sdkHasLoaded`)
|
|
65
|
+
|
|
66
|
+
And many other minor improvements and bug fixes.
|
|
67
|
+
|
|
68
|
+
Enjoy!
|
|
69
|
+
|
|
70
|
+
### Features
|
|
71
|
+
|
|
72
|
+
* Add suffix to local storage ([#2227](https://github.com/dynamic-labs/DynamicAuth/issues/2227)) ([b901b9b](https://github.com/dynamic-labs/DynamicAuth/commit/b901b9b43a3eaa80706b9ec0679f668a7b8b2507))
|
|
73
|
+
* dyn 2486 Add support for superb ([#2271](https://github.com/dynamic-labs/DynamicAuth/issues/2271)) ([8ea51e9](https://github.com/dynamic-labs/DynamicAuth/commit/8ea51e93c5d74d02efd47877042d7af05ca55f5c))
|
|
74
|
+
* pass icon theme variant to usages of SocialIcon ([#2303](https://github.com/dynamic-labs/DynamicAuth/issues/2303)) ([da59d6f](https://github.com/dynamic-labs/DynamicAuth/commit/da59d6f22e7ec49cb8cff757baada3cb1e737b99))
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
### Bug Fixes
|
|
78
|
+
|
|
79
|
+
* brief red error message as the KYC screen loads ([#2240](https://github.com/dynamic-labs/DynamicAuth/issues/2240)) ([1155e8b](https://github.com/dynamic-labs/DynamicAuth/commit/1155e8bd66ffdc96ae3f9d88f027793217c120a8))
|
|
80
|
+
* account controls hover does not fill the container ([#2300](https://github.com/dynamic-labs/DynamicAuth/issues/2300)) ([fdc984e](https://github.com/dynamic-labs/DynamicAuth/commit/fdc984e2d0b11d9d38dcd9e877c228fbc41c5855))
|
|
81
|
+
* refresh session in walletconnectv2 ([#2294](https://github.com/dynamic-labs/DynamicAuth/issues/2294)) ([d54263e](https://github.com/dynamic-labs/DynamicAuth/commit/d54263ea04c58f842b60b0c13f964fde25be786b))
|
|
82
|
+
|
|
83
|
+
## [0.17.0-RC.33](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.0-RC.32...v0.17.0-RC.33) (2023-06-09)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
### Bug Fixes
|
|
87
|
+
|
|
88
|
+
* display chain name in smaller format ([#2292](https://github.com/dynamic-labs/DynamicAuth/issues/2292)) ([95ff444](https://github.com/dynamic-labs/DynamicAuth/commit/95ff44412fcc192ecc2e9a2c1a5f090708c2da9c))
|
|
89
|
+
|
|
90
|
+
## [0.17.0-RC.32](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.0-RC.31...v0.17.0-RC.32) (2023-06-09)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
### Bug Fixes
|
|
94
|
+
|
|
95
|
+
* missing walletlist when filter finds no wallets ([#2289](https://github.com/dynamic-labs/DynamicAuth/issues/2289)) ([a7708d3](https://github.com/dynamic-labs/DynamicAuth/commit/a7708d3eab9609daa4c860555f5804f280958da5))
|
|
96
|
+
|
|
97
|
+
## [0.17.0-RC.31](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.0-RC.30...v0.17.0-RC.31) (2023-06-09)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
### Features
|
|
101
|
+
|
|
102
|
+
* add fake dapper mobile metadata so that it appears on mobile ([#2288](https://github.com/dynamic-labs/DynamicAuth/issues/2288)) ([ea98462](https://github.com/dynamic-labs/DynamicAuth/commit/ea98462e762d3fa032e2e40f17d2e3679146b3ae))
|
|
103
|
+
* pass variant to social icon getter ([#2277](https://github.com/dynamic-labs/DynamicAuth/issues/2277)) ([b1492ed](https://github.com/dynamic-labs/DynamicAuth/commit/b1492eda50eb80fbfee1aa968771f338694ef7e6))
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
### Bug Fixes
|
|
107
|
+
|
|
108
|
+
* don't remove network config from ls if there's a connected wallet ([#2280](https://github.com/dynamic-labs/DynamicAuth/issues/2280)) ([0703dfc](https://github.com/dynamic-labs/DynamicAuth/commit/0703dfc099f86a0802e83a27849b6953e1ddca31))
|
|
109
|
+
* **use-wallets-connection-state:** load connected state when wallets are present ([#2285](https://github.com/dynamic-labs/DynamicAuth/issues/2285)) ([7fb72dc](https://github.com/dynamic-labs/DynamicAuth/commit/7fb72dc8fe1404cd76e68bb3f0de9efa78634525))
|
|
110
|
+
|
|
111
|
+
## [0.17.0-RC.30](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.0-RC.29...v0.17.0-RC.30) (2023-06-08)
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
### Bug Fixes
|
|
115
|
+
|
|
116
|
+
* **view-context:** refactor view context to have initial view ([#2268](https://github.com/dynamic-labs/DynamicAuth/issues/2268)) ([0afe6ae](https://github.com/dynamic-labs/DynamicAuth/commit/0afe6ae469f62fd16fd8471322f9295957f607f6))
|
|
117
|
+
* **wcv2:** upgrade universal provider and refactor wcv2 ([#2163](https://github.com/dynamic-labs/DynamicAuth/issues/2163)) ([e69c67c](https://github.com/dynamic-labs/DynamicAuth/commit/e69c67c95dca0f694c4a554702be96c3f7d3d77e))
|
|
118
|
+
|
|
119
|
+
## [0.17.0-RC.29](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.0-RC.28...v0.17.0-RC.29) (2023-06-07)
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
### Bug Fixes
|
|
123
|
+
|
|
124
|
+
* de-duplicate authSuccess call ([#2269](https://github.com/dynamic-labs/DynamicAuth/issues/2269)) ([00268d0](https://github.com/dynamic-labs/DynamicAuth/commit/00268d001355946c98d285d71d7f7acc96d4c9f7))
|
|
125
|
+
* hide search when filtered wallets equal to number of shown wallets ([#2221](https://github.com/dynamic-labs/DynamicAuth/issues/2221)) ([fb0f629](https://github.com/dynamic-labs/DynamicAuth/commit/fb0f629ae76240fe681db91b485139934026054e))
|
|
126
|
+
|
|
127
|
+
## [0.17.0-RC.28](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.0-RC.27...v0.17.0-RC.28) (2023-06-06)
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
### Features
|
|
131
|
+
|
|
132
|
+
* lower username minimum length requirement ([#2265](https://github.com/dynamic-labs/DynamicAuth/issues/2265)) ([ed891ca](https://github.com/dynamic-labs/DynamicAuth/commit/ed891cac8cceaf9e0556b679eda7a3575725805d))
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
### Bug Fixes
|
|
136
|
+
|
|
137
|
+
* **send_balance:** add amount validation to form ([#2261](https://github.com/dynamic-labs/DynamicAuth/issues/2261)) ([9a57cfe](https://github.com/dynamic-labs/DynamicAuth/commit/9a57cfe0dd7f97aa16351b091ab385b2b5c7c5e4))
|
|
138
|
+
* shrink dynamic widget in smaller containers ([#2260](https://github.com/dynamic-labs/DynamicAuth/issues/2260)) ([353f447](https://github.com/dynamic-labs/DynamicAuth/commit/353f44724db83e9f1500c606fdea7d50a8067711))
|
|
139
|
+
|
|
140
|
+
## [0.17.0-RC.27](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.0-RC.26...v0.17.0-RC.27) (2023-06-06)
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
### Features
|
|
144
|
+
|
|
145
|
+
* sync wagmi to first connected eth wallet ([#2253](https://github.com/dynamic-labs/DynamicAuth/issues/2253)) ([c00aed7](https://github.com/dynamic-labs/DynamicAuth/commit/c00aed73a1014c668311c8cb59e5a466b5ee6779))
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
### Bug Fixes
|
|
149
|
+
|
|
150
|
+
* include username in userFieldsSchema ([#2257](https://github.com/dynamic-labs/DynamicAuth/issues/2257)) ([6e5431d](https://github.com/dynamic-labs/DynamicAuth/commit/6e5431d08323d718b11accf3790ef56fc7325b5c))
|
|
151
|
+
|
|
152
|
+
## [0.17.0-RC.26](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.0-RC.25...v0.17.0-RC.26) (2023-06-05)
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
### Features
|
|
156
|
+
|
|
157
|
+
* disable button on social unlink ([#2234](https://github.com/dynamic-labs/DynamicAuth/issues/2234)) ([7f148de](https://github.com/dynamic-labs/DynamicAuth/commit/7f148de76b0fca632e1b4d6ff71c18eb0207c02b))
|
|
158
|
+
* update magic + email icon in auth flow views ([#2224](https://github.com/dynamic-labs/DynamicAuth/issues/2224)) ([93f1ed6](https://github.com/dynamic-labs/DynamicAuth/commit/93f1ed644428701c2747565033d0ad113fa8eeb2))
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
### Bug Fixes
|
|
162
|
+
|
|
163
|
+
* **wallets:** keep magic social wallet connector on mobile ([#2242](https://github.com/dynamic-labs/DynamicAuth/issues/2242)) ([35c092d](https://github.com/dynamic-labs/DynamicAuth/commit/35c092da3b8a76c74ae25558489d663ce963d72f))
|
|
164
|
+
* wrong logger instance in UserProfileSocialAccount ([#2248](https://github.com/dynamic-labs/DynamicAuth/issues/2248)) ([814108d](https://github.com/dynamic-labs/DynamicAuth/commit/814108d416d9d730bed8976956bc7974c7fde2a8))
|
|
165
|
+
|
|
166
|
+
## [0.17.0-RC.25](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.0-RC.24...v0.17.0-RC.25) (2023-06-05)
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
### Bug Fixes
|
|
170
|
+
|
|
171
|
+
* **EmailOTPMagicWalletConnector:** allow user to reconnect with email wallet ([#2230](https://github.com/dynamic-labs/DynamicAuth/issues/2230)) ([6059886](https://github.com/dynamic-labs/DynamicAuth/commit/605988650a783ae824bb8c45edc5533fecf8726a))
|
|
172
|
+
* only set wagmi connector if connected chain is evm ([#2237](https://github.com/dynamic-labs/DynamicAuth/issues/2237)) ([a7be7d3](https://github.com/dynamic-labs/DynamicAuth/commit/a7be7d302d1e74088b0aa2b6848c879079e6f963))
|
|
173
|
+
* Revert "fix(ViewContext): only set view when on wallet list" ([#2235](https://github.com/dynamic-labs/DynamicAuth/issues/2235)) ([e790315](https://github.com/dynamic-labs/DynamicAuth/commit/e79031577f640161cc5f0b9b2e695e22d9a98901)), closes [#2226](https://github.com/dynamic-labs/DynamicAuth/issues/2226)
|
|
174
|
+
* set view to social-redirect-view while waiting to process magic redirect ([#2229](https://github.com/dynamic-labs/DynamicAuth/issues/2229)) ([f50a29c](https://github.com/dynamic-labs/DynamicAuth/commit/f50a29c0b9623c703f1577c7a41fcc5aee58abb8))
|
|
175
|
+
* user profile does not extend on mobile ([#2236](https://github.com/dynamic-labs/DynamicAuth/issues/2236)) ([5bb7912](https://github.com/dynamic-labs/DynamicAuth/commit/5bb7912a865338fdf6eca1a19ff4b74a3fb18eeb))
|
|
176
|
+
* **ViewContext:** only set view when on wallet list ([#2226](https://github.com/dynamic-labs/DynamicAuth/issues/2226)) ([85e8fc1](https://github.com/dynamic-labs/DynamicAuth/commit/85e8fc140069cabff41f4067ac93ea0c5cfaa161))
|
|
177
|
+
|
|
178
|
+
## [0.17.0-RC.24](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.0-RC.23...v0.17.0-RC.24) (2023-06-02)
|
|
179
|
+
|
|
180
|
+
## [0.17.0-RC.23](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.0-RC.22...v0.17.0-RC.23) (2023-06-02)
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
### Bug Fixes
|
|
184
|
+
|
|
185
|
+
* flow connection status improvements ([#2212](https://github.com/dynamic-labs/DynamicAuth/issues/2212)) ([5225e9f](https://github.com/dynamic-labs/DynamicAuth/commit/5225e9f3f19705cdde3c1d860ddf4e69689a839b))
|
|
186
|
+
* **useSyncPrimaryWallet:** disables the hook while connect state is loaded ([#2193](https://github.com/dynamic-labs/DynamicAuth/issues/2193)) ([d2a69c8](https://github.com/dynamic-labs/DynamicAuth/commit/d2a69c8edfbb2a19305b0fd322e24d909bbf9b4f)), closes [#2155](https://github.com/dynamic-labs/DynamicAuth/issues/2155)
|
|
187
|
+
|
|
188
|
+
## [0.17.0-RC.22](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.0-RC.21...v0.17.0-RC.22) (2023-06-02)
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
### Features
|
|
192
|
+
|
|
193
|
+
* social copy update ([#2215](https://github.com/dynamic-labs/DynamicAuth/issues/2215)) ([1fe7316](https://github.com/dynamic-labs/DynamicAuth/commit/1fe7316a94284db7227d5ab09026354269559752))
|
|
194
|
+
|
|
195
|
+
## [0.17.0-RC.21](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.0-RC.20...v0.17.0-RC.21) (2023-06-02)
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
### Bug Fixes
|
|
199
|
+
|
|
200
|
+
* social icon is missing on some views ([#2211](https://github.com/dynamic-labs/DynamicAuth/issues/2211)) ([bddd255](https://github.com/dynamic-labs/DynamicAuth/commit/bddd255f0aa61aed4b767145c51624ac1eb9b963))
|
|
201
|
+
|
|
202
|
+
## [0.17.0-RC.20](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.0-RC.19...v0.17.0-RC.20) (2023-06-01)
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
### Features
|
|
206
|
+
|
|
207
|
+
* add AccessDeniedContext to lift denied wallet state up ([#2180](https://github.com/dynamic-labs/DynamicAuth/issues/2180)) ([509519d](https://github.com/dynamic-labs/DynamicAuth/commit/509519d08496248545f1548f676b13e140473e41))
|
|
208
|
+
* **DYN-2338:** update magic icons to social icons ([#2176](https://github.com/dynamic-labs/DynamicAuth/issues/2176)) ([42a4f63](https://github.com/dynamic-labs/DynamicAuth/commit/42a4f6367e6fa4ad8736f9ac42f535c8a9c1d377))
|
|
209
|
+
* **DynamicWidget:** add send balance button ([#2183](https://github.com/dynamic-labs/DynamicAuth/issues/2183)) ([d76355e](https://github.com/dynamic-labs/DynamicAuth/commit/d76355e1f9c3a7b05cbb5b7b3144dad379586689))
|
|
210
|
+
* handle magic redirect error ([#2203](https://github.com/dynamic-labs/DynamicAuth/issues/2203)) ([9a088c6](https://github.com/dynamic-labs/DynamicAuth/commit/9a088c6aad2eb2c1045f544a784083d2732df440))
|
|
211
|
+
* **SendBalanceModal:** adds openSendBalanceModal in dynamic context ([#2159](https://github.com/dynamic-labs/DynamicAuth/issues/2159)) ([f89b21b](https://github.com/dynamic-labs/DynamicAuth/commit/f89b21bfcd65bb61ef33b17b460140404574b235))
|
|
212
|
+
* social error handling improvements ([#2146](https://github.com/dynamic-labs/DynamicAuth/issues/2146)) ([a64a26a](https://github.com/dynamic-labs/DynamicAuth/commit/a64a26aa42c228654cb135cd6c4778e8bd2bd0e6))
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
### Bug Fixes
|
|
216
|
+
|
|
217
|
+
* amendments to user profile ([#2201](https://github.com/dynamic-labs/DynamicAuth/issues/2201)) ([5d12c17](https://github.com/dynamic-labs/DynamicAuth/commit/5d12c1716cdcd8d843ef3ff941e163bad28573b1))
|
|
218
|
+
* **formatBigNumber:** display the ceil value when value is too low ([#2165](https://github.com/dynamic-labs/DynamicAuth/issues/2165)) ([ad56fe1](https://github.com/dynamic-labs/DynamicAuth/commit/ad56fe11d55ee038e08ef77dfa2bd6155fee7fe3))
|
|
219
|
+
* use wcv2 only if wallet supports it ([#2198](https://github.com/dynamic-labs/DynamicAuth/issues/2198)) ([3d5fea7](https://github.com/dynamic-labs/DynamicAuth/commit/3d5fea7743a18b47f33ef371ecc2652003accb4d))
|
|
220
|
+
|
|
221
|
+
## [0.17.0-RC.19](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.0-RC.18...v0.17.0-RC.19) (2023-05-30)
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
### Features
|
|
225
|
+
|
|
226
|
+
* add SocialWrongAccountView ([#2153](https://github.com/dynamic-labs/DynamicAuth/issues/2153)) ([531a29d](https://github.com/dynamic-labs/DynamicAuth/commit/531a29d7d87739d974ecc35c57ef0d333a5e7451))
|
|
227
|
+
* do not show unlink button for embedded wallets ([#2169](https://github.com/dynamic-labs/DynamicAuth/issues/2169)) ([f813058](https://github.com/dynamic-labs/DynamicAuth/commit/f8130585c82c7ae73d1e32e107f67ec86b4edb89))
|
|
228
|
+
* **DYN-2402:** coinbase issues after disconnecting ([#2149](https://github.com/dynamic-labs/DynamicAuth/issues/2149)) ([91d49fb](https://github.com/dynamic-labs/DynamicAuth/commit/91d49fb7f8c6fca3ab03098f3fba53d277c836ad))
|
|
229
|
+
* handle user reconnecting with wrong social account ([#2157](https://github.com/dynamic-labs/DynamicAuth/issues/2157)) ([4f7c6df](https://github.com/dynamic-labs/DynamicAuth/commit/4f7c6dff7df9a7966a644bf2510cb3825b2c6408))
|
|
230
|
+
* **social:** handle reconnect ([#2131](https://github.com/dynamic-labs/DynamicAuth/issues/2131)) ([2b3e5fb](https://github.com/dynamic-labs/DynamicAuth/commit/2b3e5fbb72bb7dafee3bd0bbfa73fae444055410))
|
|
231
|
+
|
|
232
|
+
## [0.17.0-RC.18](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.0-RC.17...v0.17.0-RC.18) (2023-05-19)
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
### Features
|
|
236
|
+
|
|
237
|
+
* add getReferencedAccount ([#2141](https://github.com/dynamic-labs/DynamicAuth/issues/2141)) ([ac170a6](https://github.com/dynamic-labs/DynamicAuth/commit/ac170a6dfac25ff9911feb390495974aa5dbede6))
|
|
238
|
+
* add reconnectSocialWallet ([#2142](https://github.com/dynamic-labs/DynamicAuth/issues/2142)) ([fefd759](https://github.com/dynamic-labs/DynamicAuth/commit/fefd759b816b286dd8a7673cf6c839fee59768ac))
|
|
239
|
+
* **DYN-2220:** add Transaction Successfully Sent view ([#2134](https://github.com/dynamic-labs/DynamicAuth/issues/2134)) ([7db96ad](https://github.com/dynamic-labs/DynamicAuth/commit/7db96adcd3b84aef29fbabe40a1e048ea629d2bb))
|
|
240
|
+
* **MagicSocialWalletConnector:** store public address from redirect result in local storage ([#2139](https://github.com/dynamic-labs/DynamicAuth/issues/2139)) ([90b60e4](https://github.com/dynamic-labs/DynamicAuth/commit/90b60e485a53ff29a0e52ef27a58383771490974))
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
### Bug Fixes
|
|
244
|
+
|
|
245
|
+
* issue when linking from detect_new_wallet ([#2148](https://github.com/dynamic-labs/DynamicAuth/issues/2148)) ([98feb7b](https://github.com/dynamic-labs/DynamicAuth/commit/98feb7bde081a8107577ac7ec70d0f9c4b611a2b))
|
|
246
|
+
* multi-wallet flows ([#2150](https://github.com/dynamic-labs/DynamicAuth/issues/2150)) ([c82ef4a](https://github.com/dynamic-labs/DynamicAuth/commit/c82ef4a5cc75c9f8edb30620e32dd64bbdb0eb7f))
|
|
247
|
+
* starknet getConnectedAccounts should return an empty array if there's no address to return ([#2140](https://github.com/dynamic-labs/DynamicAuth/issues/2140)) ([ce39641](https://github.com/dynamic-labs/DynamicAuth/commit/ce39641a6dbec1d05d8d5cc611a02de8bd756351))
|
|
248
|
+
|
|
249
|
+
## [0.17.0-RC.17](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.0-RC.16...v0.17.0-RC.17) (2023-05-17)
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
### Features
|
|
253
|
+
|
|
254
|
+
* distinguish walletconnect deeplink types ([#2093](https://github.com/dynamic-labs/DynamicAuth/issues/2093)) ([dcd29f7](https://github.com/dynamic-labs/DynamicAuth/commit/dcd29f7cfc5e6481aaaae502b3fc4e4d225f1fc1))
|
|
255
|
+
* **social:** pass did token to verify request ([#2124](https://github.com/dynamic-labs/DynamicAuth/issues/2124)) ([60d73a5](https://github.com/dynamic-labs/DynamicAuth/commit/60d73a5f432d488979f33fe29666d1afa8fc0e8e))
|
|
256
|
+
* support optional priority and stalltimeout for customer provided rpc urls ([#2091](https://github.com/dynamic-labs/DynamicAuth/issues/2091)) ([eebacda](https://github.com/dynamic-labs/DynamicAuth/commit/eebacda6a9d6ba583eff4e4e5a38eb9945c4825e))
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
### Bug Fixes
|
|
260
|
+
|
|
261
|
+
* add and remove event listeners for Solflare ([#2127](https://github.com/dynamic-labs/DynamicAuth/issues/2127)) ([978c7ba](https://github.com/dynamic-labs/DynamicAuth/commit/978c7ba0e3745e26d9dfc9b7c46a24adc913f02f))
|
|
262
|
+
* get publicKey from provider if no address and publicKey are returned on connect ([#2126](https://github.com/dynamic-labs/DynamicAuth/issues/2126)) ([c9c9b2a](https://github.com/dynamic-labs/DynamicAuth/commit/c9c9b2af81f660aa651fc4b0e01cd3c823bb0229))
|
|
263
|
+
* remove detect known secondary wallet modal ([#2117](https://github.com/dynamic-labs/DynamicAuth/issues/2117)) ([0e8bbd8](https://github.com/dynamic-labs/DynamicAuth/commit/0e8bbd8c385fe528a7af3ccc037812df9d6e0c84))
|
|
264
|
+
* revert changes for select wallet to work with solflare ([#2120](https://github.com/dynamic-labs/DynamicAuth/issues/2120)) ([76cf228](https://github.com/dynamic-labs/DynamicAuth/commit/76cf228c495d6592da4c88b8a0d5a5fc480861ae))
|
|
265
|
+
* setIsVerifying to false when selecting a connector ([#2133](https://github.com/dynamic-labs/DynamicAuth/issues/2133)) ([8ddeba3](https://github.com/dynamic-labs/DynamicAuth/commit/8ddeba377f35dfb4a104cd6bd7ee6315d574710f))
|
|
266
|
+
* setPrimaryWallet and useSyncPrimaryWallet updates ([#2128](https://github.com/dynamic-labs/DynamicAuth/issues/2128)) ([fb47b17](https://github.com/dynamic-labs/DynamicAuth/commit/fb47b17ddc7f41c29f140a1a85a1e47dbf017fff))
|
|
267
|
+
* update text color and add close button on extension not installed prompt ([#2122](https://github.com/dynamic-labs/DynamicAuth/issues/2122)) ([b4848a0](https://github.com/dynamic-labs/DynamicAuth/commit/b4848a0a8094b4ceac67e2667d277a9aa5e2e137))
|
|
268
|
+
|
|
269
|
+
## [0.17.0-RC.16](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.0-RC.15...v0.17.0-RC.16) (2023-05-15)
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
### Features
|
|
273
|
+
|
|
274
|
+
* add social oauth result to verify request ([#2081](https://github.com/dynamic-labs/DynamicAuth/issues/2081)) ([4da650a](https://github.com/dynamic-labs/DynamicAuth/commit/4da650affe9c96e0ab9e446f58c91b9b13db3651))
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
### Bug Fixes
|
|
278
|
+
|
|
279
|
+
* **DYN-2327:** user profile is not loaded properly on the first load ([#2113](https://github.com/dynamic-labs/DynamicAuth/issues/2113)) ([c05834e](https://github.com/dynamic-labs/DynamicAuth/commit/c05834ed89ecc12d586baa97bcaf2bd3c1919f59))
|
|
280
|
+
|
|
281
|
+
## [0.17.0-RC.15](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.0-RC.14...v0.17.0-RC.15) (2023-05-15)
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
### Bug Fixes
|
|
285
|
+
|
|
286
|
+
* pass network to link request ([#2114](https://github.com/dynamic-labs/DynamicAuth/issues/2114)) ([0f7d20d](https://github.com/dynamic-labs/DynamicAuth/commit/0f7d20d948b737b98d4a8db8aaa7648033e25922))
|
|
287
|
+
|
|
288
|
+
## [0.17.0-RC.14](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.0-RC.13...v0.17.0-RC.14) (2023-05-12)
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
### Features
|
|
292
|
+
|
|
293
|
+
* add local flowNetwork prop to toggle between mainnet and testnet ([#2094](https://github.com/dynamic-labs/DynamicAuth/issues/2094)) ([43c3f20](https://github.com/dynamic-labs/DynamicAuth/commit/43c3f20abf2d6c83e88e48f885749b978cec078a))
|
|
294
|
+
* deprecate multiWallet sdk setting and fetch it from projectSettings ([#2079](https://github.com/dynamic-labs/DynamicAuth/issues/2079)) ([8b7f11d](https://github.com/dynamic-labs/DynamicAuth/commit/8b7f11d9eb71a17056be05cc8006d15dc149e3ff))
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
### Bug Fixes
|
|
298
|
+
|
|
299
|
+
* **balance:** correctly compare AVAX address when fetching balance ([#2064](https://github.com/dynamic-labs/DynamicAuth/issues/2064)) ([c5942d1](https://github.com/dynamic-labs/DynamicAuth/commit/c5942d112804f3a935bca396221fb33a3c7cc42a))
|
|
300
|
+
* **DYN-2231:** restore User Profile display when social is the only enabled flag in information capture ([#2070](https://github.com/dynamic-labs/DynamicAuth/issues/2070)) ([6790bc7](https://github.com/dynamic-labs/DynamicAuth/commit/6790bc7e54afb1807be9996dc47129932441bbae))
|
|
301
|
+
|
|
302
|
+
## [0.17.0-RC.13](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.0-RC.12...v0.17.0-RC.13) (2023-05-10)
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
### Features
|
|
306
|
+
|
|
307
|
+
* discriminate magic connectors ([#2069](https://github.com/dynamic-labs/DynamicAuth/issues/2069)) ([e9f6fd1](https://github.com/dynamic-labs/DynamicAuth/commit/e9f6fd15082364612a86d6d2a091cb8bd4eccc1f))
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
### Bug Fixes
|
|
311
|
+
|
|
312
|
+
* add popper to fix dots menu positioning ([#2075](https://github.com/dynamic-labs/DynamicAuth/issues/2075)) ([fe945bd](https://github.com/dynamic-labs/DynamicAuth/commit/fe945bd3bcc5edeecfa0a2e7e53e30dc507c6118))
|
|
313
|
+
* polyfill process if not defined in global ([#2088](https://github.com/dynamic-labs/DynamicAuth/issues/2088)) ([a5d8194](https://github.com/dynamic-labs/DynamicAuth/commit/a5d81942440a6fe290c15b58b942012afe42aa00))
|
|
314
|
+
|
|
315
|
+
## [0.17.0-RC.12](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.0-RC.11...v0.17.0-RC.12) (2023-05-09)
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
### Bug Fixes
|
|
319
|
+
|
|
320
|
+
* allow opening network picker when unsupported network and only one network enabled ([#2061](https://github.com/dynamic-labs/DynamicAuth/issues/2061)) ([486607f](https://github.com/dynamic-labs/DynamicAuth/commit/486607f8bb2666749ce39f18cf2368c86a78f74f))
|
|
321
|
+
* **DynamicWagmiConnector:** prevent disconnect when WC is not present ([#2063](https://github.com/dynamic-labs/DynamicAuth/issues/2063)) ([ef93623](https://github.com/dynamic-labs/DynamicAuth/commit/ef93623fb68b63a9e89a5958eb87bbddedd15fb6))
|
|
322
|
+
|
|
323
|
+
## [0.17.0-RC.11](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.0-RC.10...v0.17.0-RC.11) (2023-05-08)
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
### Features
|
|
327
|
+
|
|
328
|
+
* add walletConnectors setting for supplying array of wallet connectors ([#2059](https://github.com/dynamic-labs/DynamicAuth/issues/2059)) ([ae65218](https://github.com/dynamic-labs/DynamicAuth/commit/ae652180b17a870f7bbf5f99c876f386e0de1af5))
|
|
329
|
+
|
|
330
|
+
## [0.17.0-RC.10](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.0-RC.9...v0.17.0-RC.10) (2023-05-05)
|
|
331
|
+
|
|
2
332
|
## [0.17.0-RC.9](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.0-RC.8...v0.17.0-RC.9) (2023-05-05)
|
|
3
333
|
|
|
4
334
|
|
package/package.json
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/wagmi-connector",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/dynamic-labs/DynamicAuth.git",
|
|
7
7
|
"directory": "packages/wagmi-connector"
|
|
8
8
|
},
|
|
9
9
|
"peerDependencies": {
|
|
10
|
-
"@wagmi/core": "~0.
|
|
10
|
+
"@wagmi/core": "~0.10.11",
|
|
11
11
|
"react": "^17.0.2 || ^18.0.0",
|
|
12
|
-
"ethers": "
|
|
13
|
-
"wagmi": "~0.
|
|
14
|
-
"@dynamic-labs/sdk-react-core": "0.17.
|
|
12
|
+
"ethers": "5.7.2",
|
|
13
|
+
"wagmi": "~0.12.13",
|
|
14
|
+
"@dynamic-labs/sdk-react-core": "0.17.1",
|
|
15
|
+
"@dynamic-labs/types": "0.17.1",
|
|
16
|
+
"@dynamic-labs/wallet-connector-core": "0.17.1"
|
|
15
17
|
},
|
|
16
18
|
"license": "MIT",
|
|
17
19
|
"main": "./src/index.cjs",
|
package/src/lib/Connector.js
CHANGED
|
@@ -25,6 +25,7 @@ class Connector extends Connector$1 {
|
|
|
25
25
|
this.onDisconnect = () => __awaiter(this, void 0, void 0, function* () { });
|
|
26
26
|
this.handleLogOut = handleLogOut;
|
|
27
27
|
this.walletConnector = walletConnector;
|
|
28
|
+
this.id = `dynamic-${walletConnector.key}`;
|
|
28
29
|
this.setupEventListeners();
|
|
29
30
|
}
|
|
30
31
|
setupEventListeners() {
|
|
@@ -114,7 +115,7 @@ class Connector extends Connector$1 {
|
|
|
114
115
|
name: `Chain ${id}`,
|
|
115
116
|
nativeCurrency: { decimals: 18, name: 'Ether', symbol: 'ETH' },
|
|
116
117
|
network: `${id}`,
|
|
117
|
-
rpcUrls: { default: { http: [''] } },
|
|
118
|
+
rpcUrls: { default: { http: [''] }, public: { http: [''] } },
|
|
118
119
|
});
|
|
119
120
|
});
|
|
120
121
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { WagmiEvmNetworks } from './types';
|
|
3
3
|
type DynamicWagmiConnectorProps = {
|
|
4
4
|
children: ReactNode;
|
|
5
|
-
evmNetworks?:
|
|
5
|
+
evmNetworks?: WagmiEvmNetworks[];
|
|
6
6
|
};
|
|
7
|
-
export declare const DynamicWagmiConnector: ({ evmNetworks: customerSuppliedEvmNetworks, children, }: DynamicWagmiConnectorProps) => React.FunctionComponentElement<React.PropsWithChildren<import("wagmi").WagmiConfigProps<import("@wagmi/core/dist/index-
|
|
7
|
+
export declare const DynamicWagmiConnector: ({ evmNetworks: customerSuppliedEvmNetworks, children, }: DynamicWagmiConnectorProps) => React.FunctionComponentElement<React.PropsWithChildren<import("wagmi").WagmiConfigProps<import("@wagmi/core/dist/index-35b6525c").P, import("@wagmi/core/dist/index-35b6525c").W>>>;
|
|
8
8
|
export {};
|
|
@@ -6,6 +6,7 @@ import { Connector } from './Connector.js';
|
|
|
6
6
|
import { SyncDynamicWagmi } from './SyncDynamicWagmi.js';
|
|
7
7
|
import { getWagmiChainsFromDynamicChains } from './getWagmiChainsFromDynamicChains.js';
|
|
8
8
|
import { getWagmiProvidersFromDynamicChains } from './getWagmiProvidersFromDynamicChains.js';
|
|
9
|
+
import { getConnector } from './getConnector.js';
|
|
9
10
|
|
|
10
11
|
const { provider } = configureChains([mainnet], [publicProvider()]);
|
|
11
12
|
const client = createClient({
|
|
@@ -18,7 +19,7 @@ const client = createClient({
|
|
|
18
19
|
let connector = undefined;
|
|
19
20
|
const DynamicWagmiConnector = ({ evmNetworks: customerSuppliedEvmNetworks, children, }) => {
|
|
20
21
|
var _a;
|
|
21
|
-
const { networkConfigurations,
|
|
22
|
+
const { networkConfigurations, handleLogOut, connectedWallets } = useDynamicContext();
|
|
22
23
|
const evmNetworks = ((_a = customerSuppliedEvmNetworks !== null && customerSuppliedEvmNetworks !== void 0 ? customerSuppliedEvmNetworks : networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.evm) !== null && _a !== void 0 ? _a : []).map((network) => {
|
|
23
24
|
network.chainId = parseInt(network.chainId.toString());
|
|
24
25
|
return network;
|
|
@@ -26,17 +27,12 @@ const DynamicWagmiConnector = ({ evmNetworks: customerSuppliedEvmNetworks, child
|
|
|
26
27
|
const mappedChains = getWagmiChainsFromDynamicChains(evmNetworks);
|
|
27
28
|
const mappedProviders = getWagmiProvidersFromDynamicChains(evmNetworks);
|
|
28
29
|
const { chains, provider } = configureChains(mappedChains, mappedProviders);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
else if (connector && !walletConnector) {
|
|
37
|
-
connector = undefined;
|
|
38
|
-
}
|
|
39
|
-
client.config = Object.assign(Object.assign({}, client.config), { autoConnect: true, connectors: connector ? [connector] : [], provider });
|
|
30
|
+
connector = getConnector(connectedWallets, (wallet) => new Connector({
|
|
31
|
+
chains,
|
|
32
|
+
handleLogOut,
|
|
33
|
+
walletConnector: wallet.connector,
|
|
34
|
+
}));
|
|
35
|
+
client.config = Object.assign(Object.assign({}, client.config), { autoConnect: true, connectors: connector ? [connector] : [], provider: provider });
|
|
40
36
|
// use React.createElement to prevent bunding react/jsx-runtime,
|
|
41
37
|
// which is not compatible when bundling apps using React 17
|
|
42
38
|
return React.createElement(WagmiConfig, { client: client }, React.createElement(SyncDynamicWagmi, { connector }, children));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { useClient, useConnect, useDisconnect } from 'wagmi';
|
|
3
3
|
import { useDynamicContext } from '@dynamic-labs/sdk-react-core';
|
|
4
|
+
import { useSyncConnectState } from './hooks/useSyncConnectState/useSyncConnectState.js';
|
|
4
5
|
|
|
5
6
|
const SyncDynamicWagmi = ({ children, connector, }) => {
|
|
6
7
|
const { status: clientStatus } = useClient();
|
|
@@ -16,14 +17,13 @@ const SyncDynamicWagmi = ({ children, connector, }) => {
|
|
|
16
17
|
}, 100);
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}, [clientStatus, connect, connector, disconnect, walletConnector]);
|
|
20
|
+
useSyncConnectState({
|
|
21
|
+
clientStatus,
|
|
22
|
+
connect,
|
|
23
|
+
connector,
|
|
24
|
+
disconnect,
|
|
25
|
+
walletConnector,
|
|
26
|
+
});
|
|
27
27
|
// use React.createElement to prevent bunding react/jsx-runtime,
|
|
28
28
|
// which is not compatible when bundling apps using React 17
|
|
29
29
|
return React.createElement(React.Fragment, null, children);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Chain } from 'wagmi';
|
|
2
|
-
import {
|
|
3
|
-
export declare const getWagmiChainsFromDynamicChains: (dynamicChains:
|
|
2
|
+
import { WagmiEvmNetworks } from './types';
|
|
3
|
+
export declare const getWagmiChainsFromDynamicChains: (dynamicChains: WagmiEvmNetworks[]) => Chain[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { providers } from 'ethers';
|
|
2
2
|
import { Chain, ChainProviderFn } from 'wagmi';
|
|
3
|
-
import {
|
|
4
|
-
export declare const getWagmiProvidersFromDynamicChains: (dynamicChains:
|
|
3
|
+
import { WagmiEvmNetworks } from './types';
|
|
4
|
+
export declare const getWagmiProvidersFromDynamicChains: (dynamicChains: WagmiEvmNetworks[]) => ChainProviderFn<Chain, providers.JsonRpcProvider, providers.WebSocketProvider>[];
|
|
@@ -1,21 +1,42 @@
|
|
|
1
1
|
import { publicProvider } from 'wagmi/providers/public';
|
|
2
|
-
import {
|
|
2
|
+
import { jsonRpcProvider } from 'wagmi/providers/jsonRpc';
|
|
3
3
|
|
|
4
|
+
/* eslint-disable prefer-destructuring */
|
|
5
|
+
const getProvider = (dynamicChain, rpcUrl) => {
|
|
6
|
+
let http;
|
|
7
|
+
let webSocket;
|
|
8
|
+
let priority;
|
|
9
|
+
let stallTimeout;
|
|
10
|
+
if (typeof rpcUrl !== 'string') {
|
|
11
|
+
http = rpcUrl.http;
|
|
12
|
+
webSocket = rpcUrl.webSocket;
|
|
13
|
+
priority = rpcUrl.priority;
|
|
14
|
+
stallTimeout = rpcUrl.stallTimeout;
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
http = rpcUrl;
|
|
18
|
+
}
|
|
19
|
+
return (chain) => {
|
|
20
|
+
if (chain.id !== dynamicChain.chainId)
|
|
21
|
+
return null;
|
|
22
|
+
return jsonRpcProvider({
|
|
23
|
+
priority,
|
|
24
|
+
rpc: () => ({
|
|
25
|
+
http,
|
|
26
|
+
webSocket,
|
|
27
|
+
}),
|
|
28
|
+
stallTimeout,
|
|
29
|
+
})(chain);
|
|
30
|
+
};
|
|
31
|
+
};
|
|
4
32
|
const getWagmiProvidersFromDynamicChains = (dynamicChains) => {
|
|
5
|
-
var _a;
|
|
6
33
|
const wagmiProviders = [];
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
chain,
|
|
14
|
-
provider: () => new providers.JsonRpcProvider(url, chain.id),
|
|
15
|
-
};
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
}
|
|
34
|
+
dynamicChains.forEach((dynamicChain) => {
|
|
35
|
+
var _a;
|
|
36
|
+
((_a = dynamicChain.privateCustomerRpcUrls) !== null && _a !== void 0 ? _a : []).forEach((rpcUrl) => {
|
|
37
|
+
wagmiProviders.push(getProvider(dynamicChain, rpcUrl));
|
|
38
|
+
});
|
|
39
|
+
});
|
|
19
40
|
return [...wagmiProviders, publicProvider()];
|
|
20
41
|
};
|
|
21
42
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useSyncConnectState } from './useSyncConnectState';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is used to track a previous value of a variable.
|
|
3
|
+
*
|
|
4
|
+
* Example:
|
|
5
|
+
* const someHook = ({ value }) => {
|
|
6
|
+
* const previousValue = usePrevious(value);
|
|
7
|
+
* useEffect(() => {
|
|
8
|
+
* if (previousValue !== value) {
|
|
9
|
+
* // do something
|
|
10
|
+
* }
|
|
11
|
+
* }, [value, previousValue]);
|
|
12
|
+
* }
|
|
13
|
+
*
|
|
14
|
+
* When someHook is rendered for the first time with value = true, previousValue will be undefined
|
|
15
|
+
* so the condition will be true and the effect will run. When someHook is rendered again with
|
|
16
|
+
* value = true, previousValue will have been set to true so the condition will be false and the
|
|
17
|
+
* effect will not run.
|
|
18
|
+
*/
|
|
19
|
+
export declare const usePrevious: <T>(value: T) => T | undefined;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useRef, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This is used to track a previous value of a variable.
|
|
5
|
+
*
|
|
6
|
+
* Example:
|
|
7
|
+
* const someHook = ({ value }) => {
|
|
8
|
+
* const previousValue = usePrevious(value);
|
|
9
|
+
* useEffect(() => {
|
|
10
|
+
* if (previousValue !== value) {
|
|
11
|
+
* // do something
|
|
12
|
+
* }
|
|
13
|
+
* }, [value, previousValue]);
|
|
14
|
+
* }
|
|
15
|
+
*
|
|
16
|
+
* When someHook is rendered for the first time with value = true, previousValue will be undefined
|
|
17
|
+
* so the condition will be true and the effect will run. When someHook is rendered again with
|
|
18
|
+
* value = true, previousValue will have been set to true so the condition will be false and the
|
|
19
|
+
* effect will not run.
|
|
20
|
+
*/
|
|
21
|
+
const usePrevious = (value) => {
|
|
22
|
+
const ref = useRef();
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
ref.current = value;
|
|
25
|
+
}, [value]);
|
|
26
|
+
return ref.current;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { usePrevious };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Connector } from 'wagmi';
|
|
2
|
+
import { ConnectArgs } from '@wagmi/core';
|
|
3
|
+
import { WalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
4
|
+
export type SyncConnectStateHookProps = {
|
|
5
|
+
clientStatus: 'connected' | 'connecting' | 'reconnecting' | 'disconnected';
|
|
6
|
+
connect: (args?: Partial<ConnectArgs> | undefined) => void;
|
|
7
|
+
connector: Connector | undefined;
|
|
8
|
+
disconnect: () => void;
|
|
9
|
+
walletConnector: WalletConnector | null;
|
|
10
|
+
};
|
|
11
|
+
export declare const useSyncConnectState: ({ walletConnector, disconnect, clientStatus, connect, connector, }: SyncConnectStateHookProps) => void;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { useWalletConnectorEverPresent } from '../useWalletConnectorEverPresent/useWalletConnectorEverPresent.js';
|
|
3
|
+
import { usePrevious } from './usePrevious.js';
|
|
4
|
+
|
|
5
|
+
const useSyncConnectState = ({ walletConnector, disconnect, clientStatus, connect, connector, }) => {
|
|
6
|
+
const wasWalletConnectEverPresent = useWalletConnectorEverPresent(walletConnector);
|
|
7
|
+
const prevConnectorId = usePrevious(connector === null || connector === void 0 ? void 0 : connector.id);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
if (!walletConnector) {
|
|
10
|
+
if (wasWalletConnectEverPresent) {
|
|
11
|
+
disconnect();
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
else if ((connector === null || connector === void 0 ? void 0 : connector.id) !== prevConnectorId) {
|
|
15
|
+
connect({ connector });
|
|
16
|
+
}
|
|
17
|
+
}, [
|
|
18
|
+
clientStatus,
|
|
19
|
+
connect,
|
|
20
|
+
connector,
|
|
21
|
+
disconnect,
|
|
22
|
+
prevConnectorId,
|
|
23
|
+
walletConnector,
|
|
24
|
+
wasWalletConnectEverPresent,
|
|
25
|
+
]);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export { useSyncConnectState };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useWalletConnectorEverPresent } from './useWalletConnectorEverPresent';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
const useWalletConnectorEverPresent = (walletConnector) => {
|
|
4
|
+
const [present, setPresent] = useState(false);
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
if (walletConnector) {
|
|
7
|
+
setPresent(true);
|
|
8
|
+
}
|
|
9
|
+
}, [walletConnector]);
|
|
10
|
+
return present;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { useWalletConnectorEverPresent };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Chain } from 'wagmi';
|
|
2
|
-
import {
|
|
3
|
-
export declare const mapDynamicChainToWagmi: (dynamicChain:
|
|
2
|
+
import { WagmiEvmNetworks } from '../types';
|
|
3
|
+
export declare const mapDynamicChainToWagmi: (dynamicChain: WagmiEvmNetworks) => Chain;
|
package/src/lib/mappers/chain.js
CHANGED
|
@@ -1,47 +1,42 @@
|
|
|
1
1
|
import * as allChains from 'wagmi/chains';
|
|
2
2
|
|
|
3
3
|
// eslint-disable-next-line import/no-namespace
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (
|
|
17
|
-
|
|
4
|
+
const findRpcProvider = (rpcUrls, privateCustomerRpcUrls, name) => {
|
|
5
|
+
const findRpcUrl = privateCustomerRpcUrls === null || privateCustomerRpcUrls === void 0 ? void 0 : privateCustomerRpcUrls.find((rpcUrl) => {
|
|
6
|
+
if (typeof rpcUrl === 'string') {
|
|
7
|
+
return rpcUrl.includes(name);
|
|
8
|
+
}
|
|
9
|
+
else if (typeof rpcUrl.http === 'string') {
|
|
10
|
+
return rpcUrl.http.includes(name);
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
if (typeof findRpcUrl === 'string') {
|
|
17
|
+
rpcUrls[name] = { http: [findRpcUrl] };
|
|
18
|
+
}
|
|
19
|
+
else if (typeof (findRpcUrl === null || findRpcUrl === void 0 ? void 0 : findRpcUrl.http) === 'string') {
|
|
20
|
+
rpcUrls[name] = { http: [findRpcUrl.http] };
|
|
18
21
|
}
|
|
22
|
+
};
|
|
23
|
+
const mapDynamicChainToWagmi = (dynamicChain) => {
|
|
24
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
19
25
|
const rpcUrls = {
|
|
20
26
|
default: {
|
|
21
27
|
http: dynamicChain.rpcUrls,
|
|
22
28
|
},
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (alchemyUrl) {
|
|
26
|
-
rpcUrls.alchemy = { http: [alchemyUrl] };
|
|
27
|
-
}
|
|
28
|
-
const infuraUrl = (_b = dynamicChain.privateCustomerRpcUrls) === null || _b === void 0 ? void 0 : _b.find((url) => url.includes('infura'));
|
|
29
|
-
if (infuraUrl) {
|
|
30
|
-
rpcUrls.infura = { http: [infuraUrl] };
|
|
31
|
-
}
|
|
32
|
-
return {
|
|
33
|
-
blockExplorers: {
|
|
34
|
-
default: {
|
|
35
|
-
name: '',
|
|
36
|
-
url: (_d = (_c = dynamicChain.blockExplorerUrls) === null || _c === void 0 ? void 0 : _c[0]) !== null && _d !== void 0 ? _d : '',
|
|
37
|
-
},
|
|
29
|
+
public: {
|
|
30
|
+
http: dynamicChain.rpcUrls,
|
|
38
31
|
},
|
|
39
|
-
id: dynamicChain.chainId,
|
|
40
|
-
name: (_e = dynamicChain.vanityName) !== null && _e !== void 0 ? _e : dynamicChain.name,
|
|
41
|
-
nativeCurrency: dynamicChain.nativeCurrency,
|
|
42
|
-
network: dynamicChain.name,
|
|
43
|
-
rpcUrls,
|
|
44
32
|
};
|
|
33
|
+
const rpcUrlProviders = ['alchemy', 'infura'];
|
|
34
|
+
rpcUrlProviders.forEach((name) => findRpcProvider(rpcUrls, dynamicChain.privateCustomerRpcUrls, name));
|
|
35
|
+
/**
|
|
36
|
+
* Find the chain in Wagmi that matches the chainId of the dynamic chain.
|
|
37
|
+
*/
|
|
38
|
+
const wagmiChain = ((_a = Object.values(allChains).find((chain) => chain.id === dynamicChain.chainId)) !== null && _a !== void 0 ? _a : {});
|
|
39
|
+
return Object.assign(Object.assign({}, wagmiChain), { blockExplorers: Object.assign(Object.assign({}, wagmiChain === null || wagmiChain === void 0 ? void 0 : wagmiChain.blockExplorers), { default: Object.assign(Object.assign({}, (_b = wagmiChain.blockExplorers) === null || _b === void 0 ? void 0 : _b.default), { name: '', url: (_d = (_c = dynamicChain.blockExplorerUrls) === null || _c === void 0 ? void 0 : _c[0]) !== null && _d !== void 0 ? _d : '' }) }), id: (_e = dynamicChain.chainId) !== null && _e !== void 0 ? _e : wagmiChain.id, name: (_g = (_f = dynamicChain.vanityName) !== null && _f !== void 0 ? _f : dynamicChain.name) !== null && _g !== void 0 ? _g : wagmiChain.name, nativeCurrency: (_h = dynamicChain.nativeCurrency) !== null && _h !== void 0 ? _h : wagmiChain.nativeCurrency, network: (_j = dynamicChain.name) !== null && _j !== void 0 ? _j : wagmiChain.network, rpcUrls: rpcUrls !== null && rpcUrls !== void 0 ? rpcUrls : wagmiChain.rpcUrls });
|
|
45
40
|
};
|
|
46
41
|
|
|
47
42
|
export { mapDynamicChainToWagmi };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { EvmNetwork } from '@dynamic-labs/types';
|
|
2
|
+
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
|
3
|
+
type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
4
|
+
type CustomProviderOptions = {
|
|
5
|
+
/**
|
|
6
|
+
* The URL of the RPC endpoint.
|
|
7
|
+
*/
|
|
8
|
+
http: string;
|
|
9
|
+
/**
|
|
10
|
+
* The priority of this provider.
|
|
11
|
+
*/
|
|
12
|
+
priority?: number;
|
|
13
|
+
/**
|
|
14
|
+
* The timeout in milliseconds for requests to this provider.
|
|
15
|
+
*/
|
|
16
|
+
stallTimeout?: number;
|
|
17
|
+
/**
|
|
18
|
+
* The URL of the websocket endpoint.
|
|
19
|
+
*/
|
|
20
|
+
webSocket?: string;
|
|
21
|
+
};
|
|
22
|
+
export type WagmiEvmNetworks = Omit<PartialBy<EvmNetwork, 'iconUrls' | 'networkId' | 'vanityName'>, 'privateCustomerRpcUrls'> & {
|
|
23
|
+
privateCustomerRpcUrls: (string | CustomProviderOptions)[];
|
|
24
|
+
};
|
|
25
|
+
export {};
|