Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

Add support for paymaster creation from presets (C7E-778)

This PR implements support for paymaster creation and updates from preset configurations in the slot CLI.

Changes

  • Added preset and chain_id parameters to the paymaster creation command
  • Created a new module for loading preset configurations from the CDN
  • Added a new update subcommand for updating existing paymasters based on preset changes
  • Implemented policy filtering to apply only policies that have isPaymastered set to true

Testing

  • All tests are passing
  • Linting checks completed successfully

Link to Devin run

https://app.devin.ai/sessions/279a17ce9b564b0ab92151ffd639fa4c

Requested by: Tarrence van As ([email protected])

@devin-ai-integration
Copy link
Contributor Author

Original prompt from Tarrence:

Hey Devin,

I need your help implementing support for paymaster creation from presets in the slot CLI (ticket C7E-778). The slot CLI currently supports CRUD operations for configuring paymasters, and we want to enhance it to pull configurations from our presets repository.

## Your Task

Update the slot CLI implementation to create and configure paymasters using project preset configurations. Specifically:

1. Update the paymaster creation command to accept a preset name and chain ID
2. Implement loading preset configurations from our CDN
3. Add support for updating existing paymasters based on preset changes
4. Apply only policies that have `isPaymaster` set to true

## Implementation Details

### 1. Update Command Arguments

Modify `cli/src/command/paymaster/create.rs` to add preset and chain_id parameters:

```rust
#[derive(Debug, Args)]
#[command(next_help_heading = "Create paymaster options")]
pub struct CreateArgs {
    #[arg(long, help = "Name for the new paymaster.")]
    name: String,
    #[arg(long, help = "Team name to associate the paymaster with.")]
    team: String,
    #[arg(long, help = "Initial budget for the paymaster (in wei).")]
    budget: BigInt,
    #[arg(long, help = "Preset name to use for configuring the paymaster (e.g., 'dopewars').")]
    preset: Option<String>,
    #[arg(long, help = "Chain ID to use for the preset policies.")]
    chain_id: Option<String>,
}

2. Implement Preset Loading

Create a new module for loading preset configurations from the CDN. Port the relevant functionality from the presets repository's TypeScript implementation (see src/config-loader.ts in the presets repo).

The CDN URL for blob-arena is: https://static.cartridge.gg/presets/blob-arena/config.json

3. Add Update Functionality

Add a new subcommand to cli/src/command/paymaster/mod.rs for updating an existing paymaster based on a preset:

#[derive(Subcommand, Debug)]
enum PaymasterSubcommand {
    // Existing subcommands...
    
    #[command(about = "Update paymaster configuration from a preset.")]
    Update(UpdateArgs),
}

Define the appropriate UpdateArgs struct with fields for paymaster ID, preset name, and chain ID.

4. Process Preset Policies

When creating or updating a paymaster:

  1. Load the preset configuration for the specified chain ID
  2. Extract policies where isPaymaster is set to true
  3. Format them for the appropriate GraphQL mutation
  4. Apply them to the paymaster

The default behavior should be to not apply policies unless they have isPaymaster explicitly set to true.

Files to Modify

  • cli/src/command/paymaster/create.rs - Add preset & chain_id arguments
  • cli/src/command/paymaster/mod.rs - Add update subcommand
  • Create a new file for preset loading logic

Important Considerations

  • Handle network and loading failures gracefully
  • Consider how to reconcile existing policies during updates
  • The CDN URL should be configurable or at least documented in the code

Please create a PR with these changes and include the linear ticket ID, C7E-778, in the PR description.

Let me know if you have any questions!

@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

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.

0 participants