Fulfill Git Escrow
You are helping the user fulfill a git escrow bounty. This means submitting code that passes a failing test suite to claim the escrowed token reward.
There are two modes:
- - Mode A (Write + Submit): You write the solution code, commit it, and submit. This is the default when no
--solution-repo is provided by the user. - Mode B (Submit Existing): The user already has a solution repo and commit. You just submit the fulfillment.
Determine the mode from the user's input:
- - If they provide
--solution-repo, use Mode B. - Otherwise, use Mode A.
The escrow UID is always required.
Step 1: Check CLI availability
Run git-escrows --help to verify the CLI is installed. If it fails, try npx git-escrows --help or bunx git-escrows --help. Use whichever works for all subsequent commands. If none work, tell the user to install with npm i -g git-escrows.
Step 2: Check .env configuration
Check if a .env file exists in the current directory. If not, tell the user they need one and suggest running:
CODEBLOCK0
Step 3: Validate the escrow
Run git-escrows list --verbose --format json and find the escrow matching the provided UID. Confirm:
- - The escrow exists and is open
- Note the test repo URL, test commit hash, reward amount, and oracle address
If no escrow UID was provided, ask the user for one. You can help them browse with git-escrows list --status open.
Mode A: Write Solution + Submit
A1: Understand the tests
Clone or read the test repository to understand what the tests expect:
- 1. Identify the test repo URL and commit from the escrow details
- Clone it to a temporary location: INLINECODE9
- Read the test files to understand:
- What functions/modules/APIs the tests import
- What behavior they assert
- What test framework is used
- The project structure expected
A2: Write the solution
In the current working directory (or a subdirectory the user specifies):
- 1. Create/modify files to implement the code that will make the tests pass
- Follow the project structure the tests expect (e.g., if tests import from
src/math.ts, create that file) - Include any necessary config files (package.json, Cargo.toml, etc.)
- Ensure the test framework's dependencies are accounted for
A3: Commit and get repo details
- 1. Stage and commit the solution: INLINECODE11
- Get the commit hash: INLINECODE12
- Get the remote URL: INLINECODE13
- If no remote exists, ask the user to push to a public git repo and provide the URL
A4: Submit the fulfillment
CODEBLOCK1
Mode B: Submit Existing Solution
B1: Gather parameters
From the user's input, extract:
- -
--solution-repo: The git repo URL with the solution - INLINECODE15 : The commit hash of the solution
If either is missing, ask the user.
B2: Submit the fulfillment
CODEBLOCK2
Step 4: Report results (both modes)
After successful execution:
- - Report the Fulfillment UID prominently
- Explain that the oracle will now automatically test the solution
- Provide the collect command for after arbitration passes:
git-escrows collect --escrow-uid <escrow-uid> --fulfillment-uid <fulfillment-uid>
- - Suggest checking status with: INLINECODE16
If the command fails, help diagnose the issue (escrow already fulfilled, wrong network, key not registered, etc.). If the user's git key isn't registered, suggest git-escrows register-key.
完成 Git 托管合约
您正在帮助用户完成一个 Git 托管合约的赏金任务。这意味着提交能够通过失败测试套件的代码,以领取托管合约中的代币奖励。
有两种模式:
- - 模式 A(编写 + 提交):您编写解决方案代码,提交并完成提交。当用户未提供 --solution-repo 时,此为默认模式。
- 模式 B(提交现有方案):用户已有解决方案仓库和提交记录。您只需完成提交。
根据用户输入确定模式:
- - 如果用户提供 --solution-repo,使用模式 B。
- 否则,使用模式 A。
托管合约 UID 始终是必需的。
步骤 1:检查 CLI 可用性
运行 git-escrows --help 验证 CLI 是否已安装。如果失败,尝试 npx git-escrows --help 或 bunx git-escrows --help。后续所有命令使用可用的那个。如果都不行,告知用户使用 npm i -g git-escrows 安装。
步骤 2:检查 .env 配置
检查当前目录是否存在 .env 文件。如果没有,告知用户需要创建并建议运行:
git-escrows new-client --privateKey 0x... --network sepolia
步骤 3:验证托管合约
运行 git-escrows list --verbose --format json 并找到与提供的 UID 匹配的托管合约。确认:
- - 托管合约存在且状态为开放
- 记录测试仓库 URL、测试提交哈希、奖励金额和预言机地址
如果未提供托管合约 UID,向用户询问。您可以使用 git-escrows list --status open 帮助用户浏览。
模式 A:编写解决方案 + 提交
A1:理解测试
克隆或读取测试仓库以理解测试的预期:
- 1. 从托管合约详情中识别测试仓库 URL 和提交
- 克隆到临时位置:git clone /tmp/escrow-tests- && cd /tmp/escrow-tests- && git checkout
- 读取测试文件以理解:
- 测试导入的函数/模块/API
- 它们断言的行为
- 使用的测试框架
- 预期的项目结构
A2:编写解决方案
在当前工作目录(或用户指定的子目录)中:
- 1. 创建/修改文件以实现能使测试通过的代码
- 遵循测试预期的项目结构(例如,如果测试从 src/math.ts 导入,则创建该文件)
- 包含必要的配置文件(package.json、Cargo.toml 等)
- 确保测试框架的依赖项已处理
A3:提交并获取仓库详情
- 1. 暂存并提交解决方案:git add -A && git commit -m solution for escrow
- 获取提交哈希:git rev-parse HEAD
- 获取远程 URL:git remote get-url origin
- 如果没有远程仓库,要求用户推送到公共 Git 仓库并提供 URL
A4:完成提交
git-escrows fulfill \
--escrow-uid \
--solution-repo \
--solution-commit
模式 B:提交现有解决方案
B1:收集参数
从用户输入中提取:
- - --solution-repo:包含解决方案的 Git 仓库 URL
- --solution-commit:解决方案的提交哈希
如果缺少任何一项,向用户询问。
B2:完成提交
git-escrows fulfill \
--escrow-uid \
--solution-repo \
--solution-commit
步骤 4:报告结果(两种模式)
成功执行后:
- - 突出显示完成 UID
- 解释预言机将自动测试解决方案
- 提供仲裁通过后的领取命令:
git-escrows collect --escrow-uid --fulfillment-uid
- - 建议使用 git-escrows list --verbose 检查状态
如果命令失败,帮助诊断问题(托管合约已完成、网络错误、密钥未注册等)。如果用户的 Git 密钥未注册,建议使用 git-escrows register-key。