@sodazone/ocelloids-client - v2.3.3-dev.0

Ocelloids Client Library

npm @sodazone/ocelloids-client

TypeScript client library to interact with Ocelloids Service APIs.

Documentation Site.

NPM

npm install @sodazone/ocelloids-client

Yarn

yarn add @sodazone/ocelloids-client
import { OcelloidsClient, xcm } from "@sodazone/ocelloids-client";

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

// get the agent API
const agent = client.agent<xcm.XcmInputs>("xcm");

// subscribe on-demand
const ws = agent.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(xcm.isXcmReceived(msg)) {
console.log("RECV", msg.subscriptionId);
} else if(xcm.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.

Enable corepack:

corepack enable

Install dependencies and build the project:

yarn && yarn build

Run unit tests:

yarn test

Run unit tests with coverage report:

yarn test:coverage

Compatible with browser environments, Node and Bun.