@dynamic-labs/wagmi-connector 0.16.13-RC.0 → 0.16.14

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,17 @@
1
1
 
2
- ### [0.16.13-RC.0](https://github.com/dynamic-labs/DynamicAuth/compare/v0.16.12...v0.16.13-RC.0) (2023-05-08)
2
+ ### [0.16.14](https://github.com/dynamic-labs/DynamicAuth/compare/v0.16.13...v0.16.14) (2023-05-08)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * **DynamicWagmiConnector:** prevent disconnect when WC is not present… ([#2071](https://github.com/dynamic-labs/DynamicAuth/issues/2071)) ([bb8d023](https://github.com/dynamic-labs/DynamicAuth/commit/bb8d023f097d80c69dcf08282dec3823069e129e)), closes [#2063](https://github.com/dynamic-labs/DynamicAuth/issues/2063) [#2060](https://github.com/dynamic-labs/DynamicAuth/issues/2060)
8
+
9
+ ### [0.16.13](https://github.com/dynamic-labs/DynamicAuth/compare/v0.16.12...v0.16.13) (2023-05-08)
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * **TransactionModal:** ensure alchemy will not fail when estimating for gas ([#2067](https://github.com/dynamic-labs/DynamicAuth/issues/2067)) ([a0aea1b](https://github.com/dynamic-labs/DynamicAuth/commit/a0aea1bbabb9a81968dc4ba59d62e748c267849a))
3
15
 
4
16
  ### [0.16.12](https://github.com/dynamic-labs/DynamicAuth/compare/v0.16.11...v0.16.12) (2023-05-05)
5
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/wagmi-connector",
3
- "version": "0.16.13-RC.0",
3
+ "version": "0.16.14",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/dynamic-labs/DynamicAuth.git",
@@ -11,7 +11,8 @@
11
11
  "react": "^17.0.2 || ^18.0.0",
12
12
  "ethers": "^5.7.2",
13
13
  "wagmi": "~0.10.3",
14
- "@dynamic-labs/sdk-react-core": "0.16.13-RC.0"
14
+ "@dynamic-labs/sdk-react-core": "0.16.14",
15
+ "@dynamic-labs/wallet-connector-core": "0.16.14"
15
16
  },
16
17
  "license": "MIT",
17
18
  "main": "./src/index.cjs",
@@ -1,6 +1,7 @@
1
- import React, { useEffect } from '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
- useEffect(() => {
20
- if (!walletConnector) {
21
- disconnect();
22
- }
23
- else if (connector && clientStatus !== 'connected') {
24
- connect({ connector });
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);
@@ -0,0 +1,2 @@
1
+ export * from './useWalletConnectorEverPresent';
2
+ export * from './useSyncConnectState';
@@ -0,0 +1 @@
1
+ export { useSyncConnectState } from './useSyncConnectState';
@@ -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,25 @@
1
+ import { useEffect } from 'react';
2
+ import { useWalletConnectorEverPresent } from '../useWalletConnectorEverPresent/useWalletConnectorEverPresent.js';
3
+
4
+ const useSyncConnectState = ({ walletConnector, disconnect, clientStatus, connect, connector, }) => {
5
+ const wasWalletConnectEverPresent = useWalletConnectorEverPresent(walletConnector);
6
+ useEffect(() => {
7
+ if (!walletConnector) {
8
+ if (wasWalletConnectEverPresent) {
9
+ disconnect();
10
+ }
11
+ }
12
+ else if (connector && clientStatus !== 'connected') {
13
+ connect({ connector });
14
+ }
15
+ }, [
16
+ clientStatus,
17
+ connect,
18
+ connector,
19
+ disconnect,
20
+ walletConnector,
21
+ wasWalletConnectEverPresent,
22
+ ]);
23
+ };
24
+
25
+ export { useSyncConnectState };
@@ -0,0 +1 @@
1
+ export { useWalletConnectorEverPresent } from './useWalletConnectorEverPresent';
@@ -0,0 +1,2 @@
1
+ import { WalletConnector } from '@dynamic-labs/wallet-connector-core';
2
+ export declare const useWalletConnectorEverPresent: (walletConnector: WalletConnector | null) => boolean;
@@ -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 };