Skip to content

Add deposit & withdraw for OP.#774

Open
Mc01 wants to merge 15 commits intomasterfrom
mc01/bridge-cli
Open

Add deposit & withdraw for OP.#774
Mc01 wants to merge 15 commits intomasterfrom
mc01/bridge-cli

Conversation

@Mc01
Copy link
Copy Markdown

@Mc01 Mc01 commented Apr 20, 2026

Description

Adds bridge commands to the Celo CLI for moving CELO tokens between Ethereum (L1) and Celo (L2) via the OP Stack bridge. This PR extends CLI with:

  • bridge:deposit — Deposit CELO from Ethereum L1 to Celo L2 (~15 min)
  • bridge:withdraw-init — Initiate a withdrawal from Celo L2 to Ethereum L1
  • bridge:withdraw-prove — Build and submit withdrawal proof on L1 (~1hr after init)
  • bridge:withdraw-status — Check withdrawal status with human-readable output and next-step guidance
  • bridge:withdraw-finalize — Claim funds on L1 after 7-day challenge period

Tested

  • 32 unit tests across 3 test suites (all passing):
    • src/utils/bridge.test.ts — validates network config, contract addresses, chain IDs, status labels
    • src/commands/bridge/deposit.test.ts — flag validation, address parsing, network rejection, signing requirements
    • src/commands/bridge/withdraw.test.ts — flag validation for all 4 withdrawal commands (init, prove, status, finalize)
  • Manual testing

How to QA

Prerequisites:

  • Funded address with CELO on Ethereum Sepolia (for deposit) or Celo Sepolia (for withdrawal)
  • Ethereum Sepolia RPC URL (e.g., Alchemy/Infura)
  • Private key for the funded address

Test deposit (L1 → L2):

celocli bridge:deposit \
    --from 0xYOUR_ADDRESS \
    --value 1000000000000000000 \
    --network sepolia \
    --l1RpcUrl https://eth-sepolia.g.alchemy.com/v2/YOUR_KEY \
    -k 0xYOUR_PRIVATE_KEY

Verify: CELO appears on Celo Sepolia within ~15 minutes.

Test withdrawal (L2 → L1):

# Step 1: Initiate
celocli bridge:withdraw-init \
    --from 0xYOUR_ADDRESS --value 1000000000000000000 \
    --network sepolia -n celo-sepolia -k 0xYOUR_PRIVATE_KEY
# Step 2: Check status (anytime)
celocli bridge:withdraw-status \
    --txHash 0xTX_HASH --network sepolia \
    --l1RpcUrl https://eth-sepolia.g.alchemy.com/v2/YOUR_KEY -n celo-sepolia
# Step 3: Prove (~1hr later when status shows "Ready to Prove")
celocli bridge:withdraw-prove \
    --txHash 0xTX_HASH --from 0xYOUR_ADDRESS --network sepolia \
    --l1RpcUrl https://eth-sepolia.g.alchemy.com/v2/YOUR_KEY -n celo-sepolia -k 0xYOUR_PRIVATE_KEY
# Step 4: Finalize (after 7-day challenge period)
  ./bin/run.js bridge:withdraw-finalize \
    --txHash 0xTX_HASH --from 0xYOUR_ADDRESS --network sepolia \
    --l1RpcUrl https://eth-sepolia.g.alchemy.com/v2/YOUR_KEY -n celo-sepolia -k 0xYOUR_PRIVATE_KEY

Related issues


PR-Codex overview

This PR introduces enhancements and tests for the bridge commands in the CLI, focusing on the process of bridging CELO between Ethereum (L1) and Celo (L2). It includes new functionalities for deposits, withdrawals, and status checks, along with improved error handling and validation.

Detailed summary

  • Added bridge section in package.json with description.
  • Implemented tests for BridgeDeposit and BridgeWithdraw commands.
  • Enhanced error handling for required flags in deposit and withdrawal processes.
  • Created detailed descriptions and examples for CLI commands in documentation.
  • Defined BRIDGE_CONFIG for network-specific configurations.
  • Added utility functions for network validation and chain ID verification.
  • Implemented withdrawal proof submission process with appropriate checks.
  • Developed tests for utility functions in bridge.test.ts.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Copilot AI review requested due to automatic review settings April 20, 2026 12:33
@Mc01 Mc01 requested a review from a team as a code owner April 20, 2026 12:33
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 20, 2026

⚠️ No Changeset found

Latest commit: 33d7414

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

@Mc01
Copy link
Copy Markdown
Author

Mc01 commented Apr 20, 2026

@copilot review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds OP Stack bridge support to the Celo CLI to move CELO between Ethereum L1 and Celo L2, including end-to-end withdraw lifecycle commands and supporting utilities/docs.

Changes:

  • Introduces new bridge:* CLI commands for deposit and multi-step withdrawals (init/prove/status/finalize).
  • Adds shared bridge network/config utilities (chain definitions, ABIs, status labels) plus unit tests.
  • Adds CLI topic metadata and end-user documentation for bridge workflows.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
packages/cli/src/utils/bridge.ts Adds bridge network config, OP Stack chain definitions, ABIs, and status labels used by commands.
packages/cli/src/utils/bridge.test.ts Unit tests for network validation, config constants, chain selection, and status labels.
packages/cli/src/commands/bridge/deposit.ts Implements L1→L2 CELO deposit flow (token lookup, approve, deposit).
packages/cli/src/commands/bridge/deposit.test.ts Flag-validation tests for bridge:deposit.
packages/cli/src/commands/bridge/withdraw-init.ts Implements L2 withdrawal initiation transaction.
packages/cli/src/commands/bridge/withdraw-prove.ts Implements proof waiting/building and L1 prove submission.
packages/cli/src/commands/bridge/withdraw-status.ts Implements human-readable withdrawal status + next-step guidance.
packages/cli/src/commands/bridge/withdraw-finalize.ts Implements finalization/claim on L1 after challenge period.
packages/cli/src/commands/bridge/withdraw.test.ts Flag-validation tests for all withdrawal commands.
packages/cli/package.json Registers the bridge command topic in CLI metadata.
packages/cli/docs/bridge.md Adds user documentation for deposit/withdraw workflows and status meanings.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/cli/src/commands/bridge/deposit.ts Outdated
Comment thread packages/cli/src/commands/bridge/withdraw-init.ts
Comment thread packages/cli/docs/bridge.md Outdated
Comment thread packages/cli/src/utils/bridge.ts
Comment thread packages/cli/src/commands/bridge/deposit.ts Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c1f4a70ce9

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/cli/src/commands/bridge/deposit.ts
Comment thread packages/cli/src/commands/bridge/deposit.ts Outdated
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 59211d4e1b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/cli/src/commands/bridge/withdraw-prove.ts Outdated
Comment thread packages/cli/src/commands/bridge/withdraw-finalize.ts Outdated
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 20, 2026

size-limit report 📦

Path Size
require('@celo/actions') (cjs) 98.85 KB (0%)
import * from '@celo/actions' (esm) 23.55 KB (0%)
import { resolveAddress } from '@celo/actions' (esm) 23.49 KB (0%)
import { getGasPriceOnCelo } from '@celo/actions' (esm) 73 B (0%)
import { getAccountsContract } from '@celo/actions/contracts/accounts' (esm) 46.11 KB (0%)
import * from '@celo/actions/staking' (esm) 50.66 KB (0%)

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.61%. Comparing base (2276386) to head (33d7414).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #774   +/-   ##
=======================================
  Coverage   69.61%   69.61%           
=======================================
  Files         150      150           
  Lines        7075     7075           
  Branches     1163     1155    -8     
=======================================
  Hits         4925     4925           
- Misses       2046     2098   +52     
+ Partials      104       52   -52     
Components Coverage Δ
celocli ∅ <ø> (∅)
sdk 69.12% <ø> (ø)
wallets 73.14% <ø> (ø)
viem-sdks 94.15% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Mc01
Copy link
Copy Markdown
Author

Mc01 commented Apr 20, 2026

@copilot review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bbd643bcde

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/cli/src/commands/bridge/deposit.ts
Comment thread packages/cli/src/commands/bridge/withdraw-init.ts Outdated
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 709a92eadd

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/cli/src/commands/bridge/withdraw-init.ts
Comment thread packages/cli/src/commands/bridge/withdraw-prove.ts
chatgpt-codex-connector[bot]

This comment was marked as outdated.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6017ecd28f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/cli/src/commands/bridge/withdraw-prove.ts
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9cde87409c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread packages/cli/src/commands/bridge/withdraw-prove.ts
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.

2 participants