Git Product home page Git Product logo

ant-design / ant-design-web3 Goto Github PK

View Code? Open in Web Editor NEW
705.0 12.0 97.0 128.16 MB

🥳 Efficient react components for building dapps easier | Connect crypto wallets and more Web3 UI components | Web3 icons | Supports Ethereum, Solana, Bitcoin and others.

Home Page: https://web3.ant.design

License: MIT License

TypeScript 99.77% JavaScript 0.02% Less 0.21% Shell 0.01%
antd ethereum react solana web3

ant-design-web3's Introduction

ant design web3 logo

Ant Design Web3

Efficient react components for building dapps easier.

CI status codecov NPM version NPM downloads

Follow Twitter antd dumi

English · 中文

Features

  • 🎨 Ant Design Friendly
  • 📦 Out-of-the-Box Experience
  • 🔌 Compatibility with Different Chains

Installation

npm i antd @ant-design/web3 --save

Usage

import { Address } from '@ant-design/web3';

export default () => {
  return <Address address="0x1234567890123456789012345678901234567890" />;
};

Development

$ git clone [email protected]:ant-design/ant-design-web3.git
$ cd ant-design-web3
$ pnpm i
$ pnpm start

Contributing


Contributors of ant-design/ant-design-web3

Contributors of ant-design/ant-design-web3 Contributors of ant-design/ant-design-web3
Contributors of ant-design/ant-design-web3

Any type of contribution is welcome, here are some examples of how you may contribute to this project:

  • Use Ant Design Web3 in your daily work.
  • Submit issues to report bugs or ask questions.
  • Join our discussion and provide us with suggestions.
  • Propose pull requests to improve our code.

To better participate and contribute, please read our contribution guidelines.

Star History

Star History Chart

ant-design-web3's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ant-design-web3's Issues

Support Ethereum with wagmi

For discussions #79

Development tasks:

  • #82
  • Support connect with Metamask
  • Support connect with WallectConnect
  • Add getNFTMetadata for NFTImage
  • Add doc

完善 Provider 选择的逻辑

调用 EthereumProvider 的 request 时,需要判断应该是通过 WalletProvider 请求还是通过 JsonRpcProvider 请求,现在的逻辑比较简单,具体见 https://github.com/ant-design/ant-design-web3/blob/main/packages/ethereum/src/ethereum-provider.ts#L19 ,通过判断 method 是否是 'eth_requestAccounts', 'eth_accounts' 来判断是否走钱包的请求,这里需要完善下。

具体应该怎么做需要参考现在一些 sdk 的实现,可以参考下 wagmi。

RFC: NFTCard

Summary

NFTCard component for web3 component library.

API

Property Description Type Default
actionText Text of action button ReactNode Buy Now
image NFTCard image ReactNode -
footer Footer of NFTCard ReactNode -
isLike Whether like NFTCard boolean false
likes Number of likes number | boolean -
price Price of NFTCard number -
serialNumber NFTCard serial number number -
showAction Whether to show action button boolean | ReactNode false
name NFTCard name string -
type NFTCard style type default | pithy default
onLikeChange Callback executed when like button is changed ( isLike:boolean ) => void -
onActionChange Callback executed when action button is changed ( ) => void -

Basic Example

import { NFTCard } from '@ant-design/web3'

const Demo = () => (
  <NFTCard
   name="Demo NFT"
   image ={<img alt="example" src="https://os.alipayobjects.com/rmsportal/QBnOOoLaAfKPirc.png" />}
   showAction
   price={1.2}
   likes={9000}
   isLike
   serialNumber={404}
  />
);

RFC: ConnectModal

📝 [RFC] The new Component: ConnectModal

主题

在 DApp 中,当用户需要支付时,可以点击 ConnectButton 进行支付,此时,需要向用户展示新手指引、支持的钱包列表以及其他的一些附加信息,用户可以选择唤起相应的钱包进行后续的支付流程。

基于上述原因,需要实现 ConnectModal 组件,以弹出框形式在用户点击 ConnectButton 时展示以上关键信息。

API

Base

属性名 类型 默认 描述
open boolean false 是否展示
onOpenChange (open: boolean) => void - 展示状态改变回调
title string Connect your wallet 标题
walletList Wallet[] - 钱包列表
footer React.ReactNode - 附加信息
guide {title: string, infos: GuideInfoItem[], moreLink: string} | React.ReactNode DefaultGuide 新手帮助配置信息,若设置为 null 或 false 则切换成无新手指引的简洁模式

Wallet

属性名 类型 默认 描述
icon string | React.ReactNode - 钱包图标
name string - 钱包名称
remark string - 备注
link string - 用于跳转新增钱包的链接(用于生成二维码)
group string Default 钱包所属分组名称
pluginLink string - 浏览器插件链接

GuideInfoItem

属性名 类型 默认 描述
icon string | React.ReactNode - 图标
title string | React.ReactNode - 指引项标题
description string | React.ReactNode - 指引项简介

示例

export default () => {
	const [open, setOpen] = useState(false);
  
  return (
  	<>
    	<ConnectButton onOpen={() => setOpen(true)} />
    	<ConnectModal
        open={open}
        onOpenChange={open => setOpen(open)}
        title="连接你的钱包"
        walletList={[
        	{
            icon: "https://test.com/test.png",
            name: "测试钱包",
            remark: "备注",
            link: "https://test.com/xxx",
            group: 'Popular',
            pluginLink: 'https://test.com/xxx'
          },
        	{
            icon: "https://test.com/test.png",
            name: "测试钱包2",
            remark: "备注",
            group: 'More',
            pluginLink: 'https://test.com/xxx'
          },
      	]}
        // 设置为 null 或 false 则切换为无新手指引的简洁模式
        // guide={false}
        
        guide={{
        	title: 'What is a Wallet?',
          infos: [
            {
	            icon: "https://test.com/test.png",
              title: 'A Home for your Digital Assets',
              desc: 'Wallets are used to send, receive, store, and display digital assets like Ethereum and NFTs.'
            },
            {
	            icon: "https://test.com/test.png",
              title: 'A Home for your Digital Assets',
              desc: 'Wallets are used to send, receive, store, and display digital assets like Ethereum and NFTs.'
            },
          ],
        	moreLink: 'https://test.com/xxx'
	      }}
        footer={
        	<div className="footer">蚂蚁链提供技术支持</div>
      	}
      />
    </>
  );
}

细节

ConnectModal 组件需与 ConnectButton 配合使用。

Ant Design Web3 1.0.0-beta Plan

Milestone

  • 0824 ConnectButton & ConnectModal Design
  • 0907 All components design
  • 1110 Official website design
  • 1201 Finish components develop
  • 1208 Release beta
  • 1215 Release 1.0
  • 1218 Official release and promotionn 🚀

Architecture

Components

Others

  • Official website
  • Release Blog
  • #152

RFC: ConnectButton

📝 [RFC] The new Component: ConnectButton

API

Base

属性名 类型 默认 描述
icon boolean | React.ReactNode false 是否展示图标
ellipsis boolean false 省略地址中间内容
tooltip boolean false 是否显示 tooltip 展示完整地址
avatar Avatar undefined 用户头像配置
chainOptions ChainOption[] [{ name: 'Ethereum', id: 1 }] 支持的链
ghost - - 透传给 antd Button

Avatar

属性名 类型 默认 描述
src string | React.ReactNode - 头像内容
position 'left' | 'right' 'right' 头像在按钮上的位置

ChainOption

属性名 类型 默认 描述
name string | React.ReactNode - 链名称
id number - chainId

Left tasks before release 1.0

Support disconnect MetaMask

  disconnect = async () => {
    // TODO: disconnect for MetaMask
    const walletProvider = await this.getWalletProvider();
    if (walletProvider) {
      await walletProvider?.disconnect?.();
    }
  };

现在调用 disconnect 并不会真的断开 MetaMask,需要研究下如何实现。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.