sarvalabs / js-moi-sdk

JavaScript library to interact with MOI Protocol via RPC API
https://js-moi-sdk.docs.moi.technology/
Apache License 2.0
24 stars 2 forks source link

feat: add `newLogs` event to `WebSocketProvider` #88

Closed sarvalabs-harshrastogi closed 1 month ago

sarvalabs-harshrastogi commented 2 months ago

This pull request introduces a new newLogs event to the WebSocketProvider class. This enhancement allows for real-time emission of logs that match specified filters, improving our ability to handle and respond to blockchain events efficiently.

Example

import { WebSocketEvents, WebSocketProvider } from "js-moi-sdk";

const ws = new WebSocketProvider("ws://141.94.161.24:1602/ws");

ws.on(WebSocketEvents.CONNECT, () => {
  console.log("Connected to the WebSocket server");
});

const logEvent = {
  address: "0xb90f39fcf346ba3260518669495f5d368a8d1bb8023584f67e8a5671cf3c56ce",
  topics: [],
  height: [-1, -1],
};

ws.on(logEvent, (response) => console.log(response));

Changes include

Checklist

cloudflare-workers-and-pages[bot] commented 2 months ago

Deploying js-moi-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: d784354
Status: ✅  Deploy successful!
Preview URL: https://465708c1.js-moi-sdk.pages.dev
Branch Preview URL: https://refactor-ws-provider.js-moi-sdk.pages.dev

View logs