Skip to content

Commit

Permalink
Fix account deserilization error
Browse files Browse the repository at this point in the history
  • Loading branch information
JesseAbram committed May 13, 2024
1 parent 89255ad commit 9f844ee
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ pub async fn proactive_refresh(
key,
value: serialized_key_share,
proactive_refresh: true,
sig_request_address: None,
};

app_state.kv_store.kv().delete(&new_key_info.key).await?;
Expand Down
7 changes: 5 additions & 2 deletions crates/threshold-signature-server/src/user/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ pub struct UserRegistrationInfo {
pub value: Vec<u8>,
/// Is this a proactive refresh message
pub proactive_refresh: bool,
pub sig_request_address: Option<SubxtAccountId32>,
}

/// Type that gets stored for request limit checks
Expand Down Expand Up @@ -331,6 +332,7 @@ async fn setup_dkg(
key: string_verifying_key,
value: serialized_key_share,
proactive_refresh: false,
sig_request_address: Some(sig_request_address.clone()),
};
send_key(
&api,
Expand Down Expand Up @@ -414,8 +416,9 @@ pub async fn receive_key(
let registering = is_registering(
&api,
&rpc,
&SubxtAccountId32::from_str(&user_registration_info.key)
.map_err(|_| UserErr::StringError("Account Conversion"))?,
&user_registration_info.sig_request_address.ok_or_else(|| {
UserErr::OptionUnwrapError("Failed to unwrap account".to_string())
})?,
)
.await?;

Expand Down
5 changes: 5 additions & 0 deletions crates/threshold-signature-server/src/user/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,7 @@ async fn test_send_and_receive_keys() {

let alice = AccountKeyring::Alice;
let program_manager = AccountKeyring::Dave;
let signature_request_account = subxtAccountId32(alice.pair().public().0);

let cxt = test_context_stationary().await;
setup_client().await;
Expand All @@ -805,6 +806,7 @@ async fn test_send_and_receive_keys() {
key: alice.to_account_id().to_string(),
value: share.clone(),
proactive_refresh: false,
sig_request_address: Some(signature_request_account.clone()),
};

let (signer_alice, _) = get_signer_and_x25519_secret_from_mnemonic(DEFAULT_MNEMONIC).unwrap();
Expand Down Expand Up @@ -888,6 +890,7 @@ async fn test_send_and_receive_keys() {
key: alice.to_account_id().to_string(),
value: some_other_share.clone(),
proactive_refresh: false,
sig_request_address: Some(signature_request_account.clone()),
};

let signed_message = serde_json::to_string(
Expand Down Expand Up @@ -929,6 +932,7 @@ async fn test_send_and_receive_keys() {
key: "MNEMONIC".to_string(),
value: share.clone(),
proactive_refresh: false,
sig_request_address: Some(signature_request_account.clone()),
};

let signed_message = serde_json::to_string(
Expand Down Expand Up @@ -958,6 +962,7 @@ async fn test_send_and_receive_keys() {
key: alice.to_account_id().to_string(),
value: b"This will not deserialize to KeyShare<KeyParams>".to_vec(),
proactive_refresh: false,
sig_request_address: Some(signature_request_account.clone()),
};

let signed_message = serde_json::to_string(
Expand Down

0 comments on commit 9f844ee

Please sign in to comment.