Skip to content

Latest commit

 

History

History
255 lines (122 loc) · 8.06 KB

File metadata and controls

255 lines (122 loc) · 8.06 KB

Module 0x3::coin_migration

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

Event emitted when an account's coin stores are migrated

struct AccountMigrationEvent has copy, drop, store

Struct CoinStoreMigrationEvent

Event emitted when a specific coin store is migrated for an account

struct CoinStoreMigrationEvent has copy, drop, store

Resource MigrationState

State tracking for migration progress

struct MigrationState has store, key

Resource MigrationUpdateCap

MigrationUpdateCap is the capability for manager operations, such as update migration state.

struct MigrationUpdateCap has store, key

Constants

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;

Function initialize_entry

Initialize the migration module, called after framework upgrade

public entry fun initialize_entry(_account: &signer)

Function dispatch_cap_entry

public entry fun dispatch_cap_entry(account: &signer, cap_address: address)

Function ensure_has_cap

Function cap_address

public fun cap_address(): address

Function migrate_account_entry

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)

Function migrate_accounts_batch_entry

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>)

Function update_migration_state_entry

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)

Function update_migration_states_batch_entry

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>)

Function migration_state_id

Function is_account_migrated

Check if an account has already been migrated

public fun is_account_migrated(addr: address): bool

Function get_migration_stats

Get migration statistics

public fun get_migration_stats(): u64