Validate affiliate conversion sat amounts - #140
Conversation
Greptile SummaryThis PR tightens
Confidence Score: 4/5Safe to merge; the validation logic is correct and the new tests confirm both the POST and PUT rejection paths work as intended. The No files require special attention; both changed files are straightforward and well-tested. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[POST or PUT request] --> B{sale_amount_sats\nprovided?}
B -- "PUT: undefined" --> C[Skip sat validation]
B -- "present" --> D{isPositiveIntegerSats?}
D -- "typeof !== number\n|| not integer\n|| <= 0" --> E[400: must be a positive integer]
D -- "positive integer ✓" --> F{POST or PUT?}
F -- POST --> G[recordConversion]
F -- PUT --> H[calculateCommission\nthen DB update]
C --> I{Other fields\nto update?}
I -- "note / status" --> H
I -- "none" --> J[400: Nothing to update]
Reviews (1): Last reviewed commit: "Validate affiliate conversion sat amount..." | Re-trigger Greptile |
Summary
sale_amount_satsvalues when creating manual affiliate conversionssale_amount_satsvalues before recalculating edited conversionsWhy
Satoshi amounts are indivisible. Allowing decimal sale amounts can store impossible conversion values and feed fractional inputs into commission calculation.
Validation
pnpm test:run src/app/api/affiliates/offers/[id]/conversions/route.test.tspnpm exec eslint src/app/api/affiliates/offers/[id]/conversions/route.ts src/app/api/affiliates/offers/[id]/conversions/route.test.tspnpm type-checkgit diff --checkPayment for the active uGig affiliate testing bounty can go to SOL:
27sdMYXofqoM9qR13bZhccRNYeEgYn5EoHXTSJn4QWKP.Payment fallback: PayPal cultofrozen@gmail.com