@dynamic-labs/wagmi-connector 1.0.1 → 1.0.3

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,4 +1,29 @@
1
1
 
2
+ ### [1.0.3](https://github.com/dynamic-labs/DynamicAuth/compare/v1.0.2...v1.0.3) (2023-12-28)
3
+
4
+
5
+ ### Features
6
+
7
+ * add default footer to wallet list when tos and pp not enabled ([#4229](https://github.com/dynamic-labs/DynamicAuth/issues/4229)) ([a6d90a7](https://github.com/dynamic-labs/DynamicAuth/commit/a6d90a7276cafeaffcb21c5362837d020fc10215)), closes [#4224](https://github.com/dynamic-labs/DynamicAuth/issues/4224)
8
+ * add starknet support for sopelia ([#4268](https://github.com/dynamic-labs/DynamicAuth/issues/4268)) ([53d4ce4](https://github.com/dynamic-labs/DynamicAuth/commit/53d4ce400070adfb32021b01b9c748b9a7d90577))
9
+ * delay setting user to after pregenerated wallet flow ([#4244](https://github.com/dynamic-labs/DynamicAuth/issues/4244)) ([503d34d](https://github.com/dynamic-labs/DynamicAuth/commit/503d34d9d6f5edd55b009f1f63c049ac6dfb1fb7))
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * coinbase solana signMessage ([#4261](https://github.com/dynamic-labs/DynamicAuth/issues/4261)) ([7e0e69c](https://github.com/dynamic-labs/DynamicAuth/commit/7e0e69c0ad9f9c9778ff9255909dd2314e16fa06))
15
+ * solflare connect ([#4215](https://github.com/dynamic-labs/DynamicAuth/issues/4215)) ([#4219](https://github.com/dynamic-labs/DynamicAuth/issues/4219)) ([df39306](https://github.com/dynamic-labs/DynamicAuth/commit/df393069b9a9859052b2d55db8dfc3399d85f2a9))
16
+
17
+ ### [1.0.2](https://github.com/dynamic-labs/DynamicAuth/compare/v1.0.1...v1.0.2) (2023-12-18)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * prevent duplicated brave wallet connector ([#4209](https://github.com/dynamic-labs/DynamicAuth/issues/4209)) ([31589b9](https://github.com/dynamic-labs/DynamicAuth/commit/31589b92ea067a5e7ca5a5bd9adb881d086d7868))
23
+ * ensure wagmi connects to primary wallet ([#4206](https://github.com/dynamic-labs/DynamicAuth/issues/4206)) ([#4210](https://github.com/dynamic-labs/DynamicAuth/issues/4210)) ([072bb05](https://github.com/dynamic-labs/DynamicAuth/commit/072bb05a5a9fd5b82f5498c20ff74ca966f3ea9f))
24
+ * ensure wallets group view shows multiple options ([#4184](https://github.com/dynamic-labs/DynamicAuth/issues/4184)) ([#4187](https://github.com/dynamic-labs/DynamicAuth/issues/4187)) ([b751f49](https://github.com/dynamic-labs/DynamicAuth/commit/b751f4952ea5a46b536edc999f37ea134348f8ef)), closes [#4186](https://github.com/dynamic-labs/DynamicAuth/issues/4186)
25
+ * enable brave to read the connected network ([#4198](https://github.com/dynamic-labs/DynamicAuth/issues/4198)) ([979e866](https://github.com/dynamic-labs/DynamicAuth/commit/979e86660f13982992cd43b1d9a8218150437e8b))
26
+
2
27
  ### [1.0.1](https://github.com/dynamic-labs/DynamicAuth/compare/v1.0.0...v1.0.1) (2023-12-14)
3
28
 
4
29
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/wagmi-connector",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/dynamic-labs/DynamicAuth.git",
@@ -8,12 +8,12 @@
8
8
  },
9
9
  "peerDependencies": {
10
10
  "react": "^17.0.2 || ^18.0.0",
11
- "viem": "^1.1.0",
11
+ "viem": "^1.19.13",
12
12
  "wagmi": "^1.4.12",
13
- "@dynamic-labs/rpc-providers": "1.0.1",
14
- "@dynamic-labs/sdk-react-core": "1.0.1",
15
- "@dynamic-labs/types": "1.0.1",
16
- "@dynamic-labs/wallet-connector-core": "1.0.1",
13
+ "@dynamic-labs/rpc-providers": "1.0.3",
14
+ "@dynamic-labs/sdk-react-core": "1.0.3",
15
+ "@dynamic-labs/types": "1.0.3",
16
+ "@dynamic-labs/wallet-connector-core": "1.0.3",
17
17
  "eventemitter3": "5.0.1"
18
18
  },
19
19
  "license": "MIT",
@@ -1,4 +1,4 @@
1
- import React, { useRef, useEffect, useMemo } from 'react';
1
+ import React, { useRef, useMemo, useEffect } from 'react';
2
2
  import { configureChains, mainnet, createConfig, WagmiConfig } from 'wagmi';
3
3
  import { publicProvider } from 'wagmi/providers/public';
4
4
  import { useDynamicContext, useUserWallets } from '@dynamic-labs/sdk-react-core';
@@ -7,6 +7,7 @@ import { getConnector } from './getConnector.js';
7
7
  import { getWagmiChainsFromDynamicChains } from './getWagmiChainsFromDynamicChains.js';
8
8
  import { getWagmiProvidersFromDynamicChains } from './getWagmiProvidersFromDynamicChains.js';
9
9
  import { SyncDynamicWagmi } from './SyncDynamicWagmi.js';
10
+ import { findAndOrderEvmWallets } from './utils/findAndOrderEvmWallets/findAndOrderEvmWallets.js';
10
11
 
11
12
  const { publicClient } = configureChains([mainnet], [publicProvider()]);
12
13
  const config = createConfig({
@@ -14,13 +15,15 @@ const config = createConfig({
14
15
  publicClient,
15
16
  });
16
17
  const DynamicWagmiConnector = ({ evmNetworks: customerSuppliedEvmNetworks, children, }) => {
17
- const { networkConfigurations, handleLogOut, sendWagmiSettings } = useDynamicContext();
18
+ const { networkConfigurations, handleLogOut, sendWagmiSettings, primaryWallet, } = useDynamicContext();
18
19
  /**
19
20
  * This will prevent the wagmi Connector from calling handleLogOut when we are the ones calling disconnect
20
21
  * as a result of a handleLogOut call (see SyncDynamicWagmi), but will preserve the existing behavior for customers.
21
22
  */
22
23
  const preventWagmiSyncFromCallingLogout = useRef(false);
23
- const wallets = useUserWallets();
24
+ // Sort places the primary wallet as the first wallet to attempt to connect with
25
+ const wallets = useUserWallets().sort((wallet) => wallet.address === (primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.address) ? -1 : 1);
26
+ const evmWallets = useMemo(() => findAndOrderEvmWallets(primaryWallet, wallets), [primaryWallet, wallets]);
24
27
  useEffect(() => {
25
28
  // only send wagmi settings once, when the first time DynamicWagmiConnector renders
26
29
  sendWagmiSettings({
@@ -38,12 +41,12 @@ const DynamicWagmiConnector = ({ evmNetworks: customerSuppliedEvmNetworks, child
38
41
  const mappedProviders = getWagmiProvidersFromDynamicChains(evmNetworks);
39
42
  return configureChains(mappedChains, mappedProviders);
40
43
  }, [customerSuppliedEvmNetworks, networkConfigurations === null || networkConfigurations === void 0 ? void 0 : networkConfigurations.evm]);
41
- const connector = useMemo(() => getConnector(wallets, (wallet) => new Connector({
44
+ const connector = useMemo(() => getConnector(evmWallets, (wallet) => new Connector({
42
45
  chains,
43
46
  handleLogOut,
44
47
  preventWagmiSyncFromCallingLogout,
45
48
  walletConnector: wallet.connector,
46
- })), [wallets, chains, handleLogOut, preventWagmiSyncFromCallingLogout]);
49
+ })), [evmWallets, chains, handleLogOut, preventWagmiSyncFromCallingLogout]);
47
50
  /**
48
51
  * Updating the wagmi config must be done in a useEffect because
49
52
  * when setting the public client and connectors, wagmi will fire
@@ -0,0 +1,2 @@
1
+ import { Wallet } from '@dynamic-labs/sdk-react-core';
2
+ export declare const findAndOrderEvmWallets: (primaryWallet: Wallet | null, wallets: Wallet[]) => Wallet[];
@@ -0,0 +1,13 @@
1
+ const evmWalletsFilter = (wallet) => wallet.connector.connectedChain === 'EVM';
2
+ const findAndOrderEvmWallets = (primaryWallet, wallets) => {
3
+ const isPrimaryWalletEvm = (primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector.connectedChain) === 'EVM';
4
+ if (isPrimaryWalletEvm) {
5
+ const secondaryEvmWallets = wallets
6
+ .filter(evmWalletsFilter)
7
+ .filter((wallet) => wallet.address !== primaryWallet.address);
8
+ return [primaryWallet, ...secondaryEvmWallets];
9
+ }
10
+ return wallets.filter(evmWalletsFilter);
11
+ };
12
+
13
+ export { findAndOrderEvmWallets };
@@ -0,0 +1 @@
1
+ export { findAndOrderEvmWallets } from './findAndOrderEvmWallets';
@@ -1 +1,2 @@
1
1
  export * from './resolveRpcUrlFromEvmNetworks';
2
+ export * from './findAndOrderEvmWallets';