Skip to content

Commit

Permalink
feat: add uncle jim internal app
Browse files Browse the repository at this point in the history
  • Loading branch information
rolznz committed Aug 28, 2024
1 parent 6350efe commit 4ebd032
Show file tree
Hide file tree
Showing 17 changed files with 479 additions and 96 deletions.
6 changes: 1 addition & 5 deletions db/db_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,9 @@ func NewDBService(db *gorm.DB, eventPublisher events.EventPublisher) *dbService
}

func (svc *dbService) CreateApp(name string, pubkey string, maxAmountSat uint64, budgetRenewal string, expiresAt *time.Time, scopes []string, isolated bool) (*App, string, error) {
if isolated && (slices.Contains(scopes, constants.GET_INFO_SCOPE)) {
// cannot return node info because the isolated app is a custodial subaccount
return nil, "", errors.New("Isolated app cannot have get_info scope")
}
if isolated && (slices.Contains(scopes, constants.SIGN_MESSAGE_SCOPE)) {
// cannot sign messages because the isolated app is a custodial subaccount
return nil, "", errors.New("Isolated app cannot have sign_message scope")
return nil, "", errors.New("isolated app cannot have sign_message scope")
}

var pairingPublicKey string
Expand Down
1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
},
"dependencies": {
"@getalby/bitcoin-connect-react": "^3.6.2",
"@radix-ui/react-accordion": "^1.2.0",
"@radix-ui/react-alert-dialog": "^1.0.5",
"@radix-ui/react-avatar": "^1.0.4",
"@radix-ui/react-checkbox": "^1.0.4",
Expand Down
Binary file added frontend/src/assets/suggested-apps/uncle-jim.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion frontend/src/components/CloseChannelDialogContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export function CloseChannelDialogContent({ alias, channel }: Props) {

const copy = (text: string) => {
copyToClipboard(text, toast);
toast({ title: "Copied to clipboard." });
};

async function closeChannel() {
Expand Down
11 changes: 10 additions & 1 deletion frontend/src/components/SuggestedAppData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import paperScissorsHodl from "src/assets/suggested-apps/paper-scissors-hodl.png
import primal from "src/assets/suggested-apps/primal.png";
import snort from "src/assets/suggested-apps/snort.png";
import stackernews from "src/assets/suggested-apps/stackernews.png";
import uncleJim from "src/assets/suggested-apps/uncle-jim.png";
import wavelake from "src/assets/suggested-apps/wavelake.png";
import wherostr from "src/assets/suggested-apps/wherostr.png";
import yakihonne from "src/assets/suggested-apps/yakihonne.png";
Expand All @@ -20,7 +21,8 @@ import zappybird from "src/assets/suggested-apps/zappy-bird.png";

export type SuggestedApp = {
id: string;
webLink: string;
webLink?: string;
internal?: boolean;
playLink?: string;
appleLink?: string;
title: string;
Expand All @@ -29,6 +31,13 @@ export type SuggestedApp = {
};

export const suggestedApps: SuggestedApp[] = [
{
id: "uncle-jim",
title: "Uncle Jim",
description: "Onboard your friends and family with your hub",
internal: true,
logo: uncleJim,
},
{
id: "alby-extension",
title: "Alby Extension",
Expand Down
46 changes: 38 additions & 8 deletions frontend/src/components/SuggestedApps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ function SuggestedAppCard({
</CardContent>
<CardFooter className="flex flex-row justify-between">
<div className="flex flex-row gap-4">
<ExternalLink to={webLink}>
<Button variant="outline" size="icon">
<Globe className="w-4 h-4" />
</Button>
</ExternalLink>
{webLink && (
<ExternalLink to={webLink}>
<Button variant="outline" size="icon">
<Globe className="w-4 h-4" />
</Button>
</ExternalLink>
)}
{appleLink && (
<ExternalLink to={appleLink}>
<Button variant="outline" size="icon">
Expand All @@ -67,13 +69,41 @@ function SuggestedAppCard({
);
}

function InternalAppCard({ id, title, description, logo }: SuggestedApp) {
return (
<Card>
<CardContent className="pt-6">
<div className="flex gap-3 items-center">
<img src={logo} alt="logo" className="inline rounded-lg w-12 h-12" />
<div className="flex-grow">
<CardTitle>{title}</CardTitle>
<CardDescription>{description}</CardDescription>
</div>
</div>
</CardContent>
<CardFooter className="flex flex-row justify-end">
<Link to={`/internal-apps/${id}`}>
<Button variant="outline">
<NostrWalletConnectIcon className="w-4 h-4 mr-2" />
Open
</Button>
</Link>
</CardFooter>
</Card>
);
}

export default function SuggestedApps() {
return (
<>
<div className="grid sm:grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4">
{suggestedApps.map((app) => (
<SuggestedAppCard key={app.id} {...app} />
))}
{suggestedApps.map((app) =>
app.internal ? (
<InternalAppCard key={app.id} {...app} />
) : (
<SuggestedAppCard key={app.id} {...app} />
)
)}
</div>
</>
);
Expand Down
1 change: 0 additions & 1 deletion frontend/src/components/TransactionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ function TransactionItem({ tx }: Props) {

const copy = (text: string) => {
copyToClipboard(text, toast);
toast({ title: "Copied to clipboard." });
};

return (
Expand Down
55 changes: 55 additions & 0 deletions frontend/src/components/ui/accordion.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import * as React from "react";
import * as AccordionPrimitive from "@radix-ui/react-accordion";
import { ChevronDownIcon } from "@radix-ui/react-icons";

import { cn } from "src/lib/utils";

const Accordion = AccordionPrimitive.Root;

const AccordionItem = React.forwardRef<
React.ElementRef<typeof AccordionPrimitive.Item>,
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item>
>(({ className, ...props }, ref) => (
<AccordionPrimitive.Item
ref={ref}
className={cn("border-b", className)}
{...props}
/>
));
AccordionItem.displayName = "AccordionItem";

const AccordionTrigger = React.forwardRef<
React.ElementRef<typeof AccordionPrimitive.Trigger>,
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger>
>(({ className, children, ...props }, ref) => (
<AccordionPrimitive.Header className="flex">
<AccordionPrimitive.Trigger
ref={ref}
className={cn(
"flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",
className
)}
{...props}
>
{children}
<ChevronDownIcon className="h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200" />
</AccordionPrimitive.Trigger>
</AccordionPrimitive.Header>
));
AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName;

const AccordionContent = React.forwardRef<
React.ElementRef<typeof AccordionPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Content>
>(({ className, children, ...props }, ref) => (
<AccordionPrimitive.Content
ref={ref}
className="overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down"
{...props}
>
<div className={cn("pb-4 pt-0", className)}>{children}</div>
</AccordionPrimitive.Content>
));
AccordionContent.displayName = AccordionPrimitive.Content.displayName;

export { Accordion, AccordionItem, AccordionTrigger, AccordionContent };
13 changes: 12 additions & 1 deletion frontend/src/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import IncreaseOutgoingCapacity from "src/screens/channels/IncreaseOutgoingCapac
import { FirstChannel } from "src/screens/channels/first/FirstChannel";
import { OpenedFirstChannel } from "src/screens/channels/first/OpenedFirstChannel";
import { OpeningFirstChannel } from "src/screens/channels/first/OpeningFirstChannel";
import { UncleJimApp } from "src/screens/internal-apps/UncleJimApp";
import { Success } from "src/screens/onboarding/Success";
import BuyBitcoin from "src/screens/onchain/BuyBitcoin";
import DepositBitcoin from "src/screens/onchain/DepositBitcoin";
Expand Down Expand Up @@ -184,7 +185,6 @@ const routes = [
index: true,
element: <AppList />,
},

{
path: ":pubkey",
element: <ShowApp />,
Expand All @@ -200,6 +200,17 @@ const routes = [
},
],
},
{
path: "internal-apps",
element: <DefaultRedirect />,
handle: { crumb: () => "Connections" },
children: [
{
path: "uncle-jim",
element: <UncleJimApp />,
},
],
},
{
path: "appstore",
element: <DefaultRedirect />,
Expand Down
Loading

0 comments on commit 4ebd032

Please sign in to comment.