Skip to content

Commit

Permalink
PR suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Coats committed Nov 30, 2023
1 parent 02888f0 commit 418b19e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bindings/core/src/method/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ pub enum WalletMethod {
PrepareImplicitAccountTransition {
output_id: OutputId,
#[serde(default)]
public_key: Option<PublicKey>,
public_key: Option<String>,
#[serde(default)]
bip_path: Option<Bip44>,
},
Expand Down
7 changes: 5 additions & 2 deletions bindings/core/src/method_handler/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use std::time::Duration;

use crypto::signatures::ed25519::PublicKey;
use iota_sdk::{
client::api::{
PreparedTransactionData, PreparedTransactionDataDto, SignedTransactionData, SignedTransactionDataDto,
Expand Down Expand Up @@ -215,9 +216,11 @@ pub(crate) async fn call_wallet_method_internal(wallet: &Wallet, method: WalletM
public_key,
bip_path,
} => {
let data = if public_key.is_some() {
let data = if let Some(public_key_str) = public_key {
let public_key = PublicKey::try_from_bytes(prefix_hex::decode(public_key_str)?)
.map_err(iota_sdk::wallet::Error::other)?;
wallet
.prepare_implicit_account_transition(&output_id, public_key)
.prepare_implicit_account_transition(&output_id, Some(public_key))
.await?
} else {
wallet.prepare_implicit_account_transition(&output_id, bip_path).await?
Expand Down
6 changes: 6 additions & 0 deletions sdk/src/wallet/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ pub enum Error {
ImplicitAccountNotFound,
}

impl Error {
pub fn other<E: 'static + std::error::Error + Send + Sync>(err: E) -> Self {
Self::Other(Box::new(err) as _)
}
}

// Serialize type with Display error
impl Serialize for Error {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/wallet/operations/transaction/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ where

let public_key = match key_source {
BlockIssuerKeySource::Key(public_key) => public_key,
BlockIssuerKeySource::Path(bip_path) => {
BlockIssuerKeySource::Bip44Path(bip_path) => {
self.secret_manager
.read()
.await
Expand Down Expand Up @@ -107,5 +107,5 @@ where
#[derive(From)]
pub enum BlockIssuerKeySource {
Key(PublicKey),
Path(Bip44),
Bip44Path(Bip44),
}

0 comments on commit 418b19e

Please sign in to comment.