@pioneer-platform/nodes 8.11.9 → 8.11.11

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": "@pioneer-platform/nodes",
3
- "version": "8.11.9",
3
+ "version": "8.11.11",
4
4
  "main": "./lib/index.js",
5
5
  "types": "./lib/index.d.ts",
6
6
  "scripts": {
@@ -17,12 +17,16 @@
17
17
  "test:watch": "jest --coverage --watchAll",
18
18
  "build:watch": "onchange 'src/**/*.ts' -- pnpm run build",
19
19
  "view:coverage": "serve coverage/lcov-report",
20
- "clean": "rm -rf coverage src/**/*.js src/**/*.map lib node_modules"
20
+ "clean": "rm -rf coverage src/**/*.js src/**/*.map lib node_modules",
21
+ "validate-nodes": "bun run src/validate-nodes.ts",
22
+ "validate-nodes:verbose": "bun run src/validate-nodes.ts --verbose",
23
+ "validate-nodes:fast": "bun run src/validate-nodes.ts --timeout 3000 --concurrency 30"
21
24
  },
22
25
  "dependencies": {
23
26
  "@pioneer-platform/loggerdog": "^8.11.0",
24
- "@pioneer-platform/pioneer-caip": "^9.10.0",
25
- "dotenv": "^8.2.0"
27
+ "@pioneer-platform/pioneer-caip": "^9.10.1",
28
+ "dotenv": "^8.2.0",
29
+ "ethers": "5.7.2"
26
30
  },
27
31
  "devDependencies": {
28
32
  "@types/jest": "^25.2.3",
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Add tier metadata to web3Seeds
3
+ */
4
+
5
+ const fs = require('fs');
6
+ const path = require('path');
7
+
8
+ // Premium providers (paid services, API keys, high reliability)
9
+ const PREMIUM_PROVIDERS = [
10
+ 'infura.io',
11
+ 'alchemy.com',
12
+ 'quicknode.pro',
13
+ 'nodereal.io',
14
+ 'chainnodes.org',
15
+ 'blastapi.io',
16
+ 'ankr.com/rpc',
17
+ 'getblock.io',
18
+ ];
19
+
20
+ // Reliable providers (established free services, good track record)
21
+ const RELIABLE_PROVIDERS = [
22
+ 'llamarpc.com',
23
+ '1rpc.io',
24
+ 'cloudflare-eth.com',
25
+ 'publicnode.com',
26
+ 'drpc.org',
27
+ 'tenderly.co',
28
+ 'omniatech.io',
29
+ 'gateway.pokt.network',
30
+ 'rpc.flashbots.net',
31
+ 'eth.merkle.io',
32
+ 'rpc.ankr.com',
33
+ ];
34
+
35
+ function getTier(service) {
36
+ const url = service.toLowerCase();
37
+
38
+ for (const provider of PREMIUM_PROVIDERS) {
39
+ if (url.includes(provider.toLowerCase())) {
40
+ return 'premium';
41
+ }
42
+ }
43
+
44
+ for (const provider of RELIABLE_PROVIDERS) {
45
+ if (url.includes(provider.toLowerCase())) {
46
+ return 'reliable';
47
+ }
48
+ }
49
+
50
+ return 'public';
51
+ }
52
+
53
+ // Read web3.ts file
54
+ const web3Path = path.join(__dirname, '../src/web3.ts');
55
+ const content = fs.readFileSync(web3Path, 'utf-8');
56
+
57
+ // Extract everything before export const web3Seeds
58
+ const headerEndIndex = content.indexOf('export const web3Seeds = [');
59
+ if (headerEndIndex === -1) {
60
+ console.error('Could not find web3Seeds export');
61
+ process.exit(1);
62
+ }
63
+
64
+ const header = content.substring(0, headerEndIndex);
65
+
66
+ // Extract the array content
67
+ const arrayStartIndex = headerEndIndex + 'export const web3Seeds = '.length;
68
+ const arrayEndIndex = content.lastIndexOf('];');
69
+ if (arrayEndIndex === -1) {
70
+ console.error('Could not find end of web3Seeds array');
71
+ process.exit(1);
72
+ }
73
+
74
+ const arrayContent = content.substring(arrayStartIndex, arrayEndIndex + 1);
75
+
76
+ // Parse the array
77
+ let nodes;
78
+ try {
79
+ nodes = JSON.parse(arrayContent);
80
+ } catch (e) {
81
+ console.error('Failed to parse nodes array:', e.message);
82
+ process.exit(1);
83
+ }
84
+
85
+ console.log(`✅ Loaded ${nodes.length} nodes`);
86
+
87
+ // Add tiers
88
+ let tierCounts = {};
89
+ const tieredNodes = nodes.map(node => {
90
+ const tier = getTier(node.service);
91
+ tierCounts[tier] = (tierCounts[tier] || 0) + 1;
92
+ return {
93
+ ...node,
94
+ tier,
95
+ };
96
+ });
97
+
98
+ console.log('\nTier distribution:');
99
+ Object.entries(tierCounts)
100
+ .sort((a, b) => {
101
+ const order = { premium: 1, reliable: 2, public: 3 };
102
+ return order[a[0]] - order[b[0]];
103
+ })
104
+ .forEach(([tier, count]) => {
105
+ const percent = ((count / nodes.length) * 100).toFixed(1);
106
+ console.log(` ${tier}: ${count} nodes (${percent}%)`);
107
+ });
108
+
109
+ // Generate new file content
110
+ const newArrayContent = JSON.stringify(tieredNodes, null, 4);
111
+ const footer = content.substring(arrayEndIndex + 2); // Everything after '];'
112
+ const newContent = `${header}export const web3Seeds = ${newArrayContent};${footer}`;
113
+
114
+ // Backup original
115
+ const backupPath = web3Path + '.backup';
116
+ fs.writeFileSync(backupPath, content, 'utf-8');
117
+ console.log(`\n📦 Backed up original to ${backupPath}`);
118
+
119
+ // Write new version
120
+ fs.writeFileSync(web3Path, newContent, 'utf-8');
121
+ console.log(`✅ Updated ${path.basename(web3Path)} with tier metadata`);
122
+
123
+ // Show sample of premium and reliable nodes
124
+ console.log('\n📊 Sample premium nodes:');
125
+ tieredNodes
126
+ .filter(n => n.tier === 'premium')
127
+ .slice(0, 3)
128
+ .forEach(n => console.log(` - ${n.service.substring(0, 60)}`));
129
+
130
+ console.log('\n📊 Sample reliable nodes:');
131
+ tieredNodes
132
+ .filter(n => n.tier === 'reliable')
133
+ .slice(0, 3)
134
+ .forEach(n => console.log(` - ${n.service.substring(0, 60)}`));
@@ -0,0 +1,135 @@
1
+ /**
2
+ * Add tier metadata to web3Seeds
3
+ *
4
+ * This script categorizes RPC nodes into tiers:
5
+ * - premium: Paid/premium services (Infura, Alchemy, etc.)
6
+ * - reliable: Well-known public services with good uptime
7
+ * - public: Community/free nodes
8
+ * - untrusted: New or unknown providers
9
+ */
10
+
11
+ const fs = require('fs');
12
+ const path = require('path');
13
+
14
+ // Premium providers (paid services, API keys, high reliability)
15
+ const PREMIUM_PROVIDERS = [
16
+ 'infura.io',
17
+ 'alchemy.com',
18
+ 'quicknode.pro',
19
+ 'nodereal.io',
20
+ 'chainnodes.org',
21
+ 'blast api.io',
22
+ 'ankr.com',
23
+ 'getblock.io',
24
+ ];
25
+
26
+ // Reliable providers (established free services, good track record)
27
+ const RELIABLE_PROVIDERS = [
28
+ 'llamarpc.com',
29
+ '1rpc.io',
30
+ 'rpc.ankr.com',
31
+ 'cloudflare-eth.com',
32
+ 'publicnode.com',
33
+ 'drpc.org',
34
+ 'tenderly.co',
35
+ 'omnia tech.io',
36
+ 'gateway.pokt.network',
37
+ 'rpc.flashbots.net',
38
+ 'eth.merkle.io',
39
+ ];
40
+
41
+ // Public providers (community nodes, may be less reliable)
42
+ const PUBLIC_PROVIDERS = [
43
+ 'api.zan.top',
44
+ 'core.gashawk.io',
45
+ 'eth.public-rpc.com',
46
+ 'rpc.payload.de',
47
+ 'ethereum.publicnode.com',
48
+ ];
49
+
50
+ /**
51
+ * Determine tier based on service URL
52
+ */
53
+ function getTier(service: string): string {
54
+ const url = service.toLowerCase();
55
+
56
+ for (const provider of PREMIUM_PROVIDERS) {
57
+ if (url.includes(provider.toLowerCase())) {
58
+ return 'premium';
59
+ }
60
+ }
61
+
62
+ for (const provider of RELIABLE_PROVIDERS) {
63
+ if (url.includes(provider.toLowerCase())) {
64
+ return 'reliable';
65
+ }
66
+ }
67
+
68
+ for (const provider of PUBLIC_PROVIDERS) {
69
+ if (url.includes(provider.toLowerCase())) {
70
+ return 'public';
71
+ }
72
+ }
73
+
74
+ // Default to public for unknown providers
75
+ return 'public';
76
+ }
77
+
78
+ /**
79
+ * Add tier to node entry
80
+ */
81
+ function addTierToNode(node: any): any {
82
+ const tier = getTier(node.service);
83
+ return {
84
+ ...node,
85
+ tier,
86
+ };
87
+ }
88
+
89
+ // Read web3.ts file
90
+ const web3Path = path.join(__dirname, '../src/web3.ts');
91
+ const content = fs.readFileSync(web3Path, 'utf-8');
92
+
93
+ // Extract the export const web3Seeds = [...] array
94
+ const match = content.match(/export const web3Seeds = \[([\s\S]*?)\];/);
95
+ if (!match) {
96
+ console.error('Could not find web3Seeds array in file');
97
+ process.exit(1);
98
+ }
99
+
100
+ const arrayContent = match[1];
101
+
102
+ // Parse nodes (simple JSON parse since it's valid JSON)
103
+ let nodes: any[];
104
+ try {
105
+ nodes = JSON.parse(`[${arrayContent}]`);
106
+ } catch (e) {
107
+ console.error('Failed to parse nodes:', e);
108
+ process.exit(1);
109
+ }
110
+
111
+ console.log(`Loaded ${nodes.length} nodes`);
112
+
113
+ // Add tiers
114
+ const tieredNodes = nodes.map(addTierToNode);
115
+
116
+ // Count by tier
117
+ const tierCounts: Record<string, number> = {};
118
+ tieredNodes.forEach(node => {
119
+ tierCounts[node.tier] = (tierCounts[node.tier] || 0) + 1;
120
+ });
121
+
122
+ console.log('\nTier distribution:');
123
+ Object.entries(tierCounts).forEach(([tier, count]) => {
124
+ console.log(` ${tier}: ${count} nodes`);
125
+ });
126
+
127
+ // Generate new file content
128
+ const header = content.substring(0, content.indexOf('export const web3Seeds = ['));
129
+ const newArrayContent = JSON.stringify(tieredNodes, null, 4);
130
+ const newContent = `${header}export const web3Seeds = ${newArrayContent};\n`;
131
+
132
+ // Write back to file
133
+ fs.writeFileSync(web3Path, newContent, 'utf-8');
134
+
135
+ console.log(`\n✅ Updated ${web3Path} with tier metadata`);
package/tsconfig.json CHANGED
@@ -9,5 +9,13 @@
9
9
  "strict": true,
10
10
  "types": ["node"],
11
11
  "esModuleInterop": true
12
- }
12
+ },
13
+ "include": [
14
+ "src/**/*"
15
+ ],
16
+ "exclude": [
17
+ "lib",
18
+ "node_modules",
19
+ "src/validate-nodes.ts"
20
+ ]
13
21
  }