Skip to content

Commit

Permalink
Merge pull request #167 from Entropy-Foundation/task/regitry-issue-1436
Browse files Browse the repository at this point in the history
[Automation: MoveLayer] Implement AutomationRegistryConfig
  • Loading branch information
nizam-supraoracles authored Jan 23, 2025
2 parents aaf2118 + 31b1314 commit 37417cf
Show file tree
Hide file tree
Showing 6 changed files with 606 additions and 376 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,17 +158,6 @@ pub enum EntryFunctionCall {
id: u64,
},

/// Update Automation gas limit.
/// If the committed gas amount for the next epoch is greater then the new gas limit, then error is reported.
AutomationRegistryUpdateAutomationGasLimit {
automation_gas_limit: u64,
},

/// Update duration upper limit
AutomationRegistryUpdateDurationUpperLimit {
duration_upper_limit: u64,
},

/// Same as `publish_package` but as an entry function which can be called as a transaction. Because
/// of current restrictions for txn parameters, the metadata needs to be passed in serialized form.
CodePublishPackageTxn {
Expand Down Expand Up @@ -1265,12 +1254,6 @@ impl EntryFunctionCall {
cap_update_table,
),
AutomationRegistryCancelTask { id } => automation_registry_cancel_task(id),
AutomationRegistryUpdateAutomationGasLimit {
automation_gas_limit,
} => automation_registry_update_automation_gas_limit(automation_gas_limit),
AutomationRegistryUpdateDurationUpperLimit {
duration_upper_limit,
} => automation_registry_update_duration_upper_limit(duration_upper_limit),
CodePublishPackageTxn {
metadata_serialized,
code,
Expand Down Expand Up @@ -2295,43 +2278,6 @@ pub fn automation_registry_cancel_task(id: u64) -> TransactionPayload {
))
}

/// Update Automation gas limit.
/// If the committed gas amount for the next epoch is greater then the new gas limit, then error is reported.
pub fn automation_registry_update_automation_gas_limit(
automation_gas_limit: u64,
) -> TransactionPayload {
TransactionPayload::EntryFunction(EntryFunction::new(
ModuleId::new(
AccountAddress::new([
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1,
]),
ident_str!("automation_registry").to_owned(),
),
ident_str!("update_automation_gas_limit").to_owned(),
vec![],
vec![bcs::to_bytes(&automation_gas_limit).unwrap()],
))
}

/// Update duration upper limit
pub fn automation_registry_update_duration_upper_limit(
duration_upper_limit: u64,
) -> TransactionPayload {
TransactionPayload::EntryFunction(EntryFunction::new(
ModuleId::new(
AccountAddress::new([
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1,
]),
ident_str!("automation_registry").to_owned(),
),
ident_str!("update_duration_upper_limit").to_owned(),
vec![],
vec![bcs::to_bytes(&duration_upper_limit).unwrap()],
))
}

/// Same as `publish_package` but as an entry function which can be called as a transaction. Because
/// of current restrictions for txn parameters, the metadata needs to be passed in serialized form.
pub fn code_publish_package_txn(
Expand Down Expand Up @@ -5648,34 +5594,6 @@ mod decoder {
}
}

pub fn automation_registry_update_automation_gas_limit(
payload: &TransactionPayload,
) -> Option<EntryFunctionCall> {
if let TransactionPayload::EntryFunction(script) = payload {
Some(
EntryFunctionCall::AutomationRegistryUpdateAutomationGasLimit {
automation_gas_limit: bcs::from_bytes(script.args().get(0)?).ok()?,
},
)
} else {
None
}
}

pub fn automation_registry_update_duration_upper_limit(
payload: &TransactionPayload,
) -> Option<EntryFunctionCall> {
if let TransactionPayload::EntryFunction(script) = payload {
Some(
EntryFunctionCall::AutomationRegistryUpdateDurationUpperLimit {
duration_upper_limit: bcs::from_bytes(script.args().get(0)?).ok()?,
},
)
} else {
None
}
}

pub fn code_publish_package_txn(payload: &TransactionPayload) -> Option<EntryFunctionCall> {
if let TransactionPayload::EntryFunction(script) = payload {
Some(EntryFunctionCall::CodePublishPackageTxn {
Expand Down Expand Up @@ -7608,14 +7526,6 @@ static SCRIPT_FUNCTION_DECODER_MAP: once_cell::sync::Lazy<EntryFunctionDecoderMa
"automation_registry_cancel_task".to_string(),
Box::new(decoder::automation_registry_cancel_task),
);
map.insert(
"automation_registry_update_automation_gas_limit".to_string(),
Box::new(decoder::automation_registry_update_automation_gas_limit),
);
map.insert(
"automation_registry_update_duration_upper_limit".to_string(),
Box::new(decoder::automation_registry_update_duration_upper_limit),
);
map.insert(
"code_publish_package_txn".to_string(),
Box::new(decoder::code_publish_package_txn),
Expand Down
Loading

0 comments on commit 37417cf

Please sign in to comment.