Open joemonem opened 3 months ago
The recent changes enhance the handling of rates across multiple contracts by transitioning from single Rate
instances to vectors (Vec<Rate>
). This change allows for batch processing of rates, significantly improving flexibility and enabling the management of multiple rates simultaneously. Key updates include modifications to function signatures, message structures, and testing logic, ultimately enriching the contracts' functionality and adaptability in varied scenarios.
Files | Change Summary |
---|---|
contracts/data-storage/.../execute.rs contracts/data-storage/.../mock.rs contracts/data-storage/.../testing/tests.rs |
Updated to handle multiple rates (Vec<Rate> ) instead of a single rate across execution and mocking functions. |
contracts/fungible-tokens/.../mock.rs contracts/fungible-tokens/.../testing/tests.rs |
Similar updates for rate handling in execution and test functions, changing parameters to accept vectors. |
contracts/non-fungible-tokens/.../mock.rs contracts/non-fungible-tokens/.../testing/tests.rs |
Modified to utilize vectors of rates in mock and test implementations, enhancing rate management. |
contracts/non-fungible-tokens/.../marketplace/src/mock.rs contracts/non-fungible-tokens/.../marketplace/src/testing/tests.rs |
Adjusted to support vectors for rates in method signatures and test cases, improving flexibility. |
packages/std/src/.../rates.rs packages/std/src/.../rates.rs |
Enum RatesMessage modified to include vectors; functions updated to accommodate multiple rates. |
packages/std/src/.../ado_contract/rates.rs |
ADOContract methods updated to handle collections of rates, improving management and flexibility. |
tests-integration/tests/.../auction_app.rs |
Test updates to include multiple rates, reflecting changes in expected distributions and balances. |
tests-integration/tests/.../cw20_app.rs |
Modified to handle rate vectors in testing, allowing for more flexible rate configurations. |
tests-integration/tests/.../marketplace_app.rs |
Adjustments made to utilize vectors for Rate::Contract in function calls, increasing function flexibility. |
tests-integration/tests/.../primitive.rs |
Changes made to wrap Rate::Local instances in vectors for consistency with new handling logic. |
CHANGELOG.md |
Added entry for "Multiple Rates" associated with pull request #517 to document the new feature. |
sequenceDiagram
participant User
participant Contract
participant MessageHandler
participant RateProcessor
User->>Contract: Send RatesMessage(SetRate)
Contract->>MessageHandler: Process RatesMessage
MessageHandler->>RateProcessor: Execute with Vec<Rate>
RateProcessor->>RateProcessor: Validate each Rate
RateProcessor-->>MessageHandler: Return results
MessageHandler-->>Contract: Response to User
π° Hopping through the fields so bright,
Rates gathered up, what a lovely sight!
From one to many, a grand new way,
Flexibility blooms in the light of day!
Letβs set the rates, let creativity soar,
In our contract garden, thereβs always more! πΌ
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Motivation
Allow multiple rates to be set per action.
Implementation
Each action now has a corresponding
Vec<Rate>
instead ofRate
Changes have been made toquery_deducted_funds
to accommodate multiple rates:Testing
The auction integration test was adjusted to have multiple rates:
In that test, the sent funds were 100. Adding the second rate resulted in an additional 10 coins being sent to
recipient_one
andrecipient_two
, alongside a decrease of 20 coins to the owner's balance.Version Changes
No version changes have been made yet. Should the version bump be for all the contracts which use rates or just
andromeda-std
?Notes
remove_rates
removes the entire vector of rates. If a user wants to modify the rates without removing them all,set_rate
can be used since the new rates overwrite the old ones. We should test scenarios like a mix of taxes and royalties, insufficient funds to cover all the taxes, and other possible edge cases. The rates contract still only holds oneLocalRate
per action, but now multiple rates contracts can be referenced simultaneously.Summary by CodeRabbit
RatesMessage
and associated functions to support batch processing of rates.