@@ -3,6 +3,7 @@ import * as starkCurve from '@scure/starknet';
3
3
import typedDataExample from '../../__mocks__/typedData/baseExample.json' ;
4
4
import exampleBaseTypes from '../../__mocks__/typedData/example_baseTypes.json' ;
5
5
import exampleEnum from '../../__mocks__/typedData/example_enum.json' ;
6
+ import exampleEnumNested from '../../__mocks__/typedData/example_enumNested.json' ;
6
7
import examplePresetTypes from '../../__mocks__/typedData/example_presetTypes.json' ;
7
8
import typedDataStructArrayExample from '../../__mocks__/typedData/mail_StructArray.json' ;
8
9
import typedDataSessionExample from '../../__mocks__/typedData/session_MerkleTree.json' ;
@@ -66,6 +67,10 @@ describe('typedData', () => {
66
67
expect ( encoded ) . toMatchInlineSnapshot (
67
68
`"\\"Example\\"(\\"someEnum1\\":\\"EnumA\\",\\"someEnum2\\":\\"EnumB\\")\\"EnumA\\"(\\"Variant 1\\":(),\\"Variant 2\\":(\\"u128\\",\\"u128*\\"),\\"Variant 3\\":(\\"u128\\"))\\"EnumB\\"(\\"Variant 1\\":(),\\"Variant 2\\":(\\"u128\\"))"`
68
69
) ;
70
+ encoded = encodeType ( exampleEnumNested . types , 'Example' , TypedDataRevision . ACTIVE ) ;
71
+ expect ( encoded ) . toMatchInlineSnapshot (
72
+ `"\\"Example\\"(\\"someEnum\\":\\"EnumA\\")\\"EnumA\\"(\\"Variant 1\\":(),\\"Variant 2\\":(\\"u128\\",\\"StructA\\"))\\"EnumB\\"(\\"Variant A\\":(),\\"Variant B\\":(\\"StructB*\\"))\\"StructA\\"(\\"nestedEnum\\":\\"EnumB\\")\\"StructB\\"(\\"flag\\":\\"bool\\")"`
73
+ ) ;
69
74
} ) ;
70
75
71
76
test ( 'should get right type hash' , ( ) => {
@@ -106,6 +111,10 @@ describe('typedData', () => {
106
111
expect ( typeHash ) . toMatchInlineSnapshot (
107
112
`"0x8eb4aeac64b707f3e843284c4258df6df1f0f7fd38dcffdd8a153a495cd351"`
108
113
) ;
114
+ typeHash = getTypeHash ( exampleEnumNested . types , 'Example' , TypedDataRevision . ACTIVE ) ;
115
+ expect ( typeHash ) . toMatchInlineSnapshot (
116
+ `"0x2143bb787fabace39d62e9acf8b6e97d9a369000516c3e6ffd963dc1370fc1a"`
117
+ ) ;
109
118
} ) ;
110
119
111
120
test ( 'should transform type selector' , ( ) => {
@@ -329,6 +338,11 @@ describe('typedData', () => {
329
338
`"0x6e61abaf480b1370bbf231f54e298c5f4872f40a6d2dd409ff30accee5bbd1e"`
330
339
) ;
331
340
341
+ messageHash = getMessageHash ( exampleEnumNested , exampleAddress ) ;
342
+ expect ( messageHash ) . toMatchInlineSnapshot (
343
+ `"0x691fc54567306a8ea5431130f1b98299e74a748ac391540a86736f20ef5f2b7"`
344
+ ) ;
345
+
332
346
expect ( spyPedersen ) . not . toHaveBeenCalled ( ) ;
333
347
expect ( spyPoseidon ) . toHaveBeenCalled ( ) ;
334
348
spyPedersen . mockRestore ( ) ;
0 commit comments