-
Notifications
You must be signed in to change notification settings - Fork 60
Add comments from Jon #28
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
[package] | ||
name = "token-interface" | ||
version = "0.0.0" | ||
edition = { workspace = true } | ||
edition = "2021" | ||
readme = "./README.md" | ||
license = { workspace = true } | ||
repository = { workspace = true } | ||
license = "Apache-2.0" | ||
#repository = { workspace = true } | ||
publish = false | ||
|
||
[lib] | ||
crate-type = ["rlib"] | ||
|
||
[dependencies] | ||
pinocchio = { workspace = true } | ||
pinocchio-pubkey = { workspace = true } | ||
pinocchio = { path = "../../../pinocchio/sdk/pinocchio" } | ||
pinocchio-pubkey = { path = "../../../pinocchio/sdk/pubkey" } |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,9 @@ pub fn process_burn( | |
|
||
// SAFETY: single mutable borrow to `mint_info` account data and | ||
// `load_mut` validates that the mint is initialized. | ||
// JC nit: to be totally clear, we can again say that an account cannot be | ||
// both a token account and a mint, so if duplicates are passed, one of them | ||
// will fail the `load` | ||
let mint = unsafe { load_mut::<Mint>(mint_info.borrow_mut_data_unchecked())? }; | ||
|
||
if mint_info.key() != &source_account.mint { | ||
|
@@ -78,6 +81,8 @@ pub fn process_burn( | |
} else { | ||
source_account.set_amount(updated_source_amount); | ||
|
||
// JC nit: I think we could safely unwrap this, but I'm not sure if | ||
// we get any real performance benefits | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In that case, we could remove the |
||
let mint_supply = mint | ||
.supply() | ||
.checked_sub(amount) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,9 @@ use crate::processor::check_account_owner; | |
pub fn process_initialize_account( | ||
accounts: &[AccountInfo], | ||
owner: Option<&Pubkey>, | ||
// JC nit: can call this `rent_sysvar_account_in_accounts` or make it the | ||
// opposite, ie. if it's *true* then use the syscall, so something like | ||
// `get_rent_sysvar_with_syscall` | ||
rent_sysvar_account: bool, | ||
) -> ProgramResult { | ||
// Accounts expected depend on whether we have the `rent_sysvar` account or not. | ||
|
@@ -86,6 +89,10 @@ pub fn process_initialize_account( | |
account.set_native(true); | ||
account.set_native_amount(minimum_balance); | ||
// SAFETY: single mutable borrow to `new_account_info` lamports. | ||
// JC nit: up to you, but since you've already checked that | ||
// `lamports() < minimum_balance` earlier, you don't actually need | ||
// checked math. If it shaves CUs, go for it! But definitely add a | ||
// comment explaining why | ||
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point! Also we don't need to do the // `new_account_info` lamports are already checked to be greater than or equal
// to the minimum balance.
account.set_amount(new_account_info.lamports() - minimum_balance); |
||
unsafe { | ||
account.set_amount( | ||
new_account_info | ||
|
Uh oh!
There was an error while loading. Please reload this page.