-only return coin indices for successfully withdrawn coins
This commit is contained in:
parent
c8336c8c2c
commit
49608f0bbb
@ -492,7 +492,7 @@ async function processPlanchetExchangeBatchRequest(
|
|||||||
|
|
||||||
const batchReq: ExchangeBatchWithdrawRequest = { planchets: [] };
|
const batchReq: ExchangeBatchWithdrawRequest = { planchets: [] };
|
||||||
// Indices of coins that are included in the batch request
|
// Indices of coins that are included in the batch request
|
||||||
const coinIdxs: number[] = [];
|
const requestCoinIdxs: number[] = [];
|
||||||
|
|
||||||
await ws.db
|
await ws.db
|
||||||
.mktx((x) => [
|
.mktx((x) => [
|
||||||
@ -537,7 +537,7 @@ async function processPlanchetExchangeBatchRequest(
|
|||||||
coin_ev: planchet.coinEv,
|
coin_ev: planchet.coinEv,
|
||||||
};
|
};
|
||||||
batchReq.planchets.push(planchetReq);
|
batchReq.planchets.push(planchetReq);
|
||||||
coinIdxs.push(coinIdx);
|
requestCoinIdxs.push(coinIdx);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -563,7 +563,7 @@ async function processPlanchetExchangeBatchRequest(
|
|||||||
for (let i = startIdx; i < coinIdxs.length; i++) {
|
for (let i = startIdx; i < coinIdxs.length; i++) {
|
||||||
let planchet = await tx.planchets.indexes.byGroupAndIndex.get([
|
let planchet = await tx.planchets.indexes.byGroupAndIndex.get([
|
||||||
withdrawalGroup.withdrawalGroupId,
|
withdrawalGroup.withdrawalGroupId,
|
||||||
coinIdxs[i],
|
requestCoinIdxs[i],
|
||||||
]);
|
]);
|
||||||
if (!planchet) {
|
if (!planchet) {
|
||||||
continue;
|
continue;
|
||||||
@ -623,11 +623,11 @@ async function processPlanchetExchangeBatchRequest(
|
|||||||
codecForWithdrawBatchResponse(),
|
codecForWithdrawBatchResponse(),
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
coinIdxs,
|
coinIdxs: requestCoinIdxs,
|
||||||
batchResp: r,
|
batchResp: r,
|
||||||
};
|
};
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
await storeCoinError(e, coinIdxs[0]);
|
await storeCoinError(e, requestCoinIdxs[0]);
|
||||||
return {
|
return {
|
||||||
batchResp: { ev_sigs: [] },
|
batchResp: { ev_sigs: [] },
|
||||||
coinIdxs: [],
|
coinIdxs: [],
|
||||||
@ -638,6 +638,7 @@ async function processPlanchetExchangeBatchRequest(
|
|||||||
const responses: ExchangeWithdrawBatchResponse = {
|
const responses: ExchangeWithdrawBatchResponse = {
|
||||||
ev_sigs: [],
|
ev_sigs: [],
|
||||||
};
|
};
|
||||||
|
const responseCoinIdxs: number[] = [];
|
||||||
for (let i = 0; i < batchReq.planchets.length; i++) {
|
for (let i = 0; i < batchReq.planchets.length; i++) {
|
||||||
try {
|
try {
|
||||||
const p = batchReq.planchets[i];
|
const p = batchReq.planchets[i];
|
||||||
@ -650,7 +651,7 @@ async function processPlanchetExchangeBatchRequest(
|
|||||||
await handleKycRequired(resp, i);
|
await handleKycRequired(resp, i);
|
||||||
// We still return blinded coins that we could actually withdraw.
|
// We still return blinded coins that we could actually withdraw.
|
||||||
return {
|
return {
|
||||||
coinIdxs,
|
coinIdxs: responseCoinIdxs,
|
||||||
batchResp: responses,
|
batchResp: responses,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -659,12 +660,13 @@ async function processPlanchetExchangeBatchRequest(
|
|||||||
codecForWithdrawResponse(),
|
codecForWithdrawResponse(),
|
||||||
);
|
);
|
||||||
responses.ev_sigs.push(r);
|
responses.ev_sigs.push(r);
|
||||||
|
responseCoinIdxs.push(requestCoinIdxs[i]);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
await storeCoinError(e, coinIdxs[i]);
|
await storeCoinError(e, requestCoinIdxs[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
coinIdxs,
|
coinIdxs: responseCoinIdxs,
|
||||||
batchResp: responses,
|
batchResp: responses,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user