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(farcaster): create a new package to support farcaster login and more features in the future #991

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AmAzing129
Copy link
Collaborator

💡 需求背景

目前有一些应用是基于 Farcaster 账户登陆的。他们与之前的 dapp 有所区别,那就是更像是一个 web2 的应用登陆(使用手机扫码,而非连接钱包)。弱化了区块链的概念,你不会明确地去连接钱包、发起交易,但是却在背后完成相关链上动作,比如通过点击 frame 的按钮 mint 一个 NFT.

在这个趋势下,“连接钱包”这个概念,逐渐成为了更广泛意义上的登陆。如下图 Privy 所做的组件,既包含了传统账户登陆,也包含了连接钱包,当然也支持处于中间态的 Farcaster

image image

因此,也需要基于我们的弹窗风格,开发 Farcaster 的登陆弹窗。

🔗 设计思路

  • 为什么需要一个新的 Provider?

Farcaster 登陆本质与 WalletConnect 类似,都是一种协议,需要用户扫码,与目前的弹窗中交互是一致的。不同的是,Wagmi 帮我们封装好了 WalletConnect 的相关内容,而 Farcaster 需要自己去实现。因此,也需要一个类似的适配器帮助开发者屏蔽中间逻辑。未来也可以加入其他 Farcaster 特性

  • Connector 中混入 Farcaster 处理逻辑?

目前的 UI 和适配器是分离的,但实际上在 Connector 组件下,写了很多 Wallet 逻辑,而 Farcaster 并不具备钱包的数据结构。这里无法直接复用,只能特殊适配。如果未来有其他类似于 Farcaster 的登陆方式也要加到 Connector 中,可能需要重构。

  • Warcaster 是钱包,也不是钱包

本质上 Warpcast 是钱包,但逻辑上与钱包不一样。比如当我们连接钱包后,按钮会展示地址或者ENS,也具备断开连接、发起交易等功能。而这些不再是 Warpcast 的交互范式。

TODO

可以先评审下设计思路,以下内容稍后补充:

  • 图标补充
  • 单测补充
  • 英文文档补充
  • changeset 补充
  • 通用二维码组件?待定

Copy link

vercel bot commented Jun 20, 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 Jun 21, 2024 3:29am

Copy link

changeset-bot bot commented Jun 20, 2024

⚠️ No Changeset found

Latest commit: 32a0f06

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

Copy link

github-actions bot commented Jun 20, 2024

Preview is ready

@ONLY-yours
Copy link
Collaborator

感觉可以发一个类似于 -next 的 tag 里面

等 Farcaster dapp 多起来再放到 main 里面去?

@jeasonstudio
Copy link
Collaborator

Farcaster 连接目前无法直接实现成 wagmi connector,功能不对齐
https://wagmi.sh/dev/creating-connectors#methods

@AmAzing129
Copy link
Collaborator Author

Farcaster 连接目前无法直接实现成 wagmi connector,功能不对齐 https://wagmi.sh/dev/creating-connectors#methods

目前希望实现的就是 Farcaster 登陆弹窗,无意将它作为真正的钱包看待。所以现在问题是增加弹窗这个需求没必要,还是说要将其实现为一个 wagmi connector?

@yutingzhao1991
Copy link
Collaborator

会出现 dapp 同时支持 Farcaster 和钱包登录吗?

@yutingzhao1991
Copy link
Collaborator

会出现 dapp 同时支持 Farcaster 和钱包登录吗?

如果只是 Farcaster 单独用那感觉单独给 Farcaster 提供一个 Provider 就行,然后看 ConnectModal 的 API 能不能适配这种场景,如果要都支持的话就要考虑如何和现有的 Provider 结合。

@AmAzing129
Copy link
Collaborator Author

会出现 dapp 同时支持 Farcaster 和钱包登录吗?

如果只是 Farcaster 单独用那感觉单独给 Farcaster 提供一个 Provider 就行,然后看 ConnectModal 的 API 能不能适配这种场景,如果要都支持的话就要考虑如何和现有的 Provider 结合。

目前的实现是支持 UI 层一起的,其他产品也是提供的。再比如 Dynamic 不过 dApp 的使用需要再调研下。

image image

登陆成功后的逻辑也支持分开处理的。因为返回的东西不一样。不过需要讨论下这里连接弹窗的架构要调整吗?要适配进以太坊的钱包吗?因为这里的概念扩展了,不止是连接钱包了。

@jeasonstudio
Copy link
Collaborator

走 farcaster 可以类比为 github、google 等 web2 的 oauth 登录,和钱包登录其实是两回事;后续可以把 Farcaster、LensProtocol、Nostr 等几个 Web3 社交协议放在一起综合考虑

@jeasonstudio
Copy link
Collaborator

jeasonstudio commented Jun 21, 2024

会出现 dapp 同时支持 Farcaster 和钱包登录吗?

如果只是 Farcaster 单独用那感觉单独给 Farcaster 提供一个 Provider 就行,然后看 ConnectModal 的 API 能不能适配这种场景,如果要都支持的话就要考虑如何和现有的 Provider 结合。

目前的实现是支持 UI 层一起的,其他产品也是提供的。再比如 Dynamic 不过 dApp 的使用需要再调研下。

image image
登陆成功后的逻辑也支持分开处理的。因为返回的东西不一样。不过需要讨论下这里连接弹窗的架构要调整吗?要适配进以太坊的钱包吗?因为这里的概念扩展了,不止是连接钱包了。

这样通过 warpcast 连接后的 dapp 是不能跟链上合约交互的,只能跟 farcaster 协议交互

Comment on lines +13 to +15
目前提供了开箱即用的 [Warpcast](https://warpcast.com/) 扫码登陆,即通过封装官方组件 `@farcaster/auth-kit`,在保持 `@ant-design/web3` UI 组件风格的基础上,使得开发者无需关注登陆逻辑,同时获取所有登陆相关数据。

## 扫码登陆 Farcaster 账户
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
目前提供了开箱即用的 [Warpcast](https://warpcast.com/) 扫码登陆,即通过封装官方组件 `@farcaster/auth-kit`,在保持 `@ant-design/web3` UI 组件风格的基础上,使得开发者无需关注登陆逻辑,同时获取所有登陆相关数据
## 扫码登陆 Farcaster 账户
目前提供了开箱即用的 [Warpcast](https://warpcast.com/) 扫码登录,即通过封装官方组件 `@farcaster/auth-kit`,在保持 `@ant-design/web3` UI 组件风格的基础上,使得开发者无需关注登录逻辑,同时获取所有登录相关数据
## 扫码登录 Farcaster 账户

Copy link
Collaborator

Choose a reason for hiding this comment

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

应该是用 登录更好, 登陆似乎是错别字

image

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK

@AmAzing129
Copy link
Collaborator Author

走 farcaster 可以类比为 github、google 等 web2 的 oauth 登录,和钱包登录其实是两回事;后续可以把 Farcaster、LensProtocol、Nostr 等几个 Web3 社交协议放在一起综合考虑

赞同这个,那 PR 先缓一下。主要是想用弹窗,但是之前弹窗是为连接钱包量身定制的,保留之前不变吧。

@jeasonstudio
Copy link
Collaborator

走 farcaster 可以类比为 github、google 等 web2 的 oauth 登录,和钱包登录其实是两回事;后续可以把 Farcaster、LensProtocol、Nostr 等几个 Web3 社交协议放在一起综合考虑

赞同这个,那 PR 先缓一下。主要是想用弹窗,但是之前弹窗是为连接钱包量身定制的,保留之前不变吧。

可以持续讨论和设计,Farcaster 最近是明星项目,看看有没有好机会能抓得住

@yutingzhao1991
Copy link
Collaborator

会出现 dapp 同时支持 Farcaster 和钱包登录吗?

如果只是 Farcaster 单独用那感觉单独给 Farcaster 提供一个 Provider 就行,然后看 ConnectModal 的 API 能不能适配这种场景,如果要都支持的话就要考虑如何和现有的 Provider 结合。

目前的实现是支持 UI 层一起的,其他产品也是提供的。再比如 Dynamic 不过 dApp 的使用需要再调研下。

image image
登陆成功后的逻辑也支持分开处理的。因为返回的东西不一样。不过需要讨论下这里连接弹窗的架构要调整吗?要适配进以太坊的钱包吗?因为这里的概念扩展了,不止是连接钱包了。

嗯,看来 ConnectModal 的 API 和 UI 要重新设计下

@jeasonstudio
Copy link
Collaborator

我之前随便做的一个 siwe + siwf (Sign-In with Farcaster) 的 demo,可以体验下:https://chain-board.vercel.app/login
代码在这里:https://github.com/jeasonstudio/chainboard/blob/main/components/siwf-button.tsx

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.

None yet

5 participants