@@ -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
`"0x393bf83422ca8626a2932696cfa0acb19dcad6de2fe84a2dd2ca7607ea5329a"`
108
113
) ;
114
+ typeHash = getTypeHash ( exampleEnumNested . types , 'Example' , TypedDataRevision . ACTIVE ) ;
115
+ expect ( typeHash ) . toMatchInlineSnapshot (
116
+ `"0x267f739fd83d30528a0fafb23df33b6c35ca0a5adbcfb32152721478fa9d0ce"`
117
+ ) ;
109
118
} ) ;
110
119
111
120
test ( 'should transform type selector' , ( ) => {
@@ -329,6 +338,11 @@ describe('typedData', () => {
329
338
`"0x150a589bb56a4fbf4ee01f52e44fd5adde6af94c02b37e383413fed185321a2"`
330
339
) ;
331
340
341
+ messageHash = getMessageHash ( exampleEnumNested , exampleAddress ) ;
342
+ expect ( messageHash ) . toMatchInlineSnapshot (
343
+ `"0x6e70eb4ef625dda451094716eee7f31fa81ca0ba99d390885e9c7b0d64cd22"`
344
+ ) ;
345
+
332
346
expect ( spyPedersen ) . not . toHaveBeenCalled ( ) ;
333
347
expect ( spyPoseidon ) . toHaveBeenCalled ( ) ;
334
348
spyPedersen . mockRestore ( ) ;
0 commit comments