Loading...
Loading...
Compare original and translation side by side
generate-tests#[expected_failure(abort_code = N)]generate-tests#[expected_failure(abort_code = N)]public(friend)package funvector::borrowwhileforvector::for_each_refvector::mapvector::foldcoinTokenV1fungible_assetEventHandle#[event]i8i256public(friend)package funvector::borrowwhileforvector::for_each_refvector::mapvector::foldcoinTokenV1fungible_assetEventHandle#[event]i8i256write-contractsanalyze-gas-optimizationsecurity-auditwrite-contractsanalyze-gas-optimizationsecurity-audit.movesources/sources/.moveundefinedundefined| # | File:Line | Rule | Pattern | Proposed Change | Tier | Confidence |
|---|---|---|---|---|---|---|
| 1 | src/mod.move:15 | T1-01 | vector::borrow | → index notation | 1 | High |
| ... | ... | ... | ... | ... | ... | ... |
| 序号 | 文件:行号 | 规则 | 模式 | 建议变更 | 层级 | 置信度 |
|---|---|---|---|---|---|---|
| 1 | src/mod.move:15 | T1-01 | vector::borrow | → 索引表示法 | 1 | 高 |
| ... | ... | ... | ... | ... | ... | ... |
2. Ask the user to choose scope:
- **`syntax-only`** (Tier 1 only) — zero risk, just cleaner syntax
- **`standard`** (Tier 1 + Tier 2) — recommended default, syntax + visibility + error constants
- **`full`** (all tiers) — includes API migrations, higher risk
3. Highlight any Tier 3 items that require major rewrites
4. If scope includes Tier 3, ask the user about deployment context:
- **Compatible** — Upgrading an already-deployed contract. Breaking changes
are excluded even if the scope includes them. Rules marked ⚠ Breaking are skipped.
- **Fresh deploy** — New deployment or willing to redeploy. All changes
in the selected scope are applied including breaking changes.
**Exit:** User has confirmed scope (and deployment context if Tier 3 is included). Do NOT proceed until confirmed.
2. 请用户选择现代化范围:
- **`syntax-only`**(仅第1层)——零风险,仅优化代码语法
- **`standard`**(第1层 + 第2层)——推荐默认选项,包含语法、可见性和错误常量优化
- **`full`**(所有层级)——包含API迁移,风险较高
3. 高亮显示任何需要重大重写的第3项内容
4. 如果范围包含第3层,请询问用户部署上下文:
- **兼容模式**——升级已部署的合约。即使范围包含破坏性变更,也会跳过这些变更。标记为⚠ 破坏性变更的规则将被忽略。
- **全新部署**——新部署或愿意重新部署。将应用所选范围内的所有变更,包括破坏性变更。
**退出条件**:用户已确认现代化范围(若包含第3层则同时确认部署上下文)。未得到确认前请勿继续。#[test_only]*_tests.movetests/generate-testsaptos move test#[test_only]*_tests.movetests/generate-testsaptos move testaptos move teststandardfullaptos move testfullcompatiblefresh deployaptos move testaptos move teststandardfullaptos move testfull兼容模式全新部署aptos move testaptos move test --coverageundefinedaptos move test --coverageundefined
**Exit:** Report presented to user.
**退出条件**:已向用户提交总结报告。| Scope | Tiers | Risk | When to Use |
|---|---|---|---|
| Tier 1 | Zero | Just clean up syntax, no semantic changes |
| Tier 1+2 | Low | Default. Syntax + visibility + error constants |
| Tier 1+2+3 | Medium-High | Full migration including API changes |
| 范围 | 涉及层级 | 风险 | 适用场景 |
|---|---|---|---|
| 第1层 | 零 | 仅清理语法,不涉及语义变更 |
| 第1+2层 | 低 | 默认选项。语法 + 可见性 + 错误常量优化 |
| 第1+2+3层 | 中高 | 完整迁移,包含API变更 |
| Tier | What Changes | Risk | Examples |
|---|---|---|---|
| 1 — Syntax | Code reads differently, compiles identically | Zero | |
| 2 — Visibility & Errors | Same semantics, cleaner declarations | Low | |
| 3 — API Migrations | Different APIs, same intended behavior. Most are breaking changes. | Medium-High | |
| 层级 | 变更内容 | 风险 | 示例 |
|---|---|---|---|
| 1 — 语法 | 代码写法不同,但编译结果一致 | 零 | |
| 2 — 可见性与错误 | 语义相同,声明更简洁 | 低 | |
| 3 — API迁移 | 使用不同API,但预期行为一致。大多数为破坏性变更。 | 中高 | |
| Rationalization | Why It's Wrong |
|---|---|
| "Tests pass so the modernization is correct" | Tests verify behavior, not code quality. Review changes manually too. |
| "This contract is simple, skip the analysis" | Simple contracts can have subtle patterns. Always analyze first. |
| "Let's do all tiers at once to save time" | If tests break, you can't isolate which change caused it. Always tier. |
| "The receiver-style call looks right" | Must verify the target function declares |
| "Error constants can have new names and values" | Existing tests depend on exact numeric values. Preserve them. |
| "No tests exist, but the changes are safe" | Without tests there is no safety net. Generate tests first. |
| "Tier 3 changes are optional, skip the test run" | Every change needs verification. Tier 3 is highest risk — test MORE, not less. |
| 错误理由 | 错误原因 |
|---|---|
| "测试通过,所以现代化是正确的" | 测试仅验证行为,不验证代码质量。还需人工审核变更。 |
| "这个合约很简单,跳过分析" | 简单合约也可能存在微妙的模式问题。必须先进行分析。 |
| "一次性完成所有层级以节省时间" | 如果测试失败,无法定位具体是哪项变更导致的问题。必须分层执行。 |
| "接收者风格调用看起来是对的" | 必须验证目标函数是否声明了 |
| "错误常量可以使用新名称和新值" | 现有测试依赖精确的数值。必须保留原数值。 |
| "没有测试,但变更很安全" | 没有测试就没有安全保障。必须先生成测试用例。 |
| "第3层变更可选,跳过测试" | 每一项变更都需要验证。第3层风险最高——需要更多测试,而不是更少。 |
fullfull| File | Content |
|---|---|
| detection-rules.md | Complete V1 pattern detection catalog (22 rules across 3 tiers) |
| transformation-guide.md | Before/after code, safety checks, edge cases per rule |
| MOVE_V2_SYNTAX.md | Full V2 syntax reference |
| OBJECTS.md | Modern object model patterns |
| ADVANCED_TYPES.md | Enums, signed integers, phantom types |
generate-testswrite-contractssecurity-audit| 文件 | 内容 |
|---|---|
| detection-rules.md | 完整的V1模式检测规则目录(3个层级共22条规则) |
| transformation-guide.md | 每条规则的代码前后对比、安全检查、边缘情况说明 |
| MOVE_V2_SYNTAX.md | 完整的V2语法参考 |
| OBJECTS.md | 现代对象模型模式 |
| ADVANCED_TYPES.md | 枚举、有符号整数、幻影类型 |
generate-testswrite-contractssecurity-audit