@@ -60,15 +60,10 @@ contract CABPaymaster is IPaymasterVerifier, BasePaymaster {
60
60
61
61
(uint256 logIndex , bytes memory proof ) = abi.decode (_proof, (uint256 , bytes ));
62
62
(,, 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);
66
63
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
+ );
72
67
}
73
68
74
69
function withdraw (address token , uint256 amount ) external override onlyOwner {
@@ -144,13 +139,17 @@ contract CABPaymaster is IPaymasterVerifier, BasePaymaster {
144
139
// don't revert on signature failure: return SIG_VALIDATION_FAILED
145
140
if (verifyingSigner != ECDSA.recover (hash, paymasterSignature)) {
146
141
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
+ ),
148
145
_packValidationData (true , validUntil, validAfter)
149
146
);
150
147
}
151
148
152
149
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
+ ),
154
153
_packValidationData (false , validUntil, validAfter)
155
154
);
156
155
}
@@ -160,8 +159,7 @@ contract CABPaymaster is IPaymasterVerifier, BasePaymaster {
160
159
virtual
161
160
override
162
161
{
163
- bytes32 invoiceId = bytes32 (context[:32 ]);
164
- bytes calldata sponsorTokenData = context[32 :];
162
+ bytes calldata sponsorTokenData = context[84 :];
165
163
166
164
(uint8 sponsorTokenLength , SponsorToken[] memory sponsorTokens ) = parseSponsorTokenData (sponsorTokenData);
167
165
for (uint8 i = 0 ; i < sponsorTokenLength; i++ ) {
@@ -170,7 +168,10 @@ contract CABPaymaster is IPaymasterVerifier, BasePaymaster {
170
168
}
171
169
// TODO: Batch Proving Optimistation -> write in settlement contract on `opSucceeded`
172
170
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);
174
175
}
175
176
}
176
177
0 commit comments