Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: modify APIs from connector #498

Merged
merged 11 commits into from
Jan 17, 2024
6 changes: 6 additions & 0 deletions .changeset/dry-seahorses-jog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@ant-design/web3-common': patch
'@ant-design/web3': patch
---

fix: Modify the content of ConnectButton message
6 changes: 6 additions & 0 deletions .changeset/twenty-lamps-punch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@ant-design/web3-common': patch
'@ant-design/web3': patch
---

docs: Delete Unreferenced APIs from connector
2 changes: 1 addition & 1 deletion packages/common/src/locale/en_US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const localeValues: RequiredLocale = {
connect: 'Connect Wallet',
disconnect: 'Disconnect',
copyAddress: 'Copy Address',
addressCopied: 'Address Copied!',
copied: 'Copied!',
walletAddress: 'Wallet address',
},
ConnectModal: {
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/locale/zh_CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const localeValues: RequiredLocale = {
connect: '连接钱包',
disconnect: '断开连接',
copyAddress: '复制地址',
addressCopied: '地址复制成功!',
copied: '复制成功!',
walletAddress: '钱包地址',
},
ConnectModal: {
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export interface RequiredLocale {
connect: string;
disconnect: string;
copyAddress: string;
addressCopied: string;
copied: string;
walletAddress: string;
};
ConnectModal: {
Expand Down
8 changes: 2 additions & 6 deletions packages/web3/src/connect-button/__tests__/menu.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ describe('ConnectButton', () => {
await vi.waitFor(() => {
expect(readCopyText()).resolves.toBe('0x21CDf0974d53a6e96eF05d7B324a9803735fFd3B');
expect(baseElement.querySelector('.ant-message')).not.toBeNull();
expect(baseElement.querySelector('.ant-message-notice-content')?.textContent).toBe(
'Address Copied!',
);
expect(baseElement.querySelector('.ant-message-notice-content')?.textContent).toBe('Copied!');
});
});

Expand Down Expand Up @@ -158,9 +156,7 @@ describe('ConnectButton', () => {
await vi.waitFor(() => {
expect(readCopyText()).resolves.toBe('0x21CDf0974d53a6e96eF05d7B324a9803735fFd3B');
expect(baseElement.querySelector('.ant-message')).not.toBeNull();
expect(baseElement.querySelector('.ant-message-notice-content')?.textContent).toBe(
'Address Copied!',
);
expect(baseElement.querySelector('.ant-message-notice-content')?.textContent).toBe('Copied!');
expect(menuClickFn).toBeCalledWith('copyAddress');
});
});
Expand Down
8 changes: 3 additions & 5 deletions packages/web3/src/connect-button/__tests__/tooltip.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ describe('ConnectButton', () => {
fireEvent.click(baseElement.querySelector('.anticon-copy')!);
await vi.waitFor(() => {
expect(baseElement.querySelector('.ant-message')).not.toBeNull();
expect(baseElement.querySelector('.ant-message-notice-content')?.textContent).toBe(
'Address Copied!',
);
expect(baseElement.querySelector('.ant-message-notice-content')?.textContent).toBe('Copied!');
expect(readCopyText()).resolves.toBe('0x3ea2cfd153b8d8505097b81c87c11f5d05097c18');
});
});
Expand All @@ -116,7 +114,7 @@ describe('ConnectButton', () => {
await vi.waitFor(() => {
expect(baseElement.querySelector('.ant-message')).not.toBeNull();
expect(baseElement.querySelector('.ant-message-notice-content')?.textContent?.trim()).toBe(
'Address Copied!',
'Copied!',
);
expect(readCopyText()).resolves.toBe('aaaaaabbbbbbcccccc');
});
Expand All @@ -139,7 +137,7 @@ describe('ConnectButton', () => {
await vi.waitFor(() => {
expect(baseElement.querySelector('.ant-message')).not.toBeNull();
expect(baseElement.querySelector('.ant-message-notice-content')?.textContent?.trim()).toBe(
'Address Copied!',
'Copied!',
);
expect(readCopyText()).resolves.toBe('0x3ea2cfd153b8d8505097b81c87c11f5d05097c18');
});
Expand Down
2 changes: 1 addition & 1 deletion packages/web3/src/connect-button/connect-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export const ConnectButton: React.FC<ConnectButtonProps> = (props) => {
setProfileOpen(false);
if (account?.address) {
writeCopyText(account?.address).then(() => {
messageApi.success(intl.messages.addressCopied);
messageApi.success(intl.messages.copied);
});
}
},
Expand Down
2 changes: 1 addition & 1 deletion packages/web3/src/connect-button/profile-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const ProfileModal: React.FC<ProfileModalProps> = ({
<Button
onClick={() => {
writeCopyText(address).then(() => {
messageApi.success(intl.getMessage(intl.messages.addressCopied));
messageApi.success(intl.getMessage(intl.messages.copied));
});
}}
>
Expand Down
4 changes: 2 additions & 2 deletions packages/web3/src/connect-button/tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const ConnectButtonTooltip: React.FC<
title={intl.getMessage(intl.messages.copyAddress)}
onClick={() => {
writeCopyText(String(title)).then(() => {
messageApi.success(intl.getMessage(intl.messages.addressCopied));
messageApi.success(intl.getMessage(intl.messages.copied));
});
}}
/>
Expand All @@ -51,7 +51,7 @@ export const ConnectButtonTooltip: React.FC<
title={intl.getMessage(intl.messages.copyAddress)}
onClick={() => {
writeCopyText(String(title)).then(() => {
messageApi.success(intl.getMessage(intl.messages.addressCopied));
messageApi.success(intl.getMessage(intl.messages.copied));
});
}}
/>
Expand Down
4 changes: 2 additions & 2 deletions packages/web3/src/connector/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ The properties of the `children` component of `Connector` are inherited and util
| onConnectClick | Connection event | `() => void;` | - | - |
| onDisconnectClick | Disconnection event | `() => void;` | - | - |
| onSwitchChain | Network switch event | `(chain: Chain) => Promise<viod>` | - | - |
| connected | Is Connected | `boolean` | - | - |
| chains | List of networks currently connected | `ChainSelectItem[]` | - | - |
| balance | Balance of the currently connected account | `Balance[]` \| `Balance` | - | - |
| availableChains | Available chains | `Chain[]` | - | - |
Copy link
Collaborator

@thinkasany thinkasany Jan 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这边的翻译倒是可以问一下 @yutingzhao1991 ,帮忙顺便统一一下文档的英文描述,出现两种了。
是不是应该 换成 List of available chains 好一点

image

image

image

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

差不多,就保持统一好了。

| chain | Current chain | [Chain](/components/types#chain) | - | |
4 changes: 2 additions & 2 deletions packages/web3/src/connector/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ order: 0
| onConnectClick | 连接事件 | `() => void;` | - | - |
| onDisconnectClick | 断开连接事件 | `() => void;` | - | - |
| onSwitchChain | 切换网络事件 | `(chain: Chain) => Promise<viod>` | - | - |
| connected | 是否已连接 | `boolean` | - | - |
| chains | 当前连接的网络列表 | `ChainSelectItem[]` | - | - |
| balance | 当前连接的账户余额 | `Balance[]` \| `Balance` | - | - |
| availableChains | 可以连接的链列表 | `Chain[]` | - | - |
| chain | 当前连接的链 | [Chain](/components/types#chain) | - | |
Loading