Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor fungible assets #7379

Merged
merged 16 commits into from
Apr 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
955 changes: 666 additions & 289 deletions aptos-move/framework/aptos-framework/doc/fungible_asset.md

Large diffs are not rendered by default.

520 changes: 0 additions & 520 deletions aptos-move/framework/aptos-framework/doc/fungible_store.md

This file was deleted.

This file was deleted.

20 changes: 10 additions & 10 deletions aptos-move/framework/aptos-framework/doc/multisig_account.md
Original file line number Diff line number Diff line change
Expand Up @@ -731,16 +731,6 @@ Event emitted when a transaction's metadata is updated.
## Constants


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

Account executing this operation is not an owner of the multisig account.


<pre><code><b>const</b> <a href="multisig_account.md#0x1_multisig_account_ENOT_OWNER">ENOT_OWNER</a>: u64 = 2003;
</code></pre>



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

The salt used to create a resource account during multisig account creation.
Expand Down Expand Up @@ -853,6 +843,16 @@ Transaction has not received enough rejections to be officially rejected.



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

Account executing this operation is not an owner of the multisig account.


<pre><code><b>const</b> <a href="multisig_account.md#0x1_multisig_account_ENOT_OWNER">ENOT_OWNER</a>: u64 = 2003;
</code></pre>



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

The number of metadata keys and values don't match.
Expand Down
156 changes: 156 additions & 0 deletions aptos-move/framework/aptos-framework/doc/object.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,25 @@ make it so that a reference to a global object can be returned from a function.
- [Struct `ExtendRef`](#0x1_object_ExtendRef)
- [Struct `TransferRef`](#0x1_object_TransferRef)
- [Struct `LinearTransferRef`](#0x1_object_LinearTransferRef)
- [Struct `DeriveRef`](#0x1_object_DeriveRef)
- [Struct `TransferEvent`](#0x1_object_TransferEvent)
- [Constants](#@Constants_0)
- [Function `address_to_object`](#0x1_object_address_to_object)
- [Function `create_object_address`](#0x1_object_create_object_address)
- [Function `create_derived_object_address`](#0x1_object_create_derived_object_address)
- [Function `exists_at`](#0x1_object_exists_at)
- [Function `object_address`](#0x1_object_object_address)
- [Function `convert`](#0x1_object_convert)
- [Function `create_named_object`](#0x1_object_create_named_object)
- [Function `create_derived_object`](#0x1_object_create_derived_object)
- [Function `create_object_from_account`](#0x1_object_create_object_from_account)
- [Function `create_object_from_object`](#0x1_object_create_object_from_object)
- [Function `create_object_from_guid`](#0x1_object_create_object_from_guid)
- [Function `create_object_internal`](#0x1_object_create_object_internal)
- [Function `generate_delete_ref`](#0x1_object_generate_delete_ref)
- [Function `generate_extend_ref`](#0x1_object_generate_extend_ref)
- [Function `generate_transfer_ref`](#0x1_object_generate_transfer_ref)
- [Function `generate_derive_ref`](#0x1_object_generate_derive_ref)
- [Function `generate_signer`](#0x1_object_generate_signer)
- [Function `address_from_constructor_ref`](#0x1_object_address_from_constructor_ref)
- [Function `object_from_constructor_ref`](#0x1_object_object_from_constructor_ref)
Expand Down Expand Up @@ -342,6 +347,34 @@ the current owner.
</dl>


</details>

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

## Struct `DeriveRef`

Used to create derived objects from a given objects.


<pre><code><b>struct</b> <a href="object.md#0x1_object_DeriveRef">DeriveRef</a> <b>has</b> drop, store
</code></pre>



<details>
<summary>Fields</summary>


<dl>
<dt>
<code>self: <b>address</b></code>
</dt>
<dd>

</dd>
</dl>


</details>

<a name="0x1_object_TransferEvent"></a>
Expand Down Expand Up @@ -480,6 +513,23 @@ nesting, but any checks such as transfer will only be evaluated this deep.



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

Scheme identifier used to generate an object's address <code>obj_addr</code> as derived from another object.
The object's address is generated as:
```
obj_addr = sha3_256(account addr | derived from object's address | 0xFC)
```

This 0xFC constant serves as a domain separation tag to prevent existing authentication key and resource account
derivation to produce an object address.


<pre><code><b>const</b> <a href="object.md#0x1_object_OBJECT_DERIVED_SCHEME">OBJECT_DERIVED_SCHEME</a>: u8 = 252;
</code></pre>



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

Scheme identifier used to generate an object's address <code>obj_addr</code> via a fresh GUID generated by the creator at
Expand Down Expand Up @@ -565,6 +615,34 @@ Derives an object address from source material: sha3_256([creator address | seed



</details>

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

## Function `create_derived_object_address`

Derives an object address from the source address and an object: sha3_256([source | object addr | 0xFC]).


<pre><code><b>public</b> <b>fun</b> <a href="object.md#0x1_object_create_derived_object_address">create_derived_object_address</a>(source: <b>address</b>, derive_from: <b>address</b>): <b>address</b>
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="object.md#0x1_object_create_derived_object_address">create_derived_object_address</a>(source: <b>address</b>, derive_from: <b>address</b>): <b>address</b> {
<b>let</b> bytes = <a href="../../aptos-stdlib/../move-stdlib/doc/bcs.md#0x1_bcs_to_bytes">bcs::to_bytes</a>(&source);
<a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector_append">vector::append</a>(&<b>mut</b> bytes, <a href="../../aptos-stdlib/../move-stdlib/doc/bcs.md#0x1_bcs_to_bytes">bcs::to_bytes</a>(&derive_from));
<a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector_push_back">vector::push_back</a>(&<b>mut</b> bytes, <a href="object.md#0x1_object_OBJECT_DERIVED_SCHEME">OBJECT_DERIVED_SCHEME</a>);
<a href="../../aptos-stdlib/doc/from_bcs.md#0x1_from_bcs_to_address">from_bcs::to_address</a>(<a href="../../aptos-stdlib/doc/hash.md#0x1_hash_sha3_256">hash::sha3_256</a>(bytes))
}
</code></pre>



</details>

<a name="0x1_object_exists_at"></a>
Expand Down Expand Up @@ -612,6 +690,31 @@ Returns the address of within an ObjectId.



</details>

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

## Function `convert`

Convert Object<X> to Object<Y>.


<pre><code><b>public</b> <b>fun</b> <a href="object.md#0x1_object_convert">convert</a>&lt;X: key, Y: key&gt;(<a href="object.md#0x1_object">object</a>: <a href="object.md#0x1_object_Object">object::Object</a>&lt;X&gt;): <a href="object.md#0x1_object_Object">object::Object</a>&lt;Y&gt;
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="object.md#0x1_object_convert">convert</a>&lt;X: key, Y: key&gt;(<a href="object.md#0x1_object">object</a>: <a href="object.md#0x1_object_Object">Object</a>&lt;X&gt;): <a href="object.md#0x1_object_Object">Object</a>&lt;Y&gt; {
<a href="object.md#0x1_object_address_to_object">address_to_object</a>&lt;Y&gt;(<a href="object.md#0x1_object">object</a>.inner)
}
</code></pre>



</details>

<a name="0x1_object_create_named_object"></a>
Expand Down Expand Up @@ -640,6 +743,34 @@ by knowing the user generated seed used to create them. Named objects cannot be



</details>

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

## Function `create_derived_object`

Create a new object whose address is derived based on the creator account address and another object.
Derivde objects, similar to named objects, cannot be deleted.


<pre><code><b>public</b> <b>fun</b> <a href="object.md#0x1_object_create_derived_object">create_derived_object</a>(creator: &<a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>, derive_ref: &<a href="object.md#0x1_object_DeriveRef">object::DeriveRef</a>): <a href="object.md#0x1_object_ConstructorRef">object::ConstructorRef</a>
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="object.md#0x1_object_create_derived_object">create_derived_object</a>(creator: &<a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>, derive_ref: &<a href="object.md#0x1_object_DeriveRef">DeriveRef</a>): <a href="object.md#0x1_object_ConstructorRef">ConstructorRef</a> {
<b>let</b> creator_address = <a href="../../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer_address_of">signer::address_of</a>(creator);
<b>let</b> obj_addr = <a href="object.md#0x1_object_create_derived_object_address">create_derived_object_address</a>(creator_address, derive_ref.self);
<a href="object.md#0x1_object_create_object_internal">create_object_internal</a>(creator_address, obj_addr, <b>false</b>)
}
</code></pre>



</details>

<a name="0x1_object_create_object_from_account"></a>
Expand Down Expand Up @@ -838,6 +969,31 @@ Generates the TransferRef, which can be used to manage object transfers.



</details>

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

## Function `generate_derive_ref`

Generates the DeriveRef, which can be used to create determnistic derived objects from the current object.


<pre><code><b>public</b> <b>fun</b> <a href="object.md#0x1_object_generate_derive_ref">generate_derive_ref</a>(ref: &<a href="object.md#0x1_object_ConstructorRef">object::ConstructorRef</a>): <a href="object.md#0x1_object_DeriveRef">object::DeriveRef</a>
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="object.md#0x1_object_generate_derive_ref">generate_derive_ref</a>(ref: &<a href="object.md#0x1_object_ConstructorRef">ConstructorRef</a>): <a href="object.md#0x1_object_DeriveRef">DeriveRef</a> {
<a href="object.md#0x1_object_DeriveRef">DeriveRef</a> { self: ref.self }
}
</code></pre>



</details>

<a name="0x1_object_generate_signer"></a>
Expand Down
3 changes: 1 addition & 2 deletions aptos-move/framework/aptos-framework/doc/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,15 @@ This is the reference documentation of the Aptos framework.
- [`0x1::delegation_pool`](delegation_pool.md#0x1_delegation_pool)
- [`0x1::event`](event.md#0x1_event)
- [`0x1::fungible_asset`](fungible_asset.md#0x1_fungible_asset)
- [`0x1::fungible_store`](fungible_store.md#0x1_fungible_store)
- [`0x1::gas_schedule`](gas_schedule.md#0x1_gas_schedule)
- [`0x1::genesis`](genesis.md#0x1_genesis)
- [`0x1::governance_proposal`](governance_proposal.md#0x1_governance_proposal)
- [`0x1::guid`](guid.md#0x1_guid)
- [`0x1::managed_coin`](managed_coin.md#0x1_managed_coin)
- [`0x1::managed_fungible_metadata`](managed_fungible_metadata.md#0x1_managed_fungible_metadata)
- [`0x1::multisig_account`](multisig_account.md#0x1_multisig_account)
- [`0x1::object`](object.md#0x1_object)
- [`0x1::optional_aggregator`](optional_aggregator.md#0x1_optional_aggregator)
- [`0x1::primary_wallet`](primary_wallet.md#0x1_primary_wallet)
- [`0x1::reconfiguration`](reconfiguration.md#0x1_reconfiguration)
- [`0x1::resource_account`](resource_account.md#0x1_resource_account)
- [`0x1::stake`](stake.md#0x1_stake)
Expand Down
Loading