Skip to content

Commit

Permalink
[aptos-framework] merge script funs into their module
Browse files Browse the repository at this point in the history
As a design principle, we should have our framework resemble the APIs we
anticipate users to build and then have a consistent theme around that.
Placing script funs outside the context of a module is a lot less
ergonomic for developers, so we develop the same methodology:

* script funs belong in their respective module
* if a script fun wraps around a function that can be reusable, make the
reusable component _internal

Closes: aptos-labs#163
  • Loading branch information
davidiw authored and aptos-bot committed Mar 13, 2022
1 parent e9b1f2b commit 550688d
Show file tree
Hide file tree
Showing 43 changed files with 254 additions and 537 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ compiled_package_info:
? address: "00000000000000000000000000000001"
name: Account
: CoreFramework
? address: "00000000000000000000000000000001"
name: AdminScripts
: AptosFramework
? address: "00000000000000000000000000000001"
name: AptosAccount
: AptosFramework
Expand Down Expand Up @@ -44,9 +41,6 @@ compiled_package_info:
? address: "00000000000000000000000000000001"
name: BCS
: Std
? address: "00000000000000000000000000000001"
name: BasicScripts
: AptosFramework
? address: "00000000000000000000000000000001"
name: BitVector
: Std
Expand Down Expand Up @@ -134,7 +128,7 @@ compiled_package_info:
? address: "00000000000000000000000000000001"
name: Version
: CoreFramework
source_digest: 3B95510C64DD284876E288D78AFEC1B6F3E15137F110C6BB86CF8B3FB825EDA0
source_digest: 0638850467F3BD5AECE657D2CE0EC7928BE82F37321094900EF380CC710D6F4B
build_flags:
dev_mode: false
test_mode: false
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ transaction in addition to the core prologue and epilogue.
- [Function `create_validator_account`](#0x1_AptosAccount_create_validator_account)
- [Function `create_validator_operator_account`](#0x1_AptosAccount_create_validator_operator_account)
- [Function `rotate_authentication_key`](#0x1_AptosAccount_rotate_authentication_key)
- [Function `rotate_authentication_key_internal`](#0x1_AptosAccount_rotate_authentication_key_internal)
- [Function `module_prologue`](#0x1_AptosAccount_module_prologue)
- [Function `script_prologue`](#0x1_AptosAccount_script_prologue)
- [Function `writeset_prologue`](#0x1_AptosAccount_writeset_prologue)
Expand Down Expand Up @@ -283,7 +284,7 @@ Initialize this module. This is only callable from genesis.
Basic account creation method.


<pre><code><b>public</b> <b>fun</b> <a href="AptosAccount.md#0x1_AptosAccount_create_account">create_account</a>(new_account_address: <b>address</b>, auth_key_preimage: vector&lt;u8&gt;): signer
<pre><code><b>public</b>(<b>script</b>) <b>fun</b> <a href="AptosAccount.md#0x1_AptosAccount_create_account">create_account</a>(new_account_address: <b>address</b>, auth_key_preimage: vector&lt;u8&gt;)
</code></pre>


Expand All @@ -292,10 +293,7 @@ Basic account creation method.
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="AptosAccount.md#0x1_AptosAccount_create_account">create_account</a>(
new_account_address: <b>address</b>,
auth_key_preimage: vector&lt;u8&gt;,
): signer {
<pre><code><b>public</b>(<b>script</b>) <b>fun</b> <a href="AptosAccount.md#0x1_AptosAccount_create_account">create_account</a>(new_account_address: <b>address</b>, auth_key_preimage: vector&lt;u8&gt;) {
<b>let</b> auth_key = <a href="../../../../../../../aptos-framework/releases/artifacts/current/build/MoveStdlib/docs/Hash.md#0x1_Hash_sha3_256">Hash::sha3_256</a>(auth_key_preimage);
<b>let</b> bytes = <a href="../../../../../../../aptos-framework/releases/artifacts/current/build/MoveStdlib/docs/BCS.md#0x1_BCS_to_bytes">BCS::to_bytes</a>(&new_account_address);
<b>let</b> len = <a href="../../../../../../../aptos-framework/releases/artifacts/current/build/MoveStdlib/docs/Vector.md#0x1_Vector_length">Vector::length</a>(&bytes);
Expand All @@ -306,7 +304,7 @@ Basic account creation method.
};

<b>let</b> (signer, _) = <a href="AptosAccount.md#0x1_AptosAccount_create_account_internal">create_account_internal</a>(new_account_address, auth_key);
signer
<a href="TestCoin.md#0x1_TestCoin_register">TestCoin::register</a>(&signer);
}
</code></pre>

Expand Down Expand Up @@ -407,7 +405,34 @@ Create a Validator Operator account
Rotate the authentication key for the account under cap.account_address


<pre><code><b>public</b> <b>fun</b> <a href="AptosAccount.md#0x1_AptosAccount_rotate_authentication_key">rotate_authentication_key</a>(account: &signer, new_authentication_key: vector&lt;u8&gt;)
<pre><code><b>public</b>(<b>script</b>) <b>fun</b> <a href="AptosAccount.md#0x1_AptosAccount_rotate_authentication_key">rotate_authentication_key</a>(account: signer, new_authentication_key: vector&lt;u8&gt;)
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>public</b>(<b>script</b>) <b>fun</b> <a href="AptosAccount.md#0x1_AptosAccount_rotate_authentication_key">rotate_authentication_key</a>(
account: signer,
new_authentication_key: vector&lt;u8&gt;,
) {
<a href="AptosAccount.md#0x1_AptosAccount_rotate_authentication_key_internal">rotate_authentication_key_internal</a>(&account, new_authentication_key);
}
</code></pre>



</details>

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

## Function `rotate_authentication_key_internal`



<pre><code><b>public</b> <b>fun</b> <a href="AptosAccount.md#0x1_AptosAccount_rotate_authentication_key_internal">rotate_authentication_key_internal</a>(account: &signer, new_authentication_key: vector&lt;u8&gt;)
</code></pre>


Expand All @@ -416,7 +441,7 @@ Rotate the authentication key for the account under cap.account_address
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="AptosAccount.md#0x1_AptosAccount_rotate_authentication_key">rotate_authentication_key</a>(
<pre><code><b>public</b> <b>fun</b> <a href="AptosAccount.md#0x1_AptosAccount_rotate_authentication_key_internal">rotate_authentication_key_internal</a>(
account: &signer,
new_authentication_key: vector&lt;u8&gt;,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Publishes the VM config.



<pre><code><b>public</b> <b>fun</b> <a href="AptosVMConfig.md#0x1_AptosVMConfig_set_gas_constants">set_gas_constants</a>(account: &signer, global_memory_per_byte_cost: u64, global_memory_per_byte_write_cost: u64, min_transaction_gas_units: u64, large_transaction_cutoff: u64, intrinsic_gas_per_byte: u64, maximum_number_of_gas_units: u64, min_price_per_gas_unit: u64, max_price_per_gas_unit: u64, max_transaction_size_in_bytes: u64, gas_unit_scaling_factor: u64, default_account_size: u64)
<pre><code><b>public</b>(<b>script</b>) <b>fun</b> <a href="AptosVMConfig.md#0x1_AptosVMConfig_set_gas_constants">set_gas_constants</a>(account: signer, global_memory_per_byte_cost: u64, global_memory_per_byte_write_cost: u64, min_transaction_gas_units: u64, large_transaction_cutoff: u64, intrinsic_gas_per_byte: u64, maximum_number_of_gas_units: u64, min_price_per_gas_unit: u64, max_price_per_gas_unit: u64, max_transaction_size_in_bytes: u64, gas_unit_scaling_factor: u64, default_account_size: u64)
</code></pre>


Expand All @@ -61,8 +61,8 @@ Publishes the VM config.
<summary>Implementation</summary>


<pre><code><b>public</b> <b>fun</b> <a href="AptosVMConfig.md#0x1_AptosVMConfig_set_gas_constants">set_gas_constants</a>(
account: &signer,
<pre><code><b>public</b>(<b>script</b>) <b>fun</b> <a href="AptosVMConfig.md#0x1_AptosVMConfig_set_gas_constants">set_gas_constants</a>(
account: signer,
global_memory_per_byte_cost: u64,
global_memory_per_byte_write_cost: u64,
min_transaction_gas_units: u64,
Expand All @@ -87,7 +87,7 @@ Publishes the VM config.
max_transaction_size_in_bytes,
gas_unit_scaling_factor,
default_account_size,
&<a href="../../../../../../../aptos-framework/releases/artifacts/current/build/MoveStdlib/docs/Capability.md#0x1_Capability_acquire">Capability::acquire</a>(account, &<a href="Marker.md#0x1_Marker_get">Marker::get</a>()),
&<a href="../../../../../../../aptos-framework/releases/artifacts/current/build/MoveStdlib/docs/Capability.md#0x1_Capability_acquire">Capability::acquire</a>(&account, &<a href="Marker.md#0x1_Marker_get">Marker::get</a>()),
);
}
</code></pre>
Expand Down

This file was deleted.

Loading

0 comments on commit 550688d

Please sign in to comment.