Skip to content

Commit 8c35a34

Browse files
authored
feat(1209): nft implementation review changes (#1215)
Signed-off-by: rozekmichal <michal.rozek@blockydevs.com>
1 parent 531f250 commit 8c35a34

File tree

5 files changed

+49
-14
lines changed

5 files changed

+49
-14
lines changed

src/plugins/token/commands/create-nft/output.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ export type CreateNftOutput = z.infer<typeof CreateNftOutputSchema>;
3838
* Human-readable template for create token output
3939
*/
4040
export const CREATE_NFT_TEMPLATE = `
41-
✅ NFT created successfully: {{tokenId}}
41+
✅ NFT created successfully: {{hashscanLink tokenId "token" network}}
4242
Name: {{name}} ({{symbol}})
43-
Treasury: {{treasuryId}}
43+
Treasury: {{hashscanLink treasuryId "account" network}}
4444
Supply Type: {{supplyType}}
45-
Admin account: {{adminAccountId}}
46-
Supply account: {{supplyAccountId}}
45+
Admin account: {{hashscanLink adminAccountId "account" network}}
46+
Supply account: {{hashscanLink supplyAccountId "account" network}}
4747
{{#if alias}}
4848
Alias: {{alias}}
4949
{{/if}}
5050
Network: {{network}}
51-
Transaction ID: {{transactionId}}
51+
Transaction ID: {{hashscanLink transactionId "transaction" network}}
5252
`.trim();

src/plugins/token/commands/list/output.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export const LIST_TOKENS_TEMPLATE = `
108108
Supply Type: {{supplyType}}
109109
Decimals: {{decimals}}
110110
Network: {{network}}
111-
{{#if maxSupply}}
111+
{{#if (eq supplyType "FINITE")}}
112112
Max Supply: {{maxSupply}}
113113
{{/if}}
114114
{{#if (gt associationCount 0)}}

src/plugins/token/commands/view/handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export async function viewToken(
6565
}
6666

6767
// 3. Build output based on mode
68-
const output: ViewTokenOutput = buildOutput(tokenInfo, nftInfo);
68+
const output: ViewTokenOutput = buildOutput(tokenInfo, nftInfo, network);
6969

7070
return {
7171
status: Status.Success,

src/plugins/token/commands/view/output.ts

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
*/
44
import { z } from 'zod';
55

6-
import { EntityIdSchema } from '@/core/schemas/common-schemas';
6+
import {
7+
EntityIdSchema,
8+
NetworkSchema,
9+
PublicKeySchema,
10+
SupplyTypeSchema,
11+
} from '@/core/schemas/common-schemas';
712

813
/**
914
* Token Info Schema
@@ -14,10 +19,12 @@ export const ViewTokenOutputSchema = z.object({
1419
name: z.string(),
1520
symbol: z.string(),
1621
type: z.string(), // 'FUNGIBLE_COMMON' | 'NON_FUNGIBLE_UNIQUE'
22+
network: NetworkSchema,
1723

1824
// === Supply info (crucial for NFT - shows valid serial range) ===
1925
totalSupply: z.string(), // For NFT = current minted count
2026
maxSupply: z.string(),
27+
supplyType: SupplyTypeSchema,
2128

2229
// === Fungible Token specific ===
2330
decimals: z.number().optional(), // NFT doesn't have decimals
@@ -27,6 +34,10 @@ export const ViewTokenOutputSchema = z.object({
2734
memo: z.string().optional(),
2835
createdTimestamp: z.string().optional(),
2936

37+
// === Token keys ===
38+
adminKey: PublicKeySchema.nullable().optional(),
39+
supplyKey: PublicKeySchema.nullable().optional(),
40+
3041
// === Specific NFT instance (when --serial provided) ===
3142
nftSerial: z
3243
.object({
@@ -54,19 +65,21 @@ export const VIEW_TOKEN_TEMPLATE = `
5465
5566
Collection Info:
5667
57-
Token ID: {{tokenId}}
68+
Token ID: {{hashscanLink tokenId "token" network}}
5869
Name: {{name}}
5970
Symbol: {{symbol}}
6071
Total Minted: {{totalSupply}}
72+
{{#if (eq supplyType "FINITE")}}
6173
Max Supply: {{maxSupply}}
74+
{{/if}}
6275
{{#if treasury}}
63-
Treasury: {{treasury}}
76+
Treasury: {{hashscanLink treasury "account" network}}
6477
{{/if}}
6578
6679
NFT Details:
6780
6881
Serial: #{{nftSerial.serialNumber}}
69-
Owner: {{nftSerial.owner}}
82+
Owner: {{hashscanLink nftSerial.owner "account" network}}
7083
{{#if nftSerial.createdTimestamp}}
7184
Created: {{nftSerial.createdTimestamp}}
7285
{{/if~}}
@@ -83,22 +96,32 @@ export const VIEW_TOKEN_TEMPLATE = `
8396
💰 Fungible Token
8497
{{/if}}
8598
86-
ID: {{tokenId}}
99+
ID: {{hashscanLink tokenId "token" network}}
87100
Name: {{name}}
88101
Symbol: {{symbol}}
89102
90103
{{#if (eq type "NON_FUNGIBLE_UNIQUE")}}
91-
Current Supply: {{totalSupply}}{{#if (gt totalSupply "0")}} (Valid serials: 1 to {{totalSupply}}){{/if}}
104+
Current Supply: {{totalSupply}}
105+
{{#if (eq supplyType "FINITE")}}
92106
Max Supply: {{maxSupply}}
107+
{{/if}}
93108
{{else}}
94109
Total Supply: {{totalSupply}}
110+
{{#if (eq supplyType "FINITE")}}
95111
Max Supply: {{maxSupply}}
112+
{{/if}}
96113
{{#if decimals}}
97114
Decimals: {{decimals}}
98115
{{/if~}}
99116
{{/if~}}
100117
{{#if treasury}}
101-
Treasury: {{treasury}}
118+
Treasury: {{hashscanLink treasury "account" network}}
119+
{{/if~}}
120+
{{#if adminKey}}
121+
Admin Key: {{adminKey}}
122+
{{/if~}}
123+
{{#if supplyKey}}
124+
Supply Key: {{supplyKey}}
102125
{{/if~}}
103126
{{#if memo}}
104127
Memo: {{memo}}

src/plugins/token/utils/nft-build-output.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import type { NftInfo, TokenInfo } from '@/core/services/mirrornode/types';
2+
import type { SupportedNetwork } from '@/core/types/shared.types';
3+
import type { SupplyType } from '@/core/types/token.types';
24
import type { ViewTokenOutput } from '@/plugins/token/commands/view';
35

46
/**
@@ -47,17 +49,27 @@ function formatHederaTimestamp(timestamp?: string): string | undefined {
4749
export function buildOutput(
4850
tokenInfo: TokenInfo,
4951
nftInfo: NftInfo | null,
52+
network: SupportedNetwork,
5053
): ViewTokenOutput {
54+
// Determine supply type based on max_supply
55+
// If max_supply is "0", it's INFINITE, otherwise FINITE
56+
const supplyType: SupplyType =
57+
tokenInfo.max_supply === '0' ? 'INFINITE' : 'FINITE';
58+
5159
const base = {
5260
tokenId: tokenInfo.token_id,
5361
name: tokenInfo.name,
5462
symbol: tokenInfo.symbol,
5563
type: tokenInfo.type,
64+
network,
5665
totalSupply: tokenInfo.total_supply,
5766
maxSupply: tokenInfo.max_supply,
67+
supplyType,
5868
treasury: tokenInfo.treasury || undefined,
5969
memo: tokenInfo.memo || undefined,
6070
createdTimestamp: formatHederaTimestamp(tokenInfo.created_timestamp),
71+
adminKey: tokenInfo.admin_key?.key || null,
72+
supplyKey: tokenInfo.supply_key?.key || null,
6173
};
6274

6375
// Add decimals only for Fungible Tokens

0 commit comments

Comments
 (0)