Skip to content

Commit

Permalink
Merge branch 'master' into update_release_template
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisli30 authored Jul 27, 2023
2 parents b15936b + d15fe71 commit e8d3499
Show file tree
Hide file tree
Showing 14 changed files with 1,257 additions and 633 deletions.
3 changes: 1 addition & 2 deletions pallets/automation-time/rpc/runtime-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,12 @@ sp_api::decl_runtime_apis! {
Hash: Codec,
Balance: Codec,
{
fn generate_task_id(account_id: AccountId, provided_id: Vec<u8>) -> Hash;
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
) -> Result<AutostakingResult, Vec<u8>>;
fn get_auto_compound_delegated_stake_task_ids(account_id: AccountId) -> Vec<Hash>;
fn get_auto_compound_delegated_stake_task_ids(account_id: AccountId) -> Vec<Vec<u8>>;
}
}
33 changes: 2 additions & 31 deletions pallets/automation-time/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,6 @@ use std::sync::Arc;
/// An RPC endpoint to provide information about tasks.
#[rpc(client, server)]
pub trait AutomationTimeApi<BlockHash, AccountId, Hash, Balance> {
/// Generates the task_id given the account_id and provided_id.
#[method(name = "automationTime_generateTaskId")]
fn generate_task_id(
&self,
account: AccountId,
provided_id: String,
at: Option<BlockHash>,
) -> RpcResult<Hash>;

#[method(name = "automationTime_queryFeeDetails")]
fn query_fee_details(
&self,
Expand Down Expand Up @@ -72,7 +63,7 @@ pub trait AutomationTimeApi<BlockHash, AccountId, Hash, Balance> {
fn get_auto_compound_delegated_stake_task_ids(
&self,
account: AccountId,
) -> RpcResult<Vec<Hash>>;
) -> RpcResult<Vec<Vec<u8>>>;
}

/// An implementation of Automation-specific RPC methods on full client.
Expand Down Expand Up @@ -115,26 +106,6 @@ where
AccountId: Codec,
Hash: Codec,
{
fn generate_task_id(
&self,
account: AccountId,
provided_id: String,
at: Option<Block::Hash>,
) -> RpcResult<Hash> {
let api = self.client.runtime_api();
let at = BlockId::hash(at.unwrap_or_else(|| self.client.info().best_hash));

let runtime_api_result =
api.generate_task_id(&at, account, provided_id.as_bytes().to_vec());
runtime_api_result.map_err(|e| {
JsonRpseeError::Call(CallError::Custom(ErrorObject::owned(
Error::RuntimeError.into(),
"Unable to generate task_id",
Some(format!("{:?}", e)),
)))
})
}

fn query_fee_details(
&self,
encoded_xt: Bytes,
Expand Down Expand Up @@ -233,7 +204,7 @@ where
fn get_auto_compound_delegated_stake_task_ids(
&self,
account: AccountId,
) -> RpcResult<Vec<Hash>> {
) -> RpcResult<Vec<Vec<u8>>> {
let api = self.client.runtime_api();
let at = BlockId::hash(self.client.info().best_hash);

Expand Down
Loading

0 comments on commit e8d3499

Please sign in to comment.