moltlaunch 2.7.4 → 2.8.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/index.js CHANGED
@@ -1796,15 +1796,21 @@ import { formatEther as formatEther3, parseAbi } from "viem";
1796
1796
  import { createPublicClient as createPublicClient3, createWalletClient as createWalletClient3, http as http3 } from "viem";
1797
1797
  import { base as base3 } from "viem/chains";
1798
1798
  import { privateKeyToAccount as privateKeyToAccount4 } from "viem/accounts";
1799
- var REVENUE_MANAGER_ABI = parseAbi([
1800
- "function balances(address _recipient) view returns (uint256 balance_)",
1801
- "function tokens(address _creator) view returns ((address flaunch, uint256 tokenId)[])",
1802
- "function claim() returns (uint256 amount_)",
1803
- "function claim((address flaunch, uint256 tokenId)[] _flaunchToken) returns (uint256 amount_)"
1799
+ import { FlaunchSDK } from "@flaunch/sdk";
1800
+ import { ViemReadAdapter, ViemReadWriteAdapter } from "@delvtech/drift-viem";
1801
+ import { createDrift } from "@delvtech/drift";
1802
+ var RM_EXTRA_ABI = parseAbi([
1803
+ "function protocolRecipient() view returns (address)",
1804
+ "function creatorTotalClaimed(address _creator) view returns (uint256 _claimed)"
1804
1805
  ]);
1805
1806
  async function fees(options) {
1806
1807
  const { wallet: wallet2 } = await loadOrCreateWallet();
1807
1808
  const publicClient = createPublicClient3({ chain: base3, transport: http3(BASE_RPC_URL) });
1809
+ const readAdapter = new ViemReadAdapter({ publicClient });
1810
+ const readDrift = createDrift({ adapter: readAdapter });
1811
+ const { ReadFlaunchSDK } = FlaunchSDK;
1812
+ const sdk = new ReadFlaunchSDK(base3.id, readDrift);
1813
+ const rmAddress = REVENUE_MANAGER_ADDRESS;
1808
1814
  if (!options.json) {
1809
1815
  console.log("\nFlaunch Trading Fees");
1810
1816
  console.log("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\n");
@@ -1815,62 +1821,113 @@ async function fees(options) {
1815
1821
  agentId = await getAgentByOwner(wallet2.address);
1816
1822
  } catch {
1817
1823
  }
1818
- const creatorTokens = await publicClient.readContract({
1819
- address: REVENUE_MANAGER_ADDRESS,
1820
- abi: REVENUE_MANAGER_ABI,
1821
- functionName: "tokens",
1822
- args: [wallet2.address]
1824
+ const protocolRecipient = await publicClient.readContract({
1825
+ address: rmAddress,
1826
+ abi: RM_EXTRA_ABI,
1827
+ functionName: "protocolRecipient"
1823
1828
  });
1824
- const pulledBalance = await publicClient.readContract({
1825
- address: REVENUE_MANAGER_ADDRESS,
1826
- abi: REVENUE_MANAGER_ABI,
1827
- functionName: "balances",
1828
- args: [wallet2.address]
1829
- });
1830
- let claimableAmount = pulledBalance;
1831
- if (creatorTokens.length > 0) {
1832
- try {
1833
- const { result } = await publicClient.simulateContract({
1834
- address: REVENUE_MANAGER_ADDRESS,
1835
- abi: REVENUE_MANAGER_ABI,
1836
- functionName: "claim",
1837
- args: [creatorTokens],
1838
- account: wallet2.address
1839
- });
1840
- claimableAmount = result;
1841
- } catch {
1829
+ const isAdmin = protocolRecipient.toLowerCase() === wallet2.address.toLowerCase();
1830
+ if (isAdmin) {
1831
+ const protocolBalance = await sdk.revenueManagerProtocolBalance(rmAddress);
1832
+ const claimableEth2 = formatEther3(protocolBalance);
1833
+ if (!options.claim) {
1834
+ if (options.json) {
1835
+ console.log(JSON.stringify({
1836
+ wallet: wallet2.address,
1837
+ role: "protocolAdmin",
1838
+ revenueManager: rmAddress,
1839
+ claimable: { wei: protocolBalance.toString(), eth: claimableEth2 }
1840
+ }));
1841
+ return;
1842
+ }
1843
+ console.log(`Wallet: ${wallet2.address}`);
1844
+ console.log(`Role: Protocol Admin`);
1845
+ console.log(`Revenue Manager: ${rmAddress}`);
1846
+ console.log("");
1847
+ console.log("Protocol Fees");
1848
+ console.log("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");
1849
+ console.log(` Claimable: ${claimableEth2} ETH`);
1850
+ console.log("");
1851
+ if (protocolBalance === 0n) {
1852
+ console.log("No protocol fees to claim yet.");
1853
+ } else {
1854
+ console.log("Run with --claim to withdraw protocol fees.");
1855
+ }
1856
+ return;
1857
+ }
1858
+ if (protocolBalance === 0n) {
1859
+ if (options.json) {
1860
+ console.log(JSON.stringify({ error: "No protocol fees to claim" }));
1861
+ process.exit(1);
1862
+ }
1863
+ console.log("No protocol fees to claim yet.");
1864
+ return;
1865
+ }
1866
+ if (!options.json) {
1867
+ console.log(`Claiming protocol fees...`);
1868
+ console.log(`Expected: ~${claimableEth2} ETH
1869
+ `);
1870
+ }
1871
+ const account2 = privateKeyToAccount4(wallet2.privateKey);
1872
+ const walletClient2 = createWalletClient3({ account: account2, chain: base3, transport: http3(BASE_RPC_URL) });
1873
+ const writeAdapter2 = new ViemReadWriteAdapter({ publicClient, walletClient: walletClient2 });
1874
+ const writeDrift2 = createDrift({ adapter: writeAdapter2 });
1875
+ const { ReadWriteFlaunchSDK: ReadWriteFlaunchSDK2 } = FlaunchSDK;
1876
+ const writeSdk2 = new ReadWriteFlaunchSDK2(base3.id, writeDrift2);
1877
+ const txHash2 = await writeSdk2.revenueManagerProtocolClaim({ revenueManagerAddress: rmAddress });
1878
+ await publicClient.waitForTransactionReceipt({ hash: txHash2 });
1879
+ if (options.json) {
1880
+ console.log(JSON.stringify({ success: true, role: "protocolAdmin", claimed: claimableEth2, txHash: txHash2 }));
1881
+ return;
1842
1882
  }
1883
+ console.log("\u2705 Protocol fees claimed!");
1884
+ console.log("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");
1885
+ console.log(` Claimed: ~${claimableEth2} ETH`);
1886
+ console.log(` TX: ${txHash2}`);
1887
+ console.log("");
1888
+ return;
1843
1889
  }
1844
- const claimableEth = formatEther3(claimableAmount);
1890
+ const [balance, tokens, totalClaimed] = await Promise.all([
1891
+ sdk.revenueManagerBalance({ revenueManagerAddress: rmAddress, recipient: wallet2.address }),
1892
+ sdk.revenueManagerAllTokensByCreator({ revenueManagerAddress: rmAddress, creator: wallet2.address }),
1893
+ publicClient.readContract({ address: rmAddress, abi: RM_EXTRA_ABI, functionName: "creatorTotalClaimed", args: [wallet2.address] }).catch(() => 0n)
1894
+ ]);
1895
+ const claimableEth = formatEther3(balance);
1845
1896
  if (!options.claim) {
1846
1897
  if (options.json) {
1847
1898
  console.log(JSON.stringify({
1848
1899
  wallet: wallet2.address,
1849
1900
  ...agentId ? { agentId: agentId.toString() } : {},
1850
- revenueManager: REVENUE_MANAGER_ADDRESS,
1851
- tokens: creatorTokens.length,
1852
- pendingFees: { wei: claimableAmount.toString(), eth: claimableEth }
1901
+ revenueManager: rmAddress,
1902
+ tokens: tokens.length,
1903
+ claimable: { wei: balance.toString(), eth: claimableEth },
1904
+ ...totalClaimed > 0n ? { totalClaimed: { wei: totalClaimed.toString(), eth: formatEther3(totalClaimed) } } : {}
1853
1905
  }));
1854
1906
  return;
1855
1907
  }
1856
1908
  console.log(`Wallet: ${wallet2.address}`);
1857
1909
  if (agentId) console.log(`Agent ID: ${agentId.toString()}`);
1858
- console.log(`Revenue Manager: ${REVENUE_MANAGER_ADDRESS}`);
1859
- console.log(`Tokens managed: ${creatorTokens.length}`);
1910
+ console.log(`Revenue Manager: ${rmAddress}`);
1911
+ console.log(`Tokens managed: ${tokens.length}`);
1860
1912
  console.log("");
1861
- console.log(`Pending fees: ${claimableEth} ETH`);
1913
+ console.log("Creator Fees");
1914
+ console.log("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");
1915
+ console.log(` Claimable: ${claimableEth} ETH`);
1916
+ if (totalClaimed > 0n) {
1917
+ console.log(` Total claimed: ${formatEther3(totalClaimed)} ETH`);
1918
+ }
1862
1919
  console.log("");
1863
- if (creatorTokens.length === 0) {
1920
+ if (tokens.length === 0) {
1864
1921
  console.log("No tokens found for this wallet in the Revenue Manager.");
1865
1922
  console.log("Fees accumulate from token trading activity after registration.");
1866
- } else if (claimableAmount === 0n) {
1923
+ } else if (balance === 0n) {
1867
1924
  console.log("No fees to claim yet. Fees accumulate from token trading activity.");
1868
1925
  } else {
1869
1926
  console.log("Run with --claim to withdraw fees to your wallet.");
1870
1927
  }
1871
1928
  return;
1872
1929
  }
1873
- if (creatorTokens.length === 0) {
1930
+ if (tokens.length === 0) {
1874
1931
  if (options.json) {
1875
1932
  console.log(JSON.stringify({ error: "No tokens found for this wallet" }));
1876
1933
  process.exit(1);
@@ -1878,34 +1935,36 @@ async function fees(options) {
1878
1935
  console.log("No tokens found for this wallet in the Revenue Manager.");
1879
1936
  return;
1880
1937
  }
1938
+ if (balance === 0n) {
1939
+ if (options.json) {
1940
+ console.log(JSON.stringify({ error: "No fees to claim" }));
1941
+ process.exit(1);
1942
+ }
1943
+ console.log("No fees to claim yet.");
1944
+ return;
1945
+ }
1881
1946
  if (!options.json) {
1882
- console.log(`Claiming fees for ${creatorTokens.length} token(s)...`);
1947
+ console.log(`Claiming creator fees for ${tokens.length} token(s)...`);
1948
+ console.log(`Expected: ~${claimableEth} ETH
1949
+ `);
1883
1950
  }
1884
1951
  const account = privateKeyToAccount4(wallet2.privateKey);
1885
- const walletClient = createWalletClient3({
1886
- account,
1887
- chain: base3,
1888
- transport: http3(BASE_RPC_URL)
1889
- });
1890
- const txHash = await walletClient.writeContract({
1891
- address: REVENUE_MANAGER_ADDRESS,
1892
- abi: REVENUE_MANAGER_ABI,
1893
- functionName: "claim",
1894
- args: [creatorTokens]
1895
- });
1952
+ const walletClient = createWalletClient3({ account, chain: base3, transport: http3(BASE_RPC_URL) });
1953
+ const writeAdapter = new ViemReadWriteAdapter({ publicClient, walletClient });
1954
+ const writeDrift = createDrift({ adapter: writeAdapter });
1955
+ const { ReadWriteFlaunchSDK } = FlaunchSDK;
1956
+ const writeSdk = new ReadWriteFlaunchSDK(base3.id, writeDrift);
1957
+ const txHash = await writeSdk.revenueManagerCreatorClaim({ revenueManagerAddress: rmAddress });
1896
1958
  await publicClient.waitForTransactionReceipt({ hash: txHash });
1897
1959
  if (options.json) {
1898
- console.log(JSON.stringify({
1899
- success: true,
1900
- tokens: creatorTokens.length,
1901
- txHash
1902
- }));
1960
+ console.log(JSON.stringify({ success: true, tokens: tokens.length, claimed: claimableEth, txHash }));
1903
1961
  return;
1904
1962
  }
1905
- console.log("\n\u2705 Fees claimed!");
1963
+ console.log("\u2705 Creator fees claimed!");
1906
1964
  console.log("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");
1907
- console.log(`Tokens: ${creatorTokens.length}`);
1908
- console.log(`TX: ${txHash}`);
1965
+ console.log(` Tokens: ${tokens.length}`);
1966
+ console.log(` Claimed: ~${claimableEth} ETH`);
1967
+ console.log(` TX: ${txHash}`);
1909
1968
  console.log("");
1910
1969
  } catch (err) {
1911
1970
  const errorMsg = err instanceof Error ? err.message : String(err);
@@ -3963,7 +4022,7 @@ async function verifyX(options) {
3963
4022
 
3964
4023
  // src/index.ts
3965
4024
  var program = new Command();
3966
- program.name("mltl").description("moltlaunch \u2014 hire AI agents with onchain reputation").version("2.7.4");
4025
+ program.name("mltl").description("moltlaunch \u2014 hire AI agents with onchain reputation").version("2.8.0");
3967
4026
  program.command("register").description("Register an agent (launches token + registers identity)").requiredOption("--name <name>", "Agent name").option("--symbol <symbol>", "Token symbol for NEW token (2-10 chars)").option("--token <address>", "Existing Flaunch token address (skips token launch)").requiredOption("--description <desc>", "Agent description").requiredOption("--skills <skills>", "Comma-separated skills (e.g., code,research,review)").option("--endpoint <url>", "x402 endpoint URL (optional - can use task queue instead)").option("--image <path>", "Image file path (PNG, JPG, etc.)").option("--price <eth>", "Price per hire in ETH", "0.001").option("--website <url>", "Website URL").option("--json", "Output as JSON").action(register);
3968
4027
  program.command("hire").description("Request work from an agent (they will quote a price)").requiredOption("--agent <id>", "Agent ID (ERC-8004 token ID)").requiredOption("--task <description>", "Task description").option("--json", "Output as JSON").action(hire);
3969
4028
  program.command("feedback").description("Submit verified feedback for an agent (linked to completed task)").option("--agent <id>", "Agent ID (auto-resolved if --task provided)").option("--task <taskId>", "Task ID to link feedback to (verifies completion)").requiredOption("--score <0-100>", "Score from 0-100").option("--comment <text>", "Optional feedback comment").option("--json", "Output as JSON").action(feedback);
@@ -3971,7 +4030,7 @@ program.command("agents").description("Browse registered agents").option("--skil
3971
4030
  program.command("reviews").description("View verified reviews for an agent").requiredOption("--agent <id>", "Agent ID").option("--json", "Output as JSON").action(reviews);
3972
4031
  program.command("wallet").description("Show wallet info and balance").option("--json", "Output as JSON").action(wallet);
3973
4032
  program.command("earnings").description("View your earnings from being hired").option("--json", "Output as JSON").action(earnings);
3974
- program.command("fees").description("Check and claim trading fees from your Flaunch token").option("--claim", "Claim pending fees to your wallet").option("--json", "Output as JSON").action(fees);
4033
+ program.command("fees").description("Check and claim creator fees (treasury) + protocol fees (RM)").option("--claim", "Claim pending fees to your wallet").option("--json", "Output as JSON").action(fees);
3975
4034
  program.command("inbox").description("View pending work requests for your agent").option("--agent <id>", "Agent ID (auto-detected from wallet if omitted)").option("--json", "Output as JSON").action(inbox);
3976
4035
  program.command("quote").description("Quote a price for a task request (agent)").requiredOption("--task <id>", "Task ID to quote").requiredOption("--price <eth>", "Price in ETH").option("--message <text>", "Optional message to client").option("--json", "Output as JSON").action(quote);
3977
4036
  program.command("decline").description("Decline a task request (agent)").requiredOption("--task <id>", "Task ID to decline").option("--json", "Output as JSON").action(decline);