Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Sep 5, 2025

This PR adds a comprehensive TypeScript script that demonstrates how to process BIP322 broadcastable messages from JSON files containing airdrop claim data. The implementation provides a clear usage example for BitGo's BIP322 utilities as requested.

New Files Added

examples/ts/process-bip322-claims.ts

A complete CLI script that:

  • Reads JSON files containing claims with broadcastableMessage fields
  • Extracts and deserializes messages using deserializeBIP322BroadcastableMessage()
  • Processes and verifies messages with generateBIP322MessageListAndVerifyFromMessageBroadcastable()
  • Provides detailed logging, error handling, and informative output
  • Supports both btc and tbtc4 coin types

examples/ts/sample-claims.json

Sample JSON data demonstrating the expected structure:

{
  "status": "success",
  "claims": [
    {
      "id": "claim-001",
      "broadcastableMessage": "7b227478486578223a22303130323033222c226d657373616765496e666f223a5b7b2261646472657373223a22736f6d6541646472657373222c226d657373616765223a22736f6d654d657373616765222c227075626b657973223a5b227075626b657931222c227075626b657932225d2c2273637269707454797065223a2270327368227d5d7d",
      ...
    }
  ],
  "count": 1,
  "pagination": { "limit": 100, "hasNext": false }
}

examples/ts/BIP322_CLAIMS_README.md

Comprehensive documentation covering:

  • Usage instructions and command-line interface
  • Input JSON format specification
  • Function descriptions for the BIP322 utilities used
  • Error handling scenarios
  • Example output and development notes

Key Features

  • Robust Error Handling: Gracefully handles file I/O errors, invalid JSON, deserialization failures, and verification errors
  • Detailed Logging: Provides step-by-step progress information and comprehensive summaries
  • Fallback Information: When verification fails (expected with test data), displays extracted message information
  • Command-line Interface: Professional CLI with argument validation and help text
  • Production-ready Pattern: Follows existing examples' structure and can be easily adapted for real BIP322 data

Usage Example

cd examples/ts
npx tsx process-bip322-claims.ts sample-claims.json btc

The script demonstrates the complete workflow from reading JSON claim data to extracting verified address/message pairs, providing developers with a clear understanding of how to process airdrop claim data using BitGo's BIP322 utilities.

Fixes #6891.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • download.cypress.io
    • Triggering command: /usr/local/bin/node index.js --exec install (dns block)
  • https://storage.googleapis.com/chromium-browser-snapshots/Linux_x64/722234/chrome-linux.zip
    • Triggering command: /usr/local/bin/node install.js (http block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copy link
Author

Copilot AI commented Sep 5, 2025

@bhavidhingra 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

@Copilot Copilot AI changed the title [WIP] Add TS script to read and process broadcastable messages from JSON in examples/ts Add TS script to read and process broadcastable messages from JSON in examples/ts Sep 5, 2025
Copilot finished work on behalf of bhavidhingra September 5, 2025 08:21
@Copilot Copilot AI requested a review from bhavidhingra September 5, 2025 08:21
@bhavidhingra bhavidhingra changed the base branch from master to scripts September 5, 2025 09:57
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.

Add TS script to read and process broadcastable messages from JSON in examples/ts
2 participants