crates/sui-framework/docs/sui/deny_list.md
Defines the <code><a href="../sui/deny_list.md#sui_deny_list_DenyList">DenyList</a></code> type. The <code><a href="../sui/deny_list.md#sui_deny_list_DenyList">DenyList</a></code> shared object is used to restrict access to instances of certain core types from being used as inputs by specified addresses in the deny list.
DenyListConfigWriteCapConfigKeyAddressKeyGlobalPauseKeyPerTypeConfigCreatedPerTypeListv2_addv2_removev2_contains_current_epochv2_contains_next_epochv2_enable_global_pausev2_disable_global_pausev2_is_global_pause_enabled_current_epochv2_is_global_pause_enabled_next_epochmigrate_v1_to_v2add_per_type_configborrow_per_type_config_mutborrow_per_type_configper_type_existsper_type_config_entryv1_addv1_per_type_list_addv1_removev1_per_type_list_removev1_containsv1_per_type_list_containscreateper_type_list<a name="sui_deny_list_DenyList"></a>
DenyListA shared object that stores the addresses that are blocked for a given core type.
<pre><code><b>public</b> <b>struct</b> <a href="../sui/deny_list.md#sui_deny_list_DenyList">DenyList</a> <b>has</b> key </code></pre> <details> <summary>Fields</summary> <dl> <dt> <code>id: <a href="../sui/object.md#sui_object_UID">sui::object::UID</a></code> </dt> <dd> </dd> <dt> <code>lists: <a href="../sui/bag.md#sui_bag_Bag">sui::bag::Bag</a></code> </dt> <dd> The individual deny lists. </dd> </dl> </details><a name="sui_deny_list_ConfigWriteCap"></a>
ConfigWriteCapThe capability used to write to the deny list config. Ensures that the Configs for the DenyList are modified only by this module.
<pre><code><b>public</b> <b>struct</b> <a href="../sui/deny_list.md#sui_deny_list_ConfigWriteCap">ConfigWriteCap</a> <b>has</b> drop </code></pre> <details> <summary>Fields</summary> <dl> </dl> </details><a name="sui_deny_list_ConfigKey"></a>
ConfigKeyThe dynamic object field key used to store the <code>Config</code> for a given type, essentially a <code>(per_type_index, per_type_key)</code> pair.
<pre><code><b>public</b> <b>struct</b> <a href="../sui/deny_list.md#sui_deny_list_ConfigKey">ConfigKey</a> <b>has</b> <b>copy</b>, drop, store </code></pre> <details> <summary>Fields</summary> <dl> <dt> <code>per_type_index: u64</code> </dt> <dd> </dd> <dt> <code>per_type_key: vector<u8></code> </dt> <dd> </dd> </dl> </details><a name="sui_deny_list_AddressKey"></a>
AddressKeyThe setting key used to store the deny list for a given address in the <code>Config</code>.
<pre><code><b>public</b> <b>struct</b> <a href="../sui/deny_list.md#sui_deny_list_AddressKey">AddressKey</a> <b>has</b> <b>copy</b>, drop, store </code></pre> <details> <summary>Fields</summary> <dl> <dt> <code>0: <b>address</b></code> </dt> <dd> </dd> </dl> </details><a name="sui_deny_list_GlobalPauseKey"></a>
GlobalPauseKeyThe setting key used to store the global pause setting in the <code>Config</code>.
<pre><code><b>public</b> <b>struct</b> <a href="../sui/deny_list.md#sui_deny_list_GlobalPauseKey">GlobalPauseKey</a> <b>has</b> <b>copy</b>, drop, store </code></pre> <details> <summary>Fields</summary> <dl> </dl> </details><a name="sui_deny_list_PerTypeConfigCreated"></a>
PerTypeConfigCreatedThe event emitted when a new <code>Config</code> is created for a given type. This can be useful for tracking the <code>ID</code> of a type's <code>Config</code> object.
<pre><code><b>public</b> <b>struct</b> <a href="../sui/deny_list.md#sui_deny_list_PerTypeConfigCreated">PerTypeConfigCreated</a> <b>has</b> <b>copy</b>, drop, store </code></pre> <details> <summary>Fields</summary> <dl> <dt> <code>key: <a href="../sui/deny_list.md#sui_deny_list_ConfigKey">sui::deny_list::ConfigKey</a></code> </dt> <dd> </dd> <dt> <code>config_id: <a href="../sui/object.md#sui_object_ID">sui::object::ID</a></code> </dt> <dd> </dd> </dl> </details><a name="sui_deny_list_PerTypeList"></a>
PerTypeListStores the addresses that are denied for a given core type.
<pre><code><b>public</b> <b>struct</b> <a href="../sui/deny_list.md#sui_deny_list_PerTypeList">PerTypeList</a> <b>has</b> key, store </code></pre> <details> <summary>Fields</summary> <dl> <dt> <code>id: <a href="../sui/object.md#sui_object_UID">sui::object::UID</a></code> </dt> <dd> </dd> <dt> <code>denied_count: <a href="../sui/table.md#sui_table_Table">sui::table::Table</a><<b>address</b>, u64></code> </dt> <dd> Number of object types that have been banned for a given address. Used to quickly skip checks for most addresses. </dd> <dt> <code>denied_addresses: <a href="../sui/table.md#sui_table_Table">sui::table::Table</a><vector<u8>, <a href="../sui/vec_set.md#sui_vec_set_VecSet">sui::vec_set::VecSet</a><<b>address</b>>></code> </dt> <dd> Set of addresses that are banned for a given type. For example with <code><a href="../sui/coin.md#sui_coin_Coin">sui::coin::Coin</a></code>: If addresses A and B are banned from using "0...0123::my_coin::MY_COIN", this will be "0...0123::my_coin::MY_COIN" -> {A, B}. </dd> </dl> </details><a name="@Constants_0"></a>
<a name="sui_deny_list_ENotSystemAddress"></a>
Trying to create a deny list object when not called by the system address.
<pre><code><b>const</b> <a href="../sui/deny_list.md#sui_deny_list_ENotSystemAddress">ENotSystemAddress</a>: u64 = 0; </code></pre><a name="sui_deny_list_ENotDenied"></a>
The specified address to be removed is not already in the deny list.
<pre><code><b>const</b> <a href="../sui/deny_list.md#sui_deny_list_ENotDenied">ENotDenied</a>: u64 = 1; </code></pre><a name="sui_deny_list_EInvalidAddress"></a>
The specified address cannot be added to the deny list.
<pre><code><b>const</b> <a href="../sui/deny_list.md#sui_deny_list_EInvalidAddress">EInvalidAddress</a>: u64 = 1; </code></pre><a name="sui_deny_list_COIN_INDEX"></a>
The index into the deny list vector for the <code><a href="../sui/coin.md#sui_coin_Coin">sui::coin::Coin</a></code> type.
<pre><code><b>const</b> <a href="../sui/deny_list.md#sui_deny_list_COIN_INDEX">COIN_INDEX</a>: u64 = 0; </code></pre><a name="sui_deny_list_RESERVED"></a>
These addresses are reserved and cannot be added to the deny list. The addresses listed are well known package and object addresses. So it would be meaningless to add them to the deny list.
<pre><code><b>const</b> <a href="../sui/deny_list.md#sui_deny_list_RESERVED">RESERVED</a>: vector<<b>address</b>> = vector[0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0x403, 0xdee9]; </code></pre><a name="sui_deny_list_v2_add"></a>
v2_add<a name="sui_deny_list_v2_remove"></a>
v2_remove<a name="sui_deny_list_v2_contains_current_epoch"></a>
v2_contains_current_epoch<a name="sui_deny_list_v2_contains_next_epoch"></a>
v2_contains_next_epoch<a name="sui_deny_list_v2_enable_global_pause"></a>
v2_enable_global_pause<a name="sui_deny_list_v2_disable_global_pause"></a>
v2_disable_global_pause<a name="sui_deny_list_v2_is_global_pause_enabled_current_epoch"></a>
v2_is_global_pause_enabled_current_epoch<a name="sui_deny_list_v2_is_global_pause_enabled_next_epoch"></a>
v2_is_global_pause_enabled_next_epoch<a name="sui_deny_list_migrate_v1_to_v2"></a>
migrate_v1_to_v2<a name="sui_deny_list_add_per_type_config"></a>
add_per_type_config<a name="sui_deny_list_borrow_per_type_config_mut"></a>
borrow_per_type_config_mut<a name="sui_deny_list_borrow_per_type_config"></a>
borrow_per_type_config<a name="sui_deny_list_per_type_exists"></a>
per_type_exists<a name="sui_deny_list_per_type_config_entry"></a>
per_type_config_entry<a name="sui_deny_list_v1_add"></a>
v1_addAdds the given address to the deny list of the specified type, preventing it from interacting with instances of that type as an input to a transaction. For coins, the type specified is the type of the coin, not the coin type itself. For example, "00...0123::my_coin::MY_COIN" would be the type, not "00...02::coin::Coin".
<pre><code><b>public</b>(<a href="../sui/package.md#sui_package">package</a>) <b>fun</b> <a href="../sui/deny_list.md#sui_deny_list_v1_add">v1_add</a>(<a href="../sui/deny_list.md#sui_deny_list">deny_list</a>: &<b>mut</b> <a href="../sui/deny_list.md#sui_deny_list_DenyList">sui::deny_list::DenyList</a>, per_type_index: u64, type: vector<u8>, addr: <b>address</b>) </code></pre> <details> <summary>Implementation</summary> <pre><code><b>public</b>(<a href="../sui/package.md#sui_package">package</a>) <b>fun</b> <a href="../sui/deny_list.md#sui_deny_list_v1_add">v1_add</a>( <a href="../sui/deny_list.md#sui_deny_list">deny_list</a>: &<b>mut</b> <a href="../sui/deny_list.md#sui_deny_list_DenyList">DenyList</a>, per_type_index: u64, `type`: vector<u8>, addr: <b>address</b>, ) { <b>let</b> reserved = <a href="../sui/deny_list.md#sui_deny_list_RESERVED">RESERVED</a>; <b>assert</b>!(!reserved.contains(&addr), <a href="../sui/deny_list.md#sui_deny_list_EInvalidAddress">EInvalidAddress</a>); <b>let</b> bag_entry: &<b>mut</b> <a href="../sui/deny_list.md#sui_deny_list_PerTypeList">PerTypeList</a> = &<b>mut</b> <a href="../sui/deny_list.md#sui_deny_list">deny_list</a>.lists[per_type_index]; bag_entry.<a href="../sui/deny_list.md#sui_deny_list_v1_per_type_list_add">v1_per_type_list_add</a>(`type`, addr) } </code></pre> </details><a name="sui_deny_list_v1_per_type_list_add"></a>
v1_per_type_list_add<a name="sui_deny_list_v1_remove"></a>
v1_removeRemoves a previously denied address from the list. Aborts with <code><a href="../sui/deny_list.md#sui_deny_list_ENotDenied">ENotDenied</a></code> if the address is not on the list.
<pre><code><b>public</b>(<a href="../sui/package.md#sui_package">package</a>) <b>fun</b> <a href="../sui/deny_list.md#sui_deny_list_v1_remove">v1_remove</a>(<a href="../sui/deny_list.md#sui_deny_list">deny_list</a>: &<b>mut</b> <a href="../sui/deny_list.md#sui_deny_list_DenyList">sui::deny_list::DenyList</a>, per_type_index: u64, type: vector<u8>, addr: <b>address</b>) </code></pre> <details> <summary>Implementation</summary> <pre><code><b>public</b>(<a href="../sui/package.md#sui_package">package</a>) <b>fun</b> <a href="../sui/deny_list.md#sui_deny_list_v1_remove">v1_remove</a>( <a href="../sui/deny_list.md#sui_deny_list">deny_list</a>: &<b>mut</b> <a href="../sui/deny_list.md#sui_deny_list_DenyList">DenyList</a>, per_type_index: u64, `type`: vector<u8>, addr: <b>address</b>, ) { <b>let</b> reserved = <a href="../sui/deny_list.md#sui_deny_list_RESERVED">RESERVED</a>; <b>assert</b>!(!reserved.contains(&addr), <a href="../sui/deny_list.md#sui_deny_list_EInvalidAddress">EInvalidAddress</a>); <b>let</b> bag_entry: &<b>mut</b> <a href="../sui/deny_list.md#sui_deny_list_PerTypeList">PerTypeList</a> = &<b>mut</b> <a href="../sui/deny_list.md#sui_deny_list">deny_list</a>.lists[per_type_index]; bag_entry.<a href="../sui/deny_list.md#sui_deny_list_v1_per_type_list_remove">v1_per_type_list_remove</a>(`type`, addr) } </code></pre> </details><a name="sui_deny_list_v1_per_type_list_remove"></a>
v1_per_type_list_remove<a name="sui_deny_list_v1_contains"></a>
v1_containsReturns true iff the given address is denied for the given type.
<pre><code><b>public</b>(<a href="../sui/package.md#sui_package">package</a>) <b>fun</b> <a href="../sui/deny_list.md#sui_deny_list_v1_contains">v1_contains</a>(<a href="../sui/deny_list.md#sui_deny_list">deny_list</a>: &<a href="../sui/deny_list.md#sui_deny_list_DenyList">sui::deny_list::DenyList</a>, per_type_index: u64, type: vector<u8>, addr: <b>address</b>): bool </code></pre> <details> <summary>Implementation</summary> <pre><code><b>public</b>(<a href="../sui/package.md#sui_package">package</a>) <b>fun</b> <a href="../sui/deny_list.md#sui_deny_list_v1_contains">v1_contains</a>( <a href="../sui/deny_list.md#sui_deny_list">deny_list</a>: &<a href="../sui/deny_list.md#sui_deny_list_DenyList">DenyList</a>, per_type_index: u64, `type`: vector<u8>, addr: <b>address</b>, ): bool { <b>let</b> reserved = <a href="../sui/deny_list.md#sui_deny_list_RESERVED">RESERVED</a>; <b>if</b> (reserved.contains(&addr)) <b>return</b> <b>false</b>; <b>let</b> bag_entry: &<a href="../sui/deny_list.md#sui_deny_list_PerTypeList">PerTypeList</a> = &<a href="../sui/deny_list.md#sui_deny_list">deny_list</a>.lists[per_type_index]; bag_entry.<a href="../sui/deny_list.md#sui_deny_list_v1_per_type_list_contains">v1_per_type_list_contains</a>(`type`, addr) } </code></pre> </details><a name="sui_deny_list_v1_per_type_list_contains"></a>
v1_per_type_list_contains<a name="sui_deny_list_create"></a>
createCreation of the deny list object is restricted to the system address via a system transaction.
<pre><code><b>fun</b> <a href="../sui/deny_list.md#sui_deny_list_create">create</a>(ctx: &<b>mut</b> <a href="../sui/tx_context.md#sui_tx_context_TxContext">sui::tx_context::TxContext</a>) </code></pre> <details> <summary>Implementation</summary> <pre><code><b>fun</b> <a href="../sui/deny_list.md#sui_deny_list_create">create</a>(ctx: &<b>mut</b> TxContext) { <b>assert</b>!(ctx.sender() == @0x0, <a href="../sui/deny_list.md#sui_deny_list_ENotSystemAddress">ENotSystemAddress</a>); <b>let</b> <b>mut</b> lists = <a href="../sui/bag.md#sui_bag_new">bag::new</a>(ctx); lists.add(<a href="../sui/deny_list.md#sui_deny_list_COIN_INDEX">COIN_INDEX</a>, <a href="../sui/deny_list.md#sui_deny_list_per_type_list">per_type_list</a>(ctx)); <b>let</b> deny_list_object = <a href="../sui/deny_list.md#sui_deny_list_DenyList">DenyList</a> { id: <a href="../sui/object.md#sui_object_sui_deny_list_object_id">object::sui_deny_list_object_id</a>(), lists, }; <a href="../sui/transfer.md#sui_transfer_share_object">transfer::share_object</a>(deny_list_object); } </code></pre> </details><a name="sui_deny_list_per_type_list"></a>
per_type_list