-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(ethers): split ethers sub pkg with legacy versions v5 (#862)
* refactor(ethers): split ethers sub pkg with legacy versions v5 * chore(example): update ethers examples * fix: ci build issue * fix(test): pkg resolve * fix(ci): test issue * chore(ethers): add changeset * docs(ethereum): split ethersjs doc * fix(ethers): cr comments * chore(ethers): reset code case by cr comment
- Loading branch information
1 parent
3099228
commit 1270c95
Showing
42 changed files
with
335 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@ant-design/web3-ethers": patch | ||
"@ant-design/web3-wagmi": patch | ||
"@ant-design/web3": patch | ||
--- | ||
|
||
chore(ethers): adjusted the compatibility form of the old version of etherjs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@ant-design/web3-ethers-v5": major | ||
--- | ||
|
||
feat(ethers-v5): split and release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,5 @@ | |
"@types/react": "^18.2.78", | ||
"@types/react-dom": "^18.2.25", | ||
"typescript": "^5.4.4" | ||
}, | ||
"version": null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { defineConfig } from 'father'; | ||
|
||
export default defineConfig({ | ||
extends: '../../.fatherrc.base.ts', | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# @ant-design/web3-ethers | ||
|
||
[https://web3.ant.design](https://web3.ant.design) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
{ | ||
"name": "@ant-design/web3-ethers-v5", | ||
"version": "0.1.0", | ||
"type": "module", | ||
"main": "dist/esm/index.js", | ||
"module": "dist/esm/index.js", | ||
"typings": "dist/esm/index.d.ts", | ||
"exports": { | ||
".": { | ||
"import": "./dist/esm/index.js", | ||
"require": "./dist/lib/index.js", | ||
"types": "./dist/esm/index.d.ts" | ||
}, | ||
"./wagmi": { | ||
"import": "./dist/esm/wagmi.js", | ||
"require": "./dist/lib/wagmi.js", | ||
"types": "./dist/esm/wagmi.d.ts" | ||
} | ||
}, | ||
"files": [ | ||
"dist", | ||
"CHANGELOG.md", | ||
"README.md" | ||
], | ||
"keywords": [ | ||
"ant", | ||
"component", | ||
"components", | ||
"design", | ||
"framework", | ||
"frontend", | ||
"react", | ||
"react-component", | ||
"ui", | ||
"web3", | ||
"ethers-v5", | ||
"ethersjs" | ||
], | ||
"homepage": "https://we3.ant.design", | ||
"bugs": { | ||
"url": "https://github.com/ant-design/ant-design-web3/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/ant-design/ant-design-web3" | ||
}, | ||
"scripts": { | ||
"dev": "father dev", | ||
"build": "father build" | ||
}, | ||
"dependencies": { | ||
"@ant-design/web3-assets": "workspace:*", | ||
"@ant-design/web3-common": "workspace:*", | ||
"@ant-design/web3-wagmi": "workspace:*", | ||
"@ant-design/web3-ethers": "workspace:*", | ||
"@tanstack/react-query": "^5.28.4", | ||
"debug": "^4.3.4", | ||
"viem": ">=2.9.25", | ||
"wagmi": "^2.8.3" | ||
}, | ||
"devDependencies": { | ||
"@types/debug": "^4.1.12", | ||
"father": "^4.4.0", | ||
"typescript": "^5.4.4", | ||
"ethers": "^5.7.2" | ||
}, | ||
"peerDependencies": { | ||
"ethers": "^5.7.2" | ||
}, | ||
"publishConfig": { | ||
"registry": "https://registry.npmjs.org", | ||
"access": "public" | ||
}, | ||
"browserslist": [ | ||
"last 2 versions", | ||
"Firefox ESR", | ||
"> 1%", | ||
"ie >= 11" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import type { EIP1193Provider } from 'viem'; | ||
|
||
declare interface Window { | ||
ethereum?: EIP1193Provider; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './use-ethers-provider'; | ||
export * from './use-ethers-signer'; |
6 changes: 3 additions & 3 deletions
6
...src/hooks/use-ethers-provider-v5.test.tsx → ...v5/src/hooks/use-ethers-provider.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...thers/src/hooks/use-ethers-provider-v5.ts → ...thers-v5/src/hooks/use-ethers-provider.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...s/src/hooks/use-ethers-signer-v5.test.tsx → ...s-v5/src/hooks/use-ethers-signer.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../ethers/src/hooks/use-ethers-signer-v5.ts → .../ethers-v5/src/hooks/use-ethers-signer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './provider'; | ||
export * from './wallets'; | ||
export * from './hooks'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from '@ant-design/web3-ethers/provider'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from '@ant-design/web3-ethers/wagmi'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from '@ant-design/web3-ethers/wallets'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"extends": "../../tsconfig.base.json", | ||
"include": ["src", "global.d.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
--- | ||
nav: Components | ||
order: 1 | ||
group: | ||
title: Connect Blockchains | ||
order: 1 | ||
order: 2 | ||
tag: | ||
title: New | ||
color: success | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
--- | ||
nav: Components | ||
order: 3 | ||
group: | ||
title: Connect Blockchains | ||
order: 2 | ||
--- | ||
|
||
# Ethereum (ethersjs) | ||
|
||
Developers who are familiar with `ethers` can install `@ant-design/web3-ethers` to use with the component library, most of which are consistent with the `wagmi` adapter. | ||
|
||
<NormalInstallDependencies packageNames="@ant-design/web3 @ant-design/web3-ethers ethers" save="true"></NormalInstallDependencies> | ||
|
||
### Basic usage | ||
|
||
This example shows basic usage using the `ethers` adapter. We provide two react hooks to obtain `provider` and `signer`, which you can use in components to perform on-chain operations. | ||
|
||
- `useEthersProvider`: Get the `Provider` instance of `ethers`. | ||
- `useEthersSigner`: Get the `Signer` instance of `ethers`. | ||
|
||
<code src="./demos/ethers-basic.tsx"></code> | ||
|
||
### Compatible with ethers legacy versions | ||
|
||
If you are a user of `ethers@5.x`, you can manually install the v5 version of ethers and modify the adapter introduction method. Versions prior to v5 are no longer supported. It is recommended to use after upgrading to the latest version: | ||
|
||
<NormalInstallDependencies packageNames="@ant-design/web3 @ant-design/web3-ethers-v5 ethers@legacy-v5" save="true"></NormalInstallDependencies> | ||
|
||
```tsx | pure | ||
import { EthersWeb3ConfigProvider, useEthersProvider } from '@ant-design/web3-ethers-v5'; // importing the adapter for ethers@5.x | ||
|
||
const Component = () => { | ||
const provider = useEthersProvider(); | ||
// do something with provider | ||
}; | ||
|
||
const App = () => { | ||
return ( | ||
<EthersWeb3ConfigProvider> | ||
<Component /> | ||
</EthersWeb3ConfigProvider> | ||
); | ||
}; | ||
``` | ||
|
||
### EthersWeb3ConfigProviderProps | ||
|
||
| Property | Description | Type | Default | Version | | ||
| --- | --- | --- | --- | --- | | ||
| wallets | Wallets | [WalletFactory](#walletfactory)[] | - | - | | ||
| chains | Chains | [Chain](./types#chain)[] | - | - | | ||
| ens | Whether to display ENS | `boolean` | - | - | | ||
| balance | Whether to display balance | `boolean` | - | - | | ||
| locale | Multilingual settings | [Locale](https://github.com/ant-design/ant-design-web3/blob/main/packages/common/src/locale/en_US.ts) | - | - | | ||
| eip6963 | Whether to use EIP6963 protocol wallet and related configurations | `boolean` \| `EIP6963Config` | `false` | | | ||
| walletConnect | Whether to use the Wallet Connect protocol | `false` \| [WalletConnectOptions](https://wagmi.sh/core/api/connectors/walletConnect#parameters) | `false` | | |
Oops, something went wrong.