diff --git a/README.md b/README.md index 38221b7..6a97cb6 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ Every command that sends a transaction waits for it to land and reports what hap pumpfun launch --name "MyToken" --ticker "MTK" --uri https://example.com/mytoken.json --buy 0.1 ``` -pump.fun no longer accepts anonymous metadata uploads, so `launch` takes the URI of a metadata JSON you host (`name`, `symbol`, `description`, `image`). Without `--uri` it still tries the upload and says so when it is refused. `--buy` buys in the same transaction as the create, so nobody buys first. +pump.fun no longer accepts anonymous metadata uploads, so `launch` requires `--uri`: the URI of a metadata JSON you host (`name`, `symbol`, `description`, `image`), for example on IPFS or any static host. `--buy` buys in the same transaction as the create, so nobody buys first. ## Commands @@ -106,7 +106,7 @@ Transaction inspection (requires RPC): pumpfun tx-status Confirmation status, slot, fee, errors Token launch (requires RPC + wallet): - pumpfun launch --name X --ticker Y [--uri U | --desc D --image P] [--buy N] + pumpfun launch --name X --ticker Y --uri U [--buy N] [--quote-mint M] [--creator-fee-bps N] [--holder-reward] [--mayhem] [--slippage N] [--fast] @@ -191,7 +191,7 @@ A pump.fun bonding curve pays a sell out of its real reserves, which on some coi | `info` | Solana RPC (`getAccountInfo` for bonding curve PDA; LaunchLab: `getMultipleAccounts`, `getProgramAccounts`) | JSON-RPC | | `buy` | Solana RPC (`getAccountInfo`, `getLatestBlockhash`, `sendTransaction`; LaunchLab adds `getMultipleAccounts`, `getProgramAccounts`) | JSON-RPC | | `sell` | Solana RPC (`getAccountInfo`, `getTokenAccountBalance`, `getLatestBlockhash`, `sendTransaction`; LaunchLab as `buy`) | JSON-RPC | -| `launch` | Solana RPC (`sendTransaction`); `pump.fun/api/ipfs` only without `--uri` | JSON-RPC (+ HTTPS) | +| `launch` | Solana RPC (`sendTransaction`) | JSON-RPC | | `tx-status` | Solana RPC (`getTransaction`) | JSON-RPC | | `migrate` | Solana RPC (`sendTransaction`) | JSON-RPC | | `claim-cashback` | Solana RPC (`sendTransaction`) | JSON-RPC | diff --git a/pyproject.toml b/pyproject.toml index 94be596..f9af858 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "pumpfun-cli" -version = "0.4.0" +version = "0.5.0" description = "CLI for pump.fun and Raydium LaunchLab on Solana — trade, launch, and browse tokens" readme = "README.md" license = {text = "Apache-2.0"} diff --git a/src/pumpfun_cli/__init__.py b/src/pumpfun_cli/__init__.py index 55a464e..f5a6ad3 100644 --- a/src/pumpfun_cli/__init__.py +++ b/src/pumpfun_cli/__init__.py @@ -1,3 +1,3 @@ """pumpfun-cli — CLI for pump.fun on Solana.""" -__version__ = "0.4.0" +__version__ = "0.5.0" diff --git a/src/pumpfun_cli/commands/launch.py b/src/pumpfun_cli/commands/launch.py index 2ab5156..b9195a0 100644 --- a/src/pumpfun_cli/commands/launch.py +++ b/src/pumpfun_cli/commands/launch.py @@ -13,12 +13,10 @@ def launch( ctx: typer.Context, name: str = typer.Option(..., "--name", help="Token name"), ticker: str = typer.Option(..., "--ticker", help="Token ticker/symbol"), - desc: str = typer.Option("", "--desc", help="Token description (for the metadata upload)"), - image: str | None = typer.Option(None, "--image", help="Path to token image"), - uri: str | None = typer.Option( - None, + uri: str = typer.Option( + ..., "--uri", - help="Metadata JSON URI you already host; skips the pump.fun upload (--desc and --image are then unused)", + help="URI of the metadata JSON you host (name, symbol, description, image)", ), buy: float | None = typer.Option( None, @@ -52,6 +50,8 @@ def launch( error("Token name cannot be empty.", exit_code=2) if not ticker.strip(): error("Token ticker cannot be empty.", exit_code=2) + if not uri.strip(): + error("Metadata URI cannot be empty.", hint="Pass --uri ", exit_code=2) if not state or not state.rpc: error("RPC endpoint not configured.", hint="Run: pumpfun config set rpc ") if slippage < 0 or slippage > 100: @@ -84,8 +84,7 @@ def launch( password, name, ticker, - desc, - image, + uri, initial_buy=buy, is_mayhem=mayhem, quote_mint_str=quote_mint, @@ -93,7 +92,6 @@ def launch( is_holder_reward=holder_reward, slippage=slippage, confirm=confirm, - uri=uri, **overrides, ) ) diff --git a/src/pumpfun_cli/core/launch.py b/src/pumpfun_cli/core/launch.py index 946454d..f55710b 100644 --- a/src/pumpfun_cli/core/launch.py +++ b/src/pumpfun_cli/core/launch.py @@ -1,9 +1,7 @@ -"""Token launch — create_v2 with IPFS metadata upload.""" +"""Token launch — create_v2 with metadata the caller hosts.""" -import os from pathlib import Path -import httpx from solders.keypair import Keypair from spl.token.instructions import create_idempotent_associated_token_account @@ -13,7 +11,6 @@ from pumpfun_cli.protocol.address import derive_bonding_curve, find_ata, find_holder_rewards from pumpfun_cli.protocol.client import RpcClient, TransactionFailedError from pumpfun_cli.protocol.contracts import ( - HTTP_HEADERS, LAUNCH_COMPUTE_UNITS, TOKEN_2022_PROGRAM, TOKEN_DECIMALS, @@ -39,34 +36,6 @@ _BPS = 10_000 -async def upload_metadata( - name: str, - symbol: str, - description: str, - image_path: str | None = None, -) -> str: - """Upload token metadata to pump.fun's IPFS endpoint. Returns metadata URI.""" - async with httpx.AsyncClient(timeout=30.0, headers=HTTP_HEADERS) as client: - files = {} - data = { - "name": name, - "symbol": symbol, - "description": description, - "showName": "true", - } - if image_path and os.path.exists(image_path): - files["file"] = (os.path.basename(image_path), open(image_path, "rb"), "image/png") - resp = await client.post( - "https://pump.fun/api/ipfs", - data=data, - files=files if files else None, - ) - if resp.status_code != 200: - raise RuntimeError(f"Metadata upload to pump.fun failed (HTTP {resp.status_code})") - result = resp.json() - return result.get("metadataUri") or result.get("metadata_uri") or result.get("uri", "") - - def opening_buy_tokens( global_state: dict, amount_raw: int, opening_reserves: int, creator_fee_bps: int | None ) -> int: @@ -94,8 +63,7 @@ async def launch_token( password: str, name: str, ticker: str, - description: str, - image_path: str | None = None, + uri: str, initial_buy: float | None = None, is_mayhem: bool = False, quote_mint_str: str | None = None, @@ -105,12 +73,11 @@ async def launch_token( confirm: bool = False, priority_fee: int | None = None, compute_units: int | None = None, - uri: str | None = None, ) -> dict: """Launch a new coin with create_v2, optionally buying it in the same transaction. - `uri` is a metadata JSON already hosted elsewhere; without it the metadata - is uploaded to pump.fun, which may refuse an unauthenticated upload. + `uri` points at a metadata JSON the caller hosts; pump.fun accepts no + anonymous uploads. With `initial_buy`, create and buy go out as one transaction (v1, since together they exceed v0), so nobody can buy in between. @@ -132,7 +99,7 @@ async def launch_token( client = RpcClient(rpc_url) try: # Refuse anything the program would reject or silently ignore before - # uploading metadata or spending a fee. + # spending a fee. check_mayhem_quote(quote_mint, is_mayhem) global_state = await fetch_global(client) if is_holder_reward and not global_state.get("is_holder_reward_enabled", False): @@ -162,17 +129,6 @@ async def launch_token( ), } - if not uri: - try: - uri = await upload_metadata(name, ticker, description, image_path) - except (RuntimeError, httpx.HTTPError) as exc: - return { - "error": "ipfs_failed", - "message": f"{exc}. Host the metadata JSON yourself and pass --uri.", - } - if not uri: - return {"error": "ipfs_failed", "message": "Failed to get metadata URI from IPFS."} - mint_keypair = Keypair() mint = mint_keypair.pubkey() bonding_curve = derive_bonding_curve(mint) diff --git a/tests/test_commands/test_human_output.py b/tests/test_commands/test_human_output.py index f1e4a47..b1dc2bb 100644 --- a/tests/test_commands/test_human_output.py +++ b/tests/test_commands/test_human_output.py @@ -1,5 +1,6 @@ """Human-readable output for the reshaped results, labelled by the coin's quote asset.""" +import re from unittest.mock import AsyncMock, patch import pytest @@ -200,8 +201,8 @@ def test_launch_forwards_options(wallet): "N", "--ticker", "T", - "--desc", - "d", + "--uri", + "u", "--buy", "2", "--quote-mint", @@ -231,8 +232,8 @@ def test_launch_rejects_negative_fee(wallet): "N", "--ticker", "T", - "--desc", - "d", + "--uri", + "u", "--creator-fee-bps", "-1", ], @@ -251,7 +252,9 @@ def test_buy_rejects_non_positive_amount(wallet, amount): def test_launch_rejects_negative_buy(wallet): with patch("pumpfun_cli.commands.launch.launch_token", new_callable=AsyncMock) as launch: result = runner.invoke( - app, ["--rpc", "http://rpc", "launch", "--name", "N", "--ticker", "T", "--buy", "-1"] + app, + ["--rpc", "http://rpc", "launch", "--name", "N", "--ticker", "T", "--uri", "u"] + + ["--buy", "-1"], ) assert result.exit_code != 0 launch.assert_not_called() @@ -277,13 +280,16 @@ def test_launch_rejects_blank_name_or_ticker(wallet, name, ticker, message): launch.assert_not_called() -def test_launch_with_uri_needs_no_desc(wallet): +@pytest.mark.parametrize("uri_args", [[], ["--uri", " "]]) +def test_launch_requires_a_metadata_uri(wallet, uri_args): with patch("pumpfun_cli.commands.launch.launch_token", new_callable=AsyncMock) as launch: - launch.return_value = {"error": "stop", "message": "stop"} - runner.invoke( - app, ["--rpc", "http://rpc", "launch", "--name", "N", "--ticker", "T", "--uri", "u"] + result = runner.invoke( + app, + ["--rpc", "http://rpc", "launch", "--name", "N", "--ticker", "T", *uri_args], ) - launch.assert_called_once() + assert result.exit_code == 2 + assert "--uri" in re.sub(r"\x1b\[[0-9;]*m", "", result.output) + launch.assert_not_called() def test_tokens_table_names_quote_and_survives_missing_chain_data(): diff --git a/tests/test_core/test_launch.py b/tests/test_core/test_launch.py index edb2f92..f1e67fd 100644 --- a/tests/test_core/test_launch.py +++ b/tests/test_core/test_launch.py @@ -1,6 +1,6 @@ -"""Launch: guards run before anything is uploaded or sent, then create (and buy).""" +"""Launch: guards run before anything is sent, then create (and buy).""" -from unittest.mock import AsyncMock, patch +from unittest.mock import patch import pytest from solders.pubkey import Pubkey @@ -33,16 +33,14 @@ def _chain(**global_overrides): return client +URI = "https://example.com/m.json" + + async def _launch(client, tmp_keystore, **kwargs): - upload = AsyncMock(return_value="https://ipfs.io/ipfs/x") - with ( - patch("pumpfun_cli.core.launch.RpcClient", return_value=client), - patch("pumpfun_cli.core.launch.upload_metadata", upload), - ): - result = await launch_token( - "http://rpc", tmp_keystore, "testpass", "Name", "TKR", "d", **kwargs + with patch("pumpfun_cli.core.launch.RpcClient", return_value=client): + return await launch_token( + "http://rpc", tmp_keystore, "testpass", "Name", "TKR", URI, **kwargs ) - return result, upload def _pump(client): @@ -51,10 +49,10 @@ def _pump(client): async def test_create_only(tmp_keystore): client = _chain() - result, upload = await _launch(client, tmp_keystore) + result = await _launch(client, tmp_keystore) assert result["action"] == "launch" assert result["quote_symbol"] == "SOL" - upload.assert_awaited_once() + assert result["metadata_uri"] == URI ixs = _pump(client) assert [bytes(i.data[:8]) for i in ixs] == [ CREATE_V2_DISCRIMINATOR, @@ -65,7 +63,7 @@ async def test_create_only(tmp_keystore): async def test_create_and_buy_in_one_transaction(tmp_keystore): client = _chain() - result, _ = await _launch(client, tmp_keystore, initial_buy=0.5, slippage=10) + result = await _launch(client, tmp_keystore, initial_buy=0.5, slippage=10) assert len(client.sent) == 1 buy = _pump(client)[-1] assert bytes(buy.data[:8]) == BUY_EXACT_QUOTE_IN_V2_DISCRIMINATOR @@ -96,7 +94,7 @@ async def test_custom_quote_with_creator_fee(tmp_keystore): user = decrypt_keypair(Path(tmp_keystore), "testpass").pubkey() client = _chain() client.token_balances[find_ata(user, T22_QUOTE, TOKEN_2022_PROGRAM)] = 10_000_000 - result, _ = await _launch( + result = await _launch( client, tmp_keystore, initial_buy=2, quote_mint_str=str(T22_QUOTE), creator_fee_bps=100 ) assert result["creator_fee_bps"] == 100 @@ -114,7 +112,7 @@ async def test_custom_quote_with_creator_fee(tmp_keystore): ({"quote_mint_str": str(T22_QUOTE), "creator_fee_bps": 900}, "maximum"), ], ) -async def test_refused_before_upload(tmp_keystore, kwargs, message): +async def test_refused_before_sending(tmp_keystore, kwargs, message): client = _chain() client.add_mint(Pubkey.new_unique(), 6) with pytest.raises(ValueError, match=message): @@ -124,56 +122,23 @@ async def test_refused_before_upload(tmp_keystore, kwargs, message): async def test_holder_reward_disabled(tmp_keystore): client = _chain(is_holder_reward_enabled=False) - result, upload = await _launch(client, tmp_keystore, is_holder_reward=True) + result = await _launch(client, tmp_keystore, is_holder_reward=True) assert result["error"] == "holder_reward_disabled" - upload.assert_not_awaited() + assert client.sent == [] async def test_custom_quote_buy_needs_the_asset(tmp_keystore): client = _chain() - result, upload = await _launch( - client, tmp_keystore, initial_buy=2, quote_mint_str=str(T22_QUOTE) - ) + result = await _launch(client, tmp_keystore, initial_buy=2, quote_mint_str=str(T22_QUOTE)) assert result["error"] == "insufficient_balance" - upload.assert_not_awaited() + assert client.sent == [] -async def test_hosted_uri_skips_the_upload(tmp_keystore): +async def test_create_carries_the_uri(tmp_keystore): client = _chain() - result, upload = await _launch(client, tmp_keystore, uri="https://example.com/m.json") - upload.assert_not_awaited() - assert result["metadata_uri"] == "https://example.com/m.json" + await _launch(client, tmp_keystore) create = _pump(client)[0] - assert b"https://example.com/m.json" in bytes(create.data) - - -async def test_refused_upload_points_at_uri(tmp_keystore): - client = _chain() - with ( - patch("pumpfun_cli.core.launch.RpcClient", return_value=client), - patch( - "pumpfun_cli.core.launch.upload_metadata", - AsyncMock(side_effect=RuntimeError("Metadata upload to pump.fun failed (HTTP 405)")), - ), - ): - result = await launch_token("http://rpc", tmp_keystore, "testpass", "N", "T", "d") - assert result["error"] == "ipfs_failed" - assert "--uri" in result["message"] - assert client.sent == [] - - -def test_upload_identifies_itself(respx_mock): - import asyncio - - import httpx - - from pumpfun_cli.core.launch import upload_metadata - - route = respx_mock.post("https://pump.fun/api/ipfs").mock( - return_value=httpx.Response(200, json={"metadataUri": "https://ipfs.io/ipfs/x"}) - ) - assert asyncio.run(upload_metadata("N", "T", "d")) == "https://ipfs.io/ipfs/x" - assert route.calls.last.request.headers["user-agent"].startswith("pumpfun-cli") + assert URI.encode() in bytes(create.data) def test_opening_buy_follows_the_curve(): @@ -185,19 +150,3 @@ def test_opening_buy_follows_the_curve(): # Constant product: a 5 SOL buy into 30 SOL receives about 14% less than linear. assert big < linear_big * 0.87 assert small > 0 - - -async def test_upload_transport_error_points_at_uri(tmp_keystore): - import httpx - - client = _chain() - with ( - patch("pumpfun_cli.core.launch.RpcClient", return_value=client), - patch( - "pumpfun_cli.core.launch.upload_metadata", - AsyncMock(side_effect=httpx.ConnectTimeout("timed out")), - ), - ): - result = await launch_token("http://rpc", tmp_keystore, "testpass", "N", "T", "d") - assert result["error"] == "ipfs_failed" - assert "--uri" in result["message"] diff --git a/tests/test_surfpool/test_extras.py b/tests/test_surfpool/test_extras.py index 01233c0..3f2c6a3 100644 --- a/tests/test_surfpool/test_extras.py +++ b/tests/test_surfpool/test_extras.py @@ -114,7 +114,6 @@ async def test_migrate_a_completed_curve( password=test_password, name="Migrate", ticker="MIG", - description="migrate test", uri="https://example.com/migrate.json", confirm=True, ) diff --git a/tests/test_surfpool/test_launch.py b/tests/test_surfpool/test_launch.py index 9be56e5..d5051bb 100644 --- a/tests/test_surfpool/test_launch.py +++ b/tests/test_surfpool/test_launch.py @@ -4,13 +4,10 @@ coins, with and without an opening buy, verifying that tokens are created on-chain successfully. A launch with a buy goes out as a v1 transaction. -The IPFS metadata upload is mocked — the on-chain program does not -validate URI content, so a fake URI is sufficient for testing the -create_v2 instruction serialisation. +The on-chain program does not validate URI content, so a fake URI is +sufficient for testing the create_v2 instruction serialisation. """ -from unittest.mock import AsyncMock, patch - import pytest from pumpfun_cli.core.info import get_token_info @@ -18,12 +15,6 @@ FAKE_URI = "https://ipfs.io/ipfs/QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG" -_UPLOAD_PATCH = patch( - "pumpfun_cli.core.launch.upload_metadata", - new_callable=AsyncMock, - return_value=FAKE_URI, -) - _LAUNCH_MATRIX = [ pytest.param(False, False, None, id="default"), pytest.param(False, True, None, id="holder_reward"), @@ -36,9 +27,7 @@ @pytest.mark.asyncio @pytest.mark.parametrize("is_mayhem,is_holder_reward,initial_buy", _LAUNCH_MATRIX) -@_UPLOAD_PATCH async def test_launch( - _mock_upload, surfpool_rpc, funded_keypair, test_keystore, @@ -62,7 +51,7 @@ async def test_launch( password=test_password, name="Test", ticker="TST", - description="parametrized launch", + uri=FAKE_URI, **kwargs, ) diff --git a/tests/test_surfpool/test_trade.py b/tests/test_surfpool/test_trade.py index 96856a5..91c589a 100644 --- a/tests/test_surfpool/test_trade.py +++ b/tests/test_surfpool/test_trade.py @@ -170,7 +170,6 @@ async def test_sell_caps_at_the_curves_real_reserves( password=test_password, name="Short", ticker="SHRT", - description="short reserves", uri="https://example.com/short.json", initial_buy=1, confirm=True, @@ -261,7 +260,6 @@ async def test_buy_past_the_curve_is_reported( password=test_password, name="Big", ticker="BIG", - description="buy past the curve", uri="https://example.com/big.json", confirm=True, ) diff --git a/uv.lock b/uv.lock index 7b29ee5..7ac493e 100644 --- a/uv.lock +++ b/uv.lock @@ -571,7 +571,7 @@ wheels = [ [[package]] name = "pumpfun-cli" -version = "0.4.0" +version = "0.5.0" source = { editable = "." } dependencies = [ { name = "base58" },