use miden_protocol::transaction::TransactionScript;
use miden_standards::code_builder::CodeBuilder;
use crate::utils::LazyLock;
const ACCOUNT_CODE_UPGRADE_SCRIPT: &str = "
use miden::standards::account_upgrade
#! Upgrades the code of the executing account to the code with NEW_CODE_COMMITMENT.
#!
#! Inputs: [NEW_CODE_COMMITMENT, pad(12)]
#! Outputs: [pad(16)]
@transaction_script
pub proc main
padw swapw
# => [NEW_CODE_COMMITMENT, STORAGE_UPGRADE_COMMITMENT, pad(12)]
call.account_upgrade::upgrade
# => [pad(20)]
dropw
# => [pad(16)]
end
";
static ACCOUNT_CODE_UPGRADE_TX_SCRIPT: LazyLock<TransactionScript> = LazyLock::new(|| {
CodeBuilder::new()
.compile_tx_script(ACCOUNT_CODE_UPGRADE_SCRIPT)
.expect("the account code upgrade script should compile")
});
pub(super) fn account_code_upgrade_script() -> TransactionScript {
ACCOUNT_CODE_UPGRADE_TX_SCRIPT.clone()
}