Skip to content
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

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

Conversation

iamnamananand996
Copy link
Contributor

@iamnamananand996 iamnamananand996 commented Aug 25, 2024

Status Type ⚠️ Core Change Issue
Ready Feature Yes #64

Problem

  • Frontend/clients don't need to worry about a world/registry being created.
  • Need CLI that allows developer to pre-deploy a registry/world in its cluster of choice.

See #64 for a full description

Solution

Examples using the Bolt CLI

Create registry on current cluster

bolt registry

Create world on current cluster

bolt world

Closes #64

@iamnamananand996 iamnamananand996 marked this pull request as draft August 25, 2024 13:23
@iamnamananand996
Copy link
Contributor Author

Hi @crypto-vincent,

for World PDA, I have just add the initialization from 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 iamnamananand996 force-pushed the add-CLI-commands-to-create-registry/world branch from f2ff9ed to dde4639 Compare August 27, 2024 12:14
@iamnamananand996 iamnamananand996 force-pushed the add-CLI-commands-to-create-registry/world branch from dde4639 to 21c09e2 Compare September 15, 2024 22:02
@iamnamananand996
Copy link
Contributor Author

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.

@iamnamananand996 iamnamananand996 marked this pull request as ready for review September 27, 2024 12:03
@GabrielePicco
Copy link
Contributor

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
Copy link
Contributor Author

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

@GabrielePicco
Copy link
Contributor

Thanks @iamnamananand996 . authorize is an example of a command that runs a transaction

@iamnamananand996 iamnamananand996 force-pushed the add-CLI-commands-to-create-registry/world branch from 5dd52b6 to c113fa8 Compare October 6, 2024 09:52
@iamnamananand996
Copy link
Contributor Author

Thanks @iamnamananand996 . authorize is an example of a command that runs a transaction

Hi @GabrielePicco, this comment had really helped.

Now the changes has been updated with the requested solution.
I have done some changes to world program also, so I think, It will require re-deploy of world program.

Please have a look, and let me know if you think it will require any further change. Happy to contribute more

@iamnamananand996 iamnamananand996 changed the title feat: Add CLI commands to create registry/world feat: ✨ Add CLI commands to create registry/world Oct 12, 2024
@GabrielePicco
Copy link
Contributor

Hey @iamnamananand996,
I don’t understand how the extra_seed is useful in the context of a registry (there should only be one) or a world instance. What was the rationale behind adding it?

@iamnamananand996
Copy link
Contributor Author

Hi @GabrielePicco, thanks for asking, I had an assumption that, from CLI app, user can create multiple registry and under those registry they can create world.

If I have understood the flow wrong, please help me to understand the correct flow, I will make the changes accordingly.

@GabrielePicco
Copy link
Contributor

Thanks for clarifying, @iamnamananand996. The idea is that there is currently a single registry (and I would keep it that way) so that everyone can discover all the existing world instances. Infinite world instances can already be created, so I don't think we need an extra registry in either of the two cases.

@iamnamananand996
Copy link
Contributor Author

iamnamananand996 commented Oct 16, 2024

Hi @GabrielePicco, thanks for answering and make me understand the flow, I will make the changes accordingly.

@iamnamananand996 iamnamananand996 force-pushed the add-CLI-commands-to-create-registry/world branch from c537893 to a1474f0 Compare October 16, 2024 16:49
@iamnamananand996
Copy link
Contributor Author

iamnamananand996 commented Oct 17, 2024

Hi @GabrielePicco, I have update the PR with the flow required and updated the example command.

Examples using the Bolt CLI

Create registry on current cluster

bolt registry

Create world on current cluster

bolt world

This is ready for review now.

Copy link
Contributor

@GabrielePicco GabrielePicco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @iamnamananand996, LGTM!

@GabrielePicco GabrielePicco merged commit fe3a235 into magicblock-labs:main Oct 18, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add CLI commands to create registry/world
2 participants