Skip to content

Commit

Permalink
[framework] Formatting: coin, token, balance, config, transfer 6/N (#…
Browse files Browse the repository at this point in the history
…19513)

## Description 

Final framework PR (excluding tests) in the formatting series.

## Test plan 

All tests must pass, framework must produce the same bytecode.

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [ ] CLI: 
- [ ] Rust SDK:
- [ ] REST API:
  • Loading branch information
damirka authored Sep 25, 2024
1 parent 63fa5c0 commit a219f19
Show file tree
Hide file tree
Showing 17 changed files with 2,251 additions and 2,354 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,9 @@ Sender is not @0x0 the system address.

<pre><code><b>fun</b> <a href="../sui-framework/authenticator_state.md#0x2_authenticator_state_jwk_equal">jwk_equal</a>(a: &<a href="../sui-framework/authenticator_state.md#0x2_authenticator_state_JWK">JWK</a>, b: &<a href="../sui-framework/authenticator_state.md#0x2_authenticator_state_JWK">JWK</a>): bool {
(&a.kty == &b.kty) &&
(&a.e == &b.e) &&
(&a.n == &b.n) &&
(&a.alg == &b.alg)
(&a.e == &b.e) &&
(&a.n == &b.n) &&
(&a.alg == &b.alg)
}
</code></pre>

Expand Down
10 changes: 2 additions & 8 deletions crates/sui-framework/docs/sui-framework/balance.md
Original file line number Diff line number Diff line change
Expand Up @@ -435,10 +435,7 @@ and nowhere else.

<pre><code><b>fun</b> <a href="../sui-framework/balance.md#0x2_balance_create_staking_rewards">create_staking_rewards</a>&lt;T&gt;(value: <a href="../move-stdlib/u64.md#0x1_u64">u64</a>, ctx: &TxContext): <a href="../sui-framework/balance.md#0x2_balance_Balance">Balance</a>&lt;T&gt; {
<b>assert</b>!(ctx.sender() == @0x0, <a href="../sui-framework/balance.md#0x2_balance_ENotSystemAddress">ENotSystemAddress</a>);
<b>assert</b>!(
std::type_name::get&lt;T&gt;().into_string().into_bytes() == <a href="../sui-framework/balance.md#0x2_balance_SUI_TYPE_NAME">SUI_TYPE_NAME</a>,
<a href="../sui-framework/balance.md#0x2_balance_ENotSUI">ENotSUI</a>,
);
<b>assert</b>!(std::type_name::get&lt;T&gt;().into_string().into_bytes() == <a href="../sui-framework/balance.md#0x2_balance_SUI_TYPE_NAME">SUI_TYPE_NAME</a>, <a href="../sui-framework/balance.md#0x2_balance_ENotSUI">ENotSUI</a>);
<a href="../sui-framework/balance.md#0x2_balance_Balance">Balance</a> { value }
}
</code></pre>
Expand Down Expand Up @@ -467,10 +464,7 @@ and nowhere else.

<pre><code><b>fun</b> <a href="../sui-framework/balance.md#0x2_balance_destroy_storage_rebates">destroy_storage_rebates</a>&lt;T&gt;(self: <a href="../sui-framework/balance.md#0x2_balance_Balance">Balance</a>&lt;T&gt;, ctx: &TxContext) {
<b>assert</b>!(ctx.sender() == @0x0, <a href="../sui-framework/balance.md#0x2_balance_ENotSystemAddress">ENotSystemAddress</a>);
<b>assert</b>!(
std::type_name::get&lt;T&gt;().into_string().into_bytes() == <a href="../sui-framework/balance.md#0x2_balance_SUI_TYPE_NAME">SUI_TYPE_NAME</a>,
<a href="../sui-framework/balance.md#0x2_balance_ENotSUI">ENotSUI</a>,
);
<b>assert</b>!(std::type_name::get&lt;T&gt;().into_string().into_bytes() == <a href="../sui-framework/balance.md#0x2_balance_SUI_TYPE_NAME">SUI_TYPE_NAME</a>, <a href="../sui-framework/balance.md#0x2_balance_ENotSUI">ENotSUI</a>);
<b>let</b> <a href="../sui-framework/balance.md#0x2_balance_Balance">Balance</a> { value: _ } = self;
}
</code></pre>
Expand Down
107 changes: 45 additions & 62 deletions crates/sui-framework/docs/sui-framework/coin.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion crates/sui-framework/docs/sui-framework/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ title: Module `0x2::config`
Name: <b>copy</b> + drop + store,
Value: <b>copy</b> + drop + store,
&gt;(
<a href="../sui-framework/config.md#0x2_config">config</a>: & <a href="../sui-framework/config.md#0x2_config_Config">Config</a>&lt;WriteCap&gt;,
<a href="../sui-framework/config.md#0x2_config">config</a>: &<a href="../sui-framework/config.md#0x2_config_Config">Config</a>&lt;WriteCap&gt;,
name: Name,
ctx: &TxContext,
): bool {
Expand Down
35 changes: 9 additions & 26 deletions crates/sui-framework/docs/sui-framework/deny_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ meaningless to add them to the deny list.
) {
<b>let</b> per_type_config = <a href="../sui-framework/deny_list.md#0x2_deny_list">deny_list</a>.per_type_config_entry!(per_type_index, per_type_key, ctx);
<b>let</b> setting_name = <a href="../sui-framework/deny_list.md#0x2_deny_list_AddressKey">AddressKey</a>(addr);
<b>let</b> next_epoch_entry = per_type_config.entry!&lt;_,<a href="../sui-framework/deny_list.md#0x2_deny_list_AddressKey">AddressKey</a>, bool&gt;(
<b>let</b> next_epoch_entry = per_type_config.entry!&lt;_, <a href="../sui-framework/deny_list.md#0x2_deny_list_AddressKey">AddressKey</a>, bool&gt;(
&<b>mut</b> <a href="../sui-framework/deny_list.md#0x2_deny_list_ConfigWriteCap">ConfigWriteCap</a>(),
setting_name,
|_deny_list, _cap, _ctx| <b>true</b>,
Expand Down Expand Up @@ -638,9 +638,8 @@ meaningless to add them to the deny list.
ctx: &<b>mut</b> TxContext,
) {
<b>let</b> bag_entry: &<b>mut</b> <a href="../sui-framework/deny_list.md#0x2_deny_list_PerTypeList">PerTypeList</a> = &<b>mut</b> <a href="../sui-framework/deny_list.md#0x2_deny_list">deny_list</a>.lists[per_type_index];
<b>let</b> elements =
<b>if</b> (!bag_entry.denied_addresses.contains(per_type_key)) <a href="../move-stdlib/vector.md#0x1_vector">vector</a>[]
<b>else</b> bag_entry.denied_addresses.remove(per_type_key).into_keys();
<b>let</b> elements = <b>if</b> (!bag_entry.denied_addresses.contains(per_type_key)) <a href="../move-stdlib/vector.md#0x1_vector">vector</a>[]
<b>else</b> bag_entry.denied_addresses.remove(per_type_key).into_keys();
elements.do_ref!(|addr| {
<b>let</b> addr = *addr;
<b>let</b> denied_count = &<b>mut</b> bag_entry.denied_count[addr];
Expand All @@ -650,9 +649,9 @@ meaningless to add them to the deny list.
}
});
<b>let</b> per_type_config = <a href="../sui-framework/deny_list.md#0x2_deny_list">deny_list</a>.per_type_config_entry!(per_type_index, per_type_key, ctx);
elements.do!(|addr| {
elements.do!(|addr| {
<b>let</b> setting_name = <a href="../sui-framework/deny_list.md#0x2_deny_list_AddressKey">AddressKey</a>(addr);
<b>let</b> next_epoch_entry = per_type_config.entry!&lt;_,<a href="../sui-framework/deny_list.md#0x2_deny_list_AddressKey">AddressKey</a>, bool&gt;(
<b>let</b> next_epoch_entry = per_type_config.entry!&lt;_, <a href="../sui-framework/deny_list.md#0x2_deny_list_AddressKey">AddressKey</a>, bool&gt;(
&<b>mut</b> <a href="../sui-framework/deny_list.md#0x2_deny_list_ConfigWriteCap">ConfigWriteCap</a>(),
setting_name,
|_deny_list, _cap, _ctx| <b>true</b>,
Expand Down Expand Up @@ -773,11 +772,7 @@ meaningless to add them to the deny list.
<summary>Implementation</summary>


<pre><code><b>fun</b> <a href="../sui-framework/deny_list.md#0x2_deny_list_per_type_exists">per_type_exists</a>(
<a href="../sui-framework/deny_list.md#0x2_deny_list">deny_list</a>: &<a href="../sui-framework/deny_list.md#0x2_deny_list_DenyList">DenyList</a>,
per_type_index: <a href="../move-stdlib/u64.md#0x1_u64">u64</a>,
per_type_key: <a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
): bool {
<pre><code><b>fun</b> <a href="../sui-framework/deny_list.md#0x2_deny_list_per_type_exists">per_type_exists</a>(<a href="../sui-framework/deny_list.md#0x2_deny_list">deny_list</a>: &<a href="../sui-framework/deny_list.md#0x2_deny_list_DenyList">DenyList</a>, per_type_index: <a href="../move-stdlib/u64.md#0x1_u64">u64</a>, per_type_key: <a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;): bool {
<b>let</b> key = <a href="../sui-framework/deny_list.md#0x2_deny_list_ConfigKey">ConfigKey</a> { per_type_index, per_type_key };
ofield::exists_(&<a href="../sui-framework/deny_list.md#0x2_deny_list">deny_list</a>.id, key)
}
Expand Down Expand Up @@ -838,11 +833,7 @@ the type specified is the type of the coin, not the coin type itself. For exampl
<summary>Implementation</summary>


<pre><code><b>fun</b> <a href="../sui-framework/deny_list.md#0x2_deny_list_v1_per_type_list_add">v1_per_type_list_add</a>(
list: &<b>mut</b> <a href="../sui-framework/deny_list.md#0x2_deny_list_PerTypeList">PerTypeList</a>,
`type`: <a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
addr: <b>address</b>,
) {
<pre><code><b>fun</b> <a href="../sui-framework/deny_list.md#0x2_deny_list_v1_per_type_list_add">v1_per_type_list_add</a>(list: &<b>mut</b> <a href="../sui-framework/deny_list.md#0x2_deny_list_PerTypeList">PerTypeList</a>, `type`: <a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;, addr: <b>address</b>) {
<b>if</b> (!list.denied_addresses.contains(`type`)) {
list.denied_addresses.add(`type`, <a href="../sui-framework/vec_set.md#0x2_vec_set_empty">vec_set::empty</a>());
};
Expand Down Expand Up @@ -912,11 +903,7 @@ Aborts with <code><a href="../sui-framework/deny_list.md#0x2_deny_list_ENotDenie
<summary>Implementation</summary>


<pre><code><b>fun</b> <a href="../sui-framework/deny_list.md#0x2_deny_list_v1_per_type_list_remove">v1_per_type_list_remove</a>(
list: &<b>mut</b> <a href="../sui-framework/deny_list.md#0x2_deny_list_PerTypeList">PerTypeList</a>,
`type`: <a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
addr: <b>address</b>,
) {
<pre><code><b>fun</b> <a href="../sui-framework/deny_list.md#0x2_deny_list_v1_per_type_list_remove">v1_per_type_list_remove</a>(list: &<b>mut</b> <a href="../sui-framework/deny_list.md#0x2_deny_list_PerTypeList">PerTypeList</a>, `type`: <a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;, addr: <b>address</b>) {
<b>let</b> denied_addresses = &<b>mut</b> list.denied_addresses[`type`];
<b>assert</b>!(denied_addresses.contains(&addr), <a href="../sui-framework/deny_list.md#0x2_deny_list_ENotDenied">ENotDenied</a>);
denied_addresses.remove(&addr);
Expand Down Expand Up @@ -980,11 +967,7 @@ Returns true iff the given address is denied for the given type.
<summary>Implementation</summary>


<pre><code><b>fun</b> <a href="../sui-framework/deny_list.md#0x2_deny_list_v1_per_type_list_contains">v1_per_type_list_contains</a>(
list: &<a href="../sui-framework/deny_list.md#0x2_deny_list_PerTypeList">PerTypeList</a>,
`type`: <a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
addr: <b>address</b>,
): bool {
<pre><code><b>fun</b> <a href="../sui-framework/deny_list.md#0x2_deny_list_v1_per_type_list_contains">v1_per_type_list_contains</a>(list: &<a href="../sui-framework/deny_list.md#0x2_deny_list_PerTypeList">PerTypeList</a>, `type`: <a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;, addr: <b>address</b>): bool {
<b>if</b> (!list.denied_count.contains(addr)) <b>return</b> <b>false</b>;

<b>let</b> denied_count = &list.denied_count[addr];
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-framework/docs/sui-framework/sui.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ This should be called only once during genesis creation.
// TODO: add appropriate description and logo <a href="../sui-framework/url.md#0x2_url">url</a>
b"",
<a href="../move-stdlib/option.md#0x1_option_none">option::none</a>(),
ctx
ctx,
);
<a href="../sui-framework/transfer.md#0x2_transfer_public_freeze_object">transfer::public_freeze_object</a>(metadata);
<b>let</b> <b>mut</b> supply = treasury.treasury_into_supply();
Expand Down
Loading

0 comments on commit a219f19

Please sign in to comment.