diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..2458192 --- /dev/null +++ b/.clang-format @@ -0,0 +1,9 @@ +BasedOnStyle: LLVM +IndentWidth: 4 +NamespaceIndentation: All +BreakBeforeBraces: Allman +PointerAlignment: Right +ColumnLimit: 100 +AllowShortFunctionsOnASingleLine: Inline +AllowShortIfStatementsOnASingleLine: WithoutElse +SortIncludes: Never diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000..aa877f3 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,14 @@ +Checks: >- + -*, + bugprone-dangling-handle, + bugprone-sizeof-expression, + bugprone-suspicious-memset-usage, + bugprone-unused-raii, + bugprone-use-after-move, + performance-*, + readability-identifier-naming +WarningsAsErrors: '*' +HeaderFilterRegex: '.*' +CheckOptions: + readability-identifier-naming.VariableCase: lower_case + readability-identifier-naming.ParameterCase: lower_case diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..a4571c9 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +indent_style = space + +[*.{cpp,h,hpp}] +indent_size = 4 + +[*.{md,json,yml,yaml}] +indent_size = 2 diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 24f30d8..6b3de21 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,12 +1,16 @@ ## Summary -- +Describe the concrete problem and resulting behavior. ## Verification -- [ ] Tested with the narrowest relevant command -- [ ] Not run; reason: +Commands run and their actual results: -## Notes +Checks not run and the reason (or none): -Compatibility concerns, API surface changes, or release notes. +## Compatibility and evidence + +Public API, binary compatibility, or release implications (or none): + +For protocol changes: official docs links and the Python SDK commit or fixture source. +For live checks: distinguish observed outcomes from local fixture coverage. diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1036132..1f22024 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,9 +2,14 @@ name: build on: push: + branches: [main] pull_request: workflow_dispatch: +concurrency: + group: build-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: build-test: name: ${{ matrix.os }} ${{ matrix.build_type }} @@ -19,8 +24,21 @@ jobs: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: + fetch-depth: 0 persist-credentials: false + - name: Check PR title + if: github.event_name == 'pull_request' && matrix.os == 'ubuntu-22.04' && matrix.build_type == 'Release' + shell: bash + env: + PR_TITLE: ${{ github.event.pull_request.title }} + run: | + pattern='^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\([a-zA-Z0-9_./-]+\))?!?: .+' + if [[ ! "$PR_TITLE" =~ $pattern ]]; then + echo 'Use type(scope): description or type: description for the PR title.' >&2 + exit 1 + fi + - name: Install Linux dependencies if: runner.os == 'Linux' run: | @@ -41,11 +59,20 @@ jobs: "${deployment_args[@]}" - name: Build - run: cmake --build build --parallel --config ${{ matrix.build_type }} + run: cmake --build build --parallel 2 --config ${{ matrix.build_type }} - name: Test run: ctest --test-dir build --output-on-failure --build-config ${{ matrix.build_type }} -LE live + - name: Check formatting and C++ lint + if: github.event_name == 'pull_request' && matrix.os == 'ubuntu-22.04' && matrix.build_type == 'Release' + env: + BASE_SHA: ${{ github.event.pull_request.base.sha }} + run: | + python3 -m pip install clang-format==21.1.6 clang-tidy==21.1.6 + python3 scripts/test_quality.py + python3 scripts/quality.py "$BASE_SHA" --build-dir build + - name: Optional live smoke if: vars.POLYMARKET_RUN_LIVE_SMOKE == '1' run: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 441eb05..1277692 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -46,6 +46,7 @@ jobs: package_version="${version%%-*}" grep -Eq "project\(polymarket_cpp_client VERSION ${package_version//./\\.} LANGUAGES" CMakeLists.txt grep -Fq "#define POLYMARKET_CLIENT_VERSION \"$package_version\"" include/polymarket/version.hpp + test -s "docs/releases/$tag.md" echo "tag=$tag" >> "$GITHUB_OUTPUT" echo "commit=$commit" >> "$GITHUB_OUTPUT" @@ -69,7 +70,7 @@ jobs: -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/install - name: Build - run: cmake --build build --parallel --config Release + run: cmake --build build --parallel 2 --config Release - name: Test run: ctest --test-dir build --output-on-failure --build-config Release -LE live @@ -125,7 +126,7 @@ jobs: -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/install - name: Build - run: cmake --build build --parallel --config Release + run: cmake --build build --parallel 2 --config Release - name: Test run: ctest --test-dir build --output-on-failure --build-config Release -LE live @@ -171,7 +172,7 @@ jobs: name: Release ${{ needs.validate.outputs.tag }} draft: false prerelease: ${{ contains(needs.validate.outputs.tag, '-') }} - generate_release_notes: true + body_path: docs/releases/${{ needs.validate.outputs.tag }}.md files: | artifacts/macos-arm64/polymarket-cpp-client-macos-arm64.tar.gz artifacts/linux-x64/polymarket-cpp-client-linux-x64.tar.gz diff --git a/.gitignore b/.gitignore index bcf4165..b7501b8 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,7 @@ node_modules/ # Project-local agent learnings .learnings/ + +# Local quality tools +.venv-quality/ +__pycache__/ diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..4753c24 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,5 @@ +build/ +work/ +node_modules/ +.learnings/ +.journal/ diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..eda44de --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,4 @@ +{ + "proseWrap": "preserve", + "printWidth": 100 +} diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..ef46109 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,40 @@ +# Working in this repository + +Read [CONTRIBUTING.md](CONTRIBUTING.md) before changing code or preparing commits. +It defines coding rules, commit names, validation, and the completion criteria. + +## Start here + +1. Check the current branch, diff, and untracked files. Preserve other work. +2. State the working assumption and success check for larger or ambiguous tasks. +3. Read the affected public headers under `include/polymarket/`, implementation, and existing tests before editing. +4. Keep the diff within the requested scope and match the surrounding C++ style. +5. Run the narrowest meaningful check, then report the command and actual result. + +Concurrent work is common. Continue around unrelated changes without resetting, +removing, or reformatting them. When asked to commit all work, review every tracked +and untracked change and create logical commit groups. + +## Load these references when relevant + +- Protocol, signing, transactions, numeric parsing, or stream lifecycle changes: + read [docs/protocol-development.md](docs/protocol-development.md). +- Position operations or wallet support: also read + [docs/position-operations.md](docs/position-operations.md). +- Versions, tags, release packages, or publication: read + [docs/releasing.md](docs/releasing.md) and `.github/workflows/release.yml`. +- Test registration and example targets: inspect `cmake/PolymarketTests.cmake` + and `cmake/PolymarketExamples.cmake`. + +## Authorization and reporting + +A request to investigate or draft permits local preparation. Publishing comments, +pushing commits, merging PRs, and publishing releases require authorization from +the user. Carry forward authorization already given in the conversation. + +Live orders, approvals, and funded transactions require explicit authorization. +Use deterministic tests and read-only inspection for routine validation. + +Distinguish prepared changes, passing local checks, passing CI, and published +artifacts. Report skipped checks and the precise reason. Keep contributor +messages natural and concise. Do not use em dashes. diff --git a/CMakeLists.txt b/CMakeLists.txt index 66b73b4..298aa51 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ if(POLICY CMP0135) cmake_policy(SET CMP0135 NEW) endif() -project(polymarket_cpp_client VERSION 2.0.0 LANGUAGES CXX C) +project(polymarket_cpp_client VERSION 3.0.0 LANGUAGES CXX C) if(PROJECT_IS_TOP_LEVEL) set(CMAKE_CXX_STANDARD 20) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..715a682 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,126 @@ +# Contributing + +## Coding rules + +- Prefer clear domain names such as `submitted_hashes` and `poll_interval`. + Use the existing snake_case convention for variables and parameters. +- Keep hot paths efficient. Avoid needless copies, repeated parsing, unbounded + queues, and allocations inside loops. Measure performance changes with the + relevant existing benchmark and report workload, build type, and comparison. + Prefer a small direct implementation over extra abstractions. +- Use C++20 and match the existing naming, indentation, and brace style. +- Keep new or substantially changed files near 300 lines or fewer. This is a + soft limit: split by responsibility, not arbitrary line counts. Explain an + exception in the PR instead of creating meaningless wrappers. +- Keep public interfaces in `include/polymarket/` and implementation details in `src/`. + Reuse existing numeric, transport, signing, and error helpers. +- Keep changes surgical. Avoid unrelated cleanup, dependency upgrades, and + formatting changes. Add configuration or features only when requested. +- Validate inputs at the boundary. Return or throw useful errors with the + original cause and relevant transaction or request identifiers. +- Handle failure explicitly. Do not hide it with fallback behavior or fabricated + production data. Deterministic fixtures and local servers belong in tests. +- Use RAII for resources and state ownership. Make callback lifetime, shutdown, + locking, and concurrent access explicit when changing asynchronous code. +- Treat public type layout and behavior as compatibility concerns. Explain + changes that require consumers to rebuild or adapt. + +Protocol and lifecycle changes also follow +[docs/protocol-development.md](docs/protocol-development.md). + +Use prefixed public includes such as ``. Keep generic +header names out of the install prefix root. + +## Commits and pull requests + +Use `type(scope): description` or `type: description`. Write a short imperative +subject and group changes by purpose. Common types are `feat`, `fix`, `docs`, +`refactor`, `test`, `perf`, `build`, `ci`, and `chore`. Use `!` and a +`BREAKING CHANGE:` footer when a change requires a migration. + +Examples: + +- `fix(position): preserve hashes after partial batch failure` +- `test(user-stream): cover authentication rejection` +- `docs: explain agent workflow and coding rules` +- `chore(release): prepare v3.0.0` + +PR titles use the same format and are checked in CI. Describe the concrete +problem and resulting behavior, then give the relevant validation. For protocol +changes, include official documentation links and the SDK commit or fixture +source used. Separate observed live results from deterministic test coverage. + +Review all tracked and untracked changes before committing. Stage explicit files +or hunks and keep unrelated work in separate commits when its inclusion is +requested. Keep credentials, local environment files, and build artifacts out +of commits. + +## Validation + +Configure an isolated build directory for the task: + +```bash +cmake -S . -B build -DCMAKE_BUILD_TYPE=Release \ + -DPOLYMARKET_CLIENT_BUILD_EXAMPLES=ON \ + -DPOLYMARKET_CLIENT_BUILD_TESTS=ON +cmake --build build --parallel 2 +ctest --test-dir build --output-on-failure -LE live +``` + +For a small fix, build the affected target and select the relevant tests with +`ctest --test-dir build --output-on-failure -R '' -LE live`. +Add a focused regression for changed behavior. Check that it exposes the failure +before the fix where practical. Assertions must remain effective in Release +builds; use explicit checks such as `tests/check_support.hpp`, not C `assert` +for new tests. + +For public headers, dependency exports, or installation changes, run +`test_package_consumer`. It installs the package, builds an external consumer and +shared plugin, and checks subproject configuration. Match the full CI matrix +before releasing: Linux and macOS, Debug and Release. The workflow files define +the authoritative build options and live-test policy. + +A successful fake-server test proves the local request and response contract. +It does not prove a transaction succeeded on mainnet. Report the distinction. + +## Formatting and linting + +Install the pinned development tools separately from the library: + +```bash +python3 -m venv .venv-quality +. .venv-quality/bin/activate +python3 -m pip install clang-format==21.1.6 clang-tidy==21.1.6 +# Requires Node.js and npm for pinned Prettier 3.6.2. +# Run test_package_consumer first when its source changes. +python3 scripts/quality.py origin/main --build-dir build +python3 scripts/quality.py origin/main --fix +``` + +On macOS, make the SDK explicit in the compile database before running clang-tidy: + +```bash +cmake -S . -B build -DCMAKE_OSX_SYSROOT="$(xcrun --sdk macosx --show-sdk-path)" +``` + +clang-format follows `.clang-format`; clang-tidy checks correctness, performance, +and variable naming through `.clang-tidy`. Prettier formats Markdown, YAML, and +JSON. `--fix` changes formatting only; inspect the diff before keeping it. + +CI checks changed C++ lines and rejects new Prettier formatting debt in touched +files. Existing formatting is the baseline, so unrelated code stays untouched. +Linux Release runs these checks against its existing build and installed +consumer, avoiding a separate library build for linting. +Header-only changes lint first-party translation units against the changed +header lines. New files are checked in full. Use the configured compile database +for linting, and keep static analysis warnings actionable. Duplicate logic and +unnecessary abstractions remain explicit code review checks; the linter does +not prove architectural quality or runtime efficiency. + +## Done means + +The requested behavior is implemented, relevant checks pass, and the diff +contains only the intended work. The PR names compatibility changes, evidence, +and checks that were not run. Report blockers instead of claiming completion. + +For releases, follow [docs/releasing.md](docs/releasing.md). diff --git a/README.md b/README.md index 7cf3441..fb73160 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,11 @@ Reusable C++20 client for Polymarket: REST, WebSocket streaming, and order signi - libcurl, OpenSSL, zlib - Prebuilt release targets: macOS 12+ arm64 and Linux x86-64 +## Contributing + +See [CONTRIBUTING.md](CONTRIBUTING.md) for coding rules, commit names, and checks. +Coding agents start with [AGENTS.md](AGENTS.md). + ## Installation ### Option 1: CMake FetchContent (Recommended) @@ -42,7 +47,7 @@ include(FetchContent) FetchContent_Declare( polymarket_client GIT_REPOSITORY https://github.com/SebastianBoehler/polymarket-cpp-client.git - GIT_TAG v2.0.0 # or any release tag + GIT_TAG v3.0.0 # or any release tag ) FetchContent_MakeAvailable(polymarket_client) @@ -56,14 +61,14 @@ Download pre-built binaries from [Releases](https://github.com/SebastianBoehler/ ```bash # macOS -curl -LO https://github.com/SebastianBoehler/polymarket-cpp-client/releases/download/v2.0.0/polymarket-cpp-client-macos-arm64.tar.gz -mkdir -p polymarket-cpp-client-2.0.0 -tar -xzf polymarket-cpp-client-macos-arm64.tar.gz -C polymarket-cpp-client-2.0.0 +curl -LO https://github.com/SebastianBoehler/polymarket-cpp-client/releases/download/v3.0.0/polymarket-cpp-client-macos-arm64.tar.gz +mkdir -p polymarket-cpp-client-3.0.0 +tar -xzf polymarket-cpp-client-macos-arm64.tar.gz -C polymarket-cpp-client-3.0.0 # Linux -curl -LO https://github.com/SebastianBoehler/polymarket-cpp-client/releases/download/v2.0.0/polymarket-cpp-client-linux-x64.tar.gz -mkdir -p polymarket-cpp-client-2.0.0 -tar -xzf polymarket-cpp-client-linux-x64.tar.gz -C polymarket-cpp-client-2.0.0 +curl -LO https://github.com/SebastianBoehler/polymarket-cpp-client/releases/download/v3.0.0/polymarket-cpp-client-linux-x64.tar.gz +mkdir -p polymarket-cpp-client-3.0.0 +tar -xzf polymarket-cpp-client-linux-x64.tar.gz -C polymarket-cpp-client-3.0.0 ``` Keep this as a dedicated prefix because the archive contains its pinned static @@ -71,7 +76,7 @@ dependencies and headers. Then point CMake at it: ```cmake # Configure with: -# cmake -S . -B build -DCMAKE_PREFIX_PATH=/absolute/path/to/polymarket-cpp-client-2.0.0 +# cmake -S . -B build -DCMAKE_PREFIX_PATH=/absolute/path/to/polymarket-cpp-client-3.0.0 find_package(polymarket_client REQUIRED) target_link_libraries(your_target PRIVATE polymarket::client) ``` @@ -80,9 +85,9 @@ target_link_libraries(your_target PRIVATE polymarket::client) ```bash cmake -S . -B build -DPOLYMARKET_CLIENT_BUILD_EXAMPLES=ON -DPOLYMARKET_CLIENT_BUILD_TESTS=ON -cmake --build build --parallel -# optional tests -ctest --test-dir build +cmake --build build --parallel 2 +# offline tests +ctest --test-dir build --output-on-failure -LE live # optional benchmarks cmake -S . -B build -DPOLYMARKET_CLIENT_BUILD_BENCHMARKS=ON # install (into system or a prefix you configure) @@ -91,6 +96,17 @@ cmake --install build --prefix ## Version Info +See the [v3.0.0 release notes](docs/releases/v3.0.0.md). Rebuild consumers with +the matching headers and libraries when upgrading; public type layouts changed. + +### v3 migration + +Public headers now live under `polymarket/`. Update includes such as +`#include ` to `#include `. +The CMake target remains `polymarket::client`. Rebuild consumers with the v3 +headers and libraries. Flat compatibility headers are not installed. Use a clean install prefix; +installing over v2 does not remove its old flat headers. + ### v2 migration Version 2 is not binary-compatible with v1: several public concrete types grew @@ -175,7 +191,7 @@ for implementation notes. pUSD (merge), and resolved positions into pUSD (redeem): ```cpp -#include "position_client.hpp" +#include "polymarket/position_client.hpp" polymarket::PositionClientConfig config; config.private_key = std::getenv("PRIVATE_KEY"); @@ -308,7 +324,7 @@ Set these env vars explicitly if you need another RPC or contract set. Configure HTTP proxy for geo-restricted access: ```cpp -#include "clob_client.hpp" +#include "polymarket/clob_client.hpp" polymarket::ClobClient client("https://clob.polymarket.com", 137); @@ -325,7 +341,7 @@ Keep TCP/TLS connections warm by configuring transport options once, pre-warming the connection, and optionally running a heartbeat: ```cpp -#include "clob_client.hpp" +#include "polymarket/clob_client.hpp" polymarket::HttpClientOptions http_options; http_options.timeout_ms = 2500; diff --git a/benchmarks/benchmark_http_fixture.cpp b/benchmarks/benchmark_http_fixture.cpp index 515c9b7..25d9ca3 100644 --- a/benchmarks/benchmark_http_fixture.cpp +++ b/benchmarks/benchmark_http_fixture.cpp @@ -1,4 +1,4 @@ -#include "http_client.hpp" +#include "polymarket/http_client.hpp" #include #include #include diff --git a/benchmarks/benchmark_order_payload.cpp b/benchmarks/benchmark_order_payload.cpp index 05bce1e..45b2634 100644 --- a/benchmarks/benchmark_order_payload.cpp +++ b/benchmarks/benchmark_order_payload.cpp @@ -1,4 +1,4 @@ -#include "order_signer.hpp" +#include "polymarket/order_signer.hpp" #include #include #include diff --git a/benchmarks/benchmark_v2_signing.cpp b/benchmarks/benchmark_v2_signing.cpp index 9a86d02..1758f2d 100644 --- a/benchmarks/benchmark_v2_signing.cpp +++ b/benchmarks/benchmark_v2_signing.cpp @@ -1,4 +1,4 @@ -#include "order_signer.hpp" +#include "polymarket/order_signer.hpp" #include #include diff --git a/docs/position-operations.md b/docs/position-operations.md index c644c75..9590260 100644 --- a/docs/position-operations.md +++ b/docs/position-operations.md @@ -1,6 +1,6 @@ # On-Chain Position Operations -`PositionClient` (`include/position_client.hpp`) splits, merges and redeems +`PositionClient` (`include/polymarket/position_client.hpp`) splits, merges and redeems binary market positions on Polygon, matching `split_position`, `merge_positions`, `merge_multiple_positions` and `redeem_positions` in the official Python SDK. @@ -21,7 +21,7 @@ given by its 31-byte (bytes31) id; it is passed to Gamma as given. ## Wallets ```cpp -#include "position_client.hpp" +#include "polymarket/position_client.hpp" polymarket::PositionClientConfig config; config.private_key = std::getenv("PRIVATE_KEY"); diff --git a/docs/protocol-development.md b/docs/protocol-development.md new file mode 100644 index 0000000..68a909a --- /dev/null +++ b/docs/protocol-development.md @@ -0,0 +1,61 @@ +# Protocol and lifecycle changes + +## Verify the contract + +Cross-check behavior against both the current +[official documentation](https://docs.polymarket.com/) and the +[official Python SDK](https://github.com/Polymarket/py-sdk). +Record exact documentation pages and the SDK commit used in the PR. Inspect +wire payloads, contract signatures, and SDK tests, not just method names. +When sources disagree, resolve the discrepancy before implementing it and +explain the evidence. An SDK fixture is evidence for that encoded case, not +proof that a public API accepts all required inputs. + +Use `PolymarketContracts` for shared contract addresses. Verify the chain, +collateral token, wallet type, operator, and approvals for the affected path. +Keep CLOB V2 order signing distinct from Protocol V2 position operations. + +## Preserve numeric and identifier meaning + +Use scaled integers or validated integer strings for money and on-chain +amounts. Reuse the decimal and EVM integer helpers; check width and overflow. +Do not narrow uint256 balances to machine integers or use floating point for +transaction amounts. + +Validate identifiers where their contract is known. A CTF condition is bytes32; +a Protocol V2 market lookup can accept bytes31. Preserve the caller's valid +lookup ID until Gamma resolves the market, then validate the selected ABI. +Test these through public methods as well as internal encoding helpers. + +## Transactions and retries + +EOA batches send separate transactions. If a later call fails, earlier calls +remain submitted. Preserve their hashes, the failed call index, and the original +exception through `PartialBatchError`. Test failures before the first submission, +after partial progress, and after a mined revert. + +A Safe MultiSend batch is atomic on-chain. Keep submission acceptance, relayer +state, and a mined receipt distinct. A timeout does not establish failure or +revert. Retry only failures whose semantics permit retry; reconcile uncertain +submission outcomes before sending another transaction. + +Use monotonic deadlines for waits. Bound sleep by the remaining time and retain +a final outcome check. Cover `timeout < poll interval` and completion near the +deadline for both receipt and relayer paths. Account for transport request time +when describing elapsed-time guarantees. + +## Streams and callbacks + +Treat missed events as stale state. Report gaps on disconnect, queue overflow, +and invalid payloads. Trigger recovery after subscriptions have been restored +so callers can reconcile through REST. Reconnect alone cannot replay missed +user events. + +Test terminal authentication rejection, late connection completion after a +timeout, subscription replay, recovery ordering, and shutdown from callbacks +when changing the corresponding behavior. Ensure stopped sessions cannot start +delivering events again through an old transport callback. + +Keep local fixture coverage, read-only RPC checks, and funded transaction tests +separate in reports. Use explicit authorization before any operation that moves +funds or changes approvals. diff --git a/docs/releases/v3.0.0.md b/docs/releases/v3.0.0.md new file mode 100644 index 0000000..347a830 --- /dev/null +++ b/docs/releases/v3.0.0.md @@ -0,0 +1,62 @@ +# v3.0.0 + +This release adds authenticated user streams and on-chain position operations. +It also defines the contributor and coding-agent workflow. + +## New APIs + +- `UserStream` receives typed CLOB order and trade events for selected markets + or all markets. Subscriptions replay after reconnect. Gap callbacks mark local + state stale; recovery callbacks let callers reconcile through REST after the + subscription is restored. Authentication rejection stops the stream, and a + connection timeout stops the transport. +- `PositionClient` splits, merges, batch-merges, and redeems binary positions + from an EOA or a Gnosis Safe. It supports CTF and Protocol V2 contract paths, + including 31-byte V2 market IDs. +- Solidity ABI encoding, EIP-155 transaction signing, transaction JSON-RPC + helpers, and `PolymarketContracts` are available as public building blocks. +- `TransactionHandle` tracks submission and mined outcomes. `PartialBatchError` + preserves submitted EOA hashes, the failed call index, and the original cause. + Waiters handle timeouts shorter than the polling interval. +- `user_stream_example` and `position_example` show the new workflows. + +## Requirements and limits + +This is a major release because public include paths changed. Replace flat +includes such as `` and `` with +`` and ``. All SDK headers now +install under `include/polymarket/`, avoiding collisions with generic application +headers. No forwarding headers are installed at the old paths. Use a clean install prefix; +installing over v2 does not remove previously installed flat headers. + +The CMake target remains `polymarket::client`. Rebuild consumers against matching +v3.0.0 headers and libraries because public type layouts also changed. + +EOAs pay Polygon gas themselves. Safe operations use the Polymarket relayer and +require `RELAYER_API_KEY`. Safe batches are atomic; EOA batches can complete +partially. A timeout does not mean a transaction failed. + +Position operations use integer base units and do not set approvals. Configure +the required token approvals first. `POLY_PROXY`, `POLY_1271`, combo positions, +and lookup by market or position ID are not supported. Split and merge use +open markets returned by Gamma. See +[the position guide](https://github.com/SebastianBoehler/polymarket-cpp-client/blob/v3.0.0/docs/position-operations.md). + +## Development and validation + +`AGENTS.md`, `CONTRIBUTING.md`, protocol guidance, and a release checklist define +scope, coding rules, commit names, verification, and publication boundaries. +Pinned clang-format, clang-tidy, and Prettier checks enforce formatting and +selected correctness, performance, and naming rules on changed code. PR titles +follow Conventional Commits, and PRs report commands and evidence. +Release notes are versioned with the source and required by the release workflow. + +Deterministic tests cover ABI/signing vectors, local RPC/Gamma/relayer flows, +stream lifecycle, partial batches, and deadlines. Release packages are gated on +Linux x86-64 and macOS arm64 builds, offline tests, and installed-package consumer +checks. Protocol V2 position flows have fixture coverage; the contributor did +not report a live V2 market test. No funded transaction is part of release CI. + +Thanks to Bill Luo (@yluoc) for the user stream and position operations. + +[Full changes](https://github.com/SebastianBoehler/polymarket-cpp-client/compare/v2.0.0...v3.0.0) diff --git a/docs/releasing.md b/docs/releasing.md new file mode 100644 index 0000000..0d11401 --- /dev/null +++ b/docs/releasing.md @@ -0,0 +1,36 @@ +# Releasing + +Publication requires the maintainer's authorization. If publication after checks +is already authorized, complete these steps without asking again. + +1. Inspect the latest release, tags, and commits on `main`. Choose the version + from the public API changes: patch for compatible fixes, minor for compatible + additions, major for required migrations. Assess binary compatibility + separately and tell consumers when they must rebuild. +2. Update `CMakeLists.txt`, all version macros in + `include/polymarket/version.hpp`, and README installation examples together. + Add curated notes at `docs/releases/.md`, for example `v3.0.0.md`. +3. Include all changes since the last release. Name new APIs, fixes, compatibility + concerns, wallet and approval requirements, and verification limits. +4. Build examples and tests, and run the offline suite including + `test_package_consumer`. Open a PR and wait for every Linux/macOS Debug/Release + build to pass on the final commit. Linux Release also checks the PR title, + formatting, and C++ lint using the same build and compile database. +5. Merge the verified PR. Confirm its commits are on `main` and that the exact + commit to tag passed the complete build matrix. Preserve useful commit groups + with a merge or rebase when available. +6. Create an annotated `vX.Y.Z` tag at that commit and push the tag. Existing + tags are immutable; do not replace a published tag to fix a failed release. +7. Monitor `.github/workflows/release.yml`. It validates tag/version agreement + and the notes file, rebuilds and tests Linux x86-64 and macOS arm64 packages, + then publishes only after both package jobs pass. A failed job is a blocker. +8. Verify the published tag resolves to the intended commit, the curated notes + are present, and both package assets exist. Download the packages to inspect + headers, archives, CMake exports, and licenses. Build a consumer from the + downloaded archive on each available matching platform. State which + validation ran locally and which ran in CI. + +The release workflow is the source of truth for supported runners, deployment +targets, package names, and action versions. Keep it and these steps consistent +when changing release behavior. A release is complete only when the published +assets and notes have been verified. diff --git a/examples/evm_event_indexer_example.cpp b/examples/evm_event_indexer_example.cpp index a1c3b2c..942a497 100644 --- a/examples/evm_event_indexer_example.cpp +++ b/examples/evm_event_indexer_example.cpp @@ -1,5 +1,5 @@ -#include "evm_event_indexer.hpp" -#include "polymarket_events.hpp" +#include "polymarket/evm_event_indexer.hpp" +#include "polymarket/polymarket_events.hpp" #include #include #include diff --git a/examples/evm_watch_common.hpp b/examples/evm_watch_common.hpp index 90d5a34..4462821 100644 --- a/examples/evm_watch_common.hpp +++ b/examples/evm_watch_common.hpp @@ -1,7 +1,7 @@ #pragma once -#include "json_rpc_client.hpp" -#include "polymarket_events.hpp" +#include "polymarket/json_rpc_client.hpp" +#include "polymarket/polymarket_events.hpp" #include #include #include diff --git a/examples/feed_latency_benchmark.cpp b/examples/feed_latency_benchmark.cpp index 2b0ce52..90e5ac3 100644 --- a/examples/feed_latency_benchmark.cpp +++ b/examples/feed_latency_benchmark.cpp @@ -1,7 +1,7 @@ -#include "json_rpc_client.hpp" -#include "polymarket_events.hpp" -#include "types.hpp" -#include "websocket_client.hpp" +#include "polymarket/json_rpc_client.hpp" +#include "polymarket/polymarket_events.hpp" +#include "polymarket/types.hpp" +#include "polymarket/websocket_client.hpp" #include #include #include diff --git a/examples/position_example.cpp b/examples/position_example.cpp index 69979ff..76b0453 100644 --- a/examples/position_example.cpp +++ b/examples/position_example.cpp @@ -1,4 +1,4 @@ -#include "position_client.hpp" +#include "polymarket/position_client.hpp" #include #include diff --git a/examples/rest_example.cpp b/examples/rest_example.cpp index ab1f6d3..6b702ad 100644 --- a/examples/rest_example.cpp +++ b/examples/rest_example.cpp @@ -1,4 +1,4 @@ -#include "clob_client.hpp" +#include "polymarket/clob_client.hpp" #include #include diff --git a/examples/sign_example.cpp b/examples/sign_example.cpp index ad1ef8b..7d7c555 100644 --- a/examples/sign_example.cpp +++ b/examples/sign_example.cpp @@ -1,4 +1,4 @@ -#include "order_signer.hpp" +#include "polymarket/order_signer.hpp" #include #include diff --git a/examples/test_positions.cpp b/examples/test_positions.cpp index 9524b7c..337be53 100644 --- a/examples/test_positions.cpp +++ b/examples/test_positions.cpp @@ -1,4 +1,4 @@ -#include "clob_client.hpp" +#include "polymarket/clob_client.hpp" #include #include #include diff --git a/examples/user_stream_example.cpp b/examples/user_stream_example.cpp index 4cfb0ee..f802090 100644 --- a/examples/user_stream_example.cpp +++ b/examples/user_stream_example.cpp @@ -1,5 +1,5 @@ -#include "clob_client.hpp" -#include "user_stream.hpp" +#include "polymarket/clob_client.hpp" +#include "polymarket/user_stream.hpp" #include #include diff --git a/examples/ws_example.cpp b/examples/ws_example.cpp index 7109842..5150ad7 100644 --- a/examples/ws_example.cpp +++ b/examples/ws_example.cpp @@ -1,4 +1,4 @@ -#include "websocket_client.hpp" +#include "polymarket/websocket_client.hpp" #include #include #include diff --git a/include/clob_client.hpp b/include/polymarket/clob_client.hpp similarity index 98% rename from include/clob_client.hpp rename to include/polymarket/clob_client.hpp index d7258de..9e85049 100644 --- a/include/clob_client.hpp +++ b/include/polymarket/clob_client.hpp @@ -1,10 +1,10 @@ #pragma once -#include "clob_types.hpp" -#include "types.hpp" -#include "http_client.hpp" -#include "order_signer.hpp" -#include "sdk_error.hpp" +#include "polymarket/clob_types.hpp" +#include "polymarket/types.hpp" +#include "polymarket/http_client.hpp" +#include "polymarket/order_signer.hpp" +#include "polymarket/sdk_error.hpp" #include #include #include diff --git a/include/clob_types.hpp b/include/polymarket/clob_types.hpp similarity index 99% rename from include/clob_types.hpp rename to include/polymarket/clob_types.hpp index 2b647d8..eaa10c2 100644 --- a/include/clob_types.hpp +++ b/include/polymarket/clob_types.hpp @@ -1,6 +1,6 @@ #pragma once -#include "order_signer.hpp" +#include "polymarket/order_signer.hpp" #include diff --git a/include/decimal_math.hpp b/include/polymarket/decimal_math.hpp similarity index 100% rename from include/decimal_math.hpp rename to include/polymarket/decimal_math.hpp diff --git a/include/evm_abi.hpp b/include/polymarket/evm_abi.hpp similarity index 100% rename from include/evm_abi.hpp rename to include/polymarket/evm_abi.hpp diff --git a/include/evm_event_indexer.hpp b/include/polymarket/evm_event_indexer.hpp similarity index 98% rename from include/evm_event_indexer.hpp rename to include/polymarket/evm_event_indexer.hpp index 431273d..1c2eb99 100644 --- a/include/evm_event_indexer.hpp +++ b/include/polymarket/evm_event_indexer.hpp @@ -1,7 +1,7 @@ #pragma once -#include "evm_utils.hpp" -#include "json_rpc_client.hpp" +#include "polymarket/evm_utils.hpp" +#include "polymarket/json_rpc_client.hpp" #include #include #include diff --git a/include/evm_transaction.hpp b/include/polymarket/evm_transaction.hpp similarity index 100% rename from include/evm_transaction.hpp rename to include/polymarket/evm_transaction.hpp diff --git a/include/evm_utils.hpp b/include/polymarket/evm_utils.hpp similarity index 100% rename from include/evm_utils.hpp rename to include/polymarket/evm_utils.hpp diff --git a/include/http_client.hpp b/include/polymarket/http_client.hpp similarity index 100% rename from include/http_client.hpp rename to include/polymarket/http_client.hpp diff --git a/include/json_rpc_client.hpp b/include/polymarket/json_rpc_client.hpp similarity index 98% rename from include/json_rpc_client.hpp rename to include/polymarket/json_rpc_client.hpp index 49b4864..4ca26ca 100644 --- a/include/json_rpc_client.hpp +++ b/include/polymarket/json_rpc_client.hpp @@ -1,7 +1,7 @@ #pragma once -#include "evm_utils.hpp" -#include "http_client.hpp" +#include "polymarket/evm_utils.hpp" +#include "polymarket/http_client.hpp" #include #include #include diff --git a/include/market_fetcher.hpp b/include/polymarket/market_fetcher.hpp similarity index 97% rename from include/market_fetcher.hpp rename to include/polymarket/market_fetcher.hpp index c971bd0..4cbac7d 100644 --- a/include/market_fetcher.hpp +++ b/include/polymarket/market_fetcher.hpp @@ -1,7 +1,7 @@ #pragma once -#include "types.hpp" -#include "http_client.hpp" +#include "polymarket/types.hpp" +#include "polymarket/http_client.hpp" #include #include #include diff --git a/include/oracle_watcher.hpp b/include/polymarket/oracle_watcher.hpp similarity index 98% rename from include/oracle_watcher.hpp rename to include/polymarket/oracle_watcher.hpp index 8947acb..cea0957 100644 --- a/include/oracle_watcher.hpp +++ b/include/polymarket/oracle_watcher.hpp @@ -1,6 +1,6 @@ #pragma once -#include "polymarket_events.hpp" +#include "polymarket/polymarket_events.hpp" #include #include #include diff --git a/include/order_signer.hpp b/include/polymarket/order_signer.hpp similarity index 100% rename from include/order_signer.hpp rename to include/polymarket/order_signer.hpp diff --git a/include/orderbook.hpp b/include/polymarket/orderbook.hpp similarity index 99% rename from include/orderbook.hpp rename to include/polymarket/orderbook.hpp index f3dcea2..2c7d123 100644 --- a/include/orderbook.hpp +++ b/include/polymarket/orderbook.hpp @@ -1,6 +1,6 @@ #pragma once -#include "types.hpp" +#include "polymarket/types.hpp" #include #include #include diff --git a/include/polymarket_contracts.hpp b/include/polymarket/polymarket_contracts.hpp similarity index 100% rename from include/polymarket_contracts.hpp rename to include/polymarket/polymarket_contracts.hpp diff --git a/include/polymarket_events.hpp b/include/polymarket/polymarket_events.hpp similarity index 98% rename from include/polymarket_events.hpp rename to include/polymarket/polymarket_events.hpp index bca9c4c..fa75cab 100644 --- a/include/polymarket_events.hpp +++ b/include/polymarket/polymarket_events.hpp @@ -1,6 +1,6 @@ #pragma once -#include "evm_utils.hpp" +#include "polymarket/evm_utils.hpp" #include #include diff --git a/include/position_client.hpp b/include/polymarket/position_client.hpp similarity index 98% rename from include/position_client.hpp rename to include/polymarket/position_client.hpp index 67f9465..dcd6550 100644 --- a/include/position_client.hpp +++ b/include/polymarket/position_client.hpp @@ -1,8 +1,8 @@ #pragma once -#include "json_rpc_client.hpp" -#include "order_signer.hpp" -#include "polymarket_contracts.hpp" +#include "polymarket/json_rpc_client.hpp" +#include "polymarket/order_signer.hpp" +#include "polymarket/polymarket_contracts.hpp" #include #include #include diff --git a/include/sdk_error.hpp b/include/polymarket/sdk_error.hpp similarity index 98% rename from include/sdk_error.hpp rename to include/polymarket/sdk_error.hpp index 10a89aa..cf1ea80 100644 --- a/include/sdk_error.hpp +++ b/include/polymarket/sdk_error.hpp @@ -1,6 +1,6 @@ #pragma once -#include "http_client.hpp" +#include "polymarket/http_client.hpp" #include #include #include diff --git a/include/types.hpp b/include/polymarket/types.hpp similarity index 100% rename from include/types.hpp rename to include/polymarket/types.hpp diff --git a/include/user_stream.hpp b/include/polymarket/user_stream.hpp similarity index 97% rename from include/user_stream.hpp rename to include/polymarket/user_stream.hpp index dfd74d4..6a9c53f 100644 --- a/include/user_stream.hpp +++ b/include/polymarket/user_stream.hpp @@ -1,8 +1,8 @@ #pragma once -#include "clob_types.hpp" -#include "order_signer.hpp" -#include "types.hpp" +#include "polymarket/clob_types.hpp" +#include "polymarket/order_signer.hpp" +#include "polymarket/types.hpp" #include #include diff --git a/include/polymarket/version.hpp b/include/polymarket/version.hpp index 398d0a8..b8da4a0 100644 --- a/include/polymarket/version.hpp +++ b/include/polymarket/version.hpp @@ -1,9 +1,9 @@ #pragma once -#define POLYMARKET_CLIENT_VERSION_MAJOR 2 +#define POLYMARKET_CLIENT_VERSION_MAJOR 3 #define POLYMARKET_CLIENT_VERSION_MINOR 0 #define POLYMARKET_CLIENT_VERSION_PATCH 0 -#define POLYMARKET_CLIENT_VERSION "2.0.0" +#define POLYMARKET_CLIENT_VERSION "3.0.0" namespace polymarket { diff --git a/include/websocket_client.hpp b/include/polymarket/websocket_client.hpp similarity index 100% rename from include/websocket_client.hpp rename to include/polymarket/websocket_client.hpp diff --git a/scripts/quality.py b/scripts/quality.py new file mode 100644 index 0000000..d8cbc3c --- /dev/null +++ b/scripts/quality.py @@ -0,0 +1,136 @@ +#!/usr/bin/env python3 +"""Check changed first-party files, preserving the existing formatting baseline.""" + +import argparse +from collections import Counter +import difflib +import json +import os +from pathlib import Path +import re +import subprocess + + +def run(*args): + return subprocess.check_output(args, text=True) + + +def changed_files(base): + output = run("git", "diff", "--name-status", "-z", "--find-renames", + "--diff-filter=ACMR", base).rstrip("\0") + fields = iter(output.split("\0") if output else []) + paths = {} + for status in fields: + original = next(fields) + path = next(fields) if status.startswith(("R", "C")) else original + paths[path] = original + return paths + + +def changed_lines(base, path, original=None): + paths = [path] if original is None or original == path else [original, path] + diff = run("git", "diff", "--unified=0", base, "--", *paths) + return [ + [int(start), int(start) + int(count or 1) - 1] + for start, count in re.findall(r"^@@ .*?\+(\d+)(?:,(\d+))? @@", diff, re.M) + if count != "0" + ] + + +def check_format(base, path, lines, fix, original_path=None): + original = path.read_text() + if path.suffix in {".cpp", ".hpp", ".h"}: + args = ["clang-format", str(path)] + args += [f"--lines={start}:{end}" for start, end in lines] + formatted = run(*args) + before = original + else: + args = ["npx", "--yes", "--package=prettier@3.6.2", "prettier", str(path)] + formatted = run(*args) + # Require touched files to add no formatting debt. Existing debt is + # measured against the base instead of rewriting unrelated text. + result = subprocess.run( + ["git", "show", f"{base}:{original_path or path}"], capture_output=True, text=True + ) + if result.returncode == 0: + previous = result.stdout + previous_format = subprocess.run( + args[:-1] + ["--stdin-filepath", str(path)], + input=previous, capture_output=True, text=True, check=True + ).stdout + old_debt = formatting_debt(previous, previous_format) + new_debt = formatting_debt(original, formatted) + if new_debt <= old_debt: + return True + before = original + if formatted == before: + return True + if fix: + path.write_text(formatted) + return True + print(f"Formatting failed: {path}") + return False + + +def formatting_debt(original, formatted): + return Counter( + (line[0], line[1:]) + for line in difflib.ndiff(original.splitlines(), formatted.splitlines()) + if line.startswith(("- ", "+ ")) + ) + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("base", help="Git ref used as the comparison base") + parser.add_argument("--build-dir", default="build") + parser.add_argument("--fix", action="store_true", help="Apply formatting only") + args = parser.parse_args() + root = Path(run("git", "rev-parse", "--show-toplevel").strip()) + os.chdir(root) + originals = changed_files(args.base) + paths = list(originals) + untracked = set(run("git", "ls-files", "--others", "--exclude-standard").splitlines()) + paths += sorted(untracked) + supported = {".cpp", ".hpp", ".h", ".md", ".yml", ".yaml", ".json"} + paths = [Path(path) for path in paths if Path(path).suffix in supported] + ranges = { + path: ([[1, max(1, len(path.read_text().splitlines()))]] if str(path) in untracked + else changed_lines(args.base, str(path), originals[str(path)])) + for path in paths + } + passed = True + for path in paths: + if ranges[path]: + passed = check_format(args.base, path, ranges[path], args.fix, + originals.get(str(path))) and passed + if args.fix: + return 0 + databases = {} + for database in Path(args.build_dir).rglob("compile_commands.json"): + for entry in json.loads(database.read_text()): + source = Path(entry["file"]).resolve() + if (source.is_relative_to(root) and + source.relative_to(root).parts[0] in {"src", "tests", "examples", "benchmarks"}): + databases[source.relative_to(root)] = database.parent + cpp_files = [path for path in paths if path.suffix == ".cpp"] + headers = [path for path in paths if path.suffix in {".hpp", ".h"}] + if headers and not cpp_files: + cpp_files = sorted(databases) + line_filter = json.dumps([ + {"name": str(root / path), "lines": ranges[path]} + for path in paths if path.suffix in {".cpp", ".hpp", ".h"} and ranges[path] + ]) + for path in cpp_files: + if path not in databases: + raise RuntimeError(f"No compile command for {path}; build its consumer first") + result = subprocess.run([ + "clang-tidy", str(path), "-p", str(databases[path]), + f"--line-filter={line_filter}", "--quiet" + ]) + passed = result.returncode == 0 and passed + return 0 if passed else 1 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/scripts/test_quality.py b/scripts/test_quality.py new file mode 100644 index 0000000..1fe45ff --- /dev/null +++ b/scripts/test_quality.py @@ -0,0 +1,41 @@ +import importlib.util +from pathlib import Path +import unittest +from unittest.mock import patch + +spec = importlib.util.spec_from_file_location("quality", Path(__file__).with_name("quality.py")) +quality = importlib.util.module_from_spec(spec) +spec.loader.exec_module(quality) + + +class QualityTests(unittest.TestCase): + def test_empty_diff_has_no_changed_files(self): + with patch.object(quality, "run", return_value=""): + self.assertEqual(quality.changed_files("base"), {}) + + def test_rename_retains_original_path(self): + diff = "R095\0include/types.hpp\0include/polymarket/types.hpp\0M\0src/main.cpp\0" + with patch.object(quality, "run", return_value=diff): + self.assertEqual(quality.changed_files("base"), { + "include/polymarket/types.hpp": "include/types.hpp", + "src/main.cpp": "src/main.cpp" + }) + + def test_changed_ranges_ignore_deleted_lines(self): + diff = "@@ -1 +1 @@\n@@ -5,2 +5,0 @@\n@@ -10,0 +9,3 @@\n" + with patch.object(quality, "run", return_value=diff): + self.assertEqual(quality.changed_lines("base", "file.cpp"), [[1, 1], [9, 11]]) + + def test_added_duplicate_formatting_debt_is_rejected(self): + old = quality.formatting_debt("bad\n", "good\n") + new = quality.formatting_debt("bad\nbad\n", "good\ngood\n") + self.assertFalse(new <= old) + + def test_resolved_formatting_debt_is_allowed(self): + old = quality.formatting_debt("bad\n", "good\n") + new = quality.formatting_debt("good\n", "good\n") + self.assertLessEqual(new, old) + + +if __name__ == "__main__": + unittest.main() diff --git a/src/arb_runtime.hpp b/src/arb_runtime.hpp index adb9967..fe9d1be 100644 --- a/src/arb_runtime.hpp +++ b/src/arb_runtime.hpp @@ -1,8 +1,8 @@ #pragma once -#include "clob_client.hpp" -#include "market_fetcher.hpp" -#include "orderbook.hpp" +#include "polymarket/clob_client.hpp" +#include "polymarket/market_fetcher.hpp" +#include "polymarket/orderbook.hpp" #include #include diff --git a/src/arb_sizing.cpp b/src/arb_sizing.cpp index fa4bcdf..e53e113 100644 --- a/src/arb_sizing.cpp +++ b/src/arb_sizing.cpp @@ -1,4 +1,4 @@ -#include "orderbook.hpp" +#include "polymarket/orderbook.hpp" #include #include diff --git a/src/clob_account.cpp b/src/clob_account.cpp index dd4d337..7f2ea90 100644 --- a/src/clob_account.cpp +++ b/src/clob_account.cpp @@ -1,4 +1,4 @@ -#include "clob_client.hpp" +#include "polymarket/clob_client.hpp" #include "clob_client_internal.hpp" #include "opaque_cursor_pagination.hpp" diff --git a/src/clob_activity.cpp b/src/clob_activity.cpp index 2da99fc..5fa39ec 100644 --- a/src/clob_activity.cpp +++ b/src/clob_activity.cpp @@ -1,4 +1,4 @@ -#include "clob_client.hpp" +#include "polymarket/clob_client.hpp" #include "clob_client_internal.hpp" #include diff --git a/src/clob_activity_pagination.cpp b/src/clob_activity_pagination.cpp index 5c59b45..0137f87 100644 --- a/src/clob_activity_pagination.cpp +++ b/src/clob_activity_pagination.cpp @@ -1,4 +1,4 @@ -#include "clob_client.hpp" +#include "polymarket/clob_client.hpp" #include "clob_client_internal.hpp" #include "opaque_cursor_pagination.hpp" diff --git a/src/clob_books.cpp b/src/clob_books.cpp index e18b6f9..af9200e 100644 --- a/src/clob_books.cpp +++ b/src/clob_books.cpp @@ -1,4 +1,4 @@ -#include "clob_client.hpp" +#include "polymarket/clob_client.hpp" #include "clob_client_internal.hpp" #include diff --git a/src/clob_client.cpp b/src/clob_client.cpp index d73e832..dc291f2 100644 --- a/src/clob_client.cpp +++ b/src/clob_client.cpp @@ -1,9 +1,9 @@ -#include "clob_client.hpp" +#include "polymarket/clob_client.hpp" #include "clob_client_internal.hpp" -#include "market_fetcher.hpp" -#include "order_signer.hpp" +#include "polymarket/market_fetcher.hpp" +#include "polymarket/order_signer.hpp" #include "order_signer_auth_internal.hpp" -#include "polymarket_contracts.hpp" +#include "polymarket/polymarket_contracts.hpp" #include #include diff --git a/src/clob_client_internal.hpp b/src/clob_client_internal.hpp index 3117f59..3273a45 100644 --- a/src/clob_client_internal.hpp +++ b/src/clob_client_internal.hpp @@ -1,6 +1,6 @@ #pragma once -#include "clob_client.hpp" +#include "polymarket/clob_client.hpp" #include "query_encoding.hpp" #include "rest_numeric.hpp" diff --git a/src/clob_client_test_fixture.hpp b/src/clob_client_test_fixture.hpp index a15a08e..9df80a8 100644 --- a/src/clob_client_test_fixture.hpp +++ b/src/clob_client_test_fixture.hpp @@ -1,6 +1,6 @@ #pragma once -#include "clob_client.hpp" +#include "polymarket/clob_client.hpp" #include #include diff --git a/src/clob_market_metadata.cpp b/src/clob_market_metadata.cpp index 203248c..73ef4f5 100644 --- a/src/clob_market_metadata.cpp +++ b/src/clob_market_metadata.cpp @@ -1,4 +1,4 @@ -#include "clob_client.hpp" +#include "polymarket/clob_client.hpp" #include "clob_client_internal.hpp" #include diff --git a/src/clob_market_parsing.cpp b/src/clob_market_parsing.cpp index 8dc4cb1..8af558f 100644 --- a/src/clob_market_parsing.cpp +++ b/src/clob_market_parsing.cpp @@ -1,4 +1,4 @@ -#include "market_fetcher.hpp" +#include "polymarket/market_fetcher.hpp" #include "market_fee_parsing.hpp" #include "market_time.hpp" #include "rest_numeric.hpp" diff --git a/src/clob_order_execution.cpp b/src/clob_order_execution.cpp index 73c3bcc..4ecc279 100644 --- a/src/clob_order_execution.cpp +++ b/src/clob_order_execution.cpp @@ -1,6 +1,6 @@ -#include "clob_client.hpp" +#include "polymarket/clob_client.hpp" #include "order_execution.hpp" -#include "order_signer.hpp" +#include "polymarket/order_signer.hpp" #include namespace polymarket diff --git a/src/clob_order_submission.cpp b/src/clob_order_submission.cpp index ef918b3..ad5e44c 100644 --- a/src/clob_order_submission.cpp +++ b/src/clob_order_submission.cpp @@ -1,4 +1,4 @@ -#include "clob_client.hpp" +#include "polymarket/clob_client.hpp" #include "clob_client_internal.hpp" #include "order_execution.hpp" diff --git a/src/clob_parsing.cpp b/src/clob_parsing.cpp index 8290c33..afdcb7f 100644 --- a/src/clob_parsing.cpp +++ b/src/clob_parsing.cpp @@ -1,6 +1,6 @@ -#include "clob_client.hpp" +#include "polymarket/clob_client.hpp" #include "clob_client_internal.hpp" -#include "market_fetcher.hpp" +#include "polymarket/market_fetcher.hpp" #include "rest_orderbook_parsing.hpp" #include diff --git a/src/clob_positions.cpp b/src/clob_positions.cpp index 52ba3f2..dba7f0d 100644 --- a/src/clob_positions.cpp +++ b/src/clob_positions.cpp @@ -1,4 +1,4 @@ -#include "clob_client.hpp" +#include "polymarket/clob_client.hpp" #include "clob_positions_internal.hpp" namespace polymarket diff --git a/src/clob_positions_internal.hpp b/src/clob_positions_internal.hpp index 9ec6675..107a9da 100644 --- a/src/clob_positions_internal.hpp +++ b/src/clob_positions_internal.hpp @@ -1,7 +1,7 @@ #pragma once -#include "clob_types.hpp" -#include "http_client.hpp" +#include "polymarket/clob_types.hpp" +#include "polymarket/http_client.hpp" #include #include diff --git a/src/decimal_math.cpp b/src/decimal_math.cpp index f72dad7..a3c6353 100644 --- a/src/decimal_math.cpp +++ b/src/decimal_math.cpp @@ -1,4 +1,4 @@ -#include "decimal_math.hpp" +#include "polymarket/decimal_math.hpp" #include #include diff --git a/src/evm_abi.cpp b/src/evm_abi.cpp index 8e42533..f6b5682 100644 --- a/src/evm_abi.cpp +++ b/src/evm_abi.cpp @@ -1,6 +1,6 @@ -#include "evm_abi.hpp" +#include "polymarket/evm_abi.hpp" #include "evm_uint.hpp" -#include "order_signer.hpp" +#include "polymarket/order_signer.hpp" #include #include diff --git a/src/evm_cursor_store.cpp b/src/evm_cursor_store.cpp index a0908fa..4917b0e 100644 --- a/src/evm_cursor_store.cpp +++ b/src/evm_cursor_store.cpp @@ -1,4 +1,4 @@ -#include "evm_event_indexer.hpp" +#include "polymarket/evm_event_indexer.hpp" #include "evm_cursor_io.hpp" #include #include diff --git a/src/evm_event_indexer.cpp b/src/evm_event_indexer.cpp index 0436f77..9bd707f 100644 --- a/src/evm_event_indexer.cpp +++ b/src/evm_event_indexer.cpp @@ -1,4 +1,4 @@ -#include "evm_event_indexer.hpp" +#include "polymarket/evm_event_indexer.hpp" #include "evm_indexer_transport.hpp" #include "evm_log_identity.hpp" #include diff --git a/src/evm_indexer_impl.hpp b/src/evm_indexer_impl.hpp index 0862508..bcce774 100644 --- a/src/evm_indexer_impl.hpp +++ b/src/evm_indexer_impl.hpp @@ -1,6 +1,6 @@ #pragma once -#include "evm_event_indexer.hpp" +#include "polymarket/evm_event_indexer.hpp" #include namespace polymarket::detail diff --git a/src/evm_indexer_transport.cpp b/src/evm_indexer_transport.cpp index 2673806..edbe62b 100644 --- a/src/evm_indexer_transport.cpp +++ b/src/evm_indexer_transport.cpp @@ -1,7 +1,7 @@ #include "evm_indexer_transport.hpp" #include "evm_transport_epoch.hpp" -#include "json_rpc_client.hpp" -#include "websocket_client.hpp" +#include "polymarket/json_rpc_client.hpp" +#include "polymarket/websocket_client.hpp" #include #include #include diff --git a/src/evm_log_identity.hpp b/src/evm_log_identity.hpp index 507cf93..d8c302c 100644 --- a/src/evm_log_identity.hpp +++ b/src/evm_log_identity.hpp @@ -1,6 +1,6 @@ #pragma once -#include "evm_event_indexer.hpp" +#include "polymarket/evm_event_indexer.hpp" namespace polymarket::detail { diff --git a/src/evm_transaction.cpp b/src/evm_transaction.cpp index c2e8757..65f04a8 100644 --- a/src/evm_transaction.cpp +++ b/src/evm_transaction.cpp @@ -1,7 +1,7 @@ -#include "evm_transaction.hpp" +#include "polymarket/evm_transaction.hpp" #include "evm_rlp.hpp" #include "evm_uint.hpp" -#include "order_signer.hpp" +#include "polymarket/order_signer.hpp" #include #include diff --git a/src/evm_uint.cpp b/src/evm_uint.cpp index 1b036d0..dac1ab6 100644 --- a/src/evm_uint.cpp +++ b/src/evm_uint.cpp @@ -1,5 +1,5 @@ #include "evm_uint.hpp" -#include "order_signer.hpp" +#include "polymarket/order_signer.hpp" #include namespace polymarket::detail diff --git a/src/evm_utils.cpp b/src/evm_utils.cpp index 273af7f..7dd7133 100644 --- a/src/evm_utils.cpp +++ b/src/evm_utils.cpp @@ -1,5 +1,5 @@ -#include "evm_utils.hpp" -#include "order_signer.hpp" +#include "polymarket/evm_utils.hpp" +#include "polymarket/order_signer.hpp" #include #include #include diff --git a/src/gamma_market_fetcher.cpp b/src/gamma_market_fetcher.cpp index baf72bf..7452545 100644 --- a/src/gamma_market_fetcher.cpp +++ b/src/gamma_market_fetcher.cpp @@ -1,4 +1,4 @@ -#include "market_fetcher.hpp" +#include "polymarket/market_fetcher.hpp" #include "bounded_workers.hpp" #include "market_time.hpp" diff --git a/src/http_client.cpp b/src/http_client.cpp index 9d76f2b..4e91914 100644 --- a/src/http_client.cpp +++ b/src/http_client.cpp @@ -1,4 +1,4 @@ -#include "http_client.hpp" +#include "polymarket/http_client.hpp" #include "http_global.hpp" #include #include diff --git a/src/http_client_connection.cpp b/src/http_client_connection.cpp index 0802e23..80fdf9b 100644 --- a/src/http_client_connection.cpp +++ b/src/http_client_connection.cpp @@ -1,4 +1,4 @@ -#include "http_client.hpp" +#include "polymarket/http_client.hpp" #include #include diff --git a/src/http_client_request.cpp b/src/http_client_request.cpp index 36d6c28..01fb383 100644 --- a/src/http_client_request.cpp +++ b/src/http_client_request.cpp @@ -1,4 +1,4 @@ -#include "http_client.hpp" +#include "polymarket/http_client.hpp" #include #include diff --git a/src/json_rpc_client.cpp b/src/json_rpc_client.cpp index 554951e..5e7c2e9 100644 --- a/src/json_rpc_client.cpp +++ b/src/json_rpc_client.cpp @@ -1,4 +1,4 @@ -#include "json_rpc_client.hpp" +#include "polymarket/json_rpc_client.hpp" #include "json_rpc_ws_runtime.hpp" #include diff --git a/src/json_rpc_transactions.cpp b/src/json_rpc_transactions.cpp index b4efff2..485c1c0 100644 --- a/src/json_rpc_transactions.cpp +++ b/src/json_rpc_transactions.cpp @@ -1,4 +1,4 @@ -#include "json_rpc_client.hpp" +#include "polymarket/json_rpc_client.hpp" #include #include diff --git a/src/json_rpc_ws_runtime.hpp b/src/json_rpc_ws_runtime.hpp index 1b4f1f3..c3b8d99 100644 --- a/src/json_rpc_ws_runtime.hpp +++ b/src/json_rpc_ws_runtime.hpp @@ -1,7 +1,7 @@ #pragma once -#include "json_rpc_client.hpp" -#include "websocket_client.hpp" +#include "polymarket/json_rpc_client.hpp" +#include "polymarket/websocket_client.hpp" #include #include diff --git a/src/market_discovery.cpp b/src/market_discovery.cpp index 5ca2054..a66765d 100644 --- a/src/market_discovery.cpp +++ b/src/market_discovery.cpp @@ -1,4 +1,4 @@ -#include "market_fetcher.hpp" +#include "polymarket/market_fetcher.hpp" #include "market_fee_parsing.hpp" #include "market_time.hpp" #include "rest_numeric.hpp" diff --git a/src/market_fetcher.cpp b/src/market_fetcher.cpp index 7c49f74..bb5b432 100644 --- a/src/market_fetcher.cpp +++ b/src/market_fetcher.cpp @@ -1,4 +1,4 @@ -#include "market_fetcher.hpp" +#include "polymarket/market_fetcher.hpp" #include "query_encoding.hpp" #include "rest_orderbook_parsing.hpp" #include diff --git a/src/market_time.cpp b/src/market_time.cpp index 752b59c..e8c22bb 100644 --- a/src/market_time.cpp +++ b/src/market_time.cpp @@ -1,4 +1,4 @@ -#include "market_fetcher.hpp" +#include "polymarket/market_fetcher.hpp" #include "market_time.hpp" #include diff --git a/src/oracle_event_history.cpp b/src/oracle_event_history.cpp index 55d6ec1..7e02bf5 100644 --- a/src/oracle_event_history.cpp +++ b/src/oracle_event_history.cpp @@ -1,5 +1,5 @@ -#include "oracle_watcher.hpp" -#include "evm_event_indexer.hpp" +#include "polymarket/oracle_watcher.hpp" +#include "polymarket/evm_event_indexer.hpp" #include #include diff --git a/src/oracle_watcher.cpp b/src/oracle_watcher.cpp index 58a17c9..3f855f2 100644 --- a/src/oracle_watcher.cpp +++ b/src/oracle_watcher.cpp @@ -1,5 +1,5 @@ -#include "oracle_watcher.hpp" -#include "evm_event_indexer.hpp" +#include "polymarket/oracle_watcher.hpp" +#include "polymarket/evm_event_indexer.hpp" #include namespace polymarket diff --git a/src/order_amounts.cpp b/src/order_amounts.cpp index b0614e1..f6e3dac 100644 --- a/src/order_amounts.cpp +++ b/src/order_amounts.cpp @@ -1,6 +1,6 @@ #include "order_execution.hpp" -#include "decimal_math.hpp" +#include "polymarket/decimal_math.hpp" #include #include diff --git a/src/order_execution.cpp b/src/order_execution.cpp index c0f40f4..55829c1 100644 --- a/src/order_execution.cpp +++ b/src/order_execution.cpp @@ -1,5 +1,5 @@ #include "order_execution.hpp" -#include "decimal_math.hpp" +#include "polymarket/decimal_math.hpp" #include #include diff --git a/src/order_execution.hpp b/src/order_execution.hpp index 3873749..39715e1 100644 --- a/src/order_execution.hpp +++ b/src/order_execution.hpp @@ -1,6 +1,6 @@ #pragma once -#include "clob_client.hpp" +#include "polymarket/clob_client.hpp" #include #include #include diff --git a/src/order_signer.cpp b/src/order_signer.cpp index 26c6947..cbc8a3b 100644 --- a/src/order_signer.cpp +++ b/src/order_signer.cpp @@ -1,5 +1,5 @@ -#include "order_signer.hpp" -#include "decimal_math.hpp" +#include "polymarket/order_signer.hpp" +#include "polymarket/decimal_math.hpp" #include #include #include diff --git a/src/order_signer_auth.cpp b/src/order_signer_auth.cpp index 24e4c62..ba4279b 100644 --- a/src/order_signer_auth.cpp +++ b/src/order_signer_auth.cpp @@ -1,5 +1,5 @@ -#include "order_signer.hpp" -#include "http_client.hpp" +#include "polymarket/order_signer.hpp" +#include "polymarket/http_client.hpp" #include "order_signer_auth_internal.hpp" #include diff --git a/src/order_signer_auth_internal.hpp b/src/order_signer_auth_internal.hpp index 3007f67..566406e 100644 --- a/src/order_signer_auth_internal.hpp +++ b/src/order_signer_auth_internal.hpp @@ -1,6 +1,6 @@ #pragma once -#include "order_signer.hpp" +#include "polymarket/order_signer.hpp" namespace polymarket::detail { diff --git a/src/order_signer_domain.cpp b/src/order_signer_domain.cpp index 4417a1d..5e95109 100644 --- a/src/order_signer_domain.cpp +++ b/src/order_signer_domain.cpp @@ -1,4 +1,4 @@ -#include "order_signer.hpp" +#include "polymarket/order_signer.hpp" #include #include diff --git a/src/order_signer_v2.cpp b/src/order_signer_v2.cpp index d16a22a..ec4f2c3 100644 --- a/src/order_signer_v2.cpp +++ b/src/order_signer_v2.cpp @@ -1,4 +1,4 @@ -#include "order_signer.hpp" +#include "polymarket/order_signer.hpp" #include #include diff --git a/src/order_test.cpp b/src/order_test.cpp index 18eaa9c..34cdf5b 100644 --- a/src/order_test.cpp +++ b/src/order_test.cpp @@ -11,9 +11,9 @@ * PRIVATE_KEY=0x... FUNDER_ADDRESS=0x... ./order_test [--live] */ -#include "order_signer.hpp" +#include "polymarket/order_signer.hpp" #include "order_test_live.hpp" -#include "http_client.hpp" +#include "polymarket/http_client.hpp" #include #include #include diff --git a/src/order_test_live.cpp b/src/order_test_live.cpp index eaecb97..f1678cc 100644 --- a/src/order_test_live.cpp +++ b/src/order_test_live.cpp @@ -1,7 +1,7 @@ #include "order_test_live.hpp" -#include "clob_client.hpp" -#include "http_client.hpp" +#include "polymarket/clob_client.hpp" +#include "polymarket/http_client.hpp" #include diff --git a/src/order_test_live.hpp b/src/order_test_live.hpp index 1228eef..9b29ea9 100644 --- a/src/order_test_live.hpp +++ b/src/order_test_live.hpp @@ -1,6 +1,6 @@ #pragma once -#include "order_signer.hpp" +#include "polymarket/order_signer.hpp" #include diff --git a/src/orderbook.cpp b/src/orderbook.cpp index cc40131..6f2d554 100644 --- a/src/orderbook.cpp +++ b/src/orderbook.cpp @@ -1,4 +1,4 @@ -#include "orderbook.hpp" +#include "polymarket/orderbook.hpp" #include "orderbook_runtime.hpp" namespace polymarket diff --git a/src/orderbook_runtime.hpp b/src/orderbook_runtime.hpp index 1cfd64d..87f5448 100644 --- a/src/orderbook_runtime.hpp +++ b/src/orderbook_runtime.hpp @@ -1,7 +1,7 @@ #pragma once -#include "orderbook.hpp" -#include "websocket_client.hpp" +#include "polymarket/orderbook.hpp" +#include "polymarket/websocket_client.hpp" #include #include diff --git a/src/orderbook_stream.hpp b/src/orderbook_stream.hpp index 725f6af..2e363b4 100644 --- a/src/orderbook_stream.hpp +++ b/src/orderbook_stream.hpp @@ -1,6 +1,6 @@ #pragma once -#include "orderbook.hpp" +#include "polymarket/orderbook.hpp" #include "websocket_resilience.hpp" #include diff --git a/src/orderbook_subscription.cpp b/src/orderbook_subscription.cpp index 7e92ff3..095a639 100644 --- a/src/orderbook_subscription.cpp +++ b/src/orderbook_subscription.cpp @@ -1,5 +1,5 @@ #include "orderbook_subscription.hpp" -#include "websocket_client.hpp" +#include "polymarket/websocket_client.hpp" namespace polymarket::detail { diff --git a/src/polymarket_contracts.cpp b/src/polymarket_contracts.cpp index ce7abc3..4f74377 100644 --- a/src/polymarket_contracts.cpp +++ b/src/polymarket_contracts.cpp @@ -1,5 +1,5 @@ -#include "polymarket_contracts.hpp" -#include "order_signer.hpp" +#include "polymarket/polymarket_contracts.hpp" +#include "polymarket/order_signer.hpp" #include #include #include diff --git a/src/polymarket_events.cpp b/src/polymarket_events.cpp index 1ab3bcc..532dd8b 100644 --- a/src/polymarket_events.cpp +++ b/src/polymarket_events.cpp @@ -1,4 +1,4 @@ -#include "polymarket_events.hpp" +#include "polymarket/polymarket_events.hpp" #include #include diff --git a/src/position_calls.cpp b/src/position_calls.cpp index de4d603..8be266f 100644 --- a/src/position_calls.cpp +++ b/src/position_calls.cpp @@ -1,7 +1,7 @@ #include "position_calls.hpp" -#include "evm_abi.hpp" +#include "polymarket/evm_abi.hpp" #include "evm_uint.hpp" -#include "evm_utils.hpp" +#include "polymarket/evm_utils.hpp" #include #include #include diff --git a/src/position_calls.hpp b/src/position_calls.hpp index a460db8..fc2ec99 100644 --- a/src/position_calls.hpp +++ b/src/position_calls.hpp @@ -1,7 +1,7 @@ #pragma once -#include "polymarket_contracts.hpp" -#include "position_client.hpp" +#include "polymarket/polymarket_contracts.hpp" +#include "polymarket/position_client.hpp" #include #include #include diff --git a/src/position_client.cpp b/src/position_client.cpp index f32d8b1..1ee1546 100644 --- a/src/position_client.cpp +++ b/src/position_client.cpp @@ -1,4 +1,4 @@ -#include "position_client.hpp" +#include "polymarket/position_client.hpp" #include "position_calls.hpp" #include "position_client_impl.hpp" #include diff --git a/src/position_client_impl.hpp b/src/position_client_impl.hpp index 080934b..928b01e 100644 --- a/src/position_client_impl.hpp +++ b/src/position_client_impl.hpp @@ -1,8 +1,8 @@ #pragma once -#include "http_client.hpp" -#include "order_signer.hpp" -#include "position_client.hpp" +#include "polymarket/http_client.hpp" +#include "polymarket/order_signer.hpp" +#include "polymarket/position_client.hpp" #include "safe_relayer.hpp" #include #include diff --git a/src/position_gamma.cpp b/src/position_gamma.cpp index 431f36c..f775c1b 100644 --- a/src/position_gamma.cpp +++ b/src/position_gamma.cpp @@ -1,5 +1,5 @@ #include "evm_uint.hpp" -#include "evm_utils.hpp" +#include "polymarket/evm_utils.hpp" #include "position_calls.hpp" #include diff --git a/src/position_senders.cpp b/src/position_senders.cpp index e47fb23..7d71e9c 100644 --- a/src/position_senders.cpp +++ b/src/position_senders.cpp @@ -1,6 +1,6 @@ -#include "evm_transaction.hpp" +#include "polymarket/evm_transaction.hpp" #include "evm_uint.hpp" -#include "evm_utils.hpp" +#include "polymarket/evm_utils.hpp" #include "position_client_impl.hpp" #include "transaction_waiters.hpp" #include diff --git a/src/rest_orderbook_parsing.hpp b/src/rest_orderbook_parsing.hpp index b6a47d2..9e309da 100644 --- a/src/rest_orderbook_parsing.hpp +++ b/src/rest_orderbook_parsing.hpp @@ -1,7 +1,7 @@ #pragma once #include "rest_numeric.hpp" -#include "types.hpp" +#include "polymarket/types.hpp" #include diff --git a/src/safe_relayer.cpp b/src/safe_relayer.cpp index 712eda0..c186941 100644 --- a/src/safe_relayer.cpp +++ b/src/safe_relayer.cpp @@ -1,8 +1,8 @@ #include "safe_relayer.hpp" -#include "evm_abi.hpp" +#include "polymarket/evm_abi.hpp" #include "evm_uint.hpp" -#include "evm_utils.hpp" -#include "order_signer.hpp" +#include "polymarket/evm_utils.hpp" +#include "polymarket/order_signer.hpp" #include "position_calls.hpp" #include #include diff --git a/src/safe_relayer.hpp b/src/safe_relayer.hpp index ca2fb1b..7cf8deb 100644 --- a/src/safe_relayer.hpp +++ b/src/safe_relayer.hpp @@ -1,8 +1,8 @@ #pragma once -#include "http_client.hpp" -#include "polymarket_contracts.hpp" -#include "position_client.hpp" +#include "polymarket/http_client.hpp" +#include "polymarket/polymarket_contracts.hpp" +#include "polymarket/position_client.hpp" #include #include #include diff --git a/src/sdk_error.cpp b/src/sdk_error.cpp index 87c4ff4..bfc9518 100644 --- a/src/sdk_error.cpp +++ b/src/sdk_error.cpp @@ -1,4 +1,4 @@ -#include "sdk_error.hpp" +#include "polymarket/sdk_error.hpp" #include #include #include diff --git a/src/transaction_waiters.hpp b/src/transaction_waiters.hpp index 0c8892a..3931f0b 100644 --- a/src/transaction_waiters.hpp +++ b/src/transaction_waiters.hpp @@ -1,7 +1,7 @@ #pragma once -#include "json_rpc_client.hpp" -#include "position_client.hpp" +#include "polymarket/json_rpc_client.hpp" +#include "polymarket/position_client.hpp" #include "safe_relayer.hpp" #include #include diff --git a/src/user_stream.cpp b/src/user_stream.cpp index 3d8025b..93413c1 100644 --- a/src/user_stream.cpp +++ b/src/user_stream.cpp @@ -1,4 +1,4 @@ -#include "user_stream.hpp" +#include "polymarket/user_stream.hpp" #include "user_stream_runtime.hpp" namespace polymarket diff --git a/src/user_stream_protocol.hpp b/src/user_stream_protocol.hpp index 7ed249d..dcac209 100644 --- a/src/user_stream_protocol.hpp +++ b/src/user_stream_protocol.hpp @@ -1,6 +1,6 @@ #pragma once -#include "user_stream.hpp" +#include "polymarket/user_stream.hpp" #include #include diff --git a/src/user_stream_runtime.hpp b/src/user_stream_runtime.hpp index a40cc1a..562d0de 100644 --- a/src/user_stream_runtime.hpp +++ b/src/user_stream_runtime.hpp @@ -1,8 +1,8 @@ #pragma once -#include "user_stream.hpp" +#include "polymarket/user_stream.hpp" #include "user_stream_protocol.hpp" -#include "websocket_client.hpp" +#include "polymarket/websocket_client.hpp" #include #include diff --git a/src/websocket_client.cpp b/src/websocket_client.cpp index a67ed4a..784b0b8 100644 --- a/src/websocket_client.cpp +++ b/src/websocket_client.cpp @@ -1,4 +1,4 @@ -#include "websocket_client.hpp" +#include "polymarket/websocket_client.hpp" #include "websocket_client_state.hpp" namespace polymarket diff --git a/src/websocket_client_state.hpp b/src/websocket_client_state.hpp index 1b77058..10c3722 100644 --- a/src/websocket_client_state.hpp +++ b/src/websocket_client_state.hpp @@ -1,6 +1,6 @@ #pragma once -#include "websocket_client.hpp" +#include "polymarket/websocket_client.hpp" #include #include diff --git a/src/websocket_resilience.hpp b/src/websocket_resilience.hpp index d527e31..3e1eb09 100644 --- a/src/websocket_resilience.hpp +++ b/src/websocket_resilience.hpp @@ -1,7 +1,7 @@ #pragma once -#include "websocket_client.hpp" -#include "types.hpp" +#include "polymarket/websocket_client.hpp" +#include "polymarket/types.hpp" #include #include #include diff --git a/tests/evm_event_indexer_test_support.hpp b/tests/evm_event_indexer_test_support.hpp index db3e9cb..c89fd14 100644 --- a/tests/evm_event_indexer_test_support.hpp +++ b/tests/evm_event_indexer_test_support.hpp @@ -1,6 +1,6 @@ #pragma once -#include "evm_event_indexer.hpp" +#include "polymarket/evm_event_indexer.hpp" #include #include #include diff --git a/tests/package_consumer/CMakeLists.txt b/tests/package_consumer/CMakeLists.txt index f14d1e1..90d5cac 100644 --- a/tests/package_consumer/CMakeLists.txt +++ b/tests/package_consumer/CMakeLists.txt @@ -4,6 +4,8 @@ project(polymarket_package_consumer LANGUAGES CXX) find_package(polymarket_client CONFIG REQUIRED) add_executable(polymarket_package_consumer main.cpp) +target_include_directories(polymarket_package_consumer BEFORE PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}) target_link_libraries(polymarket_package_consumer PRIVATE polymarket::client) add_library(polymarket_package_plugin SHARED plugin.cpp) diff --git a/tests/package_consumer/http_client.hpp b/tests/package_consumer/http_client.hpp new file mode 100644 index 0000000..5f1b53c --- /dev/null +++ b/tests/package_consumer/http_client.hpp @@ -0,0 +1,7 @@ +#pragma once + +// A consumer-owned header must coexist with the namespaced SDK header. +namespace consumer +{ + inline constexpr bool http_client_header_loaded = true; +} diff --git a/tests/package_consumer/main.cpp b/tests/package_consumer/main.cpp index 09986f5..168fdf4 100644 --- a/tests/package_consumer/main.cpp +++ b/tests/package_consumer/main.cpp @@ -1,11 +1,19 @@ -#include -#include #include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include -#include +#include +#include +#include +#include + +#include int main() { @@ -13,12 +21,25 @@ int main() { polymarket::HttpClient client; const polymarket::Config config; + const polymarket::PositionClientConfig position_config; + if (position_config.contracts.chain_id != 137 || + polymarket::evm_function_selector("transfer(address,uint256)") != "0xa9059cbb") + return 1; + // The installed stream must link and reject absent credentials without connecting. + try + { + polymarket::UserStream stream(config, {}); + return 1; + } + catch (const std::invalid_argument &) + { + } const polymarket::EvmEventIndexerConfig evm_config; const polymarket::OracleResolutionState oracle_state; const polymarket::WebSocketOptions websocket_options; - if (client.options().timeout_ms <= 0 || config.clob_ws_url.empty() || - evm_config.batch_size == 0 || oracle_state.events_seen != 0 || - websocket_options.message_queue_limit == 0 || + if (!consumer::http_client_header_loaded || client.options().timeout_ms <= 0 || + config.clob_ws_url.empty() || evm_config.batch_size == 0 || + oracle_state.events_seen != 0 || websocket_options.message_queue_limit == 0 || polymarket::version_major <= 0) return 1; } diff --git a/tests/package_consumer/plugin.cpp b/tests/package_consumer/plugin.cpp index 2428302..1d3e58e 100644 --- a/tests/package_consumer/plugin.cpp +++ b/tests/package_consumer/plugin.cpp @@ -1,4 +1,4 @@ -#include +#include extern "C" int polymarket_package_plugin_probe() { diff --git a/tests/position_test_support.hpp b/tests/position_test_support.hpp index 0b846bd..639165e 100644 --- a/tests/position_test_support.hpp +++ b/tests/position_test_support.hpp @@ -1,10 +1,10 @@ #pragma once #include "check_support.hpp" -#include "evm_abi.hpp" -#include "order_signer.hpp" +#include "polymarket/evm_abi.hpp" +#include "polymarket/order_signer.hpp" #include "position_calls.hpp" -#include "position_client.hpp" +#include "polymarket/position_client.hpp" #include "../src/clob_client_test_fixture.hpp" #include diff --git a/tests/test_arb_sizing.cpp b/tests/test_arb_sizing.cpp index 311d95f..61057fa 100644 --- a/tests/test_arb_sizing.cpp +++ b/tests/test_arb_sizing.cpp @@ -1,5 +1,5 @@ #include "arb_runtime.hpp" -#include "orderbook.hpp" +#include "polymarket/orderbook.hpp" #include #include diff --git a/tests/test_arb_stream_admission.cpp b/tests/test_arb_stream_admission.cpp index 5718b55..47277c8 100644 --- a/tests/test_arb_stream_admission.cpp +++ b/tests/test_arb_stream_admission.cpp @@ -1,4 +1,4 @@ -#include "orderbook.hpp" +#include "polymarket/orderbook.hpp" #include "websocket_test_server.hpp" #include diff --git a/tests/test_clob_positions.cpp b/tests/test_clob_positions.cpp index 020313d..355702a 100644 --- a/tests/test_clob_positions.cpp +++ b/tests/test_clob_positions.cpp @@ -1,4 +1,4 @@ -#include "clob_client.hpp" +#include "polymarket/clob_client.hpp" #include "clob_positions_internal.hpp" #include diff --git a/tests/test_evm_abi.cpp b/tests/test_evm_abi.cpp index 2539f6a..a515442 100644 --- a/tests/test_evm_abi.cpp +++ b/tests/test_evm_abi.cpp @@ -1,5 +1,5 @@ #include "check_support.hpp" -#include "evm_abi.hpp" +#include "polymarket/evm_abi.hpp" #include #include #include diff --git a/tests/test_evm_abi_shapes.cpp b/tests/test_evm_abi_shapes.cpp index 5e67432..648fd9b 100644 --- a/tests/test_evm_abi_shapes.cpp +++ b/tests/test_evm_abi_shapes.cpp @@ -1,5 +1,5 @@ #include "check_support.hpp" -#include "evm_abi.hpp" +#include "polymarket/evm_abi.hpp" #include #include #include diff --git a/tests/test_evm_event_indexer.cpp b/tests/test_evm_event_indexer.cpp index e79984e..85407f5 100644 --- a/tests/test_evm_event_indexer.cpp +++ b/tests/test_evm_event_indexer.cpp @@ -1,4 +1,4 @@ -#include "evm_event_indexer.hpp" +#include "polymarket/evm_event_indexer.hpp" #include "evm_indexer_adversarial_tests.hpp" #include "evm_indexer_delivery_tests.hpp" #include "evm_indexer_handoff_overflow_tests.hpp" diff --git a/tests/test_evm_events.cpp b/tests/test_evm_events.cpp index f4a90b2..bdc27c7 100644 --- a/tests/test_evm_events.cpp +++ b/tests/test_evm_events.cpp @@ -1,5 +1,5 @@ -#include "evm_utils.hpp" -#include "polymarket_events.hpp" +#include "polymarket/evm_utils.hpp" +#include "polymarket/polymarket_events.hpp" #include #include #include diff --git a/tests/test_evm_transaction.cpp b/tests/test_evm_transaction.cpp index 197795b..493dc03 100644 --- a/tests/test_evm_transaction.cpp +++ b/tests/test_evm_transaction.cpp @@ -1,7 +1,7 @@ -#include "evm_abi.hpp" +#include "polymarket/evm_abi.hpp" #include "evm_rlp.hpp" -#include "evm_transaction.hpp" -#include "order_signer.hpp" +#include "polymarket/evm_transaction.hpp" +#include "polymarket/order_signer.hpp" #include #include #include diff --git a/tests/test_http_client_transport.cpp b/tests/test_http_client_transport.cpp index be896e6..4b66a1b 100644 --- a/tests/test_http_client_transport.cpp +++ b/tests/test_http_client_transport.cpp @@ -1,7 +1,7 @@ -#include "clob_client.hpp" -#include "http_client.hpp" +#include "polymarket/clob_client.hpp" +#include "polymarket/http_client.hpp" #include "http_client_transport_fixture.hpp" -#include "sdk_error.hpp" +#include "polymarket/sdk_error.hpp" #include #include diff --git a/tests/test_http_global_lifetime.cpp b/tests/test_http_global_lifetime.cpp index f5b1968..5d88d27 100644 --- a/tests/test_http_global_lifetime.cpp +++ b/tests/test_http_global_lifetime.cpp @@ -1,4 +1,4 @@ -#include "http_client.hpp" +#include "polymarket/http_client.hpp" #include "http_global.hpp" #include diff --git a/tests/test_json_rpc_http_concurrency.cpp b/tests/test_json_rpc_http_concurrency.cpp index ef4b6e4..56fb908 100644 --- a/tests/test_json_rpc_http_concurrency.cpp +++ b/tests/test_json_rpc_http_concurrency.cpp @@ -1,4 +1,4 @@ -#include "json_rpc_client.hpp" +#include "polymarket/json_rpc_client.hpp" #include "../src/clob_client_test_fixture.hpp" #include diff --git a/tests/test_json_rpc_http_integrity.cpp b/tests/test_json_rpc_http_integrity.cpp index 0720045..de739fe 100644 --- a/tests/test_json_rpc_http_integrity.cpp +++ b/tests/test_json_rpc_http_integrity.cpp @@ -1,5 +1,5 @@ -#include "evm_event_indexer.hpp" -#include "json_rpc_client.hpp" +#include "polymarket/evm_event_indexer.hpp" +#include "polymarket/json_rpc_client.hpp" #include "../src/clob_client_test_fixture.hpp" #include diff --git a/tests/test_json_rpc_transactions.cpp b/tests/test_json_rpc_transactions.cpp index 883d314..e60b7bd 100644 --- a/tests/test_json_rpc_transactions.cpp +++ b/tests/test_json_rpc_transactions.cpp @@ -1,4 +1,4 @@ -#include "json_rpc_client.hpp" +#include "polymarket/json_rpc_client.hpp" #include "../src/clob_client_test_fixture.hpp" #include diff --git a/tests/test_json_rpc_ws_owner_reset.cpp b/tests/test_json_rpc_ws_owner_reset.cpp index 02f985a..1c1a6d2 100644 --- a/tests/test_json_rpc_ws_owner_reset.cpp +++ b/tests/test_json_rpc_ws_owner_reset.cpp @@ -1,4 +1,4 @@ -#include "json_rpc_client.hpp" +#include "polymarket/json_rpc_client.hpp" #include "websocket_test_server.hpp" #include diff --git a/tests/test_market_data_numeric_contracts.cpp b/tests/test_market_data_numeric_contracts.cpp index 371e925..c4a4658 100644 --- a/tests/test_market_data_numeric_contracts.cpp +++ b/tests/test_market_data_numeric_contracts.cpp @@ -1,6 +1,6 @@ -#include "clob_client.hpp" +#include "polymarket/clob_client.hpp" #include "clob_client_test_fixture.hpp" -#include "market_fetcher.hpp" +#include "polymarket/market_fetcher.hpp" #include #include diff --git a/tests/test_market_discovery.cpp b/tests/test_market_discovery.cpp index 2719250..c92a20d 100644 --- a/tests/test_market_discovery.cpp +++ b/tests/test_market_discovery.cpp @@ -1,4 +1,4 @@ -#include "market_fetcher.hpp" +#include "polymarket/market_fetcher.hpp" #include "bounded_workers.hpp" #include "clob_client_test_fixture.hpp" #include "market_time.hpp" diff --git a/tests/test_oracle_watcher.cpp b/tests/test_oracle_watcher.cpp index 4ec6c18..0ac4f8f 100644 --- a/tests/test_oracle_watcher.cpp +++ b/tests/test_oracle_watcher.cpp @@ -1,5 +1,5 @@ -#include "oracle_watcher.hpp" -#include "polymarket_events.hpp" +#include "polymarket/oracle_watcher.hpp" +#include "polymarket/polymarket_events.hpp" #include #include #include diff --git a/tests/test_oracle_watcher_historical.cpp b/tests/test_oracle_watcher_historical.cpp index 4cb3b50..ed2d0f9 100644 --- a/tests/test_oracle_watcher_historical.cpp +++ b/tests/test_oracle_watcher_historical.cpp @@ -1,7 +1,7 @@ -#include "evm_event_indexer.hpp" -#include "json_rpc_client.hpp" -#include "oracle_watcher.hpp" -#include "polymarket_events.hpp" +#include "polymarket/evm_event_indexer.hpp" +#include "polymarket/json_rpc_client.hpp" +#include "polymarket/oracle_watcher.hpp" +#include "polymarket/polymarket_events.hpp" #include #include #include diff --git a/tests/test_order_signer_v2.cpp b/tests/test_order_signer_v2.cpp index 180471e..b110856 100644 --- a/tests/test_order_signer_v2.cpp +++ b/tests/test_order_signer_v2.cpp @@ -1,4 +1,4 @@ -#include "order_signer.hpp" +#include "polymarket/order_signer.hpp" #include #include diff --git a/tests/test_order_type_serialization.cpp b/tests/test_order_type_serialization.cpp index 20c6903..fc2050a 100644 --- a/tests/test_order_type_serialization.cpp +++ b/tests/test_order_type_serialization.cpp @@ -1,8 +1,8 @@ -#include "http_client.hpp" -#include "clob_types.hpp" -#include "order_signer.hpp" -#include "sdk_error.hpp" -#include "types.hpp" +#include "polymarket/http_client.hpp" +#include "polymarket/clob_types.hpp" +#include "polymarket/order_signer.hpp" +#include "polymarket/sdk_error.hpp" +#include "polymarket/types.hpp" #include #include @@ -12,7 +12,7 @@ #include #define private public -#include "clob_client.hpp" +#include "polymarket/clob_client.hpp" #undef private using namespace polymarket; diff --git a/tests/test_orderbook_owner_reset.cpp b/tests/test_orderbook_owner_reset.cpp index 03d1599..240f1de 100644 --- a/tests/test_orderbook_owner_reset.cpp +++ b/tests/test_orderbook_owner_reset.cpp @@ -1,4 +1,4 @@ -#include "orderbook.hpp" +#include "polymarket/orderbook.hpp" #include "websocket_test_server.hpp" #include diff --git a/tests/test_orderbook_stream.cpp b/tests/test_orderbook_stream.cpp index 99c7119..42749eb 100644 --- a/tests/test_orderbook_stream.cpp +++ b/tests/test_orderbook_stream.cpp @@ -1,4 +1,4 @@ -#include "orderbook.hpp" +#include "polymarket/orderbook.hpp" #include "orderbook_subscription.hpp" #include "orderbook_stream.hpp" #include "websocket_resilience.hpp" diff --git a/tests/test_package_consumer.cmake b/tests/test_package_consumer.cmake index 2965e06..33f9a3b 100644 --- a/tests/test_package_consumer.cmake +++ b/tests/test_package_consumer.cmake @@ -12,6 +12,18 @@ if(NOT install_result EQUAL 0) message(FATAL_ERROR "installing the package failed") endif() +file(GLOB flat_public_headers "${install_dir}/include/*.hpp") +if(flat_public_headers) + message(FATAL_ERROR "SDK public headers must install under include/polymarket") +endif() +file(GLOB public_headers "${SOURCE_DIR}/include/polymarket/*.hpp") +foreach(public_header IN LISTS public_headers) + get_filename_component(header_name "${public_header}" NAME) + if(NOT EXISTS "${install_dir}/include/polymarket/${header_name}") + message(FATAL_ERROR "installed package is missing public header: ${header_name}") + endif() +endforeach() + file(GLOB_RECURSE installed_cmake_files "${install_dir}/lib/cmake/*.cmake") foreach(installed_cmake_file IN LISTS installed_cmake_files) @@ -39,6 +51,7 @@ execute_process( -S "${SOURCE_DIR}/tests/package_consumer" -B "${consumer_build_dir}" -DCMAKE_PREFIX_PATH=${install_dir} + -DCMAKE_EXPORT_COMPILE_COMMANDS=ON RESULT_VARIABLE configure_result ) if(NOT configure_result EQUAL 0) diff --git a/tests/test_polymarket_contracts.cpp b/tests/test_polymarket_contracts.cpp index 0b17fbb..ad03029 100644 --- a/tests/test_polymarket_contracts.cpp +++ b/tests/test_polymarket_contracts.cpp @@ -1,6 +1,6 @@ -#include "clob_client.hpp" -#include "order_signer.hpp" -#include "polymarket_contracts.hpp" +#include "polymarket/clob_client.hpp" +#include "polymarket/order_signer.hpp" +#include "polymarket/polymarket_contracts.hpp" #include #include #include diff --git a/tests/test_prepared_order.cpp b/tests/test_prepared_order.cpp index cb4c27b..50f2e6a 100644 --- a/tests/test_prepared_order.cpp +++ b/tests/test_prepared_order.cpp @@ -1,4 +1,4 @@ -#include "clob_client.hpp" +#include "polymarket/clob_client.hpp" #include "../src/clob_client_test_fixture.hpp" #include diff --git a/tests/test_sdk_error.cpp b/tests/test_sdk_error.cpp index a54e879..9d34fec 100644 --- a/tests/test_sdk_error.cpp +++ b/tests/test_sdk_error.cpp @@ -1,5 +1,5 @@ -#include "clob_client.hpp" -#include "sdk_error.hpp" +#include "polymarket/clob_client.hpp" +#include "polymarket/sdk_error.hpp" #include #include diff --git a/tests/test_utils.cpp b/tests/test_utils.cpp index 027cb4c..853745f 100644 --- a/tests/test_utils.cpp +++ b/tests/test_utils.cpp @@ -1,4 +1,4 @@ -#include "order_signer.hpp" +#include "polymarket/order_signer.hpp" #include #include #include diff --git a/tests/user_stream_test_support.hpp b/tests/user_stream_test_support.hpp index 720bec9..6a35fe0 100644 --- a/tests/user_stream_test_support.hpp +++ b/tests/user_stream_test_support.hpp @@ -1,6 +1,6 @@ #pragma once -#include "user_stream.hpp" +#include "polymarket/user_stream.hpp" #include #include diff --git a/tests/websocket_callback_exception_tests.hpp b/tests/websocket_callback_exception_tests.hpp index 756f810..736f318 100644 --- a/tests/websocket_callback_exception_tests.hpp +++ b/tests/websocket_callback_exception_tests.hpp @@ -1,6 +1,6 @@ #pragma once -#include "websocket_client.hpp" +#include "polymarket/websocket_client.hpp" #include "websocket_test_server.hpp" #include diff --git a/tests/websocket_client_integration_tests.hpp b/tests/websocket_client_integration_tests.hpp index f482220..e30db38 100644 --- a/tests/websocket_client_integration_tests.hpp +++ b/tests/websocket_client_integration_tests.hpp @@ -1,6 +1,6 @@ #pragma once -#include "websocket_client.hpp" +#include "polymarket/websocket_client.hpp" #include "websocket_callback_exception_tests.hpp" #include "websocket_owner_reset_tests.hpp" #include "websocket_test_server.hpp" diff --git a/tests/websocket_owner_reset_tests.hpp b/tests/websocket_owner_reset_tests.hpp index 9a74210..e31f2f9 100644 --- a/tests/websocket_owner_reset_tests.hpp +++ b/tests/websocket_owner_reset_tests.hpp @@ -1,6 +1,6 @@ #pragma once -#include "websocket_client.hpp" +#include "polymarket/websocket_client.hpp" #include "websocket_test_server.hpp" #include diff --git a/tests/websocket_transport_callback_tests.hpp b/tests/websocket_transport_callback_tests.hpp index 70110b1..c82b77d 100644 --- a/tests/websocket_transport_callback_tests.hpp +++ b/tests/websocket_transport_callback_tests.hpp @@ -1,6 +1,6 @@ #pragma once -#include "websocket_client.hpp" +#include "polymarket/websocket_client.hpp" #include "websocket_test_server.hpp" #include