Skip to content

Commit

Permalink
update to v0.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ALPAC-4 committed Oct 22, 2024
1 parent 67caa58 commit d323524
Show file tree
Hide file tree
Showing 124 changed files with 6,968 additions and 2,514 deletions.
12 changes: 2 additions & 10 deletions initia_stdlib/doc/account.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,7 @@ as both cannot have a pubkey, there is no way to use the account externally.
<a href="../../move_nursery/../move_stdlib/doc/error.md#0x1_error_already_exists">error::already_exists</a>(<a href="account.md#0x1_account_EACCOUNT_ALREADY_EXISTS">EACCOUNT_ALREADY_EXISTS</a>)
);

<a href="account.md#0x1_account_request_create_account">request_create_account</a>(
addr,
account_number,
<a href="account.md#0x1_account_ACCOUNT_TYPE_TABLE">ACCOUNT_TYPE_TABLE</a>
)
<a href="account.md#0x1_account_request_create_account">request_create_account</a>(addr, account_number, <a href="account.md#0x1_account_ACCOUNT_TYPE_TABLE">ACCOUNT_TYPE_TABLE</a>)
}
</code></pre>

Expand All @@ -242,11 +238,7 @@ as both cannot have a pubkey, there is no way to use the account externally.

// base <a href="account.md#0x1_account">account</a> <b>with</b> sequence 0 is considered <b>as</b> not created.
<b>if</b> (!found || (account_type == <a href="account.md#0x1_account_ACCOUNT_TYPE_BASE">ACCOUNT_TYPE_BASE</a> && sequence == 0)) {
<a href="account.md#0x1_account_request_create_account">request_create_account</a>(
addr,
account_number,
<a href="account.md#0x1_account_ACCOUNT_TYPE_OBJECT">ACCOUNT_TYPE_OBJECT</a>
)
<a href="account.md#0x1_account_request_create_account">request_create_account</a>(addr, account_number, <a href="account.md#0x1_account_ACCOUNT_TYPE_OBJECT">ACCOUNT_TYPE_OBJECT</a>)
} <b>else</b> {
// When an Object is deleted, the ObjectAccount in CosmosSDK is designed
// not <b>to</b> be deleted in order <b>to</b> prevent unexpected issues. Therefore,
Expand Down
6 changes: 4 additions & 2 deletions initia_stdlib/doc/bigdecimal.md
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,8 @@ Create a BigDecimal from a scaled BigUint le_bytes value.

<pre><code><b>public</b> <b>fun</b> <a href="bigdecimal.md#0x1_bigdecimal_from_ratio">from_ratio</a>(numerator: BigUint, denominator: BigUint): <a href="bigdecimal.md#0x1_bigdecimal_BigDecimal">BigDecimal</a> {
<b>assert</b>!(
!<a href="biguint.md#0x1_biguint_is_zero">biguint::is_zero</a>(denominator), <a href="../../move_nursery/../move_stdlib/doc/error.md#0x1_error_invalid_argument">error::invalid_argument</a>(<a href="bigdecimal.md#0x1_bigdecimal_EDIVISION_BY_ZERO">EDIVISION_BY_ZERO</a>)
!<a href="biguint.md#0x1_biguint_is_zero">biguint::is_zero</a>(denominator),
<a href="../../move_nursery/../move_stdlib/doc/error.md#0x1_error_invalid_argument">error::invalid_argument</a>(<a href="bigdecimal.md#0x1_bigdecimal_EDIVISION_BY_ZERO">EDIVISION_BY_ZERO</a>)
);

<b>let</b> numerator = <a href="biguint.md#0x1_biguint_mul">biguint::mul</a>(numerator, <a href="bigdecimal.md#0x1_bigdecimal_f">f</a>());
Expand Down Expand Up @@ -1093,7 +1094,8 @@ Create a BigDecimal from a scaled BigUint le_bytes value.

<pre><code><b>public</b> <b>fun</b> <a href="bigdecimal.md#0x1_bigdecimal_div">div</a>(num1: <a href="bigdecimal.md#0x1_bigdecimal_BigDecimal">BigDecimal</a>, num2: <a href="bigdecimal.md#0x1_bigdecimal_BigDecimal">BigDecimal</a>): <a href="bigdecimal.md#0x1_bigdecimal_BigDecimal">BigDecimal</a> {
<b>assert</b>!(
!<a href="biguint.md#0x1_biguint_is_zero">biguint::is_zero</a>(num2.scaled), <a href="../../move_nursery/../move_stdlib/doc/error.md#0x1_error_invalid_argument">error::invalid_argument</a>(<a href="bigdecimal.md#0x1_bigdecimal_EDIVISION_BY_ZERO">EDIVISION_BY_ZERO</a>)
!<a href="biguint.md#0x1_biguint_is_zero">biguint::is_zero</a>(num2.scaled),
<a href="../../move_nursery/../move_stdlib/doc/error.md#0x1_error_invalid_argument">error::invalid_argument</a>(<a href="bigdecimal.md#0x1_bigdecimal_EDIVISION_BY_ZERO">EDIVISION_BY_ZERO</a>)
);

<a href="bigdecimal.md#0x1_bigdecimal_BigDecimal">BigDecimal</a> {
Expand Down
39 changes: 14 additions & 25 deletions initia_stdlib/doc/code.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ strengthened but not weakened.
<a href="../../move_nursery/../move_stdlib/doc/signer.md#0x1_signer_address_of">signer::address_of</a>(chain) == @initia_std,
<a href="../../move_nursery/../move_stdlib/doc/error.md#0x1_error_permission_denied">error::permission_denied</a>(<a href="code.md#0x1_code_EINVALID_CHAIN_OPERATOR">EINVALID_CHAIN_OPERATOR</a>)
);
<a href="code.md#0x1_code_assert_no_duplication">assert_no_duplication</a>(&module_ids);

<b>let</b> metadata_table = <a href="table.md#0x1_table_new">table::new</a>&lt;String, <a href="code.md#0x1_code_ModuleMetadata">ModuleMetadata</a>&gt;();
<a href="../../move_nursery/../move_stdlib/doc/vector.md#0x1_vector_for_each_ref">vector::for_each_ref</a>(
Expand Down Expand Up @@ -433,7 +434,10 @@ strengthened but not weakened.

<b>let</b> registry = <b>borrow_global_mut</b>&lt;<a href="code.md#0x1_code_MetadataStore">MetadataStore</a>&gt;(code_object_addr);
<b>let</b> iter = <a href="table.md#0x1_table_iter_mut">table::iter_mut</a>(
&<b>mut</b> registry.metadata, <a href="../../move_nursery/../move_stdlib/doc/option.md#0x1_option_none">option::none</a>(), <a href="../../move_nursery/../move_stdlib/doc/option.md#0x1_option_none">option::none</a>(), 1
&<b>mut</b> registry.metadata,
<a href="../../move_nursery/../move_stdlib/doc/option.md#0x1_option_none">option::none</a>(),
<a href="../../move_nursery/../move_stdlib/doc/option.md#0x1_option_none">option::none</a>(),
1
);
<b>loop</b> {
<b>if</b> (!<a href="table.md#0x1_table_prepare_mut">table::prepare_mut</a>(iter)) { <b>break</b> };
Expand Down Expand Up @@ -473,23 +477,7 @@ package.
<a href="../../move_nursery/../move_stdlib/doc/vector.md#0x1_vector_length">vector::length</a>(&<a href="code.md#0x1_code">code</a>) == <a href="../../move_nursery/../move_stdlib/doc/vector.md#0x1_vector_length">vector::length</a>(&module_ids),
<a href="../../move_nursery/../move_stdlib/doc/error.md#0x1_error_invalid_argument">error::invalid_argument</a>(<a href="code.md#0x1_code_EINVALID_ARGUMENTS">EINVALID_ARGUMENTS</a>)
);

// duplication check
<b>let</b> module_ids_set = <a href="simple_map.md#0x1_simple_map_create">simple_map::create</a>&lt;String, bool&gt;();
<a href="../../move_nursery/../move_stdlib/doc/vector.md#0x1_vector_for_each_ref">vector::for_each_ref</a>(
&module_ids,
|module_id| {
<b>assert</b>!(
!<a href="simple_map.md#0x1_simple_map_contains_key">simple_map::contains_key</a>(&module_ids_set, module_id),
<a href="../../move_nursery/../move_stdlib/doc/error.md#0x1_error_invalid_argument">error::invalid_argument</a>(<a href="code.md#0x1_code_EDUPLICATE_MODULE_ID">EDUPLICATE_MODULE_ID</a>)
);
<a href="simple_map.md#0x1_simple_map_add">simple_map::add</a>(
&<b>mut</b> module_ids_set,
*module_id,
<b>true</b>
);
}
);
<a href="code.md#0x1_code_assert_no_duplication">assert_no_duplication</a>(&module_ids);

// Check whether arbitrary publish is allowed or not.
<b>let</b> module_store = <b>borrow_global_mut</b>&lt;<a href="code.md#0x1_code_ModuleStore">ModuleStore</a>&gt;(@initia_std);
Expand All @@ -503,13 +491,11 @@ package.
<a href="code.md#0x1_code_assert_allowed">assert_allowed</a>(&module_store.allowed_publishers, addr);

<b>if</b> (!<b>exists</b>&lt;<a href="code.md#0x1_code_MetadataStore">MetadataStore</a>&gt;(addr)) {
<b>move_to</b>&lt;<a href="code.md#0x1_code_MetadataStore">MetadataStore</a>&gt;(
owner,
<a href="code.md#0x1_code_MetadataStore">MetadataStore</a> { metadata: <a href="table.md#0x1_table_new">table::new</a>() }
);
<b>move_to</b>&lt;<a href="code.md#0x1_code_MetadataStore">MetadataStore</a>&gt;(owner, <a href="code.md#0x1_code_MetadataStore">MetadataStore</a> { metadata: <a href="table.md#0x1_table_new">table::new</a>() });
};

// Check upgradability
<b>let</b> new_modules = 0;
<b>let</b> metadata_table = &<b>mut</b> <b>borrow_global_mut</b>&lt;<a href="code.md#0x1_code_MetadataStore">MetadataStore</a>&gt;(addr).metadata;
<a href="../../move_nursery/../move_stdlib/doc/vector.md#0x1_vector_for_each_ref">vector::for_each_ref</a>(
&module_ids,
Expand All @@ -525,8 +511,7 @@ package.
);
<b>assert</b>!(
<a href="code.md#0x1_code_can_change_upgrade_policy_to">can_change_upgrade_policy_to</a>(
metadata.upgrade_policy,
upgrade_policy
metadata.upgrade_policy, upgrade_policy
),
<a href="../../move_nursery/../move_stdlib/doc/error.md#0x1_error_invalid_argument">error::invalid_argument</a>(<a href="code.md#0x1_code_EUPGRADE_WEAKER_POLICY">EUPGRADE_WEAKER_POLICY</a>)
);
Expand All @@ -538,6 +523,7 @@ package.
*module_id,
<a href="code.md#0x1_code_ModuleMetadata">ModuleMetadata</a> { upgrade_policy }
);
new_modules = new_modules + 1;
};

<a href="event.md#0x1_event_emit">event::emit</a>(
Expand All @@ -546,8 +532,11 @@ package.
}
);

<b>if</b> (new_modules &gt; 0) {
<a href="code.md#0x1_code_increase_total_modules">increase_total_modules</a>(new_modules)
};

// Request publish
<a href="code.md#0x1_code_increase_total_modules">increase_total_modules</a>(<a href="../../move_nursery/../move_stdlib/doc/vector.md#0x1_vector_length">vector::length</a>(&module_ids));
<a href="code.md#0x1_code_request_publish">request_publish</a>(addr, module_ids, <a href="code.md#0x1_code">code</a>)
}
</code></pre>
42 changes: 28 additions & 14 deletions initia_stdlib/doc/coin.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ TODO - make is_module_account or some blacklist from freeze.
- [Struct `MintCapability`](#0x1_coin_MintCapability)
- [Struct `BurnCapability`](#0x1_coin_BurnCapability)
- [Struct `FreezeCapability`](#0x1_coin_FreezeCapability)
- [Struct `Coin`](#0x1_coin_Coin)
- [Constants](#@Constants_0)
- [Function `sudo_transfer`](#0x1_coin_sudo_transfer)
- [Function `sudo_deposit`](#0x1_coin_sudo_deposit)
Expand Down Expand Up @@ -188,6 +189,30 @@ TODO - make is_module_account or some blacklist from freeze.
</dl>


<a id="0x1_coin_Coin"></a>

## Struct `Coin`



<pre><code><b>struct</b> <a href="coin.md#0x1_coin_Coin">Coin</a>&lt;CoinType&gt;
</code></pre>



##### Fields


<dl>
<dt>
<code>dummy_field: bool</code>
</dt>
<dd>

</dd>
</dl>


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

## Constants
Expand Down Expand Up @@ -339,10 +364,7 @@ Only fungible asset metadata owner can make changes.
): (<a href="coin.md#0x1_coin_MintCapability">MintCapability</a>, <a href="coin.md#0x1_coin_BurnCapability">BurnCapability</a>, <a href="coin.md#0x1_coin_FreezeCapability">FreezeCapability</a>, ExtendRef) {
// create <a href="object.md#0x1_object">object</a> for fungible asset metadata
<b>let</b> constructor_ref =
&<a href="object.md#0x1_object_create_named_object">object::create_named_object</a>(
creator,
*<a href="../../move_nursery/../move_stdlib/doc/string.md#0x1_string_bytes">string::bytes</a>(&symbol)
);
&<a href="object.md#0x1_object_create_named_object">object::create_named_object</a>(creator, *<a href="../../move_nursery/../move_stdlib/doc/string.md#0x1_string_bytes">string::bytes</a>(&symbol));

<a href="primary_fungible_store.md#0x1_primary_fungible_store_create_primary_store_enabled_fungible_asset">primary_fungible_store::create_primary_store_enabled_fungible_asset</a>(
constructor_ref,
Expand Down Expand Up @@ -571,11 +593,7 @@ Freeze the primary store of an account.
);
<b>let</b> refs = <b>borrow_global</b>&lt;<a href="coin.md#0x1_coin_ManagingRefs">ManagingRefs</a>&gt;(metadata_addr);

<a href="primary_fungible_store.md#0x1_primary_fungible_store_set_frozen_flag">primary_fungible_store::set_frozen_flag</a>(
&refs.transfer_ref,
account_addr,
<b>true</b>
)
<a href="primary_fungible_store.md#0x1_primary_fungible_store_set_frozen_flag">primary_fungible_store::set_frozen_flag</a>(&refs.transfer_ref, account_addr, <b>true</b>)
}
</code></pre>

Expand Down Expand Up @@ -608,11 +626,7 @@ Unfreeze the primary store of an account.
);
<b>let</b> refs = <b>borrow_global</b>&lt;<a href="coin.md#0x1_coin_ManagingRefs">ManagingRefs</a>&gt;(metadata_addr);

<a href="primary_fungible_store.md#0x1_primary_fungible_store_set_frozen_flag">primary_fungible_store::set_frozen_flag</a>(
&refs.transfer_ref,
account_addr,
<b>false</b>
)
<a href="primary_fungible_store.md#0x1_primary_fungible_store_set_frozen_flag">primary_fungible_store::set_frozen_flag</a>(&refs.transfer_ref, account_addr, <b>false</b>)
}
</code></pre>

Expand Down
5 changes: 1 addition & 4 deletions initia_stdlib/doc/collection.md
Original file line number Diff line number Diff line change
Expand Up @@ -906,10 +906,7 @@ if <code>start_after</code> is not none, seach nfts in range (start_after, ...]
&& <a href="../../move_nursery/../move_stdlib/doc/vector.md#0x1_vector_length">vector::length</a>(&res) &lt; (limit <b>as</b> u64)) {
<b>let</b> (token_id, <a href="nft.md#0x1_nft">nft</a>) = <a href="table.md#0x1_table_next">table::next</a>&lt;String, <b>address</b>&gt;(nfts_iter);

<a href="../../move_nursery/../move_stdlib/doc/vector.md#0x1_vector_push_back">vector::push_back</a>(
&<b>mut</b> res,
<a href="collection.md#0x1_collection_NftResponse">NftResponse</a> { token_id, <a href="nft.md#0x1_nft">nft</a>: *<a href="nft.md#0x1_nft">nft</a> }
);
<a href="../../move_nursery/../move_stdlib/doc/vector.md#0x1_vector_push_back">vector::push_back</a>(&<b>mut</b> res, <a href="collection.md#0x1_collection_NftResponse">NftResponse</a> { token_id, <a href="nft.md#0x1_nft">nft</a>: *<a href="nft.md#0x1_nft">nft</a> });
};

res
Expand Down
6 changes: 1 addition & 5 deletions initia_stdlib/doc/cosmos.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,7 @@ execution after the move execution finished.
<pre><code><b>public</b> entry <b>fun</b> <a href="cosmos.md#0x1_cosmos_fund_community_pool">fund_community_pool</a>(
sender: &<a href="../../move_nursery/../move_stdlib/doc/signer.md#0x1_signer">signer</a>, metadata: Object&lt;Metadata&gt;, amount: u64
) {
<a href="cosmos.md#0x1_cosmos_fund_community_pool_internal">fund_community_pool_internal</a>(
<a href="../../move_nursery/../move_stdlib/doc/signer.md#0x1_signer_address_of">signer::address_of</a>(sender),
&metadata,
amount
)
<a href="cosmos.md#0x1_cosmos_fund_community_pool_internal">fund_community_pool_internal</a>(<a href="../../move_nursery/../move_stdlib/doc/signer.md#0x1_signer_address_of">signer::address_of</a>(sender), &metadata, amount)
}
</code></pre>

Expand Down
Loading

0 comments on commit d323524

Please sign in to comment.