-
Notifications
You must be signed in to change notification settings - Fork 2
Added experimental escrow based send-to-social support #507
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
Open
tcsenpai
wants to merge
46
commits into
testnet
Choose a base branch
from
claude/testnet-wallet-exploration-01AeaDgjrVk8BGn3QhfE5jNQ
base: testnet
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
bb7bcba
docs: add comprehensive escrow onboarding documentation
claude 7e2ff36
docs: add implementation phases guide for escrow system
claude c386021
feat(escrow): Phase 1 - add database schema for escrow system
claude 690e03a
style: apply prettier formatting to EscrowTypes.ts
claude fa4f4db
style: apply prettier auto-formatting to existing files
claude e3681f4
feat(escrow): Phase 2 - implement GCR escrow operations
claude 985462b
docs: add SDK repository implementation guide
claude 0da13e7
docs: update escrow SDK implementation status
a23cecc
bumped sdk
647fa33
docs: refactor escrow documentation for clarity
claude a490a68
feat(escrow): Phase 4 - implement RPC endpoints for escrow queries
claude 7711024
fix(escrow): auto-fix code quality issues
claude 5a37ebb
fix(escrow): resolve race condition, add index, optimize N+1 queries
claude dda1ddb
fix(escrow): resolve 7 critical issues from CodeRabbit review
63a8d05
fix(escrow): resolve 4 critical issues from second CodeRabbit review
121a7a8
fix(escrow): resolve 7 critical security and robustness issues
88a6326
chore: configure ESLint to ignore test files and ts-comment
04989f3
fixed types errors
d92823a
memories
e78e9a0
applied fixes to avoid funds locks and race conditions
4643b5c
updated docs and memories
db887c7
fix: comprehensive escrow system security hardening (18 bugs fixed)
b80fed9
fixed 4 issues
f525d70
Update src/libs/network/middleware/rateLimiter.ts
tcsenpai e02ec71
Update src/libs/network/endpointHandlers.ts
tcsenpai 6ea1773
Update EscrowOnboarding/IMPLEMENTATION_PHASES.md
tcsenpai 9fda71a
Update SECURITY_HARDENING_REPORT.md
tcsenpai fdcffd9
Update EscrowOnboarding/IMPLEMENTATION_PHASES.md
tcsenpai 89702fc
feat(escrow): add Discord platform support
cd15186
feat(escrow): complete Discord platform support in routines
529ffe5
feat(escrow): implement proper rollback behavior for multi-edit trans…
bfff628
refactor(escrow): use canonical SUPPORTED_PLATFORMS constant
675ad51
refactor(escrow): remove inline MAX_DEPOSITS_PER_ESCROW declaration
def7bcf
fix(escrow): defer state mutations until after simulate flag check
d5cf927
fix(rate-limiter): use while loop for burst-resistant eviction
7ac3bfa
Update src/libs/blockchain/gcr/gcr_routines/GCREscrowRoutines.ts
tcsenpai 297213f
fix(escrow): prevent TOCTOU race condition in flagged account check
ee18e73
Merge remote-tracking branch 'refs/remotes/origin/claude/testnet-wall…
22f5710
fix(escrow): prevent deadlocks in rollback operations
3cbf449
Update src/libs/blockchain/gcr/gcr_routines/GCREscrowRoutines.ts
tcsenpai b777c89
Update src/libs/blockchain/gcr/gcr_routines/GCREscrowRoutines.ts
tcsenpai ad11e65
Merge remote-tracking branch 'refs/remotes/origin/claude/testnet-wall…
b6c2d33
ignores
083b49e
refactor(escrow): reduce cognitive complexity in applyEscrowDeposit
1787a6e
refactor(escrow): reduce cognitive complexity in handleGetSentEscrows
1c5c8ba
beads init
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # SQLite databases | ||
| *.db | ||
| *.db?* | ||
| *.db-journal | ||
| *.db-wal | ||
| *.db-shm | ||
|
|
||
| # Daemon runtime files | ||
| daemon.lock | ||
| daemon.log | ||
| daemon.pid | ||
| bd.sock | ||
|
|
||
| # Legacy database files | ||
| db.sqlite | ||
| bd.db | ||
|
|
||
| # Merge artifacts (temporary files from 3-way merge) | ||
| beads.base.jsonl | ||
| beads.base.meta.json | ||
| beads.left.jsonl | ||
| beads.left.meta.json | ||
| beads.right.jsonl | ||
| beads.right.meta.json | ||
|
|
||
| # Keep JSONL exports and config (source of truth for git) | ||
| !issues.jsonl | ||
| !metadata.json | ||
| !config.json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| # Beads - AI-Native Issue Tracking | ||
|
|
||
| Welcome to Beads! This repository uses **Beads** for issue tracking - a modern, AI-native tool designed to live directly in your codebase alongside your code. | ||
|
|
||
| ## What is Beads? | ||
|
|
||
| Beads is issue tracking that lives in your repo, making it perfect for AI coding agents and developers who want their issues close to their code. No web UI required - everything works through the CLI and integrates seamlessly with git. | ||
|
|
||
| **Learn more:** [github.com/steveyegge/beads](https://github.com/steveyegge/beads) | ||
|
|
||
| ## Quick Start | ||
|
|
||
| ### Essential Commands | ||
|
|
||
| ```bash | ||
| # Create new issues | ||
| bd create "Add user authentication" | ||
|
|
||
| # View all issues | ||
| bd list | ||
|
|
||
| # View issue details | ||
| bd show <issue-id> | ||
|
|
||
| # Update issue status | ||
| bd update <issue-id> --status in_progress | ||
| bd update <issue-id> --status done | ||
|
|
||
| # Sync with git remote | ||
| bd sync | ||
| ``` | ||
|
|
||
| ### Working with Issues | ||
|
|
||
| Issues in Beads are: | ||
| - **Git-native**: Stored in `.beads/issues.jsonl` and synced like code | ||
| - **AI-friendly**: CLI-first design works perfectly with AI coding agents | ||
| - **Branch-aware**: Issues can follow your branch workflow | ||
| - **Always in sync**: Auto-syncs with your commits | ||
|
|
||
| ## Why Beads? | ||
|
|
||
| ✨ **AI-Native Design** | ||
| - Built specifically for AI-assisted development workflows | ||
| - CLI-first interface works seamlessly with AI coding agents | ||
| - No context switching to web UIs | ||
|
|
||
| 🚀 **Developer Focused** | ||
| - Issues live in your repo, right next to your code | ||
| - Works offline, syncs when you push | ||
| - Fast, lightweight, and stays out of your way | ||
|
|
||
| 🔧 **Git Integration** | ||
| - Automatic sync with git commits | ||
| - Branch-aware issue tracking | ||
| - Intelligent JSONL merge resolution | ||
|
|
||
| ## Get Started with Beads | ||
|
|
||
| Try Beads in your own projects: | ||
|
|
||
| ```bash | ||
| # Install Beads | ||
| curl -sSL https://raw.githubusercontent.com/steveyegge/beads/main/scripts/install.sh | bash | ||
|
|
||
| # Initialize in your repo | ||
| bd init | ||
|
|
||
| # Create your first issue | ||
| bd create "Try out Beads" | ||
| ``` | ||
|
|
||
| ## Learn More | ||
|
|
||
| - **Documentation**: [github.com/steveyegge/beads/docs](https://github.com/steveyegge/beads/tree/main/docs) | ||
| - **Quick Start Guide**: Run `bd quickstart` | ||
| - **Examples**: [github.com/steveyegge/beads/examples](https://github.com/steveyegge/beads/tree/main/examples) | ||
|
|
||
| --- | ||
|
|
||
| *Beads: Issue tracking that moves at the speed of thought* ⚡ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| # Beads Configuration File | ||
| # This file configures default behavior for all bd commands in this repository | ||
| # All settings can also be set via environment variables (BD_* prefix) | ||
| # or overridden with command-line flags | ||
|
|
||
| # Issue prefix for this repository (used by bd init) | ||
| # If not set, bd init will auto-detect from directory name | ||
| # Example: issue-prefix: "myproject" creates issues like "myproject-1", "myproject-2", etc. | ||
| # issue-prefix: "" | ||
|
|
||
| # Use no-db mode: load from JSONL, no SQLite, write back after each command | ||
| # When true, bd will use .beads/issues.jsonl as the source of truth | ||
| # instead of SQLite database | ||
| # no-db: false | ||
|
|
||
| # Disable daemon for RPC communication (forces direct database access) | ||
| # no-daemon: false | ||
|
|
||
| # Disable auto-flush of database to JSONL after mutations | ||
| # no-auto-flush: false | ||
|
|
||
| # Disable auto-import from JSONL when it's newer than database | ||
| # no-auto-import: false | ||
|
|
||
| # Enable JSON output by default | ||
| # json: false | ||
|
|
||
| # Default actor for audit trails (overridden by BD_ACTOR or --actor) | ||
| # actor: "" | ||
|
|
||
| # Path to database (overridden by BEADS_DB or --db) | ||
| # db: "" | ||
|
|
||
| # Auto-start daemon if not running (can also use BEADS_AUTO_START_DAEMON) | ||
| # auto-start-daemon: true | ||
|
|
||
| # Debounce interval for auto-flush (can also use BEADS_FLUSH_DEBOUNCE) | ||
| # flush-debounce: "5s" | ||
|
|
||
| # Git branch for beads commits (bd sync will commit to this branch) | ||
| # IMPORTANT: Set this for team projects so all clones use the same sync branch. | ||
| # This setting persists across clones (unlike database config which is gitignored). | ||
| # Can also use BEADS_SYNC_BRANCH env var for local override. | ||
| # If not set, bd sync will require you to run 'bd config set sync.branch <branch>'. | ||
| # sync-branch: "beads-sync" | ||
|
|
||
| # Multi-repo configuration (experimental - bd-307) | ||
| # Allows hydrating from multiple repositories and routing writes to the correct JSONL | ||
| # repos: | ||
| # primary: "." # Primary repo (where this database lives) | ||
| # additional: # Additional repos to hydrate from (read-only) | ||
| # - ~/beads-planning # Personal planning repo | ||
| # - ~/work-planning # Work planning repo | ||
|
|
||
| # Integration settings (access with 'bd config get/set') | ||
| # These are stored in the database, not in this file: | ||
| # - jira.url | ||
| # - jira.project | ||
| # - linear.url | ||
| # - linear.api-key | ||
| # - github.org | ||
| # - github.repo | ||
| sync-branch: beads-sync |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "database": "beads.db", | ||
| "jsonl_export": "issues.jsonl" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,4 +6,5 @@ dist | |
| .vscode | ||
| .env | ||
| postgres_* | ||
| aptos_examples_ts | ||
| aptos_examples_ts | ||
| local_tests | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
|
|
||
| # Use bd merge for beads JSONL files | ||
| .beads/issues.jsonl merge=beads |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| # Escrow Security Patterns and Best Practices | ||
|
|
||
| ## Critical Security Validations | ||
|
|
||
| ### Input Validation Pattern | ||
| All escrow operations must validate: | ||
| 1. **Length limits**: Platform ≤20 chars, Username ≤100 chars | ||
| 2. **Unicode normalization**: NFKC normalization to prevent collision attacks | ||
| 3. **Delimiter protection**: Prevent `:` in platform/username fields | ||
| 4. **Non-empty validation**: Require trimmed non-empty strings | ||
|
|
||
| ### Balance Protection Pattern | ||
| ```typescript | ||
| const MAX_BALANCE = BigInt("1000000000000000000000") // 1 sextillion DEM | ||
|
|
||
| // Always check overflow before applying | ||
| const newBalance = previousBalance + BigInt(amount) | ||
| if (newBalance > MAX_BALANCE) { | ||
| // Reject operation | ||
| } | ||
| ``` | ||
|
|
||
| ### Time-Based Validation Pattern | ||
| ```typescript | ||
| const MIN_EXPIRY_DAYS = 1 | ||
| const MAX_EXPIRY_DAYS = 365 // Prevent indefinite fund locking | ||
|
|
||
| // Validate expiry on deposit creation | ||
| if (requestedExpiry < MIN_EXPIRY_DAYS || requestedExpiry > MAX_EXPIRY_DAYS) { | ||
| // Reject operation | ||
| } | ||
| ``` | ||
|
|
||
| ### Access Control Pattern | ||
| ```typescript | ||
| // Always check flagged status before allowing fund operations | ||
| if (account.flagged) { | ||
| return { | ||
| success: false, | ||
| message: "Account is flagged and cannot perform this operation" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Attack Vectors Mitigated | ||
|
|
||
| ### 1. Unicode Collision Attack | ||
| **Attack**: Different Unicode strings generating same hash | ||
| **Defense**: NFKC normalization + delimiter validation | ||
| **Example**: `alice` vs `alice` (fullwidth) → normalized to same value | ||
|
|
||
| ### 2. Fund Locking Attack | ||
| **Attack**: Creating escrow with distant future expiry | ||
| **Defense**: 365-day maximum expiry validation | ||
| **Impact**: Prevents permanent fund locks | ||
|
|
||
| ### 3. Balance Overflow Attack | ||
| **Attack**: Deposit amounts causing integer overflow | ||
| **Defense**: BigInt arithmetic + MAX_BALANCE check | ||
| **Impact**: Prevents theft via wrapping | ||
|
|
||
| ### 4. DoS via Large Input | ||
| **Attack**: Submitting 10MB usernames to exhaust SHA3 computation | ||
| **Defense**: Length limits (20/100 chars) | ||
| **Impact**: Protects network from computational DoS | ||
|
|
||
| ### 5. Flagged Account Bypass | ||
| **Attack**: Banned accounts claiming escrow funds | ||
| **Defense**: Flagged status check before claim | ||
| **Impact**: Enforces access control policies | ||
|
|
||
| ## Code Review Checklist | ||
|
|
||
| When reviewing escrow-related code, verify: | ||
| - [ ] All string inputs have length validation | ||
| - [ ] Unicode normalization applied to user-provided identifiers | ||
| - [ ] BigInt used for all balance arithmetic | ||
| - [ ] Overflow checks before balance updates | ||
| - [ ] Time-based validations have reasonable bounds | ||
| - [ ] Flagged account checks before sensitive operations | ||
| - [ ] No delimiter characters allowed in structured identifiers | ||
|
|
||
| ## Constants Reference | ||
|
|
||
| ```typescript | ||
| // Escrow limits | ||
| const MIN_EXPIRY_DAYS = 1 | ||
| const MAX_EXPIRY_DAYS = 365 | ||
| const MS_PER_DAY = 24 * 60 * 60 * 1000 | ||
| const MAX_BALANCE = BigInt("1000000000000000000000") | ||
| const MAX_PLATFORM_LENGTH = 20 | ||
| const MAX_USERNAME_LENGTH = 100 | ||
|
|
||
| // Rate limits | ||
| escrow_deposit: { maxRequests: 10, windowMs: 60000 } | ||
| escrow_claim: { maxRequests: 5, windowMs: 60000 } | ||
| escrow_refund: { maxRequests: 5, windowMs: 60000 } | ||
| ``` | ||
|
|
||
| ## Testing Recommendations | ||
|
|
||
| ### Security Test Cases | ||
| 1. **Unicode attacks**: Submit fullwidth, combining marks, homographs | ||
| 2. **Overflow attacks**: Test max values, boundary conditions | ||
| 3. **DoS attacks**: Submit maximum allowed lengths, measure performance | ||
| 4. **Time attacks**: Test min/max expiry bounds, expired escrows | ||
| 5. **Access control**: Verify flagged accounts rejected | ||
|
|
||
| ### Performance Benchmarks | ||
| - Hash computation time with MAX_USERNAME_LENGTH input | ||
| - Database query latency with GIN indexes | ||
| - Rate limiter eviction performance at 100K IPs | ||
| - Point calculation latency (should be 4x faster) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.