-
Notifications
You must be signed in to change notification settings - Fork 47
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
Updated price discovery #991
base: rc/v3.0.2
Are you sure you want to change the base?
Conversation
Coverage SummaryTotals
FilesExpand
|
Contract comparison - from 420269a to 02681bb
|
|
||
```rust | ||
#[init] | ||
fn init( | ||
&self, | ||
launched_token_id: TokenIdentifier, | ||
accepted_token_id: TokenIdentifier, | ||
accepted_token_id: EgldOrEsdtTokenIdentifier, |
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.
Ideally, use EgldOrEsdtTokenIdentifier
for all args.
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.
Nah, you can't launch EGLD, so this makes it a bit more clear.
payment_result | ||
} | ||
|
||
/// Deposit ESDT received after deposit to withdraw the initially deposited tokens. |
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.
Correct this 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.
I already did? What were you expecting the comment to say?
|
||
self.burn_redeem_token(&payment_amount); | ||
self.accepted_token_balance() | ||
.update(|balance| *balance -= &payment_amount); |
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.
Verifiy that balance
is greater than payment_amount
.
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's really no need for that. This should never fail, and even if it does, the framework has checks for BigUint diff being lower than 0.
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.
Looks good.
require!(payment_token == &redeem_token_id, INVALID_PAYMENT_ERR_MSG); | ||
|
||
let launched_token_supply = self.launched_token_balance().get(); | ||
if launched_token_supply == 0 { |
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 could you get to this situation? What if launched_token_supply is > 0 but < than the SC balance?
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.
If the owner doesn't deposit any tokens. I'm not sure I get the second question? How would you ever reach such a situation?
require!(caller == admin, "Only admin may call this function"); | ||
} | ||
|
||
#[storage_mapper("admin")] |
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.
Maybe add a view here?
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.
Nah. If people need this value, they can use "read storage from address" functionality. I've started to phase out views for simple storages like this.
Do not merge yet, until we decide the target branch.