@cloakely/mcp 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/config.js CHANGED
@@ -4,7 +4,7 @@ import { join } from "node:path";
4
4
  import { defineChain, parseEther, parseUnits } from "viem";
5
5
  import { deploymentFor, elysiumTestnet } from "@cloakely/sdk";
6
6
  const NETWORKS = {
7
- testnet: { chain: elysiumTestnet, launchesFromBlock: 15855986n },
7
+ testnet: { chain: elysiumTestnet },
8
8
  };
9
9
  export function loadSettings(env = process.env) {
10
10
  const network = env.CLOAK_NETWORK ?? (env.CLOAK_DEPLOYMENT_FILE ? "custom" : "testnet");
@@ -23,8 +23,8 @@ export function loadSettings(env = process.env) {
23
23
  const f = JSON.parse(readFileSync(env.CLOAK_DEPLOYMENT_FILE, "utf8"));
24
24
  rpcUrl = f.rpcUrl;
25
25
  chain = defineChain({ id: f.chainId, name: `Cloak custom (${f.chainId})`, nativeCurrency: { name: "HYPE", symbol: "HYPE", decimals: 18 }, rpcUrls: { default: { http: [rpcUrl] } }, testnet: true });
26
- deployment = { ...f, routerBlock: BigInt(f.routerBlock), assets: f.assets?.map((a) => ({ ...a, fromBlock: BigInt(a.fromBlock) })) };
27
26
  launchesFromBlock = BigInt(f.launchesFromBlock ?? 0);
27
+ deployment = { ...f, version: f.version ?? 0, factoryBlock: launchesFromBlock, routerBlock: BigInt(f.routerBlock), assets: f.assets?.map((a) => ({ ...a, fromBlock: BigInt(a.fromBlock) })) };
28
28
  }
29
29
  else {
30
30
  const n = NETWORKS[network];
@@ -32,7 +32,7 @@ export function loadSettings(env = process.env) {
32
32
  throw new Error(`unknown CLOAK_NETWORK "${network}" (use testnet)`);
33
33
  chain = n.chain;
34
34
  deployment = deploymentFor(chain.id);
35
- launchesFromBlock = n.launchesFromBlock;
35
+ launchesFromBlock = deployment.factoryBlock;
36
36
  rpcUrl = chain.rpcUrls.default.http[0];
37
37
  }
38
38
  if (env.CLOAK_RPC_URL)
package/dist/server.d.ts CHANGED
@@ -3,7 +3,7 @@ import { type Prover } from "@cloakely/sdk";
3
3
  import type { Settings } from "./config.js";
4
4
  export { loadSettings, type Settings, type Limits } from "./config.js";
5
5
  export { Spending } from "./limits.js";
6
- export declare const VERSION = "0.1.2";
6
+ export declare const VERSION = "0.2.0";
7
7
  export declare const HOSTED_URL = "https://cloak.boblabs.tech/mcp";
8
8
  /** Turn an SDK or chain error into one plain sentence an agent can act on. */
9
9
  export declare function explain(e: unknown): string;
package/dist/server.js CHANGED
@@ -8,7 +8,7 @@ import { Cloak, CloakPrivate, cloakPairAbi, createProver, loadProver, privateRou
8
8
  import { Spending } from "./limits.js";
9
9
  export { loadSettings } from "./config.js";
10
10
  export { Spending } from "./limits.js";
11
- export const VERSION = "0.1.2";
11
+ export const VERSION = "0.2.0";
12
12
  export const HOSTED_URL = "https://cloak.boblabs.tech/mcp";
13
13
  const INSTRUCTIONS = `Cloak: sealed-bid token launches and private trading on Kinetiq's Elysium (HYPE is the gas and base currency).
14
14
 
@@ -78,7 +78,12 @@ export function createCloakServer(settings, opts = {}) {
78
78
  });
79
79
  const account = settings.privateKey ? privateKeyToAccount(settings.privateKey) : undefined;
80
80
  const wallet = account ? createWalletClient({ chain: settings.chain, transport: http(settings.rpcUrl), account }) : undefined;
81
- const cloak = new Cloak(pub, wallet, d.factory);
81
+ // earlier deployments' launches still list, settle and pay out
82
+ const cloak = new Cloak(pub, wallet, d.factory, (d.previous ?? []).map((p) => p.factory));
83
+ /** Where to start scanning a launch's bids: the current factory's deploy block, or the start for an older launch. */
84
+ const bidsFrom = async (auction) => (await pub.readContract({ address: auction, abi: [{ type: "function", name: "factory", stateMutability: "view", inputs: [], outputs: [{ type: "address" }] }], functionName: "factory" }).catch(() => zeroAddress)).toLowerCase() === d.factory.toLowerCase()
85
+ ? settings.launchesFromBlock
86
+ : 0n;
82
87
  const spending = account ? new Spending(settings.limits, settings.stateDir, account.address) : undefined;
83
88
  const submit = relayerSubmitter(d.relayerUrl);
84
89
  const explorer = settings.chain.blockExplorers?.default.url;
@@ -467,7 +472,7 @@ export function createCloakServer(settings, opts = {}) {
467
472
  server.registerTool("my_bids", { title: "My bids", description: "The wallet's bids on a launch: deposit, whether each has opened, and once settled the tokens won, refund and any penalty.", inputSchema: { auction: addr }, annotations: READ }, safe(async ({ auction }) => {
468
473
  const { account } = needWallet();
469
474
  const s = await cloak.getAuction(auction);
470
- const bids = await cloak.bidsOf(s.address, account.address, settings.launchesFromBlock);
475
+ const bids = await cloak.bidsOf(s.address, account.address, await bidsFrom(s.address));
471
476
  return {
472
477
  launch: s.tokenSymbol,
473
478
  phase: s.phase,
@@ -479,7 +484,7 @@ export function createCloakServer(settings, opts = {}) {
479
484
  let s = await cloak.getAuction(auction);
480
485
  if (s.phase === "commit" || s.phase === "reveal")
481
486
  throw new Error(`${s.tokenSymbol} can't settle yet: bids are ${s.phase === "commit" ? "still being placed" : "still opening"} until ${iso(s.phase === "commit" ? s.commitEnd : s.revealEnd)}.`);
482
- const bids = await cloak.bidsOf(s.address, account.address, settings.launchesFromBlock);
487
+ const bids = await cloak.bidsOf(s.address, account.address, await bidsFrom(s.address));
483
488
  const open = bids.filter((b) => !b.claimed);
484
489
  if (isDry(dry_run))
485
490
  return { dryRun: true, wouldSettle: !s.settled, wouldClaim: open.map((b) => b.id) };
@@ -491,7 +496,7 @@ export function createCloakServer(settings, opts = {}) {
491
496
  }
492
497
  if (open.length)
493
498
  txs.push(link(await cloak.claim(s.address, open.map((b) => b.id))));
494
- const after = await cloak.bidsOf(s.address, account.address, settings.launchesFromBlock);
499
+ const after = await cloak.bidsOf(s.address, account.address, await bidsFrom(s.address));
495
500
  return {
496
501
  launch: s.tokenSymbol,
497
502
  settled: s.settled,
@@ -510,13 +515,17 @@ export function createCloakServer(settings, opts = {}) {
510
515
  throw new Error(`${s.tokenSymbol} needs to settle successfully first (phase: ${s.phase}).`);
511
516
  if (await privateTradingOn(s.token))
512
517
  return { alreadyOn: true, token: s.token };
513
- const idx = (await cloak.listLaunches()).findIndex((l) => l.auction.toLowerCase() === s.address.toLowerCase());
518
+ const all = await cloak.listLaunches();
519
+ const idx = all.findIndex((l) => l.auction.toLowerCase() === s.address.toLowerCase());
514
520
  if (idx < 0)
515
- throw new Error("This launch isn't from the current Cloak factory, so it can't get a private vault.");
521
+ throw new Error("This launch isn't from a Cloak factory, so it can't get a private vault.");
522
+ // earlier deployments' launches go through the router's list of earlier factories, in the order they're listed
523
+ const legacy = !!all[idx].legacy;
524
+ const index = BigInt(legacy ? idx - all.filter((l) => !l.legacy).length : idx);
516
525
  if (isDry(dry_run))
517
- return { dryRun: true, wouldEnable: s.tokenSymbol, launchIndex: idx };
526
+ return { dryRun: true, wouldEnable: s.tokenSymbol, launchIndex: index, earlierDeployment: legacy };
518
527
  return exclusive(async () => {
519
- const h = await wallet.writeContract({ address: d.router, abi: privateRouterAbi, functionName: "createPool", args: [BigInt(idx)] });
528
+ const h = await wallet.writeContract({ address: d.router, abi: privateRouterAbi, functionName: legacy ? "createLegacyPool" : "createPool", args: [index] });
520
529
  await receipt(h);
521
530
  return { enabled: true, token: s.token, vault: await pub.readContract({ address: d.router, abi: privateRouterAbi, functionName: "poolOf", args: [s.token] }), tx: link(h) };
522
531
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloakely/mcp",
3
3
  "mcpName": "io.github.NECOKIZZ/cloak",
4
- "version": "0.1.2",
4
+ "version": "0.2.0",
5
5
  "description": "Cloak's MCP server: let an AI agent launch tokens with sealed bids and trade them privately on Elysium, with spending limits, testnet by default and a local signer.",
6
6
  "keywords": [
7
7
  "mcp",
@@ -47,7 +47,7 @@
47
47
  "@modelcontextprotocol/sdk": "1.32.1",
48
48
  "viem": "2.21.54",
49
49
  "zod": "4.6.7",
50
- "@cloakely/sdk": "^0.2.6"
50
+ "@cloakely/sdk": "^0.3.0"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/node": "22.10.2",