Skip to content

Conversation

@joshisakshi
Copy link
Contributor

@joshisakshi joshisakshi commented Feb 5, 2026

TICKET: SC-5233

Implement transaction builder for AddPermissionlessDelegator transactions on Flare P-chain, enabling stake delegation to validators.

Key changes:

  • Add PermissionlessDelegatorTxBuilder with full build and initBuilder support
  • Use post-Etna API (pvm.e.newAddPermissionlessDelegatorTx) exclusively
  • Require feeState parameter (consistent with Import/Export builders)
  • Add AddPermissionlessDelegatorTx to SerializedTx type union
  • Add FlrpStakingOptions interface for delegation parameters
  • Add transaction type verification in flrp.ts
  • Comprehensive unit tests for builder validation

Note: Rewards always go to the C-chain address derived from the delegator's public key though it does not affect onchain reward distribution and rewardAddress param is kept for rewards tracking

Copy link
Contributor

@Vijay-Jagannathan Vijay-Jagannathan left a comment

Choose a reason for hiding this comment

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

few comments

Copy link
Contributor

@Vijay-Jagannathan Vijay-Jagannathan 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

@abhijit0943 abhijit0943 left a comment

Choose a reason for hiding this comment

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

Hey Sakshi, nice work on the builder — the overall structure looks solid. One issue though:

transaction.ts wasn't updated in this PR. The setTransactionType() method (line 379) only allows AddPermissionlessValidator in its whitelist, so when the delegation builder calls setTransactionType(AddPermissionlessDelegator) during buildImplementation(), it'll throw "Transaction type is not supported". The outputs, changeOutputs, inputs, and explainTransaction getters also need cases for the delegation tx type.

The reason the existing tests don't catch this is that every build() test expects a rejection before it ever gets to setTransactionType (missing nodeID, missing UTXOs, etc.). There's no test that actually builds a complete valid delegation transaction end-to-end.

Would be good to:

  1. Update transaction.ts to support AddPermissionlessDelegator in setTransactionType and the output/input/explain getters
  2. Add the delegation type to the Tx union in iface.ts (it was added to SerializedTx but not Tx)
  3. Add an end-to-end build test with all required params, and ideally an initBuilder round-trip test (build -> serialize -> factory.from() -> verify)

Copy link
Contributor

@abhijit0943 abhijit0943 left a comment

Choose a reason for hiding this comment

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

Looks good — all the issues from the previous review are addressed. transaction.ts is updated, Tx type union is fixed, and the round-trip tests with real tx data cover the deserialization path. Ship it.

@joshisakshi joshisakshi marked this pull request as ready for review February 10, 2026 11:09
@joshisakshi joshisakshi requested a review from a team as a code owner February 10, 2026 11:09
@joshisakshi joshisakshi merged commit c3a2d01 into master Feb 10, 2026
20 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.

4 participants