ghost-portal/packages/app-extrinsics/src/encode/param.js
Jaco Greeff d589964bf2
Simple block exploration app (#2)
* Updates

* s/app-testing/app-extrinsics/

* Run components as apps using url

* Redirect to /home

* Expand Portal with NotFound app component

* New block numbers & hashes are being shown

* Only display best block once

* best block -> best

* TODO for calcHash

* Explorer aligns with blockNumber/hash

* Break signing into seperate modal

* Cleanups with @flow

* Adjust Dropdown for methods

* Remove (for now) unused app-home

* Update deps
2018-04-23 17:25:00 +02:00

24 lines
640 B
JavaScript

// Copyright 2017-2018 Jaco Greeff
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
// @flow
import type { Extrinsic$Type } from '../extrinsics/types';
const bnToU8a = require('@polkadot/util/bn/toU8a');
// flowlint-next-line unclear-type:off
module.exports = function encodeValue (value: any, type: Extrinsic$Type): Uint8Array {
switch (type) {
case 'AccountId':
return value;
case 'Balance':
case 'BlockNumber':
return bnToU8a(value, 64, true);
default:
throw new Error(`Unable to encode value with type '${type}'`);
}
};