Skip to content

Decentral-America/oracle-data

DecentralChain

@decentralchain/oracle-data

Oracle data parsing and encoding utilities for the DecentralChain blockchain.

npm license bundle size node


Overview

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.

Installation

npm install @decentralchain/oracle-data

Requires Node.js >= 24 and an ESM environment ("type": "module").

Quick Start

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);

API Reference

Parsing

  • getProviderData(dataTxFields) — Parse oracle provider data from an array of data transaction fields. Returns TResponse<IProviderData>.
  • getProviderAssets(dataTxFields) — Parse oracle asset data from an array of data transaction fields. Returns TResponse<TProviderAsset>[].

Serialization

  • 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.

Diffing

  • 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.

Types

  • 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.

Development

Prerequisites

  • Node.js >= 24 (see .node-version)
  • npm >= 11 (latest stable recommended)

Setup

git clone https://github.com/Decentral-America/oracle-data.git
cd oracle-data
npm install

Scripts

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

Quality Gates

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)

Related packages

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

Contributing

See CONTRIBUTING.md.

Security

To report a vulnerability, see SECURITY.md.

License

MIT — Copyright (c) DecentralChain

About

Oracle data parsing and encoding utilities for the DecentralChain blockchain

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors