From a98197f328fb1f03ecf49a69dc3038ca7c704a28 Mon Sep 17 00:00:00 2001 From: SIDANWhatever Date: Sun, 13 Apr 2025 17:02:45 +0800 Subject: [PATCH 1/8] wip --- apps/mesh-cloud/.eslintrc.cjs | 1 + apps/mesh-cloud/package.json | 15 +- .../mesh-cloud/src/apps/cquisitor/command.tsx | 112 + .../src/apps/cquisitor/cquisitor.tsx | 90 + apps/mesh-cloud/src/apps/cquisitor/layout.tsx | 15 + apps/mesh-cloud/src/apps/cquisitor/old.tsx | 204 + apps/mesh-cloud/src/apps/cquisitor/select.tsx | 60 + apps/mesh-cloud/src/apps/cquisitor/utils.ts | 71 + .../src/components/layouts/page/index.tsx | 4 +- .../src/components/text/codeblock.tsx | 4 +- apps/mesh-cloud/src/components/ui/command.tsx | 153 + apps/mesh-cloud/src/components/ui/dialog.tsx | 122 + apps/mesh-cloud/src/components/ui/menubar.tsx | 256 + apps/mesh-cloud/src/pages/cquisitor/index.tsx | 5 + package.json | 4 +- yarn.lock | 11365 ++++++++++++++++ 16 files changed, 12470 insertions(+), 11 deletions(-) create mode 100644 apps/mesh-cloud/src/apps/cquisitor/command.tsx create mode 100644 apps/mesh-cloud/src/apps/cquisitor/cquisitor.tsx create mode 100644 apps/mesh-cloud/src/apps/cquisitor/layout.tsx create mode 100644 apps/mesh-cloud/src/apps/cquisitor/old.tsx create mode 100644 apps/mesh-cloud/src/apps/cquisitor/select.tsx create mode 100644 apps/mesh-cloud/src/apps/cquisitor/utils.ts create mode 100644 apps/mesh-cloud/src/components/ui/command.tsx create mode 100644 apps/mesh-cloud/src/components/ui/dialog.tsx create mode 100644 apps/mesh-cloud/src/components/ui/menubar.tsx create mode 100644 apps/mesh-cloud/src/pages/cquisitor/index.tsx create mode 100644 yarn.lock diff --git a/apps/mesh-cloud/.eslintrc.cjs b/apps/mesh-cloud/.eslintrc.cjs index 4482f0b..d567c05 100644 --- a/apps/mesh-cloud/.eslintrc.cjs +++ b/apps/mesh-cloud/.eslintrc.cjs @@ -47,6 +47,7 @@ const config = { "@typescript-eslint/prefer-optional-chain": "off", "@typescript-eslint/no-unsafe-argument": "off", "@typescript-eslint/no-redundant-type-constituents": "off", + "@typescript-eslint/prefer-nullish-coalescing": "off", }, }; module.exports = config; diff --git a/apps/mesh-cloud/package.json b/apps/mesh-cloud/package.json index 7953012..91ca0fe 100644 --- a/apps/mesh-cloud/package.json +++ b/apps/mesh-cloud/package.json @@ -15,20 +15,23 @@ "dev": "next dev", "postinstall": "prisma generate", "lint": "next lint", - "start": "next start" + "start": "next start", + "clean": "rm -rf .turbo && rm -rf .next && rm -rf node_modules && rm package-lock.json" }, "dependencies": { "@auth/prisma-adapter": "^1.6.0", + "@cardananium/cquisitor-lib": "^0.1.0-beta.5", "@heroicons/react": "^2.1.5", - "@meshsdk/core": "1.8.2", - "@meshsdk/react": "1.8.2", + "@meshsdk/core": "1.9.0-beta.34", + "@meshsdk/react": "1.9.0-beta.34", "@prisma/client": "^5.14.0", "@radix-ui/react-accordion": "^1.2.0", "@radix-ui/react-checkbox": "^1.1.1", - "@radix-ui/react-dialog": "^1.1.1", + "@radix-ui/react-dialog": "^1.1.7", "@radix-ui/react-dropdown-menu": "^2.1.1", "@radix-ui/react-icons": "^1.3.0", "@radix-ui/react-label": "^2.1.0", + "@radix-ui/react-menubar": "^1.1.7", "@radix-ui/react-select": "^2.1.2", "@radix-ui/react-slot": "^1.1.0", "@t3-oss/env-nextjs": "^0.10.1", @@ -39,6 +42,7 @@ "@trpc/server": "^11.0.0-rc.446", "class-variance-authority": "^0.7.0", "clsx": "^2.1.1", + "cmdk": "^1.1.1", "copy-to-clipboard": "^3.3.3", "geist": "^1.3.0", "lucide-react": "^0.436.0", @@ -72,6 +76,5 @@ }, "ct3aMetadata": { "initVersion": "7.37.0" - }, - "packageManager": "npm@10.7.0" + } } \ No newline at end of file diff --git a/apps/mesh-cloud/src/apps/cquisitor/command.tsx b/apps/mesh-cloud/src/apps/cquisitor/command.tsx new file mode 100644 index 0000000..f02c0e4 --- /dev/null +++ b/apps/mesh-cloud/src/apps/cquisitor/command.tsx @@ -0,0 +1,112 @@ +"use client"; + +import { useEffect, useState } from "react"; +import { + Calculator, + Calendar, + CreditCard, + Settings, + Smile, + User, +} from "lucide-react"; + +import { + CommandDialog, + CommandEmpty, + CommandGroup, + CommandInput, + CommandItem, + CommandList, + CommandSeparator, + CommandShortcut, +} from "@/components/ui/command"; +import { Button } from "@/components/ui/button"; +import * as cq from "@cardananium/cquisitor-lib"; + +export function CquisitorCommand({ + currentType, + setCurrentType, +}: { + currentType: string; + setCurrentType: (type: string) => void; +}) { + const [open, setOpen] = useState(false); + const [suggestions, setSuggestions] = useState([ + "Address", + "Transaction", + "PlutusData", + ]); + const [allTypes, setAllTypes] = useState(["Asset", "Certificate"]); + + // const initTypes = async () => { + // const types = cq.get_decodable_types(); + // setTypeList(types); + // }; + + useEffect(() => { + const down = (e: KeyboardEvent) => { + if (e.key === "j" && (e.metaKey || e.ctrlKey)) { + e.preventDefault(); + setOpen((open) => !open); + } + }; + + document.addEventListener("keydown", down); + return () => document.removeEventListener("keydown", down); + }, []); + + // useEffect(() => { + // initTypes() + // }, []); + + return ( + <> + + + + + No results found. + + {suggestions.map((item) => ( + { + setCurrentType(item); + setOpen(false); + }} + > + {item} + + ))} + + + + {allTypes.map((item) => ( + { + setCurrentType(item); + setOpen(false); + }} + > + {item} + + ))} + + + + + ); +} diff --git a/apps/mesh-cloud/src/apps/cquisitor/cquisitor.tsx b/apps/mesh-cloud/src/apps/cquisitor/cquisitor.tsx new file mode 100644 index 0000000..4cca45c --- /dev/null +++ b/apps/mesh-cloud/src/apps/cquisitor/cquisitor.tsx @@ -0,0 +1,90 @@ +import CardSection from "@/components/card-section"; +import { Button } from "@/components/ui/button"; +import { Input } from "@/components/ui/input"; +import CquisitorLayout from "./layout"; +import { type Dispatch, type SetStateAction, useEffect, useState } from "react"; +import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; +import { Label } from "@/components/ui/label"; +import Metatags from "@/components/site/metatags"; +import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; +import { type Budget, type Action, type RedeemerTagType } from "@meshsdk/core"; +import { csl } from "@meshsdk/core-csl"; + +import { getProvider } from "@/lib/provider"; +import { SelectNetwork, SelectService } from "./select"; +import { CquisitorCommand } from "./command"; + +import { Textarea } from "@/components/ui/textarea"; +import { decode, DecodeType } from "./utils"; + +export default function DevTransaction() { + const [cborHex, setCborHex] = useState(""); + const [loading, setLoading] = useState(false); + const [apiKey, setApiKey] = useState(""); + const [network, setNetwork] = useState("mainnet"); + const [service, setService] = useState<"blockfrost" | "maestro">( + "blockfrost", + ); + const [decodeType, setDecodeType] = useState("decode-by-csl"); + const [currentType, setCurrentType] = useState("Transaction"); + const [currentData, setCurrentData] = useState(""); + + const [success, setSuccess] = useState(false); + const [error, setError] = useState(""); + + useEffect(() => { + const decoded = decode(cborHex, decodeType, currentType); + setCurrentData(decoded); + }, [currentType, cborHex]); + + return ( + + +
+ + +
+ setApiKey(e.target.value)} + disabled={loading} + type="password" + placeholder="API Key" + /> +
+
+ <> + + <> +
+
+