@codex-data/sdk 1.0.23 → 1.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1034,6 +1034,8 @@ export type EnhancedToken = {
1034
1034
  name?: Maybe<Scalars['String']['output']>;
1035
1035
  /** The network ID the token is deployed on. */
1036
1036
  networkId: Scalars['Int']['output'];
1037
+ /** The pair that the token is contained in */
1038
+ pairId?: Maybe<Scalars['String']['output']>;
1037
1039
  /**
1038
1040
  * The amount of this token in the pair.
1039
1041
  * @deprecated Pooled can be found on the pair instead
@@ -1624,6 +1626,8 @@ export type HoldersResponse = {
1624
1626
  items: Array<Balance>;
1625
1627
  /** Status of holder. Disabled if on unsupported network or there is insufficient holder data. */
1626
1628
  status: HoldersStatus;
1629
+ /** the token Id */
1630
+ tokenId?: Maybe<Scalars['String']['output']>;
1627
1631
  /** What percentage of the total supply do the top 10 holders hold. */
1628
1632
  top10HoldersPercent?: Maybe<Scalars['Float']['output']>;
1629
1633
  };
@@ -7949,6 +7953,8 @@ export type TokenFilterResult = {
7949
7953
  liquidPair?: Maybe<Pair>;
7950
7954
  /** The liquidity of the token's most liquid pair */
7951
7955
  liquidPairLiquidity?: Maybe<Scalars['String']['output']>;
7956
+ /** The liquid pairs price in USD. */
7957
+ liquidPairPriceUSD?: Maybe<Scalars['String']['output']>;
7952
7958
  /** Amount of liquidity in the token's top pair. */
7953
7959
  liquidity?: Maybe<Scalars['String']['output']>;
7954
7960
  /** The lowest price in USD in the past hour. */
@@ -8558,14 +8564,24 @@ export type TokenSparkline = {
8558
8564
  attribute?: Maybe<SparklineAttribute>;
8559
8565
  /** The token id */
8560
8566
  id: Scalars['String']['output'];
8567
+ /** The timeframe of the sparkline. */
8568
+ resolution: Scalars['String']['output'];
8561
8569
  /** List of sparkline values to chart */
8562
8570
  sparkline: Array<SparklineValue>;
8563
8571
  };
8564
8572
 
8565
8573
  /** Input type of `tokenSparkline`. */
8566
8574
  export type TokenSparklineInput = {
8575
+ /** Whether to add empty bars to the response, populated with the previous bar's value. Default is `false` */
8576
+ fillMissingBars?: InputMaybe<Scalars['Boolean']['input']>;
8577
+ /** The unix timestamp for the start of the requested range. Defaults to 1 week ago. */
8578
+ from?: InputMaybe<Scalars['Int']['input']>;
8567
8579
  /** The contract address & networkId of the token, joined by a colon. ex: 0xbe042e9d09cb588331ff911c2b46fd833a3e5bd6:1 */
8568
8580
  ids: Array<Scalars['String']['input']>;
8581
+ /** The time frame for each candle. Available options are `1S`, `5S`, `15S`, `30S`, `1`, `5`, `15`, `30`, `60`, `240`, `720`, `1D`, `7D`. Defaults to `60` (1 hour) */
8582
+ resolution?: InputMaybe<Scalars['String']['input']>;
8583
+ /** The unix timestamp for the end of the requested range. Defaults to current time. */
8584
+ to?: InputMaybe<Scalars['Int']['input']>;
8569
8585
  };
8570
8586
 
8571
8587
  /** A top trader for a token. */
@@ -8929,16 +8945,26 @@ export type UnconfirmedResolutionBarData = {
8929
8945
  __typename?: 'UnconfirmedResolutionBarData';
8930
8946
  /** 1 minute resolution. */
8931
8947
  r1?: Maybe<UnconfirmedIndividualBarData>;
8948
+ /** 1 day resolution. */
8949
+ r1D?: Maybe<UnconfirmedIndividualBarData>;
8932
8950
  /** 1 second resolution. */
8933
8951
  r1S?: Maybe<UnconfirmedIndividualBarData>;
8934
8952
  /** 5 minute resolution. */
8935
8953
  r5?: Maybe<UnconfirmedIndividualBarData>;
8936
8954
  /** 5 second resolution. */
8937
8955
  r5S?: Maybe<UnconfirmedIndividualBarData>;
8956
+ /** 1 week resolution. */
8957
+ r7D?: Maybe<UnconfirmedIndividualBarData>;
8938
8958
  /** 15 minute resolution. */
8939
8959
  r15?: Maybe<UnconfirmedIndividualBarData>;
8940
8960
  /** 15 second resolution. */
8941
8961
  r15S?: Maybe<UnconfirmedIndividualBarData>;
8962
+ /** 60 minute resolution. */
8963
+ r60?: Maybe<UnconfirmedIndividualBarData>;
8964
+ /** 4 hour resolution. */
8965
+ r240?: Maybe<UnconfirmedIndividualBarData>;
8966
+ /** 12 hour resolution. */
8967
+ r720?: Maybe<UnconfirmedIndividualBarData>;
8942
8968
  };
8943
8969
 
8944
8970
  /** Event data for a token swap event. */
@@ -230,6 +230,31 @@ describe("Codex", () => {
230
230
  });
231
231
  });
232
232
 
233
+ describe("fetch override", () => {
234
+ it("should use the fetch override", async () => {
235
+ const fetchMock = jest.fn((input, init) => {
236
+ console.log("fetchMock", input, init);
237
+ return Promise.resolve(
238
+ new Response(
239
+ JSON.stringify({
240
+ data: { getNetworks: [] },
241
+ }),
242
+ {
243
+ status: 200,
244
+ headers: new Headers({
245
+ "Content-Type": "application/json",
246
+ }),
247
+ },
248
+ ),
249
+ );
250
+ });
251
+
252
+ const sdkWithFetch = new Codex("test-key", { fetch: fetchMock });
253
+ await sdkWithFetch.query(getNetworksDocument, {});
254
+ expect(fetchMock).toHaveBeenCalled();
255
+ });
256
+ });
257
+
233
258
  describe("dispose", () => {
234
259
  it("should dispose websocket client when it exists", async () => {
235
260
  const mockDispose = jest.fn();
package/src/sdk/index.ts CHANGED
@@ -33,6 +33,9 @@ export type ApiConfig = {
33
33
 
34
34
  // Use this to apply dynamic headers to the requests
35
35
  applyHeaders?: () => Promise<Record<string, string>>;
36
+
37
+ // Use this to override the default fetch implementation.
38
+ fetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
36
39
  };
37
40
 
38
41
  const defaultConfig: ApiConfig = {
@@ -83,6 +86,7 @@ export class Codex {
83
86
  "X-Apollo-Operation-Name": "query",
84
87
  ...config.headers,
85
88
  }),
89
+ fetch: config.fetch,
86
90
  });
87
91
  }
88
92