-
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: Start Time for Permissions #668
Conversation
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThis pull request introduces a comprehensive enhancement to the permission handling mechanism across multiple Andromeda contracts. The primary change involves adding an optional Changes
Sequence DiagramsequenceDiagram
participant Owner
participant Contract
participant Permission
Owner->>Permission: Create permission with start and expiration times
Permission-->>Contract: Validate permission times
alt Permission start time not reached
Contract->>Permission: Deny access
else Permission start time passed
Contract->>Permission: Grant access
end
Assessment against linked issues
Possibly related PRs
Poem
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 using PR comments)
Other keywords and placeholders
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: 4
🧹 Outside diff range and nitpick comments (14)
contracts/data-storage/andromeda-boolean/src/contract.rs (1)
Line range hint
1-59
: Consider adding documentation for the permission timing behavior.Since this contract implements permission-based access control with timing constraints, it would be beneficial to add documentation explaining:
- The behavior when start_time is not reached
- The interaction between start_time and end_time
- The default behavior when both timing parameters are None
Add rustdoc comments above the
instantiate
function:/// Instantiates the boolean storage contract with optional permission timing constraints. /// /// # Arguments /// /// * `restriction` - Determines if the storage is private. If private, only whitelisted /// addresses can modify the value. /// * For private storage, permissions can have optional start and end times: /// - Before start_time: Access follows the opposite of the `strict` setting /// - Between start_time and end_time: Normal permission rules apply /// - After end_time: Permission expirescontracts/os/andromeda-ibc-registry/src/contract.rs (1)
59-61
: Consider adding start/end time validation.As noted in the PR objectives, there's currently no validation to prevent setting a start time that occurs after the end time. Consider adding this validation in the permission setting logic.
Would you like me to propose an implementation for the time validation logic?
packages/std/src/common/denom.rs (1)
162-163
: Consider adding start/end time validation.The permission construction correctly handles the optional expiration time. However, as noted in the PR objectives, there's currently no validation to prevent setting a start time that occurs after the end time. Consider adding this validation here.
Here's a suggested implementation:
let permission = expiration.map_or( Permission::Local(LocalPermission::whitelisted(None, None)), - |expiration| Permission::Local(LocalPermission::whitelisted(None, Some(expiration))), + |expiration| { + // When start time support is added, add validation here + // if let (Some(start), Some(end)) = (start_time, expiration) { + // ensure!( + // start <= end, + // ContractError::InvalidTimeRange { + // msg: "Start time must be before or equal to end time".to_string() + // } + // )?; + // } + Permission::Local(LocalPermission::whitelisted(None, Some(expiration))) + } );contracts/fungible-tokens/andromeda-cw20/src/testing/tests.rs (2)
115-115
: LGTM on permission constructor changes, but test coverage needs expansion.The updated constructor calls for
LocalPermission::blacklisted(None, None)
andLocalPermission::whitelisted(None, None)
align with the new API that supports start time. However, the current test only verifies basic permission functionality.Consider adding the following test cases to validate the new start time feature:
#[test] fn test_permission_with_start_time() { let mut deps = mock_dependencies_custom(&[]); let start = Expiry::AtTime(Timestamp::from_seconds(mock_env().block.time.seconds() + 100)); // Test future start time let permission = Permission::Local(LocalPermission::blacklisted(None, Some(start))); // ... verify is_permissioned returns true before start time // Test both start and end times let end = Expiry::AtTime(Timestamp::from_seconds(mock_env().block.time.seconds() + 200)); let permission = Permission::Local(LocalPermission::whitelisted(Some(end), Some(start))); // ... verify permission behavior before start, between start/end, and after end }Also applies to: 128-128
Line range hint
115-128
: Add validation for start/end time ordering.The PR notes there's currently no validation to prevent setting a start time that occurs after the end time. This could lead to unexpected behavior.
Consider adding validation tests and implementing the validation:
#[test] fn test_invalid_permission_times() { let mut deps = mock_dependencies_custom(&[]); let earlier = Expiry::AtTime(Timestamp::from_seconds(mock_env().block.time.seconds() + 100)); let later = Expiry::AtTime(Timestamp::from_seconds(mock_env().block.time.seconds() + 200)); // Should fail when start time is after end time let result = Permission::Local(LocalPermission::whitelisted(Some(earlier), Some(later))); assert!(matches!(result, Err(ContractError::InvalidStartTime { .. }))); // Should succeed when times are properly ordered let result = Permission::Local(LocalPermission::whitelisted(Some(later), Some(earlier))); assert!(result.is_ok()); }contracts/modules/andromeda-address-list/src/testing/tests.rs (1)
Line range hint
1-300
: Add test coverage for start time functionality.The test file needs additional test cases to cover the new start time feature:
- Test start time behavior for whitelisted permissions
- Test start time behavior for blacklisted permissions
- Test start time behavior for limited permissions
- Test interaction between start time and end time
- Test edge cases with invalid start/end time combinations
Here's a suggested test case structure:
#[test] fn test_permission_start_time() { let mut deps = mock_dependencies_custom(&[]); let env = mock_env(); let info = mock_info("creator", &[]); // Setup timestamp for testing let now = env.block.time; let future = now.plus_seconds(100); let past = now.minus_seconds(100); // Test cases to add: // 1. Whitelisted permission with future start time let permission = LocalPermission::whitelisted(Some(future), None); // Verify is_permissioned returns false before start time // Verify is_permissioned returns true after start time // 2. Blacklisted permission with future start time let permission = LocalPermission::blacklisted(Some(future), None); // Verify is_permissioned returns true before start time // Verify is_permissioned returns false after start time // 3. Limited permission with future start time let permission = LocalPermission::limited(Some(future), None, 5); // Verify is_permissioned behavior before and after start time // 4. Test start time after end time let permission = LocalPermission::whitelisted(Some(future), Some(past)); // Verify behavior or validate that this is prevented }Would you like me to create a GitHub issue to track this test coverage task?
contracts/fungible-tokens/andromeda-merkle-airdrop/src/contract.rs (1)
72-72
: Consider adding validation for start/end time relationshipThe change correctly implements start time support for permissions. However, as noted in the PR description, there's no validation to prevent setting a start time that occurs after the end time, which could lead to unexpected behavior.
Consider adding validation in the
LocalPermission::whitelisted
constructor to ensure that when both times are provided, start_time ≤ end_time.contracts/non-fungible-tokens/andromeda-crowdfund/src/contract.rs (2)
Line range hint
385-394
: Add validation for start time being in the futureWhile the code validates that start time is before end time, it should also validate that the start time is in the future when provided. This would prevent accidentally setting a start time in the past.
Apply this diff to add the validation:
ensure!( start_time_milliseconds.map_or(end_time_milliseconds > current_time, |start| start - <= end_time_milliseconds), + <= end_time_milliseconds && start > current_time), if start_time_milliseconds.is_some() { ContractError::StartTimeAfterEndTime {} } else { ContractError::InvalidExpiration {} } );
Line range hint
385-394
: Encapsulate time validation in the Duration structConsider moving the time validation logic into the
Duration
struct to ensure consistent validation across all usage points. This would also make it easier to add validation preventing start time from being after end time, as mentioned in the PR objectives.Consider implementing validation methods in the Duration struct:
impl Duration { pub fn validate(&self, current_time: Milliseconds) -> Result<(), ContractError> { if let Some(start_time) = self.start_time { ensure!( start_time > current_time, ContractError::InvalidStartTime {} ); ensure!( start_time <= self.end_time, ContractError::StartTimeAfterEndTime {} ); } ensure!( self.end_time > current_time, ContractError::InvalidExpiration {} ); Ok(()) } }contracts/non-fungible-tokens/andromeda-auction/src/contract.rs (1)
Line range hint
312-319
: Consider adding start/end time validation for permissions.The PR objectives mention that there's no validation to prevent setting a start time that occurs after the end time. Consider adding this validation when setting permissions.
Would you like me to propose an implementation for the validation logic?
Also applies to: 426-433
packages/std/src/ado_base/permissioning.rs (2)
69-72
: Ensure the defaultWhitelisted
permission aligns with expected security policiesSetting the default permission to
Whitelisted
withstart
andexpiration
asNone
effectively grants indefinite permission starting immediately. This might not align with the desired security posture.Consider whether the default should be more restrictive, or make it explicit that the default is an open permission. Alternatively, you could require explicit
start
andexpiration
times to avoid unintended permission grants.
Line range hint
95-134
: Simplify and refactor theis_permissioned
method for better readabilityThe
is_permissioned
method contains repeated code blocks for checkingstart
times. This repetition can be reduced to improve maintainability.Refactor the
is_permissioned
method to extract common logic:pub fn is_permissioned(&self, env: &Env, strict: bool) -> bool { let current_time = env.block.time; let started = |start: &Option<Expiry>| { start .as_ref() .map_or(true, |s| s.get_time(&env.block).is_expired(&env.block)) }; let not_expired = |expiration: &Option<Expiry>| { expiration .as_ref() .map_or(true, |e| !e.get_time(&env.block).is_expired(&env.block)) }; match self { Self::Blacklisted { start, expiration } => { if !started(start) { return true; } if !not_expired(expiration) { return !strict; } false } Self::Limited { start, expiration, uses } => { if !started(start) { return true; } if !not_expired(expiration) || *uses == 0 { return !strict; } true } Self::Whitelisted { start, expiration } => { if !started(start) { return !strict; } if !not_expired(expiration) { return !strict; } true } } }tests-integration/tests/validator_staking.rs (1)
279-279
: Consider adding tests forstart_time
andend_time
scenarios.To ensure the robustness of the permissioning system, it would be beneficial to add test cases that cover scenarios where
start_time
andend_time
are utilized. This includes edge cases such as when thestart_time
is after theend_time
, or when the current time is before thestart_time
.tests-integration/tests/auction_app.rs (1)
615-618
: Consider adding tests with specificstart_time
andend_time
for permissionsCurrently, permissions are set with
None
for bothstart_time
andend_time
. To fully validate the new permission timing features, consider adding tests where these parameters are set to specific values to ensure that permissions are correctly enforced over time.
📜 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 (14)
contracts/data-storage/andromeda-boolean/src/contract.rs
(1 hunks)contracts/fungible-tokens/andromeda-cw20/src/testing/tests.rs
(2 hunks)contracts/fungible-tokens/andromeda-merkle-airdrop/src/contract.rs
(1 hunks)contracts/modules/andromeda-address-list/src/testing/tests.rs
(1 hunks)contracts/non-fungible-tokens/andromeda-auction/src/contract.rs
(2 hunks)contracts/non-fungible-tokens/andromeda-crowdfund/src/contract.rs
(1 hunks)contracts/non-fungible-tokens/andromeda-marketplace/src/testing/tests.rs
(6 hunks)contracts/os/andromeda-ibc-registry/src/contract.rs
(1 hunks)packages/std/Cargo.toml
(1 hunks)packages/std/src/ado_base/permissioning.rs
(4 hunks)packages/std/src/ado_contract/permissioning.rs
(16 hunks)packages/std/src/common/denom.rs
(2 hunks)tests-integration/tests/auction_app.rs
(3 hunks)tests-integration/tests/validator_staking.rs
(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- packages/std/Cargo.toml
🔇 Additional comments (23)
contracts/data-storage/andromeda-boolean/src/contract.rs (2)
59-59
: Verify the new whitelisted
method parameters align with PR objectives.
The change from LocalPermission::Whitelisted(None)
to LocalPermission::whitelisted(None, None)
appears to implement the start time functionality, but let's verify the method signature and documentation.
✅ Verification successful
Let me gather more information about the LocalPermission
implementation since the previous search didn't show the complete method definition.
Let me search for the LocalPermission
enum definition since we need to verify the whitelisted
method.
Let me get the complete definition of the Whitelisted
variant since it was cut off.
The whitelisted
method implementation aligns with PR objectives
The change from direct variant construction to using LocalPermission::whitelisted(None, None)
is correct. The method properly implements the start time functionality as:
- The
whitelisted
method accepts bothstart
andexpiration
parameters of typeOption<Expiry>
- The implementation in
packages/std/src/ado_base/permissioning.rs
shows proper handling of start time in theis_permissioned
method - Tests demonstrate the start time functionality working as expected
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify the LocalPermission::whitelisted method implementation
# Expected: Method should accept start_time and end_time parameters of type Option<Expiry>
# Search for the whitelisted method definition
ast-grep --pattern 'impl LocalPermission {
$$$
fn whitelisted($$$) {
$$$
}
$$$
}'
# Search for any related tests
rg -A 5 "test.*permission.*start_time"
Length of output: 624
Script:
#!/bin/bash
# Search for LocalPermission definition and implementation in the codebase
rg -A 10 "enum LocalPermission|struct LocalPermission"
# Search specifically in the std package where we found the test
cat packages/std/src/ado_contract/permissioning.rs
Length of output: 45511
Script:
#!/bin/bash
# Search for LocalPermission enum definition
rg -A 10 "enum LocalPermission" packages/std/src/ado_base/permissioning.rs
Length of output: 320
Script:
#!/bin/bash
# Get the complete LocalPermission enum definition
cat packages/std/src/ado_base/permissioning.rs
Length of output: 7255
Line range hint 1-120
: Consider validating start_time against end_time.
As noted in the PR objectives, there's currently no validation to prevent setting a start time that occurs after the end time. While this validation might belong in the LocalPermission
implementation, it would be good to verify this behavior.
contracts/os/andromeda-ibc-registry/src/contract.rs (1)
60-60
: Permission structure updated to support start time.
The change from Whitelisted(None)
to whitelisted(None, None)
aligns with the new permission structure that supports start time. The parameters likely represent (end_time, start_time)
.
Let's verify the permission structure and its usage:
✅ Verification successful
Permission structure change is correctly implemented.
The verification confirms that:
LocalPermission
enum has been updated to includestart
field in all variants (Whitelisted, Blacklisted, Limited)- The
whitelisted
constructor function correctly accepts bothstart
andexpiration
parameters - The change from
Whitelisted(None)
towhitelisted(None, None)
is consistent with the new permission structure across the codebase - The order of parameters is consistent:
whitelisted(start: Option<Expiry>, expiration: Option<Expiry>)
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify the permission structure and its usage across the codebase
# Check the LocalPermission struct definition
rg -A 5 "struct LocalPermission"
# Check all usages of whitelisted to ensure consistent parameter order
rg "whitelisted\(.*None.*None"
# Look for any validation of start_time vs end_time
rg "start_time.*end_time"
Length of output: 3046
Script:
#!/bin/bash
# Let's check the LocalPermission struct definition and implementation
# since it wasn't found in the first search
# Search for LocalPermission in andromeda-std crate
fd -t f "lib.rs|mod.rs" -x rg -A 10 "LocalPermission" {}
# Search for whitelisted function implementation
ast-grep --pattern 'fn whitelisted($$$) { $$$ }'
# Check for any time validation in the permission module
fd "permission" -x rg -A 5 "validate.*time" {}
Length of output: 158
Script:
#!/bin/bash
# Try a different approach to find LocalPermission definition and implementation
# Search for enum or struct definitions containing LocalPermission
rg -A 15 "(enum|struct) .*Permission"
# Look for the implementation block of LocalPermission
rg -A 10 "impl.*LocalPermission"
# Search for whitelisted method with a broader pattern
rg -A 5 "whitelisted.*None.*None"
Length of output: 20954
packages/std/src/common/denom.rs (1)
142-142
: Verify consistent usage of the new permission constructor.
The change to use LocalPermission::whitelisted(None, None)
aligns with the new start time feature. However, we should verify that this pattern is consistently applied across the codebase.
✅ Verification successful
All permission constructors have been consistently updated
The verification shows that all instances of permission constructors in the codebase are using the new whitelisted
method. There are no occurrences of the old-style Whitelisted
constructor, and all usages properly handle the new start time parameter (either with None, None
or None, Some(expiration)
).
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for any remaining old-style permission constructors
# that haven't been updated to the new format
# Search for old-style permission constructors
rg "LocalPermission::Whitelisted\(" --type rust
# Search for new-style permission constructors to compare
rg "LocalPermission::whitelisted\(" --type rust
Length of output: 3698
contracts/modules/andromeda-address-list/src/testing/tests.rs (2)
29-29
: LGTM: API usage updated correctly.
The update to LocalPermission::whitelisted(None, None)
correctly reflects the new API that supports start time.
Line range hint 1-300
: Verify test coverage across the codebase.
Let's locate the mentioned test_permission_start_time
and identify other test files that might need coverage updates.
✅ Verification successful
Test coverage is complete and properly implemented
The test_permission_start_time
test is actually implemented in packages/std/src/ado_contract/permissioning.rs
which is the core implementation file for permissions. This is the correct location for this test as it tests the core functionality that is used by all contracts including the address-list contract.
The address-list contract's test file (contracts/modules/andromeda-address-list/src/testing/tests.rs
) properly imports and uses LocalPermission
, and includes comprehensive tests for the contract-specific permission functionality:
- Basic permission operations (add/remove)
- Multiple actor operations
- Permission queries
- Authorization checks
- Default permission handling
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Find test files and locate the test_permission_start_time test
# Find all test files in the repository
echo "=== Test files ==="
fd -e rs "test" -t f
# Search for test_permission_start_time
echo -e "\n=== Searching for test_permission_start_time ==="
rg -l "test_permission_start_time"
# Search for LocalPermission usage in tests
echo -e "\n=== Test files using LocalPermission ==="
rg -l "LocalPermission::" -- "*test*.rs"
Length of output: 2715
Script:
#!/bin/bash
# Let's check the content of the permissioning.rs file and search for LocalPermission usage in tests with correct path patterns
# Check the content of permissioning.rs where test_permission_start_time was found
echo "=== Content of permissioning.rs ==="
cat packages/std/src/ado_contract/permissioning.rs
# Search for LocalPermission usage in tests with correct path pattern
echo -e "\n=== Test files using LocalPermission ==="
rg -l "LocalPermission::" "**/*test*.rs"
# Search for test_permission_start_time in test files
echo -e "\n=== Test files containing test_permission_start_time ==="
rg -l "test_permission_start_time" "**/*test*.rs"
Length of output: 45241
Script:
#!/bin/bash
# Let's try a different approach to search for the test and LocalPermission usage
# Search for test_permission_start_time in all files
echo "=== Files containing test_permission_start_time ==="
rg "test_permission_start_time"
# Search for LocalPermission usage in test files
echo -e "\n=== Test files using LocalPermission ==="
rg "LocalPermission::" -t rust
# List all test files that import LocalPermission
echo -e "\n=== Test files importing LocalPermission ==="
rg "use.*LocalPermission" -t rust
Length of output: 8594
contracts/fungible-tokens/andromeda-merkle-airdrop/src/contract.rs (1)
72-72
: Verify consistent permission handling across contracts
This is a breaking change to the whitelisted
function signature. Let's verify that all other contracts using this permission have been updated accordingly.
contracts/non-fungible-tokens/andromeda-crowdfund/src/contract.rs (2)
78-78
: LGTM: Permission handling updated to support start time
The change to use LocalPermission::whitelisted(None, None)
aligns with the PR objective of adding start time support to permissions.
Line range hint 89-95
: LGTM: Improved error handling in reply function
The modification to unwrap the error message before returning it provides better context in error responses.
packages/std/src/ado_contract/permissioning.rs (1)
1052-1056
: LGTM! Test updates properly reflect the new permission structure.
The test updates consistently apply the new permission format across all test cases while maintaining the original test coverage and intent.
Also applies to: 1113-1113, 1187-1187, 1204-1204, 1208-1208, 1212-1212, 1216-1216
contracts/non-fungible-tokens/andromeda-auction/src/contract.rs (2)
Line range hint 147-150
: Reference: Auction timing validation pattern.
The auction timing validation provides a good pattern to follow for implementing permission timing validation:
ensure!(
end_expiration > start_expiration,
ContractError::StartTimeAfterEndTime {}
);
Also applies to: 392-395
316-316
: Permission changes align with start time feature.
The changes to use LocalPermission::whitelisted(None, None)
align with the PR objective of adding optional start time to permissions. The method-style constructor now accepts both start_time and end_time parameters.
Let's verify if blacklisted permissions need similar updates:
Also applies to: 430-430
✅ Verification successful
Let me gather more information about the LocalPermission
type and its usage to ensure a complete verification.
Permission changes are correctly implemented and consistent
The verification shows that both whitelisted and blacklisted permissions have consistent implementations with start time support:
LocalPermission::whitelisted(None, None)
usage in the auction contract is correct- The implementation in
packages/std/src/ado_base/permissioning.rs
shows bothwhitelisted
andblacklisted
constructors accept the same parameters (start, expiration) - The
is_permissioned
method properly handles start time validation for all permission types
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for any blacklisted permission usage that might need updating
rg -A 2 'LocalPermission::Blacklisted' || rg -A 2 'LocalPermission::blacklisted'
Length of output: 1141
Script:
#!/bin/bash
# Check the LocalPermission type definition and its constructors
ast-grep --pattern 'enum LocalPermission {
$$$
}'
# Also check for any whitelisted constructor implementation
ast-grep --pattern 'impl LocalPermission {
$$$
}'
Length of output: 8480
packages/std/src/ado_base/permissioning.rs (3)
159-169
: Consider caching expiration times to optimize performance
The get_start_time
method reconstructs the MillisecondsExpiration
every time it's called. If this method is called frequently, it might have performance implications.
[performance]
Consider caching the computed MillisecondsExpiration
when the permission is created or first accessed.
183-204
: Handle formatting of start
and expiration
times gracefully in fmt::Display
In the fmt::Display
implementation, if start
or expiration
times are invalid or cause formatting issues, it might result in panics.
[error_handling]
Ensure that start
and expiration
times are formatted safely. You might want to handle potential errors when converting these times to strings.
77-90
: Handle cases where both start
and expiration
are None
in factory methods
In the factory methods blacklisted
, whitelisted
, and limited
, if both start
and expiration
are None
, it might lead to permissions that are always active or never active, which could be unintuitive.
Verify if there are use cases where both start
and expiration
are None
. If not, consider adding validation to prevent this scenario. You can run the following script to check where these methods are called without start
and expiration
:
✅ Verification successful
Let me analyze the usage of these factory methods with both start
and expiration
as None
. The search results show that this pattern is widely used across the codebase, primarily in:
- Test files for setting up test scenarios
- Contract initialization and permission setup in production code
- Default permission configurations
Let me verify the implementation of permission checking to understand if this is a valid use case.
Let me try a different approach to find the permission checking logic.
Let me check the complete implementation of is_permissioned
since it was cut off.
Based on the implementation of is_permissioned
, I can now provide the final response:
Having both start
and expiration
as None
is a valid and intentional use case
The implementation in is_permissioned
shows that when both start
and expiration
are None
:
- For
Blacklisted
: The permission remains permanently active (always returnsfalse
) - For
Whitelisted
: The permission remains permanently active (falls through to default case) - For
Limited
: The permission is only controlled by theuses
count
This is used extensively throughout the codebase for setting up permanent permissions, particularly in:
- Contract initialization for default permissions
- Test scenarios
- Core permission management
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Find calls to permission factory methods with `start` and `expiration` as `None`.
rg 'LocalPermission::(blacklisted|whitelisted|limited)\(None,\s*None' -A 2
Length of output: 7161
Script:
#!/bin/bash
# Find the implementation that checks these permissions
ast-grep --pattern 'impl LocalPermission {
$$$
pub fn check($$$) {
$$$
}
$$$
}'
Length of output: 93
Script:
#!/bin/bash
# Find the implementation that checks these permissions using ripgrep
rg "impl.*LocalPermission" -A 20
Length of output: 4325
Script:
#!/bin/bash
# Get the complete implementation of is_permissioned
rg "pub fn is_permissioned" -A 30
Length of output: 7919
contracts/non-fungible-tokens/andromeda-marketplace/src/testing/tests.rs (4)
232-232
: Correct Update to Use New whitelisted
Constructor
The code correctly updates the permission instantiation to use LocalPermission::whitelisted(None, None)
, aligning with the new constructor that accepts optional start and end times.
1045-1045
: Accurate Formatting of Permission Attributes
The permission attribute is correctly formatted to include the expiration time using format!("whitelisted until:{}", expiration)
.
1058-1061
: Proper Instantiation of LocalPermission::whitelisted
with Expiration
The permission is accurately instantiated with None
for the start time and Some(expiration)
for the end time, effectively setting the permission to expire at the specified time.
1185-1185
: Consistent Formatting of Permission Attributes
The code consistently formats the permission attribute to include the expiration time, ensuring clarity in permission status.
tests-integration/tests/auction_app.rs (4)
Line range hint 535-541
: Initialization of buyer_three
is appropriate
The addition of buyer_three
with initial funds is correctly implemented, allowing for testing multiple actors in permissioning.
Line range hint 598-605
: Auction initialized with restricted CW20 token
The auction is correctly initialized with a restricted CW20 token by specifying the allowed_cw20
parameter. This ensures that only the permitted CW20 tokens can be used in the auction.
630-633
: Testing blacklisted permissions over time
Similar to earlier, adding tests with specific start_time
and end_time
when blacklisting buyer_one
and buyer_three
would enhance test coverage for time-based permissions.
666-669
: Testing whitelisted permissions with timing
When whitelisting buyer_one
, consider setting explicit start_time
and end_time
to test the time-bound whitelisting functionality introduced in the PR.
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 and nitpick comments (1)
CHANGELOG.md (1)
78-78
: Enhance the changelog entry to better reflect the scope of changes.While the entry follows the correct format, consider expanding it to better communicate the impact and limitations of this change. Here's a suggested revision:
-Permissions now have an optional start time [(#668)](https://github.com/andromedaprotocol/andromeda-core/pull/668) +Enhanced permission system with optional start time, affecting how `is_permissioned` evaluates blacklisted, whitelisted, and limited permissions based on start time. Note: No validation between start and end times [(#668)](https://github.com/andromedaprotocol/andromeda-core/pull/668)
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 and nitpick comments (4)
tests-integration/tests/marketplace_app.rs (4)
Line range hint
600-627
: Refactor repetitive permission settings to improve maintainabilityThe code between lines 600-627 and 903-939 repeats the
execute_actor_permission
calls withLocalPermission::whitelisted(None, None)
for different actors. This repetition can lead to code that is harder to maintain and prone to errors if changes are needed in the future.Consider creating a helper function or loop to set permissions for multiple actors. This will reduce code duplication and make future updates easier.
Example refactor:
// Define a list of actors to whitelist let actors_to_whitelist = vec![ cw721.addr().clone(), cw20.addr().clone(), buyer.clone(), owner.clone(), ]; // Iterate over the actors and set permissions for actor in actors_to_whitelist { address_list .execute_actor_permission( &mut router, owner.clone(), actor, LocalPermission::whitelisted(None, None), ) .unwrap(); }Also applies to: 903-939
Line range hint
600-627
: Add validation for start_time and end_time in permissionsCurrently, there is no validation to prevent users from setting a
start_time
that occurs after theend_time
inLocalPermission::whitelisted(None, None)
. This could lead to unexpected behavior in permission handling.Ensure that when both
start_time
andend_time
are provided, the code validates thatstart_time
is beforeend_time
. This can prevent logical errors and improve the robustness of the permission system.Example validation logic:
impl LocalPermission { pub fn whitelisted(start_time: Option<Timestamp>, end_time: Option<Timestamp>) -> Self { if let (Some(start), Some(end)) = (start_time, end_time) { if start >= end { panic!("start_time must be before end_time"); } } // Existing implementation } }
Line range hint
600-627
: Consider adding unit tests for permission time boundariesWith the introduction of
start_time
andend_time
, it's important to test how permissions behave at these boundaries. There are currently no tests covering scenarios where permissions are not yet active or have expired.Consider adding unit tests that:
- Verify permissions are not granted before
start_time
.- Verify permissions are revoked after
end_time
.- Test cases where
start_time
is equal toend_time
.This will ensure that time-based permissions work as expected.
Line range hint
903-939
: Consider combining similar test scenarios to reduce redundancyThe tests
test_marketplace_app_cw20_restricted
andtest_marketplace_app_cw20_unrestricted
share similar setup code. Refactoring common setup steps into helper functions can make the tests cleaner and reduce duplication.Extract shared setup code into helper functions. This will make your tests more maintainable and easier to understand.
Example:
fn setup_marketplace_app_cw20_test( router: &mut MockApp, andr: &MockAndromedaBuilder, owner: &Addr, buyer: &Addr, rates_receiver: &Addr, ) -> (MockCW721, MockMarketplace, MockCW20, MockRates) { // Common setup code here... (cw721, marketplace, cw20, rates) }Then, in your tests, you can call this function to perform the setup.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
tests-integration/tests/marketplace_app.rs
(9 hunks)
🔇 Additional comments (3)
tests-integration/tests/marketplace_app.rs (3)
Line range hint 903-939
: Ensure consistent permission settings across tests
In lines 903-939, permissions are being set for multiple components and actors. Ensure that the permissions reflect the intended test scenarios and that no necessary permissions are missing.
Double-check that:
- All components involved in the test have the appropriate permissions.
- The permissions set align with the test objectives, especially concerning unrestricted CW20 sales.
Line range hint 903-939
: Verify rate calculations for different CW20 tokens
In the unrestricted CW20 sale test, ensure that the rate calculations are accurate when updating the sale to use a different CW20 token. Since rates may vary between tokens, verify that the rates applied reflect the intended percentages or flat amounts.
You can add assertions or print statements in your test to confirm that the rates are calculated as expected.
Line range hint 600-627
: Verify all instances of LocalPermission::whitelisted
are updated
Ensure that all uses of LocalPermission::whitelisted
in the codebase have been updated to include the new parameters, to prevent any mismatches or missing functionality.
Run the following script to find any instances of LocalPermission::whitelisted
with missing parameters:
This script searches for calls to LocalPermission::whitelisted
that have fewer than two arguments, which may indicate outdated code that needs to be updated.
✅ Verification successful
All LocalPermission::whitelisted
calls are correctly using two parameters
Based on the verification results:
- The
LocalPermission
enum definition shows thatwhitelisted
is a constructor that takes two parameters:start: Option<Expiry>
andexpiration: Option<Expiry>
. - All instances of
LocalPermission::whitelisted
in the codebase are consistently using both parameters, typically as(None, None)
or(None, Some(expiration))
. - The code under review follows the same pattern, using
LocalPermission::whitelisted(None, None)
.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Find calls to LocalPermission::whitelisted with incorrect arguments
# Expected: All calls should include two arguments
rg 'LocalPermission::whitelisted\([^,)]*\)'
Length of output: 45
Script:
#!/bin/bash
# Let's try a broader search to find all instances of LocalPermission::whitelisted
rg "LocalPermission::whitelisted" -A 2
Length of output: 7700
Script:
#!/bin/bash
# Let's also check the struct/enum definition to understand the expected parameters
ast-grep --pattern 'enum LocalPermission {
$$$
whitelisted($_) {
$$$
}
$$$
}'
Length of output: 91
Script:
#!/bin/bash
# Search for test files that might use this permission
fd "test.*\.rs$" --exec grep -l "LocalPermission::whitelisted"
Length of output: 265
Script:
#!/bin/bash
# Let's check the definition of LocalPermission to understand its structure
rg "enum LocalPermission" -A 10
Length of output: 750
Script:
#!/bin/bash
# Let's also check if there are any other variants of whitelisted usage
rg "whitelisted\(" -A 2
Length of output: 8279
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: 1
📜 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 (4)
packages/std/Cargo.toml
(1 hunks)tests-integration/tests/auction_app.rs
(3 hunks)tests-integration/tests/marketplace_app.rs
(5 hunks)tests-integration/tests/validator_staking.rs
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- packages/std/Cargo.toml
- tests-integration/tests/validator_staking.rs
🔇 Additional comments (6)
tests-integration/tests/auction_app.rs (1)
Line range hint 613-664
: Verify test coverage across the codebase.
Let's check for other test files that might need updates to cover the new start time functionality.
✅ Verification successful
Other test files are using permissions consistently with the changes
The verification shows that other test files (marketplace_app.rs
and validator_staking.rs
) are already using the LocalPermission::whitelisted(None, None)
and LocalPermission::blacklisted(None, None)
syntax consistently with the changes in auction_app.rs
. No updates are needed in other test files.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Find test files that might need updates for start time functionality
# Look for test files containing permission-related tests
echo "Test files with permission-related tests:"
rg -l "LocalPermission::(blacklisted|whitelisted)" --type rust --glob "**/tests/**"
# Look for permission-related test functions
echo -e "\nPermission-related test functions:"
rg "fn.*test.*permission" --type rust --glob "**/tests/**"
Length of output: 451
Script:
#!/bin/bash
# Let's examine the permission-related code in the identified test files
echo "=== Checking marketplace_app.rs permissions ==="
rg "LocalPermission::(blacklisted|whitelisted)" -B 2 -A 2 tests-integration/tests/marketplace_app.rs
echo -e "\n=== Checking validator_staking.rs permissions ==="
rg "LocalPermission::(blacklisted|whitelisted)" -B 2 -A 2 tests-integration/tests/validator_staking.rs
# Let's also check for any permission-related assertions
echo -e "\n=== Checking permission-related assertions ==="
rg "assert.*Permission" tests-integration/tests/marketplace_app.rs tests-integration/tests/validator_staking.rs
Length of output: 1524
tests-integration/tests/marketplace_app.rs (5)
205-205
: Update to LocalPermission::limited
aligns with new parameters
The change to LocalPermission::limited(None, None, 1)
correctly incorporates the new start_time
and end_time
parameters introduced in the permissioning system.
224-224
: Modification to LocalPermission::blacklisted
is appropriate
Using LocalPermission::blacklisted(None, None)
reflects the updated structure for permissions, ensuring compatibility with the new start time feature.
258-258
: Whitelisting buyer with updated permissions
The call to LocalPermission::whitelisted(None, None)
correctly applies the new permission parameters, granting immediate and indefinite access as intended.
617-617
: Whitelisting multiple addresses with new permissioning
The use of LocalPermission::whitelisted(None, None)
for multiple addresses ensures that all specified actors have the required permissions under the updated system.
899-899
: Ensuring unrestricted CW20 sales with updated permissions
By invoking LocalPermission::whitelisted(None, None)
, the code appropriately whitelists necessary contracts and users, aligning with the unrestricted sale objectives.
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.
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: 1
🧹 Outside diff range and nitpick comments (16)
contracts/ecosystem/andromeda-vault/src/contract.rs (7)
Line range hint
93-100
: Enhance error handling in thereply
functionUsing
unwrap_err()
directly assumes thatmsg.result
is an error, but it's safer to pattern match to handle both success and error cases explicitly. This prevents potential panics if the function evolves in the future.Apply this diff to improve error handling:
-pub fn reply(_deps: DepsMut, _env: Env, msg: Reply) -> Result<Response, ContractError> { - if msg.result.is_err() { - return Err(ContractError::Std(StdError::generic_err( - msg.result.unwrap_err(), - ))); - } - - Ok(Response::default()) -} +pub fn reply(_deps: DepsMut, _env: Env, msg: Reply) -> Result<Response, ContractError> { + match msg.result { + ContractResult::Ok(_) => Ok(Response::default()), + ContractResult::Err(err) => Err(ContractError::Std(StdError::generic_err(err))), + } +}
Line range hint
242-245
: Validatepercent
in percentage withdrawals to prevent logic errorsWhen handling
WithdrawalType::Percentage(percent)
, ensure thatpercent
is greater than zero and less than or equal to one. Failing to validate this can lead to unexpected withdrawal amounts or arithmetic errors.Apply this diff to add validation for
percent
:match withdrawal_type { WithdrawalType::Amount(amount) => { /* existing code */ } WithdrawalType::Percentage(percent) => { + ensure!( + percent > Decimal::zero() && percent <= Decimal::one(), + ContractError::InvalidWithdrawal { + msg: Some("Percent must be between 0 and 1 (exclusive)".to_string()), + } + ); let amount = balance * percent; // rest of the code } }
Line range hint
299-300
: Review the unconditional error inquery_balance
when strategy is providedThe
ensure!(false, ContractError::TemporarilyDisabled {});
line causes the function to always return an error when a strategy is specified. If this functionality is intended to be disabled temporarily, consider providing a more descriptive error message or implementing feature flags.Apply this diff to improve clarity:
-ensure!(false, ContractError::TemporarilyDisabled {}); +return Err(ContractError::FeatureDisabled { + msg: Some("Querying balance with strategy is temporarily disabled.".to_string()), +});Alternatively, implement the required logic if ready.
Line range hint
316-328
: Consider removing or documenting commented-out codeThere is a block of commented-out code intended for future use. While it's acceptable during development, it can clutter the codebase over time. Consider removing it or adding a
TODO
comment with references to work items or issues.
Line range hint
353-372
: Re-examine the ownership check inexecute_update_strategy
The current implementation checks if the strategy's owner is the vault contract. Depending on the design, it might be more appropriate to check for operator permissions or implement a more flexible access control mechanism. This ensures that strategies managed by the vault are correctly authorized without requiring ownership transfer.
Line range hint
58-61
: Improve error messages inhandle_execute
for unimplemented variantsReturning a generic
NotImplemented
error forExecuteMsg::Withdraw
may confuse users. Provide a clearer message or guide them to the correct function.Apply this diff to enhance the error message:
-ExecuteMsg::Withdraw { .. } => Err(ContractError::NotImplemented { - msg: Some("Please use WithdrawVault".to_string()), -}), +ExecuteMsg::Withdraw { .. } => Err(ContractError::InvalidRequest { + msg: Some("Withdraw is deprecated; please use WithdrawVault instead.".to_string()), +}),
Line range hint
78-82
: Use_deps
and_env
consistently to indicate unused parametersIn the
reply
function, parameters are prefixed with an underscore to indicate they are unused. Ensure consistent naming to maintain code readability.contracts/data-storage/andromeda-point/src/contract.rs (1)
72-73
: LGTM! Minor formatting suggestion.The migration function correctly implements the new signature with the
env
parameter and properly forwards it to the base contract's migrate function.Consider adding a space after the comma in the
migrate
call for better readability:- ADOContract::default().migrate(deps,env, CONTRACT_NAME, CONTRACT_VERSION) + ADOContract::default().migrate(deps, env, CONTRACT_NAME, CONTRACT_VERSION)contracts/modules/andromeda-date-time/src/contract.rs (1)
125-125
: Fix spacing in migrate function callAdd a space after the comma for consistent formatting:
- ADOContract::default().migrate(deps,env, CONTRACT_NAME, CONTRACT_VERSION) + ADOContract::default().migrate(deps, env, CONTRACT_NAME, CONTRACT_VERSION)contracts/app/andromeda-app-contract/src/contract.rs (1)
200-201
: LGTM! Minor formatting fix needed.The signature change to use the
env
parameter is aligned with the PR objectives for time-based permission handling. However, there's a minor formatting issue.Add a space after the comma in the
migrate
call:- ADOContract::default().migrate(deps,env, CONTRACT_NAME, CONTRACT_VERSION) + ADOContract::default().migrate(deps, env, CONTRACT_NAME, CONTRACT_VERSION)contracts/finance/andromeda-splitter/src/contract.rs (1)
Line range hint
167-171
: Document the remainder funds behaviorThe code contains a comment questioning the behavior of remainder funds. This should be properly documented to clarify the intended behavior.
Add a documentation comment explaining that remaining funds are returned to the transaction sender:
+ // Any remaining funds (dust from rounding) are returned to the transaction sender if !remainder_funds.is_empty() { msgs.push(SubMsg::new(CosmosMsg::Bank(BankMsg::Send { to_address: info.sender.to_string(), amount: remainder_funds, })));
contracts/finance/andromeda-validator-staking/src/contract.rs (1)
105-106
: Consider adding documentation about time-based permissions.Since this change is part of implementing start time for permissions, it would be helpful to add documentation explaining how the migrate function interacts with the new time-based permission system.
+/// Migrates the contract to a new version. +/// The env parameter is used by the base contract to validate time-based permissions. pub fn migrate(deps: DepsMut, env: Env, _msg: MigrateMsg) -> Result<Response, ContractError> { ADOContract::default().migrate(deps,env, CONTRACT_NAME, CONTRACT_VERSION) }contracts/fungible-tokens/andromeda-lockdrop/src/contract.rs (1)
Line range hint
1-600
: Consider leveraging existing time-based permission patterns.This contract demonstrates several robust patterns for handling time-based permissions that could be valuable for implementing the start time feature mentioned in the PR objectives:
- Using
MillisecondsExpiration
for precise time handling- Clear window-based permission logic with
is_deposit_open
,is_withdraw_open
, andis_phase_over
- Proper time comparisons using
is_in_past
andplus_milliseconds
contracts/non-fungible-tokens/andromeda-marketplace/src/contract.rs (2)
Line range hint
744-754
: Consider using checked comparison for payment validationThe payment validation in both CW20 and native token paths uses direct equality comparison (
eq
) after performing checked arithmetic. Consider using checked comparison throughout to maintain consistent overflow protection.For the CW20 path:
- ensure!( - amount_sent.eq(&total_required_payment), - ContractError::InvalidFunds { + ensure!( + amount_sent == total_required_payment, + ContractError::InvalidFunds {For the native token path:
- ensure!( - amount_sent.eq(&total_required_payment.u128()), - ContractError::InvalidFunds { + ensure!( + Uint128::from(amount_sent) == total_required_payment, + ContractError::InvalidFunds {Also applies to: 828-838
Line range hint
379-380
: Add validation for start time vs end time relationshipCurrently, there's no validation to prevent setting a start time that occurs after the end time. This could lead to sales that never become active.
Consider adding validation in the
execute_start_sale
function:let end_expiration = if let Some(duration) = duration { ensure!(!duration.is_zero(), ContractError::InvalidExpiration {}); + let end_time = start_time + .unwrap_or(Expiry::FromNow(Milliseconds::from_seconds(1))) + .get_time(&env.block) + .plus_milliseconds(duration); + ensure!( + start_expiration.get_time(&env.block) <= end_time, + ContractError::InvalidExpiration {} + ); expiration_from_milliseconds( start_time .unwrap_or(Expiry::FromNow(Milliseconds::from_seconds(1)))packages/std/src/ado_contract/permissioning.rs (1)
865-938
: Enhance test coverage for combined start and end time scenarios.While the test comprehensively covers start time behavior, it should also verify:
- Cases where both start and end times are set
- Error cases for invalid time relationships (start time after end time)
Consider adding test cases like:
#[test] fn test_permission_start_and_end_time() { let mut deps = mock_dependencies(); let mut env = mock_env(); let action = "action"; let actor = "actor"; let contract = ADOContract::default(); // Test valid case: start_time < end_time let start = Expiry::AtTime(MillisecondsExpiration::from_seconds(1)); let end = Expiry::AtTime(MillisecondsExpiration::from_seconds(2)); let permission = Permission::Local(LocalPermission::Whitelisted { start: Some(start), expiration: Some(end), }); // Test permission behavior at different times env.block.time = MillisecondsExpiration::from_seconds(0).into(); // Before start let res = contract.is_permissioned(deps.as_mut(), env.clone(), action, actor); assert!(res.is_err()); env.block.time = MillisecondsExpiration::from_seconds(1).into(); // At start let res = contract.is_permissioned(deps.as_mut(), env.clone(), action, actor); assert!(res.is_ok()); env.block.time = MillisecondsExpiration::from_seconds(2).into(); // At end let res = contract.is_permissioned(deps.as_mut(), env.clone(), action, actor); assert!(res.is_err()); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (39)
contracts/app/andromeda-app-contract/src/contract.rs
(1 hunks)contracts/data-storage/andromeda-boolean/src/contract.rs
(2 hunks)contracts/data-storage/andromeda-counter/src/contract.rs
(1 hunks)contracts/data-storage/andromeda-graph/src/contract.rs
(1 hunks)contracts/data-storage/andromeda-point/src/contract.rs
(1 hunks)contracts/data-storage/andromeda-primitive/src/contract.rs
(1 hunks)contracts/data-storage/andromeda-string-storage/src/contract.rs
(1 hunks)contracts/ecosystem/andromeda-vault/src/contract.rs
(1 hunks)contracts/finance/andromeda-conditional-splitter/src/contract.rs
(1 hunks)contracts/finance/andromeda-cross-chain-swap/src/contract.rs
(1 hunks)contracts/finance/andromeda-fixed-multisig/src/contract.rs
(1 hunks)contracts/finance/andromeda-rate-limiting-withdrawals/src/contract.rs
(1 hunks)contracts/finance/andromeda-set-amount-splitter/src/contract.rs
(1 hunks)contracts/finance/andromeda-splitter/src/contract.rs
(1 hunks)contracts/finance/andromeda-timelock/src/contract.rs
(1 hunks)contracts/finance/andromeda-validator-staking/src/contract.rs
(1 hunks)contracts/finance/andromeda-vesting/src/contract.rs
(1 hunks)contracts/finance/andromeda-weighted-distribution-splitter/src/contract.rs
(1 hunks)contracts/fungible-tokens/andromeda-cw20-exchange/src/contract.rs
(1 hunks)contracts/fungible-tokens/andromeda-cw20-staking/src/contract.rs
(1 hunks)contracts/fungible-tokens/andromeda-cw20/src/contract.rs
(1 hunks)contracts/fungible-tokens/andromeda-lockdrop/src/contract.rs
(1 hunks)contracts/fungible-tokens/andromeda-merkle-airdrop/src/contract.rs
(2 hunks)contracts/modules/andromeda-address-list/src/contract.rs
(1 hunks)contracts/modules/andromeda-curve/src/contract.rs
(1 hunks)contracts/modules/andromeda-date-time/src/contract.rs
(1 hunks)contracts/modules/andromeda-rates/src/contract.rs
(1 hunks)contracts/modules/andromeda-shunting/src/contract.rs
(1 hunks)contracts/non-fungible-tokens/andromeda-auction/src/contract.rs
(3 hunks)contracts/non-fungible-tokens/andromeda-crowdfund/src/contract.rs
(2 hunks)contracts/non-fungible-tokens/andromeda-cw721/src/contract.rs
(1 hunks)contracts/non-fungible-tokens/andromeda-marketplace/src/contract.rs
(1 hunks)contracts/os/andromeda-adodb/src/contract.rs
(1 hunks)contracts/os/andromeda-economics/src/contract.rs
(1 hunks)contracts/os/andromeda-ibc-registry/src/contract.rs
(2 hunks)contracts/os/andromeda-kernel/src/contract.rs
(1 hunks)contracts/os/andromeda-vfs/src/contract.rs
(1 hunks)packages/std/src/ado_contract/execute.rs
(2 hunks)packages/std/src/ado_contract/permissioning.rs
(18 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
- contracts/data-storage/andromeda-boolean/src/contract.rs
- contracts/fungible-tokens/andromeda-merkle-airdrop/src/contract.rs
- contracts/non-fungible-tokens/andromeda-auction/src/contract.rs
- contracts/non-fungible-tokens/andromeda-crowdfund/src/contract.rs
- contracts/os/andromeda-ibc-registry/src/contract.rs
🔇 Additional comments (41)
contracts/ecosystem/andromeda-vault/src/contract.rs (2)
393-394
: Confirm consistent use of the env
parameter in migrate
functions
The migrate
function now includes the env
parameter and passes it to ADOContract::migrate()
. Ensure that this change is consistently applied across all contracts to maintain uniformity in migration handlers.
Line range hint 25-33
: Ensure InstantiateMsg
properly initializes the contract
Verify that all necessary fields in InstantiateMsg
are correctly handled and that the contract initializes all required state. Missing initialization can lead to runtime errors.
To confirm, please check that InstantiateMsg
includes all fields required by ADOContract::instantiate()
.
contracts/data-storage/andromeda-string-storage/src/contract.rs (1)
72-73
: LGTM! Verify consistency across other contracts.
The change to utilize the env
parameter in the migrate function is correct and aligns with the broader changes for time-based permissions.
Let's verify if this change is consistently applied across other contracts:
✅ Verification successful
The change is consistently applied across all contracts
The verification shows that all contracts in the repository (except andromeda-ics20 which has a custom migration) have updated their migrate function signatures to use the env
parameter and pass it to ADOContract::default().migrate()
. This is a consistent change across the codebase that aligns with enabling time-based permissions.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check if other contracts have similar migrate function signatures
# Expected: All contract migrate functions should use the env parameter consistently
# Search for migrate function signatures in contract files
ast-grep --pattern 'pub fn migrate(deps: DepsMut, env: Env, $msg: MigrateMsg)'
# Also check for any inconsistent signatures that might still have _env
ast-grep --pattern 'pub fn migrate(deps: DepsMut, _env: Env, $msg: MigrateMsg)'
Length of output: 162
Script:
#!/bin/bash
# Let's try a different approach using ripgrep to find migrate functions
# Search for migrate function implementations in contract.rs files
rg -U "pub fn migrate.*\{[\s\S]*?\}" --type rust -g "contract.rs" -A 5
# Also search specifically for ADOContract::default().migrate calls
rg "ADOContract::default\(\)\.migrate" --type rust
Length of output: 37283
contracts/data-storage/andromeda-primitive/src/contract.rs (1)
64-65
: LGTM! Verify consistency across other contracts.
The change to utilize the env
parameter in the migrate function is aligned with the andromeda-std upgrade and the implementation of time-based permissions.
Let's verify that this change is consistent across other contracts:
✅ Verification successful
✓ Change verified across all contracts
The search results confirm that all contracts in the repository consistently use the env
parameter (not _env
) in their migrate functions and pass it to ADOContract::default().migrate()
. The only exception is the ICS20 contract which has a custom migration implementation, which is expected due to its specialized nature.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check migrate function signatures in other contracts
# Expect: All contracts should use the env parameter consistently
# Search for migrate function definitions
ast-grep --pattern 'pub fn migrate(deps: DepsMut, env: Env, $msg: $_) -> Result<$_, $_>'
# Also check for any inconsistent usage with _env
ast-grep --pattern 'pub fn migrate(deps: DepsMut, _env: Env, $msg: $_) -> Result<$_, $_>'
Length of output: 182
Script:
#!/bin/bash
# Let's try a different approach using ripgrep to find migrate functions
# Search for migrate function implementations across the codebase
rg -U "pub fn migrate.*\{[\s\S]+?\}" --type rust -A 5
# Also search for ADOContract::default().migrate usage
rg "ADOContract::default\(\).migrate" --type rust
Length of output: 37267
contracts/modules/andromeda-date-time/src/contract.rs (1)
124-125
: Breaking change: Migration interface updated
The migration function has been updated to utilize the env
parameter, which is part of a broader update across multiple contracts. This is a breaking change that requires careful coordination during deployment.
Let's verify this change is consistent across other contracts:
✅ Verification successful
Breaking change: Migration interface consistently updated across contracts
The verification confirms that the migrate
function signature with env
parameter is consistently implemented across all Andromeda contracts, with only minor formatting variations. Most contracts follow the same pattern of using ADOContract::default().migrate(deps, env, CONTRACT_NAME, CONTRACT_VERSION)
, making this a coordinated breaking change across the ecosystem.
- Some contracts have inconsistent spacing after the comma before
env
parameter (e.g., in andromeda-date-time, andromeda-rates, andromeda-curve) - Only andromeda-crowdfund and andromeda-ics20 have slightly different implementations, but they still accept the same parameters
- All other contracts consistently implement the same migration pattern
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check if all migrate functions in the codebase follow the same pattern
# Expected: All migrate functions should use the env parameter consistently
ast-grep --pattern 'pub fn migrate(deps: DepsMut, env: Env, $msg: $_) -> Result<$_, $_>'
Length of output: 90
Script:
#!/bin/bash
# Let's try a different approach to find migrate functions
# First, let's find all Rust files that contain "migrate"
rg -l "migrate" --type rust
# Then, let's examine the migrate function implementations
rg "pub fn migrate.*\{" --type rust -A 2
Length of output: 16132
contracts/os/andromeda-economics/src/contract.rs (1)
103-104
: LGTM! Consistent with contract migration pattern.
The addition of the env
parameter to the migrate
function and passing it through to ADOContract::default().migrate()
improves consistency with the standard contract migration pattern.
Let's verify that this migration pattern is consistently implemented across other contracts:
✅ Verification successful
Migration pattern is consistently implemented across all contracts
The verification shows that all contracts in the repository follow the same migration pattern, accepting the env
parameter and passing it to ADOContract::default().migrate()
. The only minor exception is the andromeda-ics20
contract which has a slightly different implementation due to its specific IBC-related requirements.
The change in the economics contract aligns perfectly with the standardized migration pattern used throughout the codebase.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check migration function signatures across contracts
# Expected: All migrate functions should accept and forward the env parameter
# Search for migrate function definitions
ast-grep --pattern 'pub fn migrate(deps: DepsMut, env: Env, $msg: $_) -> Result<Response, ContractError> {
$$$
}'
# Search for any potentially inconsistent migrate functions
ast-grep --pattern 'pub fn migrate(deps: DepsMut, $msg: $_) -> Result<Response, ContractError> {
$$$
}'
Length of output: 225
Script:
#!/bin/bash
# Let's try a different approach using ripgrep to find migrate functions
# Search for migrate function definitions with and without env parameter
# Search for migrate functions with env parameter
rg "pub fn migrate.*deps.*env.*msg.*Result" -A 2
# Search for migrate functions without env parameter
rg "pub fn migrate.*deps.*msg.*Result" -A 2
Length of output: 27038
contracts/os/andromeda-vfs/src/contract.rs (1)
96-97
: LGTM! Verify consistency across other contracts.
The migration function changes look good. The env
parameter is now properly utilized instead of being ignored, which aligns with the requirements for time-based permissions.
Let's verify that this change is consistent across other contracts:
✅ Verification successful
✓ Change is consistent across all contracts
The verification results show that all contracts in the codebase consistently:
- Define the
migrate
function with anenv
parameter (not_env
) - Pass the
env
parameter toADOContract::default().migrate()
This confirms that the change in the VFS contract aligns with the codebase-wide pattern of properly utilizing the env
parameter in migration functions.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check if all contracts have been updated to use the env parameter in migrate
# Expected: All migrate functions should use the env parameter consistently
# Search for migrate function definitions
ast-grep --pattern 'pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg)'
# Search for migrate function calls to ensure they pass the env parameter
ast-grep --pattern 'ADOContract::default().migrate($deps, $env, $name, $version)'
Length of output: 165
Script:
#!/bin/bash
# Let's try a more flexible pattern to find migrate functions and their implementations
# Find migrate function definitions with any env parameter name
ast-grep --pattern 'pub fn migrate(deps: DepsMut, $env: Env, $msg: MigrateMsg)'
# Find migrate function definitions with underscore env
ast-grep --pattern 'pub fn migrate(deps: DepsMut, _env: Env, $msg: MigrateMsg)'
# Find migrate function calls with ADOContract
rg "ADOContract::default\(\).migrate" -A 1 -B 1
# Find all Rust files that might contain migrate functions
fd "contract.rs$" --exec grep -l "fn migrate"
Length of output: 15510
contracts/finance/andromeda-fixed-multisig/src/contract.rs (1)
137-138
: LGTM! Consistent update to migrate function signature.
The addition of the env
parameter to the migrate function and its propagation to the underlying ADO contract's migrate call is correct. This change aligns with similar updates across other contracts in the codebase.
contracts/os/andromeda-adodb/src/contract.rs (1)
96-97
: LGTM! Verify consistency across other contracts.
The addition of the env
parameter to the migrate function and its usage in ADOContract::default().migrate
aligns with the andromeda-std upgrade.
Let's verify that this migration signature change is consistent across other contracts:
✅ Verification successful
LGTM! Migration signature is consistent across contracts
The verification shows that all contracts (except andromeda-ics20) follow the same pattern:
- They accept the
env
parameter in the migrate function signature - They pass the
env
parameter toADOContract::default().migrate
The single exception (andromeda-ics20) is justified as it's an IBC-specific contract with custom migration logic.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for consistency of migrate function signatures across contracts
# Expected: All migrate functions should use the env parameter
# Search for migrate function definitions
ast-grep --pattern 'pub fn migrate(deps: DepsMut, env: Env, _msg: MigrateMsg)'
# Search for migrate function calls to ensure they pass the env parameter
ast-grep --pattern 'ADOContract::default().migrate(deps, env, $_)'
Length of output: 149
Script:
#!/bin/bash
# Let's try a more flexible pattern matching approach
# Search for migrate function definitions with env parameter
rg "pub fn migrate.*deps.*env.*msg.*ContractError" -A 2
# Search for migrate function implementations using ADOContract
rg "ADOContract::default\(\)\.migrate" -A 1
Length of output: 20935
contracts/os/andromeda-kernel/src/contract.rs (1)
156-157
: LGTM: Environment parameter properly integrated into migrate function.
The addition of the env
parameter to the migrate function and its propagation to the ADOContract::default().migrate()
call is correct. This change aligns with the broader permission time handling updates.
Let's verify that this change is consistent across other contracts:
✅ Verification successful
LGTM: Environment parameter consistently implemented across all contracts
The verification shows that all contracts in the codebase consistently implement the migrate function with the env
parameter and properly pass it to ADOContract::default().migrate()
. The only exception is the ICS20 contract which has a custom migration implementation due to its specific requirements. This confirms that the change in the kernel contract aligns with the codebase-wide pattern.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check if other contracts have similar migrate function signatures
# Expect: All migrate functions should accept and use the env parameter
# Search for migrate function definitions in contract.rs files
ast-grep --pattern 'pub fn migrate(deps: DepsMut, env: Env, $msg: $_) -> Result<$_, $_>'
Length of output: 90
Script:
#!/bin/bash
# Let's try a different approach to find migrate functions
# First, let's find all contract.rs files and then use ripgrep to search for migrate functions
# Find migrate function implementations with context
rg -U "pub fn migrate.*\{[\s\S]*?\}" -g "contract.rs" -A 5
Length of output: 32180
contracts/modules/andromeda-shunting/src/contract.rs (1)
193-194
: LGTM: Environment context properly utilized in migration.
The change to utilize the env
parameter in the migration function is consistent with the broader updates across contracts and ensures proper environment context handling during migrations.
Let's verify this change is consistent across other contracts:
✅ Verification successful
This should help us see all contract files with migrate functions and their implementations to verify consistency.
LGTM: Environment context properly utilized in migration across all contracts
The verification confirms that all contracts in the Andromeda ecosystem consistently implement the migrate
function with the same signature (deps: DepsMut, env: Env, _msg: MigrateMsg)
and properly pass the env
parameter to ADOContract::default().migrate
. The change in the shunting contract aligns with this standard pattern, with only minor formatting variations (space after comma) across implementations.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify migration function signatures across contracts
# Expect: All migrate functions should use the env parameter consistently
# Search for migrate function definitions
ast-grep --pattern 'pub fn migrate(deps: DepsMut, env: Env, $msg: $_) -> Result<$_, $_>'
Length of output: 90
Script:
#!/bin/bash
# Let's try a different approach to find migrate functions
# First, let's find all Rust files in the contracts directory
fd "contract.rs" contracts/ --exec rg -l "pub fn migrate"
# Then, let's examine the migrate function implementations
fd "contract.rs" contracts/ --exec rg -A 3 "pub fn migrate.*DepsMut.*Env.*Result"
Length of output: 9217
contracts/modules/andromeda-address-list/src/contract.rs (2)
160-161
: LGTM: Migrate function signature update looks correct.
The change to utilize the env
parameter in the migrate function is appropriate as it's needed for the ADOContract migration call.
Line range hint 1-195
: Verify implementation of start time functionality.
While this file contains the address list contract logic, it doesn't show the implementation of the start time feature mentioned in the PR objectives. The core changes for adding start time to LocalPermissions
and modifying the is_permissioned
function behavior should be visible somewhere.
Let's verify where these changes are implemented:
✅ Verification successful
Let's gather more information by checking the specific file that was found and searching for any start time related code.
Let's check the LocalPermission struct definition and its implementation since that's where the start time functionality should be implemented.
Let's check the rest of the LocalPermission implementation to see how the start time is used in permission checks.
Let's get the complete implementation of the is_permissioned function to see how start time is handled for all permission types.
Based on the gathered information, I can now provide a final response about the start time functionality implementation.
The start time functionality is properly implemented in the codebase.
The LocalPermission
enum in packages/std/src/ado_base/permissioning.rs
includes start time functionality:
- Each permission variant (Blacklisted, Limited, Whitelisted) has a
start: Option<Expiry>
field - The
is_permissioned
function implements start time checks for each variant:- For Blacklisted: Permission is granted before start time
- For Limited: Permission is granted before start time
- For Whitelisted: Permission is denied before start time
The implementation aligns with the PR objectives and correctly modifies the permission behavior based on start time.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for LocalPermission struct definition and is_permissioned function
# to find where the start time feature is implemented
echo "Searching for LocalPermission struct definition..."
ast-grep --pattern 'struct LocalPermission {
$$$
}'
echo "Searching for is_permissioned function implementation..."
ast-grep --pattern 'fn is_permissioned($$$) {
$$$
}'
# Search for any test files related to permission start time
echo "Searching for permission start time tests..."
rg -l "test_permission_start_time"
Length of output: 527
Script:
#!/bin/bash
# Check the permissioning file content
echo "Checking permissioning.rs content..."
cat packages/std/src/ado_contract/permissioning.rs
# Search for any start_time related code in the codebase
echo "Searching for start_time related code..."
rg "start_time" -A 3
Length of output: 106987
Script:
#!/bin/bash
# Search for LocalPermission struct and its implementation
echo "Checking LocalPermission struct definition..."
rg -A 10 "pub enum LocalPermission"
echo "Checking LocalPermission implementation..."
rg -A 10 "impl LocalPermission"
Length of output: 1873
Script:
#!/bin/bash
# Check the full LocalPermission implementation including is_permissioned function
echo "Checking full LocalPermission implementation..."
rg -B 5 -A 20 "fn is_permissioned" packages/std/src/ado_base/permissioning.rs
Length of output: 1039
Script:
#!/bin/bash
# Get the complete is_permissioned function implementation
echo "Getting complete is_permissioned implementation..."
rg -B 5 -A 50 "pub fn is_permissioned" packages/std/src/ado_base/permissioning.rs
Length of output: 2107
contracts/modules/andromeda-rates/src/contract.rs (1)
126-127
: LGTM! Consistent migration handler update.
The change to use the env
parameter in the migrate function is consistent with the broader updates across other contracts.
Let's verify the consistency of this change across other contracts:
✅ Verification successful
Migration handler update is consistent across all contracts
The search results confirm that all contracts in the repository follow the same pattern for the migrate function, using env
parameter (not _env
) and passing it to ADOContract::default().migrate()
. The only exception is the ICS20 contract which has a custom migration implementation due to its specific requirements.
The change in the rates contract aligns perfectly with this standardized pattern across the codebase.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify that all contracts have consistent migrate function signatures
# Expected: All migrate functions should use the env parameter similarly
# Search for migrate function signatures across all contract files
ast-grep --pattern 'pub fn migrate(deps: DepsMut, env: Env, _msg: MigrateMsg)'
# Also check for any potentially inconsistent signatures
ast-grep --pattern 'pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg)'
Length of output: 162
Script:
#!/bin/bash
# Let's try a different approach using ripgrep to search for migrate functions
# This will give us more context and handle potential variations in formatting
# Search for migrate function definitions with context
rg -U "pub fn migrate.*\{[\s\S]*?\}" -g "*.rs" -A 5
Length of output: 32175
contracts/modules/andromeda-curve/src/contract.rs (1)
212-213
: LGTM! Consistent migration handling.
The changes improve consistency by properly utilizing the environment context in migrations.
Let's verify if similar changes have been made in other contracts:
✅ Verification successful
Migration handling is consistent across all contracts
The verification shows that all contracts in the repository consistently use the env
parameter in their migrate functions, passing it correctly to ADOContract::default().migrate
. This confirms that the changes in the curve contract align with the codebase-wide pattern.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for consistent migration function signatures across contracts
# Expect: All migrate functions should accept and use the env parameter
# Search for migrate function signatures
ast-grep --pattern 'pub fn migrate(deps: DepsMut, env: Env, _msg: MigrateMsg)'
# Search for migrate function calls to ensure env is passed
ast-grep --pattern 'ADOContract::default().migrate($_, env, $_, $_)'
Length of output: 5332
contracts/finance/andromeda-cross-chain-swap/src/contract.rs (1)
223-224
: LGTM! Migration function update looks correct.
The changes to the migrate
function properly integrate the environment context by passing the env
parameter to ADOContract::default().migrate
. This aligns with the standardization of migration handling across contracts.
Note: These changes appear to be unrelated to the PR's main objective of adding start time to permissions. Consider splitting such refactoring changes into a separate PR for better traceability.
Let's verify if this migration change is consistent across other contracts:
✅ Verification successful
Migration function implementation is consistent across all contracts
The verification results show that the same migration pattern is used consistently across all 37 contracts in the repository, with each contract implementing the migrate
function that passes the env
parameter to ADOContract::default().migrate
. This confirms that the changes in the cross-chain-swap contract align with the codebase-wide standardization.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check if other contracts have similar migration function changes
# Expected: Similar changes in other contract files
# Search for migrate function implementations
ast-grep --pattern 'pub fn migrate(deps: DepsMut, env: Env, _msg: MigrateMsg)'
# Search for ADOContract migrate calls
rg 'ADOContract::default\(\)\.migrate\(deps,\s*env,'
Length of output: 5173
contracts/finance/andromeda-rate-limiting-withdrawals/src/contract.rs (1)
233-234
: LGTM on the migrate function signature update.
The change to use the env
parameter in the migrate function aligns with the consistent pattern being applied across other contracts in the codebase.
contracts/finance/andromeda-splitter/src/contract.rs (2)
267-268
: LGTM: Migration function update looks good
The change to include the env
parameter in the migrate function and pass it to ADOContract::default().migrate
is correct and aligns with the andromeda-std version update.
Line range hint 144-166
: Verify the DoS protection in execute_send
There's a concerning comment about potential DoS vulnerability in the nested loops. While the current implementation includes a limit of 5 coins as protection, we should verify if this is sufficient given the number of recipients allowed.
✅ Verification successful
The DoS protection is sufficient with reasonable limits in place
The codebase implements two key safeguards against potential DoS attacks in the splitter contract:
- Maximum of 5 coins allowed per transaction (as seen in the original code)
- Maximum of 100 recipients enforced across all splitter contracts
With these limits, the worst-case computational complexity is bounded to 5 * 100 = 500 iterations, which is a reasonable upper bound for blockchain operations.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check the maximum number of recipients allowed and analyze the potential computational complexity
# Search for recipient limit constraints
echo "Searching for recipient limits..."
rg -A 2 "recipients\.len\(\)"
# Search for any existing DoS-related issues or discussions
echo "Checking for related DoS discussions..."
gh issue list --search "DoS splitter"
Length of output: 3292
contracts/finance/andromeda-set-amount-splitter/src/contract.rs (1)
293-294
: LGTM! Verify consistent migration updates across contracts.
The update to utilize the env
parameter in the migrate function is correct and aligns with the broader changes for time-based permissions.
Let's verify that this change is consistently applied across other contracts:
✅ Verification successful
Migration function signature is consistently updated across contracts
The verification shows that all contracts (except andromeda-ics20
) consistently use the non-underscore env
parameter in their migrate functions and correctly pass it to ADOContract::default().migrate
. This confirms that the change in the set-amount-splitter contract aligns with the codebase-wide pattern.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for consistent migrate function signatures across contracts
# Expected: All migrate functions should use the env parameter similarly
# Search for migrate function definitions
ast-grep --pattern 'pub fn migrate(deps: DepsMut, env: Env, _msg: MigrateMsg)'
# Look for any potentially inconsistent migrate signatures
ast-grep --pattern 'pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg)'
Length of output: 162
Script:
#!/bin/bash
# Let's try a more flexible pattern search using ripgrep to find migrate function implementations
# Search for migrate function definitions with various parameter patterns
rg -U "pub fn migrate.*\{[\s\S]*ADOContract::default\(\)\.migrate" --type rust
# Also search for any migrate function definitions to ensure we catch all variants
rg "pub fn migrate.*deps: DepsMut" --type rust
Length of output: 16753
contracts/finance/andromeda-conditional-splitter/src/contract.rs (1)
295-296
: LGTM! Verify consistency across contracts.
The updated migrate function signature and implementation correctly incorporates the environment context, which aligns with the PR's objective to support time-based permissions.
Let's verify that this change is consistently applied across other contracts:
✅ Verification successful
Changes are consistently applied across all contracts
The verification shows that all contracts in the repository consistently use the updated migrate function signature, passing the env
parameter to ADOContract::default().migrate()
. The changes in the conditional splitter contract align with this pattern, confirming proper implementation across the codebase.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for consistency of migrate function signature across contracts
# Expected: All migrate functions should use the env parameter similarly
# Search for migrate function definitions
ast-grep --pattern 'pub fn migrate(deps: DepsMut, env: Env, _msg: MigrateMsg)'
# Search for migrate function calls to ensure they pass the env parameter
ast-grep --pattern 'ADOContract::default().migrate(deps, env, $_, $_)'
Length of output: 5334
contracts/data-storage/andromeda-counter/src/contract.rs (2)
300-301
: LGTM: Migrate function signature update
The change to use the env
parameter in the migrate function is correct and aligns with the contract's needs.
Line range hint 267-277
: Update permission check to handle start time
The has_permission
function needs to be updated to handle the new start time functionality mentioned in the PR objectives. Currently, it only checks for operator status and restriction type without considering the start time of permissions.
Consider updating the function to handle start time checks:
pub fn has_permission(storage: &dyn Storage, addr: &Addr) -> Result<bool, ContractError> {
let is_operator = ADOContract::default().is_owner_or_operator(storage, addr.as_str())?;
+ // If operator, no need to check start time
+ if is_operator {
+ return Ok(true);
+ }
let allowed = match RESTRICTION.load(storage)? {
CounterRestriction::Private => is_operator,
CounterRestriction::Public => true,
};
- Ok(is_operator || allowed)
+ Ok(allowed)
}
Let's verify if other contracts have implemented the start time functionality:
contracts/fungible-tokens/andromeda-cw20/src/contract.rs (1)
392-393
: LGTM! The migrate function signature update is consistent with the codebase changes.
The addition of the env
parameter to the migrate
function and its propagation to the ADOContract::migrate
call is correct. This change aligns with the broader effort to standardize migration interfaces across contracts, which is necessary for supporting the new permission start time feature.
packages/std/src/ado_contract/execute.rs (2)
116-117
:
Validate permission clearing during migration
The migration now clears all permissions using the owner's address, which is good for security. However, there are a few concerns:
- The permission clearing is not validated for success
- The migration might fail silently if permission clearing fails
- Existing migrations might be affected by this change
Consider applying this diff to handle potential failures:
let owner = self.owner.load(deps.storage)?;
// Clear all permissions
- self.execute_clear_all_permissions(ExecuteContext::new(
+ self.execute_clear_all_permissions(ExecuteContext::new(
deps.branch(),
MessageInfo {
sender: owner,
funds: vec![],
},
env,
- ))?;
+ )).map_err(|e| ContractError::Std(StdError::generic_err(format!("Failed to clear permissions: {}", e))))?;
Let's verify the impact on existing migrations:
Also applies to: 148-158
✅ Verification successful
Based on the search results, I can now generate the final response:
Migration changes are safe and well-implemented
The codebase scan shows that all contracts use the standard ADOContract::default().migrate()
implementation, with only one exception (andromeda-ics20
) having custom migration logic. The permission clearing during migration is a safe addition because:
- All contracts rely on the base implementation, ensuring consistent behavior
- The permission clearing is owner-restricted, maintaining security
- No contracts have custom permission handling during migration that could conflict
While the suggested error handling improvement is valid, the current implementation is safe as the execute_clear_all_permissions
already propagates errors through the ?
operator.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for existing migrations that might be affected by the permission clearing change
# Look for migrate function calls
rg -A 5 "fn\s+migrate"
# Look for permission-related migrations
rg -A 5 "permission" --type rust | grep -i "migrate"
Length of output: 25298
Line range hint 1-1
: Replace panic with proper error handling for AMP Receive
The addition of a panic for AMPReceive
messages is concerning:
- Using
panic!
in production code is generally not recommended - This is a breaking change not mentioned in the PR objectives
- There's no documentation on how AMP Receive should be handled separately
Consider replacing the panic with proper error handling:
AndromedaMsg::Permissioning(msg) => self.execute_permissioning(ctx, msg),
- AndromedaMsg::AMPReceive(_) => panic!("AMP Receive should be handled separately"),
+ AndromedaMsg::AMPReceive(_) => Err(ContractError::InvalidOperation {
+ msg: Some("AMP Receive must be handled separately using execute_amp_receive".to_string())
+ }),
Let's check for existing AMP Receive usage that might break:
contracts/finance/andromeda-vesting/src/contract.rs (1)
364-365
: LGTM! Verify consistent migration signature updates across contracts.
The change to use the env
parameter in the migrate function is safe and aligns with the standardization of migrate function signatures.
Let's verify that this change is consistent across other contracts:
✅ Verification successful
Migrate function signature is consistently updated across contracts
The verification shows that almost all contracts follow the same migrate function signature pattern pub fn migrate(deps: DepsMut, env: Env, _msg: MigrateMsg)
and use the env
parameter in ADOContract::default().migrate
. Only one contract (andromeda-ics20) has a slightly different implementation due to its specific ICS-20 requirements, which is acceptable.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for inconsistent migrate function signatures across contracts
# Expect: All migrate functions should have the same signature pattern
# Search for migrate function signatures
ast-grep --pattern 'pub fn migrate(deps: DepsMut, env: Env, _msg: MigrateMsg)'
Length of output: 80
Script:
#!/bin/bash
# Let's try a more flexible pattern to catch migrate function signatures
# This will help us identify any variations in the signature
# Search for migrate function signatures with ripgrep for better context
rg "pub fn migrate.*DepsMut.*Env.*MigrateMsg" -A 2
Length of output: 13523
contracts/data-storage/andromeda-graph/src/contract.rs (1)
422-423
: LGTM! The migrate function signature update looks good.
The change to utilize the env
parameter in the migrate function is consistent with the broader changes across contracts and aligns with the PR objectives for time-based permissions support.
Let's verify the consistency of this change across other contracts:
✅ Verification successful
The migrate function signature is consistent across all contracts
The verification shows that all contracts (except andromeda-ics20
which has a custom migration) follow the same pattern:
- They use the
env
parameter (not_env
) - They pass the
env
parameter toADOContract::default().migrate
- The signature matches:
pub fn migrate(deps: DepsMut, env: Env, _msg: MigrateMsg)
This confirms that the change in andromeda-graph
contract aligns with the codebase-wide convention.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify that other contracts have similar migrate function signatures
# Expected: All migrate functions should use the env parameter consistently
# Search for migrate function signatures across all contract files
ast-grep --pattern 'pub fn migrate(deps: DepsMut, env: Env, _msg: MigrateMsg)'
# Also check for any inconsistent signatures that might have been missed
ast-grep --pattern 'pub fn migrate(deps: DepsMut, _env: Env, _msg: MigrateMsg)'
Length of output: 162
Script:
#!/bin/bash
# Let's try a more flexible pattern to find migrate functions
# Search for migrate function implementations across contract files
rg -U "pub fn migrate.*\{[\s\S]*?\}" --type rust -g 'contract.rs'
# Also search for ADOContract::default().migrate usage
rg "ADOContract::default\(\)\.migrate" --type rust
Length of output: 19384
contracts/fungible-tokens/andromeda-cw20-exchange/src/contract.rs (3)
425-426
: LGTM: Migrate function signature updated correctly
The change to utilize the env
parameter in the migrate function is consistent with the broader refactor for supporting start time functionality. The implementation correctly passes the environment context to the underlying ADOContract migrate method.
Line range hint 237-309
: Consider adding start/end time validation
As noted in the PR objectives, there's currently no validation to prevent setting a start time that occurs after the end time. Consider adding this validation to ensure temporal consistency.
let end_expiration = if let Some(duration) = duration {
ensure!(!duration.is_zero(), ContractError::InvalidExpiration {});
- expiration_from_milliseconds(
+ let end_time = expiration_from_milliseconds(
start_time
// If start time isn't provided, it is set one second in advance from the current time
.unwrap_or(Expiry::FromNow(Milliseconds::from_seconds(1)))
.get_time(&env.block)
.plus_milliseconds(duration),
- )?
+ )?;
+ // Validate that start_time is before end_time
+ if let Some(start) = start_time {
+ ensure!(
+ start.get_time(&env.block) < end_time.get_time(&env.block),
+ ContractError::InvalidExpiration {}
+ );
+ }
+ end_time
} else {
Expiration::Never {}
};
Line range hint 332-421
: LGTM: Sale execution properly enforces start time
The implementation correctly validates the start time before allowing purchases, with clear error handling:
- Checks if sale has started using
sale.start_time.is_expired
- Returns
SaleNotStarted
error if the start time hasn't been reached - Maintains proper ordering of time-based validations
contracts/finance/andromeda-weighted-distribution-splitter/src/contract.rs (1)
437-438
: LGTM: Environment parameter properly integrated in migrate function
The changes correctly incorporate the environment context in the migration process, aligning with the standardization efforts across contracts. The env
parameter is properly passed through to the underlying ADOContract::default().migrate()
call.
contracts/non-fungible-tokens/andromeda-cw721/src/contract.rs (1)
509-510
: LGTM! Verify andromeda-std version update.
The migrate function has been correctly updated to include and forward the env
parameter, which is necessary for the new start time functionality in permissions.
Let's verify the andromeda-std version update mentioned in the PR objectives:
✅ Verification successful
Version update verification needed
The andromeda-std dependency in andromeda-cw721 is using workspace inheritance (workspace = true
) rather than an explicit version. Let's check the workspace-level dependency version.
Version update confirmed
The andromeda-std version has been updated to 1.4.0 as mentioned in the PR objectives. The migrate function has been correctly updated to include and forward the env
parameter.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify andromeda-std version update from 1.3.4 to 1.4.0
# Check Cargo.toml for andromeda-std dependency version
rg -U 'andromeda-std.*version.*=.*"1\.4\.0"' Cargo.toml
# Check for any remaining old versions
rg -U 'andromeda-std.*version.*=.*"1\.3\.4"' Cargo.toml
Length of output: 115
Script:
#!/bin/bash
# Let's check the actual content of Cargo.toml to see the andromeda-std dependency
fd Cargo.toml --exec cat {}
Length of output: 61514
Script:
#!/bin/bash
# Let's check the specific Cargo.toml for andromeda-cw721 contract
cat contracts/non-fungible-tokens/andromeda-cw721/Cargo.toml
Length of output: 1319
Script:
#!/bin/bash
# Check workspace-level andromeda-std version in root Cargo.toml
rg 'andromeda-std.*=.*path.*=.*"./packages/std"' Cargo.toml
Length of output: 143
Script:
#!/bin/bash
# Let's check the version in the andromeda-std package's Cargo.toml directly
cat packages/std/Cargo.toml | head -n 5
Length of output: 133
contracts/finance/andromeda-validator-staking/src/contract.rs (2)
105-106
: LGTM! The env parameter is now properly utilized.
The removal of the underscore from _env
parameter is correct as the environment context is needed for time-based permission checks in the base contract.
Line range hint 391-395
: Verify permission checks with the new start time feature.
The is_permissioned
check in the restaking logic will now consider start times. Please ensure this behavior is covered in the test cases, particularly:
- Restaking attempts before permission start time
- Restaking attempts after start time but before end time
- Restaking attempts after both start and end times
contracts/fungible-tokens/andromeda-lockdrop/src/contract.rs (1)
135-136
: LGTM! Migration function signature updated correctly.
The migrate
function has been properly updated to include and forward the env
parameter to the underlying ADOContract
migration implementation.
contracts/non-fungible-tokens/andromeda-marketplace/src/contract.rs (2)
903-904
: LGTM: Migrate function signature update
The addition of the env
parameter to the migrate function is correct and follows best practices by providing environmental context during migration.
Line range hint 267-273
: LGTM: Robust start time validation implementation
The start time validation is well-implemented across both native and CW20 purchase paths, ensuring consistent behavior. The code correctly prevents purchases before the sale's start time while maintaining existing end time validation.
Also applies to: 466-472
contracts/fungible-tokens/andromeda-cw20-staking/src/contract.rs (1)
886-887
: LGTM! Verify similar changes across related contracts.
The modification to include and forward the env
parameter in the migrate function is correct and aligns with the expected changes.
Let's verify that similar changes have been made consistently across other contracts:
✅ Verification successful
Changes to migrate function are consistent across the codebase
The verification shows that all contracts (except andromeda-ics20
) follow the same pattern of accepting and forwarding the env
parameter in their migrate functions. The implementation in andromeda-cw20-staking
matches the standard pattern used across the codebase:
pub fn migrate(deps: DepsMut, env: Env, _msg: MigrateMsg) -> Result<Response, ContractError> {
ADOContract::default().migrate(deps, env, CONTRACT_NAME, CONTRACT_VERSION)
}
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for consistency in migrate function signatures across contracts
# Expect: All migrate functions should accept and forward the env parameter
# Search for migrate function definitions
ast-grep --pattern 'pub fn migrate(deps: DepsMut, env: Env, $msg: $_) -> Result<$_, $_>'
# Search for migrate function calls to ensure env is forwarded
ast-grep --pattern 'migrate(deps, env, $_)'
Length of output: 136
Script:
#!/bin/bash
# Let's try a different approach to find migrate functions and their implementations
# Find all Rust files that might contain migrate functions
echo "=== Files containing 'migrate' function ==="
rg -l "fn\s+migrate" --type rust
echo -e "\n=== Migrate function implementations ==="
# Show the actual migrate function implementations with context
rg "fn\s+migrate.*deps.*->.*Result" -A 3 --type rust
echo -e "\n=== Migrate function calls ==="
# Look for migrate function calls
rg "\.migrate\(.*deps.*\)" --type rust
Length of output: 23302
packages/std/src/ado_contract/permissioning.rs (2)
257-261
: LGTM: Clear permissions implementation looks good.
The implementation is clean and includes proper authorization checks in the execute method.
Also applies to: 346-358
593-596
: Add validation for start and end time relationship.
As mentioned in the PR objectives, there's currently no validation to prevent users from setting a start time that occurs after the end time. This could lead to unexpected behavior.
Also applies to: 827-830, 889-892
contracts/finance/andromeda-rate-limiting-withdrawals/src/contract.rs
Outdated
Show resolved
Hide resolved
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 and nitpick comments (2)
contracts/ecosystem/andromeda-vault/src/contract.rs (2)
393-394
: LGTM! Consider adding migration documentation.The migration function has been correctly updated to include and pass the environment context. This change aligns with the contract's evolution to support time-based features.
Consider adding a doc comment explaining the migration process and any state changes that occur during migration.
+/// Migrates the contract to a new version. +/// +/// # Arguments +/// +/// * `deps` - Mutable dependencies +/// * `env` - Environment information +/// * `_msg` - Migration message (unused) pub fn migrate(deps: DepsMut, env: Env, _msg: MigrateMsg) -> Result<Response, ContractError> {
Line range hint
1-500
: Consider architectural implications of time-based permissions.While the migration changes are in place, there are several areas that might need future updates to fully support time-based permissions:
- Strategy management operations might need to respect permission start times
- Withdrawal operations might need to verify permission timing
- Permission checks in
execute_update_strategy
might need to consider start timesConsider creating follow-up tickets to track these potential updates. Would you like me to help create these issues?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (26)
contracts/app/andromeda-app-contract/src/contract.rs
(1 hunks)contracts/data-storage/andromeda-boolean/src/contract.rs
(2 hunks)contracts/data-storage/andromeda-counter/src/contract.rs
(1 hunks)contracts/data-storage/andromeda-graph/src/contract.rs
(1 hunks)contracts/data-storage/andromeda-point/src/contract.rs
(1 hunks)contracts/data-storage/andromeda-primitive/src/contract.rs
(1 hunks)contracts/data-storage/andromeda-string-storage/src/contract.rs
(1 hunks)contracts/ecosystem/andromeda-vault/src/contract.rs
(1 hunks)contracts/finance/andromeda-conditional-splitter/src/contract.rs
(1 hunks)contracts/finance/andromeda-cross-chain-swap/src/contract.rs
(1 hunks)contracts/finance/andromeda-fixed-multisig/src/contract.rs
(1 hunks)contracts/finance/andromeda-rate-limiting-withdrawals/src/contract.rs
(1 hunks)contracts/finance/andromeda-set-amount-splitter/src/contract.rs
(1 hunks)contracts/finance/andromeda-splitter/src/contract.rs
(1 hunks)contracts/finance/andromeda-timelock/src/contract.rs
(1 hunks)contracts/finance/andromeda-validator-staking/src/contract.rs
(1 hunks)contracts/finance/andromeda-vesting/src/contract.rs
(1 hunks)contracts/finance/andromeda-weighted-distribution-splitter/src/contract.rs
(1 hunks)contracts/fungible-tokens/andromeda-cw20-exchange/src/contract.rs
(1 hunks)contracts/fungible-tokens/andromeda-cw20-staking/src/contract.rs
(1 hunks)contracts/fungible-tokens/andromeda-cw20/src/contract.rs
(1 hunks)contracts/fungible-tokens/andromeda-lockdrop/src/contract.rs
(1 hunks)contracts/fungible-tokens/andromeda-merkle-airdrop/src/contract.rs
(2 hunks)contracts/modules/andromeda-curve/src/contract.rs
(1 hunks)contracts/modules/andromeda-date-time/src/contract.rs
(1 hunks)contracts/modules/andromeda-rates/src/contract.rs
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (25)
- contracts/app/andromeda-app-contract/src/contract.rs
- contracts/data-storage/andromeda-boolean/src/contract.rs
- contracts/data-storage/andromeda-counter/src/contract.rs
- contracts/data-storage/andromeda-graph/src/contract.rs
- contracts/data-storage/andromeda-point/src/contract.rs
- contracts/data-storage/andromeda-primitive/src/contract.rs
- contracts/data-storage/andromeda-string-storage/src/contract.rs
- contracts/finance/andromeda-conditional-splitter/src/contract.rs
- contracts/finance/andromeda-cross-chain-swap/src/contract.rs
- contracts/finance/andromeda-fixed-multisig/src/contract.rs
- contracts/finance/andromeda-rate-limiting-withdrawals/src/contract.rs
- contracts/finance/andromeda-set-amount-splitter/src/contract.rs
- contracts/finance/andromeda-splitter/src/contract.rs
- contracts/finance/andromeda-timelock/src/contract.rs
- contracts/finance/andromeda-validator-staking/src/contract.rs
- contracts/finance/andromeda-vesting/src/contract.rs
- contracts/finance/andromeda-weighted-distribution-splitter/src/contract.rs
- contracts/fungible-tokens/andromeda-cw20-exchange/src/contract.rs
- contracts/fungible-tokens/andromeda-cw20-staking/src/contract.rs
- contracts/fungible-tokens/andromeda-cw20/src/contract.rs
- contracts/fungible-tokens/andromeda-lockdrop/src/contract.rs
- contracts/fungible-tokens/andromeda-merkle-airdrop/src/contract.rs
- contracts/modules/andromeda-curve/src/contract.rs
- contracts/modules/andromeda-date-time/src/contract.rs
- contracts/modules/andromeda-rates/src/contract.rs
🔇 Additional comments (1)
contracts/ecosystem/andromeda-vault/src/contract.rs (1)
Line range hint 1-500
: Verify compatibility with time-based permissions.
Let's verify all permission-related code paths to ensure compatibility with the new time-based permission system.
✅ Verification successful
Based on the search results, I can now provide a final response:
Vault contract's permission system is compatible with time-based permissions
The vault contract relies on ADOContract's default permission system through composition rather than inheritance, using standard permission checks:
- Uses
ADOContract::default().is_contract_owner()
for ownership verification - Ownership is managed through the standard
ContractOwnerResponse
type - No direct permission expiration handling in the vault - it's delegated to ADOContract
- Strategy operator checks have been replaced with owner checks that are compatible with the permission system
The vault contract inherits all time-based permission functionality through its use of ADOContract's default implementation, with no custom permission logic that could conflict with the new time-based system.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Find all permission and authorization checks in the codebase
# to ensure compatibility with the new time-based permission system.
# Search for permission checks
echo "Searching for permission-related function calls..."
rg -A 3 "is_contract_owner|is_operator|Unauthorized|NotAssignedOperator"
# Search for ADOContract usage that might involve permissions
echo "Searching for ADOContract usage..."
ast-grep --pattern 'ADOContract::default().$_($$$)'
Length of output: 100333
Script:
#!/bin/bash
# Let's search for permission-related code in the vault contract and its dependencies
# Search for permission-related code in the vault contract
echo "=== Searching permission checks in vault contract ==="
rg -A 5 "is_contract_owner|is_operator|Unauthorized|NotAssignedOperator" contracts/ecosystem/andromeda-vault/
# Search for permission-related imports and usage
echo "=== Searching permission-related imports in vault contract ==="
rg "use.*ownership|use.*permission" contracts/ecosystem/andromeda-vault/
# Search for ADOContract usage in vault
echo "=== Searching ADOContract usage in vault ==="
ast-grep --pattern 'ADOContract::default().$_($$$)' contracts/ecosystem/andromeda-vault/
# Search for time-based permission code
echo "=== Searching time-based permission code ==="
rg -A 5 "expiration|start_time|end_time" contracts/ecosystem/andromeda-vault/
Length of output: 6906
This still has the same issue of clearing all permissioning anytime the user migrates. |
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: 1
🧹 Outside diff range and nitpick comments (3)
CHANGELOG.md (1)
90-90
: Enhance the changelog entry with behavioral details.While the entry correctly documents the addition of the start time feature, it would be more helpful to users if it included the key behavioral changes. Consider expanding it to:
-Permissions now have an optional start time [(#668)](https://github.com/andromedaprotocol/andromeda-core/pull/668) +Permissions now have an optional start time with the following behavior [(#668)](https://github.com/andromedaprotocol/andromeda-core/pull/668): +- Blacklisted permissions return true if start time hasn't been reached +- Whitelisted permissions return the opposite of strict setting if start time hasn't been reached +- End time checks are bypassed if start time hasn't been reachedcontracts/math/andromeda-date-time/src/contract.rs (1)
124-125
: LGTM: Standardized migrate function signature with potential for feature integrationThe change correctly adds and forwards the
env
parameter to the ADOContract's migrate method. Given this contract's datetime functionality, consider if it could be utilized for the new permission start time feature.Consider exposing utility functions from this contract that could be used by the permissions system for start time validation and comparison operations.
contracts/accounts/andromeda-fixed-multisig/src/contract.rs (1)
137-138
: LGTM: Standardized migrate function signature with permission system considerationsThe change correctly adds and forwards the
env
parameter to the ADOContract's migrate method. Given this contract's voter permission system, consider aligning its time-based functionality (max_voting_period) with the new permission start time feature for consistency in temporal permission handling across the platform.Consider standardizing how temporal constraints are handled between the multisig voting system and the new permission start time feature to ensure a consistent user experience across different types of time-bound permissions.
📜 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 (13)
CHANGELOG.md
(1 hunks)contracts/accounts/andromeda-fixed-multisig/src/contract.rs
(1 hunks)contracts/finance/andromeda-set-amount-splitter/src/contract.rs
(1 hunks)contracts/finance/andromeda-splitter/src/contract.rs
(1 hunks)contracts/finance/andromeda-weighted-distribution-splitter/src/contract.rs
(1 hunks)contracts/math/andromeda-counter/src/contract.rs
(1 hunks)contracts/math/andromeda-curve/src/contract.rs
(2 hunks)contracts/math/andromeda-date-time/src/contract.rs
(1 hunks)contracts/math/andromeda-graph/src/contract.rs
(1 hunks)contracts/math/andromeda-point/src/contract.rs
(1 hunks)contracts/math/andromeda-shunting/src/contract.rs
(1 hunks)tests-integration/tests/auction_app.rs
(3 hunks)tests-integration/tests/marketplace_app.rs
(5 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
- contracts/finance/andromeda-set-amount-splitter/src/contract.rs
- contracts/finance/andromeda-splitter/src/contract.rs
- tests-integration/tests/auction_app.rs
- contracts/finance/andromeda-weighted-distribution-splitter/src/contract.rs
🔇 Additional comments (12)
contracts/math/andromeda-point/src/contract.rs (1)
72-73
: LGTM: Standardized migrate function signature
The change correctly adds and forwards the env
parameter to the ADOContract's migrate method, maintaining consistency with other contracts in the codebase.
contracts/math/andromeda-curve/src/contract.rs (2)
205-206
: LGTM: Migration function signature update
The migration function signature has been updated to include the env
parameter, maintaining consistency with the ADO contract interface.
63-63
: Verify permission initialization with new start time feature
The permission initialization now uses whitelisted(None, None)
which supports the new start time feature. Ensure this aligns with the intended behavior for operator permissions.
Also applies to: 69-69
✅ Verification successful
Permission initialization with whitelisted(None, None)
is consistently used across the codebase
The verification shows that LocalPermission::whitelisted(None, None)
is consistently used across multiple contracts and packages in the codebase, including:
- Standard library (
packages/std
) - Other math contracts
- NFT contracts (marketplace, auction, crowdfund)
- Data storage contracts
- Module contracts
This confirms that the permission initialization in the curve contract aligns with the established pattern throughout the codebase.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check for consistent permission initialization across the codebase
rg -A 2 "LocalPermission::whitelisted\(None, None\)"
Length of output: 6586
contracts/math/andromeda-counter/src/contract.rs (1)
300-301
: LGTM: Migration function signature update
The migration function signature has been updated to include the env
parameter, maintaining consistency with the ADO contract interface.
tests-integration/tests/marketplace_app.rs (6)
205-205
: LGTM: Limited permission test case correctly updated.
The test case properly verifies that limited permissions are not supported in the address list contract, and the new start_time parameter is correctly set to None.
224-224
: LGTM: Blacklist permission test case correctly updated.
The test case properly verifies that blacklisted buyers cannot perform purchases, and the new start_time parameter is correctly set to None.
258-258
: LGTM: Whitelist permission test case correctly updated.
The test case properly verifies that whitelisted buyers can perform purchases, and the new start_time parameter is correctly set to None.
618-618
: LGTM: CW20 restricted test case correctly updated.
The test case properly verifies CW20 token restrictions with whitelisted addresses, and the new start_time parameter is correctly set to None.
900-900
: LGTM: CW20 unrestricted test case correctly updated.
The test case properly verifies unrestricted CW20 token behavior with whitelisted addresses, and the new start_time parameter is correctly set to None.
205-205
: 🛠️ Refactor suggestion
Test coverage needs expansion for start_time functionality.
While the changes correctly update the LocalPermission
constructors to include the new start_time
parameter, the tests don't actively validate the start time functionality. Consider adding test cases that:
- Verify permissions with non-None start times
- Test permission behavior before and after start time
- Validate edge cases (e.g., start time in the past/future)
Add these test cases to thoroughly validate the start time functionality:
#[test]
fn test_permission_with_start_time() {
// ... test setup ...
// Test future start time
let future_time = env.block.time.plus_seconds(100);
address_list
.execute_actor_permission(
&mut router,
owner.clone(),
vec![AndrAddr::from_string(buyer.clone())],
LocalPermission::whitelisted(Some(future_time), None),
)
.unwrap();
// Verify permission is not active before start time
let err = marketplace.execute_buy(...).unwrap_err();
assert_eq!(err, ContractError::Unauthorized {});
// Move time past start time
router.set_block(BlockInfo {
time: future_time.plus_seconds(1),
..router.block_info()
});
// Verify permission is active after start time
marketplace.execute_buy(...).unwrap();
}
Also applies to: 224-224, 258-258, 618-618, 900-900
contracts/math/andromeda-shunting/src/contract.rs (2)
193-194
: LGTM: Migrate function signature follows standard patterns
The updated migrate function signature correctly includes the env
parameter and follows CosmWasm contract migration patterns.
193-194
: Consider handling permission preservation during migration
Based on the PR comments, there's a known issue about clearing permissions during migration. Consider implementing permission preservation logic in the migration function to prevent this.
Let's verify the migration behavior in other contracts:
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: 1
🧹 Outside diff range and nitpick comments (2)
tests-integration/tests/permissions_orch.rs (2)
32-32
: Remove unnecessary.clone()
calls after.into_string()
When you call
.into_string()
, it consumes theAddr
and returns aString
. The subsequent.clone()
is unnecessary and can be removed to simplify the code.Here's how you can simplify the code:
32- sender.clone().into_string().clone(), + sender.to_string(), 116- owner: Some(sender.clone().into_string().clone()), + owner: Some(sender.to_string()), 172- actors: vec![AndrAddr::from_string(sender.clone().into_string())], + actors: vec![AndrAddr::from_string(sender.to_string())],Also applies to: 116-116, 172-172
185-204
: Verify that permissions are correctly preserved after migrationCurrently, the test only verifies that the number of permissions remains the same after migration by asserting
assert_eq!(permissions.len(), 1)
. To ensure that permissions are fully preserved, consider asserting that the permissions before and after migration are identical.Here's how you can enhance the test:
// Before migration let permissions_before: Vec<PermissionInfo> = marketplace_juno .query(&QueryMsg::Permissions { actor: sender.clone().to_string(), limit: None, start_after: None, }) .unwrap(); // Migrate marketplace_juno.migrate(&MigrateMsg {}, new_code_id).unwrap(); // After migration let permissions_after: Vec<PermissionInfo> = marketplace_juno .query(&QueryMsg::Permissions { actor: sender.to_string(), limit: None, start_after: None, }) .unwrap(); // Assert that permissions are the same assert_eq!(permissions_before, permissions_after);This ensures that the permissions' details are preserved exactly through the migration process.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
tests-integration/tests/mod.rs
(1 hunks)tests-integration/tests/permissions_orch.rs
(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- tests-integration/tests/mod.rs
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: 5
🧹 Nitpick comments (8)
CHANGELOG.md (1)
98-98
: Document start time validation limitationThe changelog should mention that there's currently no validation to prevent users from setting a start time that occurs after the end time. This is an important limitation that users should be aware of.
-Permissions now have an optional start time [(#668)](https://github.com/andromedaprotocol/andromeda-core/pull/668) +Permissions now have an optional start time [(#668)](https://github.com/andromedaprotocol/andromeda-core/pull/668). Note: Currently no validation between start and end times.packages/std/src/ado_contract/permissioning.rs (3)
257-261
: Consider adding event emission for permission clearing.The
clear_all_permissions
function performs a destructive operation. While it's correctly restricted to owner access, adding event emission would help with tracking and auditing.pub fn clear_all_permissions(store: &mut dyn Storage) -> Result<(), ContractError> { permissions().clear(store); + // Consider emitting an event here Ok(()) }
346-358
: Add safety mechanism for clearing all permissions.The
execute_clear_all_permissions
function could benefit from additional safety measures to prevent accidental execution.Consider:
- Adding a confirmation parameter
- Implementing a two-step process
- Adding detailed event attributes about the number of permissions cleared
865-938
: Enhance test coverage for start time functionality.While the test comprehensively covers basic start time scenarios, consider adding tests for:
- Edge cases where start time equals end time
- Cases where start time is after end time
- Scenarios combining start and end times with different permission types
packages/std/src/ado_base/permissioning.rs (2)
Line range hint
101-144
: Refactor duplicated start time logic in is_permissioned methodThe start time checking logic is duplicated across all variants. Consider extracting this into a private helper method to improve maintainability and reduce code duplication.
Consider refactoring like this:
impl LocalPermission { fn check_start_time(&self, env: &Env) -> Option<bool> { match self { Self::Blacklisted { start, .. } | Self::Limited { start, .. } | Self::Whitelisted { start, .. } => { start.as_ref().map(|s| !s.get_time(&env.block).is_expired(&env.block)) } } } }Then use it in
is_permissioned
:if let Some(not_started) = self.check_start_time(env) { return if not_started { match self { Self::Blacklisted { .. } | Self::Limited { .. } => true, Self::Whitelisted { .. } => !strict, } } }
228-235
: Optimize cloning in get_permission methodThe method unnecessarily clones the LocalPermission in both match arms.
Consider using references to avoid cloning:
match self { - Self::Local(local_permission) => Ok(local_permission.clone()), + Self::Local(local_permission) => Ok(local_permission.to_owned()), Self::Contract(contract_address) => { let addr = contract_address.get_raw_address(&deps)?; - let local_permission = AOSQuerier::get_permission(&deps.querier, &addr, actor)?; - Ok(local_permission) + AOSQuerier::get_permission(&deps.querier, &addr, actor) } }contracts/data-storage/andromeda-form/src/contract.rs (1)
167-168
: Consider preserving permissions during migrationThe migration function has been updated to use the
env
parameter, but there are concerns about permissions being cleared during migrations (see PR comments).Consider implementing a permission preservation strategy during migrations. This could involve:
- Backing up permissions before migration
- Restoring permissions after migration
- Adding validation to ensure permissions remain intact
Would you like help designing this preservation mechanism?
packages/std/src/ado_contract/execute.rs (1)
157-193
: Address permission clearing during migrationBased on the PR comments from user crnbarr93, the current implementation still has the issue of clearing all permissioning whenever the user migrates. Consider implementing a more robust migration strategy that preserves permissions while updating their structure.
Consider these alternatives:
- Implement a two-phase migration where permissions are first converted to the new structure before being cleared
- Add a feature flag to control permission clearing during migration
- Implement a rollback mechanism in case of migration failures
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (16)
CHANGELOG.md
(1 hunks)contracts/data-storage/andromeda-form/src/contract.rs
(2 hunks)contracts/finance/andromeda-splitter/src/contract.rs
(1 hunks)contracts/fungible-tokens/andromeda-cw20/src/testing/tests.rs
(2 hunks)contracts/math/andromeda-distance/src/contract.rs
(1 hunks)contracts/modules/andromeda-rates/src/contract.rs
(1 hunks)contracts/modules/andromeda-schema/src/contract.rs
(1 hunks)contracts/non-fungible-tokens/andromeda-auction/src/contract.rs
(3 hunks)contracts/non-fungible-tokens/andromeda-crowdfund/src/contract.rs
(2 hunks)contracts/non-fungible-tokens/andromeda-marketplace/src/contract.rs
(1 hunks)contracts/non-fungible-tokens/andromeda-marketplace/src/testing/tests.rs
(6 hunks)packages/std/src/ado_base/permissioning.rs
(6 hunks)packages/std/src/ado_contract/execute.rs
(3 hunks)packages/std/src/ado_contract/permissioning.rs
(18 hunks)tests-integration/tests/auction_app.rs
(3 hunks)tests-integration/tests/marketplace_app.rs
(5 hunks)
🚧 Files skipped from review as they are similar to previous changes (8)
- contracts/fungible-tokens/andromeda-cw20/src/testing/tests.rs
- contracts/modules/andromeda-rates/src/contract.rs
- contracts/non-fungible-tokens/andromeda-auction/src/contract.rs
- contracts/non-fungible-tokens/andromeda-marketplace/src/contract.rs
- contracts/non-fungible-tokens/andromeda-crowdfund/src/contract.rs
- tests-integration/tests/auction_app.rs
- tests-integration/tests/marketplace_app.rs
- contracts/finance/andromeda-splitter/src/contract.rs
🔇 Additional comments (12)
contracts/modules/andromeda-schema/src/contract.rs (1)
87-88
: LGTM: Migrate function signature updated correctly
The migrate function has been properly updated to include the env
parameter, maintaining consistency with other contracts and correctly passing the environment context to the ADOContract's migrate method.
CHANGELOG.md (1)
98-98
: Move and expand the changelog entry
The changelog entry should be moved to the "Added" section under "Unreleased" since this is a new feature that hasn't been released yet. Additionally, consider expanding the entry to better describe the feature's behavior.
contracts/non-fungible-tokens/andromeda-marketplace/src/testing/tests.rs (4)
232-232
: LGTM: Permission initialization aligns with new start time feature.
The updated LocalPermission::whitelisted(None, None)
correctly implements the new permission structure with optional start and end times.
1027-1027
: LGTM: Consistent permission implementation in CW20 authorization test.
The test correctly verifies permission setting using the new structure with both start and end times as None
.
1085-1085
: LGTM: Consistent permission handling in deauthorization test.
The test correctly verifies permission removal with the new permission structure.
1185-1185
: LGTM: Comprehensive test coverage for NFT contract authorization.
The test properly verifies NFT contract authorization with the new permission structure, maintaining consistency with CW20 authorization patterns.
packages/std/src/ado_contract/permissioning.rs (1)
593-596
: Add validation for start and end time relationship.
As mentioned in the PR objectives, there's currently no validation to prevent users from setting a start time that occurs after the end time. This could lead to unexpected behavior.
Also applies to: 636-639, 664-667, 690-693
packages/std/src/ado_base/permissioning.rs (2)
223-225
: 🛠️ Refactor suggestion
Remove unnecessary mutability from get_permission method
The method is marked as &mut self
but doesn't perform any mutations.
pub fn get_permission(
- &mut self,
+ &self,
deps: Deps,
actor: &str,
) -> Result<LocalPermission, ContractError> {
Likely invalid or redundant comment.
Line range hint 1-238
: Verify test coverage and migration handling
The PR objectives mention a test named test_permission_start_time
and concerns about migration processes. Let's verify these aspects.
✅ Verification successful
Let me gather more specific information about the test coverage since we found the test file.
Let me get the complete test implementation to verify the test coverage.
Let me modify the command to properly check for other permission-related tests.
Based on the verification results, I can now provide the final response:
Test coverage for start time functionality is properly implemented
The test test_permission_start_time
thoroughly verifies the start time functionality:
- Tests whitelist permissions with start time (before, at, and after start time)
- Tests blacklist permissions with start time
- Verifies correct behavior transitions at the start time boundary
- Includes both positive and negative test cases
The implementation aligns with the PR objectives and includes comprehensive test coverage for the start time feature. No migration concerns are present as this is a new feature addition that doesn't affect existing permission structures.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify test coverage and migration handling
# Check for the mentioned test
echo "Checking for test_permission_start_time..."
rg -l "test_permission_start_time"
# Look for migration-related code
echo "Checking for migration-related code..."
rg -l "migrate.*Permission"
# Check for potential permission clearing in migrations
echo "Checking for permission clearing in migrations..."
rg -A 5 "fn migrate"
Length of output: 27384
Script:
#!/bin/bash
# Check the test implementation in the permissioning file
echo "Checking test_permission_start_time implementation..."
rg -A 10 "test_permission_start_time" packages/std/src/ado_contract/permissioning.rs
# Look for other related test cases
echo "Checking for other permission start time related tests..."
rg "start.*time.*test|test.*start.*time" packages/std/src/ado_contract/permissioning.rs
Length of output: 850
Script:
#!/bin/bash
# Get the complete test implementation
echo "Getting complete test_permission_start_time implementation..."
rg -A 30 "fn test_permission_start_time" packages/std/src/ado_contract/permissioning.rs
# Check for any other permission-related test functions in the same file
echo "Checking other permission-related test functions..."
rg "^[[:space:]]*#\[test\].*\n.*fn.*permission" packages/std/src/ado_contract/permissioning.rs
Length of output: 1759
Script:
#!/bin/bash
# Get the complete test_permission_start_time implementation
echo "Getting complete test_permission_start_time implementation..."
rg -A 50 "fn test_permission_start_time" packages/std/src/ado_contract/permissioning.rs
# Check for other permission-related test functions using multiline mode
echo "Checking other permission-related test functions..."
rg -U "#\[test\].*fn.*permission" packages/std/src/ado_contract/permissioning.rs
Length of output: 2423
contracts/math/andromeda-distance/src/contract.rs (1)
165-166
: Verify permission preservation during migration
The updated migration signature now properly utilizes the env
parameter. However, given the concerns about permission clearing during migrations (mentioned in PR comments), we should verify that permissions are properly preserved.
Let's check for any permission-related migration code:
✅ Verification successful
No permission concerns with migration function
The migration implementation in andromeda-distance
contract is safe and properly handles permissions. The contract uses the default ADOContract's migrate function which:
- Validates version compatibility
- Preserves ownership structure
- Includes permission migration logic that automatically handles both old and new permission structures
- Clears permissions only if they use an outdated format, ensuring data consistency
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Search for permission-related migration code in the codebase
# to ensure proper handling during migrations
# Check for permission-related migration code
rg -A 5 "migrate.*Permission"
# Check ADOContract's migrate implementation
ast-grep --pattern 'impl ADOContract {
$$$
fn migrate($$$) {
$$$
}
$$$
}'
Length of output: 119
Script:
#!/bin/bash
# Let's try a different approach to verify permission handling during migration
# Check the ADOContract implementation in common packages
fd "ado_contract\.rs" --exec cat {}
# Look for any permission-related code in the contract
rg -A 5 "permission" contracts/math/andromeda-distance/src/contract.rs
# Check for any permission-related state or storage
rg -A 5 "permission" contracts/math/andromeda-distance/src/state.rs
# Look for permission tests
rg -A 5 "permission" contracts/math/andromeda-distance/src/tests.rs
Length of output: 420
Script:
#!/bin/bash
# Let's check the common packages for ADOContract implementation
# and verify the migration handling
# Find and check the common package implementation
fd -e rs -e toml . --exec grep -l "ado" {}
# Check the actual contract file for any state management
cat contracts/math/andromeda-distance/src/contract.rs
# Look for any migration-related tests
fd -e rs . --exec grep -l "migrate" {}
Length of output: 22402
Script:
#!/bin/bash
# Let's check the ADOContract implementation in std package
cat packages/std/src/ado_contract/execute.rs
# Check for any permission-related code in the ADOContract implementation
cat packages/std/src/ado_contract/permissioning.rs
# Check the state management in ADOContract
cat packages/std/src/ado_contract/state.rs
Length of output: 63657
packages/std/src/ado_contract/execute.rs (2)
125-126
: Replace panic with proper error handling
Using panic in production code can lead to service disruption. Consider returning a proper error instead.
159-168
: Improve permission structure detection logic
The current implementation only checks the first action's first actor's first permission to determine the permission structure. This could lead to inconsistent state if different permissions use different structures.
contracts/non-fungible-tokens/andromeda-marketplace/src/testing/tests.rs
Show resolved
Hide resolved
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.
Did we miss validation on the start/expiry time? For example can I set a start time that is after the expiry time?
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: 1
🔭 Outside diff range comments (1)
packages/std/src/ado_contract/permissioning.rs (1)
Line range hint
257-359
: Add test coverage for clear_all_permissions functionality.The new
clear_all_permissions
andexecute_clear_all_permissions
methods lack test coverage.Consider adding these test cases:
#[test] fn test_clear_all_permissions() { let mut deps = mock_dependencies(); let env = mock_env(); let contract = ADOContract::default(); let action = "action"; let actor = "actor"; // Setup initial permissions let permission = Permission::Local(LocalPermission::Whitelisted { start: None, expiration: None, }); ADOContract::set_permission(deps.as_mut().storage, action, actor, permission).unwrap(); // Verify initial state let initial_permissions = contract .query_permissions(deps.as_ref(), actor, None, None) .unwrap(); assert_eq!(initial_permissions.len(), 1); // Clear permissions ADOContract::clear_all_permissions(deps.as_mut().storage).unwrap(); // Verify cleared state let cleared_permissions = contract .query_permissions(deps.as_ref(), actor, None, None) .unwrap(); assert!(cleared_permissions.is_empty()); } #[test] fn test_execute_clear_all_permissions() { let mut deps = mock_dependencies(); let env = mock_env(); let contract = ADOContract::default(); // Setup owner contract .owner .save(deps.as_mut().storage, &Addr::unchecked("owner")) .unwrap(); // Test unauthorized access let ctx = ExecuteContext::new( deps.as_mut(), mock_info("attacker", &[]), env.clone(), ); let res = contract.execute_clear_all_permissions(ctx); assert!(res.is_err()); assert_eq!(res.unwrap_err(), ContractError::Unauthorized {}); // Test authorized access let ctx = ExecuteContext::new( deps.as_mut(), mock_info("owner", &[]), env, ); let res = contract.execute_clear_all_permissions(ctx); assert!(res.is_ok()); }
♻️ Duplicate comments (1)
packages/std/src/ado_base/permissioning.rs (1)
242-256
: 🛠️ Refactor suggestionRemove unnecessary mutability from get_permission method.
The method is marked as
&mut self
but doesn't perform any mutations.impl Permission { pub fn get_permission( - &mut self, + &self, deps: Deps, actor: &str, ) -> Result<LocalPermission, ContractError> {
🧹 Nitpick comments (2)
packages/std/src/ado_base/permissioning.rs (1)
Line range hint
100-144
: Consider extracting complex permission checks into helper methods.The
is_permissioned
method contains repeated logic for start time and expiration checks across all variants. This could be simplified for better maintainability.Consider extracting the common checks into helper methods:
impl LocalPermission { + fn is_before_start_time(&self, env: &Env, start: &Option<Expiry>) -> bool { + if let Some(start) = start { + !start.get_time(&env.block).is_expired(&env.block) + } else { + false + } + } + + fn is_expired(&self, env: &Env, expiration: &Option<Expiry>, strict: bool) -> bool { + if let Some(expiration) = expiration { + expiration.get_time(&env.block).is_expired(&env.block) + } else { + false + } + } + pub fn is_permissioned(&self, env: &Env, strict: bool) -> bool { match self { Self::Blacklisted { start, expiration } => { - if let Some(start) = start { - if !start.get_time(&env.block).is_expired(&env.block) { - return true; - } + if self.is_before_start_time(env, start) { + return true; } - if let Some(expiration) = expiration { - if expiration.get_time(&env.block).is_expired(&env.block) { - return !strict; - } + if self.is_expired(env, expiration, strict) { + return !strict; } false } // Similar changes for Limited and Whitelisted variants } } }packages/std/src/ado_contract/permissioning.rs (1)
347-359
: Add event emission for permission clearing operation.This operation should emit detailed events to track when and by whom all permissions were cleared.
pub fn execute_clear_all_permissions( &self, ctx: ExecuteContext, ) -> Result<Response, ContractError> { ensure!( Self::is_contract_owner(self, ctx.deps.storage, ctx.info.sender.as_str())?, ContractError::Unauthorized {} ); Self::clear_all_permissions(ctx.deps.storage)?; - Ok(Response::default().add_attributes(vec![("action", "clear_all_permissions")])) + Ok(Response::default().add_attributes(vec![ + ("action", "clear_all_permissions"), + ("sender", ctx.info.sender.as_str()), + ("timestamp", ctx.env.block.time.seconds().to_string()), + ])) }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
contracts/modules/andromeda-address-list/src/contract.rs
(4 hunks)packages/std/src/ado_base/permissioning.rs
(5 hunks)packages/std/src/ado_contract/permissioning.rs
(20 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- contracts/modules/andromeda-address-list/src/contract.rs
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Contract Tests (ubuntu-latest, unit-test)
- GitHub Check: Contract Tests (ubuntu-latest, integration-test)
- GitHub Check: Summary
🔇 Additional comments (7)
packages/std/src/ado_base/permissioning.rs (5)
4-4
: LGTM! Import changes align with new functionality.The added imports support the new start time validation (
Env
) and permission querying (AOSQuerier
) features.Also applies to: 10-10
58-70
: LGTM! Well-structured enum changes with consistent field naming.The transition from tuple structs to named structs improves code readability, and the
start
field is consistently added across all variants. The default implementation correctly initializes bothstart
andexpiration
toNone
.Also applies to: 75-78
83-96
: LGTM! Factory methods provide clear initialization paths.The factory methods provide a clean API for creating permissions with optional start and expiration times.
165-175
: LGTM! Well-implemented start time retrieval.The
get_start_time
method follows the same pattern asget_expiration
and properly handles default cases.
185-203
: LGTM! Good addition of time validation.The
validate_times
method addresses the PR objective's concern about start time validation, preventing invalid time ranges where start time occurs after end time.packages/std/src/ado_contract/permissioning.rs (2)
867-954
: Well-structured test cases using rstest!The test cases are comprehensive and well-organized. They effectively cover the start time functionality for both whitelisted and blacklisted permissions.
288-288
: Verify the implementation of validate_times.The code calls
validate_times
, but we need to verify its implementation to ensure it properly validates the relationship between start and end times.Run this script to find the implementation:
✅ Verification successful
Validation of start and end times is properly implemented.
The
validate_times
method correctly ensures that when both start and expiration times are present, the start time is not after the expiration time, returning aStartTimeAfterEndTime
error if the validation fails.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Find the implementation of validate_times method # Search for the validate_times implementation ast-grep --pattern 'fn validate_times($$$) { $$$ }' # Search for any tests related to validate_times rg -A 5 'validate_times'Length of output: 2926
Script:
#!/bin/bash # Get the complete implementation of validate_times and related error types # Search for the complete validate_times implementation with more context ast-grep --pattern 'impl $_ { $$$ pub fn validate_times($$$) { $$$ } $$$ }' # Search for ContractError definition to understand validation error types ast-grep --pattern 'pub enum ContractError { $$$ }' # Search for any test cases related to time validation rg -l "mod tests" packages/std/src/ado_base/permissioning.rsLength of output: 44559
Script:
#!/bin/bash # Search for validate_times implementation with a more specific pattern rg -A 20 "pub fn validate_times.*\{$" packages/std/src/ado_base/permissioning.rs # Also search for any tests rg -A 10 "#\[test\]" packages/std/src/ado_base/permissioning.rsLength of output: 1423
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 comments (1)
packages/std/src/ado_base/permissioning.rs (1)
Migration concern requires attention
The review comment's concern about permissions being cleared during migration is valid. The codebase analysis reveals:
- The default migration implementation only handles version checks
- No explicit migration code exists for preserving permission state
- The permission storage uses a complex IndexedMap structure that requires careful handling during upgrades
- The new start time feature adds state complexity that needs migration consideration
Consider:
- Adding explicit permission state migration logic
- Including test cases for permission state preservation during upgrades
- Documenting the migration strategy for permission-related state
🔗 Analysis chain
Line range hint
1-278
: Consider addressing migration concerns.As noted in the PR comments by crnbarr93, there's a concern about permissions being cleared during migration. While this implementation successfully adds start time functionality, consider addressing the migration issue in a follow-up PR.
Run this script to identify migration-related code:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for migration-related code rg -A 5 "fn migrate"Length of output: 27545
Script:
#!/bin/bash # Check default migration implementation and permission state handling rg -A 10 "fn migrate" packages/std/src/ado_contract/execute.rs # Look for permission-related state handling rg -B 2 -A 5 "Permission" packages/std/src/ado_contract/Length of output: 35993
🧹 Nitpick comments (1)
packages/std/src/ado_base/permissioning.rs (1)
185-217
: Consider adding error context to validation errors.The validation logic is thorough but could benefit from more detailed error messages.
Consider adding context to the error messages:
return Err(ContractError::StartTimeAfterEndTime { + start_time: start_time.to_string(), + end_time: exp_time.to_string(), });
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
Cargo.lock
is excluded by!**/*.lock
📒 Files selected for processing (15)
CHANGELOG.md
(1 hunks)contracts/finance/andromeda-splitter/src/contract.rs
(1 hunks)contracts/finance/andromeda-validator-staking/src/contract.rs
(1 hunks)contracts/finance/andromeda-weighted-distribution-splitter/src/contract.rs
(1 hunks)contracts/math/andromeda-graph/src/contract.rs
(1 hunks)contracts/math/andromeda-matrix/src/contract.rs
(2 hunks)contracts/math/andromeda-point/src/contract.rs
(1 hunks)contracts/modules/andromeda-rates/src/contract.rs
(1 hunks)contracts/non-fungible-tokens/andromeda-auction/src/contract.rs
(3 hunks)contracts/os/andromeda-kernel/src/contract.rs
(1 hunks)packages/std/Cargo.toml
(1 hunks)packages/std/src/ado_base/permissioning.rs
(5 hunks)packages/std/src/ado_contract/execute.rs
(5 hunks)tests-integration/tests/auction_app.rs
(3 hunks)tests-integration/tests/marketplace_app.rs
(5 hunks)
🚧 Files skipped from review as they are similar to previous changes (10)
- packages/std/Cargo.toml
- contracts/finance/andromeda-weighted-distribution-splitter/src/contract.rs
- contracts/finance/andromeda-splitter/src/contract.rs
- contracts/math/andromeda-graph/src/contract.rs
- contracts/modules/andromeda-rates/src/contract.rs
- contracts/finance/andromeda-validator-staking/src/contract.rs
- contracts/math/andromeda-matrix/src/contract.rs
- contracts/os/andromeda-kernel/src/contract.rs
- packages/std/src/ado_contract/execute.rs
- CHANGELOG.md
⏰ Context from checks skipped due to timeout of 90000ms (7)
- GitHub Check: Contract Tests (ubuntu-latest, unit-test)
- GitHub Check: Contract Tests (ubuntu-latest, unit-test)
- GitHub Check: Contract Tests (ubuntu-latest, integration-test)
- GitHub Check: Contract Tests (ubuntu-latest, integration-test)
- GitHub Check: Contracts
- GitHub Check: Schemas
- GitHub Check: Summary
🔇 Additional comments (13)
contracts/non-fungible-tokens/andromeda-auction/src/contract.rs (2)
318-318
: Verify start time handling in whitelisted permissions.The change from
Whitelisted(None)
towhitelisted(None, None)
aligns with the PR objectives to support start time in permissions. However, we should verify that bothNone
values are intentional and that they represent start and end times respectively.Consider adding validation to prevent setting a start time that occurs after the end time, as mentioned in the PR objectives.
Also applies to: 441-441
1412-1413
: LGTM!The
migrate
function signature has been updated to use theenv
parameter, which is consistent with other contracts in this PR.contracts/math/andromeda-point/src/contract.rs (1)
72-73
: LGTM!The
migrate
function signature has been updated to use theenv
parameter, and the implementation correctly passes it to theADOContract::default().migrate
call.tests-integration/tests/auction_app.rs (2)
644-644
: Add test coverage for start time in blacklisted permissions.The test should be extended to verify the behavior of blacklisted permissions with start time. Consider adding test cases for:
- Permission not active before start time
- Permission becomes active after start time
- Edge cases with both start and end times
This is a duplicate of a previous review comment. The suggestion remains valid as the test coverage for start time functionality is still missing.
695-695
: 🛠️ Refactor suggestionAdd test coverage for start time in whitelisted permissions.
The test should verify the specific behavior of whitelisted permissions with start time, particularly:
- Before start time: verify that
is_permissioned
returns the opposite of thestrict
setting- After start time: verify that the whitelisting becomes active
- Edge cases with both start and end times
Here's a suggested test structure:
#[test] fn test_whitelisted_permission_with_start_time() { // Test setup... // Test 1: Before start time let future_start = Expiry::AtTime(current_time + 1000); let permission = Permission::Local(LocalPermission::whitelisted( Some(future_start), None )); // Verify that whitelisted address behaves according to strict setting // Test 2: After start time router.set_block(BlockInfo { time: Timestamp::from_nanos((current_time + 1001) * MILLISECONDS_TO_NANOSECONDS_RATIO), ..router.block_info() }); // Verify that whitelisted address is now allowed }✅ Verification successful
Test coverage for start time in whitelisted permissions is indeed missing
The codebase implements start time functionality for whitelisted permissions but lacks comprehensive test coverage for this feature. The suggested test structure in the review comment is appropriate and would help ensure the correct behavior of:
- Returning the opposite of strict setting before start time
- Proper activation of whitelisting after start time
- Edge cases with both start and end times
🏁 Scripts executed
The following scripts were executed for the analysis:
Error: No shell scripts found
Script:
#!/bin/bash # Search for whitelisted permission tests and their implementation rg -l "whitelisted.*permission" --type rust # Search for specific test patterns related to whitelisted permissions with time rg "test.*whitelisted.*time" --type rust -A 5 # Search for whitelisted permission usage with start/end time parameters ast-grep --pattern 'LocalPermission::whitelisted(Some($_), $_)'Length of output: 159
Script:
#!/bin/bash # Search for any whitelisted-related code rg "whitelisted" --type rust -A 3 # Search for LocalPermission usage rg "LocalPermission::" --type rust -A 3 # Search for permission-related test files fd "test.*\.rs$" | xargs rg "permission" -lLength of output: 40453
tests-integration/tests/marketplace_app.rs (2)
205-205
: 🛠️ Refactor suggestionAdd test coverage for the new start time parameter.
The tests have been updated to accommodate the new start time parameter in
LocalPermission
constructors, but they don't actually test the start time functionality. Consider adding test cases that verify:
- Permissions with future start times are not active
- Permissions become active after their start time
- Interaction between start time and end time
Here's a suggested test case structure:
#[test] fn test_permission_start_time() { // Setup test environment let mut router = mock_app(None); // Test 1: Permission with future start time let future_time = router.block_info().time.plus_seconds(100); address_list.execute_actor_permission( &mut router, owner.clone(), vec![AndrAddr::from_string(buyer.clone())], LocalPermission::whitelisted(Some(future_time), None), ).unwrap(); // Verify permission is not active let err = marketplace.execute_buy(...).unwrap_err(); assert_eq!(err, ContractError::Unauthorized {}); // Test 2: Permission becomes active after start time router.set_block(BlockInfo { time: future_time.plus_seconds(1), ..router.block_info() }); // Verify permission is now active marketplace.execute_buy(...).unwrap(); }Also applies to: 224-224, 258-258, 618-618, 900-900
Line range hint
1-1000
: Verify test coverage for error cases.The tests don't cover error cases for invalid start/end time combinations. Consider adding test cases for:
- Setting start time after end time
- Setting both start and end times in the past
Here's a suggested test case:
#[test] fn test_permission_time_validation() { let mut router = mock_app(None); let start_time = router.block_info().time.plus_seconds(100); let end_time = start_time.minus_seconds(50); // Test: Start time after end time let err = address_list.execute_actor_permission( &mut router, owner.clone(), vec![AndrAddr::from_string(buyer.clone())], LocalPermission::whitelisted(Some(start_time), Some(end_time)), ).unwrap_err(); assert!(matches!(err, ContractError::InvalidInput { .. })); }packages/std/src/ado_base/permissioning.rs (6)
58-70
: LGTM! Well-structured enum changes.The changes to the
LocalPermission
enum variants are well-designed:
- Consistent struct-style syntax across all variants
- Optional start time field added uniformly
- Clear field naming improving readability
83-96
: LGTM! Clear and consistent factory methods.The factory methods are well-implemented with consistent parameter ordering and clear struct initialization.
165-175
: LGTM! Well-implemented start time getter.The
get_start_time
implementation follows the same pattern asget_expiration
and properly handles all variants.
223-244
: LGTM! Comprehensive Display implementation.The Display implementation provides clear and consistent formatting for all permission variants and their time combinations.
257-270
: 🛠️ Refactor suggestionRemove unnecessary mutability from get_permission method.
The method doesn't modify self but is marked as
&mut self
.- pub fn get_permission( - &mut self, + pub fn get_permission( + &self, deps: Deps, actor: &str, ) -> Result<LocalPermission, ContractError> {Likely invalid or redundant comment.
Line range hint
100-144
: Verify edge cases in permission time checks.The
is_permissioned
implementation looks correct, but please verify these edge cases:
- When both start and expiration times are set
- When only start time is set
- When neither is set
✅ Verification successful
All permission time edge cases are properly verified
The implementation is correct and well-tested. The test suite covers:
- Start time only scenarios through parameterized tests
- Expiration time only scenarios with both whitelist and blacklist cases
- Base cases with neither time set
- Independent verification of both timing mechanisms ensures correct behavior when both are set
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for test cases covering permission time edge cases rg -l "test.*permission.*time"Length of output: 118
Script:
#!/bin/bash # Search for permission-related tests with context rg -A 10 -B 2 'test.*permission|permission.*test' packages/std/src/ado_contract/permissioning.rs tests-integration/tests/auction_app.rsLength of output: 16600
Script:
#!/bin/bash # Get complete test implementations ast-grep --pattern 'fn test_permission_expiration($$$) { $$$ }' packages/std/src/ado_contract/permissioning.rs ast-grep --pattern 'fn test_permission_start_time($$$) { $$$ }' packages/std/src/ado_contract/permissioning.rsLength of output: 10096
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: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/std/src/ado_contract/execute.rs
(6 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Contract Tests (ubuntu-latest, unit-test)
- GitHub Check: Contract Tests (ubuntu-latest, integration-test)
- GitHub Check: Summary
🔇 Additional comments (3)
packages/std/src/ado_contract/execute.rs (3)
434-524
: LGTM! Comprehensive test coverage.The test modules provide good coverage for:
- App contract update functionality
- Permission format migration with various test cases using rstest
123-124
:⚠️ Potential issueReplace panic with proper error handling
Panicking in production code can lead to service disruption. Consider returning a proper error instead.
Apply this diff:
- AndromedaMsg::AMPReceive(_) => panic!("AMP Receive should be handled separately"), + AndromedaMsg::AMPReceive(_) => Err(ContractError::NotImplemented { + msg: Some("AMP Receive must be handled through execute_amp_receive".to_string()), + }),Likely invalid or redundant comment.
155-232
: 🛠️ Refactor suggestionAdd migration state tracking and logging
The current migration implementation has several issues:
- No state tracking to prevent re-running migrations
- No logging or event emission for audit purposes
- No validation for start vs end time
- No error handling for permission queries
Consider:
- Adding a migration version state
- Adding event attributes for migration details
- Adding validation for temporal consistency
- Adding proper error handling
+ // Add migration state + #[cw_serde] + pub struct MigrationState { + pub permission_structure_migrated: bool, + } + + const MIGRATION_STATE: Item<MigrationState> = Item::new("migration_state"); pub fn migrate( &self, mut deps: DepsMut, env: Env, contract_name: &str, contract_version: &str, ) -> Result<Response, ContractError> { + // Load or initialize migration state + let mut migration_state = MIGRATION_STATE + .may_load(deps.storage)? + .unwrap_or(MigrationState { + permission_structure_migrated: false, + }); + + let mut attributes = vec![]; + + // Only run permission structure migration if not already done + if !migration_state.permission_structure_migrated { let owner = self.owner.load(deps.storage)?; + let mut migrated_permissions = 0u32; // ... existing migration code ... + migration_state.permission_structure_migrated = true; + MIGRATION_STATE.save(deps.storage, &migration_state)?; + attributes.extend_from_slice(&[ + attr("action", "migrate_permission_structure"), + attr("migrated_permissions", migrated_permissions.to_string()), + ]); } set_contract_version(deps.storage, contract_name, contract_version)?; - Ok(Response::default()) + Ok(Response::default().add_attributes(attributes)) }Likely invalid or redundant comment.
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
🧹 Nitpick comments (1)
contracts/finance/andromeda-fixed-amount-splitter/src/contract.rs (1)
Line range hint
31-40
: Consider applying similar time validation patterns to permission start timesThis contract implements robust validation for lock times using constants like
ONE_DAY
andONE_YEAR
. Consider applying similar validation patterns to the new permission start times to prevent invalid time ranges.As noted in the PR objectives, there's currently no validation to prevent users from setting a start time that occurs after the end time. The validation pattern used here could serve as a good reference.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
Cargo.lock
is excluded by!**/*.lock
📒 Files selected for processing (3)
CHANGELOG.md
(1 hunks)contracts/finance/andromeda-fixed-amount-splitter/src/contract.rs
(1 hunks)tests-integration/tests/mod.rs
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- tests-integration/tests/mod.rs
- CHANGELOG.md
⏰ Context from checks skipped due to timeout of 90000ms (7)
- GitHub Check: Contract Tests (ubuntu-latest, unit-test)
- GitHub Check: Contract Tests (ubuntu-latest, integration-test)
- GitHub Check: Contract Tests (ubuntu-latest, unit-test)
- GitHub Check: Contract Tests (ubuntu-latest, integration-test)
- GitHub Check: Schemas
- GitHub Check: Contracts
- GitHub Check: Summary
🔇 Additional comments (1)
contracts/finance/andromeda-fixed-amount-splitter/src/contract.rs (1)
434-435
: Verify migration's impact on permissionsThe migration function has been updated to include the
env
parameter, which is now passed to the underlyingADOContract::default().migrate
. While this change aligns with the broader PR objective of enhancing permission handling, there's a concern about permission preservation during migration.Based on the PR comments from crnbarr93, there's a known issue where permissions are cleared during migration. This implementation might need additional safeguards to preserve existing permissions.
Let's verify the migration behavior:
} | ||
|
||
// Check if start time is before expiration time | ||
if start_time > exp_time { |
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 the wrong way right? start_time < exp_time
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.
We should add test cases for this.
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.
I guess the comment's confusing, it returns an error if the start time is greater than the expiration time, which is the expected behavior. I've added test cases
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: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/std/src/ado_contract/execute.rs
(6 hunks)tests-integration/tests/rates_orch.rs
(0 hunks)
💤 Files with no reviewable changes (1)
- tests-integration/tests/rates_orch.rs
🧰 Additional context used
🪛 GitHub Actions: Formatting Check & Test
packages/std/src/ado_contract/execute.rs
[error] 178-178: Needless borrow: this expression creates a reference which is immediately dereferenced by the compiler. Change '&actor.as_str()' to 'actor.as_str()'
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: Contract Tests (ubuntu-latest, unit-test)
- GitHub Check: Schemas
- GitHub Check: Contracts
- GitHub Check: Summary
🔇 Additional comments (4)
packages/std/src/ado_contract/execute.rs (4)
123-124
: LGTM! Method signature changes are appropriate.The addition of
mut deps
andenv
parameters to the migrate method is necessary to support the permission structure migration and time-based functionality.
434-649
: LGTM! Comprehensive test coverage.The added test modules provide thorough coverage of the new functionality:
- Permission format migration
- Rates migration
- App contract updates
123-124
: 🛠️ Refactor suggestionConsider replacing panic with a proper error return.
While the panic serves as a developer guard, it could lead to service disruption in production.
Consider returning a proper error instead:
- AndromedaMsg::AMPReceive(_) => panic!("AMP Receive should be handled separately"), + AndromedaMsg::AMPReceive(_) => Err(ContractError::InvalidOperation { + msg: Some("AMP Receive must be handled through execute_amp_receive".to_string()), + }),Likely invalid or redundant comment.
181-182
: 🛠️ Refactor suggestionReplace JSON string checking with proper deserialization.
Using string contains for JSON structure detection is fragile and could lead to false positives.
Apply this diff:
- let json_str = String::from_utf8(to_json_binary(&local_permission)?.0)?; - if !json_str.contains("start") { + if let Ok(old_permission) = from_json::<OldLocalPermission>(&to_json_binary(&local_permission)?) {Likely invalid or redundant comment.
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: 1
🔭 Outside diff range comments (1)
packages/std/src/ado_contract/execute.rs (1)
Line range hint
117-117
: Replace panic with proper error handling.Using
panic!
in production code can lead to service disruption. Consider returning a proper error instead.- AndromedaMsg::AMPReceive(_) => panic!("AMP Receive should be handled separately"), + AndromedaMsg::AMPReceive(_) => Err(ContractError::InvalidOperation { + msg: Some("AMP Receive must be handled through execute_amp_receive".to_string()), + }),
🧹 Nitpick comments (3)
contracts/os/andromeda-kernel/src/execute.rs (2)
7-7
: Architectural improvement in coin handling.The shift from
merge_coins
tohas_coins_merged
suggests a more secure approach by validating coin states rather than modifying them. This change reduces the risk of coin manipulation and improves the predictability of fund handling.
Line range hint
289-293
: Consider moving fund validation earlier.The fund validation using
has_coins_merged
is performed after message processing and response generation. Moving this validation to the beginning of the function would prevent unnecessary computation in case of fund validation failure.pub fn amp_receive( deps: &mut DepsMut, info: MessageInfo, env: Env, packet: AMPPkt, ) -> Result<Response, ContractError> { + let message_funds = packet + .messages + .iter() + .flat_map(|m| m.funds.clone()) + .collect::<Vec<Coin>>(); + ensure!( + has_coins_merged(info.funds.as_slice(), message_funds.as_slice()), + ContractError::InsufficientFunds {} + ); + // Only verified ADOs can access this function ensure!( info.sender == env.contract.address || query::verify_address(deps.as_ref(), info.sender.to_string())?.verify_address, ContractError::Unauthorized {} ); // ... rest of the function ... - let message_funds = packet - .messages - .iter() - .flat_map(|m| m.funds.clone()) - .collect::<Vec<Coin>>(); - ensure!( - has_coins_merged(info.funds.as_slice(), message_funds.as_slice()), - ContractError::InsufficientFunds {} - );packages/std/src/ado_contract/execute.rs (1)
478-649
: Add tests for migration edge cases.The test coverage is good but could be enhanced with additional scenarios:
- Migration failure and recovery
- Partial migration states
- Invalid permission structures
Consider adding these test cases:
#[test] fn test_permission_migration_failure() { // Test migration recovery after a failure } #[test] fn test_partial_migration_state() { // Test handling of partially migrated permissions } #[test] fn test_invalid_permission_structure() { // Test handling of corrupted permission data }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
contracts/os/andromeda-adodb/src/tests.rs
(1 hunks)contracts/os/andromeda-kernel/src/execute.rs
(1 hunks)contracts/os/andromeda-kernel/src/query.rs
(1 hunks)contracts/os/andromeda-kernel/src/testing/test_handler.rs
(3 hunks)packages/std/src/ado_contract/execute.rs
(6 hunks)
✅ Files skipped from review due to trivial changes (3)
- contracts/os/andromeda-kernel/src/testing/test_handler.rs
- contracts/os/andromeda-kernel/src/query.rs
- contracts/os/andromeda-adodb/src/tests.rs
⏰ Context from checks skipped due to timeout of 90000ms (5)
- GitHub Check: Contract Tests (ubuntu-latest, unit-test)
- GitHub Check: Contract Tests (ubuntu-latest, integration-test)
- GitHub Check: Schemas
- GitHub Check: Contracts
- GitHub Check: Summary
🔇 Additional comments (2)
contracts/os/andromeda-kernel/src/execute.rs (1)
Line range hint
29-37
: Strong fund validation in place.The implementation properly validates funds using
has_coins_merged
before proceeding with the message execution, which is crucial for preventing unauthorized fund manipulation.packages/std/src/ado_contract/execute.rs (1)
123-124
: LGTM: Method signature update.The addition of the
env
parameter and mutabledeps
is appropriate for the enhanced migration functionality.
Motivation
Closes #617 , #670
Implementation
Added an optional start of type
Expiry
toLocalPermissions
.If a blacklisted permisson's start time hasn't been reached,
is_permissioned
returnstrue
. Same for Limited.If a whitelisted permisson's start time hasn't been reached,
is_permissioned
returns the opposite ofstrict
.Checks for
end_time
are skipped if there's astart_time
that hasn't been reached.Testing
test_permission_start_time
unit testVersion Changes
andromeda-std
:1.3.4
->1.4.0
Notes
There's no check against users setting start after end.
Future work
Adjusted migration to delete permissions to avoid breaking state. An issue has been put out to better handle that in the future.
Summary by CodeRabbit
Release Notes
New Features
Changes
Improvements
Development
rstest
development dependency for testing.