Contract API for Rx/promises (#1520)

* wip with rxjs/promise

* add outcome process

* contract call decoding solved

* restore messages as dict, cleanup

* linting

* linting

* type fixes
This commit is contained in:
Keith Ingram
2019-10-31 19:47:14 +02:00
committed by GitHub
parent 64bc3fbffa
commit cf01c41b33
39 changed files with 1080 additions and 386 deletions
+23
View File
@@ -0,0 +1,23 @@
// Copyright 2017-2019 @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, TypeDefInfo, TypeDef } from '@polkadot/types/types';
import { Bytes, Option, createClass } from '@polkadot/types';
import { createType, createTypeUnsafe } from '@polkadot/types/codec';
import { compactStripLength } from '@polkadot/util';
export function formatData (value: Bytes, { info, type }: TypeDef): Codec {
const input = compactStripLength(value.toU8a(true))[1];
const data = createType('Data', input);
if (info === TypeDefInfo.Option) {
return new Option(
createClass(type),
createTypeUnsafe(type, [data], true)
);
}
return createTypeUnsafe(type, [data], true);
}