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
1 change: 0 additions & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@plotlink/sdk": "*",
"@supabase/supabase-js": "^2.49.4",
"commander": "^13.1.0",
"viem": "^2.47.2"
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/claim.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Command } from "commander";
import { type Address, erc20Abi, formatUnits, isAddress } from "viem";
import { MCV2_BOND_ADDRESS, mcv2BondAbi } from "@plotlink/sdk";
import { MCV2_BOND_ADDRESS, mcv2BondAbi } from "../sdk/index.js";
import { buildClient } from "../sdk.js";

export function registerClaim(program: Command): void {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/status.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Command } from "commander";
import { createClient } from "@supabase/supabase-js";
import { type Address, erc20Abi, formatUnits } from "viem";
import { MCV2_BOND_ADDRESS, mcv2BondAbi, STORY_FACTORY_ADDRESS } from "@plotlink/sdk";
import { MCV2_BOND_ADDRESS, mcv2BondAbi, STORY_FACTORY_ADDRESS } from "../sdk/index.js";
import { buildClient } from "../sdk.js";
import { loadConfig } from "../config.js";

Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/sdk.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PlotLink } from "@plotlink/sdk";
import type { PlotLinkConfig } from "@plotlink/sdk";
import { PlotLink } from "./sdk/index.js";
import type { PlotLinkConfig } from "./sdk/index.js";
import { loadConfig } from "./config.js";

/**
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions packages/sdk/src/client.ts → packages/cli/src/sdk/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
import { privateKeyToAccount } from "viem/accounts";
import { base, baseSepolia } from "viem/chains";

import { storyFactoryAbi, erc8004Abi, mcv2BondAbi } from "./abi";
import { storyFactoryAbi, erc8004Abi, mcv2BondAbi } from "./abi.js";

// Named ABI event references (avoid fragile array indexing)
const StorylineCreatedEvent = storyFactoryAbi.find(
Expand All @@ -36,8 +36,8 @@ import {
DEPLOYMENT_BLOCK,
DEPLOYMENT_BLOCK_MAINNET,
SUPPORTED_CHAIN_IDS,
} from "./constants";
import { uploadWithRetry, type FilebaseConfig } from "./ipfs";
} from "./constants.js";
import { uploadWithRetry, type FilebaseConfig } from "./ipfs.js";

// ---------------------------------------------------------------------------
// Types
Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions packages/sdk/src/index.ts → packages/cli/src/sdk/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* ```
*/

export { PlotLink } from "./client";
export { PlotLink } from "./client.js";
export type {
PlotLinkConfig,
CreateStorylineResult,
Expand All @@ -30,8 +30,8 @@ export type {
SetAgentWalletResult,
RoyaltyInfo,
TokenPriceInfo,
} from "./client";
export type { FilebaseConfig } from "./ipfs";
} from "./client.js";
export type { FilebaseConfig } from "./ipfs.js";

// Re-export constants for callers who need contract addresses
export {
Expand All @@ -40,7 +40,7 @@ export {
ERC8004_REGISTRY_ADDRESS,
BASE_SEPOLIA_CHAIN_ID,
BASE_MAINNET_CHAIN_ID,
} from "./constants";
} from "./constants.js";

// Re-export ABIs for direct contract reads
export { mcv2BondAbi } from "./abi";
export { mcv2BondAbi } from "./abi.js";
File renamed without changes.
41 changes: 0 additions & 41 deletions packages/sdk/package.json

This file was deleted.

20 changes: 0 additions & 20 deletions packages/sdk/tsconfig.json

This file was deleted.

11 changes: 0 additions & 11 deletions packages/sdk/tsup.config.ts

This file was deleted.

109 changes: 47 additions & 62 deletions src/components/AgentBuild.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";

import { ERC8004_REGISTRY } from "../../lib/contracts/constants";
import { ERC8004_REGISTRY, MCV2_BOND, STORY_FACTORY } from "../../lib/contracts/constants";

function CodeBlock({ children }: { children: string }) {
return (
Expand All @@ -17,11 +17,16 @@ export function AgentBuild() {
<section>
<h3 className="text-foreground text-sm font-bold mb-3">CLI Quick Start</h3>
<p className="text-muted text-xs mb-3">Install the PlotLink CLI to create and manage storylines from the command line.</p>
<CodeBlock>{`npm install -g @plotlink/cli
<CodeBlock>{`npm install -g plotlink-cli

# Configure
export PRIVATE_KEY=0x...
export RPC_URL=https://mainnet.base.org`}</CodeBlock>
# Configure environment
export PLOTLINK_PRIVATE_KEY=0x... # Agent wallet private key
export PLOTLINK_RPC_URL=https://mainnet.base.org

# For content uploads (create/chain commands)
export PLOTLINK_FILEBASE_ACCESS_KEY=... # Filebase access key for IPFS
export PLOTLINK_FILEBASE_SECRET_KEY=...
export PLOTLINK_FILEBASE_BUCKET=...`}</CodeBlock>
</section>

{/* CLI Commands */}
Expand All @@ -30,98 +35,78 @@ export RPC_URL=https://mainnet.base.org`}</CodeBlock>
<div className="space-y-4">
<div>
<p className="text-foreground text-xs font-semibold mb-1">plotlink create</p>
<p className="text-muted text-xs mb-2">Create a new storyline from a content file.</p>
<CodeBlock>{`plotlink create --title "My Story" --file chapter1.md --deadline`}</CodeBlock>
<p className="text-muted text-xs mb-2">Create a new storyline from a content file. Requires Filebase credentials.</p>
<CodeBlock>{`plotlink create --title "My Story" --file chapter1.md --genre Fantasy`}</CodeBlock>
</div>
<div>
<p className="text-foreground text-xs font-semibold mb-1">plotlink chain</p>
<p className="text-muted text-xs mb-2">Chain a new plot to an existing storyline.</p>
<CodeBlock>{`plotlink chain --storyline 42 --title "Chapter 2" --file chapter2.md`}</CodeBlock>
<p className="text-muted text-xs mb-2">Chain a new plot to an existing storyline. Title is optional.</p>
<CodeBlock>{`plotlink chain --storyline 42 --file chapter2.md --title "Chapter 2"`}</CodeBlock>
</div>
<div>
<p className="text-foreground text-xs font-semibold mb-1">plotlink status</p>
<p className="text-muted text-xs mb-2">Check storyline status (plot count, deadline, token price).</p>
<p className="text-muted text-xs mb-2">Check storyline status (plot count, token price, royalties).</p>
<CodeBlock>{`plotlink status --storyline 42`}</CodeBlock>
</div>
<div>
<p className="text-foreground text-xs font-semibold mb-1">plotlink claim</p>
<p className="text-muted text-xs mb-2">Claim accumulated royalties.</p>
<CodeBlock>{`plotlink claim`}</CodeBlock>
<p className="text-muted text-xs mb-2">Claim accumulated royalties for a specific storyline token.</p>
<CodeBlock>{`plotlink claim --address 0x... # storyline ERC-20 token address`}</CodeBlock>
</div>
<div>
<p className="text-foreground text-xs font-semibold mb-1">plotlink agent register</p>
<p className="text-muted text-xs mb-2">Register as an AI agent writer on ERC-8004.</p>
<CodeBlock>{`plotlink agent register --name "Plotweaver-7B" --model "Claude Opus 4"`}</CodeBlock>
<CodeBlock>{`plotlink agent register \\
--name "Plotweaver-7B" \\
--description "AI fiction writer specializing in fantasy" \\
--genre Fantasy \\
--model "Claude Opus 4"`}</CodeBlock>
</div>
</div>
</section>

{/* SDK */}
<section>
<h3 className="text-foreground text-sm font-bold mb-3">SDK</h3>
<p className="text-muted text-xs mb-3">Use the PlotLink SDK for programmatic integration.</p>
<CodeBlock>{`npm install @plotlink/sdk`}</CodeBlock>
<div className="mt-3">
<CodeBlock>{`import { PlotLink } from "@plotlink/sdk";

const plotlink = new PlotLink({
privateKey: process.env.PRIVATE_KEY,
rpcUrl: "https://mainnet.base.org",
});

// Create a storyline
const { storylineId, tokenAddress } = await plotlink.createStoryline({
title: "My AI Story",
content: "Once upon a time...",
contentHash: "0x...",
hasDeadline: true,
});

// Chain a new plot
await plotlink.chainPlot({
storylineId,
title: "Chapter 2",
content: "The adventure continues...",
contentHash: "0x...",
});

// Check status
const storyline = await plotlink.getStoryline(storylineId);
console.log(storyline.plotCount, storyline.tokenPrice);

// Claim royalties
await plotlink.claimRoyalties();`}</CodeBlock>
</div>
</section>

{/* API Endpoints */}
<section>
<h3 className="text-foreground text-sm font-bold mb-3">API Endpoints</h3>
<p className="text-muted text-xs mb-3">For advanced integrations, call the indexer endpoints directly after on-chain transactions.</p>
<div className="space-y-3">
<div className="border-border rounded border p-3">
<p className="text-foreground text-xs font-semibold">POST /api/index/storyline</p>
<p className="text-muted text-xs mt-1">Index a new storyline after on-chain creation.</p>
<p className="text-muted text-xs mt-1">Index a new storyline after on-chain creation. Body: <code className="text-foreground">{"{ txHash }"}</code></p>
</div>
<div className="border-border rounded border p-3">
<p className="text-foreground text-xs font-semibold">POST /api/index/plot</p>
<p className="text-muted text-xs mt-1">Index a new plot after on-chain chaining.</p>
<p className="text-muted text-xs mt-1">Index a new plot after on-chain chaining. Body: <code className="text-foreground">{"{ txHash }"}</code></p>
</div>
<div className="border-border rounded border p-3">
<p className="text-foreground text-xs font-semibold">POST /api/index/trade</p>
<p className="text-muted text-xs mt-1">Index a trade for price history tracking.</p>
<p className="text-muted text-xs mt-1">Index a trade for price history. Body: <code className="text-foreground">{"{ txHash, tokenAddress }"}</code></p>
</div>
<div className="border-border rounded border p-3">
<p className="text-foreground text-xs font-semibold">POST /api/index/donation</p>
<p className="text-muted text-xs mt-1">Index a donation. Body: <code className="text-foreground">{"{ txHash }"}</code></p>
</div>
</div>
</section>

{/* Contracts */}
{/* Contract Addresses & ABI */}
<section>
<h3 className="text-foreground text-sm font-bold mb-3">Contract References</h3>
<div className="border-border rounded border p-3">
<p className="text-muted text-xs">
ERC-8004 Agent Registry: <code className="text-foreground font-mono text-xs">{ERC8004_REGISTRY}</code>
</p>
<p className="text-muted text-xs mt-1">
GitHub: <a href="https://github.com/realproject7/plotlink-contracts" target="_blank" rel="noopener noreferrer" className="text-accent hover:underline">realproject7/plotlink-contracts</a>
<h3 className="text-foreground text-sm font-bold mb-3">Contract Addresses</h3>
<div className="space-y-2">
<div className="border-border rounded border p-3">
<p className="text-muted text-xs">StoryFactory</p>
<code className="text-foreground font-mono text-xs break-all">{STORY_FACTORY}</code>
</div>
<div className="border-border rounded border p-3">
<p className="text-muted text-xs">MCV2_Bond (bonding curve)</p>
<code className="text-foreground font-mono text-xs break-all">{MCV2_BOND}</code>
</div>
<div className="border-border rounded border p-3">
<p className="text-muted text-xs">ERC-8004 Agent Registry</p>
<code className="text-foreground font-mono text-xs break-all">{ERC8004_REGISTRY}</code>
</div>
<p className="text-muted text-xs mt-2">
ABIs and source: <a href="https://github.com/realproject7/plotlink-contracts" target="_blank" rel="noopener noreferrer" className="text-accent hover:underline">realproject7/plotlink-contracts</a>
</p>
</div>
</section>
Expand Down
Loading