Skip to content

Commit

Permalink
refactor: remove useless proxyConnectorName (#921)
Browse files Browse the repository at this point in the history
* refactor: remove useless proxyConnectorName

* chore: add changelog

---------

Co-authored-by: tingzhao.ytz <tingzhao.ytz@antgroup.com>
  • Loading branch information
yutingzhao1991 and tingzhao.ytz committed May 31, 2024
1 parent d3034bd commit 6511134
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 13 deletions.
8 changes: 8 additions & 0 deletions .changeset/silly-schools-return.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@ant-design/web3-assets': patch
'@ant-design/web3-common': patch
'@ant-design/web3-wagmi': patch
'@ant-design/web3': patch
---

refactor: remove useless proxyConnectorName
1 change: 0 additions & 1 deletion packages/assets/src/wallets/mobile-wallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ export const metadata_MobileConnect: WalletMetadata = {
universalProtocol: {
link: 'https://walletconnect.com/',
},
proxyConnectorName: 'WalletConnect',
};
6 changes: 0 additions & 6 deletions packages/common/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,6 @@ export type WalletMetadata = {
universalProtocol?: {
link: string;
};

/**
* @desc 代理连接使用的名称
* @descEn The name used for proxy connection
*/
proxyConnectorName?: string;
};

export type Balance = BalanceMetadata & {
Expand Down
2 changes: 1 addition & 1 deletion packages/wagmi/src/wagmi-provider/config-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export const AntDesignWeb3ConfigProvider: React.FC<AntDesignWeb3ConfigProviderPr
connect={async (wallet, options) => {
let connector = await (wallet as WalletUseInWagmiAdapter)?.getWagmiConnector?.(options);
if (!connector && wallet) {
connector = findConnectorByName(wallet?.proxyConnectorName ?? wallet.name);
connector = findConnectorByName(wallet.name);
}
if (!connector) {
throw new Error(`Can not find connector for ${wallet?.name}`);
Expand Down
9 changes: 6 additions & 3 deletions packages/wagmi/src/wallets/wallet-connect.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { metadata_WalletConnect } from '@ant-design/web3-assets';
import type { Wallet, WalletMetadata } from '@ant-design/web3-common';
import type { WalletMetadata } from '@ant-design/web3-common';
import type { Connector } from 'wagmi';

import type { WalletFactory } from '../interface';
import type { WalletFactory, WalletUseInWagmiAdapter } from '../interface';

export type EthereumWalletConnect = (
metadata?: Partial<WalletMetadata> & {
Expand All @@ -14,7 +14,7 @@ export const WalletConnect: EthereumWalletConnect = (metadata) => {
const { useWalletConnectOfficialModal = false, ...rest } = metadata || {};
return {
connectors: ['WalletConnect'],
create: (connectors?: readonly Connector[]): Wallet => {
create: (connectors?: readonly Connector[]): WalletUseInWagmiAdapter => {
let qrCodeUri: string | undefined = undefined;
const getQrCode = async () => {
const provider = await connectors?.[0]?.getProvider();
Expand All @@ -35,6 +35,9 @@ export const WalletConnect: EthereumWalletConnect = (metadata) => {
};
return {
...metadata_WalletConnect,
getWagmiConnector: async () => {
return connectors?.[0];
},
hasWalletReady: async () => {
return true;
},
Expand Down
6 changes: 4 additions & 2 deletions packages/web3/src/ethereum/demos/more-wallets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,17 @@ const App: React.FC = () => {
}}
wallets={[
MetaMask(),
WalletConnect(),
TokenPocket({
group: 'Popular',
}),
MobileWallet({
group: 'Popular',
}),
WalletConnect(),
CoinbaseWallet(),
SafeheronWallet(),
OkxWallet(),
ImToken(),
MobileWallet(),
]}
config={config}
>
Expand Down

0 comments on commit 6511134

Please sign in to comment.