开源推荐
morning
GitHub 热门项目: 球体
摘要
GitHub项目:sphere 仓库地址:https://github.com/unicity-sphere/sphere Stars:9728 | 作者:unicity-sphere 项目描述:A Web3 wallet and agent platform for the Unicity network - crypto wallet, DMs, group chat, and marketp...
Sphere
the
unicity
wallet
and
dApp
connect
URL
via
sphere
2026-09-04
1 阅读
约6分钟阅读
GitHub Trending
字号:
GitHub 项目:sphere
仓库地址:https://github.com/unicity-sphere/sphere
星级:9728 | 作者:unicity-sphere
项目描述:Unicity 网络的 Web3 钱包和代理平台 - 加密钱包、DM、群聊和市场。
===================================================
自述文件内容:
# Unicity AgentSphere
Unicity 网络的 Web3 钱包和代理平台 — 加密钱包、DM、群聊和市场。
## 特点
**Unicity 状态转换:**
- 快速、低成本的代币传输
- 代币管理和余额跟踪
- 收到付款通知
- 姓名标签系统(@用户名)
**常见:**二维码、钱包切换、助记词管理、实时市场数据。
### 连接协议(dApp ↔ 钱包)
Sphere 实现了“ConnectHost”——Sphere Connect 协议的钱包端。外部 dApp 可以连接到 Sphere 并请求钱包操作:
- **Iframe 模式** — dApp 嵌入 Sphere 内,作为 iframe 通过“PostMessageTransport”连接
- **弹出模式** — dApp 将 Sphere 作为弹出窗口打开,用户批准连接
- **基于权限的访问** — dApp 请求特定范围;用户批准或拒绝
- **意图处理** — dApp 在钱包 UI 中触发发送/签名/DM 流程
关键组件:`ConnectPage`(`/connect` 路由)、`ConnectProvider`、`ConnectionApprovalModal`。
### 深层链接 (`unicity-connect://`)
Sphere 支持自定义 URL 协议,用于 DM 内的应用程序间链接。当 dApp 在 DM 中发送“unicity-connect://” URL 时,Sphere 会将其呈现为具有两个选项的交互式按钮:**在 Sphere 中打开**(将 URL 作为 iframe 代理加载)或 **在浏览器中打开**(在新选项卡中打开)。
**协议格式:**
````
unicity-connect://主机/路径?query=params
````
打开后,协议将解析为“https://”(或“http://”表示“localhost”/“127.0.0.1”)。
**它是如何工作的:**
1. **发送** — dApp 构建 URL 并用“unicity-connect://”替换“https://”,然后将其作为 DM 消息发送
2. **渲染** - Sphere 的 markdown 解析器检测纯文本中的 `unicity-connect://`、`[text](unicity-connect://...)` 和 `` 格式,渲染一个 `DeepLinkButton` 下拉列表
3. **在 Sphere 中打开** — 全局处理程序(通过 `DashboardLayout` 中的 `useDeepLinkNavigation` 注册)导航到 `/agents/custom?url=`,将目标加载为 iframe 代理
4. **在浏览器中打开** — 解析后的“http(s)://” URL 通过“window.open”在新选项卡中打开
**关键文件:**
- `src/utils/deepLinkHandler.ts` — 协议转换 (`deepLinkToHttps`),全局点击处理程序注册表
- `src/utils/markdown.tsx` — `DeepLinkButton` 组件,所有链接格式的深度链接检测
- `src/hooks/useDeepLinkNavigation.ts` — 注册 Sphere 端导航处理程序
### 代理系统
代理是作为选项卡加载的专用界面。目前活跃:
- **消息 (DM)** — 通过 Nostr 进行私人对话
- **群聊** — 通过 NIP-29 的公共群组频道
- **Sphere Agents** — 通过 iframe(自定义 URL)加载任何外部 dApp
可以在`src/config/activities.ts`中添加其他代理类型。
### 群聊 (NIP-29)
通过 [NIP-29](https://github.com/nostr-protocol/nips/blob/master/29.md) 基于中继的群组消息传递:
- 带有邀请码的公共和私人团体
- 通过 WebSock 进行实时消息传递
这篇文章对您有帮助吗?
订阅66必读
每日精选科技资讯,直达你的邮箱