@ant-design/web3-wagmi 2.8.0 → 2.9.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 CHANGED
@@ -1,5 +1,25 @@
1
1
  # @ant-design/web3-wagmi
2
2
 
3
+ ## 2.9.1
4
+
5
+ ### Patch Changes
6
+
7
+ - @ant-design/web3-assets@1.11.2
8
+
9
+ ## 2.9.0
10
+
11
+ ### Minor Changes
12
+
13
+ - c32f8e2: feat: support useWalletConnectOfficialModal for wagmi provider and add customQrCodePanel for wallet
14
+ - 613b265: feat: add addresses when multi address connected in onConnected
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies [c32f8e2]
19
+ - Updated dependencies [613b265]
20
+ - @ant-design/web3-common@1.14.0
21
+ - @ant-design/web3-assets@1.11.1
22
+
3
23
  ## 2.8.0
4
24
 
5
25
  ### Minor Changes
@@ -5,10 +5,13 @@ export interface WalletUseInWagmiAdapter extends Wallet {
5
5
  getWagmiConnector?: (options?: ConnectOptions) => Promise<Connector | undefined>;
6
6
  }
7
7
  export type EthereumWallet = (metadata?: Partial<WalletMetadata>) => WalletFactory;
8
+ export interface CreateWalletOptions {
9
+ useWalletConnectOfficialModal?: boolean;
10
+ }
8
11
  export interface WalletFactory {
9
12
  name?: string;
10
13
  connectors: Connector['name'][];
11
- create: (connector?: readonly Connector[]) => WalletUseInWagmiAdapter;
14
+ create: (connector?: readonly Connector[], options?: CreateWalletOptions) => WalletUseInWagmiAdapter;
12
15
  createWagmiConnector?: () => CreateConnectorFn;
13
16
  }
14
17
  export type EIP6963Config = boolean | UniversalEIP6963Config;
@@ -11,5 +11,6 @@ export interface AntDesignWeb3ConfigProviderProps {
11
11
  balance?: boolean;
12
12
  eip6963?: EIP6963Config;
13
13
  wagimConfig: WagmiConfig;
14
+ useWalletConnectOfficialModal?: boolean;
14
15
  }
15
16
  export declare const AntDesignWeb3ConfigProvider: React.FC<AntDesignWeb3ConfigProviderProps>;
@@ -15,7 +15,8 @@ export const AntDesignWeb3ConfigProvider = props => {
15
15
  balance,
16
16
  locale,
17
17
  eip6963,
18
- wagimConfig
18
+ wagimConfig,
19
+ useWalletConnectOfficialModal
19
20
  } = props;
20
21
  const {
21
22
  address,
@@ -68,7 +69,9 @@ export const AntDesignWeb3ConfigProvider = props => {
68
69
  // check is need auto add eip6963 wallet
69
70
  if (typeof eip6963 === 'object' && eip6963?.autoAddInjectedWallets && !walletFactories.find(item => item.connectors.some(aName => isConnectorNameMatch(aName, connector.name)))) {
70
71
  // not config wallet and find the wallet in connectors, auto add it
71
- autoAddEIP6963Wallets.push(EIP6963Wallet().create([connector]));
72
+ autoAddEIP6963Wallets.push(EIP6963Wallet().create([connector], {
73
+ useWalletConnectOfficialModal
74
+ }));
72
75
  }
73
76
  // Do not need check eip6963 wallet
74
77
  return;
@@ -88,7 +91,9 @@ export const AntDesignWeb3ConfigProvider = props => {
88
91
  console.error(`Can not find connector for ${factory.connectors.join(',')}, ignore the wallet. Please config connectors or add eip6963 config in WagmiWeb3ConfigProvider.`);
89
92
  return null;
90
93
  }
91
- return factory.create(connectors);
94
+ return factory.create(connectors, {
95
+ useWalletConnectOfficialModal
96
+ });
92
97
  }).filter(item => item !== null);
93
98
  return [...supportWallets, ...autoAddEIP6963Wallets];
94
99
  }, [wagimConfig.connectors, walletFactories, eip6963]);
@@ -157,7 +162,8 @@ export const AntDesignWeb3ConfigProvider = props => {
157
162
  chainId: currentChain?.id
158
163
  });
159
164
  return {
160
- address: accounts?.[0]
165
+ address: accounts?.[0],
166
+ addresses: accounts
161
167
  };
162
168
  },
163
169
  disconnect: async () => {
@@ -89,6 +89,7 @@ export function WagmiWeb3ConfigProvider({
89
89
  balance: balance,
90
90
  eip6963: eip6963,
91
91
  wagimConfig: wagmiConfig,
92
+ useWalletConnectOfficialModal: typeof walletConnect === 'object' && walletConnect?.useWalletConnectOfficialModal,
92
93
  children: children
93
94
  })
94
95
  })
@@ -1,11 +1,11 @@
1
1
  import type { WalletMetadata } from '@ant-design/web3-common';
2
2
  import type { Connector, CreateConnectorFn } from 'wagmi';
3
- import type { WalletFactory, WalletUseInWagmiAdapter } from '../interface';
3
+ import type { CreateWalletOptions, WalletFactory, WalletUseInWagmiAdapter } from '../interface';
4
4
  export declare class UniversalWallet implements WalletFactory {
5
5
  private wallet;
6
6
  name?: string;
7
7
  createWagmiConnector?: () => CreateConnectorFn;
8
8
  connectors: string[];
9
9
  constructor(wallet: WalletMetadata, createWagmiConnector?: () => CreateConnectorFn);
10
- create: (connectors?: readonly Connector[]) => WalletUseInWagmiAdapter;
10
+ create: (connectors?: readonly Connector[], options?: CreateWalletOptions) => WalletUseInWagmiAdapter;
11
11
  }
@@ -16,7 +16,7 @@ export class UniversalWallet {
16
16
  this.connectors.push('WalletConnect');
17
17
  }
18
18
  }
19
- create = connectors => {
19
+ create = (connectors, options) => {
20
20
  const walletConnector = connectors?.find(item => item.name === 'WalletConnect');
21
21
  const injectedConnector = connectors?.find(item => item.name === this.wallet.name);
22
22
  let qrCodeUri = undefined;
@@ -43,8 +43,8 @@ export class UniversalWallet {
43
43
  };
44
44
  return {
45
45
  ...this.wallet,
46
- getWagmiConnector: async options => {
47
- if (options?.connectType === 'qrCode') {
46
+ getWagmiConnector: async connectOptions => {
47
+ if (connectOptions?.connectType === 'qrCode') {
48
48
  return walletConnector;
49
49
  }
50
50
  if (await hasExtensionInstalled()) {
@@ -59,6 +59,7 @@ export class UniversalWallet {
59
59
  const installed = await hasExtensionInstalled();
60
60
  return !!(installed || walletConnector);
61
61
  },
62
+ customQrCodePanel: options?.useWalletConnectOfficialModal,
62
63
  getQrCode: walletConnector ? getQrCode : undefined
63
64
  };
64
65
  };
@@ -6,7 +6,7 @@ export const WalletConnect = metadata => {
6
6
  } = metadata || {};
7
7
  return {
8
8
  connectors: ['WalletConnect'],
9
- create: connectors => {
9
+ create: (connectors, options = {}) => {
10
10
  let qrCodeUri = undefined;
11
11
  const getQrCode = async () => {
12
12
  const provider = await connectors?.[0]?.getProvider();
@@ -33,7 +33,8 @@ export const WalletConnect = metadata => {
33
33
  hasWalletReady: async () => {
34
34
  return true;
35
35
  },
36
- getQrCode: useWalletConnectOfficialModal ? undefined : getQrCode,
36
+ getQrCode: getQrCode,
37
+ customQrCodePanel: useWalletConnectOfficialModal || options.useWalletConnectOfficialModal,
37
38
  ...rest
38
39
  };
39
40
  }
@@ -5,10 +5,13 @@ export interface WalletUseInWagmiAdapter extends Wallet {
5
5
  getWagmiConnector?: (options?: ConnectOptions) => Promise<Connector | undefined>;
6
6
  }
7
7
  export type EthereumWallet = (metadata?: Partial<WalletMetadata>) => WalletFactory;
8
+ export interface CreateWalletOptions {
9
+ useWalletConnectOfficialModal?: boolean;
10
+ }
8
11
  export interface WalletFactory {
9
12
  name?: string;
10
13
  connectors: Connector['name'][];
11
- create: (connector?: readonly Connector[]) => WalletUseInWagmiAdapter;
14
+ create: (connector?: readonly Connector[], options?: CreateWalletOptions) => WalletUseInWagmiAdapter;
12
15
  createWagmiConnector?: () => CreateConnectorFn;
13
16
  }
14
17
  export type EIP6963Config = boolean | UniversalEIP6963Config;
@@ -11,5 +11,6 @@ export interface AntDesignWeb3ConfigProviderProps {
11
11
  balance?: boolean;
12
12
  eip6963?: EIP6963Config;
13
13
  wagimConfig: WagmiConfig;
14
+ useWalletConnectOfficialModal?: boolean;
14
15
  }
15
16
  export declare const AntDesignWeb3ConfigProvider: React.FC<AntDesignWeb3ConfigProviderProps>;
@@ -22,7 +22,8 @@ const AntDesignWeb3ConfigProvider = props => {
22
22
  balance,
23
23
  locale,
24
24
  eip6963,
25
- wagimConfig
25
+ wagimConfig,
26
+ useWalletConnectOfficialModal
26
27
  } = props;
27
28
  const {
28
29
  address,
@@ -75,7 +76,9 @@ const AntDesignWeb3ConfigProvider = props => {
75
76
  // check is need auto add eip6963 wallet
76
77
  if (typeof eip6963 === 'object' && eip6963?.autoAddInjectedWallets && !walletFactories.find(item => item.connectors.some(aName => isConnectorNameMatch(aName, connector.name)))) {
77
78
  // not config wallet and find the wallet in connectors, auto add it
78
- autoAddEIP6963Wallets.push((0, _eip.EIP6963Wallet)().create([connector]));
79
+ autoAddEIP6963Wallets.push((0, _eip.EIP6963Wallet)().create([connector], {
80
+ useWalletConnectOfficialModal
81
+ }));
79
82
  }
80
83
  // Do not need check eip6963 wallet
81
84
  return;
@@ -95,7 +98,9 @@ const AntDesignWeb3ConfigProvider = props => {
95
98
  console.error(`Can not find connector for ${factory.connectors.join(',')}, ignore the wallet. Please config connectors or add eip6963 config in WagmiWeb3ConfigProvider.`);
96
99
  return null;
97
100
  }
98
- return factory.create(connectors);
101
+ return factory.create(connectors, {
102
+ useWalletConnectOfficialModal
103
+ });
99
104
  }).filter(item => item !== null);
100
105
  return [...supportWallets, ...autoAddEIP6963Wallets];
101
106
  }, [wagimConfig.connectors, walletFactories, eip6963]);
@@ -164,7 +169,8 @@ const AntDesignWeb3ConfigProvider = props => {
164
169
  chainId: currentChain?.id
165
170
  });
166
171
  return {
167
- address: accounts?.[0]
172
+ address: accounts?.[0],
173
+ addresses: accounts
168
174
  };
169
175
  },
170
176
  disconnect: async () => {
@@ -97,6 +97,7 @@ function WagmiWeb3ConfigProvider({
97
97
  balance: balance,
98
98
  eip6963: eip6963,
99
99
  wagimConfig: wagmiConfig,
100
+ useWalletConnectOfficialModal: typeof walletConnect === 'object' && walletConnect?.useWalletConnectOfficialModal,
100
101
  children: children
101
102
  })
102
103
  })
@@ -1,11 +1,11 @@
1
1
  import type { WalletMetadata } from '@ant-design/web3-common';
2
2
  import type { Connector, CreateConnectorFn } from 'wagmi';
3
- import type { WalletFactory, WalletUseInWagmiAdapter } from '../interface';
3
+ import type { CreateWalletOptions, WalletFactory, WalletUseInWagmiAdapter } from '../interface';
4
4
  export declare class UniversalWallet implements WalletFactory {
5
5
  private wallet;
6
6
  name?: string;
7
7
  createWagmiConnector?: () => CreateConnectorFn;
8
8
  connectors: string[];
9
9
  constructor(wallet: WalletMetadata, createWagmiConnector?: () => CreateConnectorFn);
10
- create: (connectors?: readonly Connector[]) => WalletUseInWagmiAdapter;
10
+ create: (connectors?: readonly Connector[], options?: CreateWalletOptions) => WalletUseInWagmiAdapter;
11
11
  }
@@ -22,7 +22,7 @@ class UniversalWallet {
22
22
  this.connectors.push('WalletConnect');
23
23
  }
24
24
  }
25
- create = connectors => {
25
+ create = (connectors, options) => {
26
26
  const walletConnector = connectors?.find(item => item.name === 'WalletConnect');
27
27
  const injectedConnector = connectors?.find(item => item.name === this.wallet.name);
28
28
  let qrCodeUri = undefined;
@@ -49,8 +49,8 @@ class UniversalWallet {
49
49
  };
50
50
  return {
51
51
  ...this.wallet,
52
- getWagmiConnector: async options => {
53
- if (options?.connectType === 'qrCode') {
52
+ getWagmiConnector: async connectOptions => {
53
+ if (connectOptions?.connectType === 'qrCode') {
54
54
  return walletConnector;
55
55
  }
56
56
  if (await hasExtensionInstalled()) {
@@ -65,6 +65,7 @@ class UniversalWallet {
65
65
  const installed = await hasExtensionInstalled();
66
66
  return !!(installed || walletConnector);
67
67
  },
68
+ customQrCodePanel: options?.useWalletConnectOfficialModal,
68
69
  getQrCode: walletConnector ? getQrCode : undefined
69
70
  };
70
71
  };
@@ -12,7 +12,7 @@ const WalletConnect = metadata => {
12
12
  } = metadata || {};
13
13
  return {
14
14
  connectors: ['WalletConnect'],
15
- create: connectors => {
15
+ create: (connectors, options = {}) => {
16
16
  let qrCodeUri = undefined;
17
17
  const getQrCode = async () => {
18
18
  const provider = await connectors?.[0]?.getProvider();
@@ -39,7 +39,8 @@ const WalletConnect = metadata => {
39
39
  hasWalletReady: async () => {
40
40
  return true;
41
41
  },
42
- getQrCode: useWalletConnectOfficialModal ? undefined : getQrCode,
42
+ getQrCode: getQrCode,
43
+ customQrCodePanel: useWalletConnectOfficialModal || options.useWalletConnectOfficialModal,
43
44
  ...rest
44
45
  };
45
46
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ant-design/web3-wagmi",
3
- "version": "2.8.0",
3
+ "version": "2.9.1",
4
4
  "type": "module",
5
5
  "main": "dist/esm/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -38,19 +38,19 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "debug": "^4.3.5",
41
- "@ant-design/web3-assets": "1.11.0",
42
- "@ant-design/web3-common": "1.13.0"
41
+ "@ant-design/web3-common": "1.14.0",
42
+ "@ant-design/web3-assets": "1.11.2"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@types/debug": "^4.1.12",
46
46
  "father": "^4.4.4",
47
47
  "typescript": "^5.5.4",
48
- "wagmi": "^2.10.9",
48
+ "wagmi": "^2.12.13",
49
49
  "@tanstack/react-query": "^5.51.11",
50
- "viem": "^2.16.5"
50
+ "viem": "^2.21.3"
51
51
  },
52
52
  "peerDependencies": {
53
- "wagmi": "^2.10.9",
53
+ "wagmi": "^2.12.13",
54
54
  "@tanstack/react-query": "^5.51.11",
55
55
  "viem": ">=2.0.0"
56
56
  },