Skip to content

CP-13319: Fix logic errors in Solana minimum send amount validation#3555

Closed
Copilot wants to merge 1 commit intoaddSolMinCheckfrom
copilot/sub-pr-3554
Closed

CP-13319: Fix logic errors in Solana minimum send amount validation#3555
Copilot wants to merge 1 commit intoaddSolMinCheckfrom
copilot/sub-pr-3554

Conversation

Copy link

Copilot AI commented Feb 6, 2026

Description

Ticket: CP-13319

Code review identified critical logic errors in the Solana send validation added in commit 50c5a23:

Issues Fixed:

  • Redundant validation logic in validateDestinationAccountRentExempt: Function had conflicting checks that would throw INSUFFICIENT_BALANCE for non-existent accounts and AMOUNT_TOO_LOW for existing accounts, with unreachable dead code
  • Incorrect error semantics: Used INSUFFICIENT_BALANCE when amount is below rent-exempt minimum (should be AMOUNT_TOO_LOW)
  • Caching bug in getRentExemptMinimum: Ignored space parameter, always queried and cached for 0n
  • Missing test coverage: No unit tests for SVM validation unlike other chains (AVM/BTC/EVM/PVM)

Changes Made:

  • Simplified validateDestinationAccountRentExempt to check rent-exempt requirement only for non-existent accounts (spaceOccupied === 0n)
  • Fixed error message to use AMOUNT_TOO_LOW consistently
  • Corrected getRentExemptMinimum to use space parameter in API call and caching
  • Added comprehensive validate.test.ts covering all validation scenarios
// Before: Redundant, conflicting logic
if (spaceOccupied === 0n) {
  setMinAmount(minAmount)
  if (amountBigInt < rentExemptMinimum) {
    throw new Error(SendErrorMessage.INSUFFICIENT_BALANCE) // Wrong error
  } else {
    setMinAmount(undefined) // Unreachable
  }
}
if (amountBigInt < rentExemptMinimum) { // Duplicate check
  throw new Error(SendErrorMessage.AMOUNT_TOO_LOW)
}

// After: Clear, correct logic
if (spaceOccupied === 0n) {
  setMinAmount(minAmount)
  if (amountBigInt < rentExemptMinimum) {
    throw new Error(SendErrorMessage.AMOUNT_TOO_LOW)
  }
} else {
  setMinAmount(undefined)
}

Screenshots/Videos

(Original screenshots remain valid - UI behavior unchanged)

Testing

Dev Testing

  • Run yarn core test to verify new unit tests pass
  • Test Solana send to non-existent account with amount below rent-exempt minimum (should show min amount and error)
  • Test Solana send to existing account with any amount (should not enforce rent-exempt minimum)
  • Test SPL token sends (should not check rent-exempt minimum)

QA Testing

  • Same as original PR - validation logic fixed but user-facing behavior matches original intent

Checklist

  • I have performed a self-review of my code
  • I have verified the code works
  • I have included screenshots / videos of android and ios
  • I have added testing steps
  • I have added/updated necessary unit tests
  • I have updated the documentation

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Add SOL minimum send amount validation CP-13319: Fix logic errors in Solana minimum send amount validation Feb 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants