Skip to content

Commit

Permalink
Merge pull request #305 from dojoengine/feat/bump-17
Browse files Browse the repository at this point in the history
fix: constants
  • Loading branch information
ponderingdemocritus authored Oct 21, 2024
2 parents b96afa3 + 640ec75 commit b5fa315
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
run: git submodule update --init --recursive

- run: curl -L https://install.dojoengine.org | bash
- run: /home/runner/.config/.dojo/bin/dojoup -v v1.0.0-alpha.16
- run: /home/runner/.config/.dojo/bin/dojoup -v v1.0.0-alpha.17
- run: |
cd worlds/dojo-starter
/home/runner/.config/.dojo/bin/sozo build
Expand Down
2 changes: 2 additions & 0 deletions examples/example-vite-react-app-recs/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ function App() {
account,
} = useDojo();

// sync the contract components to the local state
// this fetches the entities from the world and updates the local state
useQuerySync(toriiClient, contractComponents as any, []);

const [clipboardStatus, setClipboardStatus] = useState({
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ export const LOCAL_KATANA = "http://localhost:5050";
export const LOCAL_RELAY = "";
export const LOCAL_TORII = "http://0.0.0.0:8080";
export const KATANA_PREFUNDED_ADDRESS =
"0xb3ff441a68610b30fd5e2abbf3a1548eb6ba6f3559f2862bf2dc757e5828ca";
"0x127fd5f1fe78a71f8bcd1fec63e3fe2f0486b6ecd5c86a0466c3a21fa5cfcec";
export const KATANA_PREFUNDED_PRIVATE_KEY =
"0x2bbf4f9fd0bbb2e60b0316c1fe0b76cf7a4d0198bd493ced9b8df2a3a24d68a";
"0xc5b2fcab997346f3ea1c00b002ecf6f382c5f9c9659a3894eb783c5320f912";
export const KATANA_CLASS_HASH =
"0x05400e90f7e0ae78bd02c77cd75527280470e2fe19c54970dd79dc37a9d3645c";
"0x07dc7899aa655b0aae51eadff6d801a58e97dd99cf4666ee59e704249e51adf2";
export const KATANA_ETH_CONTRACT_ADDRESS =
"0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7";
25 changes: 20 additions & 5 deletions packages/state/src/recs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const getSyncEntities = async <S extends Schema>(
limit: number = 100,
logging: boolean = false
) => {
if (logging) console.log("Starting getSyncEntities");
if (logging) console.log("Starting getSyncEntities ", clause);
await getEntities(client, clause, components, limit, logging);
return await syncEntities(client, components, entityKeyClause, logging);
};
Expand Down Expand Up @@ -126,9 +126,11 @@ export const getEntities = async <S extends Schema>(
limit,
offset,
clause,
dont_include_hashed_keys: true,
dont_include_hashed_keys: false,
});

console.log("entities", entities);

if (logging) console.log(`Fetched ${entities} entities`);

setEntities(entities, components, logging);
Expand Down Expand Up @@ -165,7 +167,7 @@ export const getEvents = async <S extends Schema>(
limit,
offset,
clause,
dont_include_hashed_keys: true,
dont_include_hashed_keys: false,
});

if (logging) console.log("entities", entities);
Expand Down Expand Up @@ -232,14 +234,15 @@ export const getEntitiesQuery = async <S extends Schema>(
limit,
offset: cursor,
clause: clause || undefined,
dont_include_hashed_keys: true,
dont_include_hashed_keys: false,
});

while (continueFetching) {
if (logging)
console.log(
`Fetched ${Object.keys(fetchedEntities).length} entities`
`Fetched ${Object.keys(fetchedEntities).length} entities ${cursor}`
);

setEntities(fetchedEntities, components, logging);

if (Object.keys(fetchedEntities).length < limit) {
Expand Down Expand Up @@ -273,6 +276,7 @@ export const syncEntities = async <S extends Schema>(
entityKeyClause,
(fetchedEntities: any, data: any) => {
if (logging) console.log("Entity updated", fetchedEntities);

setEntities({ [fetchedEntities]: data }, components, logging);
}
);
Expand Down Expand Up @@ -301,6 +305,7 @@ export const syncEvents = async <S extends Schema>(
entityKeyClause,
(fetchedEntities: any, data: any) => {
if (logging) console.log("Event message updated", fetchedEntities);

setEntities({ [fetchedEntities]: data }, components, logging);
}
);
Expand All @@ -317,6 +322,16 @@ export const setEntities = async <S extends Schema>(
components: Component<S, Metadata, undefined>[],
logging: boolean = false
) => {
if (
Object.keys(entities).length === 0 ||
(Object.keys(entities).length === 1 &&
entities["0x0"] &&
Object.keys(entities["0x0"]).length === 0)
) {
console.warn("No entities to set");
return;
}

if (logging) console.log("Entities to set:", entities);

for (let key in entities) {
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ npx @dojoengine/create-dojo start -t example-vite-react-sdk

```bash
cd dojo-starter
sozo build && sozo migrate
sozo build && sozo migrate apply
# Start Torii indexer - world address can be found in the print out of migrate
torii --world <WORLD_ADDRESS> --allowed-origins "*"
Expand Down

0 comments on commit b5fa315

Please sign in to comment.