Skip to content

Commit

Permalink
fix: clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
jurevans committed Nov 25, 2024
1 parent d902160 commit 5fb6556
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions packages/shared/lib/src/types/masp.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
//! PaymentAddress - Provide wasm_bindgen bindings for shielded addresses
//! See @namada/crypto for zip32 HD wallet functionality.
use namada_sdk::borsh::BorshDeserialize;
use namada_sdk::{ExtendedViewingKey as NamadaExtendedViewingKey, ExtendedSpendingKey as NamadaExtendedSpendingKey, PaymentAddress as NamadaPaymentAddress};
use namada_sdk::masp_primitives::{sapling, zip32};
use namada_sdk::{
ExtendedSpendingKey as NamadaExtendedSpendingKey,
ExtendedViewingKey as NamadaExtendedViewingKey, PaymentAddress as NamadaPaymentAddress,
};
use thiserror::Error;
use wasm_bindgen::prelude::*;

Expand All @@ -23,13 +26,13 @@ pub struct ExtendedViewingKey(pub(crate) NamadaExtendedViewingKey);
impl ExtendedViewingKey {
/// Instantiate ExtendedViewingKey from serialized vector
#[wasm_bindgen(constructor)]
pub fn new(key: &[u8]) -> Result<ExtendedViewingKey, String> {
let xfvk: zip32::ExtendedFullViewingKey = BorshDeserialize::try_from_slice(key)
pub fn new(xfvk_bytes: &[u8]) -> Result<ExtendedViewingKey, String> {
let xfvk: zip32::ExtendedFullViewingKey = BorshDeserialize::try_from_slice(xfvk_bytes)
.map_err(|err| format!("{}: {:?}", MaspError::BorshDeserialize, err))?;

let vk = NamadaExtendedViewingKey::from(xfvk);
let xvk = NamadaExtendedViewingKey::from(xfvk);

Ok(ExtendedViewingKey(vk))
Ok(ExtendedViewingKey(xvk))
}

/// Return ExtendedViewingKey as Bech32-encoded String
Expand All @@ -47,8 +50,8 @@ pub struct ExtendedSpendingKey(pub(crate) NamadaExtendedSpendingKey);
impl ExtendedSpendingKey {
/// Instantiate ExtendedSpendingKey from serialized vector
#[wasm_bindgen(constructor)]
pub fn new(key: &[u8]) -> Result<ExtendedSpendingKey, String> {
let xsk: zip32::ExtendedSpendingKey = BorshDeserialize::try_from_slice(key)
pub fn new(xsk_bytes: &[u8]) -> Result<ExtendedSpendingKey, String> {
let xsk: zip32::ExtendedSpendingKey = BorshDeserialize::try_from_slice(xsk_bytes)
.map_err(|err| format!("{}: {:?}", MaspError::BorshDeserialize, err))?;

let xsk = NamadaExtendedSpendingKey::from(xsk);
Expand Down

0 comments on commit 5fb6556

Please sign in to comment.