Open
Conversation
VladasZ
approved these changes
Jul 23, 2024
| self.orders.insert(&account_id, &vec![]); | ||
| } | ||
|
|
||
| let mut account_orders = self.orders.get(&account_id).unwrap(); |
There was a problem hiding this comment.
Expect with error message. Or like we do it in jars:
.unwrap_or_else(|| env::panic_str(&format!("Jar with id: '{}' doesn't exist", id.0)))
contract/src/order.rs
Outdated
| for account_id in account_ids { | ||
| let mut order_execution = OrderExecution::new(account_id.clone()); | ||
|
|
||
| let account_orders = self.orders.get(&account_id).expect("Account not found"); |
There was a problem hiding this comment.
[nit]
Add to error message which account was not found.
contract/src/order.rs
Outdated
| let account_orders = self.orders.get(&account_id).expect("Account not found"); | ||
| for order in account_orders { | ||
| let requested_amount = order.claim_amount.0; | ||
| let approved_amount = (requested_amount as f32 * percentage) as u128; |
There was a problem hiding this comment.
Is it ok that percentage here is f32? Shouldn't it be Decimal like in jars?
| } | ||
|
|
||
| self.internal_save_account_lockups(&order.account_id, account_lockup_indices); | ||
| // endregion |
There was a problem hiding this comment.
What is this?
// region cleanup
// endregion
| pub struct OrderExecution { | ||
| pub account_id: AccountId, | ||
| pub total_approved: Balance, | ||
| pub details: HashMap<LockupIndex, (Balance, Balance)>, // (Balance approved, Balance refund) |
There was a problem hiding this comment.
[nit]
Create struct so this comment isn't needed?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change claim process to give a grant issuer priority right to buy tokens.