diff --git a/packages/trie-db/src/BaseTrie.ts b/packages/trie-db/src/BaseTrie.ts index dc24fc732..24ee4a4d3 100644 --- a/packages/trie-db/src/BaseTrie.ts +++ b/packages/trie-db/src/BaseTrie.ts @@ -14,6 +14,7 @@ import assert from '@polkadot/util/assert'; import isU8a from '@polkadot/util/is/u8a'; import promisify from '@polkadot/util/promisify'; // import u8aToHex from '@polkadot/util/u8a/toHex'; +import keccakAsU8a from '@polkadot/util-crypto/keccak/asU8a'; import decodeRlp from '@polkadot/util-rlp/decode'; import { EMPTY_ROOT_U8A, EMPTY_ROOT_STR } from './constants'; @@ -41,7 +42,7 @@ export default class BaseTrie { putRaw: RawPutFn; semaphore: SemaphorePromise; - constructor (db: any, root: Uint8Array, hashing: HashFn) { + constructor (db: any, root: Uint8Array = EMPTY_ROOT_U8A, hashing: HashFn = keccakAsU8a) { this.putRaw = this._putRaw; this.semaphore = semaphore(1); diff --git a/packages/trie-db/src/CheckpointTrie.ts b/packages/trie-db/src/CheckpointTrie.ts index d1dec365b..587a22d24 100644 --- a/packages/trie-db/src/CheckpointTrie.ts +++ b/packages/trie-db/src/CheckpointTrie.ts @@ -36,7 +36,7 @@ export default class CheckpointTrie extends BaseTrie { __putDBs: any[]; // tslint:disable-line // @ts-ignore FIXME, we need to properly check the full file - constructor (db: any, root: Uint8Array, hashing: HashFn) { + constructor (db: any, root?: Uint8Array, hashing?: HashFn) { super(db, root, hashing); this._scratch = null; diff --git a/packages/trie-db/src/index.ts b/packages/trie-db/src/index.ts index 927e4e8cb..ba2352fca 100644 --- a/packages/trie-db/src/index.ts +++ b/packages/trie-db/src/index.ts @@ -6,10 +6,7 @@ import { HashFn } from './types'; // import logger from '@polkadot/util/logger'; -import keccakAsU8a from '@polkadot/util-crypto/keccak/asU8a'; - import CheckpointTrie from './CheckpointTrie'; -import { EMPTY_ROOT_U8A } from './constants'; import { prove, verifyProof } from './proof'; // const l = logger('trie'); @@ -18,7 +15,7 @@ export default class Trie extends CheckpointTrie { static prove = prove; static verifyProof = verifyProof; - constructor (db: any, root: Uint8Array = EMPTY_ROOT_U8A, hashing: HashFn = keccakAsU8a) { + constructor (db: any, root?: Uint8Array, hashing?: HashFn) { super(db, root, hashing); // l.debug('Created Trie');