1.0.2 • Published 1 month ago

@sodazone/ocelloids-client v1.0.2

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
1 month ago

Ocelloids Client Library

TypeScript client library to interact with Ocelloids Service APIs.

Documentation Site.

Usage

import { OcelloidsClient, isXcmReceived, isXcmSent } from "@sodazone/ocelloids-client";

const client = new OcelloidsClient({
  httpUrl: "http://127.0.0.1:3000",
  wsUrl: "ws://127.0.0.1:3000"
});

// subscribe on-demand
const ws = client.subscribe({
  origin: "urn:ocn:polkadot:2004",
  senders: "*",
  events: "*",
  destinations: [ 
    "urn:ocn:polkadot:0",
    "urn:ocn:polkadot:1000",
    "urn:ocn:polkadot:2000",
    "urn:ocn:polkadot:2034",
    "urn:ocn:polkadot:2104"
  ]
}, {
 onMessage: msg => {
   if(isXcmReceived(msg)) {
     console.log("RECV", msg.subscriptionId);
   } else if(isXcmSent(msg)) {
     console.log("SENT", msg.subscriptionId)
   }
   console.log(msg);
 },
 onError: error => console.log(error),
 onClose: event => console.log(event.reason)
});

Explore the documentation site for further details.

Development

Enable corepack:

corepack enable

Install dependencies and build the project:

yarn && yarn build

Testing

Run unit tests:

yarn test

Compatibility

Compatible with browser environments, Node, Bun and Deno.

1.0.2

1 month ago

1.0.1

1 month ago

1.0.0

2 months ago