@ant-design/web3-wagmi 2.7.2 → 2.7.4

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,21 @@
1
1
  # @ant-design/web3-wagmi
2
2
 
3
+ ## 2.7.4
4
+
5
+ ### Patch Changes
6
+
7
+ - efbd948: fix(web3-wagmi): Correct spelling of "Factories"
8
+ - Updated dependencies [9bb1ea1]
9
+ - @ant-design/web3-common@1.13.0
10
+ - @ant-design/web3-assets@1.10.2
11
+
12
+ ## 2.7.3
13
+
14
+ ### Patch Changes
15
+
16
+ - 615d403: fix(web3-wagmi): Ensure AntDesignWeb3ConfigProvider component renders correctly when Wagmi config ssr is true
17
+ - 8760a03: feat(web3-wagmi): Add 'initialState' and 'reconnectOnMount' props to WagmiWeb3ConfigProviderProps
18
+
3
19
  ## 2.7.2
4
20
 
5
21
  ### Patch Changes
@@ -1,17 +1,15 @@
1
1
  import React from 'react';
2
2
  import { type Chain, type Locale } from '@ant-design/web3-common';
3
- import type { Chain as WagmiChain } from 'viem';
4
- import { type Connector as WagmiConnector } from 'wagmi';
3
+ import type { Config as WagmiConfig } from 'wagmi';
5
4
  import type { EIP6963Config, WalletFactory } from '../interface';
6
5
  export interface AntDesignWeb3ConfigProviderProps {
7
6
  chainAssets: Chain[];
8
- walletFactorys: WalletFactory[];
7
+ walletFactories: WalletFactory[];
9
8
  locale?: Locale;
10
9
  children?: React.ReactNode;
11
10
  ens?: boolean;
12
11
  balance?: boolean;
13
12
  eip6963?: EIP6963Config;
14
- readonly availableChains: readonly WagmiChain[];
15
- readonly availableConnectors: readonly WagmiConnector[];
13
+ wagimConfig: WagmiConfig;
16
14
  }
17
15
  export declare const AntDesignWeb3ConfigProvider: React.FC<AntDesignWeb3ConfigProviderProps>;
@@ -10,13 +10,12 @@ export const AntDesignWeb3ConfigProvider = props => {
10
10
  const {
11
11
  children,
12
12
  chainAssets,
13
- walletFactorys,
14
- availableChains,
15
- availableConnectors,
13
+ walletFactories,
16
14
  ens = true,
17
15
  balance,
18
16
  locale,
19
- eip6963
17
+ eip6963,
18
+ wagimConfig
20
19
  } = props;
21
20
  const {
22
21
  address,
@@ -51,26 +50,26 @@ export const AntDesignWeb3ConfigProvider = props => {
51
50
  avatar: ensAvatar ?? undefined
52
51
  } : undefined;
53
52
  const findConnectorByName = name => {
54
- const commonConnector = availableConnectors.find(item => item.name === name && !isEIP6963Connector(item));
53
+ const commonConnector = wagimConfig.connectors.find(item => item.name === name && !isEIP6963Connector(item));
55
54
  if (!eip6963) {
56
55
  return commonConnector;
57
56
  }
58
- const eip6963Connector = availableConnectors.find(item => item.name === name && isEIP6963Connector(item));
57
+ const eip6963Connector = wagimConfig.connectors.find(item => item.name === name && isEIP6963Connector(item));
59
58
  return eip6963Connector || commonConnector;
60
59
  };
61
60
  const wallets = React.useMemo(() => {
62
61
  const autoAddEIP6963Wallets = [];
63
- availableConnectors.forEach(connector => {
62
+ wagimConfig.connectors.forEach(connector => {
64
63
  if (isEIP6963Connector(connector)) {
65
64
  // check is need auto add eip6963 wallet
66
- if (typeof eip6963 === 'object' && eip6963?.autoAddInjectedWallets && !walletFactorys.find(item => item.connectors.includes(connector.name))) {
65
+ if (typeof eip6963 === 'object' && eip6963?.autoAddInjectedWallets && !walletFactories.find(item => item.connectors.includes(connector.name))) {
67
66
  // not config wallet and find the wallet in connectors, auto add it
68
67
  autoAddEIP6963Wallets.push(EIP6963Wallet().create([connector]));
69
68
  }
70
69
  // Do not need check eip6963 wallet
71
70
  return;
72
71
  }
73
- const walletFactory = walletFactorys.find(factory => factory.connectors.includes(connector.name));
72
+ const walletFactory = walletFactories.find(factory => factory.connectors.includes(connector.name));
74
73
  if (!walletFactory?.create) {
75
74
  // check user wallets config and console.error for alert
76
75
  console.error(`Can not find wallet factory for ${connector.name}, you should config it in WagmiWeb3ConfigProvider 'wallets'.`);
@@ -78,7 +77,7 @@ export const AntDesignWeb3ConfigProvider = props => {
78
77
  });
79
78
 
80
79
  // Generate Wallet for @ant-design/web3
81
- const supportWallets = walletFactorys.map(factory => {
80
+ const supportWallets = walletFactories.map(factory => {
82
81
  const connectors = factory.connectors.map(findConnectorByName).filter(item => !!item);
83
82
  if (connectors.length === 0 && !eip6963) {
84
83
  // Not config connector for this wallet factory and not use eip6963, ignore it.
@@ -88,9 +87,9 @@ export const AntDesignWeb3ConfigProvider = props => {
88
87
  return factory.create(connectors);
89
88
  }).filter(item => item !== null);
90
89
  return [...supportWallets, ...autoAddEIP6963Wallets];
91
- }, [availableConnectors, walletFactorys, eip6963]);
90
+ }, [wagimConfig.connectors, walletFactories, eip6963]);
92
91
  const chainList = React.useMemo(() => {
93
- return availableChains.map(item => {
92
+ return wagimConfig.chains.map(item => {
94
93
  const c = chainAssets?.find(asset => {
95
94
  return asset.id === item.id;
96
95
  });
@@ -104,9 +103,9 @@ export const AntDesignWeb3ConfigProvider = props => {
104
103
  console.error(`Can not find chain ${item.id}, you should config it in WagmiWeb3ConfigProvider 'chains'.`);
105
104
  return null;
106
105
  }).filter(item => item !== null);
107
- }, [availableChains, chainAssets]);
108
- const chainId = chain?.id || availableChains?.[0]?.id;
109
- const chainName = chain?.name || availableChains?.[0]?.name;
106
+ }, [wagimConfig.chains, chainAssets]);
107
+ const chainId = chain?.id || wagimConfig.chains?.[0]?.id;
108
+ const chainName = chain?.name || wagimConfig.chains?.[0]?.name;
110
109
  const [currentChain, setCurrentChain] = React.useState(undefined);
111
110
  React.useEffect(() => {
112
111
  setCurrentChain(prevChain => {
@@ -120,7 +119,7 @@ export const AntDesignWeb3ConfigProvider = props => {
120
119
  }
121
120
  return newChain || prevChain;
122
121
  });
123
- }, [chainAssets, availableChains, chainId, chainName]);
122
+ }, [chainAssets, wagimConfig.chains, chainId, chainName]);
124
123
  const currency = currentChain?.nativeCurrency;
125
124
  const getNFTMetadataFunc = React.useCallback(async ({
126
125
  address: contractAddress,
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import type { Chain, Locale } from '@ant-design/web3-common';
3
3
  import { QueryClient } from '@tanstack/react-query';
4
- import type { Config } from 'wagmi';
4
+ import type { Config, State } from 'wagmi';
5
5
  import type { EIP6963Config, WalletFactory } from '../interface';
6
6
  export type WagmiWeb3ConfigProviderProps = {
7
7
  config: Config;
@@ -12,5 +12,7 @@ export type WagmiWeb3ConfigProviderProps = {
12
12
  queryClient?: QueryClient;
13
13
  balance?: boolean;
14
14
  eip6963?: EIP6963Config;
15
+ initialState?: State;
16
+ reconnectOnMount?: boolean;
15
17
  };
16
- export declare function WagmiWeb3ConfigProvider({ children, wallets, chains, ens, locale, balance, config, queryClient, eip6963, ...restProps }: React.PropsWithChildren<WagmiWeb3ConfigProviderProps>): React.ReactElement;
18
+ export declare function WagmiWeb3ConfigProvider({ children, config, locale, wallets, chains, ens, queryClient, balance, eip6963, ...restProps }: React.PropsWithChildren<WagmiWeb3ConfigProviderProps>): React.ReactElement;
@@ -7,13 +7,13 @@ import { AntDesignWeb3ConfigProvider } from "./config-provider";
7
7
  import { jsx as _jsx } from "react/jsx-runtime";
8
8
  export function WagmiWeb3ConfigProvider({
9
9
  children,
10
+ config,
11
+ locale,
10
12
  wallets = [],
11
13
  chains = [],
12
14
  ens,
13
- locale,
14
- balance,
15
- config,
16
15
  queryClient,
16
+ balance,
17
17
  eip6963,
18
18
  ...restProps
19
19
  }) {
@@ -29,12 +29,11 @@ export function WagmiWeb3ConfigProvider({
29
29
  children: /*#__PURE__*/_jsx(AntDesignWeb3ConfigProvider, {
30
30
  locale: locale,
31
31
  chainAssets: chainAssets,
32
- walletFactorys: wallets,
33
- availableChains: config.chains,
34
- availableConnectors: config.connectors,
32
+ walletFactories: wallets,
35
33
  ens: ens,
36
34
  balance: balance,
37
35
  eip6963: eip6963,
36
+ wagimConfig: config,
38
37
  children: children
39
38
  })
40
39
  })
@@ -1,17 +1,15 @@
1
1
  import React from 'react';
2
2
  import { type Chain, type Locale } from '@ant-design/web3-common';
3
- import type { Chain as WagmiChain } from 'viem';
4
- import { type Connector as WagmiConnector } from 'wagmi';
3
+ import type { Config as WagmiConfig } from 'wagmi';
5
4
  import type { EIP6963Config, WalletFactory } from '../interface';
6
5
  export interface AntDesignWeb3ConfigProviderProps {
7
6
  chainAssets: Chain[];
8
- walletFactorys: WalletFactory[];
7
+ walletFactories: WalletFactory[];
9
8
  locale?: Locale;
10
9
  children?: React.ReactNode;
11
10
  ens?: boolean;
12
11
  balance?: boolean;
13
12
  eip6963?: EIP6963Config;
14
- readonly availableChains: readonly WagmiChain[];
15
- readonly availableConnectors: readonly WagmiConnector[];
13
+ wagimConfig: WagmiConfig;
16
14
  }
17
15
  export declare const AntDesignWeb3ConfigProvider: React.FC<AntDesignWeb3ConfigProviderProps>;
@@ -17,13 +17,12 @@ const AntDesignWeb3ConfigProvider = props => {
17
17
  const {
18
18
  children,
19
19
  chainAssets,
20
- walletFactorys,
21
- availableChains,
22
- availableConnectors,
20
+ walletFactories,
23
21
  ens = true,
24
22
  balance,
25
23
  locale,
26
- eip6963
24
+ eip6963,
25
+ wagimConfig
27
26
  } = props;
28
27
  const {
29
28
  address,
@@ -58,26 +57,26 @@ const AntDesignWeb3ConfigProvider = props => {
58
57
  avatar: ensAvatar ?? undefined
59
58
  } : undefined;
60
59
  const findConnectorByName = name => {
61
- const commonConnector = availableConnectors.find(item => item.name === name && !(0, _utils.isEIP6963Connector)(item));
60
+ const commonConnector = wagimConfig.connectors.find(item => item.name === name && !(0, _utils.isEIP6963Connector)(item));
62
61
  if (!eip6963) {
63
62
  return commonConnector;
64
63
  }
65
- const eip6963Connector = availableConnectors.find(item => item.name === name && (0, _utils.isEIP6963Connector)(item));
64
+ const eip6963Connector = wagimConfig.connectors.find(item => item.name === name && (0, _utils.isEIP6963Connector)(item));
66
65
  return eip6963Connector || commonConnector;
67
66
  };
68
67
  const wallets = _react.default.useMemo(() => {
69
68
  const autoAddEIP6963Wallets = [];
70
- availableConnectors.forEach(connector => {
69
+ wagimConfig.connectors.forEach(connector => {
71
70
  if ((0, _utils.isEIP6963Connector)(connector)) {
72
71
  // check is need auto add eip6963 wallet
73
- if (typeof eip6963 === 'object' && eip6963?.autoAddInjectedWallets && !walletFactorys.find(item => item.connectors.includes(connector.name))) {
72
+ if (typeof eip6963 === 'object' && eip6963?.autoAddInjectedWallets && !walletFactories.find(item => item.connectors.includes(connector.name))) {
74
73
  // not config wallet and find the wallet in connectors, auto add it
75
74
  autoAddEIP6963Wallets.push((0, _eip.EIP6963Wallet)().create([connector]));
76
75
  }
77
76
  // Do not need check eip6963 wallet
78
77
  return;
79
78
  }
80
- const walletFactory = walletFactorys.find(factory => factory.connectors.includes(connector.name));
79
+ const walletFactory = walletFactories.find(factory => factory.connectors.includes(connector.name));
81
80
  if (!walletFactory?.create) {
82
81
  // check user wallets config and console.error for alert
83
82
  console.error(`Can not find wallet factory for ${connector.name}, you should config it in WagmiWeb3ConfigProvider 'wallets'.`);
@@ -85,7 +84,7 @@ const AntDesignWeb3ConfigProvider = props => {
85
84
  });
86
85
 
87
86
  // Generate Wallet for @ant-design/web3
88
- const supportWallets = walletFactorys.map(factory => {
87
+ const supportWallets = walletFactories.map(factory => {
89
88
  const connectors = factory.connectors.map(findConnectorByName).filter(item => !!item);
90
89
  if (connectors.length === 0 && !eip6963) {
91
90
  // Not config connector for this wallet factory and not use eip6963, ignore it.
@@ -95,9 +94,9 @@ const AntDesignWeb3ConfigProvider = props => {
95
94
  return factory.create(connectors);
96
95
  }).filter(item => item !== null);
97
96
  return [...supportWallets, ...autoAddEIP6963Wallets];
98
- }, [availableConnectors, walletFactorys, eip6963]);
97
+ }, [wagimConfig.connectors, walletFactories, eip6963]);
99
98
  const chainList = _react.default.useMemo(() => {
100
- return availableChains.map(item => {
99
+ return wagimConfig.chains.map(item => {
101
100
  const c = chainAssets?.find(asset => {
102
101
  return asset.id === item.id;
103
102
  });
@@ -111,9 +110,9 @@ const AntDesignWeb3ConfigProvider = props => {
111
110
  console.error(`Can not find chain ${item.id}, you should config it in WagmiWeb3ConfigProvider 'chains'.`);
112
111
  return null;
113
112
  }).filter(item => item !== null);
114
- }, [availableChains, chainAssets]);
115
- const chainId = chain?.id || availableChains?.[0]?.id;
116
- const chainName = chain?.name || availableChains?.[0]?.name;
113
+ }, [wagimConfig.chains, chainAssets]);
114
+ const chainId = chain?.id || wagimConfig.chains?.[0]?.id;
115
+ const chainName = chain?.name || wagimConfig.chains?.[0]?.name;
117
116
  const [currentChain, setCurrentChain] = _react.default.useState(undefined);
118
117
  _react.default.useEffect(() => {
119
118
  setCurrentChain(prevChain => {
@@ -127,7 +126,7 @@ const AntDesignWeb3ConfigProvider = props => {
127
126
  }
128
127
  return newChain || prevChain;
129
128
  });
130
- }, [chainAssets, availableChains, chainId, chainName]);
129
+ }, [chainAssets, wagimConfig.chains, chainId, chainName]);
131
130
  const currency = currentChain?.nativeCurrency;
132
131
  const getNFTMetadataFunc = _react.default.useCallback(async ({
133
132
  address: contractAddress,
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import type { Chain, Locale } from '@ant-design/web3-common';
3
3
  import { QueryClient } from '@tanstack/react-query';
4
- import type { Config } from 'wagmi';
4
+ import type { Config, State } from 'wagmi';
5
5
  import type { EIP6963Config, WalletFactory } from '../interface';
6
6
  export type WagmiWeb3ConfigProviderProps = {
7
7
  config: Config;
@@ -12,5 +12,7 @@ export type WagmiWeb3ConfigProviderProps = {
12
12
  queryClient?: QueryClient;
13
13
  balance?: boolean;
14
14
  eip6963?: EIP6963Config;
15
+ initialState?: State;
16
+ reconnectOnMount?: boolean;
15
17
  };
16
- export declare function WagmiWeb3ConfigProvider({ children, wallets, chains, ens, locale, balance, config, queryClient, eip6963, ...restProps }: React.PropsWithChildren<WagmiWeb3ConfigProviderProps>): React.ReactElement;
18
+ export declare function WagmiWeb3ConfigProvider({ children, config, locale, wallets, chains, ens, queryClient, balance, eip6963, ...restProps }: React.PropsWithChildren<WagmiWeb3ConfigProviderProps>): React.ReactElement;
@@ -15,13 +15,13 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
15
15
 
16
16
  function WagmiWeb3ConfigProvider({
17
17
  children,
18
+ config,
19
+ locale,
18
20
  wallets = [],
19
21
  chains = [],
20
22
  ens,
21
- locale,
22
- balance,
23
- config,
24
23
  queryClient,
24
+ balance,
25
25
  eip6963,
26
26
  ...restProps
27
27
  }) {
@@ -37,12 +37,11 @@ function WagmiWeb3ConfigProvider({
37
37
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_configProvider.AntDesignWeb3ConfigProvider, {
38
38
  locale: locale,
39
39
  chainAssets: chainAssets,
40
- walletFactorys: wallets,
41
- availableChains: config.chains,
42
- availableConnectors: config.connectors,
40
+ walletFactories: wallets,
43
41
  ens: ens,
44
42
  balance: balance,
45
43
  eip6963: eip6963,
44
+ wagimConfig: config,
46
45
  children: children
47
46
  })
48
47
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ant-design/web3-wagmi",
3
- "version": "2.7.2",
3
+ "version": "2.7.4",
4
4
  "type": "module",
5
5
  "main": "dist/esm/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -38,8 +38,8 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "debug": "^4.3.5",
41
- "@ant-design/web3-assets": "1.10.1",
42
- "@ant-design/web3-common": "1.12.1"
41
+ "@ant-design/web3-assets": "1.10.2",
42
+ "@ant-design/web3-common": "1.13.0"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@types/debug": "^4.1.12",