Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
d36fb9d
🚧 API endpoints to get and create local chains
fredk3 Mar 29, 2024
19645cc
🍱 add Camera Icon
fredk3 Mar 30, 2024
318f1c2
🚧 working on the register page
fredk3 Mar 30, 2024
8edd4a1
💄 first UI pass of register local page finished
fredk3 Mar 30, 2024
a3d9efe
🍱 add Link Icon
fredk3 Apr 4, 2024
4825a35
🚧 Working on the form
fredk3 Apr 4, 2024
ebff38a
🍱 Add wifi icon
fredk3 Apr 4, 2024
eff5845
🐛 remove `node:` prefix (why is this needed ?)
fredk3 Apr 4, 2024
3e6f91d
🚧 Wip
fredk3 Apr 4, 2024
16995fc
🍱 add loader icon
fredk3 Apr 4, 2024
036102c
🍱 add another check circle icon
fredk3 Apr 4, 2024
0de135b
➖ remove unused dependencies
fredk3 Apr 4, 2024
cfa28c5
🚧 wip
fredk3 Apr 4, 2024
130b49b
🏷️ fix TS issues
fredk3 Apr 4, 2024
9bcdc5b
🙈 update gitignore
fredk3 Apr 5, 2024
d48e66b
🚧 WIP
fredk3 Apr 5, 2024
f0a16d3
🐛 fix bug with image URL for local chains
fredk3 Apr 5, 2024
464cbed
🐛 fix bug with target electron
fredk3 Apr 5, 2024
ab8b85a
🚧 WIP
fredk3 Apr 5, 2024
9870e44
⬆️ upgrade next to canary to fix some issues (?)
fredk3 Apr 5, 2024
580f111
🚧 not easy to do uh...
fredk3 Apr 5, 2024
1c002f6
🐛 Fix bug with local chain image URL
fredk3 Apr 5, 2024
ee93355
🐛 fix bug with local integration image src not showing
fredk3 Apr 5, 2024
c645fea
🐛 save file relative to parent path
fredk3 Apr 5, 2024
25030ed
⬆️ upgrade next to latest canary
fredk3 Apr 5, 2024
7dcd63b
♻️ simplify `logoURL` validation
fredk3 Apr 6, 2024
0b3bb9b
🚧 working with drizzle
fredk3 Apr 6, 2024
befa398
🚧 wip...
fredk3 Apr 6, 2024
af28da5
✨ finish sqlite migration
fredk3 Apr 9, 2024
bd8e894
💄 UI finished for local chains
fredk3 Apr 9, 2024
91c57da
🔨 add script for pushing the sqlite db
fredk3 Apr 9, 2024
88ec14d
🔨 push sqlite DB file before electron build
fredk3 Apr 9, 2024
cebd117
♻️ move from sqlite to pglite
fredk3 Apr 10, 2024
2bd811f
♻️ no `db:push` script
fredk3 Apr 10, 2024
47b2ea0
🐛 fix `pglite` not being imported correctly
fredk3 Apr 10, 2024
869235e
🔧 make `pglite` an external package at build time
fredk3 Apr 10, 2024
e6678d3
♻️ refactor
fredk3 Apr 10, 2024
de0e914
♻️ show file type
fredk3 Apr 10, 2024
db33c74
⬆️ upgrade next to latest stable version
fredk3 Apr 11, 2024
a0744b5
♻️ (re)use the FS
fredk3 Apr 12, 2024
ca4cc7c
♻️ send json to route api instead of file
fredk3 Apr 12, 2024
ee908cc
♻️ parse correctly the formData
fredk3 Apr 12, 2024
35d6ed9
✨ add "develop" menu section
fredk3 Apr 15, 2024
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@ yarn-error.log*
dist/
cache/
standalone/

*.sqlite
pgdata/
61 changes: 60 additions & 1 deletion apps/desktop/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
/* eslint-disable turbo/no-undeclared-env-vars */
// @ts-check
const { app, BrowserWindow, dialog } = require("electron");
const {
app,
Menu,
BrowserWindow,
dialog,
MenuItem,
ipcMain,
} = require("electron");
const todesktop = require("@todesktop/runtime");
const log = require("electron-log/main");
const path = require("path");

log.initialize();
log.transports.ipc.level = "verbose";
Expand Down Expand Up @@ -37,6 +45,7 @@ function getRandomPort() {

let hasServerStarted = false;
let totalAttempsLeft = 10;
process.env.ROOT_USER_PATH = app.getPath("userData");
while (!hasServerStarted && totalAttempsLeft > 0) {
try {
process.env.PORT = getRandomPort().toString();
Expand All @@ -63,9 +72,56 @@ function createWindow() {
webPreferences: {
nodeIntegration: true,
devTools: true,
preload: path.join(__dirname, "preload.js"),
},
});

/** @type any */
const template = [
{
label: "File",
submenu: [{ label: "Exit", role: "quit" }],
},
{
label: "Edit",
submenu: [
{ label: "Undo", role: "undo" },
{ label: "Redo", role: "redo" },
{ type: "separator" },
{ label: "Cut", role: "cut" },
{ label: "Copy", role: "copy" },
{ label: "Paste", role: "paste" },
],
},
{
label: "View",
submenu: [
{ label: "Reload", role: "reload" },
{ label: "Toggle Developer Tools", role: "toggleDevTools" },
],
},
{
label: "Develop",
submenu: [
{
label: "Add Local Chain",
click: () => {
mainWindow.webContents.send("navigate", "/register/local-chain");
},
},
{
label: "Go home",
click: () => {
mainWindow.webContents.send("navigate", "/");
},
},
],
},
];

const menu = Menu.buildFromTemplate(template);
Menu.setApplicationMenu(menu);

// this is to override the title set by `./apps/web/server.js`
// so that the window will show `Explorer` instead of `next-server`
process.title = mainWindow.title;
Expand All @@ -75,6 +131,9 @@ function createWindow() {
mainWindow.on("closed", () => {
app.quit();
});
ipcMain.on("navigate", (event, route) => {
mainWindow.webContents.send("navigate", route);
});
}

app.whenReady().then(createWindow);
Expand Down
7 changes: 7 additions & 0 deletions apps/desktop/preload.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const { ipcRenderer } = require("electron");

window.addEventListener("DOMContentLoaded", () => {
ipcRenderer.on("navigate", (event, route) => {
window.location.href = route;
});
});
2 changes: 2 additions & 0 deletions apps/web/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
public/images/local-chains/*
!public/images/local-chains/.gitkeep
29 changes: 29 additions & 0 deletions apps/web/app/(register)/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import * as React from "react";
import { HomeBg } from "~/ui/home-bg";
import { HomeBgMobile } from "~/ui/home-bg/mobile";

export default function RegisterLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<main
id="main-content"
className="h-[100dvh] flex flex-col items-stretch"
style={{
"--color-primary": "212 100% 49%",
}}
>
<HomeBg
aria-hidden="true"
className="fixed left-0 top-5 right-0 hidden tab:block z-[-1]"
/>
<HomeBgMobile
aria-hidden="true"
className="fixed left-0 top-5 right-0 tab:hidden block z-[-1]"
/>
{children}
</main>
);
}
19 changes: 19 additions & 0 deletions apps/web/app/(register)/register/local-chain/local-chain-schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { z, preprocess } from "zod";

export const localChainFormSchema = z.object({
chainName: z.string().trim().min(1),
namespace: z.string().trim().optional(),
startHeight: z.coerce.number().int().optional(),
daLayer: z.string().trim().optional(),
logo: z
.string()
.regex(/^data:image\/([a-zA-Z]+);base64,/, "Please upload a valid image")
.nullish(),
rpcUrl: z.string().trim().url(),
rpcPlatform: preprocess(
(arg) => (typeof arg === "string" ? arg.toLowerCase() : arg),
z.enum(["cosmos"]).default("cosmos"),
),
tokenDecimals: z.coerce.number().int().positive(),
tokenName: z.string().trim().min(1),
});
28 changes: 28 additions & 0 deletions apps/web/app/(register)/register/local-chain/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/* eslint-disable @next/next/no-img-element */
import * as React from "react";

import { redirect } from "next/navigation";
import { env } from "~/env";
import { RegisterLocalChainForm } from "./register-local-chain-form";

import type { Metadata } from "next";

export interface PageProps {}

export const metadata: Metadata = {
title: "Register a Local Chain",
};

export default function Page(props: PageProps) {
if (env.NEXT_PUBLIC_TARGET !== "electron") {
redirect("/");
}

return (
<>
<div className="inline-flex flex-col gap-8 my-auto justify-stretch w-full px-10 mx-auto tab:max-w-[30rem] relative">
<RegisterLocalChainForm />
</div>
</>
);
}
Loading