cow-sdk-core
Shared CoW Protocol core types and runtime-neutral trait contracts.
⚠️ Alpha —
0.1.0-alpha. Pre-release and not security-audited; the public API may change before0.1.0. It is published as a pre-release, so Cargo selects it only when you opt in (cow-sdk-core = "0.1.0-alpha.10"). Review it yourself before relying on it with real funds.
cow-sdk-core is the foundation of the
cow-rs crate family: the shared
vocabulary and runtime-neutral seams every other crate is built on. It ships
validated primitive types, environment and chain configuration, a uniform error
taxonomy, and the trait shapes used across the workspace. It performs no protocol
work of its own — it defines the types and boundaries the rest of the SDK fills
in. Most consumers reach these types through the top-level
cow-sdk facade re-exports; depend on this
crate directly when you are building a sibling leaf crate or implementing a custom
Signer, Provider, or HttpTransport adapter.
The cow-named identity and numeric primitive types ship as cow-owned
#[repr(transparent)] newtypes over alloy_primitives per
ADR 0052.
What it provides
- Identity & numeric newtypes —
Address,Hash32,AppDataHash,HexData,OrderUid,OrderData,OrderKind,Amount/Amounts,TokenInfo, and the validity-window types, as cow-owned transparent newtypes overalloy_primitives. - The
address!macro — compile-time-validated address literals. The literal must be the lowercase wire form; a mixed-case literal fails the build, because an EIP-55 checksum cannot be verified in const evaluation. A malformed address never reaches runtime. - Runtime-neutral trait seams —
Signer,DigestSigner,TypedDataSigner,Provider,SigningProvider,LogProvider, and the object-safeHttpTransport, plusUserRejection, the bound that lets the SDK tell a user-declined signature apart from other signer failures.async_traitis re-exported for implementors. - Explicit transaction lifecycle states —
TransactionBroadcastis the signer-side broadcast acknowledgement;TransactionReceiptis the provider-side mined observation with optional status, block, gas, sender, and recipient fields. - Chain & endpoint configuration —
SupportedChainId, default API base URLs, canonical orderbook/subgraph host allow-lists,NATIVE_CURRENCY_ADDRESS,wrapped_native_token,ProtocolOptions, andExternalHostPolicyfor SSRF-resistant URL validation. - Uniform error taxonomy —
ErrorClass, the coarse telemetry bucket every crate's error maps to, alongsideCoreError,ValidationError, andTransportErrorClass. - Secret redaction —
Redacted<T>and the redacted URL-map types, so secret-bearing configuration never leaks throughDebug,Display, orserde. - Cooperative cancellation — a re-exported
CancellationTokenplus theCancellable/WithCancellationcombinators for long-running SDK futures. - The HTTP transport seam — the
HttpTransportasync injection point with the nativeReqwestTransportdefault (size-capped, URL-stripping on error) and itswasm32siblingFetchTransport(the browserfetchdefault), both selected automatically by target.
Install
[]
= "0.1.0-alpha.10"
Minimal example
use ;
#
Feature flags
| Feature | Default | Enables |
|---|---|---|
transport-policy |
off | Shared HTTP retry, rate-limit, Retry-After, jitter, and transport-error classification policy used by the orderbook, subgraph, and IPFS clients. Off by default so a consumer that needs only the primitive types does not pull the retry-timer dependencies. |
tracing |
off | Emits tracing spans and events from the transport layer. |
Where this fits
This crate defines types and seams; it does not compute order hashes or signatures
(see cow-sdk-signing), talk to the
orderbook (see cow-sdk-orderbook),
build or submit trades (see cow-sdk-trading),
or decode contract events (see cow-sdk-contracts).
The Signer and Provider seams are defined here; concrete native adapters live in
cow-sdk-alloy-signer and
cow-sdk-alloy-provider, and
JavaScript and TypeScript hosts supply their own wallet across the
cow-sdk-js callback boundary.
Where to next
License
Licensed under GPL-3.0-or-later. See the workspace LICENSE file for the full text.