From 157a80f2e3b5bdeb159e9049f7898c87859bf718 Mon Sep 17 00:00:00 2001 From: Nicolas Burtey Date: Sat, 23 Sep 2023 15:22:27 +0100 Subject: [PATCH] chore: remove the uid page view --- .../app/api/card/{id => }/[id]/invoice/route.ts | 0 .../boltcard/app/api/card/{id => }/[id]/route.ts | 0 .../api/card/{id => }/[id]/transactions/route.ts | 0 apps/boltcard/app/api/card/uid/[uid]/route.ts | 16 ---------------- apps/boltcard/app/api/program/route.ts | 2 ++ apps/boltcard/app/card/[id]/page.tsx | 6 +++--- apps/boltcard/bats/e2e-test.bats | 11 +++++------ 7 files changed, 10 insertions(+), 25 deletions(-) rename apps/boltcard/app/api/card/{id => }/[id]/invoice/route.ts (100%) rename apps/boltcard/app/api/card/{id => }/[id]/route.ts (100%) rename apps/boltcard/app/api/card/{id => }/[id]/transactions/route.ts (100%) delete mode 100644 apps/boltcard/app/api/card/uid/[uid]/route.ts diff --git a/apps/boltcard/app/api/card/id/[id]/invoice/route.ts b/apps/boltcard/app/api/card/[id]/invoice/route.ts similarity index 100% rename from apps/boltcard/app/api/card/id/[id]/invoice/route.ts rename to apps/boltcard/app/api/card/[id]/invoice/route.ts diff --git a/apps/boltcard/app/api/card/id/[id]/route.ts b/apps/boltcard/app/api/card/[id]/route.ts similarity index 100% rename from apps/boltcard/app/api/card/id/[id]/route.ts rename to apps/boltcard/app/api/card/[id]/route.ts diff --git a/apps/boltcard/app/api/card/id/[id]/transactions/route.ts b/apps/boltcard/app/api/card/[id]/transactions/route.ts similarity index 100% rename from apps/boltcard/app/api/card/id/[id]/transactions/route.ts rename to apps/boltcard/app/api/card/[id]/transactions/route.ts diff --git a/apps/boltcard/app/api/card/uid/[uid]/route.ts b/apps/boltcard/app/api/card/uid/[uid]/route.ts deleted file mode 100644 index f66bfc297e5..00000000000 --- a/apps/boltcard/app/api/card/uid/[uid]/route.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { NextRequest, NextResponse } from "next/server" - -import { fetchPublicByCardUid } from "@/services/db/card" - -export async function GET(req: NextRequest, { params }: { params: { uid: string } }) { - const uid = params.uid - const card = await fetchPublicByCardUid(uid) - if (!card) { - return NextResponse.json( - { status: "ERROR", reason: "card not found" }, - { status: 400 }, - ) - } - - return NextResponse.json(card) -} diff --git a/apps/boltcard/app/api/program/route.ts b/apps/boltcard/app/api/program/route.ts index 921d295f708..d5be2c6b805 100644 --- a/apps/boltcard/app/api/program/route.ts +++ b/apps/boltcard/app/api/program/route.ts @@ -8,6 +8,7 @@ interface ActivateCardResponse { protocol_name: string protocol_version: number card_name: string + cardId: string lnurlw_base: string k0: string k1: string @@ -54,6 +55,7 @@ export async function GET(req: NextRequest) { protocol_name: "create_bolt_card_response", protocol_version: 2, card_name: cardKeysSetup.cardId, + cardId: cardKeysSetup.cardId, lnurlw_base: lnurlwBase, k0: cardKeysSetup.k0AuthKey, k1: k1DecryptKey, diff --git a/apps/boltcard/app/card/[id]/page.tsx b/apps/boltcard/app/card/[id]/page.tsx index 450e0acd2b7..4a1e1a90309 100644 --- a/apps/boltcard/app/card/[id]/page.tsx +++ b/apps/boltcard/app/card/[id]/page.tsx @@ -6,11 +6,11 @@ import { isAdmin, serverUrl } from "@/services/config" export default async function Card({ params }: { params: { id: string } }) { const { id } = params - const cardApi = `${serverUrl}/api/card/id/${id}` + const cardApi = `${serverUrl}/api/card/${id}` const cardResult = await fetch(cardApi, { cache: "no-store" }) const cardInfo = await cardResult.json() - const transactionsApi = `${serverUrl}/api/card/id/${id}/transactions` + const transactionsApi = `${serverUrl}/api/card/${id}/transactions` const transactionsResult = await fetch(transactionsApi, { cache: "no-store" }) const transactionsInfo = await transactionsResult.json() @@ -26,7 +26,7 @@ export default async function Card({ params }: { params: { id: string } }) { lnurlQrCode = await QRCode.toDataURL(cardInfo.lnurlp, { width: 300 }) } - const invoiceApi = `${serverUrl}/api/card/id/${id}/invoice` + const invoiceApi = `${serverUrl}/api/card/${id}/invoice` const invoiceResult = await fetch(invoiceApi, { cache: "no-store" }) const invoiceInfo = await invoiceResult.json() const invoice = invoiceInfo?.data diff --git a/apps/boltcard/bats/e2e-test.bats b/apps/boltcard/bats/e2e-test.bats index bc50b37c5bb..4408ae16828 100644 --- a/apps/boltcard/bats/e2e-test.bats +++ b/apps/boltcard/bats/e2e-test.bats @@ -33,9 +33,11 @@ random_phone() { K1_VALUE=$(echo $RESPONSE | jq -r '.k1') K2_VALUE=$(echo $RESPONSE | jq -r '.k2') + cardId=$(echo $RESPONSE | jq -r '.cardId') cache_value "k1" "$K1_VALUE" cache_value "k2" "$K2_VALUE" + cache_value "cardId" "$cardId" } @test "payment: first ln call" { @@ -57,16 +59,13 @@ random_phone() { echo "K1_CALLBACK: $K1_CALLBACK" cache_value "k1_callback" "$K1_CALLBACK" - cache_value "uid" "$uid" } # todo: a second ln call; the paths are different @test "onchain funding" { - uid=$(read_value "uid") - address=$(curl -s http://localhost:3000/api/card/uid/${uid} | jq -r '.onchainAddress') - cardId=$(curl -s http://localhost:3000/api/card/uid/${uid} | jq -r '.id') - cache_value "cardId" "$cardId" + cardId=$(read_value "cardId") + address=$(curl -s http://localhost:3000/api/card/${cardId} | jq -r '.onchainAddress') amount="0.001" token_name=$(read_value "alice") @@ -108,7 +107,7 @@ random_phone() { @test "transactions" { cardId=$(read_value "cardId") - response=$(curl -s http://localhost:3000/api/card/id/$cardId/transactions) + response=$(curl -s http://localhost:3000/api/card/$cardId/transactions) echo "$response" count=$(echo "$response" | jq 'length')