-
Notifications
You must be signed in to change notification settings - Fork 147
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
base: main
Are you sure you want to change the base?
feat: add siwe #1214
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
开发者还是需要指定一下签名的时机,因此在这里提供了 hooks 来调用签名方法 |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1214 +/- ##
=======================================
Coverage 99.99% 99.99%
=======================================
Files 858 858
Lines 18275 18279 +4
Branches 1589 1589
=======================================
+ Hits 18274 18278 +4
Misses 1 1 ☔ View full report in Codecov by Sentry. |
packages/common/src/types.ts
Outdated
@@ -1,3 +1,5 @@ | |||
import { type CreateSiweMessageParameters } from 'viem/siwe'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
common 这个包应该是通用的和链无关的,不应该依赖 viem 这个包。这里可以自己定义一个类型,但是可以参考 CreateSiweMessageParameters
packages/common/src/types.ts
Outdated
@@ -119,6 +121,7 @@ export interface UniversalWeb3ProviderInterface { | |||
|
|||
// For Bitcoin, tokenId is undefined. | |||
getNFTMetadata?: (params: { address: string; tokenId?: bigint }) => Promise<NFTMetadata>; | |||
swie?: SWIEConfig; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
swie 是和以太坊相关的概念,应该换一个通用一点的命名。可以参考 #1107 (comment) 这个,加一个 sign
。
@@ -1,5 +1,6 @@ | |||
import React from 'react'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SWIEConfig 如果是 Ethereum 特有的话,就放到 wagmi 这个包里面就好了。
import { Button, message, Space } from 'antd'; | ||
import { createSiweMessage } from 'viem/siwe'; | ||
import { useSignMessage } from 'wagmi'; | ||
import { ConnectButton, Connector, useAccount } from '@ant-design/web3'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sign-btn 的功能应该做到 ConnectButton
里面,ConnectButton 要支持已连接未签名的状态。
|
||
const DefaultSignInfo = {}; | ||
|
||
export const useSwie = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这些逻辑应该都放到 CoonectButton 里面去实现。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我在想 ConnectButton 是一个公用组件,别的 provider 也可能要用到,但是 siwe 是 eth 专用的。我们需要考虑后面不同 provider 的兼容嘛
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
要考虑的,所以在 ConnectButton 上的相关定义不应该绑定 siwe,语义上要更通用。
@@ -8,6 +8,7 @@ const localeValues: RequiredLocale = { | |||
copied: 'Copied!', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
文档和 demo 也更新一下,更重要的是要看看使用方式
@yutingzhao1991 愚指导有个问题,我在 AntDesignWeb3ConfigProvider 下面使用了 wagmi 的 signMessageAsync 来对消息进行签名,但是这个 hooks 需要在 WagmiProvider 下才可以使用。但是我们的 test 里面的用例并没有在外层包 WagmiProvider,这导致 test 过不去 |
AntDesignWeb3ConfigProvider 里面不要直接依赖 wagmi,本质上来讲你依赖的接口都是 AntDesignWeb3ConfigProvider 的 props,都可以自动去定义 mock 的。 |
[中文版模板 / Chinese template]
添加 SIWE 的配置,目前只是一个最小可用的状态,需要 review 一下使用的方式是否可行。
需要在 provider 中配置对应的方法,并且在代码中需要指定调用的时机
💡 Background and solution
🔗 Related issue link
close #1107