Skip to content
Merged
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
36 changes: 30 additions & 6 deletions packages/cli/src/commands/status.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Command } from "commander";
import { createClient } from "@supabase/supabase-js";
import { type Address, formatUnits } from "viem";
import { type Address, erc20Abi, formatUnits } from "viem";

Check warning on line 3 in packages/cli/src/commands/status.ts

View workflow job for this annotation

GitHub Actions / lint-and-typecheck

'Address' is defined but never used
import { buildClient } from "../sdk.js";
import { loadConfig } from "../config.js";

Expand Down Expand Up @@ -49,12 +49,36 @@
}

// -----------------------------------------------------------------
// 3. On-chain token price (MCV2_Bond)
// 3. Reserve token metadata (symbol + decimals)
// -----------------------------------------------------------------
let tokenSymbol = "TOKEN";
let tokenDecimals = 18;
try {
const [sym, dec] = await Promise.all([
client.publicClient.readContract({
address: info.tokenAddress,
abi: erc20Abi,
functionName: "symbol",
}),
client.publicClient.readContract({
address: info.tokenAddress,
abi: erc20Abi,
functionName: "decimals",
}),
]);
tokenSymbol = sym;
tokenDecimals = dec;
} catch {
// Fall back to defaults if token doesn't support ERC-20 metadata
}

// -----------------------------------------------------------------
// 4. On-chain token price (MCV2_Bond)
// -----------------------------------------------------------------
const tokenPrice = await client.getTokenPrice(info.tokenAddress);

// -----------------------------------------------------------------
// 4. On-chain royalty info
// 5. On-chain royalty info
// -----------------------------------------------------------------
let unclaimedRoyalty: bigint | null = null;
try {
Expand All @@ -65,7 +89,7 @@
}

// -----------------------------------------------------------------
// 5. Fall back to event-derived plot count if no Supabase
// 6. Fall back to event-derived plot count if no Supabase
// -----------------------------------------------------------------
let plotCount: number;
if (dbRow) {
Expand Down Expand Up @@ -119,11 +143,11 @@
}

if (tokenPrice) {
console.log(`Token price: ${tokenPrice.priceFormatted} ETH`);
console.log(`Token price: ${tokenPrice.priceFormatted} ${tokenSymbol}`);
}

if (unclaimedRoyalty !== null && unclaimedRoyalty > 0n) {
console.log(`Unclaimed royalty: ${formatUnits(unclaimedRoyalty, 18)} ETH`);
console.log(`Unclaimed royalty: ${formatUnits(unclaimedRoyalty, tokenDecimals)} ${tokenSymbol}`);
}
} catch (err) {
console.error(`Error: ${err instanceof Error ? err.message : String(err)}`);
Expand Down
Loading