Files
server/chain.js
2025-05-06 22:27:14 -04:00

20 lines
591 B
JavaScript

import fs from "fs";
import {marks} from "./cache.js";
export const chainInfo = JSON.parse(fs.readFileSync('../contract/version.json')).chainInfo
console.log('chainInfo', chainInfo)
export async function joinChain( socket, chainId ) {
try {
if (socket.chainId)
socket.leave(socket.chainId)
socket.join(chainId)
socket.chainId = chainId
const items = await marks.items(chainId);
for (let [token, mark] of items)
socket.emit('mark.usd', chainId, token, mark)
} catch (e) {
console.error('joinChain', e)
}
}