Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions packages/wallet/backend/src/rafiki/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ export enum EventType {
IncomingPaymentExpired = 'incoming_payment.expired',
OutgoingPaymentCreated = 'outgoing_payment.created',
OutgoingPaymentCompleted = 'outgoing_payment.completed',
OutgoingPaymentFailed = 'outgoing_payment.failed',
WalletAddressNotFound = 'wallet_address.not_found'
OutgoingPaymentFailed = 'outgoing_payment.failed'
}

export interface WebHook {
Expand Down Expand Up @@ -93,11 +92,7 @@ export class RafikiService implements IRafikiService {
) {}

public async onWebHook(wh: WebhookType): Promise<void> {
this.logger.info(
`received webhook of type : ${wh.type} for : ${
wh.type === EventType.WalletAddressNotFound ? '' : `${wh.id}}`
}`
)
this.logger.info(`received webhook of type : ${wh.type} for : ${wh.id}`)

switch (wh.type) {
case EventType.OutgoingPaymentCreated:
Expand All @@ -118,9 +113,6 @@ export class RafikiService implements IRafikiService {
case EventType.IncomingPaymentExpired:
await this.handleIncomingPaymentExpired(wh)
break
case EventType.WalletAddressNotFound:
this.logger.warn(`${EventType.WalletAddressNotFound} received`)
break
}
}

Expand Down
11 changes: 2 additions & 9 deletions packages/wallet/backend/src/rafiki/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,10 @@ export const outgoingPaymentWebhookSchema = z.object({
]),
data: outgoingPaymentSchema
})
export const walletAddressWebhookSchema = z.object({
id: z.string(),
type: z.literal(EventType.WalletAddressNotFound),
data: z.object({
walletAddressUrl: z.string()
})
})

export const webhookSchema = z.discriminatedUnion('type', [
incomingPaymentWebhookSchema,
outgoingPaymentWebhookSchema,
walletAddressWebhookSchema
outgoingPaymentWebhookSchema
])

export const webhookBodySchema = z.object({
Expand Down
Loading