Skip to content

Commit

Permalink
Merge pull request dojoengine#142 from dojoengine/starknet-react-example
Browse files Browse the repository at this point in the history
feat: init starknet react example connection
  • Loading branch information
ponderingdemocritus authored Feb 29, 2024
2 parents 217ece7 + 24d28e7 commit d157d45
Show file tree
Hide file tree
Showing 77 changed files with 5,507 additions and 15,547 deletions.
24 changes: 12 additions & 12 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: oven-sh/setup-bun@v1
- uses: pnpm/action-setup@v3
with:
version: 8

- name: Update Submodules
run: git submodule update --init --recursive

- run: curl -L https://install.dojoengine.org | bash
- run: /home/runner/.config/.dojo/bin/dojoup -v v0.5.0
- run: /home/runner/.config/.dojo/bin/dojoup -v v0.5.1
- run: |
cd examples/dojo-starter
/home/runner/.config/.dojo/bin/sozo build
Expand All @@ -26,22 +29,19 @@ jobs:
- name: Install Protobuf Compiler
run: sudo apt-get install -y protobuf-compiler

- name: Link dependencies
run: bun link

- name: Install dependencies
run: bun install
run: pnpm i

- name: Run Prettier
run: bun x prettier --check .
run: pnpm run prettier --check .

- name: Build dependencies
run: bun run build && bun run build-examples
run: pnpm run build && pnpm run build-examples

- name: Run tests
run: bun vitest
run: pnpm run test

# - name: Upload coverage reports to Codecov
# uses: codecov/codecov-action@v3
# env:
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
Binary file removed bun.lockb
Binary file not shown.
Binary file added examples/.DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion examples/dojo-starter
Binary file removed examples/node/torii-bot/bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion examples/react/react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"rxjs": "^7.8.1",
"starknet": "5.24.3",
"starknet": "5.25.0",
"vite-plugin-top-level-await": "^1.3.1",
"vite-plugin-wasm": "^3.2.2"
},
Expand Down
6 changes: 3 additions & 3 deletions examples/react/react-app/src/dojo/createSystemCalls.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Account } from "starknet";
import { AccountInterface } from "starknet";
import { Entity, getComponentValue } from "@dojoengine/recs";
import { uuid } from "@latticexyz/utils";
import { ClientComponents } from "./createClientComponents";
Expand All @@ -18,7 +18,7 @@ export function createSystemCalls(
contractComponents: ContractComponents,
{ Position, Moves }: ClientComponents
) {
const spawn = async (account: Account) => {
const spawn = async (account: AccountInterface) => {
const entityId = getEntityIdFromKeys([
BigInt(account.address),
]) as Entity;
Expand Down Expand Up @@ -62,7 +62,7 @@ export function createSystemCalls(
}
};

const move = async (account: Account, direction: Direction) => {
const move = async (account: AccountInterface, direction: Direction) => {
const entityId = getEntityIdFromKeys([
BigInt(account.address),
]) as Entity;
Expand Down
17 changes: 8 additions & 9 deletions examples/react/react-app/src/dojo/generated/generated.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
/* Autogenerated file. Do not edit manually. */

import { Account } from "starknet";
import { Account, AccountInterface } from "starknet";
import { DojoProvider } from "@dojoengine/core";
import { Direction } from "../../utils";

export type IWorld = Awaited<ReturnType<typeof setupWorld>>;

export interface MoveProps {
account: Account | AccountInterface;
direction: Direction;
}

export async function setupWorld(provider: DojoProvider) {
function actions() {
const contract_name = "actions";

const spawn = async ({ account }: { account: Account }) => {
const spawn = async ({ account }: { account: AccountInterface }) => {
try {
return await provider.execute(
account,
Expand All @@ -24,13 +29,7 @@ export async function setupWorld(provider: DojoProvider) {
}
};

const move = async ({
account,
direction,
}: {
account: Account;
direction: Direction;
}) => {
const move = async ({ account, direction }: MoveProps) => {
try {
return await provider.execute(account, contract_name, "move", [
direction,
Expand Down
2 changes: 1 addition & 1 deletion examples/react/react-phaser-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"react-dom": "^18.2.0",
"rxjs": "^7.8.1",
"simplex-noise": "^4.0.1",
"starknet": "5.24.3",
"starknet": "5.25.0",
"styled-components": "^6.0.7",
"tailwind-merge": "^2.0.0",
"tailwindcss-animate": "^1.0.7",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Account } from "starknet";
import { AccountInterface } from "starknet";
import { ClientComponents } from "./createClientComponents";
import { Direction } from "./utils";
import { ContractComponents } from "./generated/contractComponents";
Expand All @@ -11,7 +11,7 @@ export function createSystemCalls(
contractComponents: ContractComponents,
{ Position, Moves }: ClientComponents
) {
const spawn = async (account: Account) => {
const spawn = async (account: AccountInterface) => {
try {
await client.actions.spawn({
account,
Expand All @@ -21,7 +21,7 @@ export function createSystemCalls(
}
};

const move = async (account: Account, direction: Direction) => {
const move = async (account: AccountInterface, direction: Direction) => {
try {
await client.actions.move({
account,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
/* Autogenerated file. Do not edit manually. */

import { Account } from "starknet";
import { Account, AccountInterface } from "starknet";
import { DojoProvider } from "@dojoengine/core";
import { Direction } from "../utils";

export type IWorld = Awaited<ReturnType<typeof setupWorld>>;

export interface MoveProps {
account: Account | AccountInterface;
direction: Direction;
}

export async function setupWorld(provider: DojoProvider) {
function actions() {
const contract_name = "actions";

const spawn = async ({ account }: { account: Account }) => {
const spawn = async ({ account }: { account: AccountInterface }) => {
try {
return await provider.execute(
account,
Expand All @@ -24,13 +29,7 @@ export async function setupWorld(provider: DojoProvider) {
}
};

const move = async ({
account,
direction,
}: {
account: Account;
direction: Direction;
}) => {
const move = async ({ account, direction }: MoveProps) => {
try {
return await provider.execute(account, contract_name, "move", [
direction,
Expand Down
2 changes: 1 addition & 1 deletion examples/react/react-pwa-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"rxjs": "^7.8.1",
"starknet": "5.24.3",
"starknet": "5.25.0",
"vite-plugin-top-level-await": "^1.3.1",
"vite-plugin-wasm": "^3.2.2"
},
Expand Down
6 changes: 3 additions & 3 deletions examples/react/react-pwa-app/src/dojo/createSystemCalls.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Account } from "starknet";
import { Account, AccountInterface } from "starknet";
import { Entity, getComponentValue } from "@dojoengine/recs";
import { uuid } from "@latticexyz/utils";
import { ClientComponents } from "./createClientComponents";
Expand All @@ -18,7 +18,7 @@ export function createSystemCalls(
contractComponents: ContractComponents,
{ Position, Moves }: ClientComponents
) {
const spawn = async (account: Account) => {
const spawn = async (account: AccountInterface) => {
const entityId = getEntityIdFromKeys([
BigInt(account.address),
]) as Entity;
Expand Down Expand Up @@ -62,7 +62,7 @@ export function createSystemCalls(
}
};

const move = async (account: Account, direction: Direction) => {
const move = async (account: AccountInterface, direction: Direction) => {
const entityId = getEntityIdFromKeys([
BigInt(account.address),
]) as Entity;
Expand Down
17 changes: 8 additions & 9 deletions examples/react/react-pwa-app/src/dojo/generated/generated.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
/* Autogenerated file. Do not edit manually. */

import { Account } from "starknet";
import { Account, AccountInterface } from "starknet";
import { DojoProvider } from "@dojoengine/core";
import { Direction } from "../../utils";

export type IWorld = Awaited<ReturnType<typeof setupWorld>>;

export interface MoveProps {
account: Account | AccountInterface;
direction: Direction;
}

export async function setupWorld(provider: DojoProvider) {
function actions() {
const contract_name = "actions";

const spawn = async ({ account }: { account: Account }) => {
const spawn = async ({ account }: { account: AccountInterface }) => {
try {
return await provider.execute(
account,
Expand All @@ -24,13 +29,7 @@ export async function setupWorld(provider: DojoProvider) {
}
};

const move = async ({
account,
direction,
}: {
account: Account;
direction: Direction;
}) => {
const move = async ({ account, direction }: MoveProps) => {
try {
return await provider.execute(account, contract_name, "move", [
direction,
Expand Down
Binary file removed examples/react/react-threejs/bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion examples/react/react-threejs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"rxjs": "^7.8.1",
"starknet": "5.24.3",
"starknet": "5.25.0",
"tailwind-merge": "^2.2.0",
"tailwindcss": "^3.4.1",
"tailwindcss-animate": "^1.0.7",
Expand Down
Loading

0 comments on commit d157d45

Please sign in to comment.