Skip to content

refactor: Cleaning up code surrounding the cryptocurrency donation form

stephen requested to merge crypto-donation-cleanup into main

This commit performs a cleanup pass on code involved with the display and function of the BTCPay donation form on the Cryptocurrency page.

The original incarnation of this page included three separate sections, all concurrently visible:

  • A list of Tor's various cryptocurrency addresses
  • A BTCPay form, which lets you donate an amount of BTC equivalent to the USD amount you key in
  • A homespun cryptocurrency donation form, allowing you to donate precise amounts of supported cryptocurrency to Tor

The redesign of the donate site excises this third form. However, initial code had been laid out in the initial work on donate-neo, before designs had been started, and that code has persisted throughout the development of this site despite having no function. This commit refactors out this needless code and clarifies the operation of the cryptocurrency-related portions of the site for future maintainers.

Additionally, the "custom amount" field on the donation form was not being properly validated, nor were styles being properly applied once validation was carried out, if the field was invalid. This commit addresses this oversight by:

  • Properly validating the custom amount field
  • Properly displaying the "invalid" state on the field if an improper amount is entered

Because the two forms share some code, this also addresses a regression with the core donation form in which the custom donation field was being neither properly validated nor properly styled if invalid.

Merge request reports