Skip to content

Fixes/initial fixes #29

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Changelog

All notable changes to this project will be documented in this file.

## [UNRELEASED]

### Fixed
- Wallet path handling in `config wallets set` and `config wallets add` commands
- Added path normalization to store absolute paths instead of relative paths
- Added validation to check if wallet file exists before setting it
- Fixed issue where changing directories would cause "missing wallet file" errors
- Improved error messages for better user feedback

### Changed
- Updated wallet path storage to use absolute paths consistently
- Enhanced error handling in wallet configuration commands
- Improved command index pages with better descriptions and examples
- Added detailed descriptions for core commands (asset, collection, plugins)
- Enhanced examples with more use cases and options
- Improved help text formatting and organization
- Added subcommand descriptions and available options

## [0.0.6]

- Initial public beta release
17 changes: 10 additions & 7 deletions src/commands/config/wallets/add.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Args, Command } from '@oclif/core'
import fs from 'fs'
import { dirname } from 'path'
import { dirname, resolve } from 'path'
import { createSignerFromPath, getDefaultConfigPath, readConfig } from '../../../lib/Context.js'
import { ensureDirectoryExists, writeJsonSync } from '../../../lib/file.js'
import { shortenAddress } from '../../../lib/util.js'
Expand Down Expand Up @@ -41,16 +41,19 @@ export default class ConfigWalletAddsCommand extends Command {
this.error('Path must be a json file')
}

// check if the file exists on intial add
if (!fs.existsSync(args.path)) {
// Normalize the path to be absolute
const normalizedPath = resolve(args.path)

// check if the file exists on initial add
if (!fs.existsSync(normalizedPath)) {
this.error('File does not exist')
}

const path = flags.config ?? getDefaultConfigPath()

const config = readConfig(path)

const signer = await createSignerFromPath(args.path)
const signer = await createSignerFromPath(normalizedPath)

if (!config.wallets) {
config.wallets = []
Expand All @@ -60,9 +63,9 @@ export default class ConfigWalletAddsCommand extends Command {
this.error(`Wallet with name ${args.name} already exists`)
}

const existingPath = config.wallets.find((wallet) => wallet.path === args.path)
const existingPath = config.wallets.find((wallet) => wallet.path === normalizedPath)
if (existingPath) {
this.error(`Wallet with path ${args.path} already exists`)
this.error(`Wallet with path ${normalizedPath} already exists`)
}

const existingAddress = config.wallets.find((wallet) => wallet.address === signer.publicKey.toString())
Expand All @@ -74,7 +77,7 @@ export default class ConfigWalletAddsCommand extends Command {
config.wallets?.push({
name: args.name,
address: signer.publicKey,
path: args.path,
path: normalizedPath,
})

const dir = dirname(path)
Expand Down
6 changes: 3 additions & 3 deletions src/commands/config/wallets/new.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { generateSigner } from '@metaplex-foundation/umi'
import { Flags } from '@oclif/core'
import fs from 'node:fs'
import { dirname, join, normalize } from 'node:path'
import { dirname, normalize, resolve } from 'node:path'
import { BaseCommand } from '../../../BaseCommand.js'
import { getDefaultConfigPath, readConfig } from '../../../lib/Context.js'
import { ensureDirectoryExists, writeJsonSync } from '../../../lib/file.js'
Expand Down Expand Up @@ -71,7 +71,7 @@ export default class ConfigWalletsNew extends BaseCommand<typeof ConfigWalletsNe
: `${wallet.publicKey}.json`

// Save wallet file
const filePath = join(savePath, fileName)
const filePath = resolve(savePath, fileName)
writeJsonSync(filePath, walletData)
console.log(`Wallet saved to: ${filePath}`)

Expand Down Expand Up @@ -104,7 +104,7 @@ export default class ConfigWalletsNew extends BaseCommand<typeof ConfigWalletsNe

const newWallet = {
name: flags.name,
path: filePath,
path: filePath.replace(/\\/g, '\\\\'), // Escape backslashes for JSON
address: wallet.publicKey.toString(),
}

Expand Down
15 changes: 12 additions & 3 deletions src/commands/config/wallets/set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import {getDefaultConfigPath, readConfig} from '../../../lib/Context.js'
import walletSelectorPrompt from '../../../prompts/walletSelectPrompt.js'
import {shortenAddress} from './../../../lib/util.js'

import {dirname} from 'path'
import {dirname, resolve} from 'path'
import {ensureDirectoryExists, writeJsonSync} from '../../../lib/file.js'
import fs from 'fs'

export default class ConfigWalletSetCommand extends Command {
static override description = 'Set a new active wallet from a list of wallets'

public async run(): Promise<void> {

const {flags, args} = await this.parse(ConfigWalletSetCommand)

const path = flags.config ?? getDefaultConfigPath()
Expand All @@ -28,7 +28,16 @@ export default class ConfigWalletSetCommand extends Command {
publicKey: wallet.address
})))

config.keypair = selectedWallet.path
// Normalize the path to be absolute
const normalizedPath = resolve(selectedWallet.path)

// Validate the file exists
if (!fs.existsSync(normalizedPath)) {
this.error(`Wallet file not found at: ${normalizedPath}`)
return
}

config.keypair = normalizedPath

const dir = dirname(path)
ensureDirectoryExists(dir)
Expand Down
29 changes: 24 additions & 5 deletions src/commands/core/asset/index.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,37 @@
import { Command } from '@oclif/core'
import { Command, Flags } from '@oclif/core'

export default class CoreAsset extends Command {
static override description = 'MPL Core Asset Module'
static override description = `MPL Core Asset Management - Create, update, burn, and fetch digital assets

The asset commands provide functionality for managing individual digital assets on the Solana blockchain using the Metaplex Core protocol.

Available subcommands:
create - Create new assets (with wizard, direct input, or file upload)
update - Update asset metadata (name, URI, image)
burn - Burn assets (single or batch)
fetch - Fetch asset data and metadata`

static override examples = [
'<%= config.bin %> <%= command.id %>',
'$ mplx core asset create --wizard',
'$ mplx core asset create --name "My NFT" --uri "https://example.com/metadata.json"',
'$ mplx core asset create --files --image "./my-nft.png" --json "./metadata.json"',
'$ mplx core asset update <assetId> --name "Updated Name" --uri "https://example.com/new-metadata.json"',
'$ mplx core asset burn <assetId>',
'$ mplx core asset fetch <assetId> --download',
]

static override flags = {

help: Flags.help({char: 'h'}),
}

public async run(): Promise<void> {
const {args, flags} = await this.parse(CoreAsset)


// Show help by default
this.log(CoreAsset.description)
this.log('\nExamples:')
CoreAsset.examples.forEach(example => {
this.log(` ${example}`)
})
}
}
25 changes: 21 additions & 4 deletions src/commands/core/collection/index.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,35 @@
import {Args, Command, Flags} from '@oclif/core'
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Drop unused Args import.

-import {Args, Command, Flags} from '@oclif/core'
+import {Command, Flags} from '@oclif/core'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import {Args, Command, Flags} from '@oclif/core'
import {Command, Flags} from '@oclif/core'
🤖 Prompt for AI Agents
In src/commands/core/collection/index.ts at line 1, the imported `Args` from
'@oclif/core' is not used anywhere in the file. Remove `Args` from the import
statement to clean up unused imports and improve code clarity.


export default class CoreCollection extends Command {
static override description = 'MPL Core Collection Module'
static override description = `MPL Core Collection Management - Create and manage collections of digital assets

The collection commands provide functionality for managing groups of digital assets on the Solana blockchain using the Metaplex Core protocol.

Available subcommands:
create - Create new collections (with wizard, direct input, or file upload)
fetch - Fetch collection data and metadata
template - Generate template files for collection metadata and image`

static override examples = [
'<%= config.bin %> <%= command.id %>',
'$ mplx core collection create --wizard',
'$ mplx core collection create --name "My Collection" --uri "https://example.com/metadata.json"',
'$ mplx core collection create --files --image "./my-collection.png" --json "./metadata.json"',
'$ mplx core collection fetch <collectionId>',
'$ mplx core collection template',
]

static override flags = {

help: Flags.help({char: 'h'}),
}

public async run(): Promise<void> {
const {args, flags} = await this.parse(CoreCollection)


// Show help by default
this.log(CoreCollection.description)
this.log('\nExamples:')
CoreCollection.examples.forEach(example => {
this.log(` ${example}`)
})
}
}
23 changes: 19 additions & 4 deletions src/commands/core/index.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
import {Args, Command, Flags} from '@oclif/core'
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Remove unused Args import.

-import {Args, Command, Flags} from '@oclif/core'
+import {Command, Flags} from '@oclif/core'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import {Args, Command, Flags} from '@oclif/core'
import {Command, Flags} from '@oclif/core'
🤖 Prompt for AI Agents
In src/commands/core/index.ts at line 1, the imported `Args` from '@oclif/core'
is not used anywhere in the file. Remove `Args` from the import statement to
clean up unused imports and improve code clarity.


export default class Core extends Command {
static override description = 'MPL Core Program'
static override description = `MPL Core Program - Manage digital assets, collections, and plugins on Solana

The core commands provide functionality for managing Metaplex Core assets, collections, and plugins. These commands allow you to create, modify, and manage digital assets on the Solana blockchain using the Metaplex Core protocol.

Available subcommands:
asset - Manage individual digital assets (create, update, burn, fetch)
collection - Manage collections of assets (create, fetch)
plugins - Manage asset and collection plugins (add, remove, generate)`

static override examples = [
'<%= config.bin %> <%= command.id %>',
'$ mplx core asset create --name "My NFT" --uri "https://example.com/metadata.json"',
'$ mplx core collection create --name "My Collection" --uri "https://example.com/collection.json"',
'$ mplx core plugins add <assetId> --wizard',
]

static override flags = {

help: Flags.help({char: 'h'}),
}

public async run(): Promise<void> {
const {args, flags} = await this.parse(Core)


// Show help by default
this.log(Core.description)
this.log('\nExamples:')
Core.examples.forEach(example => {
this.log(` ${example}`)
})
}
}
49 changes: 44 additions & 5 deletions src/commands/core/plugins/index.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,58 @@
import { Command } from '@oclif/core'
import { Command, Flags } from '@oclif/core'
import { BaseCommand } from '../../../BaseCommand.js'

export default class CorePlugins extends BaseCommand<typeof CorePlugins> {
static override description = 'MPL Core Plugins Module'
static override description = `MPL Core Plugin Management - Add and manage plugins for assets and collections

The plugin commands provide functionality for managing plugins that extend the capabilities of assets and collections on the Solana blockchain.

Available subcommands:
add - Add plugins to assets or collections (with wizard or JSON config)
remove - Remove plugins from assets or collections
generate - Generate reusable plugin configuration files for scripting

Available Plugin Types:
Common Plugins (Asset & Collection):
- Attributes
- Royalties
- Update Delegate
- Permanent Freeze
- Permanent Transfer
- Permanent Burn
- Add Blocker
- Immutable Metadata
- Autograph
- Verified Creators

Collection-specific Plugins:
- Master Edition

Asset-specific Plugins:
- Edition
- Freeze Delegate
- Burn Delegate
- Transfer Delegate`
Comment on lines +5 to +34
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Trim leading indentation in the multi-line description string

The template literal captures all the leading spaces that appear in the source file, so the CLI prints each line indented by two spaces. This makes the help text look slightly “shifted” compared with oclif’s built-in help for other commands.

A low-impact tweak is to strip the indentation at build time so the output is perfectly left-aligned:

-  static override description = `MPL Core Plugin Management - Add and manage plugins for assets and collections
-  ...
-    - Transfer Delegate`
+  static override description = [
+    'MPL Core Plugin Management - Add and manage plugins for assets and collections',
+    '',
+    'The plugin commands provide functionality for managing plugins that extend the capabilities of assets and collections on the Solana blockchain.',
+    '',
+    'Available subcommands:',
+    '  add      - Add plugins to assets or collections (with wizard or JSON config)',
+    '  remove   - Remove plugins from assets or collections',
+    '  generate - Generate reusable plugin configuration files for scripting',
+    '',
+    'Available Plugin Types:',
+    '  Common Plugins (Asset & Collection):',
+    '    - Attributes',
+    '    - Royalties',
+    '    - Update Delegate',
+    '    - Permanent Freeze',
+    '    - Permanent Transfer',
+    '    - Permanent Burn',
+    '    - Add Blocker',
+    '    - Immutable Metadata',
+    '    - Autograph',
+    '    - Verified Creators',
+    '',
+    '  Collection-specific Plugins:',
+    '    - Master Edition',
+    '',
+    '  Asset-specific Plugins:',
+    '    - Edition',
+    '    - Freeze Delegate',
+    '    - Burn Delegate',
+    '    - Transfer Delegate',
+  ].join('\n')

Any string-dedent helper (e.g. common-tagsstripIndent) would achieve the same effect with less boilerplate.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
static override description = `MPL Core Plugin Management - Add and manage plugins for assets and collections
The plugin commands provide functionality for managing plugins that extend the capabilities of assets and collections on the Solana blockchain.
Available subcommands:
add - Add plugins to assets or collections (with wizard or JSON config)
remove - Remove plugins from assets or collections
generate - Generate reusable plugin configuration files for scripting
Available Plugin Types:
Common Plugins (Asset & Collection):
- Attributes
- Royalties
- Update Delegate
- Permanent Freeze
- Permanent Transfer
- Permanent Burn
- Add Blocker
- Immutable Metadata
- Autograph
- Verified Creators
Collection-specific Plugins:
- Master Edition
Asset-specific Plugins:
- Edition
- Freeze Delegate
- Burn Delegate
- Transfer Delegate`
static override description = [
'MPL Core Plugin Management - Add and manage plugins for assets and collections',
'',
'The plugin commands provide functionality for managing plugins that extend the capabilities of assets and collections on the Solana blockchain.',
'',
'Available subcommands:',
' add - Add plugins to assets or collections (with wizard or JSON config)',
' remove - Remove plugins from assets or collections',
' generate - Generate reusable plugin configuration files for scripting',
'',
'Available Plugin Types:',
' Common Plugins (Asset & Collection):',
' - Attributes',
' - Royalties',
' - Update Delegate',
' - Permanent Freeze',
' - Permanent Transfer',
' - Permanent Burn',
' - Add Blocker',
' - Immutable Metadata',
' - Autograph',
' - Verified Creators',
'',
' Collection-specific Plugins:',
' - Master Edition',
'',
' Asset-specific Plugins:',
' - Edition',
' - Freeze Delegate',
' - Burn Delegate',
' - Transfer Delegate',
].join('\n')
🤖 Prompt for AI Agents
In src/commands/core/plugins/index.ts between lines 5 and 34, the multi-line
description string includes leading spaces causing the CLI help text to be
indented and misaligned. To fix this, remove the leading indentation from each
line of the template literal so the output is left-aligned. You can do this by
using a string dedent helper like common-tags' stripIndent or manually trimming
the indentation in the string definition.


static override examples = [
'<%= config.bin %> <%= command.id %>',
'$ mplx core plugins add <assetId> --wizard',
'$ mplx core plugins add <assetId> ./plugin.json',
'$ mplx core plugins generate --asset',
'$ mplx core plugins generate --collection',

]

static override flags = {

help: Flags.help({char: 'h'}),
}

public async run(): Promise<void> {
const {args, flags} = await this.parse(CorePlugins)


// Show help by default
this.log(CorePlugins.description)
this.log('\nExamples:')
CorePlugins.examples.forEach(example => {
this.log(` ${example}`)
})
}
Comment on lines 49 to 57
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Drop unused destructuring from parse call

The command neither reads args nor flags, so the destructured variables are unused (and may trigger lint warnings).
You can keep the call—it validates input—while avoiding the unused bindings:

-    const {args, flags} = await this.parse(CorePlugins)
+    await this.parse(CorePlugins) // validate CLI input

Optional: you can replace the custom logging with this._help(), letting oclif format the description & examples consistently across commands.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const {args, flags} = await this.parse(CorePlugins)
// Show help by default
this.log(CorePlugins.description)
this.log('\nExamples:')
CorePlugins.examples.forEach(example => {
this.log(` ${example}`)
})
}
await this.parse(CorePlugins) // validate CLI input
// Show help by default
this.log(CorePlugins.description)
this.log('\nExamples:')
CorePlugins.examples.forEach(example => {
this.log(` ${example}`)
})
}
🤖 Prompt for AI Agents
In src/commands/core/plugins/index.ts around lines 49 to 57, the destructured
variables 'args' and 'flags' from the parse call are unused and may cause lint
warnings. To fix this, remove the destructuring and just await the parse call
without assigning its result. Optionally, replace the manual logging of
description and examples with a call to this._help() to leverage oclif's
consistent help formatting.

}
30 changes: 27 additions & 3 deletions src/commands/toolbox/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,34 @@
import {Args, Command, Flags} from '@oclif/core'

export default class Core extends Command {
export default class Toolbox extends Command {
static override description = `Solana Ecosystem Tools - Utility commands for common Solana operations

static override description = 'Various tools for the Solana ecosystem'
The toolbox commands provide utility functions for common Solana blockchain operations, including SOL management and token operations.

public async run(): Promise<void> {
Available subcommands:
sol - SOL management tools (balance, transfer, airdrop)
token - Token management tools (create, update, transfer)
rent - Calculate rent costs for on-chain data storage`

static override examples = [
'$ mplx toolbox sol balance',
'$ mplx toolbox sol transfer 1 <recipient_address>',
'$ mplx toolbox token create --wizard',
'$ mplx toolbox rent 1000',
]

static override flags = {
help: Flags.help({char: 'h'}),
}

public async run(): Promise<void> {
const {args, flags} = await this.parse(Toolbox)

// Show help by default
this.log(Toolbox.description)
this.log('\nExamples:')
Toolbox.examples.forEach(example => {
this.log(` ${example}`)
})
}
Comment on lines +24 to 33
Copy link
Contributor

@coderabbitai coderabbitai bot Jun 13, 2025

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Delegate to oclif’s built-in help instead of hand-rolling output.

this._help() prints the description, examples, and the flag list consistently with oclif’s styling.
Manually logging and duplicating that logic risks drifting out of sync and leaves args / flags unused.

-  public async run(): Promise<void> {
-    const {args, flags} = await this.parse(Toolbox)
-    
-    // Show help by default
-    this.log(Toolbox.description)
-    this.log('\nExamples:')
-    Toolbox.examples.forEach(example => {
-      this.log(`  ${example}`)
-    })
-  }
+  public async run(): Promise<void> {
+    await this.parse(Toolbox) // still ensures validation
+    return this._help()
+  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public async run(): Promise<void> {
const {args, flags} = await this.parse(Toolbox)
// Show help by default
this.log(Toolbox.description)
this.log('\nExamples:')
Toolbox.examples.forEach(example => {
this.log(` ${example}`)
})
}
public async run(): Promise<void> {
await this.parse(Toolbox) // still ensures validation
return this._help()
}
🤖 Prompt for AI Agents
In src/commands/toolbox/index.ts around lines 24 to 33, the run method manually
logs the description and examples instead of using oclif's built-in help system.
Replace the manual logging with a call to this._help() to delegate output to
oclif's consistent help formatter, ensuring description, examples, and flags are
displayed correctly and args/flags are properly utilized.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this._help() doesn't exist

Copy link
Contributor

Choose a reason for hiding this comment

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

@tonyboylehub thanks for the heads-up. Let me double-check what helper methods are actually exposed by the version of @oclif/core we’re using – the private _help() I suggested is available in oclif v3 but may not be present (or exposed) in the older v2 that this project pins to.

I’ll grep the local node_modules/@oclif/core copy and confirm the right public helper (e.g. this.help(), this.showHelp(), or fallback to this.config.runHook('command_help', …)), then circle back with an updated snippet.

}
Loading