pub trait UpgradeableMigratable: UpgradeableMigratableInternal {
// Required methods
fn upgrade(e: &Env, new_wasm_hash: BytesN<32>, operator: Address);
fn migrate(e: &Env, migration_data: Self::MigrationData, operator: Address);
}Expand description
High-level trait for a combination of upgrade and migration logic in upgradeable contracts.
This trait defines the external entry points for applying both, an upgrade and a migration. It is recommended to be used only as part of the lightweight upgrade framework provided in this module.
When using the framework, this trait is automatically derived with
#[derive(UpgradeableMigratable)], and should NOT be manually implemented.
Instead, the contract must define access control via _require_auth and
provide its custom migration logic by implementing
UpgradeableMigratableInternal.
Required Methods§
Sourcefn upgrade(e: &Env, new_wasm_hash: BytesN<32>, operator: Address)
fn upgrade(e: &Env, new_wasm_hash: BytesN<32>, operator: Address)
Upgrades the contract by setting a new WASM bytecode. The contract will only be upgraded after the invocation has successfully completed.
§Arguments
e- Access to Soroban environment.new_wasm_hash- A 32-byte hash identifying the new WASM blob, uploaded to the ledger.operator- The authorized address performing the upgrade and the migration.
Sourcefn migrate(e: &Env, migration_data: Self::MigrationData, operator: Address)
fn migrate(e: &Env, migration_data: Self::MigrationData, operator: Address)
Entry point to handle a contract migration.
§Arguments
e- The Soroban environment.migration_data- Arbitrary data passed to the migration logic.operator- The authorized address performing the upgrade and the migration.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.