ledger_ethereum/command/
get_app_configuration.rs1use ledger_transport::{APDUCommand, Exchange};
2use ledger_zondax_generic::App;
3
4use crate::command::InstructionCode;
5use crate::types::EthError;
6use crate::{EthApp, LedgerAppError};
7
8#[derive(Debug)]
9pub struct AppConfiguration {
10 pub arbitrary_data_enabled: bool,
11 pub erc20_provisioning_necessary: bool,
12 pub stark_enabled: bool,
13 pub stark_v2_supported: bool,
14 pub version: String,
15}
16
17impl<E> EthApp<E>
18where
19 E: Exchange + Send + Sync,
20 E::Error: std::error::Error,
21{
22 pub async fn configuration(&self) -> Result<AppConfiguration, EthError<E::Error>> {
25 let command = APDUCommand {
26 cla: Self::CLA,
27 ins: InstructionCode::GetAppConfiguration as u8,
28 p1: 0,
29 p2: 0,
30 data: vec![],
31 };
32 let response = self
33 .transport
34 .exchange(&command)
35 .await
36 .map_err(LedgerAppError::TransportError)?;
37 let response_data = response.data();
38
39 Ok(AppConfiguration {
40 arbitrary_data_enabled: response_data[0] & 0x01 == 0x01,
41 erc20_provisioning_necessary: response_data[0] & 0x02 == 0x02,
42 stark_enabled: response_data[0] & 0x04 == 0x04,
43 stark_v2_supported: response_data[0] & 0x08 == 0x08,
44 version: format!(
45 "{}.{}.{}",
46 response_data[1], response_data[2], response_data[3]
47 ),
48 })
49 }
50}