@@ -217,54 +217,9 @@ export class AssertionEngine {
217217 async validateAuctionAssertions ( auctionAssertions : AuctionAssertion [ ] ) : Promise < void > {
218218 for ( const assertion of auctionAssertions ) {
219219 console . log ( LOG_PREFIXES . INFO , "Auction assertion validation" ) ;
220-
221220 // Get the current auction state
222221 const auctionState = await this . getAuctionState ( ) ;
223- for ( const key of Object . keys ( assertion ) ) {
224- if ( key === TYPE_FIELD ) continue ;
225- if ( key === "latestCheckpoint" ) continue ;
226- let expected = assertion [ key as keyof AuctionAssertion ] ;
227- if ( expected != undefined && expected != null ) {
228- if ( ! this . validateEquality ( expected , auctionState [ key as keyof AuctionState ] ) ) {
229- // Check if this is a VariableAmount with variance
230- const variance = typeof expected === "object" && "variation" in expected ? expected . variation : undefined ;
231- throw new Error (
232- ERROR_MESSAGES . AUCTION_ASSERTION_FAILED (
233- typeof expected === "object" && "amount" in expected
234- ? expected . amount
235- : assertion [ key as keyof AuctionAssertion ] ,
236- auctionState [ key as keyof AuctionState ] ,
237- key ,
238- variance ,
239- ) ,
240- ) ;
241- }
242- }
243- }
244-
245- if ( assertion . latestCheckpoint ) {
246- for ( const key of Object . keys ( assertion . latestCheckpoint ) ) {
247- if ( key === TYPE_FIELD ) continue ;
248- let expected = assertion . latestCheckpoint [ key as keyof CheckpointStruct ] ;
249- if ( expected != undefined && expected != null ) {
250- let actual = auctionState . latestCheckpoint [ key as keyof CheckpointStruct ] ;
251- if ( ! this . validateEquality ( expected , actual ) ) {
252- // Check if this is a VariableAmount with variance
253- const variance = typeof expected === "object" && "variation" in expected ? expected . variation : undefined ;
254- throw new Error (
255- ERROR_MESSAGES . AUCTION_CHECKPOINT_ASSERTION_FAILED (
256- typeof expected === "object" && "amount" in expected
257- ? expected . amount
258- : assertion . latestCheckpoint [ key as keyof CheckpointStruct ] ,
259- auctionState . latestCheckpoint [ key as keyof CheckpointStruct ] ,
260- key ,
261- variance ,
262- ) ,
263- ) ;
264- }
265- }
266- }
267- }
222+ this . validateAuctionAssertion ( assertion , auctionState ) ;
268223 const { type, ...assertionWithoutType } = assertion ;
269224 console . log (
270225 LOG_PREFIXES . SUCCESS ,
0 commit comments