@calp-pro/dex-db 1.0.2 → 1.0.4

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.
Files changed (3) hide show
  1. package/dex_db.js +4 -4
  2. package/index.d.ts +11 -0
  3. package/package.json +1 -1
package/dex_db.js CHANGED
@@ -52,7 +52,7 @@ function dex_db(pairs = []) {
52
52
  if (it1 == -1) {
53
53
  it1 = T.length
54
54
  T[it1] = token1
55
- get(token1, it1, trie.tokens)
55
+ set(token1, it1, trie.tokens)
56
56
  }
57
57
  p2tt[ip] ??= []
58
58
  p2tt[ip][0] = it0
@@ -71,15 +71,15 @@ function dex_db(pairs = []) {
71
71
 
72
72
  const find_pairs_with_token = token => {
73
73
  const it = get(token, trie.tokens)
74
- if (it == -1) return -1
74
+ if (it == -1) return []
75
75
  return t2pt[it].map(pt => P[pt[0]])
76
76
  }
77
77
 
78
78
  const find_pairs_with_tokens = (token0, token1) => {
79
79
  const it0 = get(token0, trie.tokens)
80
- if (it0 == -1) return -1
80
+ if (it0 == -1) return []
81
81
  const it1 = get(token1, trie.tokens)
82
- if (it1 == -1) return -1
82
+ if (it1 == -1) return []
83
83
  return t2pt[it0].filter(pt => pt[1] == it1).map(pt => P[pt[0]])
84
84
  }
85
85
 
package/index.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ export type pair = [string, string, string]
2
+
3
+ export interface dex_db_instance {
4
+ index: (pair: pair) => void
5
+ find_pairs_with_token: (token: string) => string[]
6
+ find_pairs_with_tokens: (token_a: string, token_b: string) => string[]
7
+ }
8
+
9
+ export function dex_db(pairs?: pair[]): dex_db_instance
10
+
11
+ export default dex_db
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@calp-pro/dex-db",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Database designed for handle relation pair/pool address to token0 & token1 addresses",
5
5
  "keywords": [
6
6
  "DEX",