@@ -196,17 +196,24 @@ contract TestGsm is TestGhoBase {
196196
197197 assertEq (GHO_GSM.nonces (gsmSignerAddr), 0 , 'Unexpected before gsmSignerAddr nonce ' );
198198
199- bytes32 digest = _getSellAssetTypedDataHash (
200- EIP712Types.SellAssetWithSig ({
199+ bytes memory signature;
200+ {
201+ EIP712Types.SellAssetWithSig memory params = EIP712Types.SellAssetWithSig ({
201202 originator: gsmSignerAddr,
202203 maxAmount: DEFAULT_GSM_USDX_AMOUNT,
203204 receiver: gsmSignerAddr,
204205 nonce: GHO_GSM.nonces (gsmSignerAddr),
205206 deadline: deadline
206- })
207- );
208- (uint8 v , bytes32 r , bytes32 s ) = vm.sign (gsmSignerKey, digest);
209- bytes memory signature = abi.encodePacked (r, s, v);
207+ });
208+ bytes32 digest = _getSellAssetTypedDataHash (params);
209+ assertEq (
210+ digest,
211+ _getSellAssetEIP712Digest (params, block .chainid , address (GHO_GSM)),
212+ 'EIP712 digest not similar '
213+ );
214+ (uint8 v , bytes32 r , bytes32 s ) = vm.sign (gsmSignerKey, digest);
215+ signature = abi.encodePacked (r, s, v);
216+ }
210217
211218 assertTrue (gsmSignerAddr != ALICE, 'Signer is the same as Alice ' );
212219
@@ -249,17 +256,24 @@ contract TestGsm is TestGhoBase {
249256
250257 assertEq (GHO_GSM.nonces (gsmSignerAddr), 0 , 'Unexpected before gsmSignerAddr nonce ' );
251258
252- bytes32 digest = _getSellAssetTypedDataHash (
253- EIP712Types.SellAssetWithSig ({
259+ bytes memory signature;
260+ {
261+ EIP712Types.SellAssetWithSig memory params = EIP712Types.SellAssetWithSig ({
254262 originator: gsmSignerAddr,
255263 maxAmount: DEFAULT_GSM_USDX_AMOUNT,
256264 receiver: gsmSignerAddr,
257265 nonce: GHO_GSM.nonces (gsmSignerAddr),
258266 deadline: deadline
259- })
260- );
261- (uint8 v , bytes32 r , bytes32 s ) = vm.sign (gsmSignerKey, digest);
262- bytes memory signature = abi.encodePacked (r, s, v);
267+ });
268+ bytes32 digest = _getSellAssetTypedDataHash (params);
269+ assertEq (
270+ digest,
271+ _getSellAssetEIP712Digest (params, block .chainid , address (GHO_GSM)),
272+ 'EIP712 digest not similar '
273+ );
274+ (uint8 v , bytes32 r , bytes32 s ) = vm.sign (gsmSignerKey, digest);
275+ signature = abi.encodePacked (r, s, v);
276+ }
263277
264278 assertTrue (gsmSignerAddr != ALICE, 'Signer is the same as Alice ' );
265279
@@ -291,17 +305,24 @@ contract TestGsm is TestGhoBase {
291305 function testRevertSellAssetWithSigExpiredSignature () public {
292306 uint256 deadline = block .timestamp - 1 ;
293307
294- bytes32 digest = _getSellAssetTypedDataHash (
295- EIP712Types.SellAssetWithSig ({
308+ bytes memory signature;
309+ {
310+ EIP712Types.SellAssetWithSig memory params = EIP712Types.SellAssetWithSig ({
296311 originator: gsmSignerAddr,
297312 maxAmount: DEFAULT_GSM_USDX_AMOUNT,
298313 receiver: gsmSignerAddr,
299314 nonce: GHO_GSM.nonces (gsmSignerAddr),
300315 deadline: deadline
301- })
302- );
303- (uint8 v , bytes32 r , bytes32 s ) = vm.sign (gsmSignerKey, digest);
304- bytes memory signature = abi.encodePacked (r, s, v);
316+ });
317+ bytes32 digest = _getSellAssetTypedDataHash (params);
318+ assertEq (
319+ digest,
320+ _getSellAssetEIP712Digest (params, block .chainid , address (GHO_GSM)),
321+ 'EIP712 digest not similar '
322+ );
323+ (uint8 v , bytes32 r , bytes32 s ) = vm.sign (gsmSignerKey, digest);
324+ signature = abi.encodePacked (r, s, v);
325+ }
305326
306327 assertTrue (gsmSignerAddr != ALICE, 'Signer is the same as Alice ' );
307328
@@ -320,17 +341,24 @@ contract TestGsm is TestGhoBase {
320341 function testRevertSellAssetWithSigInvalidSignature () public {
321342 uint256 deadline = block .timestamp + 1 hours ;
322343
323- bytes32 digest = _getSellAssetTypedDataHash (
324- EIP712Types.SellAssetWithSig ({
344+ bytes memory signature;
345+ {
346+ EIP712Types.SellAssetWithSig memory params = EIP712Types.SellAssetWithSig ({
325347 originator: gsmSignerAddr,
326348 maxAmount: DEFAULT_GSM_USDX_AMOUNT,
327349 receiver: gsmSignerAddr,
328350 nonce: GHO_GSM.nonces (gsmSignerAddr),
329351 deadline: deadline
330- })
331- );
332- (uint8 v , bytes32 r , bytes32 s ) = vm.sign (gsmSignerKey, digest);
333- bytes memory signature = abi.encodePacked (r, s, v);
352+ });
353+ bytes32 digest = _getSellAssetTypedDataHash (params);
354+ assertEq (
355+ digest,
356+ _getSellAssetEIP712Digest (params, block .chainid , address (GHO_GSM)),
357+ 'EIP712 digest not similar '
358+ );
359+ (uint8 v , bytes32 r , bytes32 s ) = vm.sign (gsmSignerKey, digest);
360+ signature = abi.encodePacked (r, s, v);
361+ }
334362
335363 assertTrue (gsmSignerAddr != ALICE, 'Signer is the same as Alice ' );
336364
@@ -597,17 +625,24 @@ contract TestGsm is TestGhoBase {
597625
598626 assertEq (GHO_GSM.nonces (gsmSignerAddr), 0 , 'Unexpected before gsmSignerAddr nonce ' );
599627
600- bytes32 digest = _getBuyAssetTypedDataHash (
601- EIP712Types.BuyAssetWithSig ({
628+ bytes memory signature;
629+ {
630+ EIP712Types.BuyAssetWithSig memory params = EIP712Types.BuyAssetWithSig ({
602631 originator: gsmSignerAddr,
603632 minAmount: DEFAULT_GSM_USDX_AMOUNT,
604633 receiver: gsmSignerAddr,
605634 nonce: GHO_GSM.nonces (gsmSignerAddr),
606635 deadline: deadline
607- })
608- );
609- (uint8 v , bytes32 r , bytes32 s ) = vm.sign (gsmSignerKey, digest);
610- bytes memory signature = abi.encodePacked (r, s, v);
636+ });
637+ bytes32 digest = _getBuyAssetTypedDataHash (params);
638+ assertEq (
639+ digest,
640+ _getBuyAssetEIP712Digest (params, block .chainid , address (GHO_GSM)),
641+ 'EIP712 digest not similar '
642+ );
643+ (uint8 v , bytes32 r , bytes32 s ) = vm.sign (gsmSignerKey, digest);
644+ signature = abi.encodePacked (r, s, v);
645+ }
611646
612647 assertTrue (gsmSignerAddr != BOB, 'Signer is the same as Bob ' );
613648
@@ -665,17 +700,24 @@ contract TestGsm is TestGhoBase {
665700
666701 assertEq (GHO_GSM.nonces (gsmSignerAddr), 0 , 'Unexpected before gsmSignerAddr nonce ' );
667702
668- bytes32 digest = _getBuyAssetTypedDataHash (
669- EIP712Types.BuyAssetWithSig ({
703+ bytes memory signature;
704+ {
705+ EIP712Types.BuyAssetWithSig memory params = EIP712Types.BuyAssetWithSig ({
670706 originator: gsmSignerAddr,
671707 minAmount: DEFAULT_GSM_USDX_AMOUNT,
672708 receiver: gsmSignerAddr,
673709 nonce: GHO_GSM.nonces (gsmSignerAddr),
674710 deadline: deadline
675- })
676- );
677- (uint8 v , bytes32 r , bytes32 s ) = vm.sign (gsmSignerKey, digest);
678- bytes memory signature = abi.encodePacked (r, s, v);
711+ });
712+ bytes32 digest = _getBuyAssetTypedDataHash (params);
713+ assertEq (
714+ digest,
715+ _getBuyAssetEIP712Digest (params, block .chainid , address (GHO_GSM)),
716+ 'EIP712 digest not similar '
717+ );
718+ (uint8 v , bytes32 r , bytes32 s ) = vm.sign (gsmSignerKey, digest);
719+ signature = abi.encodePacked (r, s, v);
720+ }
679721
680722 assertTrue (gsmSignerAddr != BOB, 'Signer is the same as Bob ' );
681723
@@ -758,17 +800,24 @@ contract TestGsm is TestGhoBase {
758800 function testRevertBuyAssetWithSigExpiredSignature () public {
759801 uint256 deadline = block .timestamp - 1 ;
760802
761- bytes32 digest = _getBuyAssetTypedDataHash (
762- EIP712Types.BuyAssetWithSig ({
803+ bytes memory signature;
804+ {
805+ EIP712Types.BuyAssetWithSig memory params = EIP712Types.BuyAssetWithSig ({
763806 originator: gsmSignerAddr,
764807 minAmount: DEFAULT_GSM_USDX_AMOUNT,
765808 receiver: gsmSignerAddr,
766809 nonce: GHO_GSM.nonces (gsmSignerAddr),
767810 deadline: deadline
768- })
769- );
770- (uint8 v , bytes32 r , bytes32 s ) = vm.sign (gsmSignerKey, digest);
771- bytes memory signature = abi.encodePacked (r, s, v);
811+ });
812+ bytes32 digest = _getBuyAssetTypedDataHash (params);
813+ assertEq (
814+ digest,
815+ _getBuyAssetEIP712Digest (params, block .chainid , address (GHO_GSM)),
816+ 'EIP712 digest not similar '
817+ );
818+ (uint8 v , bytes32 r , bytes32 s ) = vm.sign (gsmSignerKey, digest);
819+ signature = abi.encodePacked (r, s, v);
820+ }
772821
773822 assertTrue (gsmSignerAddr != BOB, 'Signer is the same as Bob ' );
774823
@@ -786,17 +835,24 @@ contract TestGsm is TestGhoBase {
786835 function testRevertBuyAssetWithSigInvalidSignature () public {
787836 uint256 deadline = block .timestamp + 1 hours ;
788837
789- bytes32 digest = _getBuyAssetTypedDataHash (
790- EIP712Types.BuyAssetWithSig ({
838+ bytes memory signature;
839+ {
840+ EIP712Types.BuyAssetWithSig memory params = EIP712Types.BuyAssetWithSig ({
791841 originator: gsmSignerAddr,
792842 minAmount: DEFAULT_GSM_USDX_AMOUNT,
793843 receiver: gsmSignerAddr,
794844 nonce: GHO_GSM.nonces (gsmSignerAddr),
795845 deadline: deadline
796- })
797- );
798- (uint8 v , bytes32 r , bytes32 s ) = vm.sign (gsmSignerKey, digest);
799- bytes memory signature = abi.encodePacked (r, s, v);
846+ });
847+ bytes32 digest = _getBuyAssetTypedDataHash (params);
848+ assertEq (
849+ digest,
850+ _getBuyAssetEIP712Digest (params, block .chainid , address (GHO_GSM)),
851+ 'EIP712 digest not similar '
852+ );
853+ (uint8 v , bytes32 r , bytes32 s ) = vm.sign (gsmSignerKey, digest);
854+ signature = abi.encodePacked (r, s, v);
855+ }
800856
801857 assertTrue (gsmSignerAddr != BOB, 'Signer is the same as Bob ' );
802858
0 commit comments