Skip to content

Commit

Permalink
[PLA-2047] Fixes derivation for integers values (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardocustodio authored Oct 21, 2024
1 parent bca5211 commit 28c4e13
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
17 changes: 7 additions & 10 deletions src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,14 +209,6 @@ impl TransactionJob {
.collect())
}
}
//
// #[derive(AsyncIncremental, PartialEq, Eq, Debug)]
// struct Nonce(u64);
//
// struct EnjinWallet {
// nonce: Nonce,
// players_nonce: Mutex<LruCache<DeriveJunction, Nonce>>,
// }

pub struct TransactionProcessor {
chain_client: Arc<OnlineClient<PolkadotConfig>>,
Expand Down Expand Up @@ -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::<i64>() {
Ok(id) => DeriveJunction::soft(id),
Err(_) => DeriveJunction::soft(external_id),
};

keypair.derive([derive_junction])
} else {
keypair
};
Expand Down
8 changes: 7 additions & 1 deletion src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<i64>() {
Ok(_) => DeriveJunction::soft(external_id.parse::<i64>().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,
Expand Down

0 comments on commit 28c4e13

Please sign in to comment.