on master help sign in
clarify comments for SR contract logic.
commitc14407991a50a61d0a70a59d1d14e1eb7137652b authorLiam Fitzgerald <liam@urizen.co> dateTue 10 Dec 2019, 13:27 (7 years ago) parent232d636
1 file changed+14−2
src/lib/starRelease.js+14−2
src/lib/starRelease.js+14−2
@@ -17,6 +17,18 @@ export function generateWithdrawTxs(contracts, batchLimits, amount, to) {
1717 return [...csrTxs, ...lsrTxs];
1818}
1919
20+/**
21+ * Recurse over batchLimits to generate a valid number of withdraw txs.
22+ * amount may exceed the number of withdraw txs available in the consolidated SR contract.
23+ *
24+ * @param {object} contracts - The azimuth contracts object
25+ * @param {array} batchLimits - An array of the maximum withdraw limit for each batch
26+ * @param {amount} amount - The number of txs to be generated
27+ * @param {string} to - The addresss to withdraw to
28+ * @return {array} An array with the number of transactions missing as the head
29+ * (i.e. requested amount exceeded available), and the generated transactions
30+ * as the rest of the list
31+ */
2032function generateConditionalWithdrawTxs(
2133 contracts,
2234 batchLimits,
@@ -24,11 +36,11 @@ function generateConditionalWithdrawTxs(
2436 to,
2537 offset = 0
2638) {
27− // Successfully withdraw all requesed
39+ // Successfully withdrawn all requested, none missing
2840 if (amount <= 0) {
2941 return [0];
3042 }
31− // Return missing amount in car
43+ // Return missing amount in head of list
3244 if (batchLimits.length === 0) {
3345 return [amount];
3446 }