Skip to content

Commit

Permalink
Take Bytes parameters as borrow
Browse files Browse the repository at this point in the history
  • Loading branch information
Niederb committed Jun 29, 2023
1 parent 3162233 commit 80caeaa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
24 changes: 12 additions & 12 deletions src/api/rpc_api/author.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub trait SubmitExtrinsic {

/// Submit an encoded, opaque extrsinic to the substrate node.
/// Returns the extrinsic hash.
async fn submit_opaque_extrinsic(&self, encoded_extrinsic: Bytes) -> Result<Self::Hash>;
async fn submit_opaque_extrinsic(&self, encoded_extrinsic: &Bytes) -> Result<Self::Hash>;
}

#[maybe_async::maybe_async(?Send)]
Expand All @@ -69,10 +69,10 @@ where
Signature: Encode,
SignedExtra: Encode,
{
self.submit_opaque_extrinsic(extrinsic.encode().into()).await
self.submit_opaque_extrinsic(&extrinsic.encode().into()).await
}

async fn submit_opaque_extrinsic(&self, encoded_extrinsic: Bytes) -> Result<Self::Hash> {
async fn submit_opaque_extrinsic(&self, encoded_extrinsic: &Bytes) -> Result<Self::Hash> {
let hex_encoded_xt = rpc_params![encoded_extrinsic];
debug!("sending extrinsic: {:?}", hex_encoded_xt);
let xt_hash = self.client().request("author_submitExtrinsic", hex_encoded_xt).await?;
Expand Down Expand Up @@ -101,7 +101,7 @@ pub trait SubmitAndWatch {
/// watch the extrinsic progress.
async fn submit_and_watch_opaque_extrinsic(
&self,
encoded_extrinsic: Bytes,
encoded_extrinsic: &Bytes,
) -> Result<TransactionSubscriptionFor<Self::Client, Self::Hash>>;

/// Submit an extrinsic and watch it until the desired status
Expand Down Expand Up @@ -133,7 +133,7 @@ pub trait SubmitAndWatch {
/// This method is blocking.
async fn submit_and_watch_opaque_extrinsic_until(
&self,
encoded_extrinsic: Bytes,
encoded_extrinsic: &Bytes,
watch_until: XtStatus,
) -> Result<ExtrinsicReport<Self::Hash>>;
}
Expand Down Expand Up @@ -176,7 +176,7 @@ pub trait SubmitAndWatchUntilSuccess {
/// This method is blocking.
async fn submit_and_watch_opaque_extrinsic_until_success(
&self,
encoded_extrinsic: Bytes,
encoded_extrinsic: &Bytes,
wait_for_finalized: bool,
) -> Result<ExtrinsicReport<Self::Hash>>;
}
Expand All @@ -200,12 +200,12 @@ where
Signature: Encode,
SignedExtra: Encode,
{
self.submit_and_watch_opaque_extrinsic(extrinsic.encode().into()).await
self.submit_and_watch_opaque_extrinsic(&extrinsic.encode().into()).await
}

async fn submit_and_watch_opaque_extrinsic(
&self,
encoded_extrinsic: Bytes,
encoded_extrinsic: &Bytes,
) -> Result<TransactionSubscriptionFor<Self::Client, Self::Hash>> {
self.client()
.subscribe(
Expand All @@ -227,13 +227,13 @@ where
Signature: Encode,
SignedExtra: Encode,
{
self.submit_and_watch_opaque_extrinsic_until(extrinsic.encode().into(), watch_until)
self.submit_and_watch_opaque_extrinsic_until(&extrinsic.encode().into(), watch_until)
.await
}

async fn submit_and_watch_opaque_extrinsic_until(
&self,
encoded_extrinsic: Bytes,
encoded_extrinsic: &Bytes,
watch_until: XtStatus,
) -> Result<ExtrinsicReport<Self::Hash>> {
let tx_hash = T::Hasher::hash_of(&encoded_extrinsic.0);
Expand Down Expand Up @@ -285,15 +285,15 @@ where
SignedExtra: Encode,
{
self.submit_and_watch_opaque_extrinsic_until_success(
extrinsic.encode().into(),
&extrinsic.encode().into(),
wait_for_finalized,
)
.await
}

async fn submit_and_watch_opaque_extrinsic_until_success(
&self,
encoded_extrinsic: Bytes,
encoded_extrinsic: &Bytes,
wait_for_finalized: bool,
) -> Result<ExtrinsicReport<Self::Hash>> {
let xt_status = match wait_for_finalized {
Expand Down
8 changes: 4 additions & 4 deletions src/api/rpc_api/pallet_transaction_payment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ pub trait GetTransactionPayment {

async fn get_fee_details(
&self,
encoded_extrinsic: Bytes,
encoded_extrinsic: &Bytes,
at_block: Option<Self::Hash>,
) -> Result<Option<FeeDetails<Self::Balance>>>;

async fn get_payment_info(
&self,
encoded_extrinsic: Bytes,
encoded_extrinsic: &Bytes,
at_block: Option<Self::Hash>,
) -> Result<Option<RuntimeDispatchInfo<Self::Balance>>>;
}
Expand All @@ -50,7 +50,7 @@ where

async fn get_fee_details(
&self,
encoded_extrinsic: Bytes,
encoded_extrinsic: &Bytes,
at_block: Option<Self::Hash>,
) -> Result<Option<FeeDetails<Self::Balance>>> {
let details: Option<FeeDetails<NumberOrHex>> = self
Expand All @@ -67,7 +67,7 @@ where

async fn get_payment_info(
&self,
encoded_extrinsic: Bytes,
encoded_extrinsic: &Bytes,
at_block: Option<Self::Hash>,
) -> Result<Option<RuntimeDispatchInfo<Self::Balance>>> {
let res = self
Expand Down

0 comments on commit 80caeaa

Please sign in to comment.