uniswap-v2-loader 5.0.19 → 5.0.21

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.
@@ -32,7 +32,6 @@ jobs:
32
32
  run: npm install -g npm@latest
33
33
 
34
34
  - name: Global install package CLI version
35
-
36
35
  run: npm i -g .
37
36
 
38
37
  - name: Test CLI load first 4 pairs from Uniswap V2 using 2 workers
package/README.md CHANGED
@@ -13,7 +13,7 @@
13
13
  | **ShibaSwap** | `0x115934131916c8b277dd010ee02de363c09d037c` |
14
14
  | **DefiSwap** | `0x9deb29c9a4c7a88a3c0257393b7f3335338d9a9d` |
15
15
  | **EtherVista** | `0x9a27cb5ae0b2cee0bb71f9a85c0d60f3920757b4` |
16
- | **Balancer V2** | `0xba12222222228d8ba445958a75a0704d566bf2c8` |
16
+ | **RadioShack** | `0x91fae1bc94a9793708fbc66adcb59087c46dee10` |
17
17
 
18
18
 
19
19
  ## CLI
package/index.js CHANGED
@@ -99,14 +99,10 @@ const load = (params = {}) => {
99
99
  .then(() => pairs)
100
100
  }
101
101
 
102
- const missed = []
103
- for (var i = start_loading_from, ids; i < all_pairs_length; i++) {
104
- if (!ids || ids.length % multicall_size == 0) {
105
- ids = []
106
- missed.push(ids)
107
- }
108
- ids.push(i)
109
- }
102
+ const missed = Array(workers).fill(null).map(() => [])
103
+
104
+ for (var i = start_loading_from, iw = 0; i < all_pairs_length; i++)
105
+ missed[iw++ % workers].push(i)
110
106
 
111
107
  cluster.setupPrimary({ exec: path.join(__dirname, 'loader.js') })
112
108
 
@@ -114,11 +110,16 @@ const load = (params = {}) => {
114
110
  missed
115
111
  .filter(_ => _.length)
116
112
  .map((ids, i) => new Promise(y => {
113
+ if (abort_signal?.aborted) return y()
117
114
  const w = cluster.fork()
118
- abort_signal?.addEventListener('abort', () => w.send('abort'))
115
+ const onabort = () => w.send('abort')
116
+ abort_signal?.addEventListener('abort', onabort, { once: true })
119
117
  w.send({ ids, factory, key, multicall_size })
120
118
  w.on('message', onpair)
121
- w.on('exit', y)
119
+ w.on('exit', () => {
120
+ abort_signal?.removeEventListener('abort', onabort)
121
+ y()
122
+ })
122
123
  }))
123
124
  ).then(() => pairs)
124
125
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uniswap-v2-loader",
3
- "version": "5.0.19",
3
+ "version": "5.0.21",
4
4
  "description": "Uniswap v2 protocol loader",
5
5
  "keywords": [
6
6
  "uniswap-v2",
package/test-esm.mjs DELETED
@@ -1,18 +0,0 @@
1
- import { load, subscribe } from './index.mjs'
2
- import assert from 'node:assert/strict'
3
- import { describe, it } from 'node:test'
4
-
5
- describe('ESM Support', () => {
6
- it('should import load and subscribe', () => {
7
- assert.equal(typeof load, 'function')
8
- assert.equal(typeof subscribe, 'function')
9
- })
10
-
11
- it('should load first pair', () =>
12
- load({ to: 1 })
13
- .then(pairs => {
14
- assert.equal(pairs.length, 1)
15
- assert.equal(pairs[0].id, 0)
16
- })
17
- )
18
- })