.PHONY: build publish clean install dev test

# Build wheel + sdist
build:
	pip install hatch --quiet
	hatch build

# Upload to PyPI (needs PYPI_TOKEN env var or ~/.pypirc)
publish: build
	pip install twine --quiet
	twine upload dist/*

# Upload to TestPyPI first (safe test)
publish-test: build
	pip install twine --quiet
	twine upload --repository testpypi dist/*

# Install locally in editable mode for development
install:
	pip install -e ".[web3,dev]"

# Install only core (no web3)
install-core:
	pip install -e ".[dev]"

# Run tests
test:
	pytest tests/ -v

# Remove build artifacts
clean:
	rm -rf dist/ build/ *.egg-info src/*.egg-info

# Bump patch version (0.1.0 → 0.1.1) and build
bump-patch:
	@current=$$(grep '^version' pyproject.toml | sed 's/version = "\(.*\)"/\1/'); \
	new=$$(python -c "v='$$current'.split('.'); v[2]=str(int(v[2])+1); print('.'.join(v))"); \
	sed -i "s/version = \"$$current\"/version = \"$$new\"/" pyproject.toml; \
	echo "Bumped $$current → $$new"
