Files
proxmox/scripts/verify-ws-rpc-chain138.mjs
defiQUG fbda1b4beb
Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
docs: Ledger Live integration, contract deploy learnings, NEXT_STEPS updates
- ADD_CHAIN138_TO_LEDGER_LIVE: Ledger form done; public code review repo bis-innovations/LedgerLive; init/push commands
- CONTRACT_DEPLOYMENT_RUNBOOK: Chain 138 gas price 1 gwei, 36-addr check, TransactionMirror workaround
- CONTRACT_*: AddressMapper, MirrorManager deployed 2026-02-12; 36-address on-chain check
- NEXT_STEPS_FOR_YOU: Ledger done; steps completable now (no LAN); run-completable-tasks-from-anywhere
- MASTER_INDEX, OPERATOR_OPTIONAL, SMART_CONTRACTS_INVENTORY_SIMPLE: updates
- LEDGER_BLOCKCHAIN_INTEGRATION_COMPLETE: bis-innovations/LedgerLive reference

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 15:46:57 -08:00

90 lines
2.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env node
/**
* Verify WebSocket RPC for Chain 138 (wss://rpc-ws-pub.d-bis.org, wss://wss.defi-oracle.io).
* Sends eth_chainId and expects result "0x8a" (138).
* From LAN: set NPM_HOST=192.168.11.167 and use --resolve equivalent by connecting to that IP with Host header.
*
* Usage:
* node scripts/verify-ws-rpc-chain138.mjs [wss://rpc-ws-pub.d-bis.org|wss://wss.defi-oracle.io]
* NPM_HOST=192.168.11.167 node scripts/verify-ws-rpc-chain138.mjs # LAN: connect to NPMplus with Host
*
* Optional: npm install ws (or pnpm add -w ws)
*/
import { createRequire } from 'module';
const require = createRequire(import.meta.url);
const WSS_URL = process.argv[2] || 'wss://rpc-ws-pub.d-bis.org';
const NPM_HOST = process.env.NPM_HOST; // If set, connect to this IP with Host header (LAN test)
let WebSocket;
try {
WebSocket = require('ws');
} catch (e) {
console.error('Missing "ws" package. Run: pnpm add -w ws or npm install ws');
process.exit(1);
}
const url = NPM_HOST
? `wss://${NPM_HOST}`
: new URL(WSS_URL).href;
const options = NPM_HOST
? {
headers: { Host: new URL(WSS_URL).hostname },
rejectUnauthorized: false,
}
: {};
const payload = JSON.stringify({
jsonrpc: '2.0',
method: 'eth_chainId',
params: [],
id: 1,
});
console.log(`Connecting to ${url}${NPM_HOST ? ` (Host: ${new URL(WSS_URL).hostname})` : ''}...`);
const ws = new WebSocket(url, options);
const timeout = setTimeout(() => {
console.error('Timeout waiting for response');
ws.close();
process.exit(1);
}, 10000);
ws.on('open', () => {
ws.send(payload);
});
ws.on('message', (data) => {
clearTimeout(timeout);
try {
const j = JSON.parse(data.toString());
const result = j.result || j.error;
if (j.result === '0x8a' || (typeof j.result === 'string' && j.result.toLowerCase() === '0x8a')) {
console.log('OK:', JSON.stringify(j));
console.log('Chain ID: 0x8a (138) Defi Oracle Meta Mainnet');
ws.close();
process.exit(0);
} else {
console.error('Unexpected result:', JSON.stringify(j));
ws.close();
process.exit(1);
}
} catch (e) {
console.error('Parse error:', e.message);
ws.close();
process.exit(1);
}
});
ws.on('error', (err) => {
clearTimeout(timeout);
console.error('WebSocket error:', err.message);
process.exit(1);
});
ws.on('close', (code, reason) => {
if (code !== 1000 && process.exitCode === undefined) process.exit(1);
});