@sodazone/ocelloids-client
v3.1.1
Published
Ocelloids client library
Readme
Ocelloids Client Library
TypeScript client library to interact with Ocelloids Service APIs.
Install
NPM
npm install @sodazone/ocelloids-clientYarn
yarn add @sodazone/ocelloids-clientUsage
import { createXcmAgent } from "@sodazone/ocelloids-client";
// create an xcm agent client
const agent = createXcmAgent({
httpUrl: "http://127.0.0.1:3000",
wsUrl: "ws://127.0.0.1:3000"
});
// subscribe on-demand
const ws = agent.subscribe({
senders: "*",
events: "*",
origins: ["urn:ocn:polkadot:2004"],
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.
Development
Enable corepack:
corepack enableInstall dependencies and build the project:
yarn && yarn buildTesting
Run unit tests:
yarn testRun unit tests with coverage report:
yarn test:coverageCompatibility
Compatible with browser environments, Node and Bun.
