Files
common/packages/trie-db/src/constants.ts
T
Jaco Greeff 80db504a3b Swap to using eslint (#435)
* WIP

* ... and more

* yet more...

* and examples (more-or-less) fixed

* Only problematic promisify left...

* Last batch

* rm config header

* Update

* Use Record

* Bumps
2019-07-14 11:12:46 +02:00

29 lines
743 B
TypeScript

// Copyright 2017-2019 @polkadot/trie-db 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 } from '@polkadot/trie-codec/types';
import { trieRoot } from '@polkadot/trie-hash';
export interface Constants {
EMPTY_NODE: Uint8Array;
EMPTY_HASH: Uint8Array;
EMPTY_HASH_STR: string;
EMPTY_U8A: Uint8Array;
}
export default function (codec: Codec): Constants {
const EMPTY_NODE = new Uint8Array();
const EMPTY_U8A = trieRoot([], codec);
const EMPTY_HASH = codec.hashing(EMPTY_U8A);
const EMPTY_HASH_STR = EMPTY_HASH.toString();
return {
EMPTY_NODE,
EMPTY_HASH,
EMPTY_HASH_STR,
EMPTY_U8A
};
}