@@ -703,6 +703,7 @@ func (h *SendPublicPaymentIntentHandler) validateActions(
703703
704704 // Ensure the destination is the intent mint ATA for the client-provided owner,
705705 // if provided. We'll check later if this is absolutely required.
706+ var isVmSwapPda bool
706707 if metadata .DestinationOwner != nil {
707708 destinationOwner , err := common .NewAccountFromProto (metadata .DestinationOwner )
708709 if err != nil {
@@ -717,34 +718,7 @@ func (h *SendPublicPaymentIntentHandler) validateActions(
717718 if ata .PublicKey ().ToBase58 () != destination .PublicKey ().ToBase58 () {
718719 return NewIntentValidationErrorf ("destination is not the ata for %s" , destinationOwner .PublicKey ().ToBase58 ())
719720 }
720- }
721-
722- // Technically we should always enforce a fee payment, but these checks are only
723- // disabled for tests
724- if h .conf .disableBlockchainChecks .Get (ctx ) {
725- return nil
726- }
727-
728- // Check whether the destination account is a token account of the same mint that's
729- // been created on the blockchain. If not, a fee is likely required
730- err = validateExternalTokenAccountWithinIntent (ctx , h .data , destination , intentMint )
731- switch err {
732- case nil :
733- default :
734- if ! strings .Contains (strings .ToLower (err .Error ()), "doesn't exist on the blockchain" ) {
735- return err
736- }
737-
738- if metadata .DestinationOwner == nil {
739- return NewIntentValidationError ("destination owner account is required to derive ata" )
740- }
741721
742- destinationOwner , err := common .NewAccountFromProto (metadata .DestinationOwner )
743- if err != nil {
744- return err
745- }
746-
747- var isVmSwapPda bool
748722 vmSwapPdaTimelockRecord , err := h .data .GetTimelockBySwapPda (ctx , destinationOwner .PublicKey ().ToBase58 ())
749723 if err == nil {
750724 isVmSwapPda = true
@@ -766,6 +740,27 @@ func (h *SendPublicPaymentIntentHandler) validateActions(
766740 return NewIntentValidationError ("vm swap pda is for a different mint" )
767741 }
768742 }
743+ }
744+
745+ // Technically we should always enforce a fee payment, but these checks are only
746+ // disabled for tests
747+ if h .conf .disableBlockchainChecks .Get (ctx ) {
748+ return nil
749+ }
750+
751+ // Check whether the destination account is a token account of the same mint that's
752+ // been created on the blockchain. If not, a fee is likely required
753+ err = validateExternalTokenAccountWithinIntent (ctx , h .data , destination , intentMint )
754+ switch err {
755+ case nil :
756+ default :
757+ if ! strings .Contains (strings .ToLower (err .Error ()), "doesn't exist on the blockchain" ) {
758+ return err
759+ }
760+
761+ if metadata .DestinationOwner == nil {
762+ return NewIntentValidationError ("destination owner account is required to derive ata" )
763+ }
769764
770765 // Only VM swap PDAs are subsidized by server
771766 if ! simResult .HasAnyFeePayments () && ! isVmSwapPda {
0 commit comments