parent
7d39da8213
commit
ad5a9b3131
3 changed files with 47 additions and 9 deletions
|
@ -83,7 +83,7 @@ pub fn demo_confirmation_menu() {
|
||||||
creation_time: 1687457923,
|
creation_time: 1687457923,
|
||||||
cancel: "Cancel".to_owned(),
|
cancel: "Cancel".to_owned(),
|
||||||
accept: "Confirm".to_owned(),
|
accept: "Confirm".to_owned(),
|
||||||
icon: "".to_owned(),
|
icon: Some("".to_owned()),
|
||||||
multi: false,
|
multi: false,
|
||||||
summary: vec![],
|
summary: vec![],
|
||||||
},
|
},
|
||||||
|
@ -97,7 +97,7 @@ pub fn demo_confirmation_menu() {
|
||||||
creation_time: 1687457923,
|
creation_time: 1687457923,
|
||||||
cancel: "Cancel".to_owned(),
|
cancel: "Cancel".to_owned(),
|
||||||
accept: "Confirm".to_owned(),
|
accept: "Confirm".to_owned(),
|
||||||
icon: "".to_owned(),
|
icon: Some("".to_owned()),
|
||||||
multi: false,
|
multi: false,
|
||||||
summary: vec![],
|
summary: vec![],
|
||||||
},
|
},
|
||||||
|
|
|
@ -13,7 +13,7 @@ pub struct Confirmation {
|
||||||
pub creation_time: u64,
|
pub creation_time: u64,
|
||||||
pub cancel: String,
|
pub cancel: String,
|
||||||
pub accept: String,
|
pub accept: String,
|
||||||
pub icon: String,
|
pub icon: Option<String>,
|
||||||
pub multi: bool,
|
pub multi: bool,
|
||||||
pub headline: String,
|
pub headline: String,
|
||||||
pub summary: Vec<String>,
|
pub summary: Vec<String>,
|
||||||
|
@ -38,6 +38,7 @@ pub enum ConfirmationType {
|
||||||
Generic = 1,
|
Generic = 1,
|
||||||
Trade = 2,
|
Trade = 2,
|
||||||
MarketSell = 3,
|
MarketSell = 3,
|
||||||
|
AccountDetails = 5,
|
||||||
AccountRecovery = 6,
|
AccountRecovery = 6,
|
||||||
Unknown(u32),
|
Unknown(u32),
|
||||||
}
|
}
|
||||||
|
@ -70,15 +71,30 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_email_change() -> anyhow::Result<()> {
|
fn test_parse_confirmations() -> anyhow::Result<()> {
|
||||||
let text = include_str!("fixtures/confirmations/email-change.json");
|
struct Test {
|
||||||
let confirmations = serde_json::from_str::<ConfirmationListResponse>(text)?;
|
text: &'static str,
|
||||||
|
confirmation_type: ConfirmationType,
|
||||||
|
}
|
||||||
|
let cases = [
|
||||||
|
Test {
|
||||||
|
text: include_str!("fixtures/confirmations/email-change.json"),
|
||||||
|
confirmation_type: ConfirmationType::AccountRecovery,
|
||||||
|
},
|
||||||
|
Test {
|
||||||
|
text: include_str!("fixtures/confirmations/phone-number-change.json"),
|
||||||
|
confirmation_type: ConfirmationType::AccountDetails,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
for case in cases.iter() {
|
||||||
|
let confirmations = serde_json::from_str::<ConfirmationListResponse>(case.text)?;
|
||||||
|
|
||||||
assert_eq!(confirmations.conf.len(), 1);
|
assert_eq!(confirmations.conf.len(), 1);
|
||||||
|
|
||||||
let confirmation = &confirmations.conf[0];
|
let confirmation = &confirmations.conf[0];
|
||||||
|
|
||||||
assert_eq!(confirmation.conf_type, ConfirmationType::AccountRecovery);
|
assert_eq!(confirmation.conf_type, case.confirmation_type);
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"conf": [
|
||||||
|
{
|
||||||
|
"type": 5,
|
||||||
|
"type_name": "Account details",
|
||||||
|
"id": "13831364158",
|
||||||
|
"creator_id": "4486196268090979848",
|
||||||
|
"nonce": "11118003665658287603",
|
||||||
|
"creation_time": 1687821676,
|
||||||
|
"cancel": "Cancel",
|
||||||
|
"accept": "Confirm",
|
||||||
|
"icon": null,
|
||||||
|
"multi": false,
|
||||||
|
"headline": "Change phone number",
|
||||||
|
"summary": [
|
||||||
|
""
|
||||||
|
],
|
||||||
|
"warn": null
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in a new issue