@aptos-labs/wallet-adapter-react 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @aptos-labs/wallet-adapter-react
2
2
 
3
+ ## 2.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 444c708: Fix wallet detection
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [6be2a06]
12
+ - @aptos-labs/wallet-adapter-core@3.9.0
13
+
14
+ ## 2.2.1
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies [4127cfb]
19
+ - @aptos-labs/wallet-adapter-core@3.8.0
20
+
3
21
  ## 2.2.0
4
22
 
5
23
  ### Minor Changes
package/dist/index.js CHANGED
@@ -207,13 +207,18 @@ var AptosWalletAdapterProvider = ({
207
207
  setWallets(updatedWallets);
208
208
  };
209
209
  const handleStandardWalletsAdded = (standardWallet) => {
210
- const updatedWallets = wallets == null ? void 0 : wallets.map((wallet2) => {
211
- if (wallet2.name === standardWallet.name) {
212
- return { ...standardWallet };
213
- }
214
- return wallet2;
215
- });
216
- setWallets(updatedWallets);
210
+ const existingWalletIndex = wallets.findIndex(
211
+ (wallet2) => wallet2.name == standardWallet.name
212
+ );
213
+ if (existingWalletIndex !== -1) {
214
+ setWallets((wallets2) => [
215
+ ...wallets2.slice(0, existingWalletIndex),
216
+ standardWallet,
217
+ ...wallets2.slice(existingWalletIndex + 1)
218
+ ]);
219
+ } else {
220
+ setWallets((wallets2) => [...wallets2, standardWallet]);
221
+ }
217
222
  };
218
223
  (0, import_react2.useEffect)(() => {
219
224
  walletCore.on("connect", handleConnect);
package/dist/index.mjs CHANGED
@@ -180,13 +180,18 @@ var AptosWalletAdapterProvider = ({
180
180
  setWallets(updatedWallets);
181
181
  };
182
182
  const handleStandardWalletsAdded = (standardWallet) => {
183
- const updatedWallets = wallets == null ? void 0 : wallets.map((wallet2) => {
184
- if (wallet2.name === standardWallet.name) {
185
- return { ...standardWallet };
186
- }
187
- return wallet2;
188
- });
189
- setWallets(updatedWallets);
183
+ const existingWalletIndex = wallets.findIndex(
184
+ (wallet2) => wallet2.name == standardWallet.name
185
+ );
186
+ if (existingWalletIndex !== -1) {
187
+ setWallets((wallets2) => [
188
+ ...wallets2.slice(0, existingWalletIndex),
189
+ standardWallet,
190
+ ...wallets2.slice(existingWalletIndex + 1)
191
+ ]);
192
+ } else {
193
+ setWallets((wallets2) => [...wallets2, standardWallet]);
194
+ }
190
195
  };
191
196
  useEffect(() => {
192
197
  walletCore.on("connect", handleConnect);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aptos-labs/wallet-adapter-react",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "description": "Aptos Wallet Adapter React Provider",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -37,7 +37,7 @@
37
37
  "@aptos-labs/wallet-adapter-tsconfig": "0.0.0"
38
38
  },
39
39
  "dependencies": {
40
- "@aptos-labs/wallet-adapter-core": "3.7.0"
40
+ "@aptos-labs/wallet-adapter-core": "3.9.0"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "react": "^18"
@@ -224,13 +224,20 @@ export const AptosWalletAdapterProvider: FC<AptosWalletProviderProps> = ({
224
224
  const handleStandardWalletsAdded = (standardWallet: Wallet) => {
225
225
  // Manage current wallet state by removing optional duplications
226
226
  // as new wallets are coming
227
- const updatedWallets = wallets?.map((wallet) => {
228
- if (wallet.name === standardWallet.name) {
229
- return { ...standardWallet };
230
- }
231
- return wallet;
232
- });
233
- setWallets(updatedWallets);
227
+ const existingWalletIndex = wallets.findIndex(
228
+ (wallet) => wallet.name == standardWallet.name
229
+ );
230
+ if (existingWalletIndex !== -1) {
231
+ // If wallet exists, replace it with the new wallet
232
+ setWallets((wallets) => [
233
+ ...wallets.slice(0, existingWalletIndex),
234
+ standardWallet,
235
+ ...wallets.slice(existingWalletIndex + 1),
236
+ ]);
237
+ } else {
238
+ // If wallet doesn't exist, add it to the array
239
+ setWallets((wallets) => [...wallets, standardWallet]);
240
+ }
234
241
  };
235
242
 
236
243
  useEffect(() => {