Skip to content

Commit

Permalink
[framework] Formatting: utils, object, tx_context, types, random 5/N (#…
Browse files Browse the repository at this point in the history
…19498)

## Description 

Continues the formatting.

## Test plan 

Tests must pass, framework must be compatible.

---

## 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 23, 2024
1 parent 6a83f64 commit 7336840
Show file tree
Hide file tree
Showing 33 changed files with 2,329 additions and 2,338 deletions.
22 changes: 8 additions & 14 deletions crates/sui-framework/docs/sui-framework/authenticator_state.md
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 Expand Up @@ -484,9 +484,7 @@ Can only be called by genesis or change_epoch transactions.
<summary>Implementation</summary>


<pre><code><b>fun</b> <a href="../sui-framework/authenticator_state.md#0x2_authenticator_state_load_inner_mut">load_inner_mut</a>(
self: &<b>mut</b> <a href="../sui-framework/authenticator_state.md#0x2_authenticator_state_AuthenticatorState">AuthenticatorState</a>,
): &<b>mut</b> <a href="../sui-framework/authenticator_state.md#0x2_authenticator_state_AuthenticatorStateInner">AuthenticatorStateInner</a> {
<pre><code><b>fun</b> <a href="../sui-framework/authenticator_state.md#0x2_authenticator_state_load_inner_mut">load_inner_mut</a>(self: &<b>mut</b> <a href="../sui-framework/authenticator_state.md#0x2_authenticator_state_AuthenticatorState">AuthenticatorState</a>): &<b>mut</b> <a href="../sui-framework/authenticator_state.md#0x2_authenticator_state_AuthenticatorStateInner">AuthenticatorStateInner</a> {
<b>let</b> version = self.version;

// replace this <b>with</b> a lazy <b>update</b> function when we add a new version of the inner <a href="../sui-framework/object.md#0x2_object">object</a>.
Expand Down Expand Up @@ -518,9 +516,7 @@ Can only be called by genesis or change_epoch transactions.
<summary>Implementation</summary>


<pre><code><b>fun</b> <a href="../sui-framework/authenticator_state.md#0x2_authenticator_state_load_inner">load_inner</a>(
self: &<a href="../sui-framework/authenticator_state.md#0x2_authenticator_state_AuthenticatorState">AuthenticatorState</a>,
): &<a href="../sui-framework/authenticator_state.md#0x2_authenticator_state_AuthenticatorStateInner">AuthenticatorStateInner</a> {
<pre><code><b>fun</b> <a href="../sui-framework/authenticator_state.md#0x2_authenticator_state_load_inner">load_inner</a>(self: &<a href="../sui-framework/authenticator_state.md#0x2_authenticator_state_AuthenticatorState">AuthenticatorState</a>): &<a href="../sui-framework/authenticator_state.md#0x2_authenticator_state_AuthenticatorStateInner">AuthenticatorStateInner</a> {
<b>let</b> version = self.version;

// replace this <b>with</b> a lazy <b>update</b> function when we add a new version of the inner <a href="../sui-framework/object.md#0x2_object">object</a>.
Expand Down Expand Up @@ -709,7 +705,8 @@ indicate that the JWK has been validated in the current epoch and should not be
self: &<b>mut</b> <a href="../sui-framework/authenticator_state.md#0x2_authenticator_state_AuthenticatorState">AuthenticatorState</a>,
// any jwk below this epoch is not retained
min_epoch: <a href="../move-stdlib/u64.md#0x1_u64">u64</a>,
ctx: &TxContext) {
ctx: &TxContext,
) {
// This will only be called by sui_system::advance_epoch
<b>assert</b>!(ctx.sender() == @0x0, <a href="../sui-framework/authenticator_state.md#0x2_authenticator_state_ENotSystemAddress">ENotSystemAddress</a>);

Expand Down Expand Up @@ -793,10 +790,7 @@ JWK state from the chain.
<summary>Implementation</summary>


<pre><code><b>fun</b> <a href="../sui-framework/authenticator_state.md#0x2_authenticator_state_get_active_jwks">get_active_jwks</a>(
self: &<a href="../sui-framework/authenticator_state.md#0x2_authenticator_state_AuthenticatorState">AuthenticatorState</a>,
ctx: &TxContext,
): <a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;<a href="../sui-framework/authenticator_state.md#0x2_authenticator_state_ActiveJwk">ActiveJwk</a>&gt; {
<pre><code><b>fun</b> <a href="../sui-framework/authenticator_state.md#0x2_authenticator_state_get_active_jwks">get_active_jwks</a>(self: &<a href="../sui-framework/authenticator_state.md#0x2_authenticator_state_AuthenticatorState">AuthenticatorState</a>, ctx: &TxContext): <a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;<a href="../sui-framework/authenticator_state.md#0x2_authenticator_state_ActiveJwk">ActiveJwk</a>&gt; {
<b>assert</b>!(ctx.sender() == @0x0, <a href="../sui-framework/authenticator_state.md#0x2_authenticator_state_ENotSystemAddress">ENotSystemAddress</a>);
self.<a href="../sui-framework/authenticator_state.md#0x2_authenticator_state_load_inner">load_inner</a>().active_jwks
}
Expand Down
13 changes: 8 additions & 5 deletions crates/sui-framework/docs/sui-framework/borrow.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ Create a new <code><a href="borrow.md#0x2_borrow_Referent">Referent</a></code> s
<pre><code><b>public</b> <b>fun</b> <a href="borrow.md#0x2_borrow_new">new</a>&lt;T: key + store&gt;(value: T, ctx: &<b>mut</b> TxContext): <a href="borrow.md#0x2_borrow_Referent">Referent</a>&lt;T&gt; {
<a href="borrow.md#0x2_borrow_Referent">Referent</a> {
id: <a href="tx_context.md#0x2_tx_context_fresh_object_address">tx_context::fresh_object_address</a>(ctx),
value: <a href="../move-stdlib/option.md#0x1_option_some">option::some</a>(value)
value: <a href="../move-stdlib/option.md#0x1_option_some">option::some</a>(value),
}
}
</code></pre>
Expand Down Expand Up @@ -167,10 +167,13 @@ hot potato.
<b>let</b> value = self.value.extract();
<b>let</b> id = <a href="object.md#0x2_object_id">object::id</a>(&value);

(value, <a href="borrow.md#0x2_borrow_Borrow">Borrow</a> {
ref: self.id,
obj: id
})
(
value,
<a href="borrow.md#0x2_borrow_Borrow">Borrow</a> {
ref: self.id,
obj: id,
},
)
}
</code></pre>

Expand Down
6 changes: 1 addition & 5 deletions crates/sui-framework/docs/sui-framework/clock.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,7 @@ called exactly once, during genesis.
<summary>Implementation</summary>


<pre><code><b>fun</b> <a href="../sui-framework/clock.md#0x2_clock_consensus_commit_prologue">consensus_commit_prologue</a>(
<a href="../sui-framework/clock.md#0x2_clock">clock</a>: &<b>mut</b> <a href="../sui-framework/clock.md#0x2_clock_Clock">Clock</a>,
timestamp_ms: <a href="../move-stdlib/u64.md#0x1_u64">u64</a>,
ctx: &TxContext,
) {
<pre><code><b>fun</b> <a href="../sui-framework/clock.md#0x2_clock_consensus_commit_prologue">consensus_commit_prologue</a>(<a href="../sui-framework/clock.md#0x2_clock">clock</a>: &<b>mut</b> <a href="../sui-framework/clock.md#0x2_clock_Clock">Clock</a>, timestamp_ms: <a href="../move-stdlib/u64.md#0x1_u64">u64</a>, ctx: &TxContext) {
// Validator will make a special system call <b>with</b> sender set <b>as</b> 0x0.
<b>assert</b>!(ctx.sender() == @0x0, <a href="../sui-framework/clock.md#0x2_clock_ENotSystemAddress">ENotSystemAddress</a>);

Expand Down
25 changes: 14 additions & 11 deletions crates/sui-framework/docs/sui-framework/display.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,10 @@ Create a new Display<T> object with a set of fields.


<pre><code><b>public</b> <b>fun</b> <a href="display.md#0x2_display_new_with_fields">new_with_fields</a>&lt;T: key&gt;(
pub: &Publisher, fields: <a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;String&gt;, values: <a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;String&gt;, ctx: &<b>mut</b> TxContext
pub: &Publisher,
fields: <a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;String&gt;,
values: <a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;String&gt;,
ctx: &<b>mut</b> TxContext,
): <a href="display.md#0x2_display_Display">Display</a>&lt;T&gt; {
<b>let</b> len = fields.length();
<b>assert</b>!(len == values.length(), <a href="display.md#0x2_display_EVecLengthMismatch">EVecLengthMismatch</a>);
Expand Down Expand Up @@ -283,7 +286,7 @@ Create a new empty Display<T> object and keep it.
<summary>Implementation</summary>


<pre><code>entry <b>public</b> <b>fun</b> <a href="display.md#0x2_display_create_and_keep">create_and_keep</a>&lt;T: key&gt;(pub: &Publisher, ctx: &<b>mut</b> TxContext) {
<pre><code><b>public</b> entry <b>fun</b> <a href="display.md#0x2_display_create_and_keep">create_and_keep</a>&lt;T: key&gt;(pub: &Publisher, ctx: &<b>mut</b> TxContext) {
<a href="transfer.md#0x2_transfer_public_transfer">transfer::public_transfer</a>(<a href="display.md#0x2_display_new">new</a>&lt;T&gt;(pub, ctx), ctx.sender())
}
</code></pre>
Expand All @@ -308,9 +311,7 @@ Manually bump the version and emit an event with the updated version's contents.
<summary>Implementation</summary>


<pre><code>entry <b>public</b> <b>fun</b> <a href="display.md#0x2_display_update_version">update_version</a>&lt;T: key&gt;(
<a href="display.md#0x2_display">display</a>: &<b>mut</b> <a href="display.md#0x2_display_Display">Display</a>&lt;T&gt;
) {
<pre><code><b>public</b> entry <b>fun</b> <a href="display.md#0x2_display_update_version">update_version</a>&lt;T: key&gt;(<a href="display.md#0x2_display">display</a>: &<b>mut</b> <a href="display.md#0x2_display_Display">Display</a>&lt;T&gt;) {
<a href="display.md#0x2_display">display</a>.version = <a href="display.md#0x2_display">display</a>.version + 1;
<a href="event.md#0x2_event_emit">event::emit</a>(<a href="display.md#0x2_display_VersionUpdated">VersionUpdated</a>&lt;T&gt; {
version: <a href="display.md#0x2_display">display</a>.version,
Expand Down Expand Up @@ -340,7 +341,7 @@ Sets a custom <code>name</code> field with the <code>value</code>.
<summary>Implementation</summary>


<pre><code>entry <b>public</b> <b>fun</b> <a href="display.md#0x2_display_add">add</a>&lt;T: key&gt;(self: &<b>mut</b> <a href="display.md#0x2_display_Display">Display</a>&lt;T&gt;, name: String, value: String) {
<pre><code><b>public</b> entry <b>fun</b> <a href="display.md#0x2_display_add">add</a>&lt;T: key&gt;(self: &<b>mut</b> <a href="display.md#0x2_display_Display">Display</a>&lt;T&gt;, name: String, value: String) {
self.<a href="display.md#0x2_display_add_internal">add_internal</a>(name, value)
}
</code></pre>
Expand All @@ -365,8 +366,10 @@ Sets multiple <code>fields</code> with <code>values</code>.
<summary>Implementation</summary>


<pre><code>entry <b>public</b> <b>fun</b> <a href="display.md#0x2_display_add_multiple">add_multiple</a>&lt;T: key&gt;(
self: &<b>mut</b> <a href="display.md#0x2_display_Display">Display</a>&lt;T&gt;, fields: <a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;String&gt;, values: <a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;String&gt;
<pre><code><b>public</b> entry <b>fun</b> <a href="display.md#0x2_display_add_multiple">add_multiple</a>&lt;T: key&gt;(
self: &<b>mut</b> <a href="display.md#0x2_display_Display">Display</a>&lt;T&gt;,
fields: <a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;String&gt;,
values: <a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;String&gt;,
) {
<b>let</b> len = fields.length();
<b>assert</b>!(len == values.length(), <a href="display.md#0x2_display_EVecLengthMismatch">EVecLengthMismatch</a>);
Expand Down Expand Up @@ -400,7 +403,7 @@ TODO (long run): version changes;
<summary>Implementation</summary>


<pre><code>entry <b>public</b> <b>fun</b> <a href="display.md#0x2_display_edit">edit</a>&lt;T: key&gt;(self: &<b>mut</b> <a href="display.md#0x2_display_Display">Display</a>&lt;T&gt;, name: String, value: String) {
<pre><code><b>public</b> entry <b>fun</b> <a href="display.md#0x2_display_edit">edit</a>&lt;T: key&gt;(self: &<b>mut</b> <a href="display.md#0x2_display_Display">Display</a>&lt;T&gt;, name: String, value: String) {
<b>let</b> (_, _) = self.fields.<a href="display.md#0x2_display_remove">remove</a>(&name);
self.<a href="display.md#0x2_display_add_internal">add_internal</a>(name, value)
}
Expand All @@ -426,7 +429,7 @@ Remove the key from the Display.
<summary>Implementation</summary>


<pre><code>entry <b>public</b> <b>fun</b> <a href="display.md#0x2_display_remove">remove</a>&lt;T: key&gt;(self: &<b>mut</b> <a href="display.md#0x2_display_Display">Display</a>&lt;T&gt;, name: String) {
<pre><code><b>public</b> entry <b>fun</b> <a href="display.md#0x2_display_remove">remove</a>&lt;T: key&gt;(self: &<b>mut</b> <a href="display.md#0x2_display_Display">Display</a>&lt;T&gt;, name: String) {
self.fields.<a href="display.md#0x2_display_remove">remove</a>(&name);
}
</code></pre>
Expand Down Expand Up @@ -530,7 +533,7 @@ Internal function to create a new <code><a href="display.md#0x2_display_Display"
<b>let</b> uid = <a href="object.md#0x2_object_new">object::new</a>(ctx);

<a href="event.md#0x2_event_emit">event::emit</a>(<a href="display.md#0x2_display_DisplayCreated">DisplayCreated</a>&lt;T&gt; {
id: uid.to_inner()
id: uid.to_inner(),
});

<a href="display.md#0x2_display_Display">Display</a> {
Expand Down
6 changes: 3 additions & 3 deletions crates/sui-framework/docs/sui-framework/hex.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,11 @@ Aborts if the hex string contains non-valid hex characters (valid characters are


<pre><code><b>fun</b> <a href="../sui-framework/hex.md#0x2_hex_decode_byte">decode_byte</a>(<a href="../sui-framework/hex.md#0x2_hex">hex</a>: u8): u8 {
<b>if</b> (/* 0 .. 9 */ 48 &lt;= <a href="../sui-framework/hex.md#0x2_hex">hex</a> && <a href="../sui-framework/hex.md#0x2_hex">hex</a> &lt; 58) {
<b>if</b> (48 &lt;= <a href="../sui-framework/hex.md#0x2_hex">hex</a> && <a href="../sui-framework/hex.md#0x2_hex">hex</a> &lt; 58) {
<a href="../sui-framework/hex.md#0x2_hex">hex</a> - 48
} <b>else</b> <b>if</b> (/* A .. F */ 65 &lt;= <a href="../sui-framework/hex.md#0x2_hex">hex</a> && <a href="../sui-framework/hex.md#0x2_hex">hex</a> &lt; 71) {
} <b>else</b> <b>if</b> (65 &lt;= <a href="../sui-framework/hex.md#0x2_hex">hex</a> && <a href="../sui-framework/hex.md#0x2_hex">hex</a> &lt; 71) {
10 + <a href="../sui-framework/hex.md#0x2_hex">hex</a> - 65
} <b>else</b> <b>if</b> (/* a .. f */ 97 &lt;= <a href="../sui-framework/hex.md#0x2_hex">hex</a> && <a href="../sui-framework/hex.md#0x2_hex">hex</a> &lt; 103) {
} <b>else</b> <b>if</b> (97 &lt;= <a href="../sui-framework/hex.md#0x2_hex">hex</a> && <a href="../sui-framework/hex.md#0x2_hex">hex</a> &lt; 103) {
10 + <a href="../sui-framework/hex.md#0x2_hex">hex</a> - 97
} <b>else</b> {
<b>abort</b> <a href="../sui-framework/hex.md#0x2_hex_ENotValidHexCharacter">ENotValidHexCharacter</a>
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-framework/docs/sui-framework/math.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ DEPRECATED, use <code>std::u128::sqrt</code> instead


<pre><code><b>public</b> <b>fun</b> <a href="math.md#0x2_math_sqrt_u128">sqrt_u128</a>(x: <a href="../move-stdlib/u128.md#0x1_u128">u128</a>): <a href="../move-stdlib/u128.md#0x1_u128">u128</a> {
x.<a href="math.md#0x2_math_sqrt">sqrt</a>()
x.<a href="math.md#0x2_math_sqrt">sqrt</a>()
}
</code></pre>

Expand Down
10 changes: 5 additions & 5 deletions crates/sui-framework/docs/sui-framework/object.md
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ This should only be called once from <code><a href="../sui-framework/clock.md#0x

<pre><code><b>public</b>(package) <b>fun</b> <a href="../sui-framework/clock.md#0x2_clock">clock</a>(): <a href="../sui-framework/object.md#0x2_object_UID">UID</a> {
<a href="../sui-framework/object.md#0x2_object_UID">UID</a> {
id: <a href="../sui-framework/object.md#0x2_object_ID">ID</a> { bytes: <a href="../sui-framework/object.md#0x2_object_SUI_CLOCK_OBJECT_ID">SUI_CLOCK_OBJECT_ID</a> }
id: <a href="../sui-framework/object.md#0x2_object_ID">ID</a> { bytes: <a href="../sui-framework/object.md#0x2_object_SUI_CLOCK_OBJECT_ID">SUI_CLOCK_OBJECT_ID</a> },
}
}
</code></pre>
Expand Down Expand Up @@ -358,7 +358,7 @@ This should only be called once from <code><a href="../sui-framework/authenticat

<pre><code><b>public</b>(package) <b>fun</b> <a href="../sui-framework/authenticator_state.md#0x2_authenticator_state">authenticator_state</a>(): <a href="../sui-framework/object.md#0x2_object_UID">UID</a> {
<a href="../sui-framework/object.md#0x2_object_UID">UID</a> {
id: <a href="../sui-framework/object.md#0x2_object_ID">ID</a> { bytes: <a href="../sui-framework/object.md#0x2_object_SUI_AUTHENTICATOR_STATE_ID">SUI_AUTHENTICATOR_STATE_ID</a> }
id: <a href="../sui-framework/object.md#0x2_object_ID">ID</a> { bytes: <a href="../sui-framework/object.md#0x2_object_SUI_AUTHENTICATOR_STATE_ID">SUI_AUTHENTICATOR_STATE_ID</a> },
}
}
</code></pre>
Expand Down Expand Up @@ -386,7 +386,7 @@ This should only be called once from <code><a href="../sui-framework/random.md#0

<pre><code><b>public</b>(package) <b>fun</b> <a href="../sui-framework/object.md#0x2_object_randomness_state">randomness_state</a>(): <a href="../sui-framework/object.md#0x2_object_UID">UID</a> {
<a href="../sui-framework/object.md#0x2_object_UID">UID</a> {
id: <a href="../sui-framework/object.md#0x2_object_ID">ID</a> { bytes: <a href="../sui-framework/object.md#0x2_object_SUI_RANDOM_ID">SUI_RANDOM_ID</a> }
id: <a href="../sui-framework/object.md#0x2_object_ID">ID</a> { bytes: <a href="../sui-framework/object.md#0x2_object_SUI_RANDOM_ID">SUI_RANDOM_ID</a> },
}
}
</code></pre>
Expand Down Expand Up @@ -414,7 +414,7 @@ This should only be called once from <code><a href="../sui-framework/deny_list.m

<pre><code><b>public</b>(package) <b>fun</b> <a href="../sui-framework/object.md#0x2_object_sui_deny_list_object_id">sui_deny_list_object_id</a>(): <a href="../sui-framework/object.md#0x2_object_UID">UID</a> {
<a href="../sui-framework/object.md#0x2_object_UID">UID</a> {
id: <a href="../sui-framework/object.md#0x2_object_ID">ID</a> { bytes: <a href="../sui-framework/object.md#0x2_object_SUI_DENY_LIST_OBJECT_ID">SUI_DENY_LIST_OBJECT_ID</a> }
id: <a href="../sui-framework/object.md#0x2_object_ID">ID</a> { bytes: <a href="../sui-framework/object.md#0x2_object_SUI_DENY_LIST_OBJECT_ID">SUI_DENY_LIST_OBJECT_ID</a> },
}
}
</code></pre>
Expand Down Expand Up @@ -442,7 +442,7 @@ This should only be called once from <code>bridge</code>.

<pre><code><b>fun</b> <a href="../sui-framework/object.md#0x2_object_bridge">bridge</a>(): <a href="../sui-framework/object.md#0x2_object_UID">UID</a> {
<a href="../sui-framework/object.md#0x2_object_UID">UID</a> {
id: <a href="../sui-framework/object.md#0x2_object_ID">ID</a> { bytes: <a href="../sui-framework/object.md#0x2_object_SUI_BRIDGE_ID">SUI_BRIDGE_ID</a> }
id: <a href="../sui-framework/object.md#0x2_object_ID">ID</a> { bytes: <a href="../sui-framework/object.md#0x2_object_SUI_BRIDGE_ID">SUI_BRIDGE_ID</a> },
}
}
</code></pre>
Expand Down
11 changes: 2 additions & 9 deletions crates/sui-framework/docs/sui-framework/package.md
Original file line number Diff line number Diff line change
Expand Up @@ -899,11 +899,7 @@ for the upgrade to succeed.
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="package.md#0x2_package_authorize_upgrade">authorize_upgrade</a>(
cap: &<b>mut</b> <a href="package.md#0x2_package_UpgradeCap">UpgradeCap</a>,
policy: u8,
digest: <a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;
): <a href="package.md#0x2_package_UpgradeTicket">UpgradeTicket</a> {
<pre><code><b>public</b> <b>fun</b> <a href="package.md#0x2_package_authorize_upgrade">authorize_upgrade</a>(cap: &<b>mut</b> <a href="package.md#0x2_package_UpgradeCap">UpgradeCap</a>, policy: u8, digest: <a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;): <a href="package.md#0x2_package_UpgradeTicket">UpgradeTicket</a> {
<b>let</b> id_zero = @0x0.to_id();
<b>assert</b>!(cap.<a href="package.md#0x2_package">package</a> != id_zero, <a href="package.md#0x2_package_EAlreadyAuthorized">EAlreadyAuthorized</a>);
<b>assert</b>!(policy &gt;= cap.policy, <a href="package.md#0x2_package_ETooPermissive">ETooPermissive</a>);
Expand Down Expand Up @@ -941,10 +937,7 @@ the upgrade.
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="package.md#0x2_package_commit_upgrade">commit_upgrade</a>(
cap: &<b>mut</b> <a href="package.md#0x2_package_UpgradeCap">UpgradeCap</a>,
receipt: <a href="package.md#0x2_package_UpgradeReceipt">UpgradeReceipt</a>,
) {
<pre><code><b>public</b> <b>fun</b> <a href="package.md#0x2_package_commit_upgrade">commit_upgrade</a>(cap: &<b>mut</b> <a href="package.md#0x2_package_UpgradeCap">UpgradeCap</a>, receipt: <a href="package.md#0x2_package_UpgradeReceipt">UpgradeReceipt</a>) {
<b>let</b> <a href="package.md#0x2_package_UpgradeReceipt">UpgradeReceipt</a> { cap: cap_id, <a href="package.md#0x2_package">package</a> } = receipt;

<b>assert</b>!(<a href="object.md#0x2_object_id">object::id</a>(cap) == cap_id, <a href="package.md#0x2_package_EWrongUpgradeCap">EWrongUpgradeCap</a>);
Expand Down
Loading

0 comments on commit 7336840

Please sign in to comment.