@@ -257,7 +257,7 @@ fn encode_value(typ: &MemberType, value: Vec<u8>) -> Result<(Vec<u8>, String), E
257
257
)
258
258
}
259
259
DataType :: String => {
260
- if !util:: ascii:: is_printable_ascii ( & value, util:: ascii:: Charset :: All ) {
260
+ if !util:: ascii:: is_printable_ascii ( & value, util:: ascii:: Charset :: AllNewline ) {
261
261
return Err ( Error :: InvalidInput ) ;
262
262
}
263
263
(
@@ -312,18 +312,30 @@ async fn encode_member<U: sha3::digest::Update>(
312
312
} else {
313
313
let value = get_value_from_host ( root_object, path) . await ?;
314
314
let ( value_encoded, value_formatted) = encode_value ( member_type, value) ?;
315
- confirm:: confirm ( & confirm:: Params {
316
- title : & format ! (
317
- "{}{}" ,
318
- confirm_title( root_object) ,
319
- title_suffix. as_deref( ) . unwrap_or( "" )
320
- ) ,
321
- body : & format ! ( "{}: {}" , formatted_path. join( "." ) , value_formatted) ,
322
- scrollable : true ,
323
- accept_is_nextarrow : true ,
324
- ..Default :: default ( )
325
- } )
326
- . await ?;
315
+ let lines: Vec < & str > = value_formatted. split ( '\n' ) . collect ( ) ;
316
+ for ( i, & line) in lines. iter ( ) . enumerate ( ) {
317
+ confirm:: confirm ( & confirm:: Params {
318
+ title : & format ! (
319
+ "{}{}" ,
320
+ confirm_title( root_object) ,
321
+ title_suffix. as_deref( ) . unwrap_or( "" )
322
+ ) ,
323
+ body : & format ! (
324
+ "{}{}: {}" ,
325
+ formatted_path. join( "." ) ,
326
+ if lines. len( ) > 1 {
327
+ format!( ", line {}/{}" , i + 1 , lines. len( ) )
328
+ } else {
329
+ "" . into( )
330
+ } ,
331
+ line
332
+ ) ,
333
+ scrollable : true ,
334
+ accept_is_nextarrow : true ,
335
+ ..Default :: default ( )
336
+ } )
337
+ . await ?;
338
+ }
327
339
hasher. update ( & value_encoded) ;
328
340
}
329
341
Ok ( ( ) )
@@ -1031,7 +1043,7 @@ mod tests {
1031
1043
/// str: 'str',
1032
1044
/// emptyArray: [],
1033
1045
/// name_address: '0xa21A16EC22a940990922220E4ab5bF4C2310F556',
1034
- /// name_string: ['', 'a', 'aa', '|@#!$', 'long long long long long long long long'],
1046
+ /// name_string: ['', 'a', 'aa', '|@#!$', 'long long long long long long long long', 'multi\n\nline' ],
1035
1047
/// name_bytes: ['', '0xaabbcc'],
1036
1048
/// name_bytes1: '0xaa',
1037
1049
/// name_bytes10: '0x112233445566778899aa',
@@ -1069,12 +1081,15 @@ mod tests {
1069
1081
( "Message (1/23)" , "str: str" ) ,
1070
1082
( "Message (2/23)" , "emptyArray: (empty list)" ) ,
1071
1083
( "Message (3/23)" , "name_address: 0xa21A16EC22a940990922220E4ab5bF4C2310F556" ) ,
1072
- ( "Message (4/23)" , "name_string: list with 5 elements" ) ,
1073
- ( "Message (4/23)" , "name_string[1/5]: " ) ,
1074
- ( "Message (4/23)" , "name_string[2/5]: a" ) ,
1075
- ( "Message (4/23)" , "name_string[3/5]: aa" ) ,
1076
- ( "Message (4/23)" , "name_string[4/5]: |@#!$" ) ,
1077
- ( "Message (4/23)" , "name_string[5/5]: long long long long long long long long" ) ,
1084
+ ( "Message (4/23)" , "name_string: list with 6 elements" ) ,
1085
+ ( "Message (4/23)" , "name_string[1/6]: " ) ,
1086
+ ( "Message (4/23)" , "name_string[2/6]: a" ) ,
1087
+ ( "Message (4/23)" , "name_string[3/6]: aa" ) ,
1088
+ ( "Message (4/23)" , "name_string[4/6]: |@#!$" ) ,
1089
+ ( "Message (4/23)" , "name_string[5/6]: long long long long long long long long" ) ,
1090
+ ( "Message (4/23)" , "name_string[6/6], line 1/3: multi" ) ,
1091
+ ( "Message (4/23)" , "name_string[6/6], line 2/3: " ) ,
1092
+ ( "Message (4/23)" , "name_string[6/6], line 3/3: line" ) ,
1078
1093
( "Message (5/23)" , "name_bytes: list with 2 elements" ) ,
1079
1094
( "Message (5/23)" , "name_bytes[1/2]: 0x" ) ,
1080
1095
( "Message (5/23)" , "name_bytes[2/2]: 0xaabbcc" ) ,
@@ -1252,6 +1267,7 @@ mod tests {
1252
1267
Object :: String ( "aa" ) ,
1253
1268
Object :: String ( "|@#!$" ) ,
1254
1269
Object :: String ( "long long long long long long long long" ) ,
1270
+ Object :: String ( "multi\n \n line" ) ,
1255
1271
] ) ,
1256
1272
// name_bytes
1257
1273
Object :: List ( vec![ Object :: Bytes ( b"" ) , Object :: Bytes ( b"\xaa \xbb \xcc " ) ] ) ,
@@ -1404,7 +1420,7 @@ mod tests {
1404
1420
let sighash = block_on ( eip712_sighash ( & typed_msg. types , typed_msg. primary_type ) ) . unwrap ( ) ;
1405
1421
assert_eq ! (
1406
1422
sighash,
1407
- * b"\xc5 \x4f \xa7 \x87 \x13 \x18 \xb6 \xc2 \xd8 \x71 \x62 \xde \xbe \xff \x4c \xdf \x13 \ xf2\x85 \x45 \x12 \xf3 \x43 \x6a \x04 \xa6 \x0c \xd1 \xa7 \xcf \x47 \xc5 " ,
1423
+ * b"\x0e \xfe \x31 \xa8 \x81 \x9b \x6c \x38 \x1c \x9e \x97 \xcf \xd2 \x99 \x5a \xa6 \ xf2\x1e \x4a \x72 \x87 \x9a \xc1 \x31 \xb2 \xf6 \x48 \xd0 \x83 \x28 \x1c \x83 " ,
1408
1424
) ;
1409
1425
assert_eq ! ( unsafe { UI_COUNTER } , EXPECTED_DIALOGS . len( ) ) ;
1410
1426
}
0 commit comments