-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* docs: add adapter docs * fix: doc link bug --------- Co-authored-by: yutingzhao1991 <[email protected]>
- Loading branch information
1 parent
70ec13f
commit c30480e
Showing
5 changed files
with
132 additions
and
10 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,58 @@ | ||
import React from 'react'; | ||
import { type Account, type Wallet, type Chain, Web3ConfigProvider } from '@ant-design/web3-common'; | ||
import { Connector, ConnectButton } from '@ant-design/web3'; | ||
|
||
export interface YourAdapterProps { | ||
wallets?: Wallet[]; | ||
children?: React.ReactNode; | ||
availableChains?: Chain[]; | ||
} | ||
|
||
export const YourAdapterPropsProvider: React.FC<YourAdapterProps> = (props) => { | ||
const { children, availableChains, wallets } = props; | ||
const [account, setAccount] = React.useState<Account>({ | ||
address: '0xtestaccount', | ||
}); | ||
const [currentChain, setCurrentChain] = React.useState<Chain>(); | ||
|
||
return ( | ||
<Web3ConfigProvider | ||
availableChains={availableChains} | ||
chain={currentChain} | ||
account={account} | ||
availableWallets={wallets} | ||
connect={async (wallet) => { | ||
// 这里可以实现连接钱包的逻辑 | ||
return; | ||
}} | ||
disconnect={async () => { | ||
// 这里可以实现断开连接的逻辑 | ||
return; | ||
}} | ||
switchChain={async (c: Chain) => { | ||
// 这里可以实现切换链的逻辑 | ||
return; | ||
}} | ||
getNFTMetadata={async ({ address: contractAddress, tokenId }) => { | ||
// 这里可以实现获取 NFT 元数据的逻辑 | ||
return { | ||
name: 'NFT', | ||
description: 'NFT description', | ||
image: 'https://avatars.githubusercontent.com/u/1061968', | ||
}; | ||
}} | ||
> | ||
{children} | ||
</Web3ConfigProvider> | ||
); | ||
}; | ||
|
||
export default () => { | ||
return ( | ||
<YourAdapterPropsProvider> | ||
<Connector> | ||
<ConnectButton /> | ||
</Connector> | ||
</YourAdapterPropsProvider> | ||
); | ||
}; |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.