Skip to content

Commit f218bf6

Browse files
committed
ADDS orderbook filtering for multiple nonces and multiple token ids
1 parent f881391 commit f218bf6

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
"isomorphic-unfetch": "^3.1.0",
7474
"lodash": "^4.17.21",
7575
"lodash-es": "^4.17.21",
76+
"query-string": "^7.1.1",
7677
"tiny-invariant": "^1.2.0",
7778
"tiny-warning": "^1.0.3",
7879
"uuid": "^8.3.2"

src/sdk/v4/orderbook.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import unfetch from 'isomorphic-unfetch';
2+
import { stringify } from 'query-string';
23
import type { SignedNftOrderV4, SignedNftOrderV4Serialized } from './types';
3-
import { stringify } from '../../utils/query-string';
44
import { serializeNftOrder } from './pure';
55

66
export const ORDERBOOK_API_ROOT_URL_PRODUCTION = 'https://api.trader.xyz';
@@ -76,13 +76,13 @@ const postOrderToOrderbook = async (
7676

7777
export interface SearchOrdersParams {
7878
erc20Token?: string;
79-
nftTokenId?: string;
79+
nftTokenId?: string | string[];
8080
nftToken?: string;
8181
nftType?: string;
8282
chainId?: string;
8383
maker?: string;
8484
taker?: string;
85-
nonce?: string;
85+
nonce?: string | string[];
8686
// Defaults to only 'open' orders
8787
status?: 'open' | 'filled' | 'expired' | 'cancelled' | 'all';
8888
}
@@ -92,7 +92,10 @@ const searchOrderbook = async (
9292
requestOptions?: Partial<OrderbookRequestOptions>,
9393
fetchFn: typeof unfetch = unfetch
9494
): Promise<SearchOrdersResponsePayload> => {
95-
const stringifiedQueryParams = stringify(filters ?? {});
95+
// https://github.com/sindresorhus/query-string#arrayformat
96+
const stringifiedQueryParams = stringify(filters ?? {}, {
97+
arrayFormat: 'none',
98+
});
9699

97100
let rootUrl = requestOptions?.rootUrl ?? ORDERBOOK_API_ROOT_URL_PRODUCTION;
98101

yarn.lock

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3519,6 +3519,11 @@ fill-range@^7.0.1:
35193519
dependencies:
35203520
to-regex-range "^5.0.1"
35213521

3522+
filter-obj@^1.1.0:
3523+
version "1.1.0"
3524+
resolved "https://registry.yarnpkg.com/filter-obj/-/filter-obj-1.1.0.tgz#9b311112bc6c6127a16e016c6c5d7f19e0805c5b"
3525+
integrity sha1-mzERErxsYSehbgFsbF1/GeCAXFs=
3526+
35223527
find-cache-dir@^3.3.1:
35233528
version "3.3.2"
35243529
resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-3.3.2.tgz#b30c5b6eff0730731aea9bbd9dbecbd80256d64b"
@@ -5717,6 +5722,16 @@ qs@~6.5.2:
57175722
resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36"
57185723
integrity sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==
57195724

5725+
query-string@^7.1.1:
5726+
version "7.1.1"
5727+
resolved "https://registry.yarnpkg.com/query-string/-/query-string-7.1.1.tgz#754620669db978625a90f635f12617c271a088e1"
5728+
integrity sha512-MplouLRDHBZSG9z7fpuAAcI7aAYjDLhtsiVZsevsfaHWDS2IDdORKbSd1kWUA+V4zyva/HZoSfpwnYMMQDhb0w==
5729+
dependencies:
5730+
decode-uri-component "^0.2.0"
5731+
filter-obj "^1.1.0"
5732+
split-on-first "^1.0.0"
5733+
strict-uri-encode "^2.0.0"
5734+
57205735
queue-microtask@^1.2.2:
57215736
version "1.2.3"
57225737
resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243"
@@ -6371,6 +6386,11 @@ spdx-license-ids@^3.0.0:
63716386
resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.10.tgz#0d9becccde7003d6c658d487dd48a32f0bf3014b"
63726387
integrity sha512-oie3/+gKf7QtpitB0LYLETe+k8SifzsX4KixvpOsbI6S0kRiRQ5MKOio8eMSAKQ17N06+wdEOXRiId+zOxo0hA==
63736388

6389+
split-on-first@^1.0.0:
6390+
version "1.1.0"
6391+
resolved "https://registry.yarnpkg.com/split-on-first/-/split-on-first-1.1.0.tgz#f610afeee3b12bce1d0c30425e76398b78249a5f"
6392+
integrity sha512-43ZssAJaMusuKWL8sKUBQXHWOpq8d6CfN/u1p4gUzfJkM05C8rxTmYrkIPTXapZpORA6LkkzcUulJ8FqA7Uudw==
6393+
63746394
split-string@^3.0.1, split-string@^3.0.2:
63756395
version "3.1.0"
63766396
resolved "https://registry.yarnpkg.com/split-string/-/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2"
@@ -6418,6 +6438,11 @@ stealthy-require@^1.1.1:
64186438
resolved "https://registry.yarnpkg.com/stealthy-require/-/stealthy-require-1.1.1.tgz#35b09875b4ff49f26a777e509b3090a3226bf24b"
64196439
integrity sha1-NbCYdbT/SfJqd35QmzCQoyJr8ks=
64206440

6441+
strict-uri-encode@^2.0.0:
6442+
version "2.0.0"
6443+
resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz#b9c7330c7042862f6b142dc274bbcc5866ce3546"
6444+
integrity sha1-ucczDHBChi9rFC3CdLvMWGbONUY=
6445+
64216446
string-format@^2.0.0:
64226447
version "2.0.0"
64236448
resolved "https://registry.yarnpkg.com/string-format/-/string-format-2.0.0.tgz#f2df2e7097440d3b65de31b6d40d54c96eaffb9b"

0 commit comments

Comments
 (0)