@hawksightco/hawk-sdk 0.0.30 → 0.0.32

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.
@@ -48,13 +48,13 @@ export declare class General {
48
48
  *
49
49
  * @returns A Promise resolving to an array of pools, including metadata such as pool addresses and statistics.
50
50
  */
51
- pools(): Promise<ResponseWithStatus<_client.InlineResponse2002[]>>;
51
+ pools(): Promise<ResponseWithStatus<_client.InlineResponse2001[]>>;
52
52
  /**
53
53
  * Retrieves information about the available tokens on the platform.
54
54
  *
55
55
  * @returns A Promise resolving to an array of token details, including names, symbols, and other token-specific information.
56
56
  */
57
- tokens(): Promise<ResponseWithStatus<_client.InlineResponse2003[]>>;
57
+ tokens(): Promise<ResponseWithStatus<_client.InlineResponse2002[]>>;
58
58
  /**
59
59
  * Registers a new entity or user with the necessary parameters, handling transaction creation and response.
60
60
  *
@@ -23,9 +23,11 @@ export declare class Search {
23
23
  * If the token indices or tokens are not yet loaded, it logs a warning and returns an empty array.
24
24
  *
25
25
  * @param {string} keyword - The keyword to search for.
26
+ * @param {number} limit - Number of results to show.
27
+ * @param {boolean} noLimit - disable limit
26
28
  * @returns {Token[]} An array of tokens that match the given keyword.
27
29
  */
28
- token(keyword: string): Token[];
30
+ token(keyword: string, limit?: number, noLimit?: boolean): Token[];
29
31
  /**
30
32
  * Loads the token indices and tokens.
31
33
  *
@@ -1 +1 @@
1
- {"version":3,"file":"Search.d.ts","sourceRoot":"","sources":["../../../src/classes/Search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,EAAE,MAAM,UAAU,CAAC;AAGhD,qBAAa,MAAM;IAmBf,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM;IAjBhC,OAAO,CAAC,YAAY,CAAC,CAAgB;IACrC,OAAO,CAAC,MAAM,CAAC,CAAU;IACzB,OAAO,CAAC,OAAO,CAAkB;IAEjC;;;;OAIG;IACH,IAAI,MAAM,IAAI,OAAO,CAAwB;IAE7C;;;;OAIG;gBAEkB,GAAG,EAAE,MAAM;IAGhC;;;;;;;;OAQG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,EAAE;IAa/B;;;;;;;OAOG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAW3B;;;;;;;;;;OAUG;YACW,eAAe;IAgB7B;;;;;;;OAOG;YACW,YAAY;IAI1B;;;;;;;;;;OAUG;YACW,gBAAgB;CAO/B"}
1
+ {"version":3,"file":"Search.d.ts","sourceRoot":"","sources":["../../../src/classes/Search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,EAAE,MAAM,UAAU,CAAC;AAGhD,qBAAa,MAAM;IAmBf,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM;IAjBhC,OAAO,CAAC,YAAY,CAAC,CAAgB;IACrC,OAAO,CAAC,MAAM,CAAC,CAAU;IACzB,OAAO,CAAC,OAAO,CAAkB;IAEjC;;;;OAIG;IACH,IAAI,MAAM,IAAI,OAAO,CAAwB;IAE7C;;;;OAIG;gBAEkB,GAAG,EAAE,MAAM;IAGhC;;;;;;;;;;OAUG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,GAAE,MAAY,EAAE,OAAO,GAAE,OAAe,GAAG,KAAK,EAAE;IAiB9E;;;;;;;OAOG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAW3B;;;;;;;;;;OAUG;YACW,eAAe;IAgB7B;;;;;;;OAOG;YACW,YAAY;IAI1B;;;;;;;;;;OAUG;YACW,gBAAgB;CAO/B"}
@@ -37,17 +37,24 @@ class Search {
37
37
  * If the token indices or tokens are not yet loaded, it logs a warning and returns an empty array.
38
38
  *
39
39
  * @param {string} keyword - The keyword to search for.
40
+ * @param {number} limit - Number of results to show.
41
+ * @param {boolean} noLimit - disable limit
40
42
  * @returns {Token[]} An array of tokens that match the given keyword.
41
43
  */
42
- token(keyword) {
44
+ token(keyword, limit = 100, noLimit = false) {
45
+ const result = [];
46
+ keyword = keyword.trim();
43
47
  if (this.tokenIndices === undefined || this.tokens === undefined) {
44
48
  console.warn("Token list still loading...");
45
49
  return [];
46
50
  }
47
51
  const indices = this.tokenIndices.indices[keyword.toLowerCase()];
48
- const result = [];
52
+ let count = 0;
49
53
  for (const index in indices) {
54
+ count++;
50
55
  result.push(this.tokens[index]);
56
+ if (!noLimit && count >= limit)
57
+ break;
51
58
  }
52
59
  return result;
53
60
  }
@@ -65,7 +72,7 @@ class Search {
65
72
  this._loaded = true;
66
73
  const update = () => __awaiter(this, void 0, void 0, function* () {
67
74
  yield this.getTokenIndices();
68
- setTimeout(update, 60 * 1000);
75
+ setTimeout(update, 5 * 1000);
69
76
  });
70
77
  yield update();
71
78
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hawksightco/hawk-sdk",
3
- "version": "0.0.30",
3
+ "version": "0.0.32",
4
4
  "description": "Hawksight v2 SDK",
5
5
  "main": "dist/src/index.js",
6
6
  "repository": "https://github.com/ghabxph/hawk-api-client.git",