Skip to content

Commit

Permalink
fix - asserstion mistake fix which included in last commit and update…
Browse files Browse the repository at this point in the history
… function name
  • Loading branch information
nizam-supraoracles committed Jan 22, 2025
1 parent a88c389 commit a453a57
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions aptos-move/framework/supra-framework/doc/automation_registry.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ This contract is part of the Supra Framework and is designed to manage automated
- [Function `initializate_by_default`](#0x1_automation_registry_initializate_by_default)
- [Function `initialize`](#0x1_automation_registry_initialize)
- [Function `on_new_epoch`](#0x1_automation_registry_on_new_epoch)
- [Function `config_update_from_buffer`](#0x1_automation_registry_config_update_from_buffer)
- [Function `update_config_from_buffer`](#0x1_automation_registry_update_config_from_buffer)
- [Function `withdraw_automation_task_fees`](#0x1_automation_registry_withdraw_automation_task_fees)
- [Function `transfer_fee_to_account_internal`](#0x1_automation_registry_transfer_fee_to_account_internal)
- [Function `update_config`](#0x1_automation_registry_update_config)
Expand Down Expand Up @@ -789,7 +789,7 @@ On new epoch this function will be triggered and update the automation registry
});

// Apply the latest configuration <b>if</b> <a href="../../aptos-stdlib/doc/any.md#0x1_any">any</a> parameter <b>has</b> been updated.
<a href="automation_registry.md#0x1_automation_registry_config_update_from_buffer">config_update_from_buffer</a>();
<a href="automation_registry.md#0x1_automation_registry_update_config_from_buffer">update_config_from_buffer</a>();

<a href="automation_registry.md#0x1_automation_registry">automation_registry</a>.gas_committed_for_next_epoch = gas_committed_for_next_epoch;
automation_epoch_info.start_time = current_time;
Expand All @@ -801,14 +801,14 @@ On new epoch this function will be triggered and update the automation registry

</details>

<a id="0x1_automation_registry_config_update_from_buffer"></a>
<a id="0x1_automation_registry_update_config_from_buffer"></a>

## Function `config_update_from_buffer`
## Function `update_config_from_buffer`

The function updates the ActiveAutomationRegistryConfig structure with values extracted from the buffer, if the buffer exists.


<pre><code><b>fun</b> <a href="automation_registry.md#0x1_automation_registry_config_update_from_buffer">config_update_from_buffer</a>()
<pre><code><b>fun</b> <a href="automation_registry.md#0x1_automation_registry_update_config_from_buffer">update_config_from_buffer</a>()
</code></pre>


Expand All @@ -817,7 +817,7 @@ The function updates the ActiveAutomationRegistryConfig structure with values ex
<summary>Implementation</summary>


<pre><code><b>fun</b> <a href="automation_registry.md#0x1_automation_registry_config_update_from_buffer">config_update_from_buffer</a>() <b>acquires</b> <a href="automation_registry.md#0x1_automation_registry_ActiveAutomationRegistryConfig">ActiveAutomationRegistryConfig</a> {
<pre><code><b>fun</b> <a href="automation_registry.md#0x1_automation_registry_update_config_from_buffer">update_config_from_buffer</a>() <b>acquires</b> <a href="automation_registry.md#0x1_automation_registry_ActiveAutomationRegistryConfig">ActiveAutomationRegistryConfig</a> {
<b>if</b> (<a href="config_buffer.md#0x1_config_buffer_does_exist">config_buffer::does_exist</a>&lt;<a href="automation_registry.md#0x1_automation_registry_AutomationRegistryConfig">AutomationRegistryConfig</a>&gt;()) {
<b>let</b> buffer = <a href="config_buffer.md#0x1_config_buffer_extract">config_buffer::extract</a>&lt;<a href="automation_registry.md#0x1_automation_registry_AutomationRegistryConfig">AutomationRegistryConfig</a>&gt;();
<b>let</b> automation_registry_config = &<b>mut</b> <b>borrow_global_mut</b>&lt;<a href="automation_registry.md#0x1_automation_registry_ActiveAutomationRegistryConfig">ActiveAutomationRegistryConfig</a>&gt;(
Expand Down Expand Up @@ -1180,7 +1180,7 @@ Refunds the automation task fee to the user who has removed their task registrat
automation_registry_config: &<a href="automation_registry.md#0x1_automation_registry_AutomationRegistryConfig">AutomationRegistryConfig</a>,
) <b>acquires</b> <a href="automation_registry.md#0x1_automation_registry_AutomationRegistry">AutomationRegistry</a> {
<b>let</b> current_time = <a href="timestamp.md#0x1_timestamp_now_seconds">timestamp::now_seconds</a>();
<b>assert</b>!(automation_task_metadata.expiry_time &lt; current_time, <a href="automation_registry.md#0x1_automation_registry_ETASK_IS_ALREADY_EXPIRED">ETASK_IS_ALREADY_EXPIRED</a>);
<b>assert</b>!(automation_task_metadata.expiry_time &gt; current_time, <a href="automation_registry.md#0x1_automation_registry_ETASK_IS_ALREADY_EXPIRED">ETASK_IS_ALREADY_EXPIRED</a>);
<b>let</b> residual_ttl = automation_task_metadata.expiry_time - current_time;

<b>let</b> refund_amount = residual_ttl * automation_registry_config.automation_base_fee_in_quants_per_sec;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,15 +254,15 @@ module supra_framework::automation_registry {
});

// Apply the latest configuration if any parameter has been updated.
config_update_from_buffer();
update_config_from_buffer();

automation_registry.gas_committed_for_next_epoch = gas_committed_for_next_epoch;
automation_epoch_info.start_time = current_time;
automation_epoch_info.expected_epoch_duration = automation_epoch_info.epoch_interval;
}

/// The function updates the ActiveAutomationRegistryConfig structure with values extracted from the buffer, if the buffer exists.
fun config_update_from_buffer() acquires ActiveAutomationRegistryConfig {
fun update_config_from_buffer() acquires ActiveAutomationRegistryConfig {
if (config_buffer::does_exist<AutomationRegistryConfig>()) {
let buffer = config_buffer::extract<AutomationRegistryConfig>();
let automation_registry_config = &mut borrow_global_mut<ActiveAutomationRegistryConfig>(
Expand Down Expand Up @@ -465,7 +465,7 @@ module supra_framework::automation_registry {
automation_registry_config: &AutomationRegistryConfig,
) acquires AutomationRegistry {
let current_time = timestamp::now_seconds();
assert!(automation_task_metadata.expiry_time < current_time, ETASK_IS_ALREADY_EXPIRED);
assert!(automation_task_metadata.expiry_time > current_time, ETASK_IS_ALREADY_EXPIRED);
let residual_ttl = automation_task_metadata.expiry_time - current_time;

let refund_amount = residual_ttl * automation_registry_config.automation_base_fee_in_quants_per_sec;
Expand Down

0 comments on commit a453a57

Please sign in to comment.