Skip to content

Conversation

SimonVutovB
Copy link
Contributor

Add verifyTokenEnablementTransaction method to validate token associate transactions with comprehensive checks for amount, account ID, token name, and transaction type. Integrates with existing verifyTransaction flow for enhanced token enablement validation.

  • Add organized validation functions for transaction structure, amount, account ID, token name, and transaction type

TICKET: WP-5746

@SimonVutovB SimonVutovB requested a review from a team as a code owner September 16, 2025 14:12
mukeshsp
mukeshsp previously approved these changes Sep 17, 2025
});
});

describe('Verify Token Enablement Transaction:', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

let's add a test that uses a valid transaction response from wallet platform with a spoofed txHex,
the test should have the structure of

await assert.rejects(
        wallet.sendTokenEnablements(...)
)...

so we know a spoofed tx hex will throw an error on this flow.

Copy link
Contributor

Choose a reason for hiding this comment

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

also another test verifying a valid token enablement tx won't cause an error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tests on 685-725 and 726-774 are the two tests that address this.

@SimonVutovB SimonVutovB force-pushed the WP-5746/hbar-verify-token-enablement-tx branch 2 times, most recently from 8b832e3 to e3e03ab Compare September 24, 2025 14:04
Copy link
Contributor

@balakrishna507 balakrishna507 left a comment

Choose a reason for hiding this comment

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

requesting a review from the other coin owner.

@SimonVutovB SimonVutovB force-pushed the WP-5746/hbar-verify-token-enablement-tx branch from 9eddfef to acd50cf Compare September 29, 2025 18:06
});
});

describe('Verify Token Enablement Transaction:', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

also another test verifying a valid token enablement tx won't cause an error.

@SimonVutovB SimonVutovB force-pushed the WP-5746/hbar-verify-token-enablement-tx branch from acd50cf to 43e27d0 Compare September 30, 2025 19:38
@SimonVutovB SimonVutovB force-pushed the WP-5746/hbar-verify-token-enablement-tx branch 2 times, most recently from b638a30 to c7481dd Compare October 2, 2025 13:49
@SimonVutovB SimonVutovB force-pushed the WP-5746/hbar-verify-token-enablement-tx branch from 8ef38d8 to 6eb45c0 Compare October 2, 2025 14:34
Copy link
Contributor

@mohammadalfaiyazbitgo mohammadalfaiyazbitgo left a comment

Choose a reason for hiding this comment

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

generally LGTM, some comments to follow up on.

private validateNoTransfers(raw: HederaRawTransactionData): void {
if (raw.instructionsData?.params?.recipients?.length && raw.instructionsData.params.recipients.length > 0) {
const hasNonZeroTransfers = raw.instructionsData.params.recipients.some(
(recipient: any) => recipient.amount && recipient.amount !== '0'
Copy link
Contributor

Choose a reason for hiding this comment

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

please address the typing in a follow up.

Comment on lines 425 to 430
const t = String(raw.instructionsData?.type || '').toLowerCase();

if (t === 'contractexecute' || t === 'contractcall' || t === 'precompile') {
throw new Error(`Contract-based token association not allowed for blind enablement; got ${t}`);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

please update the variable naming here.

@SimonVutovB SimonVutovB force-pushed the WP-5746/hbar-verify-token-enablement-tx branch 2 times, most recently from 6377c0b to f65d214 Compare October 2, 2025 15:05
Copy link
Contributor

@mukeshsp mukeshsp left a comment

Choose a reason for hiding this comment

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

Please squash all the commits into a single commit.

- Add validation functions for transaction structure, amount,
  account ID, token name, and transaction type
- Integrate token enablement validation into verifyTransaction method
- Add test coverage for all validation scenarios

TICKET: WP-5746
@SimonVutovB SimonVutovB force-pushed the WP-5746/hbar-verify-token-enablement-tx branch from f65d214 to 2136fff Compare October 7, 2025 13:02
@SimonVutovB SimonVutovB requested a review from mukeshsp October 7, 2025 13:04
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