Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
smartgoo committed Jun 20, 2024
1 parent 88e223d commit 8812a6c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
7 changes: 3 additions & 4 deletions wallet/keys/src/privkeygen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ impl PrivateKeyGenerator {
}
}

// CV-NOTE: pyo3 #[new] needs to be in block that has #[pymethods] applied directly
// NOTE: pyo3 #[new] needs to be in block that has #[pymethods] applied directly
#[cfg(feature = "py-sdk")]
#[pymethods]
impl PrivateKeyGenerator {
#[new]
pub fn new_py(xprv: String, is_multisig: bool, account_index: u64, cosigner_index: Option<u32>) -> Result<PrivateKeyGenerator> {
// CV-NOTE: accepting xprv as String instead of XPrvT due to challenges with XPrvT type when building python interface
// NOTE: accepting xprv as String instead of XPrvT due to challenges with XPrvT type when building python interface
let xprv = XPrv::from_xprv_str(xprv)?;
let xprv = xprv.inner();
let receive = xprv.clone().derive_path(&WalletDerivationManager::build_derivate_path(
Expand All @@ -69,19 +69,18 @@ impl PrivateKeyGenerator {
}
}

// NOTE: Temporarily changed return type of these from Result<PrivateKey> to Result<String> to demo shared fns
#[cfg_attr(feature = "py-sdk", pymethods)]
#[wasm_bindgen]
impl PrivateKeyGenerator {
#[wasm_bindgen(js_name=receiveKey)]
pub fn receive_key(&self, index: u32) -> Result<String> {
// CV-NOTE: Temporarily changed return type from Result<PrivateKey> to Result<String> to demo shared fn
let xkey = self.receive.derive_child(ChildNumber::new(index, false)?)?;
Ok(PrivateKey::from(xkey.private_key()).to_hex())
}

#[wasm_bindgen(js_name=changeKey)]
pub fn change_key(&self, index: u32) -> Result<String> {
// CV-NOTE: Temporarily changed return type from Result<PrivateKey> to Result<String> to demo shared fn
let xkey = self.change.derive_child(ChildNumber::new(index, false)?)?;
Ok(PrivateKey::from(xkey.private_key()).to_hex())
}
Expand Down
2 changes: 1 addition & 1 deletion wallet/keys/src/pubkeygen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl PublicKeyGenerator {
Ok(Self { hd_wallet })
}

// CV-NOTE: commented out temporarily as this uses XPrvT
// NOTE: commented out temporarily as this uses XPrvT
// #[wasm_bindgen(js_name=fromMasterXPrv)]
// pub fn from_master_xprv(
// xprv: &XPrvT,
Expand Down
11 changes: 6 additions & 5 deletions wallet/keys/src/xprv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,11 @@ impl<'a> From<&'a XPrv> for &'a ExtendedPrivateKey<SecretKey> {
}
}

/* CV-NOTE:
- Nelow is what I was testing. commented out because...
- It worked when building wasm modules (wasm/build-release, etc)
- Did not work when building python module (x-python/build-dev). #[wasm_bindgen] was not being applied to XPrvT.
/* NOTE:
This cfg_if is commented out because...
- It worked when building WASM modules (wasm/build-release, etc)
- Does not work when building Python module (x-python/build-dev). wasm_bindgen is applied by default to PrivateKeyGenerator
- Changed fn exposed to Python (PrivateKeyGenerator::new) to accept String instead
*/
// cfg_if::cfg_if! {
// if #[cfg(feature = "py-sdk")] {
Expand All @@ -96,7 +97,7 @@ impl<'a> From<&'a XPrv> for &'a ExtendedPrivateKey<SecretKey> {
// }
// }

// CV-NOTE: see comment on block above
// NOTE: see comment on block above
#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(typescript_type = "XPrv | string")]
Expand Down

0 comments on commit 8812a6c

Please sign in to comment.