@@ -82,21 +82,28 @@ export async function getConditional(contracts, address) {
82 conditionalSR.getRemainingStars(contracts, address),
82 conditionalSR.getRemainingStars(contracts, address),
85− if (commitment === null || batches === null) {
85+ if (batches === [] || commitment.total === '0') {
86 return { total: 0, available: 0, withdrawn: 0, batchLimits: [] };
86 return { total: 0, available: 0, withdrawn: 0, batchLimits: [] };
89 const total = remaining.length;
89 const total = remaining.length;
90 let balance = total;
90 let balance = total;
92+ //NOTE we don't strictly need to convert the received number-strings to
93+ // integers, but it helps keep the shenanigans at bay.
92 // does not account for forfeiting or withdrawl
95 // does not account for forfeiting or withdrawl
93− const limits = await Promise.all(
97+ await Promise.all(
94− batches.map((_, idx) =>
98+ batches.map((_, idx) =>
95− conditionalSR.getWithdrawLimit(contracts, address, idx)
99+ conditionalSR.getWithdrawLimit(contracts, address, idx)
97− );
102+ ).map(n => parseInt(n));
99− const withdrawn = await conditionalSR.getWithdrawn(contracts, address);
105+ await conditionalSR.getWithdrawn(contracts, address)
106+ ).map(n => parseInt(n));
101 const forfeited = await conditionalSR.getForfeited(contracts, address);
108 const forfeited = await conditionalSR.getForfeited(contracts, address);
@@ -132,17 +139,22 @@ export async function getConditional(contracts, address) {
133export async function getLinear(contracts, address) {
140export async function getLinear(contracts, address) {
134 const batch = await linearSR.getBatch(contracts, address);
141 const batch = await linearSR.getBatch(contracts, address);
143+ //NOTE careful, we get the batch data as strings!
144+ const amount = parseInt(batch.amount);
145+ const withdrawn = parseInt(batch.withdrawn);
135− if (batch.amount === 0) {
147+ if (amount === 0) {
136 return { available: 0, withdrawn: 0, total: 0 };
148 return { available: 0, withdrawn: 0, total: 0 };
151+ //NOTE be careful, getting the withdraw limit for an address that doesn't
152+ // have a lockup throws an exception!
153+ const limit = await linearSR.getWithdrawLimit(contracts, address);
139 const remaining = (await linearSR.getRemainingStars(contracts, address))
154 const remaining = (await linearSR.getRemainingStars(contracts, address))
141− const { amount, withdrawn } = batch;
143− const limit = await linearSR.getWithdrawLimit(contracts, address);
144 const available = Math.min(limit - withdrawn, remaining);
157 const available = Math.min(limit - withdrawn, remaining);
146 const total = Math.min(amount, remaining);
158 const total = Math.min(amount, remaining);