mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 15:51:12 +00:00
contracts: Add instantiation_nonce API (#12800)
* Add `instantiation_nonce` API * Fixes for tests * Update frame/contracts/src/schedule.rs Co-authored-by: Sasha Gryaznov <hi@agryaznov.com> * ".git/.scripts/bench-bot.sh" pallet dev pallet_contracts Co-authored-by: Sasha Gryaznov <hi@agryaznov.com> Co-authored-by: command-bot <>
This commit is contained in:
committed by
GitHub
parent
c336eae64a
commit
770afb9ee3
@@ -265,6 +265,8 @@ pub enum RuntimeCosts {
|
||||
ReentrantCount,
|
||||
/// Weight of calling `account_reentrance_count`
|
||||
AccountEntranceCount,
|
||||
/// Weight of calling `instantiation_nonce`
|
||||
InstantationNonce,
|
||||
}
|
||||
|
||||
impl RuntimeCosts {
|
||||
@@ -344,6 +346,7 @@ impl RuntimeCosts {
|
||||
EcdsaToEthAddress => s.ecdsa_to_eth_address,
|
||||
ReentrantCount => s.reentrance_count,
|
||||
AccountEntranceCount => s.account_reentrance_count,
|
||||
InstantationNonce => s.instantiation_nonce,
|
||||
};
|
||||
RuntimeToken {
|
||||
#[cfg(test)]
|
||||
@@ -2614,4 +2617,14 @@ pub mod env {
|
||||
ctx.read_sandbox_memory_as(memory, account_ptr)?;
|
||||
Ok(ctx.ext.account_reentrance_count(&account_id))
|
||||
}
|
||||
|
||||
/// Returns a nonce that is unique per contract instantiation.
|
||||
///
|
||||
/// The nonce is incremented for each succesful contract instantiation. This is a
|
||||
/// sensible default salt for contract instantiations.
|
||||
#[unstable]
|
||||
fn instantiation_nonce(ctx: _, _memory: _) -> Result<u64, TrapReason> {
|
||||
ctx.charge_gas(RuntimeCosts::InstantationNonce)?;
|
||||
Ok(ctx.ext.nonce())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user