@dojoengine/core
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -15,3 +15,3 @@ import { setComponentFromEntitiesQuery, setComponentFromEvent } from "../utils"; | ||
// call provider.entities for each component to get all entities linked to that component | ||
const entities = await this.provider.entities(component.metadata.name, "0"); | ||
const entities = await this.provider.entities(component.metadata.name, "0", Object.keys(component.schema).length); | ||
setComponentFromEntitiesQuery(component, entities); | ||
@@ -18,0 +18,0 @@ } |
@@ -8,4 +8,4 @@ /// <reference types="node" /> | ||
abstract entity(component: string, query: Query, offset: number, length: number): Promise<Array<bigint>>; | ||
abstract entities(component: string, partition: string): Promise<Array<bigint>>; | ||
abstract entities(component: string, partition: string, length: number): Promise<Array<bigint>>; | ||
getWorldAddress(): string; | ||
} |
@@ -10,5 +10,5 @@ import { RpcProvider, Provider as StarknetProvider, Account, number, InvokeFunctionResponse } from "starknet"; | ||
entity(component: string, query: Query, offset?: number, length?: number): Promise<Array<bigint>>; | ||
entities(component: string, partition: string): Promise<Array<bigint>>; | ||
entities(component: string, partition: string, length: number): Promise<Array<bigint>>; | ||
component(name: string): Promise<bigint>; | ||
execute(account: Account, system: string, call_data: number.BigNumberish[]): Promise<InvokeFunctionResponse>; | ||
} |
@@ -48,7 +48,7 @@ import { RpcProvider, Provider as StarknetProvider } from "starknet"; | ||
} | ||
async entities(component, partition) { | ||
async entities(component, partition, length) { | ||
const call = { | ||
entrypoint: WorldEntryPoints.entities, | ||
contractAddress: this.getWorldAddress(), | ||
calldata: [strTofelt252Felt(component), partition] | ||
calldata: [strTofelt252Felt(component), partition, length] | ||
}; | ||
@@ -55,0 +55,0 @@ console.log(call); |
@@ -18,3 +18,3 @@ export declare enum WorldEntryPoints { | ||
entity?(component: string, query: Query, offset: number, length: number): Promise<Array<bigint>>; | ||
entities?(component: string, partition: string): Promise<Array<bigint>>; | ||
entities?(component: string, partition: string, length: number): Promise<Array<bigint>>; | ||
execute?(name: bigint, execute_calldata: Array<bigint>): Promise<Array<bigint>>; | ||
@@ -21,0 +21,0 @@ register_component?(class_hash: string): Promise<bigint>; |
import { setComponent } from "@latticexyz/recs"; | ||
import { poseidonHashMany } from 'micro-starknet'; | ||
export function strTofelt252Felt(str) { | ||
@@ -63,3 +64,3 @@ const encoder = new TextEncoder(); | ||
const keysNumber = parseInt(eventData[1]); | ||
let index = 2 + keysNumber; | ||
let index = 2 + keysNumber + 1; | ||
const keys = eventData.slice(2, 2 + keysNumber).map((key) => BigInt(key)); | ||
@@ -66,0 +67,0 @@ // get entityIndex from keys |
{ | ||
"name": "@dojoengine/core", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Dojo engine core providers and types", | ||
@@ -5,0 +5,0 @@ "scripts": { |
33755
857