Skip to content

Conversation

SimonVutovB
Copy link
Contributor

Summary

Added token enablement validation and tests

Changes

  • Inside, verifyTransaction in near.ts of sdk-coin-near, validate the txHex is a valid token enablement transaction for the specified token and does not have additional transactions embedded.

TICKET: WP-5782

@SimonVutovB SimonVutovB force-pushed the WP-5782/fix-near-token-enablement-validation branch 3 times, most recently from 3371efc to b81a0d0 Compare September 11, 2025 19:21
Copy link
Contributor

@mtexeira-simtlix mtexeira-simtlix left a comment

Choose a reason for hiding this comment

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

A few changes requested but you got a general first idea, good job! let me know if you need further clarification on any of the mentioned points @SimonVutovB

Thanks!

@SimonVutovB SimonVutovB force-pushed the WP-5782/fix-near-token-enablement-validation branch from 8d0fb13 to fa835c7 Compare September 15, 2025 17:41
@mtexeira-simtlix
Copy link
Contributor

@SimonVutovB for this issue that you're getting on the CI/CD steps, just rebase master since your dep versions are out of date:

image

@SimonVutovB SimonVutovB force-pushed the WP-5782/fix-near-token-enablement-validation branch from fa835c7 to cf059f2 Compare September 16, 2025 13:16
@SimonVutovB SimonVutovB requested review from a team as code owners September 16, 2025 13:16
@SimonVutovB SimonVutovB force-pushed the WP-5782/fix-near-token-enablement-validation branch from cf059f2 to 6141074 Compare September 16, 2025 13:31
@SimonVutovB SimonVutovB force-pushed the WP-5782/fix-near-token-enablement-validation branch from e9cbf28 to 10c27f8 Compare September 16, 2025 17:36
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.

add a unit test to show sendTokenEnablements throws an error when you mock a response with a spoofed TxHex. Otherwise lgtm.

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.

please add a test case showcasing sendAccountConsolidations fails when a spoofed txHex is returned in the response.

@SimonVutovB SimonVutovB force-pushed the WP-5782/fix-near-token-enablement-validation branch from f4a41a4 to 3be12f4 Compare September 24, 2025 18:00
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.

Can we add a test that shows a spoofed tx from platform will be rejected, similar to HBAR's?

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.

i'll also request a review from the coin owners.

Copy link
Contributor

@mtexeira-simtlix mtexeira-simtlix left a comment

Choose a reason for hiding this comment

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

Thanks for the changes Simon! It's looking better.
I left a nit and a couple of requested changes, feel free to ask about these!
Cheers.

@SimonVutovB SimonVutovB force-pushed the WP-5782/fix-near-token-enablement-validation branch from 756d4df to 49a8204 Compare October 1, 2025 16:58
Copy link
Contributor

@mtexeira-simtlix mtexeira-simtlix left a comment

Choose a reason for hiding this comment

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

lgtm, thanks!

@mohammadalfaiyazbitgo mohammadalfaiyazbitgo dismissed their stale review October 1, 2025 18:45

Forgot a comment.

const explainedTx = transaction.explainTransaction();

// users do not input recipients for consolidation requests as they are generated by the server
if (txParams.type === 'enabletoken') {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (txParams.type === 'enabletoken') {
if (txParams.type === 'enabletoken' && verification.verifyTokenEnablement) {

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.

LGTM, missing one last change.

FloBitGo
FloBitGo previously approved these changes Oct 3, 2025

if (!_.isEqual(filteredOutputs, filteredRecipients)) {
// For enabletoken, provide more specific error messages for address mismatches
if (txParams.type === 'enabletoken') {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (txParams.type === 'enabletoken') {
if (txParams.type === 'enabletoken' && params.verification?.verifyTokenEnablement) {

Not sure if we always want to throw this new error or only if the param is passed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah you're right, good catch. Just pushed change to add the check for the verifyTokenEnablement flag.

mukeshsp
mukeshsp previously approved these changes Oct 7, 2025
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.

NEAR token enablement blind signing validation

TICKET: WP-5782
@SimonVutovB SimonVutovB force-pushed the WP-5782/fix-near-token-enablement-validation branch from 8f353e7 to d84bba2 Compare October 7, 2025 13:04
@sijuu
Copy link
Contributor

sijuu commented Oct 10, 2025

PR has merge conflicts

@SimonVutovB SimonVutovB force-pushed the WP-5782/fix-near-token-enablement-validation branch from 57d600d to 3e49289 Compare October 14, 2025 14:55
@SimonVutovB SimonVutovB requested a review from mukeshsp October 14, 2025 15:15
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.

8 participants