1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
use cosmwasm_std::{Binary, ContractInfo};
use serde::{Deserialize, Serialize};
/// key for MigratedFrom singleton
pub static MIGRATED_FROM_KEY: &[u8] = b"migratedFrom";
/// key for MigratedTo singleton
pub static MIGRATED_TO_KEY: &[u8] = b"migratedTo";
/// key for Vec<ContractInfo> of contracts to notify when this contract has been migrated
pub static NOTIFY_ON_MIGRATION_COMPLETE_KEY: &[u8; 16] = b"notifyOnMigrated";
/// key for current ContractMode
pub const CONTRACT_MODE_KEY: &[u8] = b"contractMode";
#[derive(serde_repr::Serialize_repr, serde_repr::Deserialize_repr, Debug, PartialEq)]
#[repr(u8)]
pub enum ContractMode {
MigrateDataIn = 1,
Running = 2,
// MigrateOutStarted is applicable when a migration can take more than one transaction to complete
// For example when migrating a snip721 contract. A takes a least two transactions
// The first execute migration message put's the contract in this state.
// Which disables the contract's state from being altered but allows queries until migration
// is complete (after all the tokens are migrated in a second transaction).
// After all tokens are migrated. the contract switches to ContractMode::MigratedOut
MigrateOutStarted = 3,
MigratedOut = 4,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub struct MigratedFromState {
/// the info of the contract being migrated from
pub contract: ContractInfo,
/// the secret generated by the contract being migrated from
pub migration_secret: Binary,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub struct MigratedToState {
/// the info of the contract being migrated to
pub contract: ContractInfo,
/// the secret needed by another contract to migrate data out
pub migration_secret: Binary,
}