* Bump deps, type import on generated * type imports in types/types * Re-export defs * Split imports/exports * Additional type import * Remove import type * Remove dupes
20 lines
682 B
TypeScript
20 lines
682 B
TypeScript
// Copyright 2017-2020 @polkadot/rpc-core authors & contributors
|
|
// This software may be modified and distributed under the terms
|
|
// of the Apache-2.0 license. See the LICENSE file for details.
|
|
|
|
import { Codec, Registry, TypeDef, TypeDefInfo } from '@polkadot/types/types';
|
|
|
|
import { Option, Raw, createClass, createTypeUnsafe } from '@polkadot/types';
|
|
|
|
export function formatData (registry: Registry, data: Raw, { info, type }: TypeDef): Codec {
|
|
if (info === TypeDefInfo.Option) {
|
|
return new Option(
|
|
registry,
|
|
createClass(registry, type),
|
|
createTypeUnsafe(registry, type, [data], true)
|
|
);
|
|
}
|
|
|
|
return createTypeUnsafe(registry, type, [data], true);
|
|
}
|