@@ -196,24 +196,17 @@ contract TestGsm is TestGhoBase {
196196
197197 assertEq (GHO_GSM.nonces (gsmSignerAddr), 0 , 'Unexpected before gsmSignerAddr nonce ' );
198198
199- bytes memory signature;
200- {
201- EIP712Types.SellAssetWithSig memory params = EIP712Types.SellAssetWithSig ({
199+ bytes32 digest = _getSellAssetTypedDataHash (
200+ EIP712Types.SellAssetWithSig ({
202201 originator: gsmSignerAddr,
203202 maxAmount: DEFAULT_GSM_USDX_AMOUNT,
204203 receiver: gsmSignerAddr,
205204 nonce: GHO_GSM.nonces (gsmSignerAddr),
206205 deadline: deadline
207- });
208- bytes32 digest = _getSellAssetTypedDataHash (params);
209- assertEq (
210- digest,
211- _getSellAssetEIP712Digest (params, block .chainid , address (GHO_GSM)),
212- 'EIP712 digest does not match '
213- );
214- (uint8 v , bytes32 r , bytes32 s ) = vm.sign (gsmSignerKey, digest);
215- signature = abi.encodePacked (r, s, v);
216- }
206+ })
207+ );
208+ (uint8 v , bytes32 r , bytes32 s ) = vm.sign (gsmSignerKey, digest);
209+ bytes memory signature = abi.encodePacked (r, s, v);
217210
218211 assertTrue (gsmSignerAddr != ALICE, 'Signer is the same as Alice ' );
219212
@@ -256,24 +249,17 @@ contract TestGsm is TestGhoBase {
256249
257250 assertEq (GHO_GSM.nonces (gsmSignerAddr), 0 , 'Unexpected before gsmSignerAddr nonce ' );
258251
259- bytes memory signature;
260- {
261- EIP712Types.SellAssetWithSig memory params = EIP712Types.SellAssetWithSig ({
252+ bytes32 digest = _getSellAssetTypedDataHash (
253+ EIP712Types.SellAssetWithSig ({
262254 originator: gsmSignerAddr,
263255 maxAmount: DEFAULT_GSM_USDX_AMOUNT,
264256 receiver: gsmSignerAddr,
265257 nonce: GHO_GSM.nonces (gsmSignerAddr),
266258 deadline: deadline
267- });
268- bytes32 digest = _getSellAssetTypedDataHash (params);
269- assertEq (
270- digest,
271- _getSellAssetEIP712Digest (params, block .chainid , address (GHO_GSM)),
272- 'EIP712 digest does not match '
273- );
274- (uint8 v , bytes32 r , bytes32 s ) = vm.sign (gsmSignerKey, digest);
275- signature = abi.encodePacked (r, s, v);
276- }
259+ })
260+ );
261+ (uint8 v , bytes32 r , bytes32 s ) = vm.sign (gsmSignerKey, digest);
262+ bytes memory signature = abi.encodePacked (r, s, v);
277263
278264 assertTrue (gsmSignerAddr != ALICE, 'Signer is the same as Alice ' );
279265
@@ -305,24 +291,17 @@ contract TestGsm is TestGhoBase {
305291 function testRevertSellAssetWithSigExpiredSignature () public {
306292 uint256 deadline = block .timestamp - 1 ;
307293
308- bytes memory signature;
309- {
310- EIP712Types.SellAssetWithSig memory params = EIP712Types.SellAssetWithSig ({
294+ bytes32 digest = _getSellAssetTypedDataHash (
295+ EIP712Types.SellAssetWithSig ({
311296 originator: gsmSignerAddr,
312297 maxAmount: DEFAULT_GSM_USDX_AMOUNT,
313298 receiver: gsmSignerAddr,
314299 nonce: GHO_GSM.nonces (gsmSignerAddr),
315300 deadline: deadline
316- });
317- bytes32 digest = _getSellAssetTypedDataHash (params);
318- assertEq (
319- digest,
320- _getSellAssetEIP712Digest (params, block .chainid , address (GHO_GSM)),
321- 'EIP712 digest does not match '
322- );
323- (uint8 v , bytes32 r , bytes32 s ) = vm.sign (gsmSignerKey, digest);
324- signature = abi.encodePacked (r, s, v);
325- }
301+ })
302+ );
303+ (uint8 v , bytes32 r , bytes32 s ) = vm.sign (gsmSignerKey, digest);
304+ bytes memory signature = abi.encodePacked (r, s, v);
326305
327306 assertTrue (gsmSignerAddr != ALICE, 'Signer is the same as Alice ' );
328307
@@ -341,24 +320,17 @@ contract TestGsm is TestGhoBase {
341320 function testRevertSellAssetWithSigInvalidSignature () public {
342321 uint256 deadline = block .timestamp + 1 hours ;
343322
344- bytes memory signature;
345- {
346- EIP712Types.SellAssetWithSig memory params = EIP712Types.SellAssetWithSig ({
323+ bytes32 digest = _getSellAssetTypedDataHash (
324+ EIP712Types.SellAssetWithSig ({
347325 originator: gsmSignerAddr,
348326 maxAmount: DEFAULT_GSM_USDX_AMOUNT,
349327 receiver: gsmSignerAddr,
350328 nonce: GHO_GSM.nonces (gsmSignerAddr),
351329 deadline: deadline
352- });
353- bytes32 digest = _getSellAssetTypedDataHash (params);
354- assertEq (
355- digest,
356- _getSellAssetEIP712Digest (params, block .chainid , address (GHO_GSM)),
357- 'EIP712 digest does not match '
358- );
359- (uint8 v , bytes32 r , bytes32 s ) = vm.sign (gsmSignerKey, digest);
360- signature = abi.encodePacked (r, s, v);
361- }
330+ })
331+ );
332+ (uint8 v , bytes32 r , bytes32 s ) = vm.sign (gsmSignerKey, digest);
333+ bytes memory signature = abi.encodePacked (r, s, v);
362334
363335 assertTrue (gsmSignerAddr != ALICE, 'Signer is the same as Alice ' );
364336
@@ -625,24 +597,17 @@ contract TestGsm is TestGhoBase {
625597
626598 assertEq (GHO_GSM.nonces (gsmSignerAddr), 0 , 'Unexpected before gsmSignerAddr nonce ' );
627599
628- bytes memory signature;
629- {
630- EIP712Types.BuyAssetWithSig memory params = EIP712Types.BuyAssetWithSig ({
600+ bytes32 digest = _getBuyAssetTypedDataHash (
601+ EIP712Types.BuyAssetWithSig ({
631602 originator: gsmSignerAddr,
632603 minAmount: DEFAULT_GSM_USDX_AMOUNT,
633604 receiver: gsmSignerAddr,
634605 nonce: GHO_GSM.nonces (gsmSignerAddr),
635606 deadline: deadline
636- });
637- bytes32 digest = _getBuyAssetTypedDataHash (params);
638- assertEq (
639- digest,
640- _getBuyAssetEIP712Digest (params, block .chainid , address (GHO_GSM)),
641- 'EIP712 digest does not match '
642- );
643- (uint8 v , bytes32 r , bytes32 s ) = vm.sign (gsmSignerKey, digest);
644- signature = abi.encodePacked (r, s, v);
645- }
607+ })
608+ );
609+ (uint8 v , bytes32 r , bytes32 s ) = vm.sign (gsmSignerKey, digest);
610+ bytes memory signature = abi.encodePacked (r, s, v);
646611
647612 assertTrue (gsmSignerAddr != BOB, 'Signer is the same as Bob ' );
648613
@@ -700,24 +665,17 @@ contract TestGsm is TestGhoBase {
700665
701666 assertEq (GHO_GSM.nonces (gsmSignerAddr), 0 , 'Unexpected before gsmSignerAddr nonce ' );
702667
703- bytes memory signature;
704- {
705- EIP712Types.BuyAssetWithSig memory params = EIP712Types.BuyAssetWithSig ({
668+ bytes32 digest = _getBuyAssetTypedDataHash (
669+ EIP712Types.BuyAssetWithSig ({
706670 originator: gsmSignerAddr,
707671 minAmount: DEFAULT_GSM_USDX_AMOUNT,
708672 receiver: gsmSignerAddr,
709673 nonce: GHO_GSM.nonces (gsmSignerAddr),
710674 deadline: deadline
711- });
712- bytes32 digest = _getBuyAssetTypedDataHash (params);
713- assertEq (
714- digest,
715- _getBuyAssetEIP712Digest (params, block .chainid , address (GHO_GSM)),
716- 'EIP712 digest does not match '
717- );
718- (uint8 v , bytes32 r , bytes32 s ) = vm.sign (gsmSignerKey, digest);
719- signature = abi.encodePacked (r, s, v);
720- }
675+ })
676+ );
677+ (uint8 v , bytes32 r , bytes32 s ) = vm.sign (gsmSignerKey, digest);
678+ bytes memory signature = abi.encodePacked (r, s, v);
721679
722680 assertTrue (gsmSignerAddr != BOB, 'Signer is the same as Bob ' );
723681
@@ -800,24 +758,17 @@ contract TestGsm is TestGhoBase {
800758 function testRevertBuyAssetWithSigExpiredSignature () public {
801759 uint256 deadline = block .timestamp - 1 ;
802760
803- bytes memory signature;
804- {
805- EIP712Types.BuyAssetWithSig memory params = EIP712Types.BuyAssetWithSig ({
761+ bytes32 digest = _getBuyAssetTypedDataHash (
762+ EIP712Types.BuyAssetWithSig ({
806763 originator: gsmSignerAddr,
807764 minAmount: DEFAULT_GSM_USDX_AMOUNT,
808765 receiver: gsmSignerAddr,
809766 nonce: GHO_GSM.nonces (gsmSignerAddr),
810767 deadline: deadline
811- });
812- bytes32 digest = _getBuyAssetTypedDataHash (params);
813- assertEq (
814- digest,
815- _getBuyAssetEIP712Digest (params, block .chainid , address (GHO_GSM)),
816- 'EIP712 digest does not match '
817- );
818- (uint8 v , bytes32 r , bytes32 s ) = vm.sign (gsmSignerKey, digest);
819- signature = abi.encodePacked (r, s, v);
820- }
768+ })
769+ );
770+ (uint8 v , bytes32 r , bytes32 s ) = vm.sign (gsmSignerKey, digest);
771+ bytes memory signature = abi.encodePacked (r, s, v);
821772
822773 assertTrue (gsmSignerAddr != BOB, 'Signer is the same as Bob ' );
823774
@@ -835,24 +786,17 @@ contract TestGsm is TestGhoBase {
835786 function testRevertBuyAssetWithSigInvalidSignature () public {
836787 uint256 deadline = block .timestamp + 1 hours ;
837788
838- bytes memory signature;
839- {
840- EIP712Types.BuyAssetWithSig memory params = EIP712Types.BuyAssetWithSig ({
789+ bytes32 digest = _getBuyAssetTypedDataHash (
790+ EIP712Types.BuyAssetWithSig ({
841791 originator: gsmSignerAddr,
842792 minAmount: DEFAULT_GSM_USDX_AMOUNT,
843793 receiver: gsmSignerAddr,
844794 nonce: GHO_GSM.nonces (gsmSignerAddr),
845795 deadline: deadline
846- });
847- bytes32 digest = _getBuyAssetTypedDataHash (params);
848- assertEq (
849- digest,
850- _getBuyAssetEIP712Digest (params, block .chainid , address (GHO_GSM)),
851- 'EIP712 digest does not match '
852- );
853- (uint8 v , bytes32 r , bytes32 s ) = vm.sign (gsmSignerKey, digest);
854- signature = abi.encodePacked (r, s, v);
855- }
796+ })
797+ );
798+ (uint8 v , bytes32 r , bytes32 s ) = vm.sign (gsmSignerKey, digest);
799+ bytes memory signature = abi.encodePacked (r, s, v);
856800
857801 assertTrue (gsmSignerAddr != BOB, 'Signer is the same as Bob ' );
858802
0 commit comments