Skip to main content

Module sui::coin_regulation

Protocol-level address freezing, coin pausing, and seizing for regulated coins.

Seizing from an address is allowed only in an epoch after it was frozen. An address can be unfrozen only in an epoch after the last SeizeAuth for it was destroyed.

Struct FreezeList​

Singleton shared object holding the freeze and pause state of regulated coins.

public struct FreezeList has key
Click to open
Fields

Struct ComplianceCap​

Authorizes freezing, seizing, and pausing coin type T. A cap migrated from a DenyCapV2 keeps its object ID.

public struct ComplianceCap<phantom T> has key, store
Click to open
Fields
id: sui::object::UID
allow_global_pause: bool
Whether this cap may globally pause T.

Struct SeizeAuth​

Authorizes seizing coin type T from frozen_address.

public struct SeizeAuth<phantom T> has key
Click to open
Fields
id: sui::object::UID
frozen_address: address
The address this authorizes seizing from.
frozen_epoch: u64
The epoch in which frozen_address was frozen.

Struct CoinTypeKey​

Dynamic field key on FreezeList. A missing key means T is not paused and has no frozen addresses.

public struct CoinTypeKey<phantom T> has copy, drop, store

Struct CoinTypeState​

The value under CoinTypeKey<T>: the freeze and pause state of T.

public struct CoinTypeState has store
Click to open
Fields
paused: bool
Whether every transaction touching T is rejected.
num_frozen_addresses: u64
The number of addresses frozen for T.

Struct FrozenAddressKey​

Dynamic field key on FreezeList, holding the frozen address. Exists iff that address is frozen for T.

public struct FrozenAddressKey<phantom T> has copy, drop, store
Click to open
Fields
0: address

Struct FrozenAddressState​

The value under FrozenAddressKey<T>: the state of one frozen address.

public struct FrozenAddressState has store
Click to open
Fields
seize_auths: sui::vec_set::VecSet<sui::object::ID>
The IDs of the outstanding SeizeAuths for this address.
frozen_epoch: u64
The epoch in which this address was frozen.
unfreeze_lock: sui::coin_regulation::UnfreezeLock
The restriction on unfreezing this address.

Struct FreezeCountKey​

Scratch key counting the addresses newly frozen in the current transaction.

public struct FreezeCountKey has copy, drop

Struct AddressFrozen​

Event: the address was frozen for T.

public struct AddressFrozen<phantom T> has copy, drop
Click to open
Fields
0: address

Struct AddressUnfrozen​

Event: the address was unfrozen for T.

public struct AddressUnfrozen<phantom T> has copy, drop
Click to open
Fields
0: address

Struct AddressPermanentlyFrozen​

Event: the address was permanently frozen for T.

public struct AddressPermanentlyFrozen<phantom T> has copy, drop
Click to open
Fields
0: address

Struct SeizeAuthIssued​

Event: a SeizeAuth<T> was issued for frozen_address.

public struct SeizeAuthIssued<phantom T> has copy, drop
Click to open
Fields
id: sui::object::ID
The ID of the issued SeizeAuth.
frozen_address: address
The address it authorizes seizing from.

Struct SeizeAuthDestroyed​

Event: a SeizeAuth<T> for frozen_address was destroyed.

public struct SeizeAuthDestroyed<phantom T> has copy, drop
Click to open
Fields
id: sui::object::ID
The ID of the destroyed SeizeAuth.
frozen_address: address
The address it authorized seizing from.

Struct CoinTypePaused​

Event: T was globally paused.

public struct CoinTypePaused<phantom T> has copy, drop

Struct CoinTypeUnpaused​

Event: the global pause of T was lifted.

public struct CoinTypeUnpaused<phantom T> has copy, drop

Struct DenyCapMigrated​

Event: the DenyCapV2 for T was replaced by the ComplianceCap cap, keeping its ID.

public struct DenyCapMigrated<phantom T> has copy, drop
Click to open
Fields
cap: sui::object::ID
The ID of the ComplianceCap, which is also the ID of the replaced DenyCapV2.

Enum UnfreezeLock​

A restriction on unfreezing an address, in addition to its outstanding SeizeAuths.

public enum UnfreezeLock has copy, drop, store
Click to open
Variants
Variant None
No restriction.
Variant UntilEpoch
Unfreezing is allowed only from this epoch on, the epoch after the last destroy_seize_auth.
0: u64
Variant Permanent
The address can never be unfrozen.

Constants​

#[error]
const ENotSystemAddress: vector<u8> = b"Only the system can create the freeze list.";
#[error]
const EAlreadyFrozen: vector<u8> = b"The address is already frozen for this coin type.";
#[error]
const ENotFrozen: vector<u8> = b"The address is not frozen for this coin type.";
#[error]
const ESeizeAuthsOutstanding: vector<u8> = b"The address cannot be unfrozen while any SeizeAuth for it exists.";
#[error]
const EPermanentlyFrozen: vector<u8> = b"The address is permanently frozen for this coin type.";
#[error]
const EGlobalPauseNotAllowed: vector<u8> = b"The ComplianceCap does not allow global pause.";
#[error]
const EUnfreezeTooEarly: vector<u8> = b"The address cannot be unfrozen until the epoch after its last SeizeAuth was destroyed.";
#[error]
const ECoinTypeStateExists: vector<u8> = b"The coin type already has freeze list state.";
#[error]
const ETooManyFreezes: vector<u8> = b"Too many addresses frozen in this transaction.";

The maximum number of addresses newly frozen by freeze_address or permanently_freeze_address in one transaction.

Function freeze_address​

Freeze addr for T.
Aborts if addr is already frozen.
Aborts if the transaction already froze MAX_FREEZES_PER_TRANSACTION addresses.

Function unfreeze_address​

Unfreeze addr for T. Aborts unless addr is frozen, not permanently, has no outstanding SeizeAuth, and the current epoch is later than that of its last SeizeAuth destroy, if any.

Function permanently_freeze_address​

Freeze addr for T if it is not frozen, and prevent it from ever being unfrozen.
Aborts if addr is newly frozen and the transaction already froze MAX_FREEZES_PER_TRANSACTION addresses.

Function issue_seize_auth​

Issue a SeizeAuth for the frozen addr. Aborts if addr is not frozen.

Function destroy_seize_auth​

Destroy auth and remove it from its address's outstanding SeizeAuths.

Function transfer_seize_auth​

Transfer auth to recipient.

public fun transfer_seize_auth<T>(auth: sui::coin_regulation::SeizeAuth<T>, recipient: address)

Function enable_global_pause​

Globally pause T. Aborts if cap does not allow global pause.

Function disable_global_pause​

Lift the global pause of T. Aborts if cap does not allow global pause.

Function is_frozen​

Whether addr is frozen for T.

public fun is_frozen<T>(list: &sui::coin_regulation::FreezeList, addr: address): bool

Function is_permanently_frozen​

Whether addr is permanently frozen for T.

public fun is_permanently_frozen<T>(list: &sui::coin_regulation::FreezeList, addr: address): bool

Function is_global_pause_enabled​

Whether T is globally paused.

Function seize_auths​

The IDs of the outstanding SeizeAuths for addr, empty if addr is not frozen.

public fun seize_auths<T>(list: &sui::coin_regulation::FreezeList, addr: address): vector<sui::object::ID>

Function allow_global_pause​

Whether cap may globally pause T.

Function frozen_address​

The address auth authorizes seizing from.

public fun frozen_address<T>(auth: &sui::coin_regulation::SeizeAuth<T>): address

Function frozen_epoch​

The epoch in which frozen_address was frozen. Seizing is only allowed in a later epoch.

public fun frozen_epoch<T>(auth: &sui::coin_regulation::SeizeAuth<T>): u64

Function new_compliance_cap​

A new ComplianceCap for T, for a coin created through the coin registry.

Function migrate_from_deny_list​

Replace cap with a ComplianceCap that keeps its object ID, carrying over T's legacy next-epoch global pause and freezing each of frozen_addresses denied in the legacy next-epoch list.

Function create​

Create and share the FreezeList. Only callable by genesis or change_epoch transactions.

Function add_frozen_address​

Freeze addr for T and count it in T's state. Aborts if addr is already frozen.

Function count_freeze​

Count a newly frozen address against this transaction's limit.

Function coin_type_state_mut_or_add​

The state of T, added if T has none.