Merged
Conversation
|
Contract comparison - from 3984924 to 6768878
|
Contributor
There was a problem hiding this comment.
Pull request overview
Introduces a new math module in multiversx_sc that exposes linear interpolation and weighted-average helpers, and relocates internal logarithm polynomial utilities under the new module while adding corresponding unit + scenario coverage.
Changes:
- Added
math::linear_interpolation,math::weighted_average, andmath::weighted_average_round_upAPIs. - Moved the internal
logarithm_i64implementation behindmath::internal_logarithm_i64and updatedBigUint/ManagedDecimalcall sites. - Added base/scenario tests and a feature-test contract + scenario to exercise the new math APIs.
Reviewed changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| framework/scenario/tests/math_managed_test.rs | Adds scenario-level tests for math APIs using managed types. |
| framework/base/tests/math_test.rs | Adds base unit tests for linear interpolation and weighted average functions. |
| framework/base/src/types/math_util.rs | Removes the old math_util module entry (logarithm code moved). |
| framework/base/src/types/managed/wrapped/num/big_uint.rs | Updates ln() to call crate::math::internal_logarithm_i64. |
| framework/base/src/types/managed/wrapped/managed_decimal/managed_decimal_logarithm.rs | Updates ln/log2 computations to use crate::math::internal_logarithm_i64. |
| framework/base/src/types.rs | Stops exposing math_util from the types module tree. |
| framework/base/src/math/weighted_average.rs | Implements weighted average helpers (including round-up variant). |
| framework/base/src/math/linear_interpolation.rs | Implements a generic linear interpolation helper with range checking. |
| framework/base/src/math/internal_logarithm_i64.rs | Adds internal polynomial approximation helpers for ln/log2 (i64 scaled). |
| framework/base/src/math.rs | Defines the new math module and re-exports math helpers. |
| framework/base/src/lib.rs | Exposes the new pub mod math at the crate root. |
| contracts/feature-tests/basic-features/tests/basic_features_scenario_rs_test.rs | Adds a new Rust scenario test that runs math_features.scen.json. |
| contracts/feature-tests/basic-features/tests/basic_features_scenario_go_test.rs | Adds a new Go scenario test that runs math_features.scen.json. |
| contracts/feature-tests/basic-features/src/math_features.rs | Adds endpoints exercising the new math functions in a test contract. |
| contracts/feature-tests/basic-features/src/basic_features_main.rs | Wires the new MathFeatures module into the basic-features contract. |
| contracts/feature-tests/basic-features/scenarios/math_features.scen.json | Adds scenario coverage for weighted average and linear interpolation endpoints. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
contracts/feature-tests/basic-features/scenarios/math_features.scen.json
Outdated
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull request overview
Introduces a new
mathmodule inmultiversx_scthat exposes linear interpolation and weighted-average helpers, and relocates internal logarithm polynomial utilities under the new module while adding corresponding unit + scenario coverage.Changes:
math::linear_interpolation,math::weighted_average, andmath::weighted_average_round_upAPIs.logarithm_i64implementation behindmath::internal_logarithm_i64and updatedBigUint/ManagedDecimalcall sites.