@@ -60,15 +60,10 @@ contract CABPaymaster is IPaymasterVerifier, BasePaymaster {
6060
6161 (uint256 logIndex , bytes memory proof ) = abi.decode (_proof, (uint256 , bytes ));
6262 (,, bytes [] memory topics ,) = crossL2Prover.validateEvent (logIndex, proof);
63- bytes [] memory expectedTopics = new bytes [](2 );
64- expectedTopics[0 ] = abi.encode (InvoiceCreated.selector );
65- expectedTopics[1 ] = abi.encode (invoiceId);
6663
67- if (! LibBytes.eq (abi.encode (topics), abi.encode (expectedTopics))) {
68- return false ;
69- }
70- emit InvoiceVerified (invoiceId);
71- return true ;
64+ return LibBytes.eq (
65+ abi.encode (topics[0 ], topics[1 ]), abi.encode (IInvoiceManager.InvoiceCreated.selector , invoiceId)
66+ );
7267 }
7368
7469 function withdraw (address token , uint256 amount ) external override onlyOwner {
@@ -144,13 +139,17 @@ contract CABPaymaster is IPaymasterVerifier, BasePaymaster {
144139 // don't revert on signature failure: return SIG_VALIDATION_FAILED
145140 if (verifyingSigner != ECDSA.recover (hash, paymasterSignature)) {
146141 return (
147- abi.encodePacked (invoiceId, sponsorTokenData[0 :1 + sponsorTokenLength * 72 ]),
142+ abi.encodePacked (
143+ invoiceId, userOp.getSender (), userOp.nonce, sponsorTokenData[0 :1 + sponsorTokenLength * 72 ]
144+ ),
148145 _packValidationData (true , validUntil, validAfter)
149146 );
150147 }
151148
152149 return (
153- abi.encodePacked (invoiceId, sponsorTokenData[0 :1 + sponsorTokenLength * 72 ]),
150+ abi.encodePacked (
151+ invoiceId, userOp.getSender (), userOp.nonce, sponsorTokenData[0 :1 + sponsorTokenLength * 72 ]
152+ ),
154153 _packValidationData (false , validUntil, validAfter)
155154 );
156155 }
@@ -160,8 +159,7 @@ contract CABPaymaster is IPaymasterVerifier, BasePaymaster {
160159 virtual
161160 override
162161 {
163- bytes32 invoiceId = bytes32 (context[:32 ]);
164- bytes calldata sponsorTokenData = context[32 :];
162+ bytes calldata sponsorTokenData = context[84 :];
165163
166164 (uint8 sponsorTokenLength , SponsorToken[] memory sponsorTokens ) = parseSponsorTokenData (sponsorTokenData);
167165 for (uint8 i = 0 ; i < sponsorTokenLength; i++ ) {
@@ -170,7 +168,10 @@ contract CABPaymaster is IPaymasterVerifier, BasePaymaster {
170168 }
171169 // TODO: Batch Proving Optimistation -> write in settlement contract on `opSucceeded`
172170 if (mode == PostOpMode.opSucceeded) {
173- emit InvoiceCreated (invoiceId);
171+ bytes32 invoiceId = bytes32 (context[:32 ]);
172+ address account = address (bytes20 (context[32 :52 ]));
173+ uint256 nonce = uint256 (bytes32 (context[52 :84 ]));
174+ invoiceManager.createInvoice (nonce, account, invoiceId);
174175 }
175176 }
176177
0 commit comments