Skip to content

Conversation

@katspaugh
Copy link
Member

Summary

This PR completes Phase 3 by implementing comprehensive non-interactive support for the account create command, the most complex account management command.

Changes

account create - Full Argument Support

  • Add --chain-id <chainId> option to specify chain without interactive selection
  • Add --owners <addresses> option with flexible input formats:
    • Comma-separated addresses: --owners "0x123...,0x456..."
    • JSON array format: --owners '["0x123...","0x456..."]'
    • Automatic validation, checksumming, and duplicate detection
  • Add --threshold <number> option to set signature threshold
    • Validates threshold is between 1 and number of owners
  • Add --name <name> option to set Safe name
  • Add --no-deploy flag to skip deployment prompt in interactive mode
  • Add JSON output mode with --json flag including:
    • Safe details: name, address, EIP-3770 format
    • Chain information: chainId, chainName
    • Configuration: owners, threshold, salt nonce
    • Deployment status

All parameters maintain full backward compatibility - the command works interactively when options are not provided.

Examples

# Fully automated Safe creation with comma-separated owners
safe account create \
  --chain-id 1 \
  --owners "0x742d35Cc6634C0532925a3b844Bc454e4438f44e,0x123..." \
  --threshold 2 \
  --name production-safe \
  --no-deploy \
  --json

# JSON array format for owners
safe account create \
  --chain-id 137 \
  --owners '["0xabc...","0xdef...","0x123..."]' \
  --threshold 2 \
  --name polygon-multisig \
  --json

# Minimal arguments (chain ID only, interactive for rest)
safe account create --chain-id 1

# Fully interactive (no arguments)
safe account create

Test plan

  • Build passes
  • Type check passes
  • Lint passes
  • Manual testing with all argument combinations
  • Test comma-separated and JSON array owner formats
  • Verify threshold validation
  • Test JSON output format
  • Verify error handling with invalid inputs
  • Confirm backward compatibility with interactive mode
  • Test --no-deploy flag behavior

Related

This completes Phase 3 (Account commands) of the non-interactive CLI enhancement plan:

All account management commands now support full non-interactive automation with comprehensive argument support and JSON output modes.

🤖 Generated with Claude Code

Implement comprehensive non-interactive support for Safe account creation:

**account create**
- Add `--chain-id <chainId>` option to specify chain without selection prompt
- Add `--owners <addresses>` option supporting:
  - Comma-separated addresses: `0xabc,0xdef`
  - JSON array format: `["0xabc","0xdef"]`
  - Automatic validation and checksumming
- Add `--threshold <number>` option to set signature threshold
- Add `--name <name>` option to set Safe name
- Add `--no-deploy` flag to skip deployment prompt
- Add JSON output mode with `--json` flag including:
  - Safe details (name, address, EIP-3770 format, chain)
  - Configuration (owners, threshold, salt nonce)
  - Deployment status

All parameters maintain backward compatibility with interactive prompts when not provided.

### Example Usage

```bash
# Fully automated Safe creation
safe account create \
  --chain-id 1 \
  --owners "0x123...,0x456..." \
  --threshold 2 \
  --name production-safe \
  --no-deploy \
  --json

# JSON array format for owners
safe account create \
  --chain-id 137 \
  --owners '["0xabc...","0xdef..."]' \
  --threshold 2 \
  --name polygon-safe \
  --json
```

This completes Phase 3 of the non-interactive CLI enhancement, providing full automation support for all account management commands.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings November 7, 2025 15:24
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds non-interactive mode support to the account create command, enabling programmatic Safe account creation through command-line options. This allows the command to be used in scripts and CI/CD pipelines where user interaction is not possible.

Key changes:

  • Introduced command-line options (--chain-id, --owners, --threshold, --name, --no-deploy) to bypass interactive prompts
  • Added conditional logic to skip interactive prompts when options are provided or when in non-interactive mode (JSON/quiet mode)
  • Implemented JSON output for non-interactive mode using new outputSuccess and outputError helpers with standardized exit codes

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/commands/account/create.ts Refactored createSafe to accept options parameter and support both interactive and non-interactive modes with appropriate conditional logic for prompts, validation, and output formatting
src/cli.ts Added command-line options to the account create command and updated action handler to pass options to createSafe function

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +84 to +88
const parsedOwners = parseOwnersArgument(options.owners)
// Validate and checksum each address
owners = parsedOwners.map((owner) => {
return validator.assertAddressWithChain(owner, chainId, chainsConfig, 'Owner address')
})
Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

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

The parseOwnersArgument function validates addresses using isAddress which doesn't support EIP-3770 format (like eth:0x...). However, the interactive mode (lines 135-137) explicitly supports EIP-3770 format. This creates an inconsistency where users cannot use EIP-3770 format with the --owners option, even though they can in interactive mode. Consider modifying parseOwnersArgument to skip validation and just parse the strings, letting assertAddressWithChain handle validation and EIP-3770 format support on line 87.

Copilot uses AI. Check for mistakes.
Comment on lines 16 to 22
export interface SafeCreateOptions {
chainId?: string
owners?: string
threshold?: string
name?: string
noDeploy?: boolean
}
Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

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

The SafeCreateOptions interface lacks documentation. Consider adding JSDoc comments to describe each option, including:

  • Expected format for chainId
  • Expected format for owners (comma-separated addresses or JSON array)
  • Expected format for threshold (number as string)
  • Purpose of noDeploy flag

This would help API consumers understand how to use the non-interactive mode.

Copilot uses AI. Check for mistakes.
Comment on lines +131 to +134
addingOwners = false
break
}

Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

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

The value assigned to addingOwners here is unused.

Suggested change
addingOwners = false
break
}
break
}

Copilot uses AI. Check for mistakes.

return undefined
},
while (addingOwners) {
Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

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

This use of variable 'addingOwners' always evaluates to true.

Copilot uses AI. Check for mistakes.
Resolved conflict in src/commands/account/create.ts by keeping the full
implementation over the placeholder from PR #30.
@katspaugh katspaugh merged commit fed6301 into main Nov 7, 2025
4 checks passed
@katspaugh katspaugh deleted the feat/account-create-arguments branch November 7, 2025 15:40
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.

2 participants