Skip to content

Commit 9213bdc

Browse files
committed
add from/to path
1 parent 1517f74 commit 9213bdc

38 files changed

+795
-815
lines changed

rust/apps/avalanche/src/constants.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ pub const C_CHAIN_ADDRESS_LEN: usize = 20;
88
pub const ASSET_ID_LEN: usize = 32;
99
pub const ADDRESS_LEN: usize = 20;
1010
pub const NAVAX_TO_AVAX_RATIO: f64 = 1_000_000_000.0;
11+
pub const C_CHAIN_PREFIX: &str = "m/44'/60'/0'";
12+
pub const X_P_CHAIN_PREFIX: &str = "m/44'/9000'/0'";
1113

1214
pub const X_BLOCKCHAIN_ID: [u8; BLOCKCHAIN_ID_LEN] = [
1315
237, 95, 56, 52, 30, 67, 110, 93, 70, 226, 187, 0, 180, 93, 98, 174, 151, 209, 176, 80, 198,

rust/apps/avalanche/src/transactions/C_chain/evm_export.rs

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ impl AvaxTxInfo for ExportTx {
8383
AvaxFromToInfo::from(
8484
format!("{} AVAX", output.get_amount() as f64 / NAVAX_TO_AVAX_RATIO),
8585
output.get_addresses(),
86+
C_CHAIN_PREFIX.to_string(),
8687
)
8788
})
8889
.collect()

rust/apps/avalanche/src/transactions/C_chain/evm_import.rs

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ impl AvaxTxInfo for ImportTx {
7272
AvaxFromToInfo::from(
7373
format!("{} AVAX", output.amount as f64 / NAVAX_TO_AVAX_RATIO),
7474
vec![output.address.encode()],
75+
C_CHAIN_PREFIX.to_string(),
7576
)
7677
})
7778
.collect()

rust/apps/avalanche/src/transactions/P_chain/add_permissionless_delegator.rs

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ impl AvaxTxInfo for AddPermissLessionDelegatorTx {
4646
AvaxFromToInfo::from(
4747
format!("{} AVAX", output.get_amount() as f64 / NAVAX_TO_AVAX_RATIO),
4848
output.get_addresses(),
49+
X_P_CHAIN_PREFIX.to_string(),
4950
)
5051
}))
5152
.collect()

rust/apps/avalanche/src/transactions/P_chain/add_permissionless_validator.rs

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ impl AvaxTxInfo for AddPermissLessionValidatorTx {
5050
AvaxFromToInfo::from(
5151
format!("{} AVAX", output.get_amount() as f64 / NAVAX_TO_AVAX_RATIO),
5252
output.get_addresses(),
53+
X_P_CHAIN_PREFIX.to_string(),
5354
)
5455
}))
5556
.collect()

rust/apps/avalanche/src/transactions/base_tx.rs

+1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ impl AvaxTxInfo for BaseTx {
9595
AvaxFromToInfo::from(
9696
format!("{} AVAX", output.get_amount() as f64 / NAVAX_TO_AVAX_RATIO),
9797
output.get_addresses(),
98+
X_P_CHAIN_PREFIX.to_string(),
9899
)
99100
})
100101
.collect()

rust/apps/avalanche/src/transactions/export.rs

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ impl AvaxTxInfo for ExportTx {
3939
AvaxFromToInfo::from(
4040
format!("{} AVAX", output.get_amount() as f64 / NAVAX_TO_AVAX_RATIO),
4141
output.get_addresses(),
42+
X_P_CHAIN_PREFIX.to_string(),
4243
)
4344
}))
4445
.collect()

rust/apps/avalanche/src/transactions/structs.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,15 @@ impl AvaxMethodInfo {
128128
pub struct AvaxFromToInfo {
129129
pub amount: String,
130130
pub address: Vec<String>,
131+
pub path_prefix: String,
131132
}
132133

133134
impl AvaxFromToInfo {
134-
pub fn from(amount: String, address: Vec<String>) -> Self {
135-
AvaxFromToInfo { amount, address }
135+
pub fn from(amount: String, address: Vec<String>, path_prefix: String) -> Self {
136+
AvaxFromToInfo {
137+
amount,
138+
address,
139+
path_prefix,
140+
}
136141
}
137142
}

rust/rust_c/src/avalanche/mod.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ use alloc::{
2222
};
2323
use app_avalanche::{
2424
constants::{
25-
C_BLOCKCHAIN_ID, C_TEST_BLOCKCHAIN_ID, P_BLOCKCHAIN_ID, X_BLOCKCHAIN_ID,
26-
X_TEST_BLOCKCHAIN_ID,
25+
C_BLOCKCHAIN_ID, C_CHAIN_PREFIX, C_TEST_BLOCKCHAIN_ID, P_BLOCKCHAIN_ID, X_BLOCKCHAIN_ID,
26+
X_P_CHAIN_PREFIX, X_TEST_BLOCKCHAIN_ID,
2727
},
2828
errors::AvaxError,
2929
get_avax_tx_header, get_avax_tx_type_id, parse_avax_tx,
@@ -48,10 +48,6 @@ use {
4848
traits::RegistryItem,
4949
},
5050
};
51-
52-
const C_CHAIN_PREFIX: &str = "m/44'/60'/0'";
53-
const X_P_CHAIN_PREFIX: &str = "m/44'/9000'/0'";
54-
5551
#[derive(Debug, Clone)]
5652
pub struct DerivationPath {
5753
pub base_path: String,
@@ -103,9 +99,13 @@ fn parse_transaction_by_type(
10399
parse_avax_tx::<$tx_type>(tx_data)
104100
.map(|parse_data| {
105101
TransactionParseResult::success(
106-
DisplayAvaxTx::from(parse_data)
107-
.with_from_address(address.to_string(), path.full_path.to_string())
108-
.c_ptr(),
102+
DisplayAvaxTx::from_tx_info(
103+
parse_data,
104+
path.full_path,
105+
address,
106+
sign_request.get_wallet_index(),
107+
)
108+
.c_ptr(),
109109
)
110110
.c_ptr()
111111
})

rust/rust_c/src/avalanche/structs.rs

+22-23
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ impl Free for DisplayAvaxFromToInfo {
6767

6868
impl_c_ptr!(DisplayAvaxFromToInfo);
6969

70-
impl From<&AvaxFromToInfo> for DisplayAvaxFromToInfo {
71-
fn from(value: &AvaxFromToInfo) -> Self {
70+
impl DisplayAvaxFromToInfo {
71+
fn from_index(value: &AvaxFromToInfo, wallet_index: u64) -> Self {
7272
DisplayAvaxFromToInfo {
7373
address: convert_c_char(value.address.get(0).unwrap().clone()),
7474
amount: convert_c_char(value.amount.clone()),
75-
path: convert_c_char("".to_string()),
75+
path: convert_c_char(format!("{}/0/{}", value.path_prefix, wallet_index)),
7676
}
7777
}
7878
}
@@ -107,36 +107,35 @@ impl From<AvaxMethodInfo> for DisplayAvaxMethodInfo {
107107
}
108108
}
109109

110-
impl<T: AvaxTxInfo> From<T> for DisplayAvaxTx {
111-
fn from(value: T) -> Self {
112-
DisplayAvaxTx {
113-
data: DisplayTxAvaxData::from(value).c_ptr(),
114-
}
115-
}
116-
}
117-
118110
impl DisplayAvaxTx {
119-
pub fn with_from_address(mut self, address: String, path: String) -> Self {
120-
unsafe {
121-
let data = &mut *self.data;
122-
let from = &mut *data.from;
123-
from.address = convert_c_char(address);
124-
from.path = convert_c_char(path);
111+
pub fn from_tx_info<T: AvaxTxInfo>(
112+
value: T,
113+
from_path: String,
114+
from_address: String,
115+
wallet_index: u64,
116+
) -> Self {
117+
DisplayAvaxTx {
118+
data: DisplayTxAvaxData::from_tx_info(value, from_path, from_address, wallet_index)
119+
.c_ptr(),
125120
}
126-
self
127121
}
128122
}
129123

130-
impl<T: AvaxTxInfo> From<T> for DisplayTxAvaxData {
131-
fn from(value: T) -> Self {
124+
impl DisplayTxAvaxData {
125+
fn from_tx_info<T: AvaxTxInfo>(
126+
value: T,
127+
from_path: String,
128+
from_address: String,
129+
wallet_index: u64,
130+
) -> Self {
132131
DisplayTxAvaxData {
133132
from: DisplayAvaxFromToInfo {
134-
address: convert_c_char("".to_string()),
133+
address: convert_c_char(from_address),
135134
amount: convert_c_char(format!(
136135
"{} AVAX",
137136
value.get_total_input_amount() as f64 / NAVAX_TO_AVAX_RATIO
138137
)),
139-
path: convert_c_char("".to_string()),
138+
path: convert_c_char(from_path),
140139
}
141140
.c_ptr(),
142141
total_input_amount: convert_c_char(format!(
@@ -155,7 +154,7 @@ impl<T: AvaxTxInfo> From<T> for DisplayTxAvaxData {
155154
value
156155
.get_outputs_addresses()
157156
.iter()
158-
.map(|v| DisplayAvaxFromToInfo::from(v))
157+
.map(|v| DisplayAvaxFromToInfo::from_index(v, wallet_index))
159158
.collect::<Vec<DisplayAvaxFromToInfo>>(),
160159
)
161160
.c_ptr(),

src/ui/gui_analyze/gui_resolve_ur.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ static SetChainData_t g_chainViewArray[] = {
5858

5959
void HandleDefaultViewType(URParseResult *urResult, URParseMultiResult *urMultiResult, UrViewType_t urViewType, bool is_multi)
6060
{
61-
printf("%s %d.\n", __func__,__LINE__);
61+
printf("%s %d.\n", __func__, __LINE__);
6262
GuiRemapViewType viewType = ViewTypeReMap(urViewType.viewType);
63-
printf("%s %d.\n", __func__,__LINE__);
63+
printf("%s %d.\n", __func__, __LINE__);
6464
printf("viewType=%d\r\n", viewType);
6565
for (int i = 0; i < NUMBER_OF_ARRAYS(g_chainViewArray); i++) {
6666
if (g_chainViewArray[i].chain == viewType) {
67-
printf("%s %d.\n", __func__,__LINE__);
67+
printf("%s %d.\n", __func__, __LINE__);
6868
printf("g_chainViewArray[i].type=%d\r\n", g_chainViewArray[i].chain);
6969
g_chainViewArray[viewType].func(urResult, urMultiResult, is_multi);
7070
break;

src/ui/gui_assets/font/cn/cnIllustrate.c

+5-10
Original file line numberDiff line numberDiff line change
@@ -10228,8 +10228,7 @@ static const uint16_t unicode_list_1[] = {
1022810228
};
1022910229

1023010230
/*Collect the unicode lists and glyph_id offsets*/
10231-
static const lv_font_fmt_txt_cmap_t cmaps[] =
10232-
{
10231+
static const lv_font_fmt_txt_cmap_t cmaps[] = {
1023310232
{
1023410233
.range_start = 32, .range_length = 95, .glyph_id_start = 1,
1023510234
.unicode_list = NULL, .glyph_id_ofs_list = NULL, .list_length = 0, .type = LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY
@@ -10246,8 +10245,7 @@ static const lv_font_fmt_txt_cmap_t cmaps[] =
1024610245

1024710246

1024810247
/*Map glyph_ids to kern left classes*/
10249-
static const uint8_t kern_left_class_mapping[] =
10250-
{
10248+
static const uint8_t kern_left_class_mapping[] = {
1025110249
0, 0, 0, 1, 0, 0, 0, 0,
1025210250
1, 2, 0, 0, 0, 3, 4, 3,
1025310251
5, 0, 0, 0, 0, 0, 0, 0,
@@ -10344,8 +10342,7 @@ static const uint8_t kern_left_class_mapping[] =
1034410342
};
1034510343

1034610344
/*Map glyph_ids to kern right classes*/
10347-
static const uint8_t kern_right_class_mapping[] =
10348-
{
10345+
static const uint8_t kern_right_class_mapping[] = {
1034910346
0, 0, 1, 2, 0, 0, 0, 0,
1035010347
2, 0, 3, 4, 0, 5, 6, 7,
1035110348
8, 0, 0, 0, 0, 0, 0, 0,
@@ -10442,8 +10439,7 @@ static const uint8_t kern_right_class_mapping[] =
1044210439
};
1044310440

1044410441
/*Kern values between classes*/
10445-
static const int8_t kern_class_values[] =
10446-
{
10442+
static const int8_t kern_class_values[] = {
1044710443
0, 0, 0, 0, -42, 0, -42, 0,
1044810444
0, 0, 0, -20, 0, -35, -4, 0,
1044910445
0, 0, 0, -4, 0, 0, 0, 0,
@@ -10662,8 +10658,7 @@ static const int8_t kern_class_values[] =
1066210658

1066310659

1066410660
/*Collect the kern class' data in one place*/
10665-
static const lv_font_fmt_txt_kern_classes_t kern_classes =
10666-
{
10661+
static const lv_font_fmt_txt_kern_classes_t kern_classes = {
1066710662
.class_pair_values = kern_class_values,
1066810663
.left_class_mapping = kern_left_class_mapping,
1066910664
.right_class_mapping = kern_right_class_mapping,

src/ui/gui_assets/font/cn/cnLittleTitle.c

+5-10
Original file line numberDiff line numberDiff line change
@@ -3756,8 +3756,7 @@ static const uint16_t unicode_list_1[] = {
37563756
};
37573757

37583758
/*Collect the unicode lists and glyph_id offsets*/
3759-
static const lv_font_fmt_txt_cmap_t cmaps[] =
3760-
{
3759+
static const lv_font_fmt_txt_cmap_t cmaps[] = {
37613760
{
37623761
.range_start = 32, .range_length = 95, .glyph_id_start = 1,
37633762
.unicode_list = NULL, .glyph_id_ofs_list = NULL, .list_length = 0, .type = LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY
@@ -3774,8 +3773,7 @@ static const lv_font_fmt_txt_cmap_t cmaps[] =
37743773

37753774

37763775
/*Map glyph_ids to kern left classes*/
3777-
static const uint8_t kern_left_class_mapping[] =
3778-
{
3776+
static const uint8_t kern_left_class_mapping[] = {
37793777
0, 0, 0, 1, 0, 0, 0, 0,
37803778
1, 2, 0, 0, 0, 3, 4, 3,
37813779
5, 0, 0, 0, 0, 0, 0, 0,
@@ -3820,8 +3818,7 @@ static const uint8_t kern_left_class_mapping[] =
38203818
};
38213819

38223820
/*Map glyph_ids to kern right classes*/
3823-
static const uint8_t kern_right_class_mapping[] =
3824-
{
3821+
static const uint8_t kern_right_class_mapping[] = {
38253822
0, 0, 1, 2, 0, 0, 0, 0,
38263823
2, 0, 3, 4, 0, 5, 6, 7,
38273824
8, 0, 0, 0, 0, 0, 0, 0,
@@ -3866,8 +3863,7 @@ static const uint8_t kern_right_class_mapping[] =
38663863
};
38673864

38683865
/*Kern values between classes*/
3869-
static const int8_t kern_class_values[] =
3870-
{
3866+
static const int8_t kern_class_values[] = {
38713867
0, 0, 0, 0, -59, 0, -59, 0,
38723868
0, 0, 0, -28, 0, -48, -6, 0,
38733869
0, 0, 0, -6, 0, 0, 0, 0,
@@ -4086,8 +4082,7 @@ static const int8_t kern_class_values[] =
40864082

40874083

40884084
/*Collect the kern class' data in one place*/
4089-
static const lv_font_fmt_txt_kern_classes_t kern_classes =
4090-
{
4085+
static const lv_font_fmt_txt_kern_classes_t kern_classes = {
40914086
.class_pair_values = kern_class_values,
40924087
.left_class_mapping = kern_left_class_mapping,
40934088
.right_class_mapping = kern_right_class_mapping,

src/ui/gui_assets/font/cn/cnText.c

+5-10
Original file line numberDiff line numberDiff line change
@@ -6332,8 +6332,7 @@ static const uint16_t unicode_list_1[] = {
63326332
};
63336333

63346334
/*Collect the unicode lists and glyph_id offsets*/
6335-
static const lv_font_fmt_txt_cmap_t cmaps[] =
6336-
{
6335+
static const lv_font_fmt_txt_cmap_t cmaps[] = {
63376336
{
63386337
.range_start = 32, .range_length = 95, .glyph_id_start = 1,
63396338
.unicode_list = NULL, .glyph_id_ofs_list = NULL, .list_length = 0, .type = LV_FONT_FMT_TXT_CMAP_FORMAT0_TINY
@@ -6350,8 +6349,7 @@ static const lv_font_fmt_txt_cmap_t cmaps[] =
63506349

63516350

63526351
/*Map glyph_ids to kern left classes*/
6353-
static const uint8_t kern_left_class_mapping[] =
6354-
{
6352+
static const uint8_t kern_left_class_mapping[] = {
63556353
0, 0, 0, 1, 0, 0, 0, 0,
63566354
1, 2, 0, 0, 0, 3, 4, 3,
63576355
5, 0, 0, 0, 0, 0, 0, 0,
@@ -6402,8 +6400,7 @@ static const uint8_t kern_left_class_mapping[] =
64026400
};
64036401

64046402
/*Map glyph_ids to kern right classes*/
6405-
static const uint8_t kern_right_class_mapping[] =
6406-
{
6403+
static const uint8_t kern_right_class_mapping[] = {
64076404
0, 0, 1, 2, 0, 0, 0, 0,
64086405
2, 0, 3, 4, 0, 5, 6, 7,
64096406
8, 0, 0, 0, 0, 0, 0, 0,
@@ -6454,8 +6451,7 @@ static const uint8_t kern_right_class_mapping[] =
64546451
};
64556452

64566453
/*Kern values between classes*/
6457-
static const int8_t kern_class_values[] =
6458-
{
6454+
static const int8_t kern_class_values[] = {
64596455
0, 0, 0, 0, -50, 0, -50, 0,
64606456
0, 0, 0, -24, 0, -41, -5, 0,
64616457
0, 0, 0, -5, 0, 0, 0, 0,
@@ -6674,8 +6670,7 @@ static const int8_t kern_class_values[] =
66746670

66756671

66766672
/*Collect the kern class' data in one place*/
6677-
static const lv_font_fmt_txt_kern_classes_t kern_classes =
6678-
{
6673+
static const lv_font_fmt_txt_kern_classes_t kern_classes = {
66796674
.class_pair_values = kern_class_values,
66806675
.left_class_mapping = kern_left_class_mapping,
66816676
.right_class_mapping = kern_right_class_mapping,

0 commit comments

Comments
 (0)