diff --git a/ocp/rpc/transaction/intent_handler.go b/ocp/rpc/transaction/intent_handler.go index 7b840ba..3790470 100644 --- a/ocp/rpc/transaction/intent_handler.go +++ b/ocp/rpc/transaction/intent_handler.go @@ -779,7 +779,7 @@ func (h *SendPublicPaymentIntentHandler) validateActions( // Ensure the destination is the intent mint ATA for the client-provided owner, // if provided. We'll check later if this is absolutely required. - var isVmSwapPda bool + var isDestinationOwnerVmSwapPda bool if metadata.DestinationOwner != nil { destinationOwner, err := common.NewAccountFromProto(metadata.DestinationOwner) if err != nil { @@ -797,7 +797,7 @@ func (h *SendPublicPaymentIntentHandler) validateActions( _, err = h.data.GetTimelockBySwapPda(ctx, destinationOwner.PublicKey().ToBase58()) if err == nil { - isVmSwapPda = true + isDestinationOwnerVmSwapPda = true } else if err != timelock.ErrTimelockNotFound { return err } @@ -810,22 +810,27 @@ func (h *SendPublicPaymentIntentHandler) validateActions( } // Check whether the destination account is a token account of the same mint that's - // been created on the blockchain. If not, a fee is likely required - err = validateExternalTokenAccountWithinIntent(ctx, h.data, destination, intentMint) - switch err { - case nil: - default: - if !strings.Contains(strings.ToLower(err.Error()), "doesn't exist on the blockchain") { - return err - } - - if metadata.DestinationOwner == nil { - return NewIntentValidationError("destination owner account is required to derive ata") - } - - // Only VM swap PDAs are subsidized by server - if !simResult.HasAnyFeePayments() && !isVmSwapPda { - return NewIntentValidationErrorf("%s fee payment is required", transactionpb.FeePaymentAction_CREATE_ON_SEND_WITHDRAWAL.String()) + // been created on the blockchain. If not, a fee is likely required. + // + // Note: We can skip these checks for VM swap ATAs because the account is already + // validated, and no fee payment is required. + if !isDestinationOwnerVmSwapPda { + err = validateExternalTokenAccountWithinIntent(ctx, h.data, destination, intentMint) + switch err { + case nil: + default: + if !strings.Contains(strings.ToLower(err.Error()), "doesn't exist on the blockchain") { + return err + } + + if metadata.DestinationOwner == nil { + return NewIntentValidationError("destination owner account is required to derive ata") + } + + // Only VM swap ATAs are subsidized by server + if !simResult.HasAnyFeePayments() && !isDestinationOwnerVmSwapPda { + return NewIntentValidationErrorf("%s fee payment is required", transactionpb.FeePaymentAction_CREATE_ON_SEND_WITHDRAWAL.String()) + } } }