Skip to content

Commit

Permalink
[framework] Propertymap proper errors and renaming entry function param
Browse files Browse the repository at this point in the history
  • Loading branch information
davidiw committed Mar 23, 2023
1 parent ab95c83 commit bc68f50
Show file tree
Hide file tree
Showing 4 changed files with 696 additions and 331 deletions.
12 changes: 6 additions & 6 deletions aptos-move/framework/aptos-token-objects/doc/aptos_token.md
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,7 @@ With an existing collection, directly mint a soul bound token into the recipient



<pre><code>entry <b>fun</b> <a href="aptos_token.md#0x4_aptos_token_add_property_call">add_property_call</a>(creator: &<a href="../../aptos-framework/../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>, <a href="collection.md#0x4_collection">collection</a>: <a href="../../aptos-framework/../aptos-stdlib/../move-stdlib/doc/string.md#0x1_string_String">string::String</a>, name: <a href="../../aptos-framework/../aptos-stdlib/../move-stdlib/doc/string.md#0x1_string_String">string::String</a>, key: <a href="../../aptos-framework/../aptos-stdlib/../move-stdlib/doc/string.md#0x1_string_String">string::String</a>, type: <a href="../../aptos-framework/../aptos-stdlib/../move-stdlib/doc/string.md#0x1_string_String">string::String</a>, value: <a href="../../aptos-framework/../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt;)
<pre><code>entry <b>fun</b> <a href="aptos_token.md#0x4_aptos_token_add_property_call">add_property_call</a>(creator: &<a href="../../aptos-framework/../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>, <a href="collection.md#0x4_collection">collection</a>: <a href="../../aptos-framework/../aptos-stdlib/../move-stdlib/doc/string.md#0x1_string_String">string::String</a>, name: <a href="../../aptos-framework/../aptos-stdlib/../move-stdlib/doc/string.md#0x1_string_String">string::String</a>, key: <a href="../../aptos-framework/../aptos-stdlib/../move-stdlib/doc/string.md#0x1_string_String">string::String</a>, type_: <a href="../../aptos-framework/../aptos-stdlib/../move-stdlib/doc/string.md#0x1_string_String">string::String</a>, value: <a href="../../aptos-framework/../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt;)
</code></pre>


Expand All @@ -1231,11 +1231,11 @@ With an existing collection, directly mint a soul bound token into the recipient
<a href="collection.md#0x4_collection">collection</a>: String,
name: String,
key: String,
type: String,
type_: String,
value: <a href="../../aptos-framework/../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
) <b>acquires</b> <a href="aptos_token.md#0x4_aptos_token_AptosCollection">AptosCollection</a>, <a href="aptos_token.md#0x4_aptos_token_AptosToken">AptosToken</a> {
<b>let</b> <a href="token.md#0x4_token">token</a> = token_object(creator, &<a href="collection.md#0x4_collection">collection</a>, &name);
<a href="aptos_token.md#0x4_aptos_token_add_property">add_property</a>(creator, <a href="token.md#0x4_token">token</a>, key, type, value);
<a href="aptos_token.md#0x4_aptos_token_add_property">add_property</a>(creator, <a href="token.md#0x4_token">token</a>, key, type_, value);
}
</code></pre>

Expand Down Expand Up @@ -1310,7 +1310,7 @@ With an existing collection, directly mint a soul bound token into the recipient



<pre><code>entry <b>fun</b> <a href="aptos_token.md#0x4_aptos_token_update_property_call">update_property_call</a>(creator: &<a href="../../aptos-framework/../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>, <a href="collection.md#0x4_collection">collection</a>: <a href="../../aptos-framework/../aptos-stdlib/../move-stdlib/doc/string.md#0x1_string_String">string::String</a>, name: <a href="../../aptos-framework/../aptos-stdlib/../move-stdlib/doc/string.md#0x1_string_String">string::String</a>, key: <a href="../../aptos-framework/../aptos-stdlib/../move-stdlib/doc/string.md#0x1_string_String">string::String</a>, type: <a href="../../aptos-framework/../aptos-stdlib/../move-stdlib/doc/string.md#0x1_string_String">string::String</a>, value: <a href="../../aptos-framework/../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt;)
<pre><code>entry <b>fun</b> <a href="aptos_token.md#0x4_aptos_token_update_property_call">update_property_call</a>(creator: &<a href="../../aptos-framework/../aptos-stdlib/../move-stdlib/doc/signer.md#0x1_signer">signer</a>, <a href="collection.md#0x4_collection">collection</a>: <a href="../../aptos-framework/../aptos-stdlib/../move-stdlib/doc/string.md#0x1_string_String">string::String</a>, name: <a href="../../aptos-framework/../aptos-stdlib/../move-stdlib/doc/string.md#0x1_string_String">string::String</a>, key: <a href="../../aptos-framework/../aptos-stdlib/../move-stdlib/doc/string.md#0x1_string_String">string::String</a>, type_: <a href="../../aptos-framework/../aptos-stdlib/../move-stdlib/doc/string.md#0x1_string_String">string::String</a>, value: <a href="../../aptos-framework/../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt;)
</code></pre>


Expand All @@ -1324,11 +1324,11 @@ With an existing collection, directly mint a soul bound token into the recipient
<a href="collection.md#0x4_collection">collection</a>: String,
name: String,
key: String,
type: String,
type_: String,
value: <a href="../../aptos-framework/../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector">vector</a>&lt;u8&gt;,
) <b>acquires</b> <a href="aptos_token.md#0x4_aptos_token_AptosCollection">AptosCollection</a>, <a href="aptos_token.md#0x4_aptos_token_AptosToken">AptosToken</a> {
<b>let</b> <a href="token.md#0x4_token">token</a> = token_object(creator, &<a href="collection.md#0x4_collection">collection</a>, &name);
<a href="aptos_token.md#0x4_aptos_token_update_property">update_property</a>(creator, <a href="token.md#0x4_token">token</a>, &key, type, value);
<a href="aptos_token.md#0x4_aptos_token_update_property">update_property</a>(creator, <a href="token.md#0x4_token">token</a>, &key, type_, value);
}
</code></pre>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -511,11 +511,11 @@ module aptos_token_objects::aptos_token {
collection: String,
name: String,
key: String,
type: String,
type_: String,
value: vector<u8>,
) acquires AptosCollection, AptosToken {
let token = token_object(creator, &collection, &name);
add_property(creator, token, key, type, value);
add_property(creator, token, key, type_, value);
}

entry fun add_typed_property_call<T: drop>(
Expand Down Expand Up @@ -544,11 +544,11 @@ module aptos_token_objects::aptos_token {
collection: String,
name: String,
key: String,
type: String,
type_: String,
value: vector<u8>,
) acquires AptosCollection, AptosToken {
let token = token_object(creator, &collection, &name);
update_property(creator, token, &key, type, value);
update_property(creator, token, &key, type_, value);
}

entry fun update_typed_property_call<T: drop>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ module aptos_token_objects::property_map {
let (type, value) = read(object, key);
assert!(
type == type_info::type_name<V>(),
error::invalid_argument(ETYPE_INVALID),
error::invalid_argument(ETYPE_MISMATCH),
);
value
}
Expand Down Expand Up @@ -585,7 +585,7 @@ module aptos_token_objects::property_map {
}

#[test(creator = @0x123)]
#[expected_failure(abort_code = 0x10008, location = Self)]
#[expected_failure(abort_code = 0x10005, location = Self)]
fun test_invalid_read(creator: &signer) acquires PropertyMap {
let constructor_ref = object::create_named_object(creator, b"");
let object = object::object_from_constructor_ref<object::ObjectCore>(&constructor_ref);
Expand Down
Loading

0 comments on commit bc68f50

Please sign in to comment.