@@ -19,7 +19,6 @@ import {
1919 CircleBridge ,
2020 Contracts ,
2121 VAA ,
22- keccak256 ,
2322} from "@wormhole-foundation/sdk-definitions" ;
2423import {
2524 AnySolanaAddress ,
@@ -177,8 +176,10 @@ export class SolanaMatchingEngine<N extends Network, C extends SolanaChains>
177176 offerPrice : bigint ,
178177 totalDeposit ?: bigint ,
179178 ) {
180- const payer = new SolanaAddress ( sender ) . unwrap ( ) ;
179+ // If the VAA has not yet been posted, do so now
180+ yield * this . postVaa ( sender , vaa ) ;
181181
182+ const payer = new SolanaAddress ( sender ) . unwrap ( ) ;
182183 const vaaAddress = this . pdas . postedVaa ( vaa ) ;
183184
184185 const ixs = await this . placeInitialOfferCctpIx (
@@ -196,7 +197,9 @@ export class SolanaMatchingEngine<N extends Network, C extends SolanaChains>
196197 offer : bigint ,
197198 ) {
198199 const participant = new SolanaAddress ( sender ) . unwrap ( ) ;
199- const auction = this . auctionAddress ( keccak256 ( vaa . hash ) ) ;
200+
201+ const digest = vaaHash ( vaa ) ;
202+ const auction = this . pdas . auction ( digest ) ;
200203
201204 const ixs = await this . improveOfferIx ( { participant, auction } , { offerPrice : offer } ) ;
202205
@@ -223,7 +226,6 @@ export class SolanaMatchingEngine<N extends Network, C extends SolanaChains>
223226
224227 const digest = vaaHash ( vaa ) ;
225228 const auction = this . pdas . auction ( digest ) ;
226-
227229 const reservedSequence = this . pdas . reservedFastFillSequence ( digest ) ;
228230
229231 // TODO: make sure this has already been done, or do it here
@@ -272,7 +274,8 @@ export class SolanaMatchingEngine<N extends Network, C extends SolanaChains>
272274 const fastVaa = this . pdas . postedVaa ( fast ) ;
273275 const finalizedVaa = this . pdas . postedVaa ( finalized ) ;
274276
275- const preparedAddress = this . preparedOrderResponseAddress ( keccak256 ( fast . hash ) ) ;
277+ const digest = vaaHash ( fast ) ;
278+ const preparedAddress = this . pdas . preparedOrderResponse ( digest ) ;
276279
277280 try {
278281 // Check if its already been prepared
@@ -341,15 +344,16 @@ export class SolanaMatchingEngine<N extends Network, C extends SolanaChains>
341344 }
342345 }
343346
344- const digest = keccak256 ( fast . hash ) ;
345- const preparedOrderResponse = this . preparedOrderResponseAddress ( digest ) ;
346- const auction = this . auctionAddress ( digest ) ;
347347 const fastVaa = this . pdas . postedVaa ( fast ) ;
348348
349+ const digest = vaaHash ( fast ) ;
350+ const preparedOrderResponse = this . pdas . preparedOrderResponse ( digest ) ;
351+ const auction = this . pdas . auction ( digest ) ;
352+
349353 const settleIx = await ( async ( ) => {
350354 if ( finalized && ! cctp ) {
351355 if ( fast . payload . targetChain === "Solana" ) {
352- const reservedSequence = this . reservedFastFillSequenceAddress ( digest ) ;
356+ const reservedSequence = this . pdas . reservedFastFillSequence ( digest ) ;
353357 return await this . settleAuctionNoneLocalIx ( {
354358 payer,
355359 reservedSequence,
0 commit comments