Skip to content

Add support for Tron staking #5972

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Add support for Tron staking #5972

wants to merge 1 commit into from

Conversation

abhijit0943
Copy link
Contributor

@abhijit0943 abhijit0943 commented Apr 16, 2025

TICKET: SC-1632

Adding support for freeze and vote transactions for validating the transaction built by the WP (which calls the respective rpc methods via IMS)

@abhijit0943 abhijit0943 force-pushed the SC-1632 branch 10 times, most recently from f32b13c to 8325c1f Compare April 21, 2025 05:56
@abhijit0943 abhijit0943 requested review from Vijay-Jagannathan and removed request for Vijay-Jagannathan April 21, 2025 06:02
@abhijit0943 abhijit0943 force-pushed the SC-1632 branch 2 times, most recently from 6d8f7a6 to b6a3a71 Compare April 22, 2025 05:55
@abhijit0943 abhijit0943 changed the title Adding freezeBuilder Adding freezeBuilder and voteBuilder Apr 22, 2025
@abhijit0943 abhijit0943 requested a review from noel-bitgo April 29, 2025 09:38
@abhijit0943 abhijit0943 marked this pull request as ready for review May 5, 2025 08:05
@abhijit0943 abhijit0943 requested a review from a team as a code owner May 5, 2025 08:05
@abhijit0943 abhijit0943 removed the request for review from noel-bitgo May 5, 2025 08:05
@abhijit0943 abhijit0943 marked this pull request as draft May 5, 2025 08:06
Copy link
Contributor

@gianchandania gianchandania left a comment

Choose a reason for hiding this comment

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

Am yet to fully review this, but I think we should do the tx building here in SDK just like we do for all coins

this.transaction.setTransactionType(this.transactionType);
}

validateTransaction(transaction: Transaction | TransactionReceipt): void {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the type is transaction: Transaction | TransactionReceipt, why not just transaction: Transaction as in case of validateTransaction in other builder classes like ContractCallBuilder and TransactionBuilder

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For flexibility, because 2 paths are being checked: if its a txn object or if it's raw txn data

Copy link
Contributor

Choose a reason for hiding this comment

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

Where are we calling this from, can you point me to that? Is the type there Transaction | TransactionReceipt

Copy link
Contributor Author

@abhijit0943 abhijit0943 May 9, 2025

Choose a reason for hiding this comment

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

In the tests (resources file), the type is TransactionReceipt, but since we are overriding the method from the base class which uses Transaction object for validation, we would need to have Transaction | TransactionReceipt

@@ -10,6 +10,8 @@ import { ContractType } from './enum';
import { ContractCallBuilder } from './contractCallBuilder';
import { TransactionReceipt } from './iface';
import { TokenTransferBuilder } from './tokenTransferBuilder';
import { FreezeTransactionBuilder } from './freezeBuilder';
Copy link
Contributor

Choose a reason for hiding this comment

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

import { FreezeBalanceTxBuilder } from './freezeBalanceTxBuilder';

@@ -10,6 +10,8 @@ import { ContractType } from './enum';
import { ContractCallBuilder } from './contractCallBuilder';
import { TransactionReceipt } from './iface';
import { TokenTransferBuilder } from './tokenTransferBuilder';
import { FreezeTransactionBuilder } from './freezeBuilder';
import { VoteBuilder } from './voteBuilder';
Copy link
Contributor

Choose a reason for hiding this comment

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

import { VoteWitnessTxBuilder } from './voteWitnessTxBuilder';

* @param {Transaction} [tx] The transaction to initialize builder
* @returns {FreezeTransactionBuilder} The specific freeze balance builder
*/
getFreezeBuilder(tx?: TransactionReceipt | string): FreezeTransactionBuilder {
Copy link
Contributor

Choose a reason for hiding this comment

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

getFreezeBalanceTxBuilder

* @param {Transaction} [tx] The transaction to initialize builder
* @returns {VoteBuilder} The specific vote witness builder
*/
getVoteBuilder(tx?: TransactionReceipt | string): VoteBuilder {
Copy link
Contributor

Choose a reason for hiding this comment

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

getVoteWitnessBuilder

/**
* Vote data in a vote transaction
*/
export interface VoteData {
Copy link
Contributor

Choose a reason for hiding this comment

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

export interface VoteWitnessData

import { VoteBuilder } from '../../src/lib/voteBuilder';
import { validVoteUnsignedTx } from '../resources';
import { getBuilder } from '../../src/lib/builder';
import { TransactionType } from '@bitgo/sdk-core';
Copy link
Contributor

Choose a reason for hiding this comment

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

external imports should be on top for better readability

import { FreezeTransactionBuilder, FreezeResource } from '../../src/lib/freezeBuilder';
import { validFreezeUnsignedTx } from '../resources';
import { getBuilder } from '../../src/lib/builder';
import { TransactionType } from '@bitgo/sdk-core';
Copy link
Contributor

Choose a reason for hiding this comment

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

external imports should be on top for better readability


describe('Tron VoteBuilder', function () {
let voteBuilder: VoteBuilder;
let wrappedBuilder;
Copy link
Contributor

Choose a reason for hiding this comment

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

assign type

wrappedBuilder = getBuilder('ttrx');
// Get VoteBuilder from the wrapped builder
voteBuilder = wrappedBuilder.getVoteBuilder();
});
Copy link
Contributor

Choose a reason for hiding this comment

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

this should be in before

ENERGY = 'ENERGY',
}

interface RawContract {
Copy link
Contributor

Choose a reason for hiding this comment

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

RawFreezeContract

@abhijit0943 abhijit0943 force-pushed the SC-1632 branch 6 times, most recently from 90d066b to 425ff10 Compare May 11, 2025 17:27
@Vijay-Jagannathan Vijay-Jagannathan changed the title Adding freezeBuilder and voteBuilder Add support for Tron staking May 13, 2025
@Vijay-Jagannathan Vijay-Jagannathan force-pushed the SC-1632 branch 11 times, most recently from 08d4521 to 69134ff Compare May 19, 2025 18:07
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