This repository was archived by the owner on Nov 23, 2023. It is now read-only.
File tree 2 files changed +31
-3
lines changed
src/js/core/methods/helpers
2 files changed +31
-3
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,17 @@ export const parseArrayType = [
19
19
arraySize : null ,
20
20
} ,
21
21
} ,
22
+ {
23
+ // Decode last [] first
24
+ // Can't find an official source, but this is what Metamask's signTypedData_v4 does:
25
+ // https://github.com/MetaMask/eth-sig-util/blob/5f2259463990050606cd58b43e64e4bffcb715f4/src/sign-typed-data.ts#L202-L211
26
+ description : 'should parse nested arrays' ,
27
+ input : 'int32[5][12]' ,
28
+ output : {
29
+ entryTypeName : 'int32[5]' ,
30
+ arraySize : 12 ,
31
+ } ,
32
+ } ,
22
33
{
23
34
description : 'should throw error for non-array type' ,
24
35
input : 'bytes' ,
@@ -121,6 +132,26 @@ export const getFieldType = [
121
132
} ,
122
133
} ,
123
134
} ,
135
+ {
136
+ // Unsupported in Trezor firmware as of v2.4.3
137
+ description : 'should parse nested arrays' ,
138
+ input : {
139
+ typeName : 'int32[5][12]' ,
140
+ types : { } ,
141
+ } ,
142
+ output : {
143
+ data_type : Enum_EthereumDataType . ARRAY ,
144
+ size : 12 ,
145
+ entry_type : {
146
+ data_type : Enum_EthereumDataType . ARRAY ,
147
+ size : 5 ,
148
+ entry_type : {
149
+ data_type : Enum_EthereumDataType . INT ,
150
+ size : 4 ,
151
+ } ,
152
+ } ,
153
+ } ,
154
+ } ,
124
155
{
125
156
description : `should parse Struct types` ,
126
157
input : {
Original file line number Diff line number Diff line change @@ -146,9 +146,6 @@ export function getFieldType(
146
146
if ( arrayMatch ) {
147
147
const [ _ , arrayItemTypeName , arraySize ] = arrayMatch ;
148
148
const entryType = getFieldType ( arrayItemTypeName , types ) ;
149
- if ( entryType . data_type === Enum_EthereumDataType . ARRAY ) {
150
- throw ERRORS . TypedError ( 'Method_InvalidParameter' , 'Nested arrays are not supported' ) ;
151
- }
152
149
return {
153
150
data_type : Enum_EthereumDataType . ARRAY ,
154
151
size : parseInt ( arraySize , 10 ) || undefined ,
You can’t perform that action at this time.
0 commit comments