add missing kyc url for manual withdrawal and add support for 451 case: aml-required
This commit is contained in:
parent
7e37b34744
commit
9c17b7cd92
@ -699,6 +699,7 @@ function buildTransactionForManualWithdraw(
|
|||||||
withdrawalGroup.status === WithdrawalGroupStatus.Finished ||
|
withdrawalGroup.status === WithdrawalGroupStatus.Finished ||
|
||||||
withdrawalGroup.status === WithdrawalGroupStatus.PendingReady,
|
withdrawalGroup.status === WithdrawalGroupStatus.PendingReady,
|
||||||
},
|
},
|
||||||
|
kycUrl: withdrawalGroup.kycUrl,
|
||||||
exchangeBaseUrl: withdrawalGroup.exchangeBaseUrl,
|
exchangeBaseUrl: withdrawalGroup.exchangeBaseUrl,
|
||||||
timestamp: withdrawalGroup.timestampStart,
|
timestamp: withdrawalGroup.timestampStart,
|
||||||
transactionId: constructTransactionIdentifier({
|
transactionId: constructTransactionIdentifier({
|
||||||
|
@ -725,6 +725,9 @@ interface WithdrawalBatchResult {
|
|||||||
coinIdxs: number[];
|
coinIdxs: number[];
|
||||||
batchResp: ExchangeWithdrawBatchResponse;
|
batchResp: ExchangeWithdrawBatchResponse;
|
||||||
}
|
}
|
||||||
|
enum AmlStatus {
|
||||||
|
normal= 0, pending = 1, fronzen = 2,
|
||||||
|
}
|
||||||
|
|
||||||
async function handleKycRequired(
|
async function handleKycRequired(
|
||||||
ws: InternalWalletState,
|
ws: InternalWalletState,
|
||||||
@ -757,6 +760,7 @@ async function handleKycRequired(
|
|||||||
method: "GET",
|
method: "GET",
|
||||||
});
|
});
|
||||||
let kycUrl: string;
|
let kycUrl: string;
|
||||||
|
let amlStatus: AmlStatus | undefined;
|
||||||
if (
|
if (
|
||||||
kycStatusRes.status === HttpStatusCode.Ok ||
|
kycStatusRes.status === HttpStatusCode.Ok ||
|
||||||
//FIXME: NoContent is not expected https://docs.taler.net/core/api-exchange.html#post--purses-$PURSE_PUB-merge
|
//FIXME: NoContent is not expected https://docs.taler.net/core/api-exchange.html#post--purses-$PURSE_PUB-merge
|
||||||
@ -769,6 +773,10 @@ async function handleKycRequired(
|
|||||||
const kycStatus = await kycStatusRes.json();
|
const kycStatus = await kycStatusRes.json();
|
||||||
logger.info(`kyc status: ${j2s(kycStatus)}`);
|
logger.info(`kyc status: ${j2s(kycStatus)}`);
|
||||||
kycUrl = kycStatus.kyc_url;
|
kycUrl = kycStatus.kyc_url;
|
||||||
|
} else if (kycStatusRes.status === HttpStatusCode.UnavailableForLegalReasons) {
|
||||||
|
const kycStatus = await kycStatusRes.json();
|
||||||
|
logger.info(`aml status: ${j2s(kycStatus)}`);
|
||||||
|
amlStatus = kycStatus.aml_status;
|
||||||
} else {
|
} else {
|
||||||
throw Error(`unexpected response from kyc-check (${kycStatusRes.status})`);
|
throw Error(`unexpected response from kyc-check (${kycStatusRes.status})`);
|
||||||
}
|
}
|
||||||
@ -801,7 +809,11 @@ async function handleKycRequired(
|
|||||||
requirementRow: uuidResp.requirement_row,
|
requirementRow: uuidResp.requirement_row,
|
||||||
};
|
};
|
||||||
wg2.kycUrl = kycUrl;
|
wg2.kycUrl = kycUrl;
|
||||||
wg2.status = WithdrawalGroupStatus.PendingKyc;
|
wg2.status = amlStatus === AmlStatus.normal || amlStatus === undefined ? WithdrawalGroupStatus.PendingKyc :
|
||||||
|
amlStatus === AmlStatus.pending ? WithdrawalGroupStatus.PendingAml :
|
||||||
|
amlStatus === AmlStatus.fronzen ? WithdrawalGroupStatus.SuspendedAml :
|
||||||
|
assertUnreachable(amlStatus);
|
||||||
|
|
||||||
await tx.withdrawalGroups.put(wg2);
|
await tx.withdrawalGroups.put(wg2);
|
||||||
const newTxState = computeWithdrawalTransactionStatus(wg2);
|
const newTxState = computeWithdrawalTransactionStatus(wg2);
|
||||||
return {
|
return {
|
||||||
@ -1428,7 +1440,6 @@ async function processWithdrawalGroupPendingKyc(
|
|||||||
url.searchParams.set("timeout_ms", "30000");
|
url.searchParams.set("timeout_ms", "30000");
|
||||||
|
|
||||||
const retryTag = TaskIdentifiers.forWithdrawal(withdrawalGroup);
|
const retryTag = TaskIdentifiers.forWithdrawal(withdrawalGroup);
|
||||||
|
|
||||||
runLongpollAsync(ws, retryTag, async (cancellationToken) => {
|
runLongpollAsync(ws, retryTag, async (cancellationToken) => {
|
||||||
logger.info(`long-polling for withdrawal KYC status via ${url.href}`);
|
logger.info(`long-polling for withdrawal KYC status via ${url.href}`);
|
||||||
const kycStatusRes = await ws.http.fetch(url.href, {
|
const kycStatusRes = await ws.http.fetch(url.href, {
|
||||||
@ -1451,6 +1462,10 @@ async function processWithdrawalGroupPendingKyc(
|
|||||||
logger.info(`kyc status: ${j2s(kycStatus)}`);
|
logger.info(`kyc status: ${j2s(kycStatus)}`);
|
||||||
// FIXME: do we need to update the KYC url, or does it always stay constant?
|
// FIXME: do we need to update the KYC url, or does it always stay constant?
|
||||||
return { ready: false };
|
return { ready: false };
|
||||||
|
} else if (kycStatusRes.status === HttpStatusCode.UnavailableForLegalReasons) {
|
||||||
|
const kycStatus = await kycStatusRes.json();
|
||||||
|
logger.info(`aml status: ${j2s(kycStatus)}`);
|
||||||
|
return {ready : false}
|
||||||
} else {
|
} else {
|
||||||
throw Error(
|
throw Error(
|
||||||
`unexpected response from kyc-check (${kycStatusRes.status})`,
|
`unexpected response from kyc-check (${kycStatusRes.status})`,
|
||||||
|
Loading…
Reference in New Issue
Block a user