-
Notifications
You must be signed in to change notification settings - Fork 54
fix: predeployed connector warning #400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
"@dojoengine/predeployed-connector": patch | ||
"@dojoengine/core": patch | ||
"template-vite-ts": patch | ||
"@dojoengine/create-burner": patch | ||
"@dojoengine/create-dojo": patch | ||
"@dojoengine/react": patch | ||
"@dojoengine/sdk": patch | ||
"@dojoengine/state": patch | ||
"@dojoengine/torii-client": patch | ||
"@dojoengine/torii-wasm": patch | ||
"@dojoengine/utils": patch | ||
"@dojoengine/utils-wasm": patch | ||
--- | ||
|
||
fix: predeployed warnings |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# React + TypeScript + Vite | ||
|
||
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. | ||
|
||
Currently, two official plugins are available: | ||
|
||
- [@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 | ||
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh | ||
|
||
## Expanding the ESLint configuration | ||
|
||
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules: | ||
|
||
- Configure the top-level `parserOptions` property like this: | ||
|
||
```js | ||
export default tseslint.config({ | ||
languageOptions: { | ||
// other options... | ||
parserOptions: { | ||
project: ["./tsconfig.node.json", "./tsconfig.app.json"], | ||
tsconfigRootDir: import.meta.dirname, | ||
}, | ||
}, | ||
}); | ||
``` | ||
|
||
- Replace `tseslint.configs.recommended` to `tseslint.configs.recommendedTypeChecked` or `tseslint.configs.strictTypeChecked` | ||
- Optionally add `...tseslint.configs.stylisticTypeChecked` | ||
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and update the config: | ||
|
||
```js | ||
// eslint.config.js | ||
import react from "eslint-plugin-react"; | ||
|
||
export default tseslint.config({ | ||
// Set the react version | ||
settings: { react: { version: "18.3" } }, | ||
plugins: { | ||
// Add the react plugin | ||
react, | ||
}, | ||
rules: { | ||
// other rules... | ||
// Enable its recommended rules | ||
...react.configs.recommended.rules, | ||
...react.configs["jsx-runtime"].rules, | ||
}, | ||
}); | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { createDojoConfig } from "@dojoengine/core"; | ||
|
||
import manifest from "../../worlds/dojo-starter/manifest_dev.json"; | ||
|
||
export const dojoConfig = createDojoConfig({ | ||
manifest, | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import js from "@eslint/js"; | ||
import globals from "globals"; | ||
import reactHooks from "eslint-plugin-react-hooks"; | ||
import reactRefresh from "eslint-plugin-react-refresh"; | ||
import tseslint from "typescript-eslint"; | ||
|
||
export default tseslint.config( | ||
{ ignores: ["dist"] }, | ||
{ | ||
extends: [js.configs.recommended, ...tseslint.configs.recommended], | ||
files: ["**/*.{ts,tsx}"], | ||
languageOptions: { | ||
ecmaVersion: 2020, | ||
globals: globals.browser, | ||
}, | ||
plugins: { | ||
"react-hooks": reactHooks, | ||
"react-refresh": reactRefresh, | ||
}, | ||
rules: { | ||
...reactHooks.configs.recommended.rules, | ||
"react-refresh/only-export-components": [ | ||
"warn", | ||
{ allowConstantExport: true }, | ||
], | ||
}, | ||
} | ||
); |
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> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"name": "example-predeployed-connector", | ||
"private": true, | ||
"version": "0.0.0", | ||
"type": "module", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "tsc -b && vite build", | ||
"lint": "eslint .", | ||
"preview": "vite preview" | ||
}, | ||
"dependencies": { | ||
"@dojoengine/core": "workspace:*", | ||
"@dojoengine/predeployed-connector": "workspace:*", | ||
"@dojoengine/sdk": "workspace:*", | ||
"@starknet-react/chains": "catalog:", | ||
"@starknet-react/core": "catalog:", | ||
"react": "catalog:", | ||
"react-dom": "catalog:" | ||
}, | ||
"devDependencies": { | ||
"@eslint/js": "^9.20.0", | ||
"@types/react": "catalog:", | ||
"@types/react-dom": "catalog:", | ||
"@vitejs/plugin-react": "^4.3.4", | ||
"eslint": "^9.20.1", | ||
"eslint-plugin-react-hooks": "^5.1.0", | ||
"eslint-plugin-react-refresh": "^0.4.19", | ||
"globals": "^15.15.0", | ||
"typescript": "~5.7.3", | ||
"typescript-eslint": "^8.24.1", | ||
"vite": "^6.1.1" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#root { | ||
max-width: 1280px; | ||
margin: 0 auto; | ||
padding: 2rem; | ||
text-align: center; | ||
} | ||
|
||
.logo { | ||
height: 6em; | ||
padding: 1.5em; | ||
will-change: filter; | ||
transition: filter 300ms; | ||
} | ||
.logo:hover { | ||
filter: drop-shadow(0 0 2em #646cffaa); | ||
} | ||
.logo.react:hover { | ||
filter: drop-shadow(0 0 2em #61dafbaa); | ||
} | ||
|
||
@keyframes logo-spin { | ||
from { | ||
transform: rotate(0deg); | ||
} | ||
to { | ||
transform: rotate(360deg); | ||
} | ||
} | ||
|
||
@media (prefers-reduced-motion: no-preference) { | ||
a:nth-of-type(2) .logo { | ||
animation: logo-spin infinite 20s linear; | ||
} | ||
} | ||
|
||
.card { | ||
padding: 2em; | ||
} | ||
|
||
.read-the-docs { | ||
color: #888; | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,39 @@ | ||||||||||||||
import { useState } from "react"; | ||||||||||||||
import reactLogo from "./assets/react.svg"; | ||||||||||||||
import viteLogo from "/vite.svg"; | ||||||||||||||
import "./App.css"; | ||||||||||||||
|
||||||||||||||
function App() { | ||||||||||||||
const [count, setCount] = useState(0); | ||||||||||||||
|
||||||||||||||
return ( | ||||||||||||||
<> | ||||||||||||||
<div> | ||||||||||||||
<a href="https://vite.dev" target="_blank"> | ||||||||||||||
<img src={viteLogo} className="logo" alt="Vite logo" /> | ||||||||||||||
</a> | ||||||||||||||
Comment on lines
+12
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add security attributes to external links. Links with Apply this fix: - <a href="https://vite.dev" target="_blank">
+ <a href="https://vite.dev" target="_blank" rel="noreferrer">
<img src={viteLogo} className="logo" alt="Vite logo" />
</a>
- <a href="https://react.dev" target="_blank">
+ <a href="https://react.dev" target="_blank" rel="noreferrer"> Also applies to: 15-21 🧰 Tools🪛 Biome (1.9.4)[error] 12-12: Avoid using target="_blank" without rel="noreferrer". Opening external links in new tabs without rel="noreferrer" is a security risk. See the explanation for more details. (lint/a11y/noBlankTarget) |
||||||||||||||
<a href="https://react.dev" target="_blank"> | ||||||||||||||
<img | ||||||||||||||
src={reactLogo} | ||||||||||||||
className="logo react" | ||||||||||||||
alt="React logo" | ||||||||||||||
/> | ||||||||||||||
</a> | ||||||||||||||
</div> | ||||||||||||||
<h1>Vite + React</h1> | ||||||||||||||
<div className="card"> | ||||||||||||||
<button onClick={() => setCount((count) => count + 1)}> | ||||||||||||||
count is {count} | ||||||||||||||
</button> | ||||||||||||||
Comment on lines
+25
to
+27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add explicit button type for accessibility. Buttons should have an explicit type for better accessibility and to prevent unintended form submissions. Apply this fix: - <button onClick={() => setCount((count) => count + 1)}>
+ <button type="button" onClick={() => setCount((count) => count + 1)}> 📝 Committable suggestion
Suggested change
🧰 Tools🪛 Biome (1.9.4)[error] 25-25: Provide an explicit type prop for the button element. The default type of a button is submit, which causes the submission of a form when placed inside a (lint/a11y/useButtonType) |
||||||||||||||
<p> | ||||||||||||||
Edit <code>src/App.tsx</code> and save to test HMR | ||||||||||||||
</p> | ||||||||||||||
</div> | ||||||||||||||
<p className="read-the-docs"> | ||||||||||||||
Click on the Vite and React logos to learn more | ||||||||||||||
</p> | ||||||||||||||
</> | ||||||||||||||
); | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
export default App; |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,68 @@ | ||||||||||||||||||||||||||||||||
:root { | ||||||||||||||||||||||||||||||||
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; | ||||||||||||||||||||||||||||||||
line-height: 1.5; | ||||||||||||||||||||||||||||||||
font-weight: 400; | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
color-scheme: light dark; | ||||||||||||||||||||||||||||||||
color: rgba(255, 255, 255, 0.87); | ||||||||||||||||||||||||||||||||
background-color: #242424; | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
font-synthesis: none; | ||||||||||||||||||||||||||||||||
text-rendering: optimizeLegibility; | ||||||||||||||||||||||||||||||||
-webkit-font-smoothing: antialiased; | ||||||||||||||||||||||||||||||||
-moz-osx-font-smoothing: grayscale; | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
a { | ||||||||||||||||||||||||||||||||
font-weight: 500; | ||||||||||||||||||||||||||||||||
color: #646cff; | ||||||||||||||||||||||||||||||||
text-decoration: inherit; | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
a:hover { | ||||||||||||||||||||||||||||||||
color: #535bf2; | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
body { | ||||||||||||||||||||||||||||||||
margin: 0; | ||||||||||||||||||||||||||||||||
display: flex; | ||||||||||||||||||||||||||||||||
place-items: center; | ||||||||||||||||||||||||||||||||
min-width: 320px; | ||||||||||||||||||||||||||||||||
min-height: 100vh; | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
Comment on lines
+25
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Flex Container Centering Issue in - place-items: center;
+ justify-content: center;
+ align-items: center; 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
h1 { | ||||||||||||||||||||||||||||||||
font-size: 3.2em; | ||||||||||||||||||||||||||||||||
line-height: 1.1; | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
button { | ||||||||||||||||||||||||||||||||
border-radius: 8px; | ||||||||||||||||||||||||||||||||
border: 1px solid transparent; | ||||||||||||||||||||||||||||||||
padding: 0.6em 1.2em; | ||||||||||||||||||||||||||||||||
font-size: 1em; | ||||||||||||||||||||||||||||||||
font-weight: 500; | ||||||||||||||||||||||||||||||||
font-family: inherit; | ||||||||||||||||||||||||||||||||
background-color: #1a1a1a; | ||||||||||||||||||||||||||||||||
cursor: pointer; | ||||||||||||||||||||||||||||||||
transition: border-color 0.25s; | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
button:hover { | ||||||||||||||||||||||||||||||||
border-color: #646cff; | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
button:focus, | ||||||||||||||||||||||||||||||||
button:focus-visible { | ||||||||||||||||||||||||||||||||
outline: 4px auto -webkit-focus-ring-color; | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
@media (prefers-color-scheme: light) { | ||||||||||||||||||||||||||||||||
:root { | ||||||||||||||||||||||||||||||||
color: #213547; | ||||||||||||||||||||||||||||||||
background-color: #ffffff; | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
a:hover { | ||||||||||||||||||||||||||||||||
color: #747bff; | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
button { | ||||||||||||||||||||||||||||||||
background-color: #f9f9f9; | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,13 @@ | ||||||||||
import { StrictMode } from "react"; | ||||||||||
import { createRoot } from "react-dom/client"; | ||||||||||
import "./index.css"; | ||||||||||
import App from "./App.tsx"; | ||||||||||
import StarknetProvider from "./starknet-provider.tsx"; | ||||||||||
|
||||||||||
createRoot(document.getElementById("root")!).render( | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Handle potential null case for root element. The non-null assertion ( Consider this safer approach: -createRoot(document.getElementById("root")!).render(
+const rootElement = document.getElementById("root");
+if (!rootElement) throw new Error("Failed to find root element");
+createRoot(rootElement).render( 📝 Committable suggestion
Suggested change
🧰 Tools🪛 Biome (1.9.4)[error] 7-7: Forbidden non-null assertion. (lint/style/noNonNullAssertion) |
||||||||||
<StrictMode> | ||||||||||
<StarknetProvider> | ||||||||||
<App /> | ||||||||||
</StarknetProvider> | ||||||||||
</StrictMode> | ||||||||||
); |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,41 @@ | ||||||||||||||||||||||||||||||||||||||||||
import { useEffect, useState, type PropsWithChildren } from "react"; | ||||||||||||||||||||||||||||||||||||||||||
import { mainnet } from "@starknet-react/chains"; | ||||||||||||||||||||||||||||||||||||||||||
import { jsonRpcProvider, StarknetConfig, voyager } from "@starknet-react/core"; | ||||||||||||||||||||||||||||||||||||||||||
import { dojoConfig } from "../dojoConfig"; | ||||||||||||||||||||||||||||||||||||||||||
import { | ||||||||||||||||||||||||||||||||||||||||||
predeployedAccounts, | ||||||||||||||||||||||||||||||||||||||||||
type PredeployedAccountsConnector, | ||||||||||||||||||||||||||||||||||||||||||
} from "@dojoengine/predeployed-connector"; | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
export default function StarknetProvider({ children }: PropsWithChildren) { | ||||||||||||||||||||||||||||||||||||||||||
const [retries, setRetries] = useState<number>(0); | ||||||||||||||||||||||||||||||||||||||||||
const [connectors, setConnectors] = useState< | ||||||||||||||||||||||||||||||||||||||||||
PredeployedAccountsConnector[] | ||||||||||||||||||||||||||||||||||||||||||
>([]); | ||||||||||||||||||||||||||||||||||||||||||
const provider = jsonRpcProvider({ | ||||||||||||||||||||||||||||||||||||||||||
rpc: () => ({ nodeUrl: dojoConfig.rpcUrl as string }), | ||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
useEffect(() => { | ||||||||||||||||||||||||||||||||||||||||||
if (connectors.length === 0 && retries < 5) { | ||||||||||||||||||||||||||||||||||||||||||
setRetries(retries + 1); | ||||||||||||||||||||||||||||||||||||||||||
predeployedAccounts({ | ||||||||||||||||||||||||||||||||||||||||||
rpc: dojoConfig.rpcUrl as string, | ||||||||||||||||||||||||||||||||||||||||||
id: "katana", | ||||||||||||||||||||||||||||||||||||||||||
name: "Katana", | ||||||||||||||||||||||||||||||||||||||||||
}).then(setConnectors); | ||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||
}, [connectors]); | ||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+19
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix missing dependency in useEffect hook. The Apply this fix: - }, [connectors]);
+ }, [connectors, retries]); 📝 Committable suggestion
Suggested change
🧰 Tools🪛 Biome (1.9.4)[error] 19-19: This hook does not specify all of its dependencies: retries This dependency is not specified in the hook dependency list. This dependency is not specified in the hook dependency list. (lint/correctness/useExhaustiveDependencies) |
||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
return ( | ||||||||||||||||||||||||||||||||||||||||||
<StarknetConfig | ||||||||||||||||||||||||||||||||||||||||||
chains={[mainnet]} | ||||||||||||||||||||||||||||||||||||||||||
provider={provider} | ||||||||||||||||||||||||||||||||||||||||||
connectors={connectors} | ||||||||||||||||||||||||||||||||||||||||||
explorer={voyager} | ||||||||||||||||||||||||||||||||||||||||||
autoConnect | ||||||||||||||||||||||||||||||||||||||||||
> | ||||||||||||||||||||||||||||||||||||||||||
{children} | ||||||||||||||||||||||||||||||||||||||||||
</StarknetConfig> | ||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Verify the manifest file path and add type safety.
The manifest is imported from a path outside the example directory. Let's verify the path and improve type safety:
Consider adding type information for the manifest import:
🏁 Script executed:
Length of output: 107
Attention: Manifest File Missing & Type Safety for JSON Import
It appears that the manifest file at the relative path
"../../worlds/dojo-starter/manifest_dev.json"
could not be located. Please take the following actions:📝 Committable suggestion