magicblock-labs / bolt

High-performance, Composable framework for Fully On Chain Games and Autonomous Worlds
https://book.boltengine.gg
MIT License
31 stars 7 forks source link

feat: Add CLI commands to create registry/world #79

Open iamnamananand996 opened 1 month ago

iamnamananand996 commented 1 month ago
Status Type ⚠️ Core Change Issue
Hold Feature No Link

Problem

So that the frontend/clients don't need to worry about a world/registry being created, we could have CLI that allows developer to pre-deploy a registry/world in its cluster of choice

Solution

bolt world "seed" command could return an usable world PDA that is initialized on the current cluster

cc - @crypto-vincent

iamnamananand996 commented 1 month ago

Hi @crypto-vincent,

for World PDA, I have just add the initializationfrom program template, do we need expand it more and make it workable or just boilerplate like this is enough.

fn create_world_template_simple(name: &str, program_path: &Path) -> Files {
    vec![(
        program_path.join("src").join("lib.rs"),
        format!(
            r#"use anchor_lang::prelude::*;

declare_id!("{}");

#[program]
pub mod {} {{
    use super::*;

    pub fn initialize(ctx: Context<Initialize>) -> Result<()> {{
        Ok(())
    }}
}}

#[derive(Accounts)]
pub struct Initialize {{}}
"#,
            get_or_create_program_id(name),
            name.to_snake_case(),
        ),
    )]
}
iamnamananand996 commented 1 week ago

Hi @GabrielePicco, this PR is sitting here from very long time, if you can have look and see what is the actual expectations and add some suggestions.

That will be very helpful for me to proceed further.

GabrielePicco commented 3 days ago

Hey @iamnamananand996, the commands to create registry/world don't create a new component/system or template, but rather they should execute transction. Namely it would be the equivalent of running https://github.com/magicblock-labs/bolt/blob/main/tests/bolt.ts#L111 from Rust

iamnamananand996 commented 3 days ago

Hi @GabrielePicco, thank you for your valuable suggestion, and guided to correct path, will update the PR with correct changes