ApplyPrecision handles both operations involving precision: 1. If PreciseAmount exists: converts it to a decimal Amount 2. If Amount exists: converts it to a PreciseAmount This function is now a wrapper that sets default precision if needed and calls applyPrecisionLogic.
(transaction *Transaction)
| 233 | // 2. If Amount exists: converts it to a PreciseAmount |
| 234 | // This function is now a wrapper that sets default precision if needed and calls applyPrecisionLogic. |
| 235 | func ApplyPrecision(transaction *Transaction) *big.Int { |
| 236 | if transaction.Precision == 0 { |
| 237 | transaction.Precision = 1 |
| 238 | } |
| 239 | return applyPrecisionLogic(transaction) |
| 240 | } |
| 241 | |
| 242 | // applyPrecisionLogic contains the core logic for converting amounts based on precision. |
| 243 | // It assumes transaction.Precision has been set appropriately before this call. |