-
Notifications
You must be signed in to change notification settings - Fork 395
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
OK-34478: Support transfer custom token without symbol #6388
Conversation
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
概述代码变更总览这个拉取请求包含了多个文件的修改,主要涉及服务令牌处理、添加自定义令牌流程、本地化翻译和 RPC 缓存方法。变更旨在改进令牌管理和用户交互体验。 变更
详细变更ServiceToken 服务新增 添加自定义令牌流程在 本地化和 RPC 方法
这些变更整体上提升了应用的令牌管理、用户交互和系统灵活性。 Tip CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (20)
packages/shared/src/locale/json/bn.json
is excluded by!packages/shared/src/locale/json/*.json
packages/shared/src/locale/json/de.json
is excluded by!packages/shared/src/locale/json/*.json
packages/shared/src/locale/json/en.json
is excluded by!packages/shared/src/locale/json/*.json
packages/shared/src/locale/json/en_US.json
is excluded by!packages/shared/src/locale/json/*.json
packages/shared/src/locale/json/es.json
is excluded by!packages/shared/src/locale/json/*.json
packages/shared/src/locale/json/fr_FR.json
is excluded by!packages/shared/src/locale/json/*.json
packages/shared/src/locale/json/hi_IN.json
is excluded by!packages/shared/src/locale/json/*.json
packages/shared/src/locale/json/id.json
is excluded by!packages/shared/src/locale/json/*.json
packages/shared/src/locale/json/it_IT.json
is excluded by!packages/shared/src/locale/json/*.json
packages/shared/src/locale/json/ja_JP.json
is excluded by!packages/shared/src/locale/json/*.json
packages/shared/src/locale/json/ko_KR.json
is excluded by!packages/shared/src/locale/json/*.json
packages/shared/src/locale/json/pt.json
is excluded by!packages/shared/src/locale/json/*.json
packages/shared/src/locale/json/pt_BR.json
is excluded by!packages/shared/src/locale/json/*.json
packages/shared/src/locale/json/ru.json
is excluded by!packages/shared/src/locale/json/*.json
packages/shared/src/locale/json/th_TH.json
is excluded by!packages/shared/src/locale/json/*.json
packages/shared/src/locale/json/uk_UA.json
is excluded by!packages/shared/src/locale/json/*.json
packages/shared/src/locale/json/vi.json
is excluded by!packages/shared/src/locale/json/*.json
packages/shared/src/locale/json/zh_CN.json
is excluded by!packages/shared/src/locale/json/*.json
packages/shared/src/locale/json/zh_HK.json
is excluded by!packages/shared/src/locale/json/*.json
packages/shared/src/locale/json/zh_TW.json
is excluded by!packages/shared/src/locale/json/*.json
📒 Files selected for processing (5)
packages/kit-bg/src/services/ServiceToken.ts
(3 hunks)packages/kit/src/views/AssetList/hooks/useAddToken.ts
(6 hunks)packages/kit/src/views/AssetList/pages/AddCustomTokenModal.tsx
(4 hunks)packages/shared/src/locale/enum/translations.ts
(2 hunks)packages/shared/src/rpcCache/constants.ts
(1 hunks)
🔇 Additional comments (6)
packages/shared/src/rpcCache/constants.ts (1)
77-77
: 新增的 RPC 方法符合安全标准!
新增的 eth_feeHistory
方法是一个只读方法,用于获取历史 gas 费用数据,适合添加到安全 RPC 方法列表中。
packages/kit/src/views/AssetList/hooks/useAddToken.ts (2)
57-57
: 状态管理实现清晰!
新增的 isSymbolEditable
状态变量及其 setter 函数实现了对代币符号编辑权限的灵活控制。
Also applies to: 89-90
160-166
: 代币符号处理逻辑合理!
代码根据搜索结果动态设置符号的可编辑状态:
- 当获取到有效符号时禁用编辑
- 当符号为空时启用编辑,允许用户输入
这种实现方式既保证了数据准确性,又提供了良好的用户体验。
packages/kit/src/views/AssetList/pages/AddCustomTokenModal.tsx (1)
355-364
: 表单验证规则优化合理!
根据 isSymbolEditable
状态动态设置验证规则:
- 当符号可编辑时要求必填
- 当符号不可编辑时移除验证
这种实现方式避免了不必要的验证提示。
packages/kit-bg/src/services/ServiceToken.ts (1)
290-314
: 代码实现清晰且逻辑合理!
新增的 mergeTokenWithCustomData
方法实现了 token 数据的优雅合并,并在 fetchAccountTokens
中得到了一致的应用。代码结构良好,类型定义完整。
Also applies to: 198-227
packages/shared/src/locale/enum/translations.ts (1)
91-91
: 翻译键添加规范!
新增的两个翻译键:
auth_new_passcode_same_as_old
manage_token_token_required
遵循了现有的命名规范和点号表示法模式。
Also applies to: 1281-1281
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.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
packages/kit-bg/src/services/ServiceToken.ts
(5 hunks)
🔇 Additional comments (4)
packages/kit-bg/src/services/ServiceToken.ts (4)
198-202
: 合并自定义元数据的用法不错
这里在 map() 内部调用 mergeTokenMetadataWithCustomData,逻辑清晰,确保在获取到 tokens 后第一时间合并额外信息,避免出现空 symbol 或 name。
210-214
: 保持一致性地合并自定义信息
riskTokens 的处理方式与前面 tokens 相同,实现始终如一的合并逻辑。这对后续维护很友好。
490-502
: 在 getToken 中对 localToken 使用合并策略
如果本地 token 缺失 symbol 或 name,就从自定义 tokens 中补齐,逻辑正确。若后续还有更多 info 字段需要补全,也可沿用此方法。
515-529
: 在 fetchTokensDetails 之后再次合并元数据
fetchTokensDetails 返回的 tokenInfo 同样进行补齐,保证获取到的 token 始终包含完整信息。做法一致性强、可维护性好。
Summary by CodeRabbit
新功能
更新
eth_feeHistory
方法。错误修复