Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions .github/workflows/ci-contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- uses: actions/checkout@v3
- uses: software-mansion/setup-scarb@v1
with:
scarb-version: "2.7.0"
scarb-version: "2.8.4"
- run: |
scarb fmt --check
core-test:
Expand All @@ -35,6 +35,6 @@ jobs:
- uses: asdf-vm/actions/setup@v3
- run: |
asdf plugin add dojo https://github.com/dojoengine/asdf-dojo
asdf install dojo 1.0.0-alpha.12
asdf global dojo 1.0.0-alpha.12
asdf install dojo 1.0.4
asdf global dojo 1.0.4
sozo test
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ otherwise,

```bash
# Run Katana
katana --disable-fee --allowed-origins "*" --db-dir katana
katana --allowed-origins "*" --db-dir katana
```

#### Terminal two
Expand All @@ -68,7 +68,7 @@ sozo build
sozo migrate apply

# Start Torii
torii --world 0x263ae44e5414519a5c5a135cccaf3d9d7ee196d37e8de47a178da91f3de9b34 --allowed-origins "*"
torii --world 0x2bf4d3aa0dced89d37d8c3b4ff6a05895c0af32ff3baf9b02abf8504e53eaad --allowed-origins "*"
```

### How to deploy
Expand Down
1 change: 1 addition & 0 deletions client/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ node_modules
dist
dist-ssr
*.tsbuildinfo
bun.lockb

.env.production

Expand Down
Binary file modified client/bun.lockb
Binary file not shown.
6 changes: 3 additions & 3 deletions client/dojoConfig.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { createDojoConfig } from "@dojoengine/core";
import manifestDev from "../contracts/manifests/dev/deployment/manifest.json";
import manifestRelease from "../contracts/manifests/release/deployment/manifest.json";
import manifestDev from "../contracts/manifest_dev.json";
// import manifestSepolia from "../contracts/manifest_sepolia.json";

export const manifest = import.meta.env.VITE_PUBLIC_PROFILE === "dev" ? manifestDev : manifestRelease;
export const manifest = manifestDev;

export const dojoConfig = createDojoConfig({
toriiUrl: import.meta.env.VITE_PUBLIC_TORII_URL,
Expand Down
70 changes: 35 additions & 35 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,64 +13,64 @@
},
"packageManager": "bun@1.1.26",
"dependencies": {
"@cartridge/connector": "^0.3.44",
"@cartridge/controller": "^0.3.44",
"@dojoengine/core": "^1.0.0-alpha.14",
"@dojoengine/create-burner": "^1.0.0-alpha.14",
"@dojoengine/react": "^1.0.0-alpha.14",
"@cartridge/connector": "^0.3.46",
"@cartridge/controller": "^0.3.46",
"@dojoengine/core": "^1.0.2",
"@dojoengine/create-burner": "^1.0.2",
"@dojoengine/react": "^1.0.2",
"@dojoengine/recs": "^2.0.13",
"@dojoengine/state": "^1.0.0-alpha.14",
"@dojoengine/torii-client": "^1.0.0-alpha.14",
"@dojoengine/utils": "^1.0.0-alpha.14",
"@radix-ui/react-dialog": "^1.1.1",
"@radix-ui/react-dropdown-menu": "^2.1.1",
"@radix-ui/react-popover": "^1.1.1",
"@radix-ui/react-select": "^2.1.1",
"@dojoengine/state": "^1.0.2",
"@dojoengine/torii-client": "^1.0.2",
"@dojoengine/utils": "^1.0.2",
"@radix-ui/react-dialog": "^1.1.2",
"@radix-ui/react-dropdown-menu": "^2.1.2",
"@radix-ui/react-popover": "^1.1.2",
"@radix-ui/react-select": "^2.1.2",
"@radix-ui/react-slot": "^1.1.0",
"@radix-ui/react-tooltip": "^1.1.2",
"@radix-ui/react-tooltip": "^1.1.4",
"@starknet-react/core": "^2.9.0",
"class-variance-authority": "^0.7.0",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"fluid-tailwind": "^1.0.3",
"fluid-tailwind": "^1.0.4",
"idle-task": "^4.3.0",
"lucide-react": "^0.428.0",
"next-themes": "^0.3.0",
"react": "^19.0.0-rc-fb9a90fa48-20240614",
"react-dom": "^19.0.0-rc-fb9a90fa48-20240614",
"react-swipeable": "^7.0.1",
"sass": "^1.79.3",
"sonner": "^1.5.0",
"react-swipeable": "^7.0.2",
"sass": "^1.82.0",
"sonner": "^1.7.0",
"starknet": "^6.11.0",
"tailwind-merge": "^2.5.2",
"tailwind-merge": "^2.5.5",
"tailwindcss-animate": "^1.0.7",
"twgl.js": "^5.5.4",
"use-debounce": "^10.0.3",
"use-debounce": "^10.0.4",
"use-haptic": "^1.0.1",
"use-sound": "^4.0.3"
},
"devDependencies": {
"@eslint/js": "^9.11.1",
"@eslint/js": "^9.16.0",
"@fluid-tailwind/tailwind-merge": "^0.0.3",
"@types/node": "^22.6.1",
"@types/node": "^22.10.1",
"@types/react": "npm:types-react@rc",
"@types/react-dom": "npm:types-react-dom@rc",
"@vitejs/plugin-react-swc": "^3.7.0",
"@vitejs/plugin-react-swc": "^3.7.2",
"autoprefixer": "^10.4.20",
"eslint": "^9.11.1",
"eslint": "^9.16.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-react": "^7.36.1",
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-react-hooks": "^5.1.0-rc-fb9a90fa48-20240614",
"eslint-plugin-react-refresh": "^0.4.12",
"globals": "^15.9.0",
"postcss": "^8.4.47",
"prettier": "^3.3.3",
"eslint-plugin-react-refresh": "^0.4.16",
"globals": "^15.13.0",
"postcss": "^8.4.49",
"prettier": "^3.4.2",
"slint": "^0.1.0",
"tailwindcss": "^3.4.13",
"typescript": "^5.6.2",
"typescript-eslint": "^8.7.0",
"vite": "^5.4.7",
"vite-envs": "^4.4.5",
"vite-plugin-glsl": "^1.3.0",
"tailwindcss": "^3.4.16",
"typescript": "^5.7.2",
"typescript-eslint": "^8.17.0",
"vite": "^6.0.2",
"vite-envs": "^4.4.6",
"vite-plugin-glsl": "^1.3.1",
"vite-plugin-top-level-await": "^1.4.4",
"vite-plugin-wasm": "^3.3.0"
},
Expand Down
1 change: 1 addition & 0 deletions client/src/libs/dojo/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const getPixelEntities = async (
const entities = await client.getEntities({
limit,
offset: 0,
dont_include_hashed_keys: true,
clause: {
Composite: {
operator: "And",
Expand Down
4 changes: 2 additions & 2 deletions client/src/libs/dojo/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export async function setup({ ...config }: DojoConfig) {
const eventSync = await getSyncEvents(toriiClient, contractComponents as any, undefined, []);

// Sync all entities
const sync = await getSyncEntities(toriiClient, contractComponents as any, []);
const sync = await getSyncEntities(toriiClient, contractComponents as any, undefined, []);

// setup world
const client = await setupWorld(dojoProvider);
Expand Down Expand Up @@ -68,7 +68,7 @@ export async function setup({ ...config }: DojoConfig) {
contractComponents,
systemCalls: createSystemCalls({ client }, clientComponents, world),
publish: (typedData: string, signature: ArraySignatureType) => {
toriiClient.publishMessage(typedData, signature);
toriiClient.publishMessage(typedData, signature, true);
},
config,
dojoProvider,
Expand Down
2 changes: 1 addition & 1 deletion client/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ export interface GridHistory {
past: Pixel[][];
present: Pixel[];
future: Pixel[][];
}
}
73 changes: 73 additions & 0 deletions contracts/.cursorrules
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
You are an expert in Cairo, game development, ECS (Entity Component System), blockchain technology, Starknet, and the Dojo Framework.

Key Principles

- Write clear, concise, and idiomatic Cairo code with accurate examples.
- Use ECS paradigms effectively for game development.
- Prioritize modularity, clean code organization, and efficient resource management in Cairo and Dojo projects.
- Use expressive variable names that convey intent (e.g., `is_ready`, `has_data`).
- Adhere to Cairo's naming conventions: snake_case for variables and functions, PascalCase for types and structs.
- Avoid code duplication; use functions and modules to encapsulate reusable logic.
- Write code with safety, concurrency, and performance in mind, embracing Cairo's ownership and type system.

Game Development with ECS

- Implement ECS architecture using Dojo's components, systems, and world.
- Use Dojo's query system for efficient entity management and data access.
- Leverage Dojo's event system for game state changes and inter-system communication.
- Implement game loops and update cycles using Dojo's system execution order.
- Optimize performance by minimizing state changes and leveraging Dojo's batched updates.

Smart Contract Development

- Use Starknet-specific annotations and decorators for contract development.
- Implement storage variables and mappings using Starknet's storage model.
- Use events for logging important state changes in smart contracts.
- Implement view and external functions for contract interactions.
- Utilize Starknet's native types (e.g., felt252, ContractAddress) appropriately.

Blockchain Integration

- Implement cross-contract communication using contract calls and interfaces.
- Use Starknet's messaging system for L1-L2 communication.
- Implement account abstraction features for enhanced user experience.
- Utilize Starknet's cryptographic primitives for secure operations.

Dojo Framework

- Use Sozo for project scaffolding, building, and deployment.
- Leverage Katana for local development and testing of Starknet contracts.
- Utilize Torii for efficient indexing and querying of on-chain data.
- Implement and use actions for game state transitions.
- Use Dojo's authorization system for secure contract interactions.

Testing and Deployment

- Write unit tests for Cairo contracts using the `#[test]` attribute.
- Use Dojo's testing utilities for simulating game scenarios.
- Implement integration tests to validate contract interactions and game logic.
- Use Katana for local testing and Starknet's testnet for pre-production deployment.
- Leverage Sozo for managing contract migrations and upgrades.

Performance Optimization

- Minimize storage reads and writes in smart contracts.
- Use efficient data structures and algorithms for on-chain computations.
- Implement off-chain computations where possible, using on-chain verification.
- Optimize gas usage by batching transactions and using calldata efficiently.
Ï
Key Conventions

1. Structure the application into modules: separate concerns like game logic, smart contracts, and off-chain components.
2. Use environment variables for configuration management in off-chain components.
3. Ensure code is well-documented with inline comments and Cairo-doc.

Ecosystem

- Use Cairo for smart contract development on Starknet.
- Leverage Scarb for package management and build processes.
- Use Dojo for game development on Starknet.
- Utilize Katana for local Starknet development environment.
- Implement off-chain components using languages like Rust or TypeScript for optimal performance.

Refer to the Cairo Book, Starknet documentation, and Dojo documentation for in-depth information on best practices and advanced features.Ï
5 changes: 4 additions & 1 deletion contracts/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
db
target
generated
.idea
.idea
manifests
sepolia.deployer.keystore.json
sepolia.deployer.keystore.jsonc
4 changes: 2 additions & 2 deletions contracts/.tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
scarb 2.7.0
dojo 1.0.0-alpha.12
dojo 1.0.4
scarb 2.8.4
4 changes: 2 additions & 2 deletions contracts/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"cairo1.enableLanguageServer": true,
"cairo1.languageServerPath": "${userHome}/.asdf/installs/dojo/1.0.0-alpha.12/bin/dojo-language-server",
"cairo1.languageServerPath": "${userHome}/.asdf/installs/dojo/1.0.4/bin/dojo-language-server",
"cairo1.enableScarb": true,
"cairo1.scarbPath": "${userHome}/.asdf/installs/scarb/2.7.0/bin/scarb",
"cairo1.scarbPath": "${userHome}/.asdf/installs/scarb/2.8.4/bin/scarb",
"cairo1.preferScarbLanguageServer": false
}
6 changes: 3 additions & 3 deletions contracts/.vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"label": "Start Katana",
"type": "shell",
"command": "katana --disable-fee --allowed-origins '*' --db-dir db/katana",
"command": "katana --http.cors_origins '*' --db-dir db/katana",
"isBackground": true,
"problemMatcher": [],
"presentation": {
Expand All @@ -16,7 +16,7 @@
{
"label": "Start Torii",
"type": "shell",
"command": "torii --world 0x263ae44e5414519a5c5a135cccaf3d9d7ee196d37e8de47a178da91f3de9b34 --allowed-origins '*' --database db/torii",
"command": "torii --world 0x6f130c8e150882e39cbe878c650c8f35c86579180dbc77d0c1cbe169449b5f6 --http.cors_origins '*' --db-dir db/torii",
"isBackground": true,
"problemMatcher": [],
"presentation": {
Expand All @@ -40,4 +40,4 @@
}
}
]
}
}
32 changes: 25 additions & 7 deletions contracts/Scarb.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,47 @@ version = 1

[[package]]
name = "dojo"
version = "1.0.0-alpha.4"
source = "git+https://github.com/dojoengine/dojo?tag=v1.0.0-alpha.12#b391948911356cbf8a91daa93314809c87411098"
version = "1.0.4"
source = "git+https://github.com/dojoengine/dojo?tag=v1.0.4#e9f286c14f5952604bec915719c14b7f2d7b4233"
dependencies = [
"dojo_plugin",
]

[[package]]
name = "dojo_cairo_test"
version = "1.0.0-rc.0"
source = "git+https://github.com/dojoengine/dojo?tag=v1.0.4#e9f286c14f5952604bec915719c14b7f2d7b4233"
dependencies = [
"dojo",
]

[[package]]
name = "dojo_plugin"
version = "1.0.0-alpha.4"
source = "git+https://github.com/dojoengine/dojo?rev=f15def33#f15def330c0d099e79351d11c197f63e8cc1ff36"
version = "2.8.4"
source = "git+https://github.com/dojoengine/dojo?tag=v1.0.4#e9f286c14f5952604bec915719c14b7f2d7b4233"

[[package]]
name = "p_war"
version = "0.3.54"
dependencies = [
"dojo",
"dojo_cairo_test",
"pixelaw",
"pixelaw_test_helpers",
]

[[package]]
name = "pixelaw"
version = "0.3.50"
source = "git+https://github.com/pixelaw/core?branch=feat%2Fup-v12#75240c7f745330bfe60e8f420c774aca22a68002"
version = "0.5.15"
source = "git+https://github.com/pixelaw/core?tag=v0.5.15#6f18b9210cd917b6247be8e77e96381c05284443"
dependencies = [
"dojo",
]

[[package]]
name = "pixelaw_test_helpers"
version = "0.5.15"
source = "git+https://github.com/pixelaw/core?tag=v0.5.15#6f18b9210cd917b6247be8e77e96381c05284443"
dependencies = [
"dojo",
"dojo_cairo_test",
]
Loading
Loading