-
Notifications
You must be signed in to change notification settings - Fork 11
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
add some refactors to airdrop contract #111
Conversation
WalkthroughThe airdrop contract has been enhanced for better security and error handling; it now verifies ownership and authorization before rewarding users and efficiently handles cases of insufficient funds. The associated tests have been expanded to cover these new scenarios. Additionally, the Changes
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's AI:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
Codecov ReportAttention:
Additional details and impacted files
|
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.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (3)
- contracts/airdrop/src/contract.rs (1 hunks)
- contracts/airdrop/src/tests/execute/reward_users.rs (2 hunks)
- nibiru-std/src/proto/mod.rs (1 hunks)
Additional comments: 5
contracts/airdrop/src/tests/execute/reward_users.rs (2)
5-5: The import of
StdError
is added to support error handling in the new test case.175-216: The new test case
test_fails_when_we_try_to_allocate_more_than_available
correctly checks the contract's behavior when the reward allocation exceeds the available funds. It asserts that the response is an error with the message "Not enough funds in the campaign", which aligns with the PR objectives.nibiru-std/src/proto/mod.rs (1)
- 5-5: The removal of
pub use type_url_cosmos::*;
andpub use type_url_nibiru::*;
may impact how external modules access these types and traits. Ensure that all references to these modules in the codebase are updated to the new access pattern.Verification successful
Based on the executed scripts and their results, there are no direct or indirect references to
type_url_cosmos
ortype_url_nibiru
in the codebase outside of themod.rs
file. This suggests that the removal of thepub use
declarations for these modules has not resulted in any unresolved references. The codebase appears to be consistent with the changes made in the pull request.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for direct usage of types and traits from type_url_cosmos and type_url_nibiru. rg --type rust --glob '!mod.rs' 'type_url_cosmos::|type_url_nibiru::'Length of output: 71
Script:
#!/bin/bash # Search for indirect usage of types and traits that might have been re-exported from type_url_cosmos and type_url_nibiru. rg --type rust 'type_url_cosmos|type_url_nibiru'Length of output: 148
Script:
#!/bin/bash # Search for any wildcard imports or aliased imports from type_url_cosmos and type_url_nibiru. rg --type rust 'use .*type_url_cosmos.*;|use .*type_url_nibiru.*;'Length of output: 68
contracts/airdrop/src/contract.rs (2)
106-114: The addition of ownership and authorization checks in the
reward_users
function is a critical security improvement. It ensures that only the owner or managers can distribute rewards.118-121: The updated error handling for insufficient funds uses early returns, which simplifies the logic and makes it more readable. This change aligns with the PR objectives to improve error handling.
commit 2296e6f1e91db857318632089aa2cf888a4ce8ae Merge: c14558d dd90c9a Author: Unique-Divine <[email protected]> Date: Wed Jan 10 21:25:41 2024 -0600 Merge branch 'main' into realu/std commit c14558de1b80b739701ff3b146355ea815327192 Author: Unique-Divine <[email protected]> Date: Wed Jan 10 15:43:00 2024 -0600 quick save wip! commit dd90c9a Merge: bd792e4 902b788 Author: Jonathan Gimeno <[email protected]> Date: Fri Jan 5 19:00:52 2024 +0100 Merge pull request #111 from NibiruChain/feat/some-refactors-airdrop add some refactors to airdrop contract commit 902b788 Author: Jonathan Gimeno <[email protected]> Date: Fri Jan 5 17:41:16 2024 +0100 remove unused imports commit 0f337d1 Author: Jonathan Gimeno <[email protected]> Date: Fri Jan 5 17:39:21 2024 +0100 it fails when there are not enough funds commit 1d42220 Author: Jonathan Gimeno <[email protected]> Date: Fri Jan 5 17:31:57 2024 +0100 add some refactors, part 1 commit bd792e4 Author: Kevin Yang <[email protected]> Date: Wed Jan 3 14:22:23 2024 -0800 feat: initial airdrop contract (#110) * feat: initial airdrop contract * create cargo config * test: instantiate message * remove owner from instantiate msg * test: query functions * test: execute functions * feat: add manager list * feat: implement manager list * Create README.md * Update contracts/airdrop/src/contract.rs Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update contracts/airdrop/src/contract.rs Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update contracts/airdrop/src/contract.rs Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update contracts/airdrop/src/contract.rs Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * fix error messages --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> commit 88ae9fd Author: Matthias <[email protected]> Date: Wed Jan 3 15:32:33 2024 +0100 doc: Add cookbook for live smart contracts (#109)
* fix(bash-rs): type corrections for e2e tests * build: artifacts + just tidy + docs + merge main commit 2296e6f1e91db857318632089aa2cf888a4ce8ae Merge: c14558d dd90c9a Author: Unique-Divine <[email protected]> Date: Wed Jan 10 21:25:41 2024 -0600 Merge branch 'main' into realu/std commit c14558de1b80b739701ff3b146355ea815327192 Author: Unique-Divine <[email protected]> Date: Wed Jan 10 15:43:00 2024 -0600 quick save wip! commit dd90c9a Merge: bd792e4 902b788 Author: Jonathan Gimeno <[email protected]> Date: Fri Jan 5 19:00:52 2024 +0100 Merge pull request #111 from NibiruChain/feat/some-refactors-airdrop add some refactors to airdrop contract commit 902b788 Author: Jonathan Gimeno <[email protected]> Date: Fri Jan 5 17:41:16 2024 +0100 remove unused imports commit 0f337d1 Author: Jonathan Gimeno <[email protected]> Date: Fri Jan 5 17:39:21 2024 +0100 it fails when there are not enough funds commit 1d42220 Author: Jonathan Gimeno <[email protected]> Date: Fri Jan 5 17:31:57 2024 +0100 add some refactors, part 1 commit bd792e4 Author: Kevin Yang <[email protected]> Date: Wed Jan 3 14:22:23 2024 -0800 feat: initial airdrop contract (#110) * feat: initial airdrop contract * create cargo config * test: instantiate message * remove owner from instantiate msg * test: query functions * test: execute functions * feat: add manager list * feat: implement manager list * Create README.md * Update contracts/airdrop/src/contract.rs ---
Summary by CodeRabbit
New Features
Bug Fixes
Tests
Refactor