@@ -3,6 +3,7 @@ import * as starkCurve from '@scure/starknet';
33import typedDataExample from '../../__mocks__/typedData/baseExample.json' ;
44import exampleBaseTypes from '../../__mocks__/typedData/example_baseTypes.json' ;
55import exampleEnum from '../../__mocks__/typedData/example_enum.json' ;
6+ import exampleEnumNested from '../../__mocks__/typedData/example_enumNested.json' ;
67import examplePresetTypes from '../../__mocks__/typedData/example_presetTypes.json' ;
78import typedDataStructArrayExample from '../../__mocks__/typedData/mail_StructArray.json' ;
89import typedDataSessionExample from '../../__mocks__/typedData/session_MerkleTree.json' ;
@@ -66,6 +67,10 @@ describe('typedData', () => {
6667 expect ( encoded ) . toMatchInlineSnapshot (
6768 `"\\"Example\\"(\\"someEnum1\\":\\"EnumA\\",\\"someEnum2\\":\\"EnumB\\")\\"EnumA\\"(\\"Variant 1\\":(),\\"Variant 2\\":(\\"u128\\",\\"u128*\\"),\\"Variant 3\\":(\\"u128\\"))\\"EnumB\\"(\\"Variant 1\\":(),\\"Variant 2\\":(\\"u128\\"))"`
6869 ) ;
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+ ) ;
6974 } ) ;
7075
7176 test ( 'should get right type hash' , ( ) => {
@@ -106,6 +111,10 @@ describe('typedData', () => {
106111 expect ( typeHash ) . toMatchInlineSnapshot (
107112 `"0x8eb4aeac64b707f3e843284c4258df6df1f0f7fd38dcffdd8a153a495cd351"`
108113 ) ;
114+ typeHash = getTypeHash ( exampleEnumNested . types , 'Example' , TypedDataRevision . ACTIVE ) ;
115+ expect ( typeHash ) . toMatchInlineSnapshot (
116+ `"0x2143bb787fabace39d62e9acf8b6e97d9a369000516c3e6ffd963dc1370fc1a"`
117+ ) ;
109118 } ) ;
110119
111120 test ( 'should transform type selector' , ( ) => {
@@ -329,6 +338,11 @@ describe('typedData', () => {
329338 `"0x6e61abaf480b1370bbf231f54e298c5f4872f40a6d2dd409ff30accee5bbd1e"`
330339 ) ;
331340
341+ messageHash = getMessageHash ( exampleEnumNested , exampleAddress ) ;
342+ expect ( messageHash ) . toMatchInlineSnapshot (
343+ `"0x691fc54567306a8ea5431130f1b98299e74a748ac391540a86736f20ef5f2b7"`
344+ ) ;
345+
332346 expect ( spyPedersen ) . not . toHaveBeenCalled ( ) ;
333347 expect ( spyPoseidon ) . toHaveBeenCalled ( ) ;
334348 spyPedersen . mockRestore ( ) ;
0 commit comments