@raydium-io/raydium-sdk-v2 0.1.35-alpha → 0.1.37-alpha

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raydium-io/raydium-sdk-v2",
3
- "version": "0.1.35-alpha",
3
+ "version": "0.1.37-alpha",
4
4
  "description": "An SDK for building applications on top of Raydium.",
5
5
  "license": "GPL-3.0",
6
6
  "main": "./lib/index.js",
package/src/api/api.ts CHANGED
@@ -169,7 +169,7 @@ export class Api {
169
169
  }
170
170
 
171
171
  async getJupTokenList(type?: JupTokenType): Promise<ApiV3Token[]> {
172
- return this.api.get("/", {
172
+ return this.api.get("", {
173
173
  baseURL: (this.urlConfigs.JUP_TOKEN_LIST || API_URLS.JUP_TOKEN_LIST).replace("{type}", type || JupTokenType.ALL),
174
174
  });
175
175
  }
@@ -185,7 +185,7 @@ export class Api {
185
185
  const { type = "all", sort = "liquidity", order = "desc", page = 0, pageSize = 100 } = props;
186
186
  const res = await this.api.get<PoolsApiReturn>(
187
187
  (this.urlConfigs.POOL_LIST || API_URLS.POOL_LIST) +
188
- `?poolType=${type}&poolSortField=${sort}&sortType=${order}&page=${page}&pageSize=${pageSize}`,
188
+ `?poolType=${type}&poolSortField=${sort}&sortType=${order}&page=${page}&pageSize=${pageSize}`,
189
189
  );
190
190
  return res.data;
191
191
  }
@@ -246,7 +246,7 @@ export class Api {
246
246
 
247
247
  const res = await this.api.get(
248
248
  (this.urlConfigs.POOL_SEARCH_MINT || API_URLS.POOL_SEARCH_MINT) +
249
- `?mint1=${baseMint}&mint2=${quoteMint}&poolType=${type}&poolSortField=${sort}&sortType=${order}&pageSize=100&page=${page}`,
249
+ `?mint1=${baseMint}&mint2=${quoteMint}&poolType=${type}&poolSortField=${sort}&sortType=${order}&pageSize=100&page=${page}`,
250
250
  );
251
251
  return res.data;
252
252
  }
@@ -238,29 +238,43 @@ export class Raydium {
238
238
  public async fetchV3TokenList(forceUpdate?: boolean): Promise<ApiV3TokenRes> {
239
239
  if (this.apiData.tokenList && !this.isCacheInvalidate(this.apiData.tokenList.fetched) && !forceUpdate)
240
240
  return this.apiData.tokenList.data;
241
- const raydiumList = await this.api.getTokenList();
242
- const dataObject = {
243
- fetched: Date.now(),
244
- data: raydiumList,
245
- };
246
- this.apiData.tokenList = dataObject;
247
-
248
- return dataObject.data;
241
+ try {
242
+ const raydiumList = await this.api.getTokenList();
243
+ const dataObject = {
244
+ fetched: Date.now(),
245
+ data: raydiumList,
246
+ };
247
+ this.apiData.tokenList = dataObject;
248
+
249
+ return dataObject.data;
250
+ } catch (e) {
251
+ console.error(e);
252
+ return {
253
+ mintList: [],
254
+ blacklist: [],
255
+ whiteList: [],
256
+ };
257
+ }
249
258
  }
250
259
 
251
260
  public async fetchJupTokenList(type: JupTokenType, forceUpdate?: boolean): Promise<ApiV3Token[]> {
252
261
  const prevFetched = this.apiData.jupTokenList?.[type];
253
262
  if (prevFetched && !this.isCacheInvalidate(prevFetched.fetched) && !forceUpdate) return prevFetched.data;
254
- const jupList = await this.api.getJupTokenList(type);
255
- this.apiData.jupTokenList = {
256
- ...this.apiData.jupTokenList,
257
- [type]: {
258
- fetched: Date.now(),
259
- data: jupList,
260
- },
261
- };
263
+ try {
264
+ const jupList = await this.api.getJupTokenList(type);
265
+ this.apiData.jupTokenList = {
266
+ ...this.apiData.jupTokenList,
267
+ [type]: {
268
+ fetched: Date.now(),
269
+ data: jupList,
270
+ },
271
+ };
262
272
 
263
- return this.apiData.jupTokenList[type]!.data;
273
+ return this.apiData.jupTokenList[type]!.data;
274
+ } catch (e) {
275
+ console.error(e);
276
+ return [];
277
+ }
264
278
  }
265
279
 
266
280
  get chainTimeData(): { offset: number; chainTime: number } | undefined {
@@ -1,8 +1,6 @@
1
1
  import { PublicKey } from "@solana/web3.js";
2
2
  import { MintLayout, TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID } from "@solana/spl-token";
3
3
 
4
- import { Price, Token } from "@/module";
5
- import { validateAndParsePublicKey, SOLMint } from "@/common/pubKey";
6
4
  import { ApiV3Token, JupTokenType } from "@/api/type";
7
5
  import ModuleBase, { ModuleBaseProps } from "../moduleBase";
8
6
  import { LoadParams } from "../type";