You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`src/orders/`| Order types and Seaport parameter construction |
36
+
|`test/`| Unit and integration tests |
37
+
38
+
## Review Checklist
39
+
40
+
When reviewing changes to this package, verify:
41
+
42
+
1.**Chain enum sync**: The `Chain` enum in `src/types.ts` has a compile-time check (`_AssertAPIChainsCovered`) ensuring every `ChainIdentifier` from `@opensea/api-types` maps to a `Chain` value. When adding a chain, also update `scripts/chain-data.json` at the **monorepo root**, run `pnpm sync-chains` from the monorepo root, and update `getListingPaymentToken` / `getOfferPaymentToken` / `getNativeWrapTokenAddress`.
43
+
44
+
2.**Dual provider support**: Both `OpenSeaSDK` (ethers) and `OpenSeaViemSDK` (viem) must work. Changes to `BaseOpenSeaSDK` affect both. If adding provider-specific logic, ensure both adapters in `src/provider/` are updated.
45
+
46
+
3.**`@opensea/api-types` dependency**: The SDK imports types from the workspace `@opensea/api-types` package. If the OpenAPI spec changes, rebuild api-types first (`pnpm --filter @opensea/api-types run build`) before testing the SDK.
47
+
48
+
4.**Seaport integration**: Order creation and fulfillment flows use `@opensea/seaport-js`. Changes to order parameters, consideration items, or fulfillment logic must be tested against the Seaport contract behavior.
49
+
50
+
5.**No secret leakage**: API keys are passed via `OpenSeaAPIConfig.apiKey`. Never log or expose them. Integration tests read keys from environment variables.
51
+
52
+
## Conventions
53
+
54
+
- CommonJS (`"type": "commonjs"`). The SDK is consumed by both CJS and ESM projects.
55
+
- Biome for linting and formatting (config at monorepo root).
56
+
-`viem` is an optional peer dependency — the main entry point uses ethers; `@opensea/sdk/viem` is the viem entry point.
57
+
- Amounts use the `Amount` type (`string | number | bigint`). Prefer `string` for decimal values to avoid floating-point precision issues.
58
+
- The `Chain` enum uses API slug strings (e.g. `"ethereum"`, `"base"`), not numeric chain IDs.
59
+
60
+
## Testing
61
+
62
+
-**Unit tests** (`test/`): Mock API responses, test order construction and parameter validation.
63
+
-**Integration tests** (`test/integration/`): Hit the real API. Require `OPENSEA_API_KEY` env var. Run separately with `pnpm run test:integration`.
64
+
- Always run `pnpm run check-types` — it uses a stricter tsconfig than the build.
Copy file name to clipboardExpand all lines: CHANGELOG.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,11 @@
1
1
# @opensea/sdk
2
2
3
+
## 10.2.1
4
+
5
+
### Patch Changes
6
+
7
+
- 4a76bc1: Add server-side trait filtering on three collection-scoped read methods. `getNFTsByCollection`, `getBestListings`, and `getEventsByCollection` now accept an optional `traits` argument (a `TraitFilter[]`); multiple entries are AND-combined server-side. The SDK JSON-encodes the array for the request — callers pass a structured `[{ traitType, value }]`. New exports: `TraitFilter`, `GetEventsByCollectionArgs`, `encodeTraitsParam`. Requires `@opensea/api-types@^0.2.2`.
|`limit`| number | No | Number of NFTs to retrieve (1-50) |
80
+
|`next`| string | No | Pagination cursor from previous request |
81
+
|`traits`| TraitFilter[]| No | Trait filters, e.g. `[{ traitType: "Background", value: "Red" }]`. Multiple entries are AND-combined. The SDK JSON-encodes the array for the request. |
|`limit`| number | No | Number of listings (1-100) |
413
+
|`next`| string | No | Pagination cursor |
414
+
|`includePrivateListings`| boolean | No | Include private listings (default: false) |
415
+
|`traits`| TraitFilter[]| No | Trait filters, e.g. `[{ traitType: "Background", value: "Red" }]`. Multiple entries are AND-combined. The SDK JSON-encodes the array for the request. |
414
416
415
417
**Returns:**`GetListingsResponse` with best listings.
|`args`| GetEventsArgs | No | Event filtering options. `args.traits` is a `TraitFilter[]` (e.g. `[{ traitType: "Background", value: "Red" }]`) to scope events to NFTs matching every trait — the SDK JSON-encodes it for the request.|
1027
1029
1028
1030
**Returns:**`GetEventsResponse` with collection events.
-`getNFTsByCollection(collectionSlug, limit?, next?)` - Get all NFTs in a collection
40
+
-`getNFTsByCollection(collectionSlug, limit?, next?, traits?)` - Get all NFTs in a collection (`traits` is an array of `{ traitType, value }` for server-side filtering — multiple entries are AND-combined)
41
41
-`getNFTsByContract(contractAddress, limit?, next?, chain?)` - Get all NFTs for a contract
42
42
-`getNFTsByAccount(accountAddress, limit?, next?, chain?)` - Get all NFTs owned by an account
43
43
-`getContract(contractAddress, chain?)` - Get contract information
0 commit comments