From 28c4e1334525adae4fdd26d4e7ee98d2c1236c1b Mon Sep 17 00:00:00 2001 From: Leonardo Custodio Date: Sun, 20 Oct 2024 22:16:54 -0300 Subject: [PATCH] [PLA-2047] Fixes derivation for integers values (#38) --- src/transaction.rs | 17 +++++++---------- src/wallet.rs | 8 +++++++- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/transaction.rs b/src/transaction.rs index 98d5b08..8586c78 100644 --- a/src/transaction.rs +++ b/src/transaction.rs @@ -209,14 +209,6 @@ impl TransactionJob { .collect()) } } -// -// #[derive(AsyncIncremental, PartialEq, Eq, Debug)] -// struct Nonce(u64); -// -// struct EnjinWallet { -// nonce: Nonce, -// players_nonce: Mutex>, -// } pub struct TransactionProcessor { chain_client: Arc>, @@ -385,8 +377,13 @@ impl TransactionProcessor { payload, }: TransactionRequest, ) { - let signer = if external_id.is_some() { - keypair.derive([DeriveJunction::soft(external_id.unwrap())]) + let signer = if let Some(external_id) = external_id { + let derive_junction = match external_id.parse::() { + Ok(id) => DeriveJunction::soft(id), + Err(_) => DeriveJunction::soft(external_id), + }; + + keypair.derive([derive_junction]) } else { keypair }; diff --git a/src/wallet.rs b/src/wallet.rs index 54b17e7..90fb030 100644 --- a/src/wallet.rs +++ b/src/wallet.rs @@ -206,8 +206,14 @@ impl DeriveWalletProcessor { managed: _, }: DeriveWalletRequest, ) { - let derived_pair = keypair.derive([DeriveJunction::soft(external_id.clone())]); + let derive_junction = match external_id.parse::() { + Ok(_) => DeriveJunction::soft(external_id.parse::().unwrap()), + Err(_) => DeriveJunction::soft(external_id.clone()), + }; + + let derived_pair = keypair.derive([derive_junction]); let derived_key = hex::encode(derived_pair.public_key().0); + platform_client::set_wallet_account( client, platform_url,