-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ethers): init sub package for ethers
- Loading branch information
1 parent
6f4c55f
commit 0a1d90f
Showing
20 changed files
with
269 additions
and
16 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
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,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,69 @@ | ||
{ | ||
"name": "@ant-design/web3-ethers", | ||
"version": "0.0.1", | ||
"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" | ||
}, | ||
"files": [ | ||
"dist", | ||
"CHANGELOG.md", | ||
"README.md" | ||
], | ||
"keywords": [ | ||
"ant", | ||
"component", | ||
"components", | ||
"design", | ||
"framework", | ||
"frontend", | ||
"react", | ||
"react-component", | ||
"ui", | ||
"web3", | ||
"ethers", | ||
"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:*", | ||
"debug": "^4.3.4", | ||
"@tanstack/react-query": "^5.28.4" | ||
}, | ||
"devDependencies": { | ||
"@types/debug": "^4.1.12", | ||
"ethers": "^6.11.1", | ||
"father": "^4.3.8", | ||
"typescript": "^5.4.2" | ||
}, | ||
"peerDependencies": { | ||
"ethers": "^6.0.0" | ||
}, | ||
"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,43 @@ | ||
import React from 'react'; | ||
import { Web3ConfigProvider, type Chain, type Locale } from '@ant-design/web3-common'; | ||
|
||
import type { EthersEIP6963Config } from '../interface'; | ||
|
||
export interface AntDesignWeb3ConfigProviderProps { | ||
chainAssets: Chain[]; | ||
// walletFactorys: WalletFactory[]; | ||
locale?: Locale; | ||
ens?: boolean; | ||
balance?: boolean; | ||
eip6963?: EthersEIP6963Config; | ||
} | ||
|
||
export const AntDesignWeb3ConfigProvider: React.FC< | ||
React.PropsWithChildren<AntDesignWeb3ConfigProviderProps> | ||
> = ({ locale, children }) => { | ||
return ( | ||
<Web3ConfigProvider | ||
locale={locale} | ||
// TODO | ||
account={undefined} | ||
chain={undefined} | ||
balance={undefined} | ||
availableChains={[]} | ||
availableWallets={[]} | ||
connect={async () => { | ||
throw new Error('Method not implemented'); | ||
}} | ||
disconnect={async () => { | ||
throw new Error('Method not implemented'); | ||
}} | ||
switchChain={async () => { | ||
throw new Error('Method not implemented'); | ||
}} | ||
getNFTMetadata={async () => { | ||
throw new Error('Method not implemented'); | ||
}} | ||
> | ||
{children} | ||
</Web3ConfigProvider> | ||
); | ||
}; | ||
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,45 @@ | ||
import React from 'react'; | ||
import { Mainnet } from '@ant-design/web3-assets'; | ||
import type { Chain, Locale } from '@ant-design/web3-common'; | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
|
||
import type { EthersEIP6963Config } from '../interface'; | ||
import { AntDesignWeb3ConfigProvider } from './config-provider'; | ||
|
||
export interface EthersWeb3ConfigProviderProps { | ||
// config: Config; | ||
// wallets?: WalletFactory[]; | ||
locale?: Locale; | ||
chains?: Chain[]; | ||
ens?: boolean; | ||
balance?: boolean; | ||
queryClient?: QueryClient; | ||
eip6963?: EthersEIP6963Config; | ||
} | ||
|
||
export const EthersWeb3ConfigProvider: React.FC< | ||
React.PropsWithChildren<EthersWeb3ConfigProviderProps> | ||
> = ({ children, chains = [], ens, balance, locale, eip6963, queryClient }) => { | ||
const chainAssets = [...chains, Mainnet]; | ||
|
||
const mergedQueryClient = React.useMemo(() => { | ||
return queryClient ?? new QueryClient(); | ||
}, [queryClient]); | ||
|
||
return ( | ||
<QueryClientProvider client={mergedQueryClient}> | ||
<AntDesignWeb3ConfigProvider | ||
locale={locale} | ||
chainAssets={chainAssets} | ||
// walletFactorys={wallets} | ||
// availableChains={config.chains} | ||
// availableConnectors={config.connectors} | ||
ens={ens} | ||
balance={balance} | ||
eip6963={eip6963} | ||
> | ||
{children} | ||
</AntDesignWeb3ConfigProvider> | ||
</QueryClientProvider> | ||
); | ||
}; | ||
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 './ethers-provider'; | ||
export * from './wallets'; | ||
export * from './interface'; |
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,19 @@ | ||
import type { | ||
ConnectOptions, | ||
UniversalEIP6963Config, | ||
Wallet, | ||
WalletMetadata, | ||
} from '@ant-design/web3-common'; | ||
import type { Provider } from 'ethers'; | ||
|
||
export type EthersEIP6963Config = boolean | UniversalEIP6963Config; | ||
|
||
export interface EthersWallet extends Wallet { | ||
getEthersProvider?: (connectOptions?: ConnectOptions) => Promise<Provider | null>; | ||
} | ||
|
||
export interface EthersWalletFactory { | ||
create: () => EthersWallet; | ||
} | ||
|
||
export type EthereumWallet = (metadata?: Partial<WalletMetadata>) => EthersWalletFactory; |
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 './metamask'; | ||
export * from './universal-wallet'; |
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,10 @@ | ||
import { metadata_MetaMask } from '@ant-design/web3-assets'; | ||
|
||
import type { EthereumWallet } from '../interface'; | ||
import { UniversalWallet } from './universal-wallet'; | ||
|
||
export const MetaMask: EthereumWallet = (metadata) => | ||
new UniversalWallet({ | ||
...metadata_MetaMask, | ||
...metadata, | ||
}); |
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,10 @@ | ||
import type { WalletMetadata } from '@ant-design/web3-common'; | ||
|
||
import type { EthersWallet, EthersWalletFactory } from '../interface'; | ||
|
||
export class UniversalWallet implements EthersWalletFactory { | ||
constructor(private readonly wallet: WalletMetadata) {} | ||
create = (): EthersWallet => { | ||
throw new Error('Method not implemented.'); | ||
}; | ||
} |
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 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
Oops, something went wrong.