Skip to content

Commit

Permalink
feat: add addresses when multi address connected in onConnected (#1131)
Browse files Browse the repository at this point in the history
* feat: add addresses when use onConnected

* chore: add changeset

* Update packages/common/src/types.ts

* fix: review issue

* docs: update doc

---------

Co-authored-by: 愚指导 <[email protected]>
Co-authored-by: tingzhao.ytz <[email protected]>
  • Loading branch information
3 people authored Sep 14, 2024
1 parent 4c21861 commit 613b265
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 8 deletions.
6 changes: 6 additions & 0 deletions .changeset/nine-knives-live.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@ant-design/web3-common': minor
'@ant-design/web3-wagmi': minor
---

feat: add addresses when multi address connected in onConnected
1 change: 1 addition & 0 deletions packages/common/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export interface Account {
address: string;
name?: string;
avatar?: string;
addresses?: readonly [`0x${string}`, ...`0x${string}`[]];
}

export enum ChainIds {
Expand Down
4 changes: 4 additions & 0 deletions packages/wagmi/src/wagmi-provider/__tests__/connect.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ describe('WagmiWeb3ConfigProvider connect', () => {
});

expect(onConnected).toBeCalledWith({
addresses: [
'0x21CDf0974d53a6e96eF05d7B324a9803735fFd3B',
'0x0212f0974d53a6e96eF05d7B324a9803735fFd3B',
],
address: '0x21CDf0974d53a6e96eF05d7B324a9803735fFd3B',
});

Expand Down
1 change: 1 addition & 0 deletions packages/wagmi/src/wagmi-provider/config-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ export const AntDesignWeb3ConfigProvider: React.FC<AntDesignWeb3ConfigProviderPr
});
return {
address: accounts?.[0],
addresses: accounts,
};
}}
disconnect={async () => {
Expand Down
9 changes: 5 additions & 4 deletions packages/web3/src/types/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ This defines the unified types of Ant Design Web3, which may be used in multiple

## Account

| Property | Description | Type | Default | Version |
| -------- | ------------------------------------------ | -------- | ------- | ------- |
| address | Account address | `string` | - | - |
| name | Account name, For example, ENS in Ethereum | `string` | - | - |
| Property | Description | Type | Default | Version |
| --- | --- | --- | --- | --- |
| address | Account address (When multiple addresses are supported by the adapter, this represents the first address (`addresses[0]`)) | `string` | - | - |
| name | Account name, For example, ENS in Ethereum | `string` | - | - |
| addresses | List of wallet addresses authorized by the user (implemented by the adapter, supported in some chains) | `string[]` | - | - |

## ChainIds

Expand Down
9 changes: 5 additions & 4 deletions packages/web3/src/types/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ coverDark: https://mdn.alipayobjects.com/huamei_mutawc/afts/img/A*n4F2RK3AVTsAAA

## Account

| 属性 | 描述 | 类型 | 默认值 | 版本 |
| ------- | -------------------------- | -------- | ------ | ---- |
| address | 账户地址 | `string` | - | - |
| name | 账户名称,比如以太坊的 ENS | `string` | - | - |
| 属性 | 描述 | 类型 | 默认值 | 版本 |
| --------- | ------------------------------------------------------ | ---------- | ------ | ---- |
| address | 账户地址(适配器支持多地址时为 `addresses[0]`| `string` | - | - |
| name | 账户名称,比如以太坊的 ENS | `string` | - | - |
| addresses | 用户授权的钱包地址列表(依赖适配器实现,部分链中支持) | `string[]` | - | - |

## ChainIds

Expand Down

0 comments on commit 613b265

Please sign in to comment.