This module provides migration functionality to transition from the generic coin store system (using CoinType) to the non-generic multi coin store system. It helps migrate coin stores, balances, frozen states, and accept data.
- Struct
AccountMigrationEvent - Struct
CoinStoreMigrationEvent - Resource
MigrationState - Resource
MigrationUpdateCap - Constants
- Function
initialize_entry - Function
dispatch_cap_entry - Function
ensure_has_cap - Function
cap_address - Function
migrate_account_entry - Function
migrate_accounts_batch_entry - Function
update_migration_state_entry - Function
update_migration_states_batch_entry - Function
migration_state_id - Function
is_account_migrated - Function
get_migration_stats
use 0x1::string;
use 0x2::event;
use 0x2::object;
use 0x2::signer;
use 0x2::table;
use 0x2::type_info;
use 0x3::account_coin_store;
use 0x3::coin;
use 0x3::coin_store;
use 0x3::multi_coin_store;
use 0x3::onchain_config;
Event emitted when an account's coin stores are migrated
struct AccountMigrationEvent has copy, drop, store
Event emitted when a specific coin store is migrated for an account
struct CoinStoreMigrationEvent has copy, drop, store
State tracking for migration progress
struct MigrationState has store, key
MigrationUpdateCap is the capability for manager operations, such as update migration state.
struct MigrationUpdateCap has store, key
Migration is already done for an account
const ErrorMigrationAlreadyDone: u64 = 1;
const ErrorNoCap: u64 = 3;
Nothing to migrate for the account
const ErrorNothingToMigrate: u64 = 2;
Initialize the migration module, called after framework upgrade
public entry fun initialize_entry(_account: &signer)
public entry fun dispatch_cap_entry(account: &signer, cap_address: address)
public fun ensure_has_cap(account: &signer)
public fun cap_address(): address
Entry function to migrate a specific account's coin stores The coin type must be only key to compatiable with both the public(key+store) and private(key) coins Can be called by arbitrary user
public entry fun migrate_account_entry<CoinType: key>(_account: &signer, addr: address)
Entry function to migrate account's coin stores for multiple accounts from a comma-separated string Can be called by arbitrary user to update migration coin stores in batch
public entry fun migrate_accounts_batch_entry<CoinType: key>(_account: &signer, addresses: vector<address>)
Entry function to update migration state for a specific account Only called by the cap account to update migrate states
public entry fun update_migration_state_entry(account: &signer, addr: address)
Entry function to update migration states for multiple accounts from a comma-separated string Only called by the cap account to update migration states in batch
public entry fun update_migration_states_batch_entry(account: &signer, addresses: vector<address>)
public fun migration_state_id(): object::ObjectID
Check if an account has already been migrated
public fun is_account_migrated(addr: address): bool
Get migration statistics
public fun get_migration_stats(): u64