Skip to content

SubQuery indexer for pallet-robonomics-cps #406

@akru

Description

@akru

SubQuery Integration

Architecture:

Robonomics Node → SubQuery Indexer → PostgreSQL → GraphQL API → UI/Apps

Implementation:

  • Create a SubQuery project specifically for pallet-robonomics-cps
  • Subscribe to all CPS pallet events: NodeCreated, NodeUpdated, NodeMoved, NodeDeleted, MetaSet, PayloadSet, CryptoProfileCreated
  • Build relational schema in PostgreSQL:
    nodes (id, parent_id, owner, meta_type, meta_data, payload_type, payload_data, created_at, updated_at)
    node_history (node_id, action, block_number, timestamp, old_value, new_value)
    crypto_profiles (id, algorithm, public_params)
    node_ownership_index (owner, node_id)
  • Expose GraphQL queries:
    • getTreeByRoot(rootId) - materialized tree structure
    • getNodesByOwner(account) - all nodes for owner
    • getNodeHistory(nodeId) - audit trail
    • searchNodes(filters) - advanced filtering

Benefits:

  • Battle-tested in Polkadot ecosystem
  • Built-in GraphQL API
  • Historical data & audit trails
  • Automatic schema generation
  • Multi-chain support

Example SubQuery Manifest:

specVersion: 1. 0.0
name: robonomics-cps-indexer
version: 1. 0.0
runner:
  node:
    name: '@subql/node-substrate'
    version: '*'
description: 'Indexer for Robonomics CPS Pallet'
repository: 'https://github.com/airalab/robonomics-cps-indexer'
schema:
  file: ./schema.graphql
network:
  chainId: '0x.. .'
  endpoint: 'wss://kusama.rpc.robonomics.network'
dataSources:
  - kind: substrate/Runtime
    startBlock: 1
    mapping:
      file: ./dist/index.js
      handlers:
        - handler: handleNodeCreated
          kind: substrate/EventHandler
          filter:
            module: cps
            method: NodeCreated
        - handler: handleNodeUpdated
          kind: substrate/EventHandler
          filter:
            module: cps
            method: NodeUpdated

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions