Skip to content

Commit

Permalink
feat: add kitchen sink example
Browse files Browse the repository at this point in the history
  • Loading branch information
MartianGreed committed Sep 27, 2024
1 parent 105af37 commit a8ca98a
Show file tree
Hide file tree
Showing 44 changed files with 3,817 additions and 57 deletions.
5 changes: 4 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "dojo-starter"]
path = worlds/dojo-starter
url = https://github.com/dojoengine/dojo-starter
url = https://github.com/dojoengine/dojo-starter
[submodule "examples/example-vite-kitchen-sink/src/onchain"]
path = examples/example-vite-kitchen-sink/src/onchain
url = https://github.com/MartianGreed/onchain-dash
5 changes: 5 additions & 0 deletions examples/example-vite-kitchen-sink/.env.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
VITE_RPC_URL="http://localhost:5050"
VITE_RPC_API_KEY=""
VITE_CONTROLLER_URL="https://x.cartridge.gg/mainnet"
VITE_CONTROLLER_RPC="https://x.cartridge.gg/mainnet"
VITE_TORII_URL="http://localhost:8080"
3 changes: 3 additions & 0 deletions examples/example-vite-kitchen-sink/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["next/core-web-vitals", "next/typescript"]
}
37 changes: 37 additions & 0 deletions examples/example-vite-kitchen-sink/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
.env
49 changes: 49 additions & 0 deletions examples/example-vite-kitchen-sink/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# OnChainDash Vite Kitchen Sink

This project aims at showcasing dojo's capabilities outside of gaming.

## Getting Started

First, install dependencies:

```bash
pnpm install
```

In one terminal window, start katana (the sequencer). If you want to use sepolia / mainnet contracts, you can just use a classic rpc (e.g. `https://rpc.netermind.io/(mainnet|sepolia)-juno`). If this is the case, you can skip the next command.

```bash
katana --disable-fee --allowed-origins "*"
```

In another terminal window, start torii server

```bash
# with katana
torii --world 0x6dd367f5e11f11e0502cb2c4db7ae9bb6d8b5a4a431750bed7bec88b218e12 --allowed-origins "*"
# with mainnet|sepolia
torii --world 0x6dd367f5e11f11e0502cb2c4db7ae9bb6d8b5a4a431750bed7bec88b218e12 --allowed-origins "*" --rpc "https://rpc.nethermind.io/(mainnet|sepolia)-juno?apikey={apikey}" -s 204922
```

Then, start the development server:

```bash
pnpm run dev
```

Open [http://localhost:5173](http://localhost:5173) with your browser to see the result.

## Local Contracts deployment

In order to make those commands work, you need to have torii & katana running.

```bash
cd src/onchain
sozo build
sozo migrate apply
```

### Notes

- you main want to update `actions` contract address in `src/components/caller-counter.tsx` & `src/components/global-counter.tsx` which is hardcoded in those files.
- if you want to have braavos & argent wallet working, you need to deploy classes and deploy your wallet manually.
20 changes: 20 additions & 0 deletions examples/example-vite-kitchen-sink/components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "new-york",
"rsc": true,
"tsx": true,
"tailwind": {
"config": "tailwind.config.ts",
"css": "app/globals.css",
"baseColor": "zinc",
"cssVariables": true,
"prefix": ""
},
"aliases": {
"components": "@/components",
"utils": "@/lib/utils",
"ui": "@/components/ui",
"lib": "@/lib",
"hooks": "@/hooks"
}
}
13 changes: 13 additions & 0 deletions examples/example-vite-kitchen-sink/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
56 changes: 56 additions & 0 deletions examples/example-vite-kitchen-sink/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"name": "sink",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"lint": "eslint .",
"preview": "vite preview"
},
"dependencies": {
"@cartridge/connector": "^0.3.44",
"@dojoengine/core": "workspace:*",
"@dojoengine/sdk": "workspace:*",
"@radix-ui/react-dialog": "^1.1.1",
"@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-label": "^2.1.0",
"@radix-ui/react-select": "^2.1.1",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-switch": "^1.1.0",
"@radix-ui/react-tooltip": "^1.1.2",
"@starknet-react/chains": "^3.0.0",
"@starknet-react/core": "2.3.0",
"@t3-oss/env-core": "^0.11.1",
"@t3-oss/env-nextjs": "^0.11.1",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"dotenv": "^16.4.5",
"jiti": "^1.21.6",
"lucide-react": "^0.441.0",
"next": "14.2.12",
"react": "^18",
"react-dom": "^18",
"react-hook-form": "^7.53.0",
"starknet": "6.11.0",
"tailwind-merge": "^2.5.2",
"tailwindcss-animate": "^1.0.7",
"vaul": "^0.9.4",
"zod": "^3.22.4"
},
"devDependencies": {
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"@vitejs/plugin-react": "^4.3.1",
"eslint": "^8",
"eslint-config-next": "14.2.12",
"postcss": "^8",
"tailwindcss": "^3.4.1",
"typescript": "^5",
"vite": "^5.4.8",
"vite-plugin-top-level-await": "^1.4.4",
"vite-plugin-wasm": "^3.3.0",
"vite-preset-react": "^2.3.0"
}
}
8 changes: 8 additions & 0 deletions examples/example-vite-kitchen-sink/postcss.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/** @type {import('postcss-load-config').Config} */
const config = {
plugins: {
tailwindcss: {},
},
};

export default config;
Binary file not shown.
Binary file not shown.
Binary file not shown.
85 changes: 85 additions & 0 deletions examples/example-vite-kitchen-sink/src/app/globals.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

body {
color: hsl(var(--foreground));
background: hsl(var(--background));
}

@layer utilities {
.text-balance {
text-wrap: balance;
}
}

@layer base {
:root {
--background: 0 0% 100%;
--foreground: 240 10% 3.9%;
--card: 0 0% 100%;
--card-foreground: 240 10% 3.9%;
--popover: 0 0% 100%;
--popover-foreground: 240 10% 3.9%;
--primary: 240 5.9% 10%;
--primary-foreground: 0 0% 98%;
--secondary: 240 4.8% 95.9%;
--secondary-foreground: 240 5.9% 10%;
--muted: 240 4.8% 95.9%;
--muted-foreground: 240 3.8% 46.1%;
--accent: 240 4.8% 95.9%;
--accent-foreground: 240 5.9% 10%;
--destructive: 0 84.2% 60.2%;
--destructive-foreground: 0 0% 98%;
--border: 240 5.9% 90%;
--input: 240 5.9% 90%;
--ring: 240 10% 3.9%;
--chart-1: 12 76% 61%;
--chart-2: 173 58% 39%;
--chart-3: 197 37% 24%;
--chart-4: 43 74% 66%;
--chart-5: 27 87% 67%;
--radius: 0.5rem;
--font-body: var(--font-geist-sans);
--font-heading: var(--font-geist-mono);
}
.dark {
--background: 240 10% 3.9%;
--foreground: 0 0% 98%;
--card: 240 10% 3.9%;
--card-foreground: 0 0% 98%;
--popover: 240 10% 3.9%;
--popover-foreground: 0 0% 98%;
--primary: 0 0% 98%;
--primary-foreground: 240 5.9% 10%;
--secondary: 240 3.7% 15.9%;
--secondary-foreground: 0 0% 98%;
--muted: 240 3.7% 15.9%;
--muted-foreground: 240 5% 64.9%;
--accent: 240 3.7% 15.9%;
--accent-foreground: 0 0% 98%;
--destructive: 0 62.8% 30.6%;
--destructive-foreground: 0 0% 98%;
--border: 240 3.7% 15.9%;
--input: 240 3.7% 15.9%;
--ring: 240 4.9% 83.9%;
--chart-1: 220 70% 50%;
--chart-2: 160 60% 45%;
--chart-3: 30 80% 55%;
--chart-4: 280 65% 60%;
--chart-5: 340 75% 55%;
}
}

@layer base {
* {
@apply border-border;
}
body {
@apply bg-background text-foreground;
font-family: var(--font-geist-sans);
}
h1, h2, h3, h4, h5, h6, h7 {
font-family: var(--font-geist-sans);
}
}
25 changes: 25 additions & 0 deletions examples/example-vite-kitchen-sink/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { TooltipProvider } from "@/components/ui/tooltip";

import Sidebar from "@/components/sidebar";
import Header from "@/components/header";
import StarknetProvider from "@/components/starknet-provider";
import DojoProvider from "@/dojo/provider";


export default function RootLayout({ children }) {
return (
<StarknetProvider>
<DojoProvider>
<TooltipProvider delayDuration={400}>
<div className="grid h-screen w-full pl-[53px]">
<Sidebar />
<div className="flex flex-col">
<Header />
{children}
</div>
</div>
</TooltipProvider>
</DojoProvider>
</StarknetProvider>
);
}
Loading

0 comments on commit a8ca98a

Please sign in to comment.