@nomyx/canton-projection
v0.1.0
Published
Projection engine for streaming Canton ledger events into pluggable stores
Readme
@nomyx/canton-projection
Projection engine for streaming Canton ledger events into pluggable stores.
Installation
npm install @nomyx/canton-projection @nomyx/canton-sdk wsQuick Start
import { ProjectionEngine, InMemoryStore } from '@nomyx/canton-projection';
import { CantonClient, SandboxAuth } from '@nomyx/canton-sdk';
const client = new CantonClient({
ledgerUrl: 'http://localhost:7575',
auth: new SandboxAuth('Alice'),
});
const store = new InMemoryStore();
const engine = new ProjectionEngine({ client, store });
// Map ledger events to store records
engine.register('Main:Asset', {
created: (event) => ({
id: event.contractId,
owner: event.payload.owner,
name: event.payload.name,
}),
archived: (event) => event.contractId,
});
await engine.start();
// Query projected data
const assets = store.getAll('Main:Asset');Stores
| Store | Description |
|-------|-------------|
| InMemoryStore | Simple in-process Map-backed store for development and testing |
| PlexusStore | Persists projections to a Plexus data layer collection |
Both stores implement the ProjectionStore interface, so you can swap them without
changing projection logic.
License
Apache-2.0 -- see LICENSE for details.
