-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Multiple Rates #517
feat: Multiple Rates #517
Conversation
WalkthroughThe recent changes enhance the handling of rates across multiple contracts by transitioning from single Changes
Sequence Diagram(s)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
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? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Outside diff range, codebase verification and nitpick comments (2)
contracts/non-fungible-tokens/andromeda-marketplace/src/testing/tests.rs (1)
Issues Found: Inconsistent Usage of New
set_rates
SignatureThe following instances of
set_rates
do not use the new signature withVec<Rate>
:
contracts/fungible-tokens/andromeda-cw20/src/testing/tests.rs
- Lines: 1-5, 8-12
contracts/non-fungible-tokens/andromeda-auction/src/testing/tests.rs
- Lines: 1-5, 8-12, 15-19
contracts/non-fungible-tokens/andromeda-marketplace/src/testing/tests.rs
- Lines: 1-5, 8-12, 15-19
contracts/data-storage/andromeda-primitive/src/testing/tests.rs
- Lines: 1-5
Please update these instances to match the new signature with
Vec<Rate>
.Analysis chain
Line range hint
790-801
:
LGTM! But verify the function usage in the codebase.The code changes are approved.
However, ensure that all function calls to
set_rates
match the new signature with a vector of rates.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `set_rates` match the new signature. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type rust -A 5 $'set_rates'Length of output: 9535
Script:
#!/bin/bash # Description: Verify that all instances of `set_rates` use the new signature with `Vec<Rate>`. # Check if all `set_rates` function calls use the new signature with `Vec<Rate>`. rg --type rust --pcre2 'set_rates\(\s*deps\.as_mut\(\)\.storage,\s*"[A-Za-z]+",\s*vec!\['Length of output: 91
Script:
#!/bin/bash # Description: Verify that all instances of `set_rates` use the new signature with `Vec<Rate>`. # Check if all `set_rates` function calls use the new signature with `Vec<Rate>`. rg --type rust 'set_rates\(\s*deps\.as_mut\(\)\.storage,\s*".*",\s*\w+\s*\)' -A 3Length of output: 4144
tests-integration/tests/marketplace_app.rs (1)
568-568
: Inconsistent function signature forexecute_set_rate
The function
execute_set_rate
has been updated to accept a vector of rates in some parts of the codebase, but not consistently.
contracts/modules/andromeda-rates/src/contract.rs
still uses the old signature with a single rate.Please update the function signature in
contracts/modules/andromeda-rates/src/contract.rs
to match the new signature that accepts a vector of rates.Analysis chain
LGTM! But verify the function usage in the codebase.
The code changes are approved.
However, ensure that all function calls to
execute_set_rate
match the new signature with a vector of rates.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `execute_set_rate` match the new signature. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type rust -A 5 $'execute_set_rate'Length of output: 3712
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
Cargo.lock
is excluded by!**/*.lock
Files selected for processing (16)
- contracts/data-storage/andromeda-primitive/src/execute.rs (1 hunks)
- contracts/data-storage/andromeda-primitive/src/mock.rs (2 hunks)
- contracts/data-storage/andromeda-primitive/src/testing/tests.rs (3 hunks)
- contracts/fungible-tokens/andromeda-cw20/src/mock.rs (2 hunks)
- contracts/fungible-tokens/andromeda-cw20/src/testing/tests.rs (4 hunks)
- contracts/non-fungible-tokens/andromeda-auction/src/mock.rs (2 hunks)
- contracts/non-fungible-tokens/andromeda-auction/src/testing/tests.rs (6 hunks)
- contracts/non-fungible-tokens/andromeda-marketplace/src/mock.rs (2 hunks)
- contracts/non-fungible-tokens/andromeda-marketplace/src/testing/tests.rs (6 hunks)
- packages/std/src/ado_base/rates.rs (1 hunks)
- packages/std/src/ado_contract/rates.rs (8 hunks)
- packages/std/src/ado_contract/state.rs (1 hunks)
- tests-integration/tests/auction_app.rs (2 hunks)
- tests-integration/tests/cw20_app.rs (2 hunks)
- tests-integration/tests/marketplace_app.rs (4 hunks)
- tests-integration/tests/primitive.rs (2 hunks)
Additional comments not posted (34)
packages/std/src/ado_contract/state.rs (1)
16-16
: LGTM! But verify the usage of therates
field in the codebase.The change to store multiple rates per action enhances flexibility.
However, ensure that all usages of the
rates
field are compatible with the new type.contracts/data-storage/andromeda-primitive/src/mock.rs (2)
64-66
: LGTM!The change to accept a vector of
Rate
objects enhances flexibility.
112-113
: LGTM!The change to accept a vector of
Rate
objects enhances flexibility.tests-integration/tests/cw20_app.rs (1)
Line range hint
102-112
:
LGTM!The change to wrap the
Rate::Local
instantiation in a vector enhances flexibility and is consistent with the updated functionality.contracts/non-fungible-tokens/andromeda-marketplace/src/mock.rs (2)
66-68
: LGTM!The function
execute_set_rate
has been updated to accept aVec<Rate>
, which aligns with the new requirement to handle multiple rates.
153-156
: LGTM!The function
mock_set_rates
has been updated to accept aVec<Rate>
, which aligns with the new requirement to handle multiple rates.contracts/data-storage/andromeda-primitive/src/execute.rs (1)
37-47
: LGTM!The function
handle_execute
has been updated to handle multiple rates. The logic iterates through each rate and validates it before executing the contract. This change is consistent with the new requirement to handle multiple rates.contracts/fungible-tokens/andromeda-cw20/src/mock.rs (2)
126-128
: LGTM!The function
execute_add_rate
has been updated to accept aVec<Rate>
, which aligns with the new requirement to handle multiple rates.
223-224
: LGTM!The function
mock_set_rate_msg
has been updated to accept aVec<Rate>
, which aligns with the new requirement to handle multiple rates.tests-integration/tests/primitive.rs (2)
87-94
: LGTM! The change to wrapRate::Local(LocalRate)
in a vector is consistent with the new structure.The test logic for adding a percentage rate remains valid.
107-112
: LGTM! The change to wrapRate::Local(LocalRate)
in a vector is consistent with the new structure.The test logic for adding a flat rate remains valid.
contracts/non-fungible-tokens/andromeda-auction/src/mock.rs (2)
110-112
: LGTM! The change to update the function parameter to accept a vector ofRate
objects is consistent with the new structure.The function call and internal logic remain valid.
232-233
: LGTM! The change to update the function parameter to accept a vector ofRate
objects is consistent with the new structure.The message construction logic remains valid.
packages/std/src/ado_base/rates.rs (1)
31-31
: LGTM! The change to modify theSetRate
variant to accept a vector ofRate
objects is consistent with the new structure.The enum variant and related logic remain valid.
packages/std/src/ado_contract/rates.rs (7)
15-17
: LGTM!The function
rates
has been updated to returnMap<'a, &'a str, Vec<Rate>>
to handle multiple rates. This change is correct and aligns with the new requirement.
23-28
: LGTM!The function
set_rates
has been updated to accept aVec<Rate>
instead of a singleRate
. This change is correct and aligns with the new requirement.
35-37
: LGTM!The function
execute_rates
has been updated to handleRatesMessage::SetRate
with aVec<Rate>
. This change is correct and aligns with the new requirement.
43-56
: LGTM!The function
execute_set_rates
has been updated to accept aVec<Rate>
instead of a singleRate
. The function validates each rate and saves them to storage. This change is correct and aligns with the new requirement.
Line range hint
105-166
: LGTM!The function
query_deducted_funds
has been updated to handle multiple rates. The function iterates over each rate and generates corresponding messages, events, and leftover funds. This change is correct and aligns with the new requirement.
91-93
: LGTM!The function
get_rates
has been updated to returnOption<Vec<Rate>>
instead ofOption<Rate>
. This change is correct and aligns with the new requirement.
Line range hint
200-209
: LGTM!The test
test_rates_crud
has been updated to handle multiple rates. The test correctly sets, gets, and removes multiple rates. This change is correct and aligns with the new requirement.contracts/fungible-tokens/andromeda-cw20/src/testing/tests.rs (2)
Line range hint
90-101
: LGTM!The function
test_transfer
has been updated to handle multiple rates by wrappingRate::Local
instances in avec![]
. This change is correct and aligns with the new requirement.
Line range hint
196-207
: LGTM!The function
test_send
has been updated to handle multiple rates by wrappingRate::Local
instances in avec![]
. This change is correct and aligns with the new requirement.contracts/data-storage/andromeda-primitive/src/testing/tests.rs (2)
73-80
: LGTM!The function
test_set_value_with_tax
has been updated to handle multiple rates by wrappingRate::Local
instances in avec![]
. This change is correct and aligns with the new requirement.
Line range hint
93-102
: LGTM!The function
test_set_value_with_tax
has been updated to handle multiple rates by wrappingRate::Local
instances in avec![]
. This change is correct and aligns with the new requirement.contracts/non-fungible-tokens/andromeda-marketplace/src/testing/tests.rs (2)
Line range hint
713-724
:
LGTM! But verify the function usage in the codebase.The code changes are approved.
However, ensure that all function calls to
set_rates
match the new signature with a vector of rates.Verification successful
Function usage verification successful.
All instances of the
set_rates
function call match the new signature with a vector of rates.
- Verified locations:
packages/std/src/ado_contract/rates.rs
contracts/data-storage/andromeda-primitive/src/testing/tests.rs
contracts/non-fungible-tokens/andromeda-marketplace/src/mock.rs
contracts/non-fungible-tokens/andromeda-marketplace/src/testing/tests.rs
contracts/non-fungible-tokens/andromeda-cw721/src/testing/mod.rs
contracts/non-fungible-tokens/andromeda-auction/src/testing/tests.rs
contracts/fungible-tokens/andromeda-cw20/src/testing/tests.rs
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `set_rates` match the new signature. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type rust -A 5 $'set_rates'Length of output: 9535
Line range hint
658-669
:
LGTM! But verify the function usage in the codebase.The code changes are approved.
However, ensure that all function calls to
set_rates
match the new signature with a vector of rates.Verification successful
The new signature of
set_rates
is consistently used throughout the codebase.The changes are correctly propagated and match the new functionality of handling multiple rates. No further action is required.
- Verified in:
contracts/non-fungible-tokens/andromeda-marketplace/src/mock.rs
contracts/non-fungible-tokens/andromeda-marketplace/src/testing/tests.rs
contracts/non-fungible-tokens/andromeda-auction/src/testing/tests.rs
contracts/fungible-tokens/andromeda-cw20/src/testing/tests.rs
packages/std/src/ado_contract/rates.rs
contracts/data-storage/andromeda-primitive/src/testing/tests.rs
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `set_rates` match the new signature. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type rust -A 5 $'set_rates'Length of output: 9535
tests-integration/tests/marketplace_app.rs (2)
140-140
: LGTM! But verify the function usage in the codebase.The code changes are approved.
However, ensure that all function calls to
execute_set_rate
match the new signature with a vector of rates.
866-866
: LGTM! But verify the function usage in the codebase.The code changes are approved.
However, ensure that all function calls to
execute_set_rate
match the new signature with a vector of rates.Verification successful
Verify all instances of
execute_set_rate
andexecute_set_rates
conform to the new signature.The code changes are approved.
However, ensure that all instances of
execute_set_rate
andexecute_set_rates
match the new signature with a vector of rates.
All instances of
execute_set_rate
andexecute_set_rates
conform to the new signature.The code changes are approved.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `execute_set_rate` match the new signature. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type rust -A 5 $'execute_set_rate'Length of output: 3712
Script:
#!/bin/bash # Description: Verify all instances of `execute_set_rate` and `execute_set_rates` conform to the new signature. # Test: Search for the function definitions and usages in the mentioned files. # Verify function definitions echo "Function definitions:" rg --type rust -A 5 $'fn execute_set_rate' packages/std/src/ado_contract/rates.rs contracts/non-fungible-tokens/andromeda-marketplace/src/mock.rs contracts/modules/andromeda-rates/src/contract.rs rg --type rust -A 5 $'fn execute_set_rates' packages/std/src/ado_contract/rates.rs # Verify function usages echo "Function usages:" rg --type rust -A 5 $'execute_set_rate' packages/std/src/ado_contract/rates.rs contracts/non-fungible-tokens/andromeda-marketplace/src/mock.rs contracts/modules/andromeda-rates/src/contract.rs rg --type rust -A 5 $'execute_set_rates' packages/std/src/ado_contract/rates.rsLength of output: 4961
tests-integration/tests/auction_app.rs (2)
238-242
: Update balance assertions to reflect new rate structure.The balance assertions have been updated to reflect the new distribution of values among the involved parties.
120-143
: LGTM! But verify the function usage in the codebase.The code changes are approved.
However, ensure that all function calls to
execute_add_rate
match the new signature with a vector of rates.Verification successful
All occurrences of
execute_add_rate
match the new signature.The function calls to
execute_add_rate
across various files have been verified to match the new signature that includes a vector of rates.
tests-integration/tests/primitive.rs
tests-integration/tests/cw20_app.rs
tests-integration/tests/auction_app.rs
contracts/non-fungible-tokens/andromeda-auction/src/mock.rs
contracts/data-storage/andromeda-primitive/src/mock.rs
contracts/fungible-tokens/andromeda-cw20/src/mock.rs
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `execute_add_rate` match the new signature. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type rust -A 5 $'execute_add_rate'Length of output: 3197
contracts/non-fungible-tokens/andromeda-auction/src/testing/tests.rs (3)
Line range hint
1490-1501
:
LGTM! But verify the function usage in the codebase.The code changes are approved.
However, ensure that all function calls to
execute_claim_cw20_with_tax
match the newrate
data structure.Verification successful
No further verification needed.
The function
execute_claim_cw20_with_tax
is not called elsewhere in the codebase, confirming that the changes to therate
data structure are self-contained. Therefore, no additional verification is required.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `execute_claim_cw20_with_tax` match the new `rate` data structure. # Test: Search for the function usage. Expect: Only occurrences of the new data structure. rg --type rust -A 5 $'execute_claim_cw20_with_tax'Length of output: 710
Script:
#!/bin/bash # Description: Search for all instances where `execute_claim_cw20_with_tax` is called in the codebase. # Test: Search for function calls. Expect: Only occurrences of the new data structure. rg --type rust 'execute_claim_cw20_with_tax\('Length of output: 152
Line range hint
1241-1250
:
LGTM! But verify the function usage in the codebase.The code changes are approved.
However, ensure that all function calls to
execute_claim_with_tax
match the newrate
data structure.Verification successful
No issues found with the function usage.
The function
execute_claim_with_tax
is not called within the codebase, so there are no external usages to verify against the newrate
data structure.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all function calls to `execute_claim_with_tax` match the new `rate` data structure. # Test: Search for the function usage. Expect: Only occurrences of the new data structure. rg --type rust -A 5 $'execute_claim_with_tax'Length of output: 646
Script:
#!/bin/bash # Description: Find all call sites of `execute_claim_with_tax` and verify the `rate` data structure usage. # Search for all call sites of `execute_claim_with_tax` rg 'execute_claim_with_tax\(' --type rust -A 5Length of output: 650
Script:
#!/bin/bash # Description: Find all call sites of `execute_claim_with_tax` with extended context to ensure no call sites are missed. # Search for all call sites of `execute_claim_with_tax` with extended context rg 'execute_claim_with_tax\(' --type rust -A 10Length of output: 1215
Line range hint
1328-1337
:
LGTM! But verify the function usage in the codebase.The code changes are approved.
However, ensure that all function calls to
execute_claim_with_royalty
match the newrate
data structure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (13)
- contracts/data-storage/andromeda-primitive/src/execute.rs (1 hunks)
- contracts/data-storage/andromeda-primitive/src/testing/tests.rs (4 hunks)
- contracts/fungible-tokens/andromeda-cw20/src/testing/tests.rs (4 hunks)
- contracts/non-fungible-tokens/andromeda-auction/src/testing/tests.rs (6 hunks)
- contracts/non-fungible-tokens/andromeda-marketplace/src/mock.rs (2 hunks)
- contracts/non-fungible-tokens/andromeda-marketplace/src/testing/tests.rs (6 hunks)
- packages/std/src/ado_base/rates.rs (2 hunks)
- packages/std/src/ado_contract/execute.rs (2 hunks)
- packages/std/src/ado_contract/rates.rs (7 hunks)
- tests-integration/tests/auction_app.rs (2 hunks)
- tests-integration/tests/cw20_app.rs (2 hunks)
- tests-integration/tests/marketplace_app.rs (4 hunks)
- tests-integration/tests/primitive.rs (2 hunks)
Additional comments not posted (28)
tests-integration/tests/cw20_app.rs (1)
Line range hint
102-112
:
Ensure comprehensive test coverage for multiple rates.The change from a single
Rate::Local
to a vector of rates is consistent with the PR's objective to handle multiple rates. Ensure that the test thoroughly checks scenarios with multiple rates, including edge cases such as zero rates and conflicting rates.Verification successful
Comprehensive test coverage for multiple rates is present in the codebase. Although the
cw20_app.rs
file does not explicitly include tests for multipleRate::Local
instances, other test files such as those in theandromeda-marketplace
,andromeda-auction
, andandromeda-primitive
directories do cover these scenarios. This indicates that the functionality for handling multiple rates is being tested elsewhere.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the test covers multiple rates scenarios. # Test: Search for test functions that handle multiple rates. Expect: Comprehensive test cases. rg --type rust 'test_cw20_with_rates' -A 10 | rg 'vec!\[Rate::Local'Length of output: 68
Script:
#!/bin/bash # Search for test functions in the tests-integration/tests/cw20_app.rs file that involve multiple Rate::Local instances. fd 'cw20_app.rs' | xargs rg 'fn ' -A 10 | rg 'vec!\[Rate::Local'Length of output: 64
Script:
#!/bin/bash # Search for test functions across the tests-integration/tests directory that might involve multiple rates. fd 'tests' | xargs rg 'fn ' -A 20 | rg 'Rate::Local'Length of output: 848
contracts/non-fungible-tokens/andromeda-marketplace/src/mock.rs (2)
68-70
: Adapt to handle multiple rates inexecute_set_rate
.The
execute_set_rate
function now accepts a vector of rates, aligning with the PR's objective. Ensure that the logic within the function and any dependent components correctly processes each rate in the vector.
165-168
: Updatemock_set_rates
to handle multiple rates.The
mock_set_rates
function now accepts aVec<Rate>
, which enhances flexibility. Verify that all usages of this function are updated to pass vectors of rates, ensuring consistency across the codebase.Verification successful
All usages of
mock_set_rates
are consistent with vector inputs.The
mock_set_rates
function is used only once in the codebase, and it is correctly passed a vector of rates. No further updates are needed.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that all usages of `mock_set_rates` are updated to pass vectors of rates. # Test: Search for `mock_set_rates` function calls. Expect: Updated calls with vectors. rg --type rust 'mock_set_rates' -A 5Length of output: 1157
Script:
#!/bin/bash # Search for all instances of `mock_set_rates` across the codebase to verify consistent usage. rg 'mock_set_rates' --type rust -A 5Length of output: 1157
contracts/data-storage/andromeda-primitive/src/execute.rs (1)
33-43
: Verify rate processing logic inhandle_execute
.The
handle_execute
function now processes multiple rates, maintaining validation forRate::Local
. Ensure that the logic correctly handles different rate types and that the validation for local rates is robust.tests-integration/tests/primitive.rs (2)
87-94
: Ensure handling of multiple rates in tests.The change to wrap
Rate::Local
in a vector aligns with the new functionality of handling multiple rates. Ensure that the test logic correctly processes this vector and that assertions reflect the expected outcomes for multiple rates.
107-112
: Confirm correct integration of multiple rates.The wrapping of
Rate::Local
in a vector is consistent with the updated functionality. Ensure that the test scenarios adequately cover the implications of handling multiple rates.packages/std/src/ado_base/rates.rs (2)
31-31
: Verify handling of multiple rates inSetRate
.The
SetRate
variant now accepts a vector of rates, enhancing flexibility. Ensure that the logic processing this variant correctly handles multiple rates and that any related functions are updated accordingly.
251-251
: Ensure correct handling ofAllRatesResponse
.The
all_rates
field now holds a vector of tuples with vectors of rates, allowing for more complex rate management. Verify that the response handling logic is updated to accommodate this change and that all related functionality is tested.contracts/fungible-tokens/andromeda-cw20/src/testing/tests.rs (2)
Line range hint
90-101
: Validate handling of multiple rates intest_transfer
.The change to use a vector for
Rate::Local
aligns with the updated functionality. Ensure that the test logic correctly processes this vector and that assertions are updated to reflect the expected outcomes for multiple rates.
Line range hint
196-207
: Confirm correct integration of multiple rates intest_send
.The wrapping of
Rate::Local
in a vector is consistent with the updated functionality. Ensure that the test scenarios adequately cover the implications of handling multiple rates and that assertions are updated accordingly.packages/std/src/ado_contract/rates.rs (5)
13-15
: LGTM!The change to return a
Map
withVec<Rate>
aligns with the objective of supporting multiple rates.
29-60
: LGTM!The function correctly processes multiple rates, validating each and updating recipients as needed.
93-98
: LGTM!The function correctly retrieves a vector of rates for a given action.
Line range hint
103-115
: LGTM!The function correctly aggregates all rates into a vector of tuples, supporting the new multiple rates structure.
Line range hint
122-188
: LGTM!The function effectively processes multiple rates, calculating deducted funds and generating the appropriate response.
packages/std/src/ado_contract/execute.rs (1)
104-109
: LGTM!The pattern matching for
RatesMessage
enhances clarity and modularity in handling rate-related commands.contracts/data-storage/andromeda-primitive/src/testing/tests.rs (1)
Line range hint
73-129
: LGTM!The test effectively verifies the handling of multiple rates, ensuring correct functionality.
contracts/non-fungible-tokens/andromeda-marketplace/src/testing/tests.rs (3)
Line range hint
658-669
: LGTM! Transition to vector of rates is consistent.The change to use a vector for the
rate
variable is correct and aligns with the goal of supporting multiple rates.
Line range hint
713-724
: LGTM! Transition to vector of rates is consistent.The change to use a vector for the
rate
variable is correct and aligns with the goal of supporting multiple rates.
Line range hint
790-801
: LGTM! Transition to vector of rates is consistent.The change to use a vector for the
rate
variable is correct and aligns with the goal of supporting multiple rates.tests-integration/tests/marketplace_app.rs (3)
140-140
: LGTM! Transition to vector of rates is consistent.The change to use a vector for the
Rate
parameter is correct and aligns with the goal of supporting multiple rates.
586-586
: LGTM! Transition to vector of rates is consistent.The change to use a vector for the
Rate
parameter is correct and aligns with the goal of supporting multiple rates.
884-884
: LGTM! Transition to vector of rates is consistent.The change to use a vector for the
Rate
parameter is correct and aligns with the goal of supporting multiple rates.tests-integration/tests/auction_app.rs (2)
120-142
: LGTM! Enhanced rate configuration is consistent.The introduction of multiple
Rate::Local
instances with different percentage values is correct and aligns with the goal of supporting more complex rate configurations.
238-242
: LGTM! Balance assertions updated to match new rate configuration.The changes to the balance assertions are correct and align with the new rate configuration, ensuring accurate test verification.
contracts/non-fungible-tokens/andromeda-auction/src/testing/tests.rs (3)
Line range hint
1241-1250
: Transition to vector of rates is appropriate.Wrapping the
Rate::Local
instance in a vector aligns with the PR's objective of supporting multiple rates. The logic remains intact.
Line range hint
1328-1337
: Transition to vector of rates is appropriate.Wrapping the
Rate::Local
instance in a vector aligns with the PR's objective of supporting multiple rates. The logic remains intact.
Line range hint
1490-1501
: Transition to vector of rates is appropriate.Wrapping the
Rate::Local
instance in a vector, using a percentage rate, aligns with the PR's objective of supporting multiple rates. The logic remains intact.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- packages/std/src/ado_contract/rates.rs (6 hunks)
Additional comments not posted (7)
packages/std/src/ado_contract/rates.rs (7)
13-15
: LGTM!The change to return a
Map
with a vector ofRate
aligns with the requirement to handle multiple rates.
20-26
: LGTM!The function correctly delegates to
execute_set_rates
andexecute_remove_rates
, reflecting the updated logic for handling multiple rates.
28-38
: LGTM!The logic for storing a vector of rates for a given action is correctly implemented.
39-73
: LGTM!The function processes a vector of rates, ensuring validation and correct recipient updates, while enforcing contract ownership.
105-109
: LGTM!The function correctly returns an
Option<Vec<Rate>>
, aligning with the new structure for multiple rates.
Line range hint
111-123
: LGTM!The function correctly returns a vector of tuples with a string and a vector of rates, iterating over all stored rates.
Line range hint
125-199
: LGTM!The function accurately processes multiple rates, handling different fund types and calculating total deducted funds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
RatesMessage::SetRate { rates, .. } => { | ||
for rate in rates { | ||
match rate { | ||
Rate::Local(local_rate) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Refactor this to a rate.is_flat()
and rate.is_local()
} | ||
|
||
// Save the updated rates | ||
self.set_rates(ctx.deps.storage, action, rates)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is state breaking, we'd need a migration function for this for any current ADOs
We've decided to limit number of recipients per rate to one. A similar PR will be opened after this is merged. |
Motivation
Allow multiple rates to be set per action.
Implementation
Each action now has a corresponding
Vec<Rate>
instead ofRate
Changes have been made to
query_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 one
LocalRate
per action, but now multiple rates contracts can be referenced simultaneously.Summary by CodeRabbit
RatesMessage
and associated functions to support batch processing of rates.