Skip to content

Commit

Permalink
Remove get_time_automation_fees RPC function (#448)
Browse files Browse the repository at this point in the history
  • Loading branch information
imstar15 authored Oct 9, 2023
1 parent c9f8ab0 commit 2a0e745
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 84 deletions.
1 change: 0 additions & 1 deletion pallets/automation-time/rpc/runtime-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ sp_api::decl_runtime_apis! {
Balance: Codec,
{
fn query_fee_details(uxt: Block::Extrinsic) -> Result<FeeDetails<Balance>, Vec<u8>>;
fn get_time_automation_fees(action: AutomationAction, executions: u32) -> Balance;
fn calculate_optimal_autostaking(
principal: i128,
collator: AccountId
Expand Down
35 changes: 0 additions & 35 deletions pallets/automation-time/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,6 @@ pub trait AutomationTimeApi<BlockHash, AccountId, Hash, Balance> {
at: Option<BlockHash>,
) -> RpcResult<FeeDetails<NumberOrHex>>;

#[method(name = "automationTime_getTimeAutomationFees")]
fn get_time_automation_fees(
&self,
action: AutomationAction,
executions: u32,
at: Option<BlockHash>,
) -> RpcResult<u64>;

/// Returns optimal autostaking period based on principal and a target collator.
#[method(name = "automationTime_calculateOptimalAutostaking")]
fn caclulate_optimal_autostaking(
Expand Down Expand Up @@ -154,33 +146,6 @@ where
})
}

fn get_time_automation_fees(
&self,
action: AutomationAction,
executions: u32,
at: Option<<Block as BlockT>::Hash>,
) -> RpcResult<u64> {
let api = self.client.runtime_api();
let at = BlockId::hash(at.unwrap_or_else(||
// If the block hash is not supplied assume the best block.
self.client.info().best_hash));
let runtime_api_result =
api.get_time_automation_fees(&at, action, executions).map_err(|e| {
CallError::Custom(ErrorObject::owned(
Error::RuntimeError.into(),
"Unable to get time automation fees",
Some(e.to_string()),
))
})?;
runtime_api_result.try_into().map_err(|_| {
JsonRpseeError::Call(CallError::Custom(ErrorObject::owned(
Error::RuntimeError.into(),
"RPC value doesn't fit in u64 representation",
Some("RPC value cannot be translated into u64 representation".to_string()),
)))
})
}

fn caclulate_optimal_autostaking(
&self,
principal: i128,
Expand Down
16 changes: 0 additions & 16 deletions runtime/neumann/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1196,22 +1196,6 @@ impl_runtime_apis! {
})
}

/**
* The get_time_automation_fees RPC function is used to get the execution fee of scheduling a time-automation task.
* This function requires the action type and the number of executions in order to generate an estimate.
* However, the AutomationTime::calculate_schedule_fee_amount requires an Action enum from the automation time pallet,
* which requires more information than is necessary for this calculation.
* Therefore, for ease of use, this function will just require an integer representing the action type and an integer
* representing the number of executions. For all of the extraneous information, the function will provide faux inputs for it.
*
*/
fn get_time_automation_fees(
action: AutomationAction,
executions: u32,
) -> Balance {
AutomationTime::calculate_schedule_fee_amount(&(action.into()), executions).expect("Can only fail for DynamicDispatch which is not an option here")
}

fn calculate_optimal_autostaking(
principal: i128,
collator: AccountId
Expand Down
16 changes: 0 additions & 16 deletions runtime/oak/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1201,22 +1201,6 @@ impl_runtime_apis! {
})
}

/**
* The get_time_automation_fees RPC function is used to get the execution fee of scheduling a time-automation task.
* This function requires the action type and the number of executions in order to generate an estimate.
* However, the AutomationTime::calculate_schedule_fee_amount requires an Action enum from the automation time pallet,
* which requires more information than is necessary for this calculation.
* Therefore, for ease of use, this function will just require an integer representing the action type and an integer
* representing the number of executions. For all of the extraneous information, the function will provide faux inputs for it.
*
*/
fn get_time_automation_fees(
action: AutomationAction,
executions: u32,
) -> Balance {
AutomationTime::calculate_schedule_fee_amount(&(action.into()), executions).expect("Can only fail for DynamicDispatch which is not an option here")
}

fn calculate_optimal_autostaking(
principal: i128,
collator: AccountId
Expand Down
16 changes: 0 additions & 16 deletions runtime/turing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1220,22 +1220,6 @@ impl_runtime_apis! {
})
}

/**
* The get_time_automation_fees RPC function is used to get the execution fee of scheduling a time-automation task.
* This function requires the action type and the number of executions in order to generate an estimate.
* However, the AutomationTime::calculate_schedule_fee_amount requires an Action enum from the automation time pallet,
* which requires more information than is necessary for this calculation.
* Therefore, for ease of use, this function will just require an integer representing the action type and an integer
* representing the number of executions. For all of the extraneous information, the function will provide faux inputs for it.
*
*/
fn get_time_automation_fees(
action: AutomationAction,
executions: u32,
) -> Balance {
AutomationTime::calculate_schedule_fee_amount(&(action.into()), executions).expect("Can only fail for DynamicDispatch which is not an option here")
}

fn calculate_optimal_autostaking(
principal: i128,
collator: AccountId
Expand Down

0 comments on commit 2a0e745

Please sign in to comment.