Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add siwe #1214

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open

feat: add siwe #1214

wants to merge 19 commits into from

Conversation

LCJove
Copy link
Collaborator

@LCJove LCJove commented Oct 26, 2024

[中文版模板 / Chinese template]

添加 SIWE 的配置,目前只是一个最小可用的状态,需要 review 一下使用的方式是否可行。

需要在 provider 中配置对应的方法,并且在代码中需要指定调用的时机

💡 Background and solution

🔗 Related issue link

close #1107

Copy link

changeset-bot bot commented Oct 26, 2024

🦋 Changeset detected

Latest commit: cae22ba

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 14 packages
Name Type
@ant-design/web3-common Minor
@ant-design/web3-wagmi Minor
@ant-design/web3 Minor
@ant-design/web3-assets Patch
@ant-design/web3-bitcoin Patch
@ant-design/web3-eth-web3js Patch
@ant-design/web3-ethers-v5 Patch
@ant-design/web3-ethers Patch
@ant-design/web3-solana Patch
@ant-design/web3-sui Patch
@ant-design/web3-ton Patch
@example/eth-web3js Patch
@example/ethers-v5 Patch
@example/ethers Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Oct 26, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ant-design-web3 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 4, 2024 8:10am

Copy link

github-actions bot commented Oct 26, 2024

Preview is ready

@LCJove
Copy link
Collaborator Author

LCJove commented Oct 26, 2024

开发者还是需要指定一下签名的时机,因此在这里提供了 hooks 来调用签名方法

Copy link

codecov bot commented Oct 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.99%. Comparing base (1072532) to head (7d8e839).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1214   +/-   ##
=======================================
  Coverage   99.99%   99.99%           
=======================================
  Files         858      858           
  Lines       14726    14799   +73     
  Branches     1589     1610   +21     
=======================================
+ Hits        14725    14798   +73     
  Misses          1        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

packages/common/src/types.ts Outdated Show resolved Hide resolved
packages/common/src/types.ts Outdated Show resolved Hide resolved
packages/web3/src/ethereum/demos/siwe/sign-btn.tsx Outdated Show resolved Hide resolved
packages/web3/src/ethereum/demos/siwe/useSwie.tsx Outdated Show resolved Hide resolved
@LCJove LCJove changed the title feat: add swie feat: add siwe Nov 1, 2024
@LCJove LCJove marked this pull request as draft November 15, 2024 10:01
@LCJove LCJove marked this pull request as ready for review November 15, 2024 10:23
@LCJove
Copy link
Collaborator Author

LCJove commented Nov 21, 2024

@yutingzhao1991 愚指导有个问题,我在 AntDesignWeb3ConfigProvider 下面使用了 wagmi 的 signMessageAsync 来对消息进行签名,但是这个 hooks 需要在 WagmiProvider 下才可以使用。但是我们的 test 里面的用例并没有在外层包 WagmiProvider,这导致 test 过不去

@yutingzhao1991
Copy link
Collaborator

AntDesignWeb3ConfigProvider

AntDesignWeb3ConfigProvider 里面不要直接依赖 wagmi,本质上来讲你依赖的接口都是 AntDesignWeb3ConfigProvider 的 props,都可以自动去定义 mock 的。

@yutingzhao1991
Copy link
Collaborator

有代码冲突了

) : (
<>
{`${intl.getMessage(intl.messages.sign)}: `}
{buttonText}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

签名的情况下感觉不要直接用 buttonText,看了下 buttonText 可能会是金额,这样就很奇怪,用户可能会认为是对金额签名。直接用 Sign: 0x1234....2313,这样吧,直接是 Sign 加上地址,不要用 buttonText。

@@ -18,6 +24,8 @@ export type ConnectButtonProps = ButtonProps &
prefixCls?: string;
locale?: Locale['ConnectButton'];
avatar?: AvatarProps;
sign?: SignConfig;
signBtnTextRender?: (account?: Account, content?: React.ReactNode) => React.ReactNode;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

signTextRender?:(signText: ReactNode): ReactNode 改为这样吧,和 antd 的大部分组件的 render 都是类似的,把默认的内容放到第一个参数给出来就行。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] SIWE signMessage demo
2 participants