Skip to content

Commit

Permalink
snapshot'ing around
Browse files Browse the repository at this point in the history
  • Loading branch information
dariorussi committed Oct 19, 2024
1 parent b3cf8bc commit 47ad6fd
Show file tree
Hide file tree
Showing 9 changed files with 1,317 additions and 26 deletions.
279 changes: 270 additions & 9 deletions crates/sui-framework/docs/sui-framework/tx_context.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,27 @@ title: Module `0x2::tx_context`


- [Struct `TxContext`](#0x2_tx_context_TxContext)
- [Constants](#@Constants_0)
- [Function `sender`](#0x2_tx_context_sender)
- [Function `digest`](#0x2_tx_context_digest)
- [Function `epoch`](#0x2_tx_context_epoch)
- [Function `epoch_timestamp_ms`](#0x2_tx_context_epoch_timestamp_ms)
- [Function `sponsor`](#0x2_tx_context_sponsor)
- [Function `fresh_object_address`](#0x2_tx_context_fresh_object_address)
- [Function `increment_ids_created`](#0x2_tx_context_increment_ids_created)
- [Function `ids_created`](#0x2_tx_context_ids_created)
- [Function `derive_id`](#0x2_tx_context_derive_id)
- [Function `native_sender`](#0x2_tx_context_native_sender)
- [Function `native_digest`](#0x2_tx_context_native_digest)
- [Function `native_epoch`](#0x2_tx_context_native_epoch)
- [Function `native_epoch_timestamp_ms`](#0x2_tx_context_native_epoch_timestamp_ms)
- [Function `native_sponsor`](#0x2_tx_context_native_sponsor)
- [Function `native_ids_created`](#0x2_tx_context_native_ids_created)
- [Function `native_inc_ids_created`](#0x2_tx_context_native_inc_ids_created)


<pre><code></code></pre>
<pre><code><b>use</b> <a href="../move-stdlib/option.md#0x1_option">0x1::option</a>;
</code></pre>



Expand Down Expand Up @@ -73,6 +84,29 @@ the VM and passed in to the entrypoint of the transaction as <code>&<b>mut</b> <

</details>

<a name="@Constants_0"></a>

## Constants


<a name="0x2_tx_context_EUnsupportedFunction"></a>



<pre><code><b>const</b> <a href="../sui-framework/tx_context.md#0x2_tx_context_EUnsupportedFunction">EUnsupportedFunction</a>: <a href="../move-stdlib/u64.md#0x1_u64">u64</a> = 2;
</code></pre>



<a name="0x2_tx_context_NATIVE_CONTEXT"></a>



<pre><code><b>const</b> <a href="../sui-framework/tx_context.md#0x2_tx_context_NATIVE_CONTEXT">NATIVE_CONTEXT</a>: bool = <b>false</b>;
</code></pre>



<a name="0x2_tx_context_sender"></a>

## Function `sender`
Expand All @@ -91,7 +125,11 @@ transaction


<pre><code><b>public</b> <b>fun</b> <a href="../sui-framework/tx_context.md#0x2_tx_context_sender">sender</a>(self: &<a href="../sui-framework/tx_context.md#0x2_tx_context_TxContext">TxContext</a>): <b>address</b> {
self.sender
<b>if</b> (<a href="../sui-framework/tx_context.md#0x2_tx_context_NATIVE_CONTEXT">NATIVE_CONTEXT</a>) {
self.<a href="../sui-framework/tx_context.md#0x2_tx_context_native_sender">native_sender</a>()
} <b>else</b> {
self.sender
}
}
</code></pre>

Expand All @@ -117,7 +155,11 @@ Please do not use as a source of randomness.


<pre><code><b>public</b> <b>fun</b> <a href="../sui-framework/tx_context.md#0x2_tx_context_digest">digest</a>(self: &<a href="../sui-framework/tx_context.md#0x2_tx_context_TxContext">TxContext</a>): &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt; {
&self.tx_hash
<b>if</b> (<a href="../sui-framework/tx_context.md#0x2_tx_context_NATIVE_CONTEXT">NATIVE_CONTEXT</a>) {
self.<a href="../sui-framework/tx_context.md#0x2_tx_context_native_digest">native_digest</a>()
} <b>else</b> {
&self.tx_hash
}
}
</code></pre>

Expand All @@ -142,7 +184,11 @@ Return the current epoch


<pre><code><b>public</b> <b>fun</b> <a href="../sui-framework/tx_context.md#0x2_tx_context_epoch">epoch</a>(self: &<a href="../sui-framework/tx_context.md#0x2_tx_context_TxContext">TxContext</a>): <a href="../move-stdlib/u64.md#0x1_u64">u64</a> {
self.epoch
<b>if</b> (<a href="../sui-framework/tx_context.md#0x2_tx_context_NATIVE_CONTEXT">NATIVE_CONTEXT</a>) {
self.<a href="../sui-framework/tx_context.md#0x2_tx_context_native_epoch">native_epoch</a>()
} <b>else</b> {
self.epoch
}
}
</code></pre>

Expand All @@ -167,7 +213,36 @@ Return the epoch start time as a unix timestamp in milliseconds.


<pre><code><b>public</b> <b>fun</b> <a href="../sui-framework/tx_context.md#0x2_tx_context_epoch_timestamp_ms">epoch_timestamp_ms</a>(self: &<a href="../sui-framework/tx_context.md#0x2_tx_context_TxContext">TxContext</a>): <a href="../move-stdlib/u64.md#0x1_u64">u64</a> {
self.epoch_timestamp_ms
<b>if</b> (<a href="../sui-framework/tx_context.md#0x2_tx_context_NATIVE_CONTEXT">NATIVE_CONTEXT</a>) {
self.<a href="../sui-framework/tx_context.md#0x2_tx_context_native_epoch_timestamp_ms">native_epoch_timestamp_ms</a>()
} <b>else</b> {
self.epoch_timestamp_ms
}
}
</code></pre>



</details>

<a name="0x2_tx_context_sponsor"></a>

## Function `sponsor`



<pre><code><b>public</b> <b>fun</b> <a href="../sui-framework/tx_context.md#0x2_tx_context_sponsor">sponsor</a>(self: &<a href="../sui-framework/tx_context.md#0x2_tx_context_TxContext">tx_context::TxContext</a>): <a href="../move-stdlib/option.md#0x1_option_Option">option::Option</a>&lt;<b>address</b>&gt;
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="../sui-framework/tx_context.md#0x2_tx_context_sponsor">sponsor</a>(self: &<a href="../sui-framework/tx_context.md#0x2_tx_context_TxContext">TxContext</a>): Option&lt;<b>address</b>&gt; {
<b>assert</b>!(<a href="../sui-framework/tx_context.md#0x2_tx_context_NATIVE_CONTEXT">NATIVE_CONTEXT</a>, <a href="../sui-framework/tx_context.md#0x2_tx_context_EUnsupportedFunction">EUnsupportedFunction</a>);
self.<a href="../sui-framework/tx_context.md#0x2_tx_context_native_sponsor">native_sponsor</a>()
}
</code></pre>

Expand All @@ -194,15 +269,43 @@ In other words, the generated address is a globally unique object ID.


<pre><code><b>public</b> <b>fun</b> <a href="../sui-framework/tx_context.md#0x2_tx_context_fresh_object_address">fresh_object_address</a>(ctx: &<b>mut</b> <a href="../sui-framework/tx_context.md#0x2_tx_context_TxContext">TxContext</a>): <b>address</b> {
<b>let</b> ids_created = ctx.ids_created;
<b>let</b> id = <a href="../sui-framework/tx_context.md#0x2_tx_context_derive_id">derive_id</a>(*&ctx.tx_hash, ids_created);
ctx.ids_created = ids_created + 1;
<b>let</b> ids_created = ctx.<a href="../sui-framework/tx_context.md#0x2_tx_context_ids_created">ids_created</a>();
<b>let</b> id = <a href="../sui-framework/tx_context.md#0x2_tx_context_derive_id">derive_id</a>(*ctx.<a href="../sui-framework/tx_context.md#0x2_tx_context_digest">digest</a>(), ids_created);
ctx.<a href="../sui-framework/tx_context.md#0x2_tx_context_increment_ids_created">increment_ids_created</a>();
id
}
</code></pre>



</details>

<a name="0x2_tx_context_increment_ids_created"></a>

## Function `increment_ids_created`



<pre><code><b>fun</b> <a href="../sui-framework/tx_context.md#0x2_tx_context_increment_ids_created">increment_ids_created</a>(self: &<b>mut</b> <a href="../sui-framework/tx_context.md#0x2_tx_context_TxContext">tx_context::TxContext</a>)
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>fun</b> <a href="../sui-framework/tx_context.md#0x2_tx_context_increment_ids_created">increment_ids_created</a>(self: &<b>mut</b> <a href="../sui-framework/tx_context.md#0x2_tx_context_TxContext">TxContext</a>) {
<b>if</b> (<a href="../sui-framework/tx_context.md#0x2_tx_context_NATIVE_CONTEXT">NATIVE_CONTEXT</a>) {
self.<a href="../sui-framework/tx_context.md#0x2_tx_context_native_inc_ids_created">native_inc_ids_created</a>()
} <b>else</b> {
self.ids_created = self.ids_created + 1
}
}
</code></pre>



</details>

<a name="0x2_tx_context_ids_created"></a>
Expand All @@ -223,7 +326,11 @@ Hidden for now, but may expose later


<pre><code><b>fun</b> <a href="../sui-framework/tx_context.md#0x2_tx_context_ids_created">ids_created</a>(self: &<a href="../sui-framework/tx_context.md#0x2_tx_context_TxContext">TxContext</a>): <a href="../move-stdlib/u64.md#0x1_u64">u64</a> {
self.ids_created
<b>if</b> (<a href="../sui-framework/tx_context.md#0x2_tx_context_NATIVE_CONTEXT">NATIVE_CONTEXT</a>) {
self.<a href="../sui-framework/tx_context.md#0x2_tx_context_native_ids_created">native_ids_created</a>()
} <b>else</b> {
self.ids_created
}
}
</code></pre>

Expand Down Expand Up @@ -252,4 +359,158 @@ Native function for deriving an ID via hash(tx_hash || ids_created)



</details>

<a name="0x2_tx_context_native_sender"></a>

## Function `native_sender`



<pre><code><b>fun</b> <a href="../sui-framework/tx_context.md#0x2_tx_context_native_sender">native_sender</a>(self: &<a href="../sui-framework/tx_context.md#0x2_tx_context_TxContext">tx_context::TxContext</a>): <b>address</b>
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>native</b> <b>fun</b> <a href="../sui-framework/tx_context.md#0x2_tx_context_native_sender">native_sender</a>(self: &<a href="../sui-framework/tx_context.md#0x2_tx_context_TxContext">TxContext</a>): <b>address</b>;
</code></pre>



</details>

<a name="0x2_tx_context_native_digest"></a>

## Function `native_digest`



<pre><code><b>fun</b> <a href="../sui-framework/tx_context.md#0x2_tx_context_native_digest">native_digest</a>(self: &<a href="../sui-framework/tx_context.md#0x2_tx_context_TxContext">tx_context::TxContext</a>): &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>native</b> <b>fun</b> <a href="../sui-framework/tx_context.md#0x2_tx_context_native_digest">native_digest</a>(self: &<a href="../sui-framework/tx_context.md#0x2_tx_context_TxContext">TxContext</a>): &<a href="../move-stdlib/vector.md#0x1_vector">vector</a>&lt;u8&gt;;
</code></pre>



</details>

<a name="0x2_tx_context_native_epoch"></a>

## Function `native_epoch`



<pre><code><b>fun</b> <a href="../sui-framework/tx_context.md#0x2_tx_context_native_epoch">native_epoch</a>(self: &<a href="../sui-framework/tx_context.md#0x2_tx_context_TxContext">tx_context::TxContext</a>): <a href="../move-stdlib/u64.md#0x1_u64">u64</a>
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>native</b> <b>fun</b> <a href="../sui-framework/tx_context.md#0x2_tx_context_native_epoch">native_epoch</a>(self: &<a href="../sui-framework/tx_context.md#0x2_tx_context_TxContext">TxContext</a>): <a href="../move-stdlib/u64.md#0x1_u64">u64</a>;
</code></pre>



</details>

<a name="0x2_tx_context_native_epoch_timestamp_ms"></a>

## Function `native_epoch_timestamp_ms`



<pre><code><b>fun</b> <a href="../sui-framework/tx_context.md#0x2_tx_context_native_epoch_timestamp_ms">native_epoch_timestamp_ms</a>(self: &<a href="../sui-framework/tx_context.md#0x2_tx_context_TxContext">tx_context::TxContext</a>): <a href="../move-stdlib/u64.md#0x1_u64">u64</a>
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>native</b> <b>fun</b> <a href="../sui-framework/tx_context.md#0x2_tx_context_native_epoch_timestamp_ms">native_epoch_timestamp_ms</a>(self: &<a href="../sui-framework/tx_context.md#0x2_tx_context_TxContext">TxContext</a>): <a href="../move-stdlib/u64.md#0x1_u64">u64</a>;
</code></pre>



</details>

<a name="0x2_tx_context_native_sponsor"></a>

## Function `native_sponsor`



<pre><code><b>fun</b> <a href="../sui-framework/tx_context.md#0x2_tx_context_native_sponsor">native_sponsor</a>(self: &<a href="../sui-framework/tx_context.md#0x2_tx_context_TxContext">tx_context::TxContext</a>): <a href="../move-stdlib/option.md#0x1_option_Option">option::Option</a>&lt;<b>address</b>&gt;
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>native</b> <b>fun</b> <a href="../sui-framework/tx_context.md#0x2_tx_context_native_sponsor">native_sponsor</a>(self: &<a href="../sui-framework/tx_context.md#0x2_tx_context_TxContext">TxContext</a>): Option&lt;<b>address</b>&gt;;
</code></pre>



</details>

<a name="0x2_tx_context_native_ids_created"></a>

## Function `native_ids_created`



<pre><code><b>fun</b> <a href="../sui-framework/tx_context.md#0x2_tx_context_native_ids_created">native_ids_created</a>(self: &<a href="../sui-framework/tx_context.md#0x2_tx_context_TxContext">tx_context::TxContext</a>): <a href="../move-stdlib/u64.md#0x1_u64">u64</a>
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>native</b> <b>fun</b> <a href="../sui-framework/tx_context.md#0x2_tx_context_native_ids_created">native_ids_created</a>(self: &<a href="../sui-framework/tx_context.md#0x2_tx_context_TxContext">TxContext</a>): <a href="../move-stdlib/u64.md#0x1_u64">u64</a>;
</code></pre>



</details>

<a name="0x2_tx_context_native_inc_ids_created"></a>

## Function `native_inc_ids_created`



<pre><code><b>fun</b> <a href="../sui-framework/tx_context.md#0x2_tx_context_native_inc_ids_created">native_inc_ids_created</a>(self: &<b>mut</b> <a href="../sui-framework/tx_context.md#0x2_tx_context_TxContext">tx_context::TxContext</a>)
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>native</b> <b>fun</b> <a href="../sui-framework/tx_context.md#0x2_tx_context_native_inc_ids_created">native_inc_ids_created</a>(self: &<b>mut</b> <a href="../sui-framework/tx_context.md#0x2_tx_context_TxContext">TxContext</a>);
</code></pre>



</details>
Binary file modified crates/sui-framework/packages_compiled/sui-framework
Binary file not shown.
27 changes: 27 additions & 0 deletions crates/sui-framework/published_api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1126,15 +1126,42 @@ epoch
epoch_timestamp_ms
public fun
0x2::tx_context
sponsor
public fun
0x2::tx_context
fresh_object_address
public fun
0x2::tx_context
increment_ids_created
fun
0x2::tx_context
ids_created
fun
0x2::tx_context
derive_id
fun
0x2::tx_context
native_sender
fun
0x2::tx_context
native_digest
fun
0x2::tx_context
native_epoch
fun
0x2::tx_context
native_epoch_timestamp_ms
fun
0x2::tx_context
native_sponsor
fun
0x2::tx_context
native_ids_created
fun
0x2::tx_context
native_inc_ids_created
fun
0x2::tx_context
ID
public struct
0x2::object
Expand Down
Loading

0 comments on commit 47ad6fd

Please sign in to comment.