CI rehearsal only (do not merge) - #19
michael-moffett wants to merge 1 commit into
Conversation
Add a `surfnet_setMint` cheatcode that creates or patches a mint, optionally writing the Token-2022 `ConfidentialTransferMint` extension (authority, auditor ElGamal pubkey, auto-approve). Lead 3 of : builders must fork a mainnet mint today because there is no way to spin up a confidential-capable mint with a chosen auditor and decimals.
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
|
@greptileai review |
|
| let final_mint_bytes = if let Some(conf) = &confidential { | ||
| // The extension lives in a TLV layout the base-only packing | ||
| // can't represent, so the account is rewritten from scratch. | ||
| let base = match &mint_data { | ||
| MintAccount::SplToken2022(base) => *base, | ||
| MintAccount::SplToken(_) => { | ||
| return Err(Error::invalid_params( | ||
| "confidential transfer mints require the Token-2022 program" | ||
| .to_string(), | ||
| )); | ||
| } | ||
| }; | ||
| build_confidential_mint_data(&base, conf).map_err(Error::invalid_params)? |
There was a problem hiding this comment.
Existing mint extensions disappear When
setMint adds confidential settings to a Token-2022 mint that already has a transfer-fee or other extension, this branch builds new account data containing only the confidential extension. The existing extension is silently removed, so a transfer-fee mint, for example, loses its fee configuration. Preserve the existing extensions or reject the update.
| .init_extension::<ConfidentialTransferMint>(false) | ||
| .map_err(|e| format!("failed to init confidential mint extension: {e}"))?; | ||
| ct.authority = authority.map(Into::into).unwrap_or_default(); | ||
| ct.auto_approve_new_accounts = conf.auto_approve_new_accounts.unwrap_or(true).into(); | ||
| ct.auditor_elgamal_pubkey = auditor_elgamal_pubkey | ||
| .map(|key| PodElGamalPubkey::from(key).into()) | ||
| .unwrap_or_default(); |
There was a problem hiding this comment.
Partial updates clear confidential settings On an already-confidential mint, an update that supplies only
autoApproveNewAccounts writes null values over the existing authority and auditor key. This silently discards settings the caller did not ask to change, contrary to setMint’s promise to retain omitted fields. Preserve those fields when updating an existing extension.
| account.owner | ||
| ))); | ||
| } | ||
| account.lamports = lamports; |
There was a problem hiding this comment.
Mint updates discard excess SOL When an existing mint holds more SOL than the minimum rent balance, even a decimals-only update replaces its balance with that minimum. The excess SOL disappears from the simulated account. Retain the existing balance when it is sufficient, adding lamports only if the updated account needs more rent.
Fork CI only. Do not merge.