cw_migratable_contract_std/
msg.rs

1use cosmwasm_std::{Binary, ContractInfo};
2use schemars::JsonSchema;
3use serde::{Deserialize, Serialize};
4
5#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq, JsonSchema)]
6#[serde(rename_all = "snake_case")]
7pub enum MigratableExecuteMsg {
8    /// Sets a contract that should be notified when this contract completes the migration process
9    SubscribeToMigrationCompleteEvent { address: String, code_hash: String },
10    /// Triggers a MigrationCompleteNotification to be sent to the address specified. If this contract
11    /// has been migrated out, otherwise it will return an error.
12    ///
13    /// Consider the case where you have a FactoryContract which only instantiates ChildContracts
14    /// and only maintains a list of them which can become very large. In this scenario note that the
15    /// only time a ChildContract needs to interact with the FactoryContract is when it migrates out.
16    /// When a child Contract migrates out only then does it need to notify the FactoryContract of
17    /// its new address. Now consider that the FactoryContract can also migrate. Instead of having
18    /// each ChildContract call SubscribeToMigrationCompleteEvent on the FactoryContract (which could
19    /// get very expensive with a large number of ChildContracts when the FactoryContract wants to
20    /// migrate because it needs to notify every ChildContract before completing migration).
21    /// The ChildContract can instead upon migration just query the FactoryContract address it has
22    /// stored to check if it is the latest version before allowing a migration to continue.
23    /// If the FactoryContract has migrated out the sender can call
24    /// BroadcastMigrationCompleteNotification on the FactoryContract to notify the
25    /// ChildContract of the new address. After that the ChildContract can proceed with its
26    /// own migration.
27    BroadcastMigrationCompleteNotification {
28        /// addresses to send a MigrationCompleteNotification
29        addresses: Vec<String>,
30        /// the code for the addresses
31        code_hash: String,
32        data: Option<Binary>,
33    },
34}
35
36#[derive(Serialize, Deserialize, Clone, Debug, Eq, PartialEq, JsonSchema)]
37#[serde(rename_all = "snake_case")]
38pub enum MigrationListenerExecuteMsg {
39    /// Upon a contract setting its ContractMode to MigratedOut. All contracts registered to be
40    /// notified of a completed migration with RegisterToNotifyOnMigrationComplete should be sent
41    /// a MigrationCompleteNotification message
42    MigrationCompleteNotification {
43        to: ContractInfo,
44        // optional data to send
45        data: Option<Binary>,
46    },
47}