Skip to content

Commit a4fc8e4

Browse files
committed
fix: predeployed connector warning
1 parent 81dbb13 commit a4fc8e4

33 files changed

+2582
-1173
lines changed

.changeset/early-steaks-perform.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
"@dojoengine/predeployed-connector": patch
3+
"@dojoengine/core": patch
4+
"template-vite-ts": patch
5+
"@dojoengine/create-burner": patch
6+
"@dojoengine/create-dojo": patch
7+
"@dojoengine/react": patch
8+
"@dojoengine/sdk": patch
9+
"@dojoengine/state": patch
10+
"@dojoengine/torii-client": patch
11+
"@dojoengine/torii-wasm": patch
12+
"@dojoengine/utils": patch
13+
"@dojoengine/utils-wasm": patch
14+
---
15+
16+
fix: predeployed warnings
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# React + TypeScript + Vite
2+
3+
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
4+
5+
Currently, two official plugins are available:
6+
7+
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
8+
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
9+
10+
## Expanding the ESLint configuration
11+
12+
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:
13+
14+
- Configure the top-level `parserOptions` property like this:
15+
16+
```js
17+
export default tseslint.config({
18+
languageOptions: {
19+
// other options...
20+
parserOptions: {
21+
project: ["./tsconfig.node.json", "./tsconfig.app.json"],
22+
tsconfigRootDir: import.meta.dirname,
23+
},
24+
},
25+
});
26+
```
27+
28+
- Replace `tseslint.configs.recommended` to `tseslint.configs.recommendedTypeChecked` or `tseslint.configs.strictTypeChecked`
29+
- Optionally add `...tseslint.configs.stylisticTypeChecked`
30+
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and update the config:
31+
32+
```js
33+
// eslint.config.js
34+
import react from "eslint-plugin-react";
35+
36+
export default tseslint.config({
37+
// Set the react version
38+
settings: { react: { version: "18.3" } },
39+
plugins: {
40+
// Add the react plugin
41+
react,
42+
},
43+
rules: {
44+
// other rules...
45+
// Enable its recommended rules
46+
...react.configs.recommended.rules,
47+
...react.configs["jsx-runtime"].rules,
48+
},
49+
});
50+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { createDojoConfig } from "@dojoengine/core";
2+
3+
import manifest from "../../worlds/dojo-starter/manifest_dev.json";
4+
5+
export const dojoConfig = createDojoConfig({
6+
manifest,
7+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import js from "@eslint/js";
2+
import globals from "globals";
3+
import reactHooks from "eslint-plugin-react-hooks";
4+
import reactRefresh from "eslint-plugin-react-refresh";
5+
import tseslint from "typescript-eslint";
6+
7+
export default tseslint.config(
8+
{ ignores: ["dist"] },
9+
{
10+
extends: [js.configs.recommended, ...tseslint.configs.recommended],
11+
files: ["**/*.{ts,tsx}"],
12+
languageOptions: {
13+
ecmaVersion: 2020,
14+
globals: globals.browser,
15+
},
16+
plugins: {
17+
"react-hooks": reactHooks,
18+
"react-refresh": reactRefresh,
19+
},
20+
rules: {
21+
...reactHooks.configs.recommended.rules,
22+
"react-refresh/only-export-components": [
23+
"warn",
24+
{ allowConstantExport: true },
25+
],
26+
},
27+
}
28+
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Vite + React + TS</title>
8+
</head>
9+
<body>
10+
<div id="root"></div>
11+
<script type="module" src="/src/main.tsx"></script>
12+
</body>
13+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "example-predeployed-connector",
3+
"private": true,
4+
"version": "0.0.0",
5+
"type": "module",
6+
"scripts": {
7+
"dev": "vite",
8+
"build": "tsc -b && vite build",
9+
"lint": "eslint .",
10+
"preview": "vite preview"
11+
},
12+
"dependencies": {
13+
"@dojoengine/core": "workspace:*",
14+
"@dojoengine/predeployed-connector": "workspace:*",
15+
"@dojoengine/sdk": "workspace:*",
16+
"@starknet-react/chains": "catalog:",
17+
"@starknet-react/core": "catalog:",
18+
"react": "catalog:",
19+
"react-dom": "catalog:"
20+
},
21+
"devDependencies": {
22+
"@eslint/js": "^9.20.0",
23+
"@types/react": "catalog:",
24+
"@types/react-dom": "catalog:",
25+
"@vitejs/plugin-react": "^4.3.4",
26+
"eslint": "^9.20.1",
27+
"eslint-plugin-react-hooks": "^5.1.0",
28+
"eslint-plugin-react-refresh": "^0.4.19",
29+
"globals": "^15.15.0",
30+
"typescript": "~5.7.3",
31+
"typescript-eslint": "^8.24.1",
32+
"vite": "^6.1.1"
33+
}
34+
}
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#root {
2+
max-width: 1280px;
3+
margin: 0 auto;
4+
padding: 2rem;
5+
text-align: center;
6+
}
7+
8+
.logo {
9+
height: 6em;
10+
padding: 1.5em;
11+
will-change: filter;
12+
transition: filter 300ms;
13+
}
14+
.logo:hover {
15+
filter: drop-shadow(0 0 2em #646cffaa);
16+
}
17+
.logo.react:hover {
18+
filter: drop-shadow(0 0 2em #61dafbaa);
19+
}
20+
21+
@keyframes logo-spin {
22+
from {
23+
transform: rotate(0deg);
24+
}
25+
to {
26+
transform: rotate(360deg);
27+
}
28+
}
29+
30+
@media (prefers-reduced-motion: no-preference) {
31+
a:nth-of-type(2) .logo {
32+
animation: logo-spin infinite 20s linear;
33+
}
34+
}
35+
36+
.card {
37+
padding: 2em;
38+
}
39+
40+
.read-the-docs {
41+
color: #888;
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { useState } from "react";
2+
import reactLogo from "./assets/react.svg";
3+
import viteLogo from "/vite.svg";
4+
import "./App.css";
5+
6+
function App() {
7+
const [count, setCount] = useState(0);
8+
9+
return (
10+
<>
11+
<div>
12+
<a href="https://vite.dev" target="_blank">
13+
<img src={viteLogo} className="logo" alt="Vite logo" />
14+
</a>
15+
<a href="https://react.dev" target="_blank">
16+
<img
17+
src={reactLogo}
18+
className="logo react"
19+
alt="React logo"
20+
/>
21+
</a>
22+
</div>
23+
<h1>Vite + React</h1>
24+
<div className="card">
25+
<button onClick={() => setCount((count) => count + 1)}>
26+
count is {count}
27+
</button>
28+
<p>
29+
Edit <code>src/App.tsx</code> and save to test HMR
30+
</p>
31+
</div>
32+
<p className="read-the-docs">
33+
Click on the Vite and React logos to learn more
34+
</p>
35+
</>
36+
);
37+
}
38+
39+
export default App;
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
:root {
2+
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
3+
line-height: 1.5;
4+
font-weight: 400;
5+
6+
color-scheme: light dark;
7+
color: rgba(255, 255, 255, 0.87);
8+
background-color: #242424;
9+
10+
font-synthesis: none;
11+
text-rendering: optimizeLegibility;
12+
-webkit-font-smoothing: antialiased;
13+
-moz-osx-font-smoothing: grayscale;
14+
}
15+
16+
a {
17+
font-weight: 500;
18+
color: #646cff;
19+
text-decoration: inherit;
20+
}
21+
a:hover {
22+
color: #535bf2;
23+
}
24+
25+
body {
26+
margin: 0;
27+
display: flex;
28+
place-items: center;
29+
min-width: 320px;
30+
min-height: 100vh;
31+
}
32+
33+
h1 {
34+
font-size: 3.2em;
35+
line-height: 1.1;
36+
}
37+
38+
button {
39+
border-radius: 8px;
40+
border: 1px solid transparent;
41+
padding: 0.6em 1.2em;
42+
font-size: 1em;
43+
font-weight: 500;
44+
font-family: inherit;
45+
background-color: #1a1a1a;
46+
cursor: pointer;
47+
transition: border-color 0.25s;
48+
}
49+
button:hover {
50+
border-color: #646cff;
51+
}
52+
button:focus,
53+
button:focus-visible {
54+
outline: 4px auto -webkit-focus-ring-color;
55+
}
56+
57+
@media (prefers-color-scheme: light) {
58+
:root {
59+
color: #213547;
60+
background-color: #ffffff;
61+
}
62+
a:hover {
63+
color: #747bff;
64+
}
65+
button {
66+
background-color: #f9f9f9;
67+
}
68+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { StrictMode } from "react";
2+
import { createRoot } from "react-dom/client";
3+
import "./index.css";
4+
import App from "./App.tsx";
5+
import StarknetProvider from "./starknet-provider.tsx";
6+
7+
createRoot(document.getElementById("root")!).render(
8+
<StrictMode>
9+
<StarknetProvider>
10+
<App />
11+
</StarknetProvider>
12+
</StrictMode>
13+
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { useEffect, useState, type PropsWithChildren } from "react";
2+
import { mainnet } from "@starknet-react/chains";
3+
import { jsonRpcProvider, StarknetConfig, voyager } from "@starknet-react/core";
4+
import { dojoConfig } from "../dojoConfig";
5+
import {
6+
predeployedAccounts,
7+
type PredeployedAccountsConnector,
8+
} from "@dojoengine/predeployed-connector";
9+
10+
export default function StarknetProvider({ children }: PropsWithChildren) {
11+
const [retries, setRetries] = useState<number>(0);
12+
const [connectors, setConnectors] = useState<
13+
PredeployedAccountsConnector[]
14+
>([]);
15+
const provider = jsonRpcProvider({
16+
rpc: () => ({ nodeUrl: dojoConfig.rpcUrl as string }),
17+
});
18+
19+
useEffect(() => {
20+
if (connectors.length === 0 && retries < 5) {
21+
setRetries(retries + 1);
22+
predeployedAccounts({
23+
rpc: dojoConfig.rpcUrl as string,
24+
id: "katana",
25+
name: "Katana",
26+
}).then(setConnectors);
27+
}
28+
}, [connectors]);
29+
30+
return (
31+
<StarknetConfig
32+
chains={[mainnet]}
33+
provider={provider}
34+
connectors={connectors}
35+
explorer={voyager}
36+
autoConnect
37+
>
38+
{children}
39+
</StarknetConfig>
40+
);
41+
}

0 commit comments

Comments
 (0)