Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

Commit

Permalink
[framework] remove creation name from token
Browse files Browse the repository at this point in the history
feedback was that it was confusing
also planning on moving to guid token by default
  • Loading branch information
davidiw committed Apr 12, 2023
1 parent da5e7cc commit 7736873
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 66 deletions.
1 change: 0 additions & 1 deletion aptos-move/e2e-move-tests/src/tests/token_objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ struct Token {
collection_id: u64,
description: String,
name: String,
creation_name: Option<String>,
uri: String,
mutation_events: EventHandle,
}
Expand Down
42 changes: 0 additions & 42 deletions aptos-move/framework/aptos-token-objects/doc/token.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ TODO:
- [Function `creator`](#0x4_token_creator)
- [Function `collection`](#0x4_token_collection)
- [Function `collection_object`](#0x4_token_collection_object)
- [Function `creation_name`](#0x4_token_creation_name)
- [Function `description`](#0x4_token_description)
- [Function `name`](#0x4_token_name)
- [Function `uri`](#0x4_token_uri)
Expand Down Expand Up @@ -94,13 +93,6 @@ Represents the common fields to all tokens.
should be smaller than 128, characters, eg: "Aptos Animal #1234"
</dd>
<dt>
<code>creation_name: <a href="../../aptos-framework/../aptos-stdlib/../move-stdlib/doc/option.md#0x1_option_Option">option::Option</a>&lt;<a href="../../aptos-framework/../aptos-stdlib/../move-stdlib/doc/string.md#0x1_string_String">string::String</a>&gt;</code>
</dt>
<dd>
The creation name of the token. Since tokens are created with the name as part of the
object id generation.
</dd>
<dt>
<code>uri: <a href="../../aptos-framework/../aptos-stdlib/../move-stdlib/doc/string.md#0x1_string_String">string::String</a></code>
</dt>
<dd>
Expand Down Expand Up @@ -284,7 +276,6 @@ Creates a new token object and returns the ConstructorRef for additional special
collection_id: <a href="../../aptos-framework/../aptos-stdlib/../move-stdlib/doc/option.md#0x1_option_get_with_default">option::get_with_default</a>(&<b>mut</b> id, 0),
description,
name,
creation_name: <a href="../../aptos-framework/../aptos-stdlib/../move-stdlib/doc/option.md#0x1_option_none">option::none</a>(),
uri,
mutation_events: <a href="../../aptos-framework/doc/object.md#0x1_object_new_event_handle">object::new_event_handle</a>(&object_signer),
};
Expand Down Expand Up @@ -511,35 +502,6 @@ Extracts the tokens address from a BurnRef.



</details>

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

## Function `creation_name`



<pre><code><b>public</b> <b>fun</b> <a href="token.md#0x4_token_creation_name">creation_name</a>&lt;T: key&gt;(<a href="token.md#0x4_token">token</a>: <a href="../../aptos-framework/doc/object.md#0x1_object_Object">object::Object</a>&lt;T&gt;): <a href="../../aptos-framework/../aptos-stdlib/../move-stdlib/doc/string.md#0x1_string_String">string::String</a>
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="token.md#0x4_token_creation_name">creation_name</a>&lt;T: key&gt;(<a href="token.md#0x4_token">token</a>: Object&lt;T&gt;): String <b>acquires</b> <a href="token.md#0x4_token_Token">Token</a> {
<b>let</b> <a href="token.md#0x4_token">token</a> = borrow(&<a href="token.md#0x4_token">token</a>);
<b>if</b> (<a href="../../aptos-framework/../aptos-stdlib/../move-stdlib/doc/option.md#0x1_option_is_some">option::is_some</a>(&<a href="token.md#0x4_token">token</a>.creation_name)) {
*<a href="../../aptos-framework/../aptos-stdlib/../move-stdlib/doc/option.md#0x1_option_borrow">option::borrow</a>(&<a href="token.md#0x4_token">token</a>.creation_name)
} <b>else</b> {
<a href="token.md#0x4_token">token</a>.name
}
}
</code></pre>



</details>

<a name="0x4_token_description"></a>
Expand Down Expand Up @@ -682,7 +644,6 @@ Extracts the tokens address from a BurnRef.
collection_id,
description: _,
name: _,
creation_name: _,
uri: _,
mutation_events,
} = <b>move_from</b>&lt;<a href="token.md#0x4_token_Token">Token</a>&gt;(addr);
Expand Down Expand Up @@ -742,9 +703,6 @@ Extracts the tokens address from a BurnRef.

<pre><code><b>public</b> <b>fun</b> <a href="token.md#0x4_token_set_name">set_name</a>(mutator_ref: &<a href="token.md#0x4_token_MutatorRef">MutatorRef</a>, name: String) <b>acquires</b> <a href="token.md#0x4_token_Token">Token</a> {
<b>let</b> <a href="token.md#0x4_token">token</a> = borrow_mut(mutator_ref);
<b>if</b> (<a href="../../aptos-framework/../aptos-stdlib/../move-stdlib/doc/option.md#0x1_option_is_none">option::is_none</a>(&<a href="token.md#0x4_token">token</a>.creation_name)) {
<a href="../../aptos-framework/../aptos-stdlib/../move-stdlib/doc/option.md#0x1_option_fill">option::fill</a>(&<b>mut</b> <a href="token.md#0x4_token">token</a>.creation_name, <a href="token.md#0x4_token">token</a>.name)
};
<a href="token.md#0x4_token">token</a>.name = name;
<a href="../../aptos-framework/doc/event.md#0x1_event_emit_event">event::emit_event</a>(
&<b>mut</b> <a href="token.md#0x4_token">token</a>.mutation_events,
Expand Down
23 changes: 0 additions & 23 deletions aptos-move/framework/aptos-token-objects/sources/token.move
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ module aptos_token_objects::token {
/// The name of the token, which should be unique within the collection; the length of name
/// should be smaller than 128, characters, eg: "Aptos Animal #1234"
name: String,
/// The creation name of the token. Since tokens are created with the name as part of the
/// object id generation.
creation_name: Option<String>,
/// The Uniform Resource Identifier (uri) pointing to the JSON file stored in off-chain
/// storage; the URL length will likely need a maximum any suggestions?
uri: String,
Expand Down Expand Up @@ -91,7 +88,6 @@ module aptos_token_objects::token {
collection_id: option::get_with_default(&mut id, 0),
description,
name,
creation_name: option::none(),
uri,
mutation_events: object::new_event_handle(&object_signer),
};
Expand Down Expand Up @@ -169,16 +165,6 @@ module aptos_token_objects::token {
borrow(&token).collection
}

#[view]
public fun creation_name<T: key>(token: Object<T>): String acquires Token {
let token = borrow(&token);
if (option::is_some(&token.creation_name)) {
*option::borrow(&token.creation_name)
} else {
token.name
}
}

#[view]
public fun description<T: key>(token: Object<T>): String acquires Token {
borrow(&token).description
Expand Down Expand Up @@ -238,7 +224,6 @@ module aptos_token_objects::token {
collection_id,
description: _,
name: _,
creation_name: _,
uri: _,
mutation_events,
} = move_from<Token>(addr);
Expand All @@ -258,9 +243,6 @@ module aptos_token_objects::token {

public fun set_name(mutator_ref: &MutatorRef, name: String) acquires Token {
let token = borrow_mut(mutator_ref);
if (option::is_none(&token.creation_name)) {
option::fill(&mut token.creation_name, token.name)
};
token.name = name;
event::emit_event(
&mut token.mutation_events,
Expand Down Expand Up @@ -406,13 +388,8 @@ module aptos_token_objects::token {

let name = string::utf8(b"no fail");
assert!(name != name(token), 0);
{
let token = borrow_global<Token>(object::object_address(&token));
assert!(option::is_none(&token.creation_name), 1);
};
set_name(&mutator_ref, *&name);
assert!(name == name(token), 2);
assert!(token_name == creation_name(token), 3);
}

#[test(creator = @0x123)]
Expand Down

0 comments on commit 7736873

Please sign in to comment.