-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[discuss] Codegen world interface #82
Comments
This functionality would be really awesome. As I am developing with the Dojo stack, I find myself wanting something like this more and more and I actually searched if this was already there for a bit - it makes a lot of sense to have this for developers. |
great! Yes, this will be the next big feature - I would suggest to just copy this structure into your project for now. |
Totally agree, after doing almost the same boilerplate for 3 games. Auto-gen with TypeScript would be awesome and definitely would speed up the dev process! |
I like this, the more abstraction the better |
Ohayo, this would be a great feature indeed for lots of projets. Though for Eternum, we mostly use multi calls which would not be possible to automatically generate. |
Rethought this a bit. We should avoid classes and be purely functional. Have been experimenting with interfaces and new structure in the react-app on the PR - #99 Have arrived at something like this which provides a typed interface and avoids strange class inheritence. export async function setupWorld(provider: DojoProvider) {
function actions() {
const contract_name = "actions";
const spawn = async ({ account }: { account: Account }) => {
try {
return await provider.execute(
account,
contract_name,
"spawn",
[]
);
} catch (error) {
console.error("Error executing spawn:", error);
throw error;
}
};
const move = async ({
account,
direction,
}: {
account: Account;
direction: Direction;
}) => {
try {
return await provider.execute(account, contract_name, "move", [
direction,
]);
} catch (error) {
console.error("Error executing move:", error);
throw error;
}
};
return { spawn, move };
}
return {
actions: actions(),
};
} |
Looks clean! I frequently wonder if I should return anything from system calls when I need to do something when it is finished. What I end up doing is returning nothing, and listening to any component that should be updated after the system call |
We are adding Katana long polling into this, which will allow fo this. What we really need is to know if it hits Torii and then reflect in the client. |
We want to minimize boilerplate writing as much as possible while also improving type safety and completion for the best possible developer experience.
One way we can achieve this is by generating a World Class based on the manifest.json, which builds a typed interface for all potential endpoints into the world.
Ideally, the end goal is something like this:
This would execute the
Play
system contract and theCreate
function.We could achieve this by generating classes like:
(Slayer is the World Name)
Since worlds will contain many contracts we need to nest the classes to avoid potential clashes.
This file could be generated by simply:
Looking for feedback on this.
@tarrencev @broody @JunichiSugiura @rsodre @Matth26 @aymericdelab
The text was updated successfully, but these errors were encountered: