Skip to content

Commit

Permalink
Merge pull request #87 from sodazone/baseline/agents
Browse files Browse the repository at this point in the history
Baseline/agents
  • Loading branch information
XY-Wang authored May 30, 2024
2 parents 4079380 + 4a099d6 commit 0c0d946
Show file tree
Hide file tree
Showing 110 changed files with 3,001 additions and 2,342 deletions.
51 changes: 27 additions & 24 deletions packages/client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,36 +21,39 @@ yarn add @sodazone/ocelloids-client
## Usage

```typescript
import { OcelloidsClient, isXcmReceived, isXcmSent } from "@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"
});

// 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)
const ws = client.subscribe<xcm.XcmInputs>({
agent: "xcm",
args: {
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)
});
```

Expand Down Expand Up @@ -80,4 +83,4 @@ yarn test

## Compatibility

Compatible with [browser environments, Node, Bun and Deno](/~https://github.com/sodazone/ocelloids-services/blob/main/packages/client/test).
Compatible with [browser environments, Node and Bun](/~https://github.com/sodazone/ocelloids-services/blob/main/packages/client/test).
111 changes: 0 additions & 111 deletions packages/client/deno-build.mjs

This file was deleted.

15 changes: 4 additions & 11 deletions packages/client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sodazone/ocelloids-client",
"version": "1.0.3-dev.0",
"version": "2.0.0",
"type": "module",
"description": "Ocelloids client library",
"author": "SO/DA <projects@soda.zone>",
Expand Down Expand Up @@ -32,24 +32,18 @@
"clean": true
},
"scripts": {
"build": "yarn build:ts && yarn build:api && yarn build:deno",
"build": "yarn build:ts && yarn build:api",
"build:ts": "tsup",
"build:api": "tsc && api-extractor run --local --verbose",
"build:deno": "node deno-build.mjs",
"test": "NODE_OPTIONS=\"--experimental-vm-modules --no-warnings\" jest",
"docs": "typedoc",
"lint": "biome check --apply src/**/*.ts"
},
"jest": {
"preset": "ts-jest",
"testEnvironment": "node",
"collectCoverage": true,
"testPathIgnorePatterns": [
"./deno_dist"
],
"coveragePathIgnorePatterns": [
".*/dist",
".*/deno_dist"
".*/dist"
],
"extensionsToTreatAsEsm": [
".ts"
Expand Down Expand Up @@ -83,6 +77,5 @@
},
"dependencies": {
"isows": "^1.0.4"
},
"stableVersion": "1.0.2"
}
}
Loading

0 comments on commit 0c0d946

Please sign in to comment.