aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2023-11-09 14:54:15 +0100
committerFlorian Dold <florian@dold.me>2023-11-09 14:54:27 +0100
commitf1e6fe17303ae21000b596b05dfb8b24163b0880 (patch)
tree3f0e3493cccc803ef6329d72e407ac739eee9a85
parent7e3d6938bf5184b88ab4d0b75e4dc3d10af7c60a (diff)
wallet-core: deliver kyc URL via experimental user data
Currently only needed by iOS, might be removed in the future.
-rw-r--r--packages/taler-util/src/notifications.ts13
-rw-r--r--packages/taler-wallet-core/src/operations/transactions.ts2
-rw-r--r--packages/taler-wallet-core/src/operations/withdraw.ts21
3 files changed, 26 insertions, 10 deletions
diff --git a/packages/taler-util/src/notifications.ts b/packages/taler-util/src/notifications.ts
index ed26c6ae7..b91d91777 100644
--- a/packages/taler-util/src/notifications.ts
+++ b/packages/taler-util/src/notifications.ts
@@ -46,6 +46,17 @@ export interface TransactionStateTransitionNotification {
oldTxState: TransactionState;
newTxState: TransactionState;
errorInfo?: ErrorInfoSummary;
+
+ /**
+ * Additional "user data" that is dependent on the
+ * state transition.
+ *
+ * Usage should be avoided.
+ *
+ * Currently used to notify the iOS app about
+ * the KYC URL.
+ */
+ experimentalUserData?: any;
}
export interface ExchangeAddedNotification {
@@ -66,13 +77,11 @@ export interface BackupOperationErrorNotification {
error: TalerErrorDetail;
}
-
export interface PendingOperationProcessedNotification {
type: NotificationType.PendingOperationProcessed;
id: string;
}
-
export type WalletNotification =
| BalanceChangeNotification
| BackupOperationErrorNotification
diff --git a/packages/taler-wallet-core/src/operations/transactions.ts b/packages/taler-wallet-core/src/operations/transactions.ts
index 33ee2b424..a30120baa 100644
--- a/packages/taler-wallet-core/src/operations/transactions.ts
+++ b/packages/taler-wallet-core/src/operations/transactions.ts
@@ -1934,6 +1934,7 @@ export function notifyTransition(
ws: InternalWalletState,
transactionId: string,
transitionInfo: TransitionInfo | undefined,
+ experimentalUserData: any = undefined,
): void {
if (
transitionInfo &&
@@ -1947,6 +1948,7 @@ export function notifyTransition(
oldTxState: transitionInfo.oldTxState,
newTxState: transitionInfo.newTxState,
transactionId,
+ experimentalUserData,
});
}
ws.workAvailable.trigger();
diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts b/packages/taler-wallet-core/src/operations/withdraw.ts
index 5b8d101b1..c83993816 100644
--- a/packages/taler-wallet-core/src/operations/withdraw.ts
+++ b/packages/taler-wallet-core/src/operations/withdraw.ts
@@ -781,6 +781,8 @@ async function handleKycRequired(
throw Error(`unexpected response from kyc-check (${kycStatusRes.status})`);
}
+ let notificationKycUrl: string | undefined = undefined;
+
const transitionInfo = await ws.db
.mktx((x) => [x.planchets, x.withdrawalGroups])
.runReadWrite(async (tx) => {
@@ -813,10 +815,12 @@ async function handleKycRequired(
amlStatus === AmlStatus.normal || amlStatus === undefined
? WithdrawalGroupStatus.PendingKyc
: amlStatus === AmlStatus.pending
- ? WithdrawalGroupStatus.PendingAml
- : amlStatus === AmlStatus.fronzen
- ? WithdrawalGroupStatus.SuspendedAml
- : assertUnreachable(amlStatus);
+ ? WithdrawalGroupStatus.PendingAml
+ : amlStatus === AmlStatus.fronzen
+ ? WithdrawalGroupStatus.SuspendedAml
+ : assertUnreachable(amlStatus);
+
+ notificationKycUrl = kycUrl;
await tx.withdrawalGroups.put(wg2);
const newTxState = computeWithdrawalTransactionStatus(wg2);
@@ -829,7 +833,7 @@ async function handleKycRequired(
return undefined;
}
});
- notifyTransition(ws, transactionId, transitionInfo);
+ notifyTransition(ws, transactionId, transitionInfo, notificationKycUrl);
}
/**
@@ -1102,7 +1106,7 @@ async function processPlanchetVerifyAndStoreCoin(
return false;
}
p.planchetStatus = PlanchetStatus.WithdrawalDone;
- p.lastError = undefined
+ p.lastError = undefined;
await tx.planchets.put(p);
await makeCoinAvailable(ws, tx, coin);
return true;
@@ -1150,7 +1154,8 @@ export async function updateWithdrawalDenoms(
denom.verificationStatus === DenominationVerificationStatus.Unverified
) {
logger.trace(
- `Validating denomination (${current + 1}/${denominations.length
+ `Validating denomination (${current + 1}/${
+ denominations.length
}) signature of ${denom.denomPubHash}`,
);
let valid = false;
@@ -1775,7 +1780,7 @@ export async function getExchangeWithdrawalInfo(
) {
logger.warn(
`wallet's support for exchange protocol version ${WALLET_EXCHANGE_PROTOCOL_VERSION} might be outdated ` +
- `(exchange has ${exchangeDetails.protocolVersionRange}), checking for updates`,
+ `(exchange has ${exchangeDetails.protocolVersionRange}), checking for updates`,
);
}
}