fleet icon indicating copy to clipboard operation
fleet copied to clipboard

Implements comprehensive transaction validation for mock-chain package.

Open AdityaGupta20871 opened this issue 3 months ago • 5 comments

Features Added

  • Minimum nanoergs per box validation (based on box size)
  • Miner fee validation (fee-per-byte threshold)
  • Custom fee ErgoTree support
  • Configurable validation options
  • Can disable all checks or specific checks

Methods

  • validateTransaction() - Main validation function
  • checkMinNanoergsPerBox() - Box value validation
  • checkMinerFee() - Fee validation
  • isFeeContract() - Fee contract detection
  • TransactionCheckOptions - Configuration type

Breaking Changes

None - validation is enabled by default but non-breaking:

  • Only errors (insufficient box values) cause failures
  • Warnings (missing fees) are logged but don't fail
  • Use checks: false to disable validation

Testing

  • 14 new unit tests in transactionChecks.spec.ts
  • 4 integration tests in mockChain.spec.ts
  • All 67 tests passing

Closes #120

AdityaGupta20871 avatar Oct 06 '25 23:10 AdityaGupta20871

⚠️ No Changeset found

Latest commit: e99ee3181db1d862ef200f7e6d1353bfa557d3b7

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

changeset-bot[bot] avatar Oct 06 '25 23:10 changeset-bot[bot]

@arobsn LMK if any changes are needed! :)

AdityaGupta20871 avatar Oct 06 '25 23:10 AdityaGupta20871

Codecov Report

:x: Patch coverage is 93.33333% with 8 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 99.94%. Comparing base (69c8309) to head (e99ee31).

Files with missing lines Patch % Lines
packages/mock-chain/src/mockChain.ts 77.77% 4 Missing :warning:
packages/mock-chain/src/transactionChecks.ts 96.07% 4 Missing :warning:
Additional details and impacted files
@@             Coverage Diff             @@
##            master     #205      +/-   ##
===========================================
- Coverage   100.00%   99.94%   -0.06%     
===========================================
  Files          124      125       +1     
  Lines        14204    14324     +120     
  Branches      1778     1808      +30     
===========================================
+ Hits         14204    14316     +112     
- Misses           0        8       +8     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Oct 07 '25 00:10 codecov[bot]

@fleet-sdk/blockchain-providers

npm i https://pkg.pr.new/@fleet-sdk/blockchain-providers@205
@fleet-sdk/common

npm i https://pkg.pr.new/@fleet-sdk/common@205
@fleet-sdk/compiler

npm i https://pkg.pr.new/@fleet-sdk/compiler@205
@fleet-sdk/core

npm i https://pkg.pr.new/@fleet-sdk/core@205
@fleet-sdk/crypto

npm i https://pkg.pr.new/@fleet-sdk/crypto@205
@fleet-sdk/mock-chain

npm i https://pkg.pr.new/@fleet-sdk/mock-chain@205
@fleet-sdk/serializer

npm i https://pkg.pr.new/@fleet-sdk/serializer@205
@fleet-sdk/wallet

npm i https://pkg.pr.new/@fleet-sdk/wallet@205
@fleet-sdk/ageusd-plugin

npm i https://pkg.pr.new/@fleet-sdk/ageusd-plugin@205
@fleet-sdk/babel-fees-plugin

npm i https://pkg.pr.new/@fleet-sdk/babel-fees-plugin@205

commit: e99ee31

pkg-pr-new[bot] avatar Oct 07 '25 00:10 pkg-pr-new[bot]

@arobsn Fixed! The CI failures were due to: Lint/format issues in my files which should be resolved (removed unused import, fixed template literals, fixed formatting) Can you review it again! It also build successfully

AdityaGupta20871 avatar Oct 07 '25 14:10 AdityaGupta20871