Skip to content
Merged
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
7 changes: 6 additions & 1 deletion packages/cli/src/commands/agent-register.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Command } from "commander";
import type { Address } from "viem";
import { isAddress } from "viem";
import { buildClient } from "../sdk.js";

export function registerAgentRegister(program: Command): void {
Expand All @@ -26,9 +27,13 @@ export function registerAgentRegister(program: Command): void {
skipWallet?: boolean;
}) => {
try {
// Resolve wallet key from env BEFORE spending gas on registration
// Validate wallet address and key BEFORE spending gas on registration
let walletKey: string | undefined;
if (opts.wallet && !opts.skipWallet) {
if (!isAddress(opts.wallet)) {
console.error(`Invalid address: ${opts.wallet}`);
process.exit(1);
}
walletKey = process.env.PLOTLINK_AGENT_WALLET_KEY;
if (!walletKey) {
console.error(
Expand Down
5 changes: 5 additions & 0 deletions packages/cli/src/commands/claim.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Command } from "commander";
import type { Address } from "viem";
import { isAddress } from "viem";
import { buildClient } from "../sdk.js";

export function registerClaim(program: Command): void {
Expand All @@ -9,6 +10,10 @@ export function registerClaim(program: Command): void {
.requiredOption("-a, --address <tokenAddress>", "Storyline ERC-20 token address")
.action(async (opts: { address: string }) => {
try {
if (!isAddress(opts.address)) {
console.error(`Invalid address: ${opts.address}`);
process.exit(1);
}
const tokenAddress = opts.address as Address;
const client = buildClient({ ipfs: false });

Expand Down
Loading