Skip to content

Commit c4de5e2

Browse files
authored
new method for cached package (#227)
1 parent 77587e5 commit c4de5e2

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

aptos-move/framework/supra-framework/doc/genesis.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ Genesis step 1: Initialize supra framework account and core modules on chain.
587587
<b>let</b> (supra_framework_account, supra_framework_signer_cap) = <a href="account.md#0x1_account_create_framework_reserved_account">account::create_framework_reserved_account</a>(
588588
@supra_framework
589589
);
590-
// Initialize <a href="account.md#0x1_account">account</a> configs on aptos framework <a href="account.md#0x1_account">account</a>.
590+
// Initialize <a href="account.md#0x1_account">account</a> configs on supra framework <a href="account.md#0x1_account">account</a>.
591591
<a href="account.md#0x1_account_initialize">account::initialize</a>(&supra_framework_account);
592592

593593
<a href="transaction_validation.md#0x1_transaction_validation_initialize">transaction_validation::initialize</a>(

aptos-move/framework/supra-framework/doc/vesting_without_staking.md

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,6 +1342,10 @@ Create a vesting schedule with the given schedule of distributions, a vesting st
13421342
sum != 0,
13431343
<a href="../../aptos-stdlib/../move-stdlib/doc/error.md#0x1_error_invalid_argument">error::invalid_argument</a>(<a href="vesting_without_staking.md#0x1_vesting_without_staking_EINVALID_VESTING_SCHEDULE">EINVALID_VESTING_SCHEDULE</a>),
13441344
);
1345+
<b>assert</b>!(
1346+
sum &lt;= denominator,
1347+
<a href="../../aptos-stdlib/../move-stdlib/doc/error.md#0x1_error_invalid_argument">error::invalid_argument</a>(<a href="vesting_without_staking.md#0x1_vesting_without_staking_EINVALID_VESTING_SCHEDULE">EINVALID_VESTING_SCHEDULE</a>)
1348+
);
13451349
<b>assert</b>!(
13461350
denominator != 0,
13471351
<a href="../../aptos-stdlib/../move-stdlib/doc/error.md#0x1_error_invalid_argument">error::invalid_argument</a>(<a href="vesting_without_staking.md#0x1_vesting_without_staking_EINVALID_VESTING_SCHEDULE">EINVALID_VESTING_SCHEDULE</a>),
@@ -1717,9 +1721,6 @@ Unlock any vested portion of the grant.
17171721

17181722
<b>if</b> (last_completed_period &gt;= next_period_to_vest && vesting_record.left_amount != 0) {
17191723
<b>let</b> final_fraction = *<a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector_borrow">vector::borrow</a>(schedule, <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector_length">vector::length</a>(schedule) - 1);
1720-
<b>let</b> final_fraction_amount = <a href="../../aptos-stdlib/../move-stdlib/doc/fixed_point32.md#0x1_fixed_point32_multiply_u64">fixed_point32::multiply_u64</a>(
1721-
vesting_record.init_amount, final_fraction
1722-
);
17231724
// Determine how many periods is needed based on the left_amount
17241725
periods_fast_forward = last_completed_period - next_period_to_vest + 1;
17251726
<b>let</b> added_fraction = <a href="../../aptos-stdlib/../move-stdlib/doc/fixed_point32.md#0x1_fixed_point32_multiply_u64_return_fixpoint32">fixed_point32::multiply_u64_return_fixpoint32</a>(
@@ -1731,10 +1732,6 @@ Unlock any vested portion of the grant.
17311732
);
17321733

17331734
};
1734-
<b>let</b> total_vesting_fraction_amount = <a href="../../aptos-stdlib/../move-stdlib/doc/fixed_point32.md#0x1_fixed_point32_multiply_u64">fixed_point32::multiply_u64</a>(
1735-
vesting_record.init_amount,
1736-
total_vesting_fraction,
1737-
);
17381735
// We don't need <b>to</b> check vesting_record.left_amount &gt; 0 because vest_transfer will handle that.
17391736
<b>let</b> transfer_happened = <a href="vesting_without_staking.md#0x1_vesting_without_staking_vest_transfer">vest_transfer</a>(
17401737
vesting_record, signer_cap, beneficiary, total_vesting_fraction
@@ -1794,14 +1791,12 @@ Unlock any vested portion of the grant.
17941791
vesting_record.left_amount,
17951792
<a href="../../aptos-stdlib/../move-stdlib/doc/fixed_point32.md#0x1_fixed_point32_multiply_u64">fixed_point32::multiply_u64</a>(vesting_record.init_amount, vesting_fraction),
17961793
);
1797-
<b>let</b> result =
17981794
<b>if</b> (amount &gt; 0) {
17991795
//<b>update</b> left_amount for the shareholder
18001796
vesting_record.left_amount = vesting_record.left_amount - amount;
18011797
<a href="coin.md#0x1_coin_transfer">coin::transfer</a>&lt;SupraCoin&gt;(&vesting_signer, beneficiary, amount);
18021798
<b>true</b>
1803-
} <b>else</b> { <b>false</b> };
1804-
result
1799+
} <b>else</b> { <b>false</b> }
18051800
}
18061801
</code></pre>
18071802

@@ -1841,9 +1836,7 @@ Unlock any vested portion of the grant.
18411836
<b>let</b> schedule = <a href="../../aptos-stdlib/../move-stdlib/doc/vector.md#0x1_vector_map_ref">vector::map_ref</a>(
18421837
&vesting_numerators,
18431838
|numerator| {
1844-
<b>let</b> e =
1845-
<a href="../../aptos-stdlib/../move-stdlib/doc/fixed_point32.md#0x1_fixed_point32_create_from_rational">fixed_point32::create_from_rational</a>(*numerator, vesting_denominator);
1846-
e
1839+
<a href="../../aptos-stdlib/../move-stdlib/doc/fixed_point32.md#0x1_fixed_point32_create_from_rational">fixed_point32::create_from_rational</a>(*numerator, vesting_denominator)
18471840
},
18481841
);
18491842

@@ -1859,7 +1852,6 @@ Unlock any vested portion of the grant.
18591852
msrecord.last_vested_period * old_period_duration
18601853
) / period_duration;
18611854
msrecord.last_vested_period = new_last_vested_period;
1862-
msrecord.last_vested_period = new_last_vested_period;
18631855
},
18641856
);
18651857
vesting_contract.shareholders = <a href="../../aptos-stdlib/doc/simple_map.md#0x1_simple_map_new_from">simple_map::new_from</a>(keys, values);

crates/aptos/src/move_tool/stored_package.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ impl fmt::Display for CachedPackageMetadata<'_> {
3939
}
4040

4141
impl CachedPackageRegistry {
42+
pub fn new(inner: PackageRegistry, bytecode: BTreeMap<String, Vec<u8>>) -> Self {
43+
Self {
44+
inner,
45+
bytecode,
46+
}
47+
}
48+
4249
/// Creates a new registry.
4350
pub async fn create(
4451
url: Url,

0 commit comments

Comments
 (0)