Order book refactor (FungiblePayment) + big num proportion methods#2276
Order book refactor (FungiblePayment) + big num proportion methods#2276andrei-marinica merged 19 commits intomasterfrom
Conversation
|
Contract comparison - from dcf00bb to ebb1f7c
|
There was a problem hiding this comment.
Pull request overview
Refactors the order-book example contract to use the framework’s FungiblePayment / NonZeroBigUint types and introduces proportion/into_proportion helpers for big number types, with added scenario tests for these new helpers.
Changes:
- Added
proportion/into_proportionAPIs onBigInt,BigUint, andNonZeroBigUint. - Refactored the order-book example to use
FungiblePaymentandNonZeroBigUintamounts. - Added/expanded scenario tests for proportion behavior (including
NonZeroBigUintpanic behavior).
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| framework/scenario/tests/non_zero_big_uint_test.rs | Adds tests for NonZeroBigUint proportion behavior and panic on zero result. |
| framework/scenario/tests/big_uint_test.rs | Adds BigUint proportion tests alongside existing ln tests. |
| framework/scenario/tests/big_int_test.rs | Adds BigInt proportion tests. |
| framework/base/src/types/managed/wrapped/num/non_zero_big_uint_operators.rs | Exposes an internal helper (wrap_big_int_assert_gt_zero) for use by new APIs. |
| framework/base/src/types/managed/wrapped/num/non_zero_big_uint.rs | Adds NonZeroBigUint::{proportion, into_proportion} with rustdoc. |
| framework/base/src/types/managed/wrapped/num/big_uint.rs | Adds BigUint::{proportion, into_proportion} and new_unchecked, with rustdoc. |
| framework/base/src/types/managed/basic/big_int.rs | Makes overwrite_i64 mutable and adds BigInt::{proportion, into_proportion}. |
| contracts/feature-tests/basic-features/src/big_num_methods.rs | Updates endpoint to pass BigInt as mutable due to signature change. |
| contracts/examples/order-book/pair/src/validation.rs | Switches to FungiblePayment/NonZeroBigUint and updates fee/payment validation logic. |
| contracts/examples/order-book/pair/src/orders.rs | Refactors order processing to use new payment/amount types and new proportion helpers. |
| contracts/examples/order-book/pair/src/common.rs | Replaces custom payment struct with FungiblePayment and makes order amounts non-zero. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
framework/base/src/types/managed/wrapped/num/non_zero_big_uint.rs
Outdated
Show resolved
Hide resolved
framework/base/src/types/managed/wrapped/num/non_zero_big_uint.rs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Pull request overview
Refactors the order-book example contract to use the framework’s
FungiblePayment/NonZeroBigUinttypes and introducesproportion/into_proportionhelpers for big number types, with added scenario tests for these new helpers.Changes:
proportion/into_proportionAPIs onBigInt,BigUint.NonZeroBigUintas well, but it is not helpful, since there are no clean mathematical mechanisms of preserving the non-zero invariant. Ultimately dropped.FungiblePaymentandNonZeroBigUintamounts.NonZeroBigUintpanic behavior).