Skip to content

fix: automatically refresh transaction expiration#299

Merged
gabrieledm merged 4 commits into
mainfrom
NEB-1123-refresh-transaction-metadata
May 21, 2026
Merged

fix: automatically refresh transaction expiration#299
gabrieledm merged 4 commits into
mainfrom
NEB-1123-refresh-transaction-metadata

Conversation

@ulissesferreira

@ulissesferreira ulissesferreira commented May 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add a shared TRON transaction metadata freshness check for expiration and TAPOS reference block fields.
  • Refresh stale or invalid expiration, ref_block_bytes, and ref_block_hash before signing in both send/broadcast paths.
  • Preserve valid transactions without rebuilding derived fields, and return a clear rebuild-and-retry error when metadata cannot be refreshed.
  • Update Snap coverage thresholds after the pre-push test hook reported improved coverage.

@ulissesferreira ulissesferreira requested a review from a team as a code owner May 12, 2026 13:57
@ulissesferreira ulissesferreira force-pushed the NEB-1123-refresh-transaction-metadata branch 4 times, most recently from 40323a4 to c8b9525 Compare May 12, 2026 17:19
@ulissesferreira ulissesferreira changed the title NEB-1123 Refresh transaction metadata before signing NEB-1123: Refresh transaction metadata before signing May 12, 2026
@ulissesferreira ulissesferreira force-pushed the NEB-1123-refresh-transaction-metadata branch 5 times, most recently from 3d07287 to ad2d7a2 Compare May 13, 2026 14:28
@ulissesferreira ulissesferreira changed the title NEB-1123: Refresh transaction metadata before signing fix: automatically refresh transaction expiration May 13, 2026
@ulissesferreira ulissesferreira force-pushed the NEB-1123-refresh-transaction-metadata branch 8 times, most recently from b76b4a6 to d009136 Compare May 14, 2026 13:50
}
}

async #ensureFreshRawData<RawDataType extends TransactionRawData>(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You might wonder why we have a private method with the same name as above. The reason is that we are sharing this method between the public 3 ones above. We need to have tronWeb as a param for it so we don't keep re-instantiating it. In a future PR this will not be a problem because Tronweb will have one instance per network readily available for the whole Snap instead of the existing factory pattern.

The factory pattern was useful when we were storing the instances but for some reason this stopped being the case it seems.

@ulissesferreira ulissesferreira force-pushed the NEB-1123-refresh-transaction-metadata branch 2 times, most recently from 3286a53 to 44ac903 Compare May 14, 2026 15:07
Comment thread packages/snap/src/handlers/cronjob.tsx
Comment thread packages/snap/src/handlers/cronjob.tsx
@ulissesferreira ulissesferreira force-pushed the NEB-1123-refresh-transaction-metadata branch from 67d799e to 0b76de1 Compare May 14, 2026 16:59
@ulissesferreira ulissesferreira force-pushed the NEB-1123-refresh-transaction-metadata branch 3 times, most recently from 4d380e6 to d4386a4 Compare May 14, 2026 17:32
@ulissesferreira ulissesferreira force-pushed the NEB-1123-refresh-transaction-metadata branch from d4386a4 to 9a16d70 Compare May 14, 2026 17:37
@gabrieledm gabrieledm force-pushed the NEB-1123-refresh-transaction-metadata branch from 3b57287 to 9a16d70 Compare May 20, 2026 08:14
gabrieledm
gabrieledm previously approved these changes May 20, 2026

@gabrieledm gabrieledm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

## Summary
- Moves transaction metadata refresh test coverage onto a stacked branch
above #299
- Re-enables the tests that are skipped on the base PR branch
- Restores the higher coverage thresholds supported by the added tests

## Verification
- yarn lint:fix
- yarn test
gabrieledm

This comment was marked as duplicate.

@gabrieledm gabrieledm self-requested a review May 20, 2026 09:04
gabrieledm
gabrieledm previously approved these changes May 20, 2026

@gabrieledm gabrieledm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@gabrieledm

Copy link
Copy Markdown
Contributor

@metamaskbot publish-preview

@github-actions

Copy link
Copy Markdown
Contributor

Preview builds have been published. See these instructions for more information about preview builds.

Expand for full list of packages and versions.
{
  "@metamask-previews/tron-wallet-snap": "1.25.4-preview-20f5407"
}

@gabrieledm

Copy link
Copy Markdown
Contributor

@metamaskbot publish-preview

1 similar comment
@gabrieledm

Copy link
Copy Markdown
Contributor

@metamaskbot publish-preview

@gabrieledm gabrieledm merged commit d5f4248 into main May 21, 2026
11 checks passed
@gabrieledm gabrieledm deleted the NEB-1123-refresh-transaction-metadata branch May 21, 2026 15:28
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.

3 participants