-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #286 from dojoengine/feat/readme
feat: new readme
- Loading branch information
Showing
19 changed files
with
658 additions
and
381 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { useDojoStore } from "./App"; | ||
import { Schema } from "./bindings"; | ||
|
||
/** | ||
* Custom hook to retrieve a specific model for a given entityId within a specified namespace. | ||
* | ||
* @param entityId - The ID of the entity. | ||
* @param model - The model to retrieve, specified as a string in the format "namespace-modelName". | ||
* @returns The model structure if found, otherwise undefined. | ||
*/ | ||
function useModel<N extends keyof Schema, M extends keyof Schema[N] & string>( | ||
entityId: string, | ||
model: `${N}-${M}` | ||
): Schema[N][M] | undefined { | ||
const [namespace, modelName] = model.split("-") as [N, M]; | ||
|
||
// Select only the specific model data for the given entityId | ||
const modelData = useDojoStore( | ||
(state) => | ||
state.entities[entityId]?.models?.[namespace]?.[modelName] as | ||
| Schema[N][M] | ||
| undefined | ||
); | ||
|
||
return modelData; | ||
} | ||
|
||
export default useModel; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { BurnerManager } from "./burnerManager"; | ||
export { PredeployedManager } from "./predeployedManager"; | ||
export { prefundAccount } from "./prefundAccount"; | ||
export { setupBurnerManager } from "./setupBurnerManager"; |
4 changes: 2 additions & 2 deletions
4
...xample-vite-react-sdk/src/setupBurner.tsx → ...-burner/src/manager/setupBurnerManager.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.