|
5 | 5 |
|
6 | 6 |
|
7 | 7 |
|
| 8 | +- [Struct `Receiving`](#0x2_transfer_Receiving) |
8 | 9 | - [Constants](#@Constants_0)
|
9 | 10 | - [Function `transfer`](#0x2_transfer_transfer)
|
10 | 11 | - [Function `public_transfer`](#0x2_transfer_public_transfer)
|
11 | 12 | - [Function `freeze_object`](#0x2_transfer_freeze_object)
|
12 | 13 | - [Function `public_freeze_object`](#0x2_transfer_public_freeze_object)
|
13 | 14 | - [Function `share_object`](#0x2_transfer_share_object)
|
14 | 15 | - [Function `public_share_object`](#0x2_transfer_public_share_object)
|
| 16 | +- [Function `receive`](#0x2_transfer_receive) |
15 | 17 | - [Function `freeze_object_impl`](#0x2_transfer_freeze_object_impl)
|
16 | 18 | - [Function `share_object_impl`](#0x2_transfer_share_object_impl)
|
17 | 19 | - [Function `transfer_impl`](#0x2_transfer_transfer_impl)
|
| 20 | +- [Function `receive_impl`](#0x2_transfer_receive_impl) |
18 | 21 |
|
19 | 22 |
|
20 |
| -<pre><code></code></pre> |
| 23 | +<pre><code><b>use</b> <a href="object.md#0x2_object">0x2::object</a>; |
| 24 | +</code></pre> |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | +<a name="0x2_transfer_Receiving"></a> |
| 29 | + |
| 30 | +## Struct `Receiving` |
| 31 | + |
| 32 | +This represents the ability to <code>receive</code> an object of type <code>T</code>. |
| 33 | +This type is ephemeral per-transaction and cannot be stored on-chain. |
| 34 | +This does not represent the obligation to receive the object that it |
| 35 | +references, but simply the ability to receive the object with object ID |
| 36 | +<code>id</code> at version <code>version</code> if you can prove mutable access to the parent |
| 37 | +object during the transaction. |
| 38 | +Internals of this struct are opaque outside this module. |
| 39 | + |
| 40 | + |
| 41 | +<pre><code><b>struct</b> <a href="transfer.md#0x2_transfer_Receiving">Receiving</a><T: key> <b>has</b> drop |
| 42 | +</code></pre> |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | +<details> |
| 47 | +<summary>Fields</summary> |
| 48 | + |
21 | 49 |
|
| 50 | +<dl> |
| 51 | +<dt> |
| 52 | +<code>id: <a href="object.md#0x2_object_ID">object::ID</a></code> |
| 53 | +</dt> |
| 54 | +<dd> |
22 | 55 |
|
| 56 | +</dd> |
| 57 | +<dt> |
| 58 | +<code>version: u64</code> |
| 59 | +</dt> |
| 60 | +<dd> |
| 61 | + |
| 62 | +</dd> |
| 63 | +</dl> |
| 64 | + |
| 65 | + |
| 66 | +</details> |
23 | 67 |
|
24 | 68 | <a name="@Constants_0"></a>
|
25 | 69 |
|
@@ -211,6 +255,37 @@ The object must have <code>store</code> to be shared outside of its module.
|
211 | 255 |
|
212 | 256 |
|
213 | 257 |
|
| 258 | +</details> |
| 259 | + |
| 260 | +<a name="0x2_transfer_receive"></a> |
| 261 | + |
| 262 | +## Function `receive` |
| 263 | + |
| 264 | +Given mutable (i.e., locked) access to the <code>parent</code> and a <code><a href="transfer.md#0x2_transfer_Receiving">Receiving</a></code> argument |
| 265 | +referencing an object of type <code>T</code> owned by <code>parent</code> use the <code>to_receive</code> |
| 266 | +argument to receive and return the referenced owned object of type <code>T</code>. |
| 267 | + |
| 268 | + |
| 269 | +<pre><code><b>public</b> <b>fun</b> <a href="transfer.md#0x2_transfer_receive">receive</a><T: key>(parent: &<b>mut</b> <a href="object.md#0x2_object_UID">object::UID</a>, to_receive: <a href="transfer.md#0x2_transfer_Receiving">transfer::Receiving</a><T>): T |
| 270 | +</code></pre> |
| 271 | + |
| 272 | + |
| 273 | + |
| 274 | +<details> |
| 275 | +<summary>Implementation</summary> |
| 276 | + |
| 277 | + |
| 278 | +<pre><code><b>public</b> <b>fun</b> <a href="transfer.md#0x2_transfer_receive">receive</a><T: key>(parent: &<b>mut</b> UID, to_receive: <a href="transfer.md#0x2_transfer_Receiving">Receiving</a><T>): T { |
| 279 | + <b>let</b> <a href="transfer.md#0x2_transfer_Receiving">Receiving</a> { |
| 280 | + id, |
| 281 | + version, |
| 282 | + } = to_receive; |
| 283 | + <a href="transfer.md#0x2_transfer_receive_impl">receive_impl</a>(<a href="object.md#0x2_object_uid_to_address">object::uid_to_address</a>(parent), id, version) |
| 284 | +} |
| 285 | +</code></pre> |
| 286 | + |
| 287 | + |
| 288 | + |
214 | 289 | </details>
|
215 | 290 |
|
216 | 291 | <a name="0x2_transfer_freeze_object_impl"></a>
|
@@ -326,4 +401,26 @@ The object must have <code>store</code> to be shared outside of its module.
|
326 | 401 |
|
327 | 402 |
|
328 | 403 |
|
| 404 | +</details> |
| 405 | + |
| 406 | +<a name="0x2_transfer_receive_impl"></a> |
| 407 | + |
| 408 | +## Function `receive_impl` |
| 409 | + |
| 410 | + |
| 411 | + |
| 412 | +<pre><code><b>fun</b> <a href="transfer.md#0x2_transfer_receive_impl">receive_impl</a><T: key>(parent: <b>address</b>, to_receive: <a href="object.md#0x2_object_ID">object::ID</a>, version: u64): T |
| 413 | +</code></pre> |
| 414 | + |
| 415 | + |
| 416 | + |
| 417 | +<details> |
| 418 | +<summary>Implementation</summary> |
| 419 | + |
| 420 | + |
| 421 | +<pre><code><b>native</b> <b>fun</b> <a href="transfer.md#0x2_transfer_receive_impl">receive_impl</a><T: key>(parent: <b>address</b>, to_receive: <a href="object.md#0x2_object_ID">object::ID</a>, version: u64): T; |
| 422 | +</code></pre> |
| 423 | + |
| 424 | + |
| 425 | + |
329 | 426 | </details>
|
0 commit comments