diff --git a/client/package.json b/client/package.json index 21e9852..406b29a 100644 --- a/client/package.json +++ b/client/package.json @@ -55,4 +55,4 @@ "typescript": "^5.5.4", "vite": "^4.3.9" } -} \ No newline at end of file +} diff --git a/client/src/dojo/createClientComponents.ts b/client/src/dojo/createClientComponents.ts index 550ad13..70814af 100644 --- a/client/src/dojo/createClientComponents.ts +++ b/client/src/dojo/createClientComponents.ts @@ -4,13 +4,13 @@ import { ContractComponents } from "./generated/contractComponents"; export type ClientComponents = ReturnType; export function createClientComponents({ - contractComponents, + contractComponents, }: { - contractComponents: ContractComponents; + contractComponents: ContractComponents; }) { - return { - ...contractComponents, - Position: overridableComponent(contractComponents.Position), - Moves: overridableComponent(contractComponents.Moves), - }; + return { + ...contractComponents, + Position: overridableComponent(contractComponents.Position), + Moves: overridableComponent(contractComponents.Moves), + }; } diff --git a/client/src/dojo/createSystemCalls.ts b/client/src/dojo/createSystemCalls.ts index 4240ba1..c3d0f06 100644 --- a/client/src/dojo/createSystemCalls.ts +++ b/client/src/dojo/createSystemCalls.ts @@ -1,11 +1,11 @@ import { AccountInterface } from "starknet"; import { - Entity, - Has, - HasValue, - World, - defineSystem, - getComponentValue, + Entity, + Has, + HasValue, + World, + defineSystem, + getComponentValue, } from "@dojoengine/recs"; import { uuid } from "@latticexyz/utils"; import { ClientComponents } from "./createClientComponents"; @@ -16,127 +16,116 @@ import type { IWorld } from "./generated/generated"; export type SystemCalls = ReturnType; export function createSystemCalls( - { client }: { client: IWorld }, - { Position, Moves }: ClientComponents, - world: World + { client }: { client: IWorld }, + { Position, Moves }: ClientComponents, + world: World, ) { - const spawn = async (account: AccountInterface) => { - const entityId = getEntityIdFromKeys([ - BigInt(account.address), - ]) as Entity; + const spawn = async (account: AccountInterface) => { + const entityId = getEntityIdFromKeys([BigInt(account.address)]) as Entity; - const movesId = uuid(); - Moves.addOverride(movesId, { - entity: entityId, - value: { - player: BigInt(entityId), - remaining: - (getComponentValue(Moves, entityId)?.remaining || 0) + 100, - }, - }); + const movesId = uuid(); + Moves.addOverride(movesId, { + entity: entityId, + value: { + player: BigInt(entityId), + remaining: (getComponentValue(Moves, entityId)?.remaining || 0) + 100, + }, + }); - const positionId = uuid(); - Position.addOverride(positionId, { - entity: entityId, - value: { - player: BigInt(entityId), - vec: { - x: 10 + (getComponentValue(Position, entityId)?.vec.x || 0), - y: 10 + (getComponentValue(Position, entityId)?.vec.y || 0), - }, - }, - }); + const positionId = uuid(); + Position.addOverride(positionId, { + entity: entityId, + value: { + player: BigInt(entityId), + vec: { + x: 10 + (getComponentValue(Position, entityId)?.vec.x || 0), + y: 10 + (getComponentValue(Position, entityId)?.vec.y || 0), + }, + }, + }); - try { - await client.actions.spawn({ - account, - }); + try { + await client.actions.spawn({ + account, + }); - // Wait for the indexer to update the entity - // By doing this we keep the optimistic UI in sync with the actual state - await new Promise((resolve) => { - defineSystem( - world, - [ - Has(Moves), - HasValue(Moves, { player: BigInt(account.address) }), - ], - () => { - resolve(); - } - ); - }); - } catch (e) { - console.log(e); - Position.removeOverride(positionId); - Moves.removeOverride(movesId); - } finally { - Position.removeOverride(positionId); - Moves.removeOverride(movesId); - } - }; + // Wait for the indexer to update the entity + // By doing this we keep the optimistic UI in sync with the actual state + await new Promise((resolve) => { + defineSystem( + world, + [Has(Moves), HasValue(Moves, { player: BigInt(account.address) })], + () => { + resolve(); + }, + ); + }); + } catch (e) { + console.log(e); + Position.removeOverride(positionId); + Moves.removeOverride(movesId); + } finally { + Position.removeOverride(positionId); + Moves.removeOverride(movesId); + } + }; - const move = async (account: AccountInterface, direction: Direction) => { - const entityId = getEntityIdFromKeys([ - BigInt(account.address), - ]) as Entity; + const move = async (account: AccountInterface, direction: Direction) => { + const entityId = getEntityIdFromKeys([BigInt(account.address)]) as Entity; - // Update the state before the transaction - // const positionId = uuid(); - // Position.addOverride(positionId, { - // entity: entityId, - // value: { - // player: BigInt(entityId), - // vec: updatePositionWithDirection( - // direction, - // getComponentValue(Position, entityId) as any - // ).vec, - // }, - // }); + // Update the state before the transaction + // const positionId = uuid(); + // Position.addOverride(positionId, { + // entity: entityId, + // value: { + // player: BigInt(entityId), + // vec: updatePositionWithDirection( + // direction, + // getComponentValue(Position, entityId) as any + // ).vec, + // }, + // }); - // // Update the state before the transaction - // const movesId = uuid(); - // Moves.addOverride(movesId, { - // entity: entityId, - // value: { - // player: BigInt(entityId), - // remaining: - // (getComponentValue(Moves, entityId)?.remaining || 0) - 1, - // }, - // }); + // // Update the state before the transaction + // const movesId = uuid(); + // Moves.addOverride(movesId, { + // entity: entityId, + // value: { + // player: BigInt(entityId), + // remaining: + // (getComponentValue(Moves, entityId)?.remaining || 0) - 1, + // }, + // }); - try { - await client.actions.move({ - account, - direction, - }); + try { + await client.actions.move({ + account, + direction, + }); - // Wait for the indexer to update the entity - // By doing this we keep the optimistic UI in sync with the actual state - await new Promise((resolve) => { - defineSystem( - world, - [ - Has(Moves), - HasValue(Moves, { player: BigInt(account.address) }), - ], - () => { - resolve(); - } - ); - }); - } catch (e) { - console.log(e); - // Position.removeOverride(positionId); - // Moves.removeOverride(movesId); - } finally { - // Position.removeOverride(positionId); - // Moves.removeOverride(movesId); - } - }; + // Wait for the indexer to update the entity + // By doing this we keep the optimistic UI in sync with the actual state + await new Promise((resolve) => { + defineSystem( + world, + [Has(Moves), HasValue(Moves, { player: BigInt(account.address) })], + () => { + resolve(); + }, + ); + }); + } catch (e) { + console.log(e); + // Position.removeOverride(positionId); + // Moves.removeOverride(movesId); + } finally { + // Position.removeOverride(positionId); + // Moves.removeOverride(movesId); + } + }; - return { - spawn, - move, - }; + return { + spawn, + move, + }; } diff --git a/client/src/dojo/generated/contractComponents.ts b/client/src/dojo/generated/contractComponents.ts index 596871c..d4197ee 100644 --- a/client/src/dojo/generated/contractComponents.ts +++ b/client/src/dojo/generated/contractComponents.ts @@ -7,57 +7,57 @@ import { defineComponent, Type as RecsType, World } from "@dojoengine/recs"; export type ContractComponents = Awaited< - ReturnType + ReturnType >; export function defineContractComponents(world: World) { - return { - DirectionsAvailable: (() => { - return defineComponent( - world, - { player: RecsType.BigInt, directions: RecsType.StringArray }, - { - metadata: { - name: "dojo_starter-DirectionsAvailable", - types: ["contractaddress"], - customTypes: ["Direction"], - }, - } - ); - })(), - Moves: (() => { - return defineComponent( - world, - { - player: RecsType.BigInt, - remaining: RecsType.Number, - last_direction: RecsType.Number, - can_move: RecsType.Boolean, - }, - { - metadata: { - name: "dojo_starter-Moves", - types: ["contractaddress", "u8", "enum", "bool"], - customTypes: ["Direction"], - }, - } - ); - })(), - Position: (() => { - return defineComponent( - world, - { - player: RecsType.BigInt, - vec: { x: RecsType.Number, y: RecsType.Number }, - }, - { - metadata: { - name: "dojo_starter-Position", - types: ["contractaddress", "u32", "u32"], - customTypes: ["Vec2"], - }, - } - ); - })(), - }; + return { + DirectionsAvailable: (() => { + return defineComponent( + world, + { player: RecsType.BigInt, directions: RecsType.StringArray }, + { + metadata: { + name: "dojo_starter-DirectionsAvailable", + types: ["contractaddress"], + customTypes: ["Direction"], + }, + }, + ); + })(), + Moves: (() => { + return defineComponent( + world, + { + player: RecsType.BigInt, + remaining: RecsType.Number, + last_direction: RecsType.Number, + can_move: RecsType.Boolean, + }, + { + metadata: { + name: "dojo_starter-Moves", + types: ["contractaddress", "u8", "enum", "bool"], + customTypes: ["Direction"], + }, + }, + ); + })(), + Position: (() => { + return defineComponent( + world, + { + player: RecsType.BigInt, + vec: { x: RecsType.Number, y: RecsType.Number }, + }, + { + metadata: { + name: "dojo_starter-Position", + types: ["contractaddress", "u32", "u32"], + customTypes: ["Vec2"], + }, + }, + ); + })(), + }; } diff --git a/client/src/dojo/generated/generated.ts b/client/src/dojo/generated/generated.ts index b10d265..bbd1c73 100644 --- a/client/src/dojo/generated/generated.ts +++ b/client/src/dojo/generated/generated.ts @@ -5,56 +5,56 @@ import { Direction } from "../../utils"; const NAMESPACE = "dojo_starter"; export interface IWorld { - actions: { - spawn: (props: { account: AccountInterface }) => Promise; - move: (props: MoveProps) => Promise; - }; + actions: { + spawn: (props: { account: AccountInterface }) => Promise; + move: (props: MoveProps) => Promise; + }; } export interface MoveProps { - account: Account | AccountInterface; - direction: Direction; + account: Account | AccountInterface; + direction: Direction; } const handleError = (action: string, error: unknown) => { - console.error(`Error executing ${action}:`, error); - throw error; + console.error(`Error executing ${action}:`, error); + throw error; }; export const setupWorld = async (provider: DojoProvider): Promise => { - const actions = () => ({ - spawn: async ({ account }: { account: AccountInterface }) => { - try { - return await provider.execute( - account, - { - contractName: "actions", - entrypoint: "spawn", - calldata: [], - }, - NAMESPACE - ); - } catch (error) { - handleError("spawn", error); - } - }, + const actions = () => ({ + spawn: async ({ account }: { account: AccountInterface }) => { + try { + return await provider.execute( + account, + { + contractName: "actions", + entrypoint: "spawn", + calldata: [], + }, + NAMESPACE, + ); + } catch (error) { + handleError("spawn", error); + } + }, - move: async ({ account, direction }: MoveProps) => { - try { - return await provider.execute( - account, - { - contractName: "actions", - entrypoint: "move", - calldata: [direction], - }, - NAMESPACE - ); - } catch (error) { - handleError("move", error); - } - }, - }); + move: async ({ account, direction }: MoveProps) => { + try { + return await provider.execute( + account, + { + contractName: "actions", + entrypoint: "move", + calldata: [direction], + }, + NAMESPACE, + ); + } catch (error) { + handleError("move", error); + } + }, + }); - return { actions: actions() }; + return { actions: actions() }; }; diff --git a/client/src/dojo/generated/setup.ts b/client/src/dojo/generated/setup.ts index dd51a3a..386810d 100644 --- a/client/src/dojo/generated/setup.ts +++ b/client/src/dojo/generated/setup.ts @@ -11,61 +11,61 @@ import { BurnerManager } from "@dojoengine/create-burner"; export type SetupResult = Awaited>; export async function setup({ ...config }: DojoConfig) { - console.log(torii.poseidonHash(["1"])); - // torii client - const toriiClient = await torii.createClient({ - rpcUrl: config.rpcUrl, - toriiUrl: config.toriiUrl, - relayUrl: "", - worldAddress: config.manifest.world.address || "", - }); + console.log(torii.poseidonHash(["1"])); + // torii client + const toriiClient = await torii.createClient({ + rpcUrl: config.rpcUrl, + toriiUrl: config.toriiUrl, + relayUrl: "", + worldAddress: config.manifest.world.address || "", + }); - // create contract components - const contractComponents = defineContractComponents(world); + // create contract components + const contractComponents = defineContractComponents(world); - // create client components - const clientComponents = createClientComponents({ contractComponents }); + // create client components + const clientComponents = createClientComponents({ contractComponents }); - // create dojo provider - const dojoProvider = new DojoProvider(config.manifest, config.rpcUrl); + // create dojo provider + const dojoProvider = new DojoProvider(config.manifest, config.rpcUrl); - // setup world - const client = await setupWorld(dojoProvider); + // setup world + const client = await setupWorld(dojoProvider); - // create burner manager - const burnerManager = new BurnerManager({ - masterAccount: new Account( - { - nodeUrl: config.rpcUrl, - }, - config.masterAddress, - config.masterPrivateKey - ), - accountClassHash: config.accountClassHash, - rpcProvider: dojoProvider.provider, - feeTokenAddress: config.feeTokenAddress, - }); + // create burner manager + const burnerManager = new BurnerManager({ + masterAccount: new Account( + { + nodeUrl: config.rpcUrl, + }, + config.masterAddress, + config.masterPrivateKey, + ), + accountClassHash: config.accountClassHash, + rpcProvider: dojoProvider.provider, + feeTokenAddress: config.feeTokenAddress, + }); - try { - await burnerManager.init(); - if (burnerManager.list().length === 0) { - await burnerManager.create(); - } - } catch (e) { - console.error(e); + try { + await burnerManager.init(); + if (burnerManager.list().length === 0) { + await burnerManager.create(); } + } catch (e) { + console.error(e); + } - return { - client, - clientComponents, - contractComponents, - systemCalls: createSystemCalls({ client }, clientComponents, world), - publish: (typedData: string, signature: ArraySignatureType) => { - toriiClient.publishMessage(typedData, signature); - }, - config, - dojoProvider, - burnerManager, - toriiClient, - }; + return { + client, + clientComponents, + contractComponents, + systemCalls: createSystemCalls({ client }, clientComponents, world), + publish: (typedData: string, signature: ArraySignatureType) => { + toriiClient.publishMessage(typedData, signature); + }, + config, + dojoProvider, + burnerManager, + toriiClient, + }; } diff --git a/client/src/hooks/utils.ts b/client/src/hooks/utils.ts index 6e92883..31827b0 100644 --- a/client/src/hooks/utils.ts +++ b/client/src/hooks/utils.ts @@ -99,7 +99,7 @@ export const animateCustomEase = ( element: HTMLSpanElement, property: any, currentValue: number, - toValue: number + toValue: number, ) => { let d = duration, ea = easing, @@ -134,7 +134,7 @@ const Utils: { fromMin: number, fromMax: number, toMin: number, - toMax: number + toMax: number, ) => number; } = { modulate: (val, fromMin, fromMax, toMin, toMax) => { @@ -147,7 +147,7 @@ export const flicker = ( durationLow: number, durationHigh: number, valLow: number, - valHigh: number + valHigh: number, ) => { // get normalized progress value from 0 - 1 let n = Utils.modulate(progress, durationLow, durationHigh, valLow, valHigh); @@ -156,7 +156,7 @@ export const flicker = ( return n; } let result: number = Math.abs( - n * Math.sin((n - 0.13) * ((0.2 * Math.PI) / 0.4)) + n * Math.sin((n - 0.13) * ((0.2 * Math.PI) / 0.4)), ); return result > 0 ? result : result * -1; }; diff --git a/client/src/types.d.ts b/client/src/types.d.ts index 0689483..3baaab0 100644 --- a/client/src/types.d.ts +++ b/client/src/types.d.ts @@ -8,7 +8,6 @@ export type OptionsProps = { gameCondition: number[]; }; - type WinnerList = number[]; export type GameOptions = { @@ -25,4 +24,4 @@ export type MarkerProps = { pos: string; size: number; tileMap: Record; -} \ No newline at end of file +}; diff --git a/client/src/types/react-simple-flex-grid.d.ts b/client/src/types/react-simple-flex-grid.d.ts index 1992e64..aa53988 100644 --- a/client/src/types/react-simple-flex-grid.d.ts +++ b/client/src/types/react-simple-flex-grid.d.ts @@ -1,4 +1,4 @@ -declare module 'react-simple-flex-grid' { - export const Row: React.ComponentType; - export const Col: React.ComponentType; -} \ No newline at end of file +declare module "react-simple-flex-grid" { + export const Row: React.ComponentType; + export const Col: React.ComponentType; +} diff --git a/client/src/utils/abi/erc721.json b/client/src/utils/abi/erc721.json index 3fdd70e..c08fe58 100644 --- a/client/src/utils/abi/erc721.json +++ b/client/src/utils/abi/erc721.json @@ -1,340 +1,340 @@ [ - { - "type": "impl", - "name": "IERC721Impl", - "interface_name": "starkludo::erc721::IERC721" - }, - { - "type": "struct", - "name": "core::integer::u256", - "members": [ - { - "name": "low", - "type": "core::integer::u128" - }, - { - "name": "high", - "type": "core::integer::u128" - } - ] - }, - { - "type": "enum", - "name": "core::bool", - "variants": [ - { - "name": "False", - "type": "()" - }, - { - "name": "True", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "starkludo::erc721::IERC721", - "items": [ - { - "type": "function", - "name": "get_name", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "get_symbol", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "get_token_uri", - "inputs": [ - { - "name": "token_id", - "type": "core::integer::u256" - } - ], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "balance_of", - "inputs": [ - { - "name": "account", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [ - { - "type": "core::integer::u256" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "owner_of", - "inputs": [ - { - "name": "token_id", - "type": "core::integer::u256" - } - ], - "outputs": [ - { - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "get_approved", - "inputs": [ - { - "name": "token_id", - "type": "core::integer::u256" - } - ], - "outputs": [ - { - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "get_total_nft", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u256" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "get_token_ids_of_address", - "inputs": [ - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [ - { - "type": "core::array::Array::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "is_approved_for_all", - "inputs": [ - { - "name": "owner", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "operator", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [ - { - "type": "core::bool" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "approve", - "inputs": [ - { - "name": "to", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "token_id", - "type": "core::integer::u256" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "set_approval_for_all", - "inputs": [ - { - "name": "operator", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "approved", - "type": "core::bool" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "transfer_from", - "inputs": [ - { - "name": "from", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "to", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "token_id", - "type": "core::integer::u256" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "mint", - "inputs": [ - { - "name": "to", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "constructor", - "name": "constructor", + { + "type": "impl", + "name": "IERC721Impl", + "interface_name": "starkludo::erc721::IERC721" + }, + { + "type": "struct", + "name": "core::integer::u256", + "members": [ + { + "name": "low", + "type": "core::integer::u128" + }, + { + "name": "high", + "type": "core::integer::u128" + } + ] + }, + { + "type": "enum", + "name": "core::bool", + "variants": [ + { + "name": "False", + "type": "()" + }, + { + "name": "True", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "starkludo::erc721::IERC721", + "items": [ + { + "type": "function", + "name": "get_name", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "get_symbol", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "get_token_uri", "inputs": [ - { - "name": "_name", - "type": "core::felt252" - }, - { - "name": "_symbol", - "type": "core::felt252" - } - ] - }, - { - "type": "event", - "name": "starkludo::erc721::ERC721::Approval", - "kind": "struct", - "members": [ - { - "name": "owner", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "to", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "token_id", - "type": "core::integer::u256", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "starkludo::erc721::ERC721::Transfer", - "kind": "struct", - "members": [ - { - "name": "from", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "to", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "token_id", - "type": "core::integer::u256", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "starkludo::erc721::ERC721::ApprovalForAll", - "kind": "struct", - "members": [ - { - "name": "owner", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "operator", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "approved", - "type": "core::bool", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "starkludo::erc721::ERC721::Event", - "kind": "enum", - "variants": [ - { - "name": "Approval", - "type": "starkludo::erc721::ERC721::Approval", - "kind": "nested" - }, - { - "name": "Transfer", - "type": "starkludo::erc721::ERC721::Transfer", - "kind": "nested" - }, - { - "name": "ApprovalForAll", - "type": "starkludo::erc721::ERC721::ApprovalForAll", - "kind": "nested" - } - ] - } -] \ No newline at end of file + { + "name": "token_id", + "type": "core::integer::u256" + } + ], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "balance_of", + "inputs": [ + { + "name": "account", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::integer::u256" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "owner_of", + "inputs": [ + { + "name": "token_id", + "type": "core::integer::u256" + } + ], + "outputs": [ + { + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "get_approved", + "inputs": [ + { + "name": "token_id", + "type": "core::integer::u256" + } + ], + "outputs": [ + { + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "get_total_nft", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u256" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "get_token_ids_of_address", + "inputs": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::array::Array::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "is_approved_for_all", + "inputs": [ + { + "name": "owner", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "operator", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "approve", + "inputs": [ + { + "name": "to", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "token_id", + "type": "core::integer::u256" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "set_approval_for_all", + "inputs": [ + { + "name": "operator", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "approved", + "type": "core::bool" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "transfer_from", + "inputs": [ + { + "name": "from", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "to", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "token_id", + "type": "core::integer::u256" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "mint", + "inputs": [ + { + "name": "to", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "constructor", + "name": "constructor", + "inputs": [ + { + "name": "_name", + "type": "core::felt252" + }, + { + "name": "_symbol", + "type": "core::felt252" + } + ] + }, + { + "type": "event", + "name": "starkludo::erc721::ERC721::Approval", + "kind": "struct", + "members": [ + { + "name": "owner", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "to", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "token_id", + "type": "core::integer::u256", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "starkludo::erc721::ERC721::Transfer", + "kind": "struct", + "members": [ + { + "name": "from", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "to", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "token_id", + "type": "core::integer::u256", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "starkludo::erc721::ERC721::ApprovalForAll", + "kind": "struct", + "members": [ + { + "name": "owner", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "operator", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "approved", + "type": "core::bool", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "starkludo::erc721::ERC721::Event", + "kind": "enum", + "variants": [ + { + "name": "Approval", + "type": "starkludo::erc721::ERC721::Approval", + "kind": "nested" + }, + { + "name": "Transfer", + "type": "starkludo::erc721::ERC721::Transfer", + "kind": "nested" + }, + { + "name": "ApprovalForAll", + "type": "starkludo::erc721::ERC721::ApprovalForAll", + "kind": "nested" + } + ] + } +] diff --git a/client/src/utils/abi/nft_name_resolver.json b/client/src/utils/abi/nft_name_resolver.json index a7ff1d8..06016bd 100644 --- a/client/src/utils/abi/nft_name_resolver.json +++ b/client/src/utils/abi/nft_name_resolver.json @@ -1,87 +1,87 @@ [ - { - "type": "impl", - "name": "NFTNameResolver", - "interface_name": "starkludo::nft_name_resolver::INFTNameResolver" - }, - { - "type": "struct", - "name": "core::integer::u256", - "members": [ - { - "name": "low", - "type": "core::integer::u128" - }, - { - "name": "high", - "type": "core::integer::u128" - } - ] - }, - { - "type": "interface", - "name": "starkludo::nft_name_resolver::INFTNameResolver", - "items": [ - { - "type": "function", - "name": "get_name_of_id", - "inputs": [ - { - "name": "id", - "type": "core::integer::u256" - } - ], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "get_id_of_name", - "inputs": [ - { - "name": "name", - "type": "core::felt252" - } - ], - "outputs": [ - { - "type": "core::integer::u256" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "create_nft_name", - "inputs": [ - { - "name": "name", - "type": "core::felt252" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "constructor", - "name": "constructor", + { + "type": "impl", + "name": "NFTNameResolver", + "interface_name": "starkludo::nft_name_resolver::INFTNameResolver" + }, + { + "type": "struct", + "name": "core::integer::u256", + "members": [ + { + "name": "low", + "type": "core::integer::u128" + }, + { + "name": "high", + "type": "core::integer::u128" + } + ] + }, + { + "type": "interface", + "name": "starkludo::nft_name_resolver::INFTNameResolver", + "items": [ + { + "type": "function", + "name": "get_name_of_id", "inputs": [ - { - "name": "nft_address", - "type": "core::starknet::contract_address::ContractAddress" - } - ] - }, - { - "type": "event", - "name": "starkludo::nft_name_resolver::NFTNameResolver::Event", - "kind": "enum", - "variants": [] - } -] \ No newline at end of file + { + "name": "id", + "type": "core::integer::u256" + } + ], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "get_id_of_name", + "inputs": [ + { + "name": "name", + "type": "core::felt252" + } + ], + "outputs": [ + { + "type": "core::integer::u256" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "create_nft_name", + "inputs": [ + { + "name": "name", + "type": "core::felt252" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "constructor", + "name": "constructor", + "inputs": [ + { + "name": "nft_address", + "type": "core::starknet::contract_address::ContractAddress" + } + ] + }, + { + "type": "event", + "name": "starkludo::nft_name_resolver::NFTNameResolver::Event", + "kind": "enum", + "variants": [] + } +] diff --git a/client/src/utils/constants.ts b/client/src/utils/constants.ts index 451f970..05020e6 100644 --- a/client/src/utils/constants.ts +++ b/client/src/utils/constants.ts @@ -30,7 +30,7 @@ export const getERC721Contract = (account?: AccountInterface): Contract => { }; export const getNftNameResolverContract = ( - account?: AccountInterface + account?: AccountInterface, ): Contract => { // const { abi: NFT_NAME_RESOLVER_ABI } = await RPC_PROVIDER.getClassAt( // NFT_NAME_RESOLVER_ADDRESS @@ -42,7 +42,7 @@ export const getNftNameResolverContract = ( let contract = new Contract( NFT_NAME_RESOLVER_ABI, NFT_NAME_RESOLVER_ADDRESS, - RPC_PROVIDER + RPC_PROVIDER, ); if (account) { diff --git a/client/src/utils/index.ts b/client/src/utils/index.ts index 1ec8b00..ca67a8d 100644 --- a/client/src/utils/index.ts +++ b/client/src/utils/index.ts @@ -1,29 +1,29 @@ export enum Direction { - Left = 1, - Right = 2, - Up = 3, - Down = 4, + Left = 1, + Right = 2, + Up = 3, + Down = 4, } export function updatePositionWithDirection( - direction: Direction, - value: { vec: { x: number; y: number } } + direction: Direction, + value: { vec: { x: number; y: number } }, ) { - switch (direction) { - case Direction.Left: - value.vec.x--; - break; - case Direction.Right: - value.vec.x++; - break; - case Direction.Up: - value.vec.y--; - break; - case Direction.Down: - value.vec.y++; - break; - default: - throw new Error("Invalid direction provided"); - } - return value; + switch (direction) { + case Direction.Left: + value.vec.x--; + break; + case Direction.Right: + value.vec.x++; + break; + case Direction.Up: + value.vec.y--; + break; + case Direction.Down: + value.vec.y++; + break; + default: + throw new Error("Invalid direction provided"); + } + return value; } diff --git a/client/tsconfig.json b/client/tsconfig.json index 7f1be29..ec12d9d 100644 --- a/client/tsconfig.json +++ b/client/tsconfig.json @@ -1,26 +1,26 @@ { - "compilerOptions": { - "target": "ES2020", - "useDefineForClassFields": true, - "lib": ["ES2020", "DOM", "DOM.Iterable"], - "module": "ESNext", - "skipLibCheck": true, - "moduleResolution": "node", - "allowImportingTsExtensions": true, - "resolveJsonModule": true, - "isolatedModules": true, - "noEmit": true, - "jsx": "react-jsx", - "strict": true, - // "noUnusedLocals": true, - // "noUnusedParameters": true, - "noFallthroughCasesInSwitch": true, - "allowSyntheticDefaultImports": true - }, - "include": ["src", "dojoConfig.ts"], - "references": [ - { - "path": "./tsconfig.node.json" - } - ] + "compilerOptions": { + "target": "ES2020", + "useDefineForClassFields": true, + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "module": "ESNext", + "skipLibCheck": true, + "moduleResolution": "node", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "react-jsx", + "strict": true, + // "noUnusedLocals": true, + // "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, + "allowSyntheticDefaultImports": true + }, + "include": ["src", "dojoConfig.ts"], + "references": [ + { + "path": "./tsconfig.node.json" + } + ] } diff --git a/client/tsconfig.node.json b/client/tsconfig.node.json index 26063d8..42872c5 100644 --- a/client/tsconfig.node.json +++ b/client/tsconfig.node.json @@ -1,10 +1,10 @@ { - "compilerOptions": { - "composite": true, - "skipLibCheck": true, - "module": "ESNext", - "moduleResolution": "bundler", - "allowSyntheticDefaultImports": true - }, - "include": ["vite.config.ts"] + "compilerOptions": { + "composite": true, + "skipLibCheck": true, + "module": "ESNext", + "moduleResolution": "bundler", + "allowSyntheticDefaultImports": true + }, + "include": ["vite.config.ts"] } diff --git a/client/vite.config.ts b/client/vite.config.ts index a77004f..1643bf6 100644 --- a/client/vite.config.ts +++ b/client/vite.config.ts @@ -5,5 +5,5 @@ import topLevelAwait from "vite-plugin-top-level-await"; // https://vitejs.dev/config/ export default defineConfig({ - plugins: [react(), wasm(), topLevelAwait()], + plugins: [react(), wasm(), topLevelAwait()], });