Skip to content

Commit

Permalink
chore: update alby packages, improve error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
rolznz committed Sep 13, 2023
1 parent 5b32f5c commit f4c7362
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 31 deletions.
2 changes: 1 addition & 1 deletion app/confirm/components/ConfirmSubscriptionForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { CreateSubscriptionRequest } from "types/CreateSubscriptionRequest";
import { useRouter } from "next/navigation";
import { CreateSubscriptionResponse } from "types/CreateSubscriptionResponse";
import React from "react";
import { webln } from "alby-js-sdk";
import { webln } from "@getalby/sdk";
import { UnconfirmedSubscription } from "types/UnconfirmedSubscription";
import { isValidNostrConnectUrl } from "lib/validation";
import { Box } from "app/components/Box";
Expand Down
10 changes: 5 additions & 5 deletions app/create/components/CreateSubscriptionForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import { useForm } from "react-hook-form";
import { useRouter } from "next/navigation";
import React from "react";
import { Timeframe, timeframes } from "types/Timeframe";
import { LightningAddress } from "alby-tools";
import { RequestInvoiceArgs } from "alby-tools/dist/types";
import { Loading } from "app/components/Loading";
import { CreateSubscriptionRequest } from "types/CreateSubscriptionRequest";
import { isValidPositiveValue, validateLightningAddress } from "lib/validation";
import { Box } from "app/components/Box";
import { Button } from "app/components/Button";

// TODO: remove when alby-tools exposes LUD18PayerData
type LUD18PayerData = RequestInvoiceArgs["payerdata"];
import {
LUD18PayerData,
LightningAddress,
RequestInvoiceArgs,
} from "@getalby/lightning-tools";

type CreateSubscriptionFormData = Omit<
CreateSubscriptionRequest,
Expand Down
4 changes: 2 additions & 2 deletions lib/server/sendEmail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type EmailTemplate = (
subscription: Subscription;
};

export const sendEmail = (to: string, template: EmailTemplate) => {
export const sendEmail = async (to: string, template: EmailTemplate) => {
const subscriptionUrl = getSubscriptionUrl(template.subscription.id);
if (transport) {
// TODO: templates
Expand All @@ -59,7 +59,7 @@ export const sendEmail = (to: string, template: EmailTemplate) => {
getEmailHtml(template) +
`<br/><br/>Manage your recurring payment: <a href="${subscriptionUrl}">${subscriptionUrl}</a>`;
try {
transport.sendMail({
await transport.sendMail({
to,
subject,
html,
Expand Down
2 changes: 1 addition & 1 deletion lib/validation.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LightningAddress } from "alby-tools";
import { LightningAddress } from "@getalby/lightning-tools";

export const isValidPositiveValue = (value: number) => {
return !isNaN(value) && value > 0;
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
"@types/node": "20.6.0",
"@types/react": "18.2.21",
"@types/react-dom": "18.2.7",
"alby-js-sdk": "^2.3.0",
"alby-tools": "^3.2.1",
"@getalby/sdk": "^2.4.0",
"@getalby/lightning-tools": "^4.0.2",
"autoprefixer": "^10.4.15",
"clsx": "^2.0.0",
"daisyui": "^3.7.3",
Expand Down
14 changes: 11 additions & 3 deletions pages/api/inngest.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import crypto from "crypto";
import { webln } from "alby-js-sdk";
import { LightningAddress } from "alby-tools";
import { webln } from "@getalby/sdk";
import { LightningAddress } from "@getalby/lightning-tools";
import { EventSchemas, Inngest } from "inngest";
import { serve } from "inngest/next";
import { prismaClient } from "lib/server/prisma";
Expand Down Expand Up @@ -272,7 +272,15 @@ const periodicZap = inngest.createFunction(
if (ENABLE_REPEAT_EVENTS) {
// create a new event object without inngest-added properties (id, ts)
const newEvent: typeof event = { data: event.data, name: event.name };
await step.sendEvent(newEvent);
try {
await step.sendEvent(newEvent);
} catch (error) {
logger.error("Failed to reschedule event", {
error,
subscriptionId: event.data.subscriptionId,
});
throw error;
}
}

return { event, body: "OK" };
Expand Down
34 changes: 17 additions & 17 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,23 @@
resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.49.0.tgz#86f79756004a97fa4df866835093f1df3d03c333"
integrity sha512-1S8uAY/MTJqVx0SC4epBq+N2yhuwtNwLbJYNZyhL2pO1ZVKn5HFXav5T41Ryzy9K9V7ZId2JB2oy/W4aCd9/2w==

"@getalby/lightning-tools@^4.0.2":
version "4.0.2"
resolved "https://registry.yarnpkg.com/@getalby/lightning-tools/-/lightning-tools-4.0.2.tgz#a6f5127ca768de28e87cff101508cd2d90590b60"
integrity sha512-6EOo4iqjc4BB37KPtzkTR2Fn/Bf5W7Zqb7sYW4pdPRHKTwbtPSgCFqsankAqn6pXxvnvy/kn0ueFz6af7zYijg==
dependencies:
crypto-js "^4.1.1"
light-bolt11-decoder "^3.0.0"

"@getalby/sdk@^2.4.0":
version "2.4.0"
resolved "https://registry.yarnpkg.com/@getalby/sdk/-/sdk-2.4.0.tgz#fd3a6b24585e3dc32462da97c4b13a70294c7dee"
integrity sha512-aIGNwLRF9coj6koxfq7P4GtFZbFjQbnIheix39x9176PwFw4dXOdGXHPXnqioJTmeq80y+vX1yd+u/f03YGoeg==
dependencies:
crypto-js "^4.1.1"
events "^3.3.0"
nostr-tools "1.13.1"

"@humanwhocodes/config-array@^0.11.11":
version "0.11.11"
resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.11.tgz#88a04c570dbbc7dd943e4712429c3df09bc32844"
Expand Down Expand Up @@ -619,23 +636,6 @@ ajv@^6.12.4:
json-schema-traverse "^0.4.1"
uri-js "^4.2.2"

alby-js-sdk@^2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/alby-js-sdk/-/alby-js-sdk-2.3.0.tgz#d460436d5078b4d229b1f10bcf0d40f341374f1b"
integrity sha512-EZ7c1tk85IjDC6fzzIcliZNCUnAHhL5EfoqzXCfn7DExvaFHxJLOpacy6X9zdtXWVFX/SPWovQtR/OioG6uDUw==
dependencies:
crypto-js "^4.1.1"
events "^3.3.0"
nostr-tools "1.13.1"

alby-tools@^3.2.1:
version "3.2.1"
resolved "https://registry.yarnpkg.com/alby-tools/-/alby-tools-3.2.1.tgz#60f15983454b6635cd90da40f097d32fd0875308"
integrity sha512-dSQ6dBD/qXeBfF40g3PtzLo6yvN5w9zaQ9qeGFkez6feQ4qVMFq+iuxurCDTaR2KFxAf5fboWNZechl7DuH5Sw==
dependencies:
crypto-js "^4.1.1"
light-bolt11-decoder "^3.0.0"

ansi-regex@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304"
Expand Down

0 comments on commit f4c7362

Please sign in to comment.