Oracle data parsing and encoding utilities for the DecentralChain blockchain.
Provides structured access to on-chain oracle data entries — defining how oracle key-value data is encoded, decoded, and validated. Parse data transaction fields into typed provider and asset objects, convert them back to fields, and compute diffs between data states.
Part of the DecentralChain SDK.
npm install @decentralchain/oracle-dataRequires Node.js >= 24 and an ESM environment (
"type": "module").
import {
getProviderData,
getProviderAssets,
getFieldsFromData,
getFieldsFromAsset,
getDifferenceByData,
getDifferenceByFields,
getFields,
} from '@decentralchain/oracle-data';
// Parse oracle provider data from on-chain data transaction fields
const providerResult = getProviderData(dataTxFields);
if (providerResult.status === 'ok') {
console.log(providerResult.content.name);
}
// Parse oracle asset data
const assets = getProviderAssets(dataTxFields);
// Convert provider data back to data transaction fields
const fields = getFieldsFromData(providerResult.content);
// Convert asset data back to fields
const assetFields = getFieldsFromAsset(asset);
// Get the diff between two provider data objects
const diff = getDifferenceByData(oldProvider, newProvider);
// Get the diff between two sets of raw fields
const fieldDiff = getDifferenceByFields(oldFields, newFields);
// Auto-detect provider vs asset and convert to fields
const autoFields = getFields(dataOrAsset);getProviderData(dataTxFields)— Parse oracle provider data from an array of data transaction fields. ReturnsTResponse<IProviderData>.getProviderAssets(dataTxFields)— Parse oracle asset data from an array of data transaction fields. ReturnsTResponse<TProviderAsset>[].
getFieldsFromData(data)— Convert provider data back to data transaction fields.getFieldsFromAsset(data)— Convert asset data back to data transaction fields.getFields(data)— Auto-detect type and convert to data transaction fields.
getDifferenceByData(previous, next)— Compute diff between two data objects of the same type.getDifferenceByFields(previous, next)— Compute diff between two arrays of data transaction fields.
IProviderData— Oracle provider metadata (name, link, email, version, description).IProviderAsset/TProviderAsset— Oracle asset data (id, status, ticker, logo, etc.).TDataTxField— A single data transaction field (string, integer, boolean, or binary).TResponse<T>— Success or error response wrapper.STATUS_LIST— Asset verification status enum.DATA_ENTRY_TYPES— Data entry type identifiers.
- Node.js >= 24 (see
.node-version) - npm >= 11 (latest stable recommended)
git clone https://github.com/Decentral-America/oracle-data.git
cd oracle-data
npm install| Command | Description |
|---|---|
npm run build |
Build distribution files (ESM + CJS) |
npm test |
Run tests with Vitest |
npm run test:watch |
Tests in watch mode |
npm run test:coverage |
Tests with V8 coverage |
npm run typecheck |
TypeScript type checking |
npm run lint |
Biome lint |
npm run lint:fix |
Biome lint with auto-fix |
npm run format |
Format with Biome |
npm run format:check |
Check formatting |
npm run check:publint |
Validate package structure |
npm run check:exports |
Validate type exports |
npm run check:size |
Check bundle size budget |
npm run validate |
Full CI validation pipeline |
npm run bulletproof |
Format + lint fix + typecheck + test |
npm run bulletproof:check |
CI-safe: check format + lint + tc + test |
All PRs must pass:
- Zero lint errors (
npm run lint) - Zero type errors (
npm run typecheck) - All tests passing with 90%+ coverage
- Bundle size within budget (
npm run check:size) - Valid package exports (
npm run check:publint && npm run check:exports)
| Package | Description |
|---|---|
@decentralchain/ts-types |
Core TypeScript type definitions |
@decentralchain/data-entities |
Asset, Money, and OrderPrice models |
@decentralchain/node-api-js |
Node REST API client |
@decentralchain/transactions |
Transaction builders and signers |
See CONTRIBUTING.md.
To report a vulnerability, see SECURITY.md.
MIT — Copyright (c) DecentralChain