no more wildcard notifications

This commit is contained in:
Florian Dold 2020-07-20 16:20:32 +05:30
parent a2e7f21627
commit d331f8b8b6
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
6 changed files with 46 additions and 16 deletions

View File

@ -1118,7 +1118,7 @@ export async function refuseProposal(
); );
if (success) { if (success) {
ws.notify({ ws.notify({
type: NotificationType.Wildcard, type: NotificationType.ProposalRefused,
}); });
} }
} }

View File

@ -336,7 +336,7 @@ async function registerReserveWithBank(
r.retryInfo = initRetryInfo(); r.retryInfo = initRetryInfo();
return r; return r;
}); });
ws.notify({ type: NotificationType.Wildcard }); ws.notify({ type: NotificationType.ReserveRegisteredWithBank });
return processReserveBankStatus(ws, reservePub); return processReserveBankStatus(ws, reservePub);
} }
@ -377,8 +377,6 @@ async function processReserveBankStatusImpl(
await statusResp.json(), await statusResp.json(),
); );
ws.notify({ type: NotificationType.Wildcard });
if (status.selection_done) { if (status.selection_done) {
if (reserve.reserveStatus === ReserveRecordStatus.REGISTERING_BANK) { if (reserve.reserveStatus === ReserveRecordStatus.REGISTERING_BANK) {
await registerReserveWithBank(ws, reservePub); await registerReserveWithBank(ws, reservePub);
@ -420,7 +418,6 @@ async function processReserveBankStatusImpl(
}); });
await incrementReserveRetry(ws, reservePub, undefined); await incrementReserveRetry(ws, reservePub, undefined);
} }
ws.notify({ type: NotificationType.Wildcard });
} }
async function incrementReserveRetry( async function incrementReserveRetry(

View File

@ -19,14 +19,14 @@
* *
* Uses libtool's current:revision:age versioning. * Uses libtool's current:revision:age versioning.
*/ */
export const WALLET_EXCHANGE_PROTOCOL_VERSION = "7:0:0"; export const WALLET_EXCHANGE_PROTOCOL_VERSION = "8:0:0";
/** /**
* Protocol version spoken with the merchant. * Protocol version spoken with the merchant.
* *
* Uses libtool's current:revision:age versioning. * Uses libtool's current:revision:age versioning.
*/ */
export const WALLET_MERCHANT_PROTOCOL_VERSION = "0:0:0"; export const WALLET_MERCHANT_PROTOCOL_VERSION = "1:0:0";
/** /**
* Cache breaker that is appended to queries such as /keys and /wire * Cache breaker that is appended to queries such as /keys and /wire

View File

@ -489,7 +489,6 @@ export async function selectWithdrawalDenoms(
} }
} while (selectedDenoms.selectedDenoms.length > 0 && !allValid); } while (selectedDenoms.selectedDenoms.length > 0 && !allValid);
if (Amounts.cmp(selectedDenoms.totalWithdrawCost, amount) > 0) { if (Amounts.cmp(selectedDenoms.totalWithdrawCost, amount) > 0) {
throw Error("Bug: withdrawal coin selection is wrong"); throw Error("Bug: withdrawal coin selection is wrong");
} }
@ -515,7 +514,9 @@ async function incrementWithdrawalRetry(
wsr.lastError = err; wsr.lastError = err;
await tx.put(Stores.withdrawalGroups, wsr); await tx.put(Stores.withdrawalGroups, wsr);
}); });
ws.notify({ type: NotificationType.WithdrawOperationError }); if (err) {
ws.notify({ type: NotificationType.WithdrawOperationError, error: err });
}
} }
export async function processWithdrawGroup( export async function processWithdrawGroup(

View File

@ -55,7 +55,10 @@ export const enum NotificationType {
PayOperationError = "pay-error", PayOperationError = "pay-error",
WithdrawOperationError = "withdraw-error", WithdrawOperationError = "withdraw-error",
ReserveOperationError = "reserve-error", ReserveOperationError = "reserve-error",
Wildcard = "wildcard", InternalError = "internal-error",
PendingOperationProcessed = "pending-operation-processed",
ProposalRefused = "proposal-refused",
ReserveRegisteredWithBank = "reserve-registered-with-bank",
} }
export interface ProposalAcceptedNotification { export interface ProposalAcceptedNotification {
@ -63,6 +66,12 @@ export interface ProposalAcceptedNotification {
proposalId: string; proposalId: string;
} }
export interface InternalErrorNotification {
type: NotificationType.InternalError;
message: string;
exception: any;
}
export interface CoinWithdrawnNotification { export interface CoinWithdrawnNotification {
type: NotificationType.CoinWithdrawn; type: NotificationType.CoinWithdrawn;
} }
@ -167,6 +176,7 @@ export interface TipOperationErrorNotification {
export interface WithdrawOperationErrorNotification { export interface WithdrawOperationErrorNotification {
type: NotificationType.WithdrawOperationError; type: NotificationType.WithdrawOperationError;
error: OperationError,
} }
export interface RecoupOperationErrorNotification { export interface RecoupOperationErrorNotification {
@ -182,8 +192,16 @@ export interface ReserveCreatedNotification {
type: NotificationType.ReserveCreated; type: NotificationType.ReserveCreated;
} }
export interface WildcardNotification { export interface PendingOperationProcessedNotification {
type: NotificationType.Wildcard; type: NotificationType.PendingOperationProcessed;
}
export interface ProposalRefusedNotification {
type: NotificationType.ProposalRefused;
}
export interface ReserveRegisteredWithBankNotification {
type: NotificationType.ReserveRegisteredWithBank;
} }
export type WalletNotification = export type WalletNotification =
@ -215,5 +233,8 @@ export type WalletNotification =
| RefundQueriedNotification | RefundQueriedNotification
| WithdrawalGroupCreatedNotification | WithdrawalGroupCreatedNotification
| CoinWithdrawnNotification | CoinWithdrawnNotification
| WildcardNotification | RecoupOperationErrorNotification
| RecoupOperationErrorNotification; | InternalErrorNotification
| PendingOperationProcessedNotification
| ProposalRefusedNotification
| ReserveRegisteredWithBankNotification;

View File

@ -364,9 +364,20 @@ export class Wallet {
try { try {
await this.processOnePendingOperation(p); await this.processOnePendingOperation(p);
} catch (e) { } catch (e) {
console.error(e); if (e instanceof OperationFailedAndReportedError) {
logger.warn("operation processed resulted in reported error");
} else {
console.error("Uncaught exception", e);
this.ws.notify({
type: NotificationType.InternalError,
message: "uncaught exception",
exception: e,
});
} }
this.ws.notify({ type: NotificationType.Wildcard }); }
this.ws.notify({
type: NotificationType.PendingOperationProcessed,
});
} }
} }
} }