-
Notifications
You must be signed in to change notification settings - Fork 6
bulk-payments: Add new contract #146
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
base: main
Are you sure you want to change the base?
Conversation
This is a proxy deployer for bulk-payments SC
Coverage SummaryTotals
FilesExpand
|
Contract comparison - from d451bc5 to 3a2bbef
|
let user_already_opted_in = self.is_user_opted_in(caller.clone()); | ||
|
||
// If opted in and still getting rewards | ||
if user_already_opted_in && !self.is_timestamp_expired(caller.clone()) { |
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.
So you allow users who already opted in, but expired, to opt in again?
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.
Also, would it be helpful to add a time check for reentering? Or a maximum number of entries per epoch?
fn addr_timestamp(&self, user: ManagedAddress) -> SingleValueMapper<u64>; | ||
|
||
#[storage_mapper("optedInAddrs")] | ||
fn opted_in_addrs(&self) -> SetMapper<ManagedAddress<Self::Api>>; |
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.
Being a queue basically, I would recommend to use LinkedListMapper, which is made mostly for these types of cases. It allows you to better add/remove from the front / back of the list and it is more efficient.
self.opted_in_addrs().insert(caller); | ||
} | ||
|
||
fn try_clear_first_user_if_timestamp_expired(&self) { |
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.
Wouldn't it be more efficient to clear multiple entries that expired? Maybe not all of them (to avoid outOfGas errors), but in batches?
|
||
// Returns user without timestamp expired | ||
#[view(getUsersOptedIn)] | ||
fn get_users_opted_in(&self) -> MultiValueEncoded<ManagedAddress> { |
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.
Not sure if this works or how it works for an array as big as MAX_USERS_ALLOW = 1000.
} | ||
|
||
#[multiversx_sc::contract] | ||
pub trait BulkPayments { |
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.
Is BulkPayments a proper name for this contract. This makes me expect a different type of SC.
|
||
let user_already_opted_in = self.is_user_opted_in(caller.clone()); | ||
|
||
// If opted in and still getting rewards |
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.
How are the rewards distributed?
No description provided.