Skip to content

fix signature output on core create#58

Merged
tonyboylehub merged 4 commits intomainfrom
fix/signature-results
Feb 23, 2026
Merged

fix signature output on core create#58
tonyboylehub merged 4 commits intomainfrom
fix/signature-results

Conversation

@tonyboylehub
Copy link
Contributor

No description provided.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 5, 2026

Summary by CodeRabbit

  • Refactor
    • Asset creation now returns a standardized result containing asset and signature; CLI flows (interactive and file-based) log a formatted signature and Explorer link.
    • Command execution no longer returns creation objects (uses logging for output), and signature handling/display is more consistent across flows.

Walkthrough

Signature string conversion was moved from the CLI command to the asset-creation utility. The CLI command run() now returns void and logs formatted results instead of returning them. The creation utility exports a typed AssetCreationResult and normalizes transaction signatures to strings.

Changes

Cohort / File(s) Summary
Asset Creation Command
src/commands/core/asset/create.ts
Changed run() return type to Promise<void>; removed returning of result values and now logs formatted output; updated formatAssetResult to accept a typed result (`{ asset: PublicKey
Asset Creation Arguments / Result Type
src/lib/core/create/createAssetFromArgs.ts
Added and exported AssetCreationResult interface ({ asset: string; signature: string }); normalized transaction signature extraction and conversion (uses txSignatureToString when needed); updated createAssetFromArgs to return Promise<AssetCreationResult> and populate asset and signature fields accordingly.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • blockiosaurus
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive No pull request description was provided by the author, making it impossible to assess whether it relates to the changeset. Add a pull request description that explains the changes made, the problem being fixed, and why these changes were necessary.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix signature output on core create' directly describes the main change in the changeset: fixing how signatures are handled and output in the asset creation functionality.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/signature-results

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/lib/core/create/createAssetFromArgs.ts (1)

28-33: ⚠️ Potential issue | 🟡 Minor

Handle null and string signature fields from response.

res.transaction.signature can be TransactionSignature | null | string per UmiTransactionResponse, but the cast masks these cases. The code will throw at runtime if the signature is null or a base58 string. Add a guard before conversion.

🛡️ Suggested guard + normalization
-  return {
-    asset: transaction.asset,
-    signature: txSignatureToString(res.transaction.signature as TransactionSignature),
-  }
+  const signature = res.transaction.signature
+  if (!signature) {
+    throw new Error('Missing transaction signature in confirmation response')
+  }
+  const signatureString =
+    typeof signature === 'string'
+      ? signature
+      : txSignatureToString(signature as TransactionSignature)
+
+  return {
+    asset: transaction.asset,
+    signature: signatureString,
+  }
src/commands/core/asset/create.ts (1)

218-287: ⚠️ Potential issue | 🟠 Major

Use Promise<unknown> return type and this.log to preserve oclif's JSON output handling.

TransactionCommand enables JSON output (enableJsonFlag = true), and switching to console.log with Promise<void> bypasses oclif's output serialization. This breaks --json flag support and removes structured output needed by tests and CI. Other transaction commands in the same directory (e.g., burn.ts) correctly use Promise<unknown> and return results.

🔧 Suggested fix
-  public async run(): Promise<void> {
+  public async run(): Promise<unknown> {

Replace all three instances of console.log(this.formatAssetResult(result, explorer)) with:

-      console.log(this.formatAssetResult(result, explorer))
+      this.log(this.formatAssetResult(result, explorer))
+      return result
🤖 Fix all issues with AI agents
In `@src/commands/core/asset/create.ts`:
- Around line 209-214: formatAssetResult currently types its parameter as any
which hides the contract that result.asset and result.signature are strings;
replace the any with a concrete type (either derive the return type from
createAssetFromArgs or introduce a small interface like AssetCreationResult with
asset: string and signature: string) and update the function signature to use
that type so TypeScript enforces that result.signature is a string when calling
generateExplorerUrl; ensure any other callers of formatAssetResult are updated
if needed.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Fix all issues with AI agents
In `@src/commands/core/asset/create.ts`:
- Line 256: Replace direct console output with OCLIF's logger: change all calls
using console.log(this.formatAssetResult(result, explorer)) to
this.log(this.formatAssetResult(result, explorer)) (and any other console.log
usages in this file related to asset creation). Locate the calls around the
asset creation flow that invoke formatAssetResult and ensure they use this.log
so output flags (e.g., --json), test stdout capture, and redirection are
respected.
- Line 6: Remove PublicKey from the import list on the top-of-file import that
currently reads "import { generateSigner, PublicKey, Umi } ..." and update the
formatAssetResult function signature to use the imported AssetCreationResult
type instead of its inline type; ensure you import AssetCreationResult (from its
module) if not already present so formatAssetResult references
AssetCreationResult and the unused PublicKey import can be deleted.

In `@src/lib/core/create/createAssetFromArgs.ts`:
- Around line 8-11: The AssetCreationResult type declares asset as a string but
the function createAssetFromArgs doesn't have an explicit return type and
returns transaction.asset which is likely a PublicKey; update the contract by
either (A) changing AssetCreationResult.asset to the actual type (e.g.,
PublicKey) and add an explicit return annotation on createAssetFromArgs to :
Promise<AssetCreationResult> (import the PublicKey type where needed), or (B)
convert transaction.asset to a string with .toString() before returning and keep
AssetCreationResult.asset as string, and annotate createAssetFromArgs' return
type accordingly so TypeScript enforces the shape. Ensure you reference
transaction.asset in the fix and adjust the consumer types (e.g., in create.ts)
to match the chosen representation.
- Line 37: res.transaction.signature is being cast to TransactionSignature
without null-checking before passing to txSignatureToString; update the
createAssetFromArgs logic so you explicitly handle the possible types
(TransactionSignature | null | string) returned by umiSendAndConfirmTransaction:
check res.transaction.signature for null and throw or return a clear error if
null, or if it can be a string pass it directly to txSignatureToString (or
extend txSignatureToString to accept the union), and replace the unsafe cast on
res.transaction.signature with a safe branch that ensures a non-null
TransactionSignature is provided to txSignatureToString.

@MarkSackerberg
Copy link
Contributor

are you planning to address the code rabbit stuff? At least some of them seem to make sense.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (5)
src/commands/core/asset/create.ts (3)

209-216: formatAssetResult correctly typed — LGTM.

result: AssetCreationResult replaces the prior any, enforcing that both result.asset and result.signature are strings. generateExplorerUrl receives a string as expected.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/commands/core/asset/create.ts` around lines 209 - 216, No change
required: formatAssetResult already uses the correctly typed parameter
AssetCreationResult and constructs the string using result.asset and
result.signature; leave the formatAssetResult(result: AssetCreationResult,
explorer: ExplorerType) implementation as-is and ensure generateExplorerUrl is
called with the signature string as shown.

218-288: run() correctly returns void and uses this.log throughout — LGTM.

All three code paths (wizard, file-based, and direct flags) now use this.log, resolving the previously flagged console.log issue. Promise<void> correctly reflects that results are surfaced via side effects.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/commands/core/asset/create.ts` around lines 218 - 288, The run() method
correctly returns Promise<void> and consistently uses this.log instead of
console.log across all branches (wizard, file-based, direct flags), so no code
changes are needed; leave the run() signature as Promise<void>, keep the
this.log usages, and ensure functions referenced (createAndUploadMetadata,
createAssetPrompt, handleFileBasedCreation, createAssetFromArgs,
formatAssetResult, getPluginData, generateSigner) remain unchanged.

8-8: Import correctly updated — LGTM.

AssetCreationResult is imported from the utility, and the now-unnecessary PublicKey import was removed.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/commands/core/asset/create.ts` at line 8, The import was correctly
updated in create.ts: ensure the old PublicKey import is fully removed and
AssetCreationResult remains imported from createAssetFromArgs (check the import
statement referencing createAssetFromArgs and the AssetCreationResult type); no
further changes required besides confirming there are no other unused PublicKey
imports in this module or related modules used by createAssetFromArgs.
src/lib/core/create/createAssetFromArgs.ts (2)

35-38: Null guard for signature — LGTM.

The explicit null check and descriptive error message correctly address the previously flagged missing guard before passing to txSignatureToString.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/lib/core/create/createAssetFromArgs.ts` around lines 35 - 38, The null
check for res.transaction.signature is correct but ensure callers use the
non-null value: keep the explicit guard in createAssetFromArgs (the signature
constant and the if (signature === null) throw ...) before passing the value to
txSignatureToString; this ensures txSignatureToString is only called with a
non-null signature and preserves the descriptive error message "Transaction
signature is null — transaction may not have been confirmed".

8-11: Addressed prior type-safety concerns — LGTM.

The explicit Promise<AssetCreationResult> annotation on the function (line 22) and .toString() call on line 41 resolve the previously flagged PublicKey/string mismatch.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/lib/core/create/createAssetFromArgs.ts` around lines 8 - 11, The review
shows the type-safety issue for AssetCreationResult has been resolved (keep the
exported interface AssetCreationResult, the explicit
Promise<AssetCreationResult> return on createAssetFromArgs, and the .toString()
conversion), but there’s a duplicated review marker; remove the duplicate
review/comment token ([duplicate_comment] or redundant approval note) from the
PR metadata/comments so only a single approval remains while leaving the code
symbols AssetCreationResult, createAssetFromArgs, and the .toString() usage
unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/lib/core/create/createAssetFromArgs.ts`:
- Line 41: In createAssetFromArgs, don't silently default transaction.asset to
an empty string; instead detect a missing/falsy transaction.asset and throw a
descriptive Error (e.g., "Missing transaction.asset") so callers (and
formatAssetResult) don't receive an empty asset value; update the object
construction that currently uses transaction.asset ?
transaction.asset.toString() : '' to validate transaction.asset first, call
transaction.asset.toString() when present, and throw when it's absent.

---

Duplicate comments:
In `@src/commands/core/asset/create.ts`:
- Around line 209-216: No change required: formatAssetResult already uses the
correctly typed parameter AssetCreationResult and constructs the string using
result.asset and result.signature; leave the formatAssetResult(result:
AssetCreationResult, explorer: ExplorerType) implementation as-is and ensure
generateExplorerUrl is called with the signature string as shown.
- Around line 218-288: The run() method correctly returns Promise<void> and
consistently uses this.log instead of console.log across all branches (wizard,
file-based, direct flags), so no code changes are needed; leave the run()
signature as Promise<void>, keep the this.log usages, and ensure functions
referenced (createAndUploadMetadata, createAssetPrompt, handleFileBasedCreation,
createAssetFromArgs, formatAssetResult, getPluginData, generateSigner) remain
unchanged.
- Line 8: The import was correctly updated in create.ts: ensure the old
PublicKey import is fully removed and AssetCreationResult remains imported from
createAssetFromArgs (check the import statement referencing createAssetFromArgs
and the AssetCreationResult type); no further changes required besides
confirming there are no other unused PublicKey imports in this module or related
modules used by createAssetFromArgs.

In `@src/lib/core/create/createAssetFromArgs.ts`:
- Around line 35-38: The null check for res.transaction.signature is correct but
ensure callers use the non-null value: keep the explicit guard in
createAssetFromArgs (the signature constant and the if (signature === null)
throw ...) before passing the value to txSignatureToString; this ensures
txSignatureToString is only called with a non-null signature and preserves the
descriptive error message "Transaction signature is null — transaction may not
have been confirmed".
- Around line 8-11: The review shows the type-safety issue for
AssetCreationResult has been resolved (keep the exported interface
AssetCreationResult, the explicit Promise<AssetCreationResult> return on
createAssetFromArgs, and the .toString() conversion), but there’s a duplicated
review marker; remove the duplicate review/comment token ([duplicate_comment] or
redundant approval note) from the PR metadata/comments so only a single approval
remains while leaving the code symbols AssetCreationResult, createAssetFromArgs,
and the .toString() usage unchanged.

ℹ️ Review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 86fa73f and d7d0c13.

📒 Files selected for processing (2)
  • src/commands/core/asset/create.ts
  • src/lib/core/create/createAssetFromArgs.ts

@tonyboylehub tonyboylehub merged commit a83d7e9 into main Feb 23, 2026
3 checks passed
@tonyboylehub tonyboylehub deleted the fix/signature-results branch February 23, 2026 14:16
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