Skip to content

Dynamic codec namespaces #218

@0x009922

Description

@0x009922

Context:

  • Iroha has a WASM-based executor, which could declare its data model via the same schema.json format as used for the main Iroha data model. It is available via client.find.executorDataModel().
  • Iroha JS "hardcodes" the main Iroha data model as static codecs
  • Iroha JS doesn't provide tools to create a dynamic codec from the schema

In theory, the users of the SDK might want to use the schema returned from the FindExecutorDataModel query to encode something. For this, the SDK could provide some tooling like this:

import type { SchemaDefinition } from '@iroha/core/data-model/schema' 
// new API
import { DynamicNamespace } from '@iroha/core/codec'

const SCHEMA = {
  Foo: {
    Struct: [{ name: 'bar', type: 'String' }]
  }
} satisfies SchemaDefinition

const ns = new DynamicNamespace(SCHEMA)
const fooEncoded = ns.get('Foo')!.encode({ bar: 'hey' })

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions