Skip to content

Conversation

@yogeshwar-bitgo
Copy link
Contributor

@yogeshwar-bitgo yogeshwar-bitgo commented Sep 17, 2025

This pull request introduces significant enhancements and new features to the Flare P-chain SDK module, particularly around atomic transaction building, delegator transaction support, and improved transaction validation and signing. The changes include the addition of a new delegator transaction builder, expanded constants for Flare network compatibility, and a comprehensive refactor of the atomic transaction builder to support FlareJS structures and error handling.

New Features

  • Added a new DelegatorTxBuilder class to support building and validating Flare P-chain delegator transactions with proper credential and reward address handling, including FlareJS-compatible structures and error management.

Atomic Transaction Builder Enhancements

  • Refactored AtomicTransactionBuilder to:
    • Use new FlareJS-compatible constants and regex validation utilities,
    • Implement FlareJS-compatible input/output and asset ID handling,
    • Add support for proper signature storage and validation,
    • Improve error handling and transaction building logic,
    • Enhance transaction explanation and parsing for Flare network. [1] [2] [3] [4] [5] [6] [7] [8]

Constants and Utilities

  • Expanded constants.ts with Flare-specific asset, transaction, fee, and validator constants, and added utility functions for flexible hex validation.

Transaction Type Validation

  • Improved transaction type validation logic for export transactions in ExportInCTxBuilder, adding robust structure checks while maintaining backward compatibility. [1] [2]

Project Ownership

  • Updated CODEOWNERS to assign the new sdk-coin-flrp module to the @BitGo/ethalt-team.

Key changes:

  • CODEOWNERS

    • Adds /modules/sdk-coin-flrp/ to the @BitGo/ethalt-team for code ownership.
  • modules/sdk-coin-flrp/src/lib/atomicTransactionBuilder.ts

    • Extends the atomic transaction builder logic for Flare P-chain, with support for FlareJS credentials, asset ID handling, input/output management, and FlareJS-compatible signing/building methods.
  • modules/sdk-coin-flrp/src/lib/constants.ts

    • Defines Flare-specific constants (asset ID length, fees, BLS key lengths, regex patterns) and helper functions for hex validation and transaction construction.
  • modules/sdk-coin-flrp/src/lib/delegatorTxBuilder.ts

    • Implements the AddDelegator transaction builder, with methods to set node ID, times, stake amount, reward addresses, and FlareJS-compatible build logic.
  • modules/sdk-coin-flrp/src/lib/exportInCTxBuilder.ts

    • Implements the export transaction builder for C-chain, adding validation, asset ID support, and FlareJS-compliant transaction construction.
  • modules/sdk-coin-flrp/src/lib/exportInPTxBuilder.ts

    • Implements the export transaction builder for P-chain, including enhanced validation and FlareJS-compatible output/input structure.
  • modules/sdk-coin-flrp/src/lib/importInCTxBuilder.ts
    (New file)

    • Adds a builder for importing assets into the C-chain from other chains, including address, UTXO, and source chain management.
  • modules/sdk-coin-flrp/src/lib/importInPTxBuilder.ts
    (New file)

    • Adds a builder for importing assets into the P-chain, with relevant transaction construction logic.
  • modules/sdk-coin-flrp/src/lib/index.ts

    • Exports all new builder classes, making them available to the SDK.
  • modules/sdk-coin-flrp/src/lib/permissionlessValidatorTxBuilder.ts
    (New file)

    • Adds support for permissionless validator transactions, with BLS key/signature handling, delegation fee validation, and reward address support.
  • modules/sdk-coin-flrp/src/lib/transactionBuilder.ts
    (New file)

    • Base transaction builder for Flare P-chain, providing shared validation, field management, and recovery signature logic.
  • modules/sdk-coin-flrp/src/lib/types.ts
    (New file)

    • Type definitions for extended P-chain transaction data, improving type safety across builders.
  • modules/sdk-coin-flrp/src/lib/validatorTxBuilder.ts
    (New file)

    • Implements AddValidator transaction builder (inherits from AddDelegator), with delegation fee validation and FlareJS-compatible construction.

TICKET: WIN-7084, WIN-6318, WIN-6317

@yogeshwar-bitgo yogeshwar-bitgo force-pushed the WIN-7084 branch 5 times, most recently from 15dd921 to 55b5bd7 Compare September 17, 2025 06:51
@yogeshwar-bitgo yogeshwar-bitgo marked this pull request as ready for review September 17, 2025 10:14
@yogeshwar-bitgo yogeshwar-bitgo requested review from a team as code owners September 17, 2025 10:14
Copy link

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

This PR introduces comprehensive support for Flare P-chain transactions in the BitGo SDK. The implementation adds multiple transaction builders for delegator operations, validator management, and atomic cross-chain transactions. The changes focus on FlareJS compatibility and provide structured transaction building capabilities for the Flare blockchain's Platform chain.

Key additions include:

  • New delegator and validator transaction builders with proper fee validation and time management
  • Atomic transaction builders for import/export operations between P-chain and C-chain
  • Enhanced constants and utilities for Flare-specific validation patterns
  • Comprehensive type definitions for improved type safety

Reviewed Changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
CODEOWNERS Assigns ownership of sdk-coin-flrp module to the ethalt-team
atomicTransactionBuilder.ts Enhances atomic transaction builder with FlareJS compatibility and proper input/output handling
constants.ts Adds Flare-specific constants including asset lengths, fees, and hex validation utilities
delegatorTxBuilder.ts Implements AddDelegator transaction builder with validation and FlareJS integration
validatorTxBuilder.ts Extends delegator builder for AddValidator transactions with delegation fee validation
permissionlessValidatorTxBuilder.ts Adds support for permissionless validators with BLS key handling
transactionBuilder.ts Provides base transaction builder with recovery signature support
exportInCTxBuilder.ts/exportInPTxBuilder.ts Implements export transaction builders for cross-chain operations
importInCTxBuilder.ts/importInPTxBuilder.ts Implements import transaction builders for cross-chain operations
types.ts Defines type-safe interfaces for extended transaction properties
Test files Comprehensive unit tests for all transaction builders

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Contributor

@sijuu sijuu left a comment

Choose a reason for hiding this comment

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

approving CODEOWNERS change

Copy link
Contributor

@kisslove-dewangan kisslove-dewangan left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

@lokesh-bitgo lokesh-bitgo left a comment

Choose a reason for hiding this comment

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

LGTM

@yogeshwar-bitgo yogeshwar-bitgo merged commit b8ed00a into master Sep 23, 2025
15 checks passed
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.

6 participants