From 3230663ae172eedcd80474b57083288add8e4df2 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Sun, 1 Nov 2020 14:44:14 +0100 Subject: [PATCH] 3.7 (#738) * 3.7 * Update new rules * RegExp * formatBalance cleanups * Revert * Formatting * fill * format test fix * cleanups * Cleanups * Expand bip39 tests * Cleanups * Cleanups --- CHANGELOG.md | 2 +- package.json | 4 +- packages/keyring/package.json | 6 +- packages/networks/package.json | 6 +- packages/networks/src/index.ts | 76 +- packages/util-crypto/package.json | 6 +- packages/util-crypto/src/base32/decode.ts | 41 +- packages/util-crypto/src/mnemonic/bip39-en.ts | 2051 +---------------- packages/util-crypto/src/mnemonic/bip39.ts | 67 +- .../util-crypto/src/mnemonic/generate.spec.ts | 18 +- packages/util-crypto/src/mnemonic/generate.ts | 4 +- .../src/mnemonic/toEntropy.spec.ts | 1 + .../util-crypto/src/mnemonic/toEntropy.ts | 11 +- .../src/mnemonic/toLegacySeed.spec.ts | 24 +- .../util-crypto/src/mnemonic/toLegacySeed.ts | 4 +- .../src/mnemonic/toMiniSecret.spec.ts | 16 +- .../util-crypto/src/mnemonic/toMiniSecret.ts | 4 +- .../util-crypto/src/mnemonic/validate.spec.ts | 6 + packages/util-crypto/src/mnemonic/validate.ts | 4 +- packages/util/package.json | 6 +- packages/util/src/bn/toU8a.ts | 31 +- .../util/src/format/formatBalance.spec.ts | 6 + packages/util/src/format/formatBalance.ts | 4 +- packages/util/src/format/formatDecimal.ts | 1 + packages/util/src/format/formatElapsed.ts | 41 +- packages/util/src/hex/toBn.ts | 2 +- packages/util/src/is/ascii.ts | 10 +- packages/util/src/is/testChain.ts | 2 +- packages/util/src/logger.spec.ts | 10 +- packages/util/src/logger.ts | 21 +- packages/util/src/polyfill/fill.ts | 50 +- packages/util/src/u8a/toHex.ts | 33 +- packages/x-fetch/package.json | 2 +- packages/x-textdecoder/package.json | 2 +- packages/x-textencoder/package.json | 2 +- packages/x-ws/package.json | 2 +- yarn.lock | 203 +- 37 files changed, 345 insertions(+), 2434 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a5ddf9512..af398b144 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # CHANGELOG -## 3.6.2-x +## 3.7.1 Nov 1, 2020 Changes: diff --git a/package.json b/package.json index b7d7f0037..d18b0ad21 100644 --- a/package.json +++ b/package.json @@ -22,9 +22,9 @@ }, "devDependencies": { "@babel/core": "^7.12.3", - "@polkadot/dev": "^0.59.10", + "@polkadot/dev": "^0.59.12", "@polkadot/ts": "^0.3.53", "@types/jest": "^26.0.15" }, - "version": "3.6.2-12" + "version": "3.7.0" } diff --git a/packages/keyring/package.json b/packages/keyring/package.json index d3a9a6210..36fa8e4f7 100644 --- a/packages/keyring/package.json +++ b/packages/keyring/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/keyring", - "version": "3.6.2-12", + "version": "3.7.0", "description": "Keyring management", "main": "index.js", "publishConfig": { @@ -28,7 +28,7 @@ "homepage": "https://github.com/polkadot-js/common/tree/master/packages/keyring#readme", "dependencies": { "@babel/runtime": "^7.12.1", - "@polkadot/util": "^3.6.2-12", - "@polkadot/util-crypto": "^3.6.2-12" + "@polkadot/util": "^3.7.0", + "@polkadot/util-crypto": "^3.7.0" } } diff --git a/packages/networks/package.json b/packages/networks/package.json index 0656ffefb..e14ac4df8 100644 --- a/packages/networks/package.json +++ b/packages/networks/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/networks", - "version": "3.6.2-12", + "version": "3.7.0", "description": "A list of all available Substrate networks and their applicable prefixes", "main": "index.js", "publishConfig": { @@ -29,7 +29,7 @@ "@babel/runtime": "^7.12.1" }, "devDependencies": { - "@polkadot/util": "^3.6.2-12", - "@polkadot/x-fetch": "^3.6.2-12" + "@polkadot/util": "^3.7.0", + "@polkadot/x-fetch": "^3.7.0" } } diff --git a/packages/networks/src/index.ts b/packages/networks/src/index.ts index 4ba54ebd9..91ca45492 100644 --- a/packages/networks/src/index.ts +++ b/packages/networks/src/index.ts @@ -11,6 +11,16 @@ const UNSORTED = [0, 2, 42]; // last. This make lookups for the current a simple genesisHash[0] // (See Kusama as an example) +const createReserved = (prefix: number, displayName = 'This prefix is reserved.'): NetworkFromSubstrate => ({ + decimals: null, + displayName, + network: `reserved${prefix}`, + prefix, + standardAccount: null, + symbols: null, + website: null +}); + const all: NetworkFromSubstrate[] = [ { decimals: [10], @@ -23,15 +33,7 @@ const all: NetworkFromSubstrate[] = [ symbols: ['DOT'], website: 'https://polkadot.network' }, - { - decimals: null, - displayName: 'This prefix is reserved.', - network: 'reserved1', - prefix: 1, - standardAccount: null, - symbols: null, - website: null - }, + createReserved(1), { decimals: [12], displayName: 'Kusama Relay Chain', @@ -47,15 +49,7 @@ const all: NetworkFromSubstrate[] = [ symbols: ['KSM'], website: 'https://kusama.network' }, - { - decimals: null, - displayName: 'This prefix is reserved.', - network: 'reserved3', - prefix: 3, - standardAccount: null, - symbols: null, - website: null - }, + createReserved(3), { decimals: null, displayName: 'Katal Chain', @@ -195,14 +189,14 @@ const all: NetworkFromSubstrate[] = [ website: 'https://geekcash.org' }, { - decimals: null, + decimals: [12], displayName: 'Stafi', genesisHash: ['0x290a4149f09ea0e402c74c1c7e96ae4239588577fe78932f94f5404c68243d80'], network: 'stafi', prefix: 20, standardAccount: '*25519', - symbols: null, - website: null + symbols: ['FIS'], + website: 'https://stafi.io' }, { decimals: [6], @@ -333,15 +327,7 @@ const all: NetworkFromSubstrate[] = [ symbols: null, website: 'https://substrate.dev/' }, - { - decimals: null, - displayName: 'This prefix is reserved.', - network: 'reserved43', - prefix: 43, - standardAccount: null, - symbols: null, - website: null - }, + createReserved(43), { decimals: [8], displayName: 'ChainX', @@ -351,33 +337,9 @@ const all: NetworkFromSubstrate[] = [ symbols: ['PCX'], website: 'https://chainx.org/' }, - { - decimals: null, - displayName: 'This prefix is reserved.', - network: 'reserved46', - prefix: 46, - standardAccount: null, - symbols: null, - website: null - }, - { - decimals: null, - displayName: 'This prefix is reserved.', - network: 'reserved47', - prefix: 47, - standardAccount: null, - symbols: null, - website: null - }, - { - decimals: null, - displayName: 'All prefixes 48 and higher are reserved and cannot be allocated.', - network: 'reserved48', - prefix: 48, - standardAccount: null, - symbols: null, - website: null - } + createReserved(46), + createReserved(47), + createReserved(48, 'All prefixes 48 and higher are reserved and cannot be allocated.') ]; // The list of available/claimed prefixes diff --git a/packages/util-crypto/package.json b/packages/util-crypto/package.json index 4f054c895..f11c3f0a0 100644 --- a/packages/util-crypto/package.json +++ b/packages/util-crypto/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/util-crypto", - "version": "3.6.2-12", + "version": "3.7.0", "description": "A collection of useful crypto utilities for @polkadot", "main": "index.js", "keywords": [ @@ -26,8 +26,8 @@ "homepage": "https://github.com/polkadot-js/common/tree/master/packages/util-crypto#readme", "dependencies": { "@babel/runtime": "^7.12.1", - "@polkadot/networks": "^3.6.2-12", - "@polkadot/util": "^3.6.2-12", + "@polkadot/networks": "^3.7.0", + "@polkadot/util": "^3.7.0", "@polkadot/wasm-crypto": "^1.4.1", "base-x": "^3.0.8", "blakejs": "^1.1.0", diff --git a/packages/util-crypto/src/base32/decode.ts b/packages/util-crypto/src/base32/decode.ts index 89a64b58d..d778852e1 100644 --- a/packages/util-crypto/src/base32/decode.ts +++ b/packages/util-crypto/src/base32/decode.ts @@ -17,6 +17,25 @@ const LOOKUP = BASE32_ALPHABET return lookup; }, {}); +/** @internal */ +function decode (output: Uint8Array, input: string, offset: number): [Uint8Array, number, number] { + let bits = 0; + let buffer = 0; + let written = 0; + + for (let i = offset; i < input.length; i++) { + buffer = (buffer << BITS_PER_CHAR) | LOOKUP[input[i]]; + bits += BITS_PER_CHAR; + + if (bits >= 8) { + bits -= 8; + output[written++] = 0xff & (buffer >> bits); + } + } + + return [output, bits, buffer]; +} + /** * @name base32Decode * @summary Delookup a base32 value. @@ -26,22 +45,14 @@ const LOOKUP = BASE32_ALPHABET export default function base32Decode (value: string, ipfsCompat = false): Uint8Array { validate(value, ipfsCompat); - const out = new Uint8Array(((value.length - (ipfsCompat ? 1 : 0)) * BITS_PER_CHAR / 8) | 0); - let bits = 0; - let buffer = 0; - let written = 0; - - for (let i = (ipfsCompat ? 1 : 0); i < value.length; ++i) { - buffer = (buffer << BITS_PER_CHAR) | LOOKUP[value[i]]; - bits += BITS_PER_CHAR; - - if (bits >= 8) { - bits -= 8; - out[written++] = 0xff & (buffer >> bits); - } - } + const offset = (ipfsCompat ? 1 : 0); + const [output, bits, buffer] = decode( + new Uint8Array(((value.length - offset) * BITS_PER_CHAR / 8) | 0), + value, + offset + ); assert(!(bits >= BITS_PER_CHAR || 0xff & (buffer << (8 - bits))), 'Unexpected end of data'); - return out; + return output; } diff --git a/packages/util-crypto/src/mnemonic/bip39-en.ts b/packages/util-crypto/src/mnemonic/bip39-en.ts index d1eb76145..f2464ec89 100644 --- a/packages/util-crypto/src/mnemonic/bip39-en.ts +++ b/packages/util-crypto/src/mnemonic/bip39-en.ts @@ -4,2053 +4,4 @@ // Adapted from the bitcoinjs/bip39 source // https://github.com/bitcoinjs/bip39/blob/1d063b6a6aee4145b34d701037cd3e67f5446ff9/ts_src/ -export default [ - 'abandon', - 'ability', - 'able', - 'about', - 'above', - 'absent', - 'absorb', - 'abstract', - 'absurd', - 'abuse', - 'access', - 'accident', - 'account', - 'accuse', - 'achieve', - 'acid', - 'acoustic', - 'acquire', - 'across', - 'act', - 'action', - 'actor', - 'actress', - 'actual', - 'adapt', - 'add', - 'addict', - 'address', - 'adjust', - 'admit', - 'adult', - 'advance', - 'advice', - 'aerobic', - 'affair', - 'afford', - 'afraid', - 'again', - 'age', - 'agent', - 'agree', - 'ahead', - 'aim', - 'air', - 'airport', - 'aisle', - 'alarm', - 'album', - 'alcohol', - 'alert', - 'alien', - 'all', - 'alley', - 'allow', - 'almost', - 'alone', - 'alpha', - 'already', - 'also', - 'alter', - 'always', - 'amateur', - 'amazing', - 'among', - 'amount', - 'amused', - 'analyst', - 'anchor', - 'ancient', - 'anger', - 'angle', - 'angry', - 'animal', - 'ankle', - 'announce', - 'annual', - 'another', - 'answer', - 'antenna', - 'antique', - 'anxiety', - 'any', - 'apart', - 'apology', - 'appear', - 'apple', - 'approve', - 'april', - 'arch', - 'arctic', - 'area', - 'arena', - 'argue', - 'arm', - 'armed', - 'armor', - 'army', - 'around', - 'arrange', - 'arrest', - 'arrive', - 'arrow', - 'art', - 'artefact', - 'artist', - 'artwork', - 'ask', - 'aspect', - 'assault', - 'asset', - 'assist', - 'assume', - 'asthma', - 'athlete', - 'atom', - 'attack', - 'attend', - 'attitude', - 'attract', - 'auction', - 'audit', - 'august', - 'aunt', - 'author', - 'auto', - 'autumn', - 'average', - 'avocado', - 'avoid', - 'awake', - 'aware', - 'away', - 'awesome', - 'awful', - 'awkward', - 'axis', - 'baby', - 'bachelor', - 'bacon', - 'badge', - 'bag', - 'balance', - 'balcony', - 'ball', - 'bamboo', - 'banana', - 'banner', - 'bar', - 'barely', - 'bargain', - 'barrel', - 'base', - 'basic', - 'basket', - 'battle', - 'beach', - 'bean', - 'beauty', - 'because', - 'become', - 'beef', - 'before', - 'begin', - 'behave', - 'behind', - 'believe', - 'below', - 'belt', - 'bench', - 'benefit', - 'best', - 'betray', - 'better', - 'between', - 'beyond', - 'bicycle', - 'bid', - 'bike', - 'bind', - 'biology', - 'bird', - 'birth', - 'bitter', - 'black', - 'blade', - 'blame', - 'blanket', - 'blast', - 'bleak', - 'bless', - 'blind', - 'blood', - 'blossom', - 'blouse', - 'blue', - 'blur', - 'blush', - 'board', - 'boat', - 'body', - 'boil', - 'bomb', - 'bone', - 'bonus', - 'book', - 'boost', - 'border', - 'boring', - 'borrow', - 'boss', - 'bottom', - 'bounce', - 'box', - 'boy', - 'bracket', - 'brain', - 'brand', - 'brass', - 'brave', - 'bread', - 'breeze', - 'brick', - 'bridge', - 'brief', - 'bright', - 'bring', - 'brisk', - 'broccoli', - 'broken', - 'bronze', - 'broom', - 'brother', - 'brown', - 'brush', - 'bubble', - 'buddy', - 'budget', - 'buffalo', - 'build', - 'bulb', - 'bulk', - 'bullet', - 'bundle', - 'bunker', - 'burden', - 'burger', - 'burst', - 'bus', - 'business', - 'busy', - 'butter', - 'buyer', - 'buzz', - 'cabbage', - 'cabin', - 'cable', - 'cactus', - 'cage', - 'cake', - 'call', - 'calm', - 'camera', - 'camp', - 'can', - 'canal', - 'cancel', - 'candy', - 'cannon', - 'canoe', - 'canvas', - 'canyon', - 'capable', - 'capital', - 'captain', - 'car', - 'carbon', - 'card', - 'cargo', - 'carpet', - 'carry', - 'cart', - 'case', - 'cash', - 'casino', - 'castle', - 'casual', - 'cat', - 'catalog', - 'catch', - 'category', - 'cattle', - 'caught', - 'cause', - 'caution', - 'cave', - 'ceiling', - 'celery', - 'cement', - 'census', - 'century', - 'cereal', - 'certain', - 'chair', - 'chalk', - 'champion', - 'change', - 'chaos', - 'chapter', - 'charge', - 'chase', - 'chat', - 'cheap', - 'check', - 'cheese', - 'chef', - 'cherry', - 'chest', - 'chicken', - 'chief', - 'child', - 'chimney', - 'choice', - 'choose', - 'chronic', - 'chuckle', - 'chunk', - 'churn', - 'cigar', - 'cinnamon', - 'circle', - 'citizen', - 'city', - 'civil', - 'claim', - 'clap', - 'clarify', - 'claw', - 'clay', - 'clean', - 'clerk', - 'clever', - 'click', - 'client', - 'cliff', - 'climb', - 'clinic', - 'clip', - 'clock', - 'clog', - 'close', - 'cloth', - 'cloud', - 'clown', - 'club', - 'clump', - 'cluster', - 'clutch', - 'coach', - 'coast', - 'coconut', - 'code', - 'coffee', - 'coil', - 'coin', - 'collect', - 'color', - 'column', - 'combine', - 'come', - 'comfort', - 'comic', - 'common', - 'company', - 'concert', - 'conduct', - 'confirm', - 'congress', - 'connect', - 'consider', - 'control', - 'convince', - 'cook', - 'cool', - 'copper', - 'copy', - 'coral', - 'core', - 'corn', - 'correct', - 'cost', - 'cotton', - 'couch', - 'country', - 'couple', - 'course', - 'cousin', - 'cover', - 'coyote', - 'crack', - 'cradle', - 'craft', - 'cram', - 'crane', - 'crash', - 'crater', - 'crawl', - 'crazy', - 'cream', - 'credit', - 'creek', - 'crew', - 'cricket', - 'crime', - 'crisp', - 'critic', - 'crop', - 'cross', - 'crouch', - 'crowd', - 'crucial', - 'cruel', - 'cruise', - 'crumble', - 'crunch', - 'crush', - 'cry', - 'crystal', - 'cube', - 'culture', - 'cup', - 'cupboard', - 'curious', - 'current', - 'curtain', - 'curve', - 'cushion', - 'custom', - 'cute', - 'cycle', - 'dad', - 'damage', - 'damp', - 'dance', - 'danger', - 'daring', - 'dash', - 'daughter', - 'dawn', - 'day', - 'deal', - 'debate', - 'debris', - 'decade', - 'december', - 'decide', - 'decline', - 'decorate', - 'decrease', - 'deer', - 'defense', - 'define', - 'defy', - 'degree', - 'delay', - 'deliver', - 'demand', - 'demise', - 'denial', - 'dentist', - 'deny', - 'depart', - 'depend', - 'deposit', - 'depth', - 'deputy', - 'derive', - 'describe', - 'desert', - 'design', - 'desk', - 'despair', - 'destroy', - 'detail', - 'detect', - 'develop', - 'device', - 'devote', - 'diagram', - 'dial', - 'diamond', - 'diary', - 'dice', - 'diesel', - 'diet', - 'differ', - 'digital', - 'dignity', - 'dilemma', - 'dinner', - 'dinosaur', - 'direct', - 'dirt', - 'disagree', - 'discover', - 'disease', - 'dish', - 'dismiss', - 'disorder', - 'display', - 'distance', - 'divert', - 'divide', - 'divorce', - 'dizzy', - 'doctor', - 'document', - 'dog', - 'doll', - 'dolphin', - 'domain', - 'donate', - 'donkey', - 'donor', - 'door', - 'dose', - 'double', - 'dove', - 'draft', - 'dragon', - 'drama', - 'drastic', - 'draw', - 'dream', - 'dress', - 'drift', - 'drill', - 'drink', - 'drip', - 'drive', - 'drop', - 'drum', - 'dry', - 'duck', - 'dumb', - 'dune', - 'during', - 'dust', - 'dutch', - 'duty', - 'dwarf', - 'dynamic', - 'eager', - 'eagle', - 'early', - 'earn', - 'earth', - 'easily', - 'east', - 'easy', - 'echo', - 'ecology', - 'economy', - 'edge', - 'edit', - 'educate', - 'effort', - 'egg', - 'eight', - 'either', - 'elbow', - 'elder', - 'electric', - 'elegant', - 'element', - 'elephant', - 'elevator', - 'elite', - 'else', - 'embark', - 'embody', - 'embrace', - 'emerge', - 'emotion', - 'employ', - 'empower', - 'empty', - 'enable', - 'enact', - 'end', - 'endless', - 'endorse', - 'enemy', - 'energy', - 'enforce', - 'engage', - 'engine', - 'enhance', - 'enjoy', - 'enlist', - 'enough', - 'enrich', - 'enroll', - 'ensure', - 'enter', - 'entire', - 'entry', - 'envelope', - 'episode', - 'equal', - 'equip', - 'era', - 'erase', - 'erode', - 'erosion', - 'error', - 'erupt', - 'escape', - 'essay', - 'essence', - 'estate', - 'eternal', - 'ethics', - 'evidence', - 'evil', - 'evoke', - 'evolve', - 'exact', - 'example', - 'excess', - 'exchange', - 'excite', - 'exclude', - 'excuse', - 'execute', - 'exercise', - 'exhaust', - 'exhibit', - 'exile', - 'exist', - 'exit', - 'exotic', - 'expand', - 'expect', - 'expire', - 'explain', - 'expose', - 'express', - 'extend', - 'extra', - 'eye', - 'eyebrow', - 'fabric', - 'face', - 'faculty', - 'fade', - 'faint', - 'faith', - 'fall', - 'false', - 'fame', - 'family', - 'famous', - 'fan', - 'fancy', - 'fantasy', - 'farm', - 'fashion', - 'fat', - 'fatal', - 'father', - 'fatigue', - 'fault', - 'favorite', - 'feature', - 'february', - 'federal', - 'fee', - 'feed', - 'feel', - 'female', - 'fence', - 'festival', - 'fetch', - 'fever', - 'few', - 'fiber', - 'fiction', - 'field', - 'figure', - 'file', - 'film', - 'filter', - 'final', - 'find', - 'fine', - 'finger', - 'finish', - 'fire', - 'firm', - 'first', - 'fiscal', - 'fish', - 'fit', - 'fitness', - 'fix', - 'flag', - 'flame', - 'flash', - 'flat', - 'flavor', - 'flee', - 'flight', - 'flip', - 'float', - 'flock', - 'floor', - 'flower', - 'fluid', - 'flush', - 'fly', - 'foam', - 'focus', - 'fog', - 'foil', - 'fold', - 'follow', - 'food', - 'foot', - 'force', - 'forest', - 'forget', - 'fork', - 'fortune', - 'forum', - 'forward', - 'fossil', - 'foster', - 'found', - 'fox', - 'fragile', - 'frame', - 'frequent', - 'fresh', - 'friend', - 'fringe', - 'frog', - 'front', - 'frost', - 'frown', - 'frozen', - 'fruit', - 'fuel', - 'fun', - 'funny', - 'furnace', - 'fury', - 'future', - 'gadget', - 'gain', - 'galaxy', - 'gallery', - 'game', - 'gap', - 'garage', - 'garbage', - 'garden', - 'garlic', - 'garment', - 'gas', - 'gasp', - 'gate', - 'gather', - 'gauge', - 'gaze', - 'general', - 'genius', - 'genre', - 'gentle', - 'genuine', - 'gesture', - 'ghost', - 'giant', - 'gift', - 'giggle', - 'ginger', - 'giraffe', - 'girl', - 'give', - 'glad', - 'glance', - 'glare', - 'glass', - 'glide', - 'glimpse', - 'globe', - 'gloom', - 'glory', - 'glove', - 'glow', - 'glue', - 'goat', - 'goddess', - 'gold', - 'good', - 'goose', - 'gorilla', - 'gospel', - 'gossip', - 'govern', - 'gown', - 'grab', - 'grace', - 'grain', - 'grant', - 'grape', - 'grass', - 'gravity', - 'great', - 'green', - 'grid', - 'grief', - 'grit', - 'grocery', - 'group', - 'grow', - 'grunt', - 'guard', - 'guess', - 'guide', - 'guilt', - 'guitar', - 'gun', - 'gym', - 'habit', - 'hair', - 'half', - 'hammer', - 'hamster', - 'hand', - 'happy', - 'harbor', - 'hard', - 'harsh', - 'harvest', - 'hat', - 'have', - 'hawk', - 'hazard', - 'head', - 'health', - 'heart', - 'heavy', - 'hedgehog', - 'height', - 'hello', - 'helmet', - 'help', - 'hen', - 'hero', - 'hidden', - 'high', - 'hill', - 'hint', - 'hip', - 'hire', - 'history', - 'hobby', - 'hockey', - 'hold', - 'hole', - 'holiday', - 'hollow', - 'home', - 'honey', - 'hood', - 'hope', - 'horn', - 'horror', - 'horse', - 'hospital', - 'host', - 'hotel', - 'hour', - 'hover', - 'hub', - 'huge', - 'human', - 'humble', - 'humor', - 'hundred', - 'hungry', - 'hunt', - 'hurdle', - 'hurry', - 'hurt', - 'husband', - 'hybrid', - 'ice', - 'icon', - 'idea', - 'identify', - 'idle', - 'ignore', - 'ill', - 'illegal', - 'illness', - 'image', - 'imitate', - 'immense', - 'immune', - 'impact', - 'impose', - 'improve', - 'impulse', - 'inch', - 'include', - 'income', - 'increase', - 'index', - 'indicate', - 'indoor', - 'industry', - 'infant', - 'inflict', - 'inform', - 'inhale', - 'inherit', - 'initial', - 'inject', - 'injury', - 'inmate', - 'inner', - 'innocent', - 'input', - 'inquiry', - 'insane', - 'insect', - 'inside', - 'inspire', - 'install', - 'intact', - 'interest', - 'into', - 'invest', - 'invite', - 'involve', - 'iron', - 'island', - 'isolate', - 'issue', - 'item', - 'ivory', - 'jacket', - 'jaguar', - 'jar', - 'jazz', - 'jealous', - 'jeans', - 'jelly', - 'jewel', - 'job', - 'join', - 'joke', - 'journey', - 'joy', - 'judge', - 'juice', - 'jump', - 'jungle', - 'junior', - 'junk', - 'just', - 'kangaroo', - 'keen', - 'keep', - 'ketchup', - 'key', - 'kick', - 'kid', - 'kidney', - 'kind', - 'kingdom', - 'kiss', - 'kit', - 'kitchen', - 'kite', - 'kitten', - 'kiwi', - 'knee', - 'knife', - 'knock', - 'know', - 'lab', - 'label', - 'labor', - 'ladder', - 'lady', - 'lake', - 'lamp', - 'language', - 'laptop', - 'large', - 'later', - 'latin', - 'laugh', - 'laundry', - 'lava', - 'law', - 'lawn', - 'lawsuit', - 'layer', - 'lazy', - 'leader', - 'leaf', - 'learn', - 'leave', - 'lecture', - 'left', - 'leg', - 'legal', - 'legend', - 'leisure', - 'lemon', - 'lend', - 'length', - 'lens', - 'leopard', - 'lesson', - 'letter', - 'level', - 'liar', - 'liberty', - 'library', - 'license', - 'life', - 'lift', - 'light', - 'like', - 'limb', - 'limit', - 'link', - 'lion', - 'liquid', - 'list', - 'little', - 'live', - 'lizard', - 'load', - 'loan', - 'lobster', - 'local', - 'lock', - 'logic', - 'lonely', - 'long', - 'loop', - 'lottery', - 'loud', - 'lounge', - 'love', - 'loyal', - 'lucky', - 'luggage', - 'lumber', - 'lunar', - 'lunch', - 'luxury', - 'lyrics', - 'machine', - 'mad', - 'magic', - 'magnet', - 'maid', - 'mail', - 'main', - 'major', - 'make', - 'mammal', - 'man', - 'manage', - 'mandate', - 'mango', - 'mansion', - 'manual', - 'maple', - 'marble', - 'march', - 'margin', - 'marine', - 'market', - 'marriage', - 'mask', - 'mass', - 'master', - 'match', - 'material', - 'math', - 'matrix', - 'matter', - 'maximum', - 'maze', - 'meadow', - 'mean', - 'measure', - 'meat', - 'mechanic', - 'medal', - 'media', - 'melody', - 'melt', - 'member', - 'memory', - 'mention', - 'menu', - 'mercy', - 'merge', - 'merit', - 'merry', - 'mesh', - 'message', - 'metal', - 'method', - 'middle', - 'midnight', - 'milk', - 'million', - 'mimic', - 'mind', - 'minimum', - 'minor', - 'minute', - 'miracle', - 'mirror', - 'misery', - 'miss', - 'mistake', - 'mix', - 'mixed', - 'mixture', - 'mobile', - 'model', - 'modify', - 'mom', - 'moment', - 'monitor', - 'monkey', - 'monster', - 'month', - 'moon', - 'moral', - 'more', - 'morning', - 'mosquito', - 'mother', - 'motion', - 'motor', - 'mountain', - 'mouse', - 'move', - 'movie', - 'much', - 'muffin', - 'mule', - 'multiply', - 'muscle', - 'museum', - 'mushroom', - 'music', - 'must', - 'mutual', - 'myself', - 'mystery', - 'myth', - 'naive', - 'name', - 'napkin', - 'narrow', - 'nasty', - 'nation', - 'nature', - 'near', - 'neck', - 'need', - 'negative', - 'neglect', - 'neither', - 'nephew', - 'nerve', - 'nest', - 'net', - 'network', - 'neutral', - 'never', - 'news', - 'next', - 'nice', - 'night', - 'noble', - 'noise', - 'nominee', - 'noodle', - 'normal', - 'north', - 'nose', - 'notable', - 'note', - 'nothing', - 'notice', - 'novel', - 'now', - 'nuclear', - 'number', - 'nurse', - 'nut', - 'oak', - 'obey', - 'object', - 'oblige', - 'obscure', - 'observe', - 'obtain', - 'obvious', - 'occur', - 'ocean', - 'october', - 'odor', - 'off', - 'offer', - 'office', - 'often', - 'oil', - 'okay', - 'old', - 'olive', - 'olympic', - 'omit', - 'once', - 'one', - 'onion', - 'online', - 'only', - 'open', - 'opera', - 'opinion', - 'oppose', - 'option', - 'orange', - 'orbit', - 'orchard', - 'order', - 'ordinary', - 'organ', - 'orient', - 'original', - 'orphan', - 'ostrich', - 'other', - 'outdoor', - 'outer', - 'output', - 'outside', - 'oval', - 'oven', - 'over', - 'own', - 'owner', - 'oxygen', - 'oyster', - 'ozone', - 'pact', - 'paddle', - 'page', - 'pair', - 'palace', - 'palm', - 'panda', - 'panel', - 'panic', - 'panther', - 'paper', - 'parade', - 'parent', - 'park', - 'parrot', - 'party', - 'pass', - 'patch', - 'path', - 'patient', - 'patrol', - 'pattern', - 'pause', - 'pave', - 'payment', - 'peace', - 'peanut', - 'pear', - 'peasant', - 'pelican', - 'pen', - 'penalty', - 'pencil', - 'people', - 'pepper', - 'perfect', - 'permit', - 'person', - 'pet', - 'phone', - 'photo', - 'phrase', - 'physical', - 'piano', - 'picnic', - 'picture', - 'piece', - 'pig', - 'pigeon', - 'pill', - 'pilot', - 'pink', - 'pioneer', - 'pipe', - 'pistol', - 'pitch', - 'pizza', - 'place', - 'planet', - 'plastic', - 'plate', - 'play', - 'please', - 'pledge', - 'pluck', - 'plug', - 'plunge', - 'poem', - 'poet', - 'point', - 'polar', - 'pole', - 'police', - 'pond', - 'pony', - 'pool', - 'popular', - 'portion', - 'position', - 'possible', - 'post', - 'potato', - 'pottery', - 'poverty', - 'powder', - 'power', - 'practice', - 'praise', - 'predict', - 'prefer', - 'prepare', - 'present', - 'pretty', - 'prevent', - 'price', - 'pride', - 'primary', - 'print', - 'priority', - 'prison', - 'private', - 'prize', - 'problem', - 'process', - 'produce', - 'profit', - 'program', - 'project', - 'promote', - 'proof', - 'property', - 'prosper', - 'protect', - 'proud', - 'provide', - 'public', - 'pudding', - 'pull', - 'pulp', - 'pulse', - 'pumpkin', - 'punch', - 'pupil', - 'puppy', - 'purchase', - 'purity', - 'purpose', - 'purse', - 'push', - 'put', - 'puzzle', - 'pyramid', - 'quality', - 'quantum', - 'quarter', - 'question', - 'quick', - 'quit', - 'quiz', - 'quote', - 'rabbit', - 'raccoon', - 'race', - 'rack', - 'radar', - 'radio', - 'rail', - 'rain', - 'raise', - 'rally', - 'ramp', - 'ranch', - 'random', - 'range', - 'rapid', - 'rare', - 'rate', - 'rather', - 'raven', - 'raw', - 'razor', - 'ready', - 'real', - 'reason', - 'rebel', - 'rebuild', - 'recall', - 'receive', - 'recipe', - 'record', - 'recycle', - 'reduce', - 'reflect', - 'reform', - 'refuse', - 'region', - 'regret', - 'regular', - 'reject', - 'relax', - 'release', - 'relief', - 'rely', - 'remain', - 'remember', - 'remind', - 'remove', - 'render', - 'renew', - 'rent', - 'reopen', - 'repair', - 'repeat', - 'replace', - 'report', - 'require', - 'rescue', - 'resemble', - 'resist', - 'resource', - 'response', - 'result', - 'retire', - 'retreat', - 'return', - 'reunion', - 'reveal', - 'review', - 'reward', - 'rhythm', - 'rib', - 'ribbon', - 'rice', - 'rich', - 'ride', - 'ridge', - 'rifle', - 'right', - 'rigid', - 'ring', - 'riot', - 'ripple', - 'risk', - 'ritual', - 'rival', - 'river', - 'road', - 'roast', - 'robot', - 'robust', - 'rocket', - 'romance', - 'roof', - 'rookie', - 'room', - 'rose', - 'rotate', - 'rough', - 'round', - 'route', - 'royal', - 'rubber', - 'rude', - 'rug', - 'rule', - 'run', - 'runway', - 'rural', - 'sad', - 'saddle', - 'sadness', - 'safe', - 'sail', - 'salad', - 'salmon', - 'salon', - 'salt', - 'salute', - 'same', - 'sample', - 'sand', - 'satisfy', - 'satoshi', - 'sauce', - 'sausage', - 'save', - 'say', - 'scale', - 'scan', - 'scare', - 'scatter', - 'scene', - 'scheme', - 'school', - 'science', - 'scissors', - 'scorpion', - 'scout', - 'scrap', - 'screen', - 'script', - 'scrub', - 'sea', - 'search', - 'season', - 'seat', - 'second', - 'secret', - 'section', - 'security', - 'seed', - 'seek', - 'segment', - 'select', - 'sell', - 'seminar', - 'senior', - 'sense', - 'sentence', - 'series', - 'service', - 'session', - 'settle', - 'setup', - 'seven', - 'shadow', - 'shaft', - 'shallow', - 'share', - 'shed', - 'shell', - 'sheriff', - 'shield', - 'shift', - 'shine', - 'ship', - 'shiver', - 'shock', - 'shoe', - 'shoot', - 'shop', - 'short', - 'shoulder', - 'shove', - 'shrimp', - 'shrug', - 'shuffle', - 'shy', - 'sibling', - 'sick', - 'side', - 'siege', - 'sight', - 'sign', - 'silent', - 'silk', - 'silly', - 'silver', - 'similar', - 'simple', - 'since', - 'sing', - 'siren', - 'sister', - 'situate', - 'six', - 'size', - 'skate', - 'sketch', - 'ski', - 'skill', - 'skin', - 'skirt', - 'skull', - 'slab', - 'slam', - 'sleep', - 'slender', - 'slice', - 'slide', - 'slight', - 'slim', - 'slogan', - 'slot', - 'slow', - 'slush', - 'small', - 'smart', - 'smile', - 'smoke', - 'smooth', - 'snack', - 'snake', - 'snap', - 'sniff', - 'snow', - 'soap', - 'soccer', - 'social', - 'sock', - 'soda', - 'soft', - 'solar', - 'soldier', - 'solid', - 'solution', - 'solve', - 'someone', - 'song', - 'soon', - 'sorry', - 'sort', - 'soul', - 'sound', - 'soup', - 'source', - 'south', - 'space', - 'spare', - 'spatial', - 'spawn', - 'speak', - 'special', - 'speed', - 'spell', - 'spend', - 'sphere', - 'spice', - 'spider', - 'spike', - 'spin', - 'spirit', - 'split', - 'spoil', - 'sponsor', - 'spoon', - 'sport', - 'spot', - 'spray', - 'spread', - 'spring', - 'spy', - 'square', - 'squeeze', - 'squirrel', - 'stable', - 'stadium', - 'staff', - 'stage', - 'stairs', - 'stamp', - 'stand', - 'start', - 'state', - 'stay', - 'steak', - 'steel', - 'stem', - 'step', - 'stereo', - 'stick', - 'still', - 'sting', - 'stock', - 'stomach', - 'stone', - 'stool', - 'story', - 'stove', - 'strategy', - 'street', - 'strike', - 'strong', - 'struggle', - 'student', - 'stuff', - 'stumble', - 'style', - 'subject', - 'submit', - 'subway', - 'success', - 'such', - 'sudden', - 'suffer', - 'sugar', - 'suggest', - 'suit', - 'summer', - 'sun', - 'sunny', - 'sunset', - 'super', - 'supply', - 'supreme', - 'sure', - 'surface', - 'surge', - 'surprise', - 'surround', - 'survey', - 'suspect', - 'sustain', - 'swallow', - 'swamp', - 'swap', - 'swarm', - 'swear', - 'sweet', - 'swift', - 'swim', - 'swing', - 'switch', - 'sword', - 'symbol', - 'symptom', - 'syrup', - 'system', - 'table', - 'tackle', - 'tag', - 'tail', - 'talent', - 'talk', - 'tank', - 'tape', - 'target', - 'task', - 'taste', - 'tattoo', - 'taxi', - 'teach', - 'team', - 'tell', - 'ten', - 'tenant', - 'tennis', - 'tent', - 'term', - 'test', - 'text', - 'thank', - 'that', - 'theme', - 'then', - 'theory', - 'there', - 'they', - 'thing', - 'this', - 'thought', - 'three', - 'thrive', - 'throw', - 'thumb', - 'thunder', - 'ticket', - 'tide', - 'tiger', - 'tilt', - 'timber', - 'time', - 'tiny', - 'tip', - 'tired', - 'tissue', - 'title', - 'toast', - 'tobacco', - 'today', - 'toddler', - 'toe', - 'together', - 'toilet', - 'token', - 'tomato', - 'tomorrow', - 'tone', - 'tongue', - 'tonight', - 'tool', - 'tooth', - 'top', - 'topic', - 'topple', - 'torch', - 'tornado', - 'tortoise', - 'toss', - 'total', - 'tourist', - 'toward', - 'tower', - 'town', - 'toy', - 'track', - 'trade', - 'traffic', - 'tragic', - 'train', - 'transfer', - 'trap', - 'trash', - 'travel', - 'tray', - 'treat', - 'tree', - 'trend', - 'trial', - 'tribe', - 'trick', - 'trigger', - 'trim', - 'trip', - 'trophy', - 'trouble', - 'truck', - 'true', - 'truly', - 'trumpet', - 'trust', - 'truth', - 'try', - 'tube', - 'tuition', - 'tumble', - 'tuna', - 'tunnel', - 'turkey', - 'turn', - 'turtle', - 'twelve', - 'twenty', - 'twice', - 'twin', - 'twist', - 'two', - 'type', - 'typical', - 'ugly', - 'umbrella', - 'unable', - 'unaware', - 'uncle', - 'uncover', - 'under', - 'undo', - 'unfair', - 'unfold', - 'unhappy', - 'uniform', - 'unique', - 'unit', - 'universe', - 'unknown', - 'unlock', - 'until', - 'unusual', - 'unveil', - 'update', - 'upgrade', - 'uphold', - 'upon', - 'upper', - 'upset', - 'urban', - 'urge', - 'usage', - 'use', - 'used', - 'useful', - 'useless', - 'usual', - 'utility', - 'vacant', - 'vacuum', - 'vague', - 'valid', - 'valley', - 'valve', - 'van', - 'vanish', - 'vapor', - 'various', - 'vast', - 'vault', - 'vehicle', - 'velvet', - 'vendor', - 'venture', - 'venue', - 'verb', - 'verify', - 'version', - 'very', - 'vessel', - 'veteran', - 'viable', - 'vibrant', - 'vicious', - 'victory', - 'video', - 'view', - 'village', - 'vintage', - 'violin', - 'virtual', - 'virus', - 'visa', - 'visit', - 'visual', - 'vital', - 'vivid', - 'vocal', - 'voice', - 'void', - 'volcano', - 'volume', - 'vote', - 'voyage', - 'wage', - 'wagon', - 'wait', - 'walk', - 'wall', - 'walnut', - 'want', - 'warfare', - 'warm', - 'warrior', - 'wash', - 'wasp', - 'waste', - 'water', - 'wave', - 'way', - 'wealth', - 'weapon', - 'wear', - 'weasel', - 'weather', - 'web', - 'wedding', - 'weekend', - 'weird', - 'welcome', - 'west', - 'wet', - 'whale', - 'what', - 'wheat', - 'wheel', - 'when', - 'where', - 'whip', - 'whisper', - 'wide', - 'width', - 'wife', - 'wild', - 'will', - 'win', - 'window', - 'wine', - 'wing', - 'wink', - 'winner', - 'winter', - 'wire', - 'wisdom', - 'wise', - 'wish', - 'witness', - 'wolf', - 'woman', - 'wonder', - 'wood', - 'wool', - 'word', - 'work', - 'world', - 'worry', - 'worth', - 'wrap', - 'wreck', - 'wrestle', - 'wrist', - 'write', - 'wrong', - 'yard', - 'year', - 'yellow', - 'you', - 'young', - 'youth', - 'zebra', - 'zero', - 'zone', - 'zoo' -]; +export default ['abandon', 'ability', 'able', 'about', 'above', 'absent', 'absorb', 'abstract', 'absurd', 'abuse', 'access', 'accident', 'account', 'accuse', 'achieve', 'acid', 'acoustic', 'acquire', 'across', 'act', 'action', 'actor', 'actress', 'actual', 'adapt', 'add', 'addict', 'address', 'adjust', 'admit', 'adult', 'advance', 'advice', 'aerobic', 'affair', 'afford', 'afraid', 'again', 'age', 'agent', 'agree', 'ahead', 'aim', 'air', 'airport', 'aisle', 'alarm', 'album', 'alcohol', 'alert', 'alien', 'all', 'alley', 'allow', 'almost', 'alone', 'alpha', 'already', 'also', 'alter', 'always', 'amateur', 'amazing', 'among', 'amount', 'amused', 'analyst', 'anchor', 'ancient', 'anger', 'angle', 'angry', 'animal', 'ankle', 'announce', 'annual', 'another', 'answer', 'antenna', 'antique', 'anxiety', 'any', 'apart', 'apology', 'appear', 'apple', 'approve', 'april', 'arch', 'arctic', 'area', 'arena', 'argue', 'arm', 'armed', 'armor', 'army', 'around', 'arrange', 'arrest', 'arrive', 'arrow', 'art', 'artefact', 'artist', 'artwork', 'ask', 'aspect', 'assault', 'asset', 'assist', 'assume', 'asthma', 'athlete', 'atom', 'attack', 'attend', 'attitude', 'attract', 'auction', 'audit', 'august', 'aunt', 'author', 'auto', 'autumn', 'average', 'avocado', 'avoid', 'awake', 'aware', 'away', 'awesome', 'awful', 'awkward', 'axis', 'baby', 'bachelor', 'bacon', 'badge', 'bag', 'balance', 'balcony', 'ball', 'bamboo', 'banana', 'banner', 'bar', 'barely', 'bargain', 'barrel', 'base', 'basic', 'basket', 'battle', 'beach', 'bean', 'beauty', 'because', 'become', 'beef', 'before', 'begin', 'behave', 'behind', 'believe', 'below', 'belt', 'bench', 'benefit', 'best', 'betray', 'better', 'between', 'beyond', 'bicycle', 'bid', 'bike', 'bind', 'biology', 'bird', 'birth', 'bitter', 'black', 'blade', 'blame', 'blanket', 'blast', 'bleak', 'bless', 'blind', 'blood', 'blossom', 'blouse', 'blue', 'blur', 'blush', 'board', 'boat', 'body', 'boil', 'bomb', 'bone', 'bonus', 'book', 'boost', 'border', 'boring', 'borrow', 'boss', 'bottom', 'bounce', 'box', 'boy', 'bracket', 'brain', 'brand', 'brass', 'brave', 'bread', 'breeze', 'brick', 'bridge', 'brief', 'bright', 'bring', 'brisk', 'broccoli', 'broken', 'bronze', 'broom', 'brother', 'brown', 'brush', 'bubble', 'buddy', 'budget', 'buffalo', 'build', 'bulb', 'bulk', 'bullet', 'bundle', 'bunker', 'burden', 'burger', 'burst', 'bus', 'business', 'busy', 'butter', 'buyer', 'buzz', 'cabbage', 'cabin', 'cable', 'cactus', 'cage', 'cake', 'call', 'calm', 'camera', 'camp', 'can', 'canal', 'cancel', 'candy', 'cannon', 'canoe', 'canvas', 'canyon', 'capable', 'capital', 'captain', 'car', 'carbon', 'card', 'cargo', 'carpet', 'carry', 'cart', 'case', 'cash', 'casino', 'castle', 'casual', 'cat', 'catalog', 'catch', 'category', 'cattle', 'caught', 'cause', 'caution', 'cave', 'ceiling', 'celery', 'cement', 'census', 'century', 'cereal', 'certain', 'chair', 'chalk', 'champion', 'change', 'chaos', 'chapter', 'charge', 'chase', 'chat', 'cheap', 'check', 'cheese', 'chef', 'cherry', 'chest', 'chicken', 'chief', 'child', 'chimney', 'choice', 'choose', 'chronic', 'chuckle', 'chunk', 'churn', 'cigar', 'cinnamon', 'circle', 'citizen', 'city', 'civil', 'claim', 'clap', 'clarify', 'claw', 'clay', 'clean', 'clerk', 'clever', 'click', 'client', 'cliff', 'climb', 'clinic', 'clip', 'clock', 'clog', 'close', 'cloth', 'cloud', 'clown', 'club', 'clump', 'cluster', 'clutch', 'coach', 'coast', 'coconut', 'code', 'coffee', 'coil', 'coin', 'collect', 'color', 'column', 'combine', 'come', 'comfort', 'comic', 'common', 'company', 'concert', 'conduct', 'confirm', 'congress', 'connect', 'consider', 'control', 'convince', 'cook', 'cool', 'copper', 'copy', 'coral', 'core', 'corn', 'correct', 'cost', 'cotton', 'couch', 'country', 'couple', 'course', 'cousin', 'cover', 'coyote', 'crack', 'cradle', 'craft', 'cram', 'crane', 'crash', 'crater', 'crawl', 'crazy', 'cream', 'credit', 'creek', 'crew', 'cricket', 'crime', 'crisp', 'critic', 'crop', 'cross', 'crouch', 'crowd', 'crucial', 'cruel', 'cruise', 'crumble', 'crunch', 'crush', 'cry', 'crystal', 'cube', 'culture', 'cup', 'cupboard', 'curious', 'current', 'curtain', 'curve', 'cushion', 'custom', 'cute', 'cycle', 'dad', 'damage', 'damp', 'dance', 'danger', 'daring', 'dash', 'daughter', 'dawn', 'day', 'deal', 'debate', 'debris', 'decade', 'december', 'decide', 'decline', 'decorate', 'decrease', 'deer', 'defense', 'define', 'defy', 'degree', 'delay', 'deliver', 'demand', 'demise', 'denial', 'dentist', 'deny', 'depart', 'depend', 'deposit', 'depth', 'deputy', 'derive', 'describe', 'desert', 'design', 'desk', 'despair', 'destroy', 'detail', 'detect', 'develop', 'device', 'devote', 'diagram', 'dial', 'diamond', 'diary', 'dice', 'diesel', 'diet', 'differ', 'digital', 'dignity', 'dilemma', 'dinner', 'dinosaur', 'direct', 'dirt', 'disagree', 'discover', 'disease', 'dish', 'dismiss', 'disorder', 'display', 'distance', 'divert', 'divide', 'divorce', 'dizzy', 'doctor', 'document', 'dog', 'doll', 'dolphin', 'domain', 'donate', 'donkey', 'donor', 'door', 'dose', 'double', 'dove', 'draft', 'dragon', 'drama', 'drastic', 'draw', 'dream', 'dress', 'drift', 'drill', 'drink', 'drip', 'drive', 'drop', 'drum', 'dry', 'duck', 'dumb', 'dune', 'during', 'dust', 'dutch', 'duty', 'dwarf', 'dynamic', 'eager', 'eagle', 'early', 'earn', 'earth', 'easily', 'east', 'easy', 'echo', 'ecology', 'economy', 'edge', 'edit', 'educate', 'effort', 'egg', 'eight', 'either', 'elbow', 'elder', 'electric', 'elegant', 'element', 'elephant', 'elevator', 'elite', 'else', 'embark', 'embody', 'embrace', 'emerge', 'emotion', 'employ', 'empower', 'empty', 'enable', 'enact', 'end', 'endless', 'endorse', 'enemy', 'energy', 'enforce', 'engage', 'engine', 'enhance', 'enjoy', 'enlist', 'enough', 'enrich', 'enroll', 'ensure', 'enter', 'entire', 'entry', 'envelope', 'episode', 'equal', 'equip', 'era', 'erase', 'erode', 'erosion', 'error', 'erupt', 'escape', 'essay', 'essence', 'estate', 'eternal', 'ethics', 'evidence', 'evil', 'evoke', 'evolve', 'exact', 'example', 'excess', 'exchange', 'excite', 'exclude', 'excuse', 'execute', 'exercise', 'exhaust', 'exhibit', 'exile', 'exist', 'exit', 'exotic', 'expand', 'expect', 'expire', 'explain', 'expose', 'express', 'extend', 'extra', 'eye', 'eyebrow', 'fabric', 'face', 'faculty', 'fade', 'faint', 'faith', 'fall', 'false', 'fame', 'family', 'famous', 'fan', 'fancy', 'fantasy', 'farm', 'fashion', 'fat', 'fatal', 'father', 'fatigue', 'fault', 'favorite', 'feature', 'february', 'federal', 'fee', 'feed', 'feel', 'female', 'fence', 'festival', 'fetch', 'fever', 'few', 'fiber', 'fiction', 'field', 'figure', 'file', 'film', 'filter', 'final', 'find', 'fine', 'finger', 'finish', 'fire', 'firm', 'first', 'fiscal', 'fish', 'fit', 'fitness', 'fix', 'flag', 'flame', 'flash', 'flat', 'flavor', 'flee', 'flight', 'flip', 'float', 'flock', 'floor', 'flower', 'fluid', 'flush', 'fly', 'foam', 'focus', 'fog', 'foil', 'fold', 'follow', 'food', 'foot', 'force', 'forest', 'forget', 'fork', 'fortune', 'forum', 'forward', 'fossil', 'foster', 'found', 'fox', 'fragile', 'frame', 'frequent', 'fresh', 'friend', 'fringe', 'frog', 'front', 'frost', 'frown', 'frozen', 'fruit', 'fuel', 'fun', 'funny', 'furnace', 'fury', 'future', 'gadget', 'gain', 'galaxy', 'gallery', 'game', 'gap', 'garage', 'garbage', 'garden', 'garlic', 'garment', 'gas', 'gasp', 'gate', 'gather', 'gauge', 'gaze', 'general', 'genius', 'genre', 'gentle', 'genuine', 'gesture', 'ghost', 'giant', 'gift', 'giggle', 'ginger', 'giraffe', 'girl', 'give', 'glad', 'glance', 'glare', 'glass', 'glide', 'glimpse', 'globe', 'gloom', 'glory', 'glove', 'glow', 'glue', 'goat', 'goddess', 'gold', 'good', 'goose', 'gorilla', 'gospel', 'gossip', 'govern', 'gown', 'grab', 'grace', 'grain', 'grant', 'grape', 'grass', 'gravity', 'great', 'green', 'grid', 'grief', 'grit', 'grocery', 'group', 'grow', 'grunt', 'guard', 'guess', 'guide', 'guilt', 'guitar', 'gun', 'gym', 'habit', 'hair', 'half', 'hammer', 'hamster', 'hand', 'happy', 'harbor', 'hard', 'harsh', 'harvest', 'hat', 'have', 'hawk', 'hazard', 'head', 'health', 'heart', 'heavy', 'hedgehog', 'height', 'hello', 'helmet', 'help', 'hen', 'hero', 'hidden', 'high', 'hill', 'hint', 'hip', 'hire', 'history', 'hobby', 'hockey', 'hold', 'hole', 'holiday', 'hollow', 'home', 'honey', 'hood', 'hope', 'horn', 'horror', 'horse', 'hospital', 'host', 'hotel', 'hour', 'hover', 'hub', 'huge', 'human', 'humble', 'humor', 'hundred', 'hungry', 'hunt', 'hurdle', 'hurry', 'hurt', 'husband', 'hybrid', 'ice', 'icon', 'idea', 'identify', 'idle', 'ignore', 'ill', 'illegal', 'illness', 'image', 'imitate', 'immense', 'immune', 'impact', 'impose', 'improve', 'impulse', 'inch', 'include', 'income', 'increase', 'index', 'indicate', 'indoor', 'industry', 'infant', 'inflict', 'inform', 'inhale', 'inherit', 'initial', 'inject', 'injury', 'inmate', 'inner', 'innocent', 'input', 'inquiry', 'insane', 'insect', 'inside', 'inspire', 'install', 'intact', 'interest', 'into', 'invest', 'invite', 'involve', 'iron', 'island', 'isolate', 'issue', 'item', 'ivory', 'jacket', 'jaguar', 'jar', 'jazz', 'jealous', 'jeans', 'jelly', 'jewel', 'job', 'join', 'joke', 'journey', 'joy', 'judge', 'juice', 'jump', 'jungle', 'junior', 'junk', 'just', 'kangaroo', 'keen', 'keep', 'ketchup', 'key', 'kick', 'kid', 'kidney', 'kind', 'kingdom', 'kiss', 'kit', 'kitchen', 'kite', 'kitten', 'kiwi', 'knee', 'knife', 'knock', 'know', 'lab', 'label', 'labor', 'ladder', 'lady', 'lake', 'lamp', 'language', 'laptop', 'large', 'later', 'latin', 'laugh', 'laundry', 'lava', 'law', 'lawn', 'lawsuit', 'layer', 'lazy', 'leader', 'leaf', 'learn', 'leave', 'lecture', 'left', 'leg', 'legal', 'legend', 'leisure', 'lemon', 'lend', 'length', 'lens', 'leopard', 'lesson', 'letter', 'level', 'liar', 'liberty', 'library', 'license', 'life', 'lift', 'light', 'like', 'limb', 'limit', 'link', 'lion', 'liquid', 'list', 'little', 'live', 'lizard', 'load', 'loan', 'lobster', 'local', 'lock', 'logic', 'lonely', 'long', 'loop', 'lottery', 'loud', 'lounge', 'love', 'loyal', 'lucky', 'luggage', 'lumber', 'lunar', 'lunch', 'luxury', 'lyrics', 'machine', 'mad', 'magic', 'magnet', 'maid', 'mail', 'main', 'major', 'make', 'mammal', 'man', 'manage', 'mandate', 'mango', 'mansion', 'manual', 'maple', 'marble', 'march', 'margin', 'marine', 'market', 'marriage', 'mask', 'mass', 'master', 'match', 'material', 'math', 'matrix', 'matter', 'maximum', 'maze', 'meadow', 'mean', 'measure', 'meat', 'mechanic', 'medal', 'media', 'melody', 'melt', 'member', 'memory', 'mention', 'menu', 'mercy', 'merge', 'merit', 'merry', 'mesh', 'message', 'metal', 'method', 'middle', 'midnight', 'milk', 'million', 'mimic', 'mind', 'minimum', 'minor', 'minute', 'miracle', 'mirror', 'misery', 'miss', 'mistake', 'mix', 'mixed', 'mixture', 'mobile', 'model', 'modify', 'mom', 'moment', 'monitor', 'monkey', 'monster', 'month', 'moon', 'moral', 'more', 'morning', 'mosquito', 'mother', 'motion', 'motor', 'mountain', 'mouse', 'move', 'movie', 'much', 'muffin', 'mule', 'multiply', 'muscle', 'museum', 'mushroom', 'music', 'must', 'mutual', 'myself', 'mystery', 'myth', 'naive', 'name', 'napkin', 'narrow', 'nasty', 'nation', 'nature', 'near', 'neck', 'need', 'negative', 'neglect', 'neither', 'nephew', 'nerve', 'nest', 'net', 'network', 'neutral', 'never', 'news', 'next', 'nice', 'night', 'noble', 'noise', 'nominee', 'noodle', 'normal', 'north', 'nose', 'notable', 'note', 'nothing', 'notice', 'novel', 'now', 'nuclear', 'number', 'nurse', 'nut', 'oak', 'obey', 'object', 'oblige', 'obscure', 'observe', 'obtain', 'obvious', 'occur', 'ocean', 'october', 'odor', 'off', 'offer', 'office', 'often', 'oil', 'okay', 'old', 'olive', 'olympic', 'omit', 'once', 'one', 'onion', 'online', 'only', 'open', 'opera', 'opinion', 'oppose', 'option', 'orange', 'orbit', 'orchard', 'order', 'ordinary', 'organ', 'orient', 'original', 'orphan', 'ostrich', 'other', 'outdoor', 'outer', 'output', 'outside', 'oval', 'oven', 'over', 'own', 'owner', 'oxygen', 'oyster', 'ozone', 'pact', 'paddle', 'page', 'pair', 'palace', 'palm', 'panda', 'panel', 'panic', 'panther', 'paper', 'parade', 'parent', 'park', 'parrot', 'party', 'pass', 'patch', 'path', 'patient', 'patrol', 'pattern', 'pause', 'pave', 'payment', 'peace', 'peanut', 'pear', 'peasant', 'pelican', 'pen', 'penalty', 'pencil', 'people', 'pepper', 'perfect', 'permit', 'person', 'pet', 'phone', 'photo', 'phrase', 'physical', 'piano', 'picnic', 'picture', 'piece', 'pig', 'pigeon', 'pill', 'pilot', 'pink', 'pioneer', 'pipe', 'pistol', 'pitch', 'pizza', 'place', 'planet', 'plastic', 'plate', 'play', 'please', 'pledge', 'pluck', 'plug', 'plunge', 'poem', 'poet', 'point', 'polar', 'pole', 'police', 'pond', 'pony', 'pool', 'popular', 'portion', 'position', 'possible', 'post', 'potato', 'pottery', 'poverty', 'powder', 'power', 'practice', 'praise', 'predict', 'prefer', 'prepare', 'present', 'pretty', 'prevent', 'price', 'pride', 'primary', 'print', 'priority', 'prison', 'private', 'prize', 'problem', 'process', 'produce', 'profit', 'program', 'project', 'promote', 'proof', 'property', 'prosper', 'protect', 'proud', 'provide', 'public', 'pudding', 'pull', 'pulp', 'pulse', 'pumpkin', 'punch', 'pupil', 'puppy', 'purchase', 'purity', 'purpose', 'purse', 'push', 'put', 'puzzle', 'pyramid', 'quality', 'quantum', 'quarter', 'question', 'quick', 'quit', 'quiz', 'quote', 'rabbit', 'raccoon', 'race', 'rack', 'radar', 'radio', 'rail', 'rain', 'raise', 'rally', 'ramp', 'ranch', 'random', 'range', 'rapid', 'rare', 'rate', 'rather', 'raven', 'raw', 'razor', 'ready', 'real', 'reason', 'rebel', 'rebuild', 'recall', 'receive', 'recipe', 'record', 'recycle', 'reduce', 'reflect', 'reform', 'refuse', 'region', 'regret', 'regular', 'reject', 'relax', 'release', 'relief', 'rely', 'remain', 'remember', 'remind', 'remove', 'render', 'renew', 'rent', 'reopen', 'repair', 'repeat', 'replace', 'report', 'require', 'rescue', 'resemble', 'resist', 'resource', 'response', 'result', 'retire', 'retreat', 'return', 'reunion', 'reveal', 'review', 'reward', 'rhythm', 'rib', 'ribbon', 'rice', 'rich', 'ride', 'ridge', 'rifle', 'right', 'rigid', 'ring', 'riot', 'ripple', 'risk', 'ritual', 'rival', 'river', 'road', 'roast', 'robot', 'robust', 'rocket', 'romance', 'roof', 'rookie', 'room', 'rose', 'rotate', 'rough', 'round', 'route', 'royal', 'rubber', 'rude', 'rug', 'rule', 'run', 'runway', 'rural', 'sad', 'saddle', 'sadness', 'safe', 'sail', 'salad', 'salmon', 'salon', 'salt', 'salute', 'same', 'sample', 'sand', 'satisfy', 'satoshi', 'sauce', 'sausage', 'save', 'say', 'scale', 'scan', 'scare', 'scatter', 'scene', 'scheme', 'school', 'science', 'scissors', 'scorpion', 'scout', 'scrap', 'screen', 'script', 'scrub', 'sea', 'search', 'season', 'seat', 'second', 'secret', 'section', 'security', 'seed', 'seek', 'segment', 'select', 'sell', 'seminar', 'senior', 'sense', 'sentence', 'series', 'service', 'session', 'settle', 'setup', 'seven', 'shadow', 'shaft', 'shallow', 'share', 'shed', 'shell', 'sheriff', 'shield', 'shift', 'shine', 'ship', 'shiver', 'shock', 'shoe', 'shoot', 'shop', 'short', 'shoulder', 'shove', 'shrimp', 'shrug', 'shuffle', 'shy', 'sibling', 'sick', 'side', 'siege', 'sight', 'sign', 'silent', 'silk', 'silly', 'silver', 'similar', 'simple', 'since', 'sing', 'siren', 'sister', 'situate', 'six', 'size', 'skate', 'sketch', 'ski', 'skill', 'skin', 'skirt', 'skull', 'slab', 'slam', 'sleep', 'slender', 'slice', 'slide', 'slight', 'slim', 'slogan', 'slot', 'slow', 'slush', 'small', 'smart', 'smile', 'smoke', 'smooth', 'snack', 'snake', 'snap', 'sniff', 'snow', 'soap', 'soccer', 'social', 'sock', 'soda', 'soft', 'solar', 'soldier', 'solid', 'solution', 'solve', 'someone', 'song', 'soon', 'sorry', 'sort', 'soul', 'sound', 'soup', 'source', 'south', 'space', 'spare', 'spatial', 'spawn', 'speak', 'special', 'speed', 'spell', 'spend', 'sphere', 'spice', 'spider', 'spike', 'spin', 'spirit', 'split', 'spoil', 'sponsor', 'spoon', 'sport', 'spot', 'spray', 'spread', 'spring', 'spy', 'square', 'squeeze', 'squirrel', 'stable', 'stadium', 'staff', 'stage', 'stairs', 'stamp', 'stand', 'start', 'state', 'stay', 'steak', 'steel', 'stem', 'step', 'stereo', 'stick', 'still', 'sting', 'stock', 'stomach', 'stone', 'stool', 'story', 'stove', 'strategy', 'street', 'strike', 'strong', 'struggle', 'student', 'stuff', 'stumble', 'style', 'subject', 'submit', 'subway', 'success', 'such', 'sudden', 'suffer', 'sugar', 'suggest', 'suit', 'summer', 'sun', 'sunny', 'sunset', 'super', 'supply', 'supreme', 'sure', 'surface', 'surge', 'surprise', 'surround', 'survey', 'suspect', 'sustain', 'swallow', 'swamp', 'swap', 'swarm', 'swear', 'sweet', 'swift', 'swim', 'swing', 'switch', 'sword', 'symbol', 'symptom', 'syrup', 'system', 'table', 'tackle', 'tag', 'tail', 'talent', 'talk', 'tank', 'tape', 'target', 'task', 'taste', 'tattoo', 'taxi', 'teach', 'team', 'tell', 'ten', 'tenant', 'tennis', 'tent', 'term', 'test', 'text', 'thank', 'that', 'theme', 'then', 'theory', 'there', 'they', 'thing', 'this', 'thought', 'three', 'thrive', 'throw', 'thumb', 'thunder', 'ticket', 'tide', 'tiger', 'tilt', 'timber', 'time', 'tiny', 'tip', 'tired', 'tissue', 'title', 'toast', 'tobacco', 'today', 'toddler', 'toe', 'together', 'toilet', 'token', 'tomato', 'tomorrow', 'tone', 'tongue', 'tonight', 'tool', 'tooth', 'top', 'topic', 'topple', 'torch', 'tornado', 'tortoise', 'toss', 'total', 'tourist', 'toward', 'tower', 'town', 'toy', 'track', 'trade', 'traffic', 'tragic', 'train', 'transfer', 'trap', 'trash', 'travel', 'tray', 'treat', 'tree', 'trend', 'trial', 'tribe', 'trick', 'trigger', 'trim', 'trip', 'trophy', 'trouble', 'truck', 'true', 'truly', 'trumpet', 'trust', 'truth', 'try', 'tube', 'tuition', 'tumble', 'tuna', 'tunnel', 'turkey', 'turn', 'turtle', 'twelve', 'twenty', 'twice', 'twin', 'twist', 'two', 'type', 'typical', 'ugly', 'umbrella', 'unable', 'unaware', 'uncle', 'uncover', 'under', 'undo', 'unfair', 'unfold', 'unhappy', 'uniform', 'unique', 'unit', 'universe', 'unknown', 'unlock', 'until', 'unusual', 'unveil', 'update', 'upgrade', 'uphold', 'upon', 'upper', 'upset', 'urban', 'urge', 'usage', 'use', 'used', 'useful', 'useless', 'usual', 'utility', 'vacant', 'vacuum', 'vague', 'valid', 'valley', 'valve', 'van', 'vanish', 'vapor', 'various', 'vast', 'vault', 'vehicle', 'velvet', 'vendor', 'venture', 'venue', 'verb', 'verify', 'version', 'very', 'vessel', 'veteran', 'viable', 'vibrant', 'vicious', 'victory', 'video', 'view', 'village', 'vintage', 'violin', 'virtual', 'virus', 'visa', 'visit', 'visual', 'vital', 'vivid', 'vocal', 'voice', 'void', 'volcano', 'volume', 'vote', 'voyage', 'wage', 'wagon', 'wait', 'walk', 'wall', 'walnut', 'want', 'warfare', 'warm', 'warrior', 'wash', 'wasp', 'waste', 'water', 'wave', 'way', 'wealth', 'weapon', 'wear', 'weasel', 'weather', 'web', 'wedding', 'weekend', 'weird', 'welcome', 'west', 'wet', 'whale', 'what', 'wheat', 'wheel', 'when', 'where', 'whip', 'whisper', 'wide', 'width', 'wife', 'wild', 'will', 'win', 'window', 'wine', 'wing', 'wink', 'winner', 'winter', 'wire', 'wisdom', 'wise', 'wish', 'witness', 'wolf', 'woman', 'wonder', 'wood', 'wool', 'word', 'work', 'world', 'worry', 'worth', 'wrap', 'wreck', 'wrestle', 'wrist', 'write', 'wrong', 'yard', 'year', 'yellow', 'you', 'young', 'youth', 'zebra', 'zero', 'zone', 'zoo']; diff --git a/packages/util-crypto/src/mnemonic/bip39.ts b/packages/util-crypto/src/mnemonic/bip39.ts index 5e2fc30da..f6ae040f1 100644 --- a/packages/util-crypto/src/mnemonic/bip39.ts +++ b/packages/util-crypto/src/mnemonic/bip39.ts @@ -15,6 +15,7 @@ import createHash from 'create-hash'; import { pbkdf2Sync } from 'pbkdf2'; +import { assert, u8aToU8a } from '@polkadot/util'; import randomAsU8a from '../random/asU8a'; import DEFAULT_WORDLIST from './bip39-en'; @@ -56,26 +57,20 @@ export function mnemonicToSeedSync (mnemonic: string, password?: string): Buffer return pbkdf2Sync(mnemonicBuffer, saltBuffer, 2048, 64, 'sha512'); } -export function mnemonicToEntropy (mnemonic: string): string { +export function mnemonicToEntropy (mnemonic: string): Uint8Array { const words = normalize(mnemonic).split(' '); - if (words.length % 3 !== 0) { - throw new Error(INVALID_MNEMONIC); - } + assert(words.length % 3 === 0, INVALID_MNEMONIC); // convert word indices to 11 bit binary strings const bits = words - .map( - (word: string): string => { - const index = DEFAULT_WORDLIST.indexOf(word); + .map((word): string => { + const index = DEFAULT_WORDLIST.indexOf(word); - if (index === -1) { - throw new Error(INVALID_MNEMONIC); - } + assert(index !== -1, INVALID_MNEMONIC); - return index.toString(2).padStart(11, '0'); - } - ) + return index.toString(2).padStart(11, '0'); + }) .join(''); // split the binary string into ENT/CS @@ -86,62 +81,34 @@ export function mnemonicToEntropy (mnemonic: string): string { // calculate the checksum and compare const entropyBytes = entropyBits.match(/(.{1,8})/g)?.map(binaryToByte); - if (!entropyBytes || entropyBytes.length < 16) { - throw new Error(INVALID_ENTROPY); - } else if (entropyBytes.length > 32) { - throw new Error(INVALID_ENTROPY); - } else if (entropyBytes.length % 4 !== 0) { - throw new Error(INVALID_ENTROPY); - } + assert(entropyBytes && entropyBytes.length % 4 === 0 && entropyBytes.length >= 16 && entropyBytes.length <= 32, INVALID_ENTROPY); - const entropy = Buffer.from(entropyBytes); + const entropy = u8aToU8a(entropyBytes); const newChecksum = deriveChecksumBits(entropy); - if (newChecksum !== checksumBits) { - throw new Error(INVALID_CHECKSUM); - } + assert(newChecksum === checksumBits, INVALID_CHECKSUM); - return entropy.toString('hex'); + return entropy; } export function entropyToMnemonic (entropy: Uint8Array): string { // 128 <= ENT <= 256 - if (entropy.length < 16) { - throw new TypeError(INVALID_ENTROPY); - } - - if (entropy.length > 32) { - throw new TypeError(INVALID_ENTROPY); - } else if (entropy.length % 4 !== 0) { - throw new TypeError(INVALID_ENTROPY); - } + assert(entropy.length % 4 === 0 && entropy.length >= 16 && entropy.length <= 32, INVALID_ENTROPY); const entropyBits = bytesToBinary(Array.from(entropy)); const checksumBits = deriveChecksumBits(entropy); - const bits = entropyBits + checksumBits; - // we just set it prior, so this is a safe check // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - const chunks = bits.match(/(.{1,11})/g)!; - - const words = chunks.map( - (binary: string): string => { - const index = binaryToByte(binary); - - return DEFAULT_WORDLIST[index]; - } - ); - - return words.join(' '); + return (entropyBits + checksumBits).match(/(.{1,11})/g)! + .map((binary) => DEFAULT_WORDLIST[binaryToByte(binary)]) + .join(' '); } export function generateMnemonic (strength?: number): string { strength = strength || 128; - if (strength % 32 !== 0) { - throw new TypeError(INVALID_ENTROPY); - } + assert(strength % 32 === 0, INVALID_ENTROPY); return entropyToMnemonic(randomAsU8a(strength / 8)); } diff --git a/packages/util-crypto/src/mnemonic/generate.spec.ts b/packages/util-crypto/src/mnemonic/generate.spec.ts index 87c42884a..5b4395062 100644 --- a/packages/util-crypto/src/mnemonic/generate.spec.ts +++ b/packages/util-crypto/src/mnemonic/generate.spec.ts @@ -11,24 +11,20 @@ describe('mnemonicGenerate', (): void => { }); it('generates a valid mnemonic (default strength)', (): void => { - const mnemonic = generate(); - - console.error(mnemonic); - expect( - validate(mnemonic) + validate(generate()) ).toEqual(true); }); ([12, 15, 18, 21, 24] as WordCount[]).forEach((num: WordCount): void => { it(`generates a valid mnemonic (${num} words)`, (): void => { - const mnemonic = generate(num); - const isValid = validate(mnemonic); + [false, true].forEach((onlyJs): void => { + const mnemonic = generate(num, onlyJs); + const isValid = validate(mnemonic); - console.error(mnemonic); - - expect(mnemonic.split(' ')).toHaveLength(num); - expect(isValid).toEqual(true); + expect(mnemonic.split(' ')).toHaveLength(num); + expect(isValid).toEqual(true); + }); }); }); }); diff --git a/packages/util-crypto/src/mnemonic/generate.ts b/packages/util-crypto/src/mnemonic/generate.ts index 23af41839..c70c6965d 100644 --- a/packages/util-crypto/src/mnemonic/generate.ts +++ b/packages/util-crypto/src/mnemonic/generate.ts @@ -30,8 +30,8 @@ const STRENGTH_MAP = { * const mnemonic = mnemonicGenerate(); // => string * ``` */ -export default function mnemonicGenerate (numWords: WordCount = 12): string { - return isReady() +export default function mnemonicGenerate (numWords: WordCount = 12, onlyJs = false): string { + return isReady() && !onlyJs ? bip39Generate(numWords) : generateMnemonic(STRENGTH_MAP[numWords]); } diff --git a/packages/util-crypto/src/mnemonic/toEntropy.spec.ts b/packages/util-crypto/src/mnemonic/toEntropy.spec.ts index 43295264f..9dbf29380 100644 --- a/packages/util-crypto/src/mnemonic/toEntropy.spec.ts +++ b/packages/util-crypto/src/mnemonic/toEntropy.spec.ts @@ -15,6 +15,7 @@ describe('mnemonicToEntropy', (): void => { tests.forEach(([mnemonic, entropy], index): void => { it(`Created correct entropy for ${index}`, (): void => { expect(u8aToHex(toEntropy(mnemonic))).toEqual(entropy); + expect(u8aToHex(toEntropy(mnemonic, true))).toEqual(entropy); }); }); }); diff --git a/packages/util-crypto/src/mnemonic/toEntropy.ts b/packages/util-crypto/src/mnemonic/toEntropy.ts index 5e86f0225..2746781a5 100644 --- a/packages/util-crypto/src/mnemonic/toEntropy.ts +++ b/packages/util-crypto/src/mnemonic/toEntropy.ts @@ -3,17 +3,12 @@ import '../polyfill'; -import { hexAddPrefix, hexToU8a } from '@polkadot/util'; import { bip39ToEntropy, isReady } from '@polkadot/wasm-crypto'; import { mnemonicToEntropy } from './bip39'; -export default function toEntropy (mnemonic: string): Uint8Array { - return isReady() +export default function toEntropy (mnemonic: string, onlyJs = false): Uint8Array { + return isReady() && !onlyJs ? bip39ToEntropy(mnemonic) - : hexToU8a( - hexAddPrefix( - mnemonicToEntropy(mnemonic) - ) - ); + : mnemonicToEntropy(mnemonic); } diff --git a/packages/util-crypto/src/mnemonic/toLegacySeed.spec.ts b/packages/util-crypto/src/mnemonic/toLegacySeed.spec.ts index 8a404da4d..6ffafd7c6 100644 --- a/packages/util-crypto/src/mnemonic/toLegacySeed.spec.ts +++ b/packages/util-crypto/src/mnemonic/toLegacySeed.spec.ts @@ -6,22 +6,20 @@ import { waitReady } from '@polkadot/wasm-crypto'; import { mnemonicToLegacySeed } from './'; +const MENMONIC = 'seed sock milk update focus rotate barely fade car face mechanic mercy'; +const SEED = '0x3c121e20de068083b49c2315697fb59a2d9e8643c24e5ea7628132c58969a027'; + describe('mnemonicToLegacySeed', (): void => { + beforeEach(async (): Promise => { + await waitReady(); + }); + it('generates a valid seed', (): void => { expect( - u8aToHex( - mnemonicToLegacySeed('seed sock milk update focus rotate barely fade car face mechanic mercy') - ) - ).toEqual('0x3c121e20de068083b49c2315697fb59a2d9e8643c24e5ea7628132c58969a027'); - }); - - it('generates the seed via WASM', async (): Promise => { - await waitReady(); - + u8aToHex(mnemonicToLegacySeed(MENMONIC)) + ).toEqual(SEED); expect( - u8aToHex( - mnemonicToLegacySeed('seed sock milk update focus rotate barely fade car face mechanic mercy') - ) - ).toEqual('0x3c121e20de068083b49c2315697fb59a2d9e8643c24e5ea7628132c58969a027'); + u8aToHex(mnemonicToLegacySeed(MENMONIC, undefined, true)) + ).toEqual(SEED); }); }); diff --git a/packages/util-crypto/src/mnemonic/toLegacySeed.ts b/packages/util-crypto/src/mnemonic/toLegacySeed.ts index fc3e7afb8..2672dd8d8 100644 --- a/packages/util-crypto/src/mnemonic/toLegacySeed.ts +++ b/packages/util-crypto/src/mnemonic/toLegacySeed.ts @@ -24,8 +24,8 @@ import { mnemonicToSeedSync } from './bip39'; * } * ``` */ -export default function toLegacy (mnemonic: string, password = ''): Uint8Array { - return isReady() +export default function toLegacy (mnemonic: string, password = '', onlyJs = false): Uint8Array { + return isReady() && !onlyJs ? bip39ToSeed(mnemonic, password) : bufferToU8a(mnemonicToSeedSync(mnemonic, password)).subarray(0, 32); } diff --git a/packages/util-crypto/src/mnemonic/toMiniSecret.spec.ts b/packages/util-crypto/src/mnemonic/toMiniSecret.spec.ts index 18f957336..7b4894d7d 100644 --- a/packages/util-crypto/src/mnemonic/toMiniSecret.spec.ts +++ b/packages/util-crypto/src/mnemonic/toMiniSecret.spec.ts @@ -7,6 +7,9 @@ import mnemonicToMiniSecret from './toMiniSecret'; import tests from '../schnorrkel/keypair/testing'; import { cryptoWaitReady } from '..'; +const MNEMONIC = 'seed sock milk update focus rotate barely fade car face mechanic mercy'; +const SEED = '0x4d1ab2a57929edfd018aaa974e62ed557e3f54b4104acabedf73c8f5a1dbb029'; + describe('mnemonicToMiniSecret', (): void => { beforeEach(async (): Promise => { await cryptoWaitReady(); @@ -14,8 +17,11 @@ describe('mnemonicToMiniSecret', (): void => { it('generates a valid seed', (): void => { expect( - u8aToHex(mnemonicToMiniSecret('seed sock milk update focus rotate barely fade car face mechanic mercy')) - ).toEqual('0x4d1ab2a57929edfd018aaa974e62ed557e3f54b4104acabedf73c8f5a1dbb029'); + u8aToHex(mnemonicToMiniSecret(MNEMONIC)) + ).toEqual(SEED); + expect( + u8aToHex(mnemonicToMiniSecret(MNEMONIC, undefined, true)) + ).toEqual(SEED); }); tests.forEach(([mnemonic, , seed], index): void => { @@ -26,6 +32,12 @@ describe('mnemonicToMiniSecret', (): void => { // mini returned here, only check first 32-bytes (64 hex + 2 prefix) seed.substr(0, 66) ); + expect( + u8aToHex(mnemonicToMiniSecret(mnemonic, 'Substrate', true)) + ).toEqual( + // mini returned here, only check first 32-bytes (64 hex + 2 prefix) + seed.substr(0, 66) + ); }); }); }); diff --git a/packages/util-crypto/src/mnemonic/toMiniSecret.ts b/packages/util-crypto/src/mnemonic/toMiniSecret.ts index c7d14949a..e9b7d616d 100644 --- a/packages/util-crypto/src/mnemonic/toMiniSecret.ts +++ b/packages/util-crypto/src/mnemonic/toMiniSecret.ts @@ -9,8 +9,8 @@ import { bip39ToMiniSecret, isReady } from '@polkadot/wasm-crypto'; import toEntropy from './toEntropy'; -export default function toMiniSecret (mnemonic: string, password = ''): Uint8Array { - if (isReady()) { +export default function toMiniSecret (mnemonic: string, password = '', onlyJs = false): Uint8Array { + if (isReady() && !onlyJs) { return bip39ToMiniSecret(mnemonic, password); } diff --git a/packages/util-crypto/src/mnemonic/validate.spec.ts b/packages/util-crypto/src/mnemonic/validate.spec.ts index 876f1aaba..3b7046f52 100644 --- a/packages/util-crypto/src/mnemonic/validate.spec.ts +++ b/packages/util-crypto/src/mnemonic/validate.spec.ts @@ -13,11 +13,17 @@ describe('mnemonicValidate', (): void => { expect( validate('seed sock milk update focus rotate barely fade car face mechanic mercy') ).toEqual(true); + expect( + validate('seed sock milk update focus rotate barely fade car face mechanic mercy', true) + ).toEqual(true); }); it('returns false on invalid', (): void => { expect( validate('wine photo extra cushion basket dwarf humor cloud truck job boat submit') ).toEqual(false); + expect( + validate('wine photo extra cushion basket dwarf humor cloud truck job boat submit', true) + ).toEqual(false); }); }); diff --git a/packages/util-crypto/src/mnemonic/validate.ts b/packages/util-crypto/src/mnemonic/validate.ts index 0df21e0d6..785b2c07a 100644 --- a/packages/util-crypto/src/mnemonic/validate.ts +++ b/packages/util-crypto/src/mnemonic/validate.ts @@ -20,8 +20,8 @@ import { validateMnemonic } from './bip39'; * const isValidMnemonic = mnemonicValidate(mnemonic); // => boolean * ``` */ -export default function mnemonicValidate (mnemonic: string): boolean { - return isReady() +export default function mnemonicValidate (mnemonic: string, onlyJs = false): boolean { + return isReady() && !onlyJs ? bip39Validate(mnemonic) : validateMnemonic(mnemonic); } diff --git a/packages/util/package.json b/packages/util/package.json index b46465dd8..dae42fa84 100644 --- a/packages/util/package.json +++ b/packages/util/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/util", - "version": "3.6.2-12", + "version": "3.7.0", "description": "A collection of useful utilities for @polkadot", "main": "index.js", "keywords": [ @@ -26,8 +26,8 @@ "homepage": "https://github.com/polkadot-js/common/tree/master/packages/util#readme", "dependencies": { "@babel/runtime": "^7.12.1", - "@polkadot/x-textdecoder": "^3.6.2-12", - "@polkadot/x-textencoder": "^3.6.2-12", + "@polkadot/x-textdecoder": "^3.7.0", + "@polkadot/x-textencoder": "^3.7.0", "@types/bn.js": "^4.11.6", "bn.js": "^5.1.3", "camelcase": "^5.3.1", diff --git a/packages/util/src/bn/toU8a.ts b/packages/util/src/bn/toU8a.ts index fcb3984d2..597c1db9d 100644 --- a/packages/util/src/bn/toU8a.ts +++ b/packages/util/src/bn/toU8a.ts @@ -12,6 +12,15 @@ interface Options extends ToBnOptions { bitLength?: number; } +function setBn (valueBn: BN, byteLength: number, { isLe, isNegative }: Options): Uint8Array { + const output = new Uint8Array(byteLength); + const bn = isNegative ? valueBn.toTwos(byteLength * 8) : valueBn; + + output.set(bn.toArray(isLe ? 'le' : 'be', byteLength), 0); + + return output; +} + /** * @name bnToU8a * @summary Creates a Uint8Array object from a BN. @@ -29,7 +38,7 @@ interface Options extends ToBnOptions { function bnToU8a (value?: ExtToBn | BN | BigInt | number | null, options?: Options): Uint8Array; function bnToU8a (value?: ExtToBn | BN | BigInt | number | null, bitLength?: number, isLe?: boolean): Uint8Array; function bnToU8a (value?: ExtToBn | BN | BigInt | number | null, arg1: number | Options = { bitLength: -1, isLe: true, isNegative: false }, arg2?: boolean): Uint8Array { - const _options: Options = { + const options: Options = { bitLength: -1, isLe: true, isNegative: false, @@ -37,25 +46,15 @@ function bnToU8a (value?: ExtToBn | BN | BigInt | number }; const valueBn = bnToBn(value); - const byteLength = _options.bitLength === -1 + const byteLength = options.bitLength === -1 ? Math.ceil(valueBn.bitLength() / 8) - : Math.ceil((_options.bitLength || 0) / 8); + : Math.ceil((options.bitLength || 0) / 8); - if (!value) { - return _options.bitLength === -1 + return value + ? setBn(valueBn, byteLength, options) + : options.bitLength === -1 ? new Uint8Array() : new Uint8Array(byteLength); - } - - const output = new Uint8Array(byteLength); - const bn = _options.isNegative ? valueBn.toTwos(byteLength * 8) : valueBn; - - output.set( - bn.toArray(_options.isLe ? 'le' : 'be', byteLength), - 0 - ); - - return output; } export default bnToU8a; diff --git a/packages/util/src/format/formatBalance.spec.ts b/packages/util/src/format/formatBalance.spec.ts index 5aac483f5..358ff5a68 100644 --- a/packages/util/src/format/formatBalance.spec.ts +++ b/packages/util/src/format/formatBalance.spec.ts @@ -20,6 +20,12 @@ describe('formatBalance', (): void => { ).toEqual('123.4567 µUnit'); }); + it('formats 123,456 (decimals=0)', (): void => { + expect( + formatBalance(123456, { decimals: 0, withSi: true }) + ).toEqual('123.4560 kUnit'); + }); + it('formats BigInt numbers', (): void => { expect( formatBalance(123456789000n, { decimals: 15, withSi: true }) diff --git a/packages/util/src/format/formatBalance.ts b/packages/util/src/format/formatBalance.ts index f099e7ec9..ec5d41e6f 100644 --- a/packages/util/src/format/formatBalance.ts +++ b/packages/util/src/format/formatBalance.ts @@ -61,8 +61,8 @@ function _formatBalance (input?: number | string | BN | B : options; // NOTE We start at midpoint (8) minus 1 - this means that values display as - // 123.456 instead of 0.123k (so always 6 relevant). Additionally we us ceil - // so there are at most 3 decimal before the decimal seperator + // 123.456 instead of 0.123k (so always 6 relevant). Additionally we use ceil + // so there are at most 3 decimal before the decimal separator const si = calcSi(text, decimals, forceUnit); const mid = text.length - (decimals + si.power); const prefix = text.substr(0, mid); diff --git a/packages/util/src/format/formatDecimal.ts b/packages/util/src/format/formatDecimal.ts index f9caff87e..ae82c0d24 100644 --- a/packages/util/src/format/formatDecimal.ts +++ b/packages/util/src/format/formatDecimal.ts @@ -1,6 +1,7 @@ // Copyright 2017-2020 @polkadot/util authors & contributors // SPDX-License-Identifier: Apache-2.0 +// eslint-disable-next-line prefer-regex-literals const NUMBER_REGEX = new RegExp('(\\d+?)(?=(\\d{3})+(?!\\d)|$)', 'g'); export default function formatDecimal (value: string): string { diff --git a/packages/util/src/format/formatElapsed.ts b/packages/util/src/format/formatElapsed.ts index 188240493..2e3c2ead4 100644 --- a/packages/util/src/format/formatElapsed.ts +++ b/packages/util/src/format/formatElapsed.ts @@ -8,37 +8,38 @@ import BN from 'bn.js'; import isToBn from '../is/toBn'; function getValue (value?: BN | ExtToBn | Date | number | null): number { - if (value) { - if (isToBn(value)) { - return getValue(value.toBn()); - } else if (value instanceof Date) { - return getValue(value.getTime()); - } else if (value instanceof BN) { - return getValue(value.toNumber()); - } + if (isToBn(value)) { + return getValue(value.toBn()); + } else if (value instanceof Date) { + return getValue(value.getTime()); + } else if (value instanceof BN) { + return getValue(value.toNumber()); } - return (value as number) || 0; + return value || 0; +} + +function formatValue (elapsed: number): string { + if (elapsed < 15) { + return `${elapsed.toFixed(1)}s`; + } else if (elapsed < 60) { + return `${elapsed | 0}s`; + } else if (elapsed < 3600) { + return `${elapsed / 60 | 0}m`; + } + + return `${elapsed / 3600 | 0}h`; } export default function formatElapsed (now?: Date | null, value?: BN | ExtToBn | Date | number | null): string { const tsNow = (now && now.getTime()) || 0; const tsValue = getValue(value); - let display = '0.0s'; if (tsNow && tsValue) { const elapsed = Math.max(Math.abs(tsNow - tsValue), 0) / 1000; - if (elapsed < 15) { - display = `${elapsed.toFixed(1)}s`; - } else if (elapsed < 60) { - display = `${elapsed | 0}s`; - } else if (elapsed < 3600) { - display = `${elapsed / 60 | 0}m`; - } else { - display = `${elapsed / 3600 | 0}h`; - } + return formatValue(elapsed); } - return display; + return '0.0s'; } diff --git a/packages/util/src/hex/toBn.ts b/packages/util/src/hex/toBn.ts index 8405f385d..5aaf8b1c2 100644 --- a/packages/util/src/hex/toBn.ts +++ b/packages/util/src/hex/toBn.ts @@ -8,7 +8,7 @@ import hexStripPrefix from './stripPrefix'; import { ToBnOptions } from '../types'; function reverse (value: string): string { - return (value.match(new RegExp('.{1,2}', 'g')) || []) + return (value.match(/.{1,2}/g) || []) .reverse() .join(''); } diff --git a/packages/util/src/is/ascii.ts b/packages/util/src/is/ascii.ts index 4ba4c7fcf..85d9fc4cc 100644 --- a/packages/util/src/is/ascii.ts +++ b/packages/util/src/is/ascii.ts @@ -13,11 +13,7 @@ const FORMAT = [9, 10, 13]; * Checks to see if the input string or Uint8Array is printable ASCII, 32-127 + formatters */ export default function isAscii (value?: number[] | Buffer | Uint8Array | string | null): boolean { - if (!value) { - return isString(value); - } - - const u8a = u8aToU8a(value); - - return !u8a.some((byte) => (byte >= 127) || (byte < 32 && !FORMAT.includes(byte))); + return value + ? !u8aToU8a(value).some((byte) => (byte >= 127) || (byte < 32 && !FORMAT.includes(byte))) + : isString(value); } diff --git a/packages/util/src/is/testChain.ts b/packages/util/src/is/testChain.ts index 5958882c9..2e139ee8c 100644 --- a/packages/util/src/is/testChain.ts +++ b/packages/util/src/is/testChain.ts @@ -1,7 +1,7 @@ // Copyright 2017-2020 @polkadot/util authors & contributors // SPDX-License-Identifier: Apache-2.0 -const re = new RegExp('(Development|Local Testnet)$'); +const re = /(Development|Local Testnet)$/; export default function isTestChain (chain?: string | null): boolean { if (!chain) { diff --git a/packages/util/src/logger.spec.ts b/packages/util/src/logger.spec.ts index 77a54900e..3a68a44ed 100644 --- a/packages/util/src/logger.spec.ts +++ b/packages/util/src/logger.spec.ts @@ -3,6 +3,8 @@ import { Logger } from './types'; +import BN from 'bn.js'; + import { logger } from '.'; import { format } from './logger'; @@ -62,15 +64,17 @@ describe('logger', (): void => { ); }); - it('logs with mulptiple values', (): void => { - l.log('test', 'a', 2); + it('logs with multiple values', (): void => { + l.log('test', 'a', 2, new BN('12345678900987654321'), Buffer.from([0, 1, 2, 3])); expect(spy.log).toHaveBeenCalledWith( dateMatch, prefixMatch, expect.stringMatching('test'), expect.stringMatching('a'), - 2 + 2, + expect.stringMatching('12345678900987654321'), + expect.stringMatching('0x00010203') ); }); diff --git a/packages/util/src/logger.ts b/packages/util/src/logger.ts index f23e2df71..aebd910ec 100644 --- a/packages/util/src/logger.ts +++ b/packages/util/src/logger.ts @@ -5,11 +5,12 @@ import { Logger, Logger$Data } from './types'; import formatDate from './format/formatDate'; import isBn from './is/bn'; -import isBuffer from './is/buffer'; import isFunction from './is/function'; import isObject from './is/object'; import isU8a from './is/u8a'; import u8aToHex from './u8a/toHex'; +import u8aToU8a from './u8a/toU8a'; +import { isBuffer } from './is'; type ConsoleType = 'error' | 'log' | 'warn'; type LogType = ConsoleType | 'debug'; @@ -34,21 +35,11 @@ function formatObject (value: Record): Record export function format (value: unknown): unknown { if (Array.isArray(value)) { return value.map(format); - } - - if (isBn(value)) { + } else if (isBn(value)) { return value.toString(); - } - - if (isBuffer(value)) { - return `0x${value.toString('hex')}`; - } - - if (isU8a(value)) { - return u8aToHex(value); - } - - if (value && isObject(value) && value.constructor === Object) { + } else if (isU8a(value) || isBuffer(value)) { + return u8aToHex(u8aToU8a(value)); + } else if (value && isObject(value) && value.constructor === Object) { return formatObject(value); } diff --git a/packages/util/src/polyfill/fill.ts b/packages/util/src/polyfill/fill.ts index 08c68f00c..87a22ef44 100644 --- a/packages/util/src/polyfill/fill.ts +++ b/packages/util/src/polyfill/fill.ts @@ -2,50 +2,30 @@ // SPDX-License-Identifier: Apache-2.0 /* eslint-disable no-extend-native */ -/* eslint-disable @typescript-eslint/unbound-method */ + +import assert from '../assert'; + +function getOffset (value: number, length: number): number { + return value < 0 + ? Math.max(length + value, 0) + : Math.min(value, length); +} if (!Array.prototype.fill) { - // eslint-disable-next-line no-extend-native,@typescript-eslint/no-explicit-any - Array.prototype.fill = function fill (value: any, start = 0, end?: number): any[] { - // Steps 1-2. - if (!this) { - throw new TypeError('this is null or not defined'); - } + // eslint-disable-next-line no-extend-native + Array.prototype.fill = function fill (value: T, start = 0, end?: number): T[] { + assert(this, 'this is null or not defined'); - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment - const A = Object(this); + const A = Object(this) as T[]; + const relativeEnd = end ?? A.length; + const final = getOffset(relativeEnd, A.length); + let k = getOffset(start, A.length); - // Steps 3-5. - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - const len = A.length >>> 0; - - // Steps 6-7. - const relativeStart = start >> 0; - - // Step 8. - let k = relativeStart < 0 - ? Math.max(len + relativeStart, 0) - : Math.min(relativeStart, len); - - // Steps 9-10. - const relativeEnd = end === undefined - ? len - : end >> 0; - - // Step 11. - const final = relativeEnd < 0 - ? Math.max(len + relativeEnd, 0) - : Math.min(relativeEnd, len); - - // Step 12. while (k < final) { - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access A[k] = value; k++; } - // Step 13. - // eslint-disable-next-line @typescript-eslint/no-unsafe-return return A; }; } diff --git a/packages/util/src/u8a/toHex.ts b/packages/util/src/u8a/toHex.ts index 49a813a90..0ef51355c 100644 --- a/packages/util/src/u8a/toHex.ts +++ b/packages/util/src/u8a/toHex.ts @@ -7,6 +7,22 @@ for (let n = 0; n < 256; ++n) { ALPHABET[n] = n.toString(16).padStart(2, '0'); } +/** @internal */ +function extract (value: Uint8Array): string { + const result = new Array(value.length) as string[]; + + for (let i = 0; i < value.length; i++) { + result[i] = ALPHABET[value[i]]; + } + + return result.join(''); +} + +/** @internal */ +function trim (value: Uint8Array, halfLength: number): string { + return `${u8aToHex(value.subarray(0, halfLength), -1, false)}…${u8aToHex(value.subarray(value.length - halfLength), -1, false)}`; +} + /** * @name u8aToHex * @summary Creates a hex string from a Uint8Array object. @@ -32,17 +48,8 @@ export default function u8aToHex (value?: Uint8Array | null, bitLength = -1, isP const byteLength = Math.ceil(bitLength / 8); - if (byteLength > 0 && value.length > byteLength) { - const halfLength = Math.ceil(byteLength / 2); - - return `${u8aToHex(value.subarray(0, halfLength), -1, isPrefixed)}…${u8aToHex(value.subarray(value.length - halfLength), -1, false)}`; - } - - const result = new Array(value.length) as string[]; - - for (let i = 0; i < value.length; i++) { - result[i] = ALPHABET[value[i]]; - } - - return prefix + result.join(''); + return prefix + ((byteLength > 0 && value.length > byteLength) + ? trim(value, Math.ceil(byteLength / 2)) + : extract(value) + ); } diff --git a/packages/x-fetch/package.json b/packages/x-fetch/package.json index de8e401b5..542dff062 100644 --- a/packages/x-fetch/package.json +++ b/packages/x-fetch/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/x-fetch", - "version": "3.6.2-12", + "version": "3.7.0", "description": "A cross-environment fetch replacement", "browser": "browser.js", "main": "node.js", diff --git a/packages/x-textdecoder/package.json b/packages/x-textdecoder/package.json index 23dc77e2a..4fc4a9462 100644 --- a/packages/x-textdecoder/package.json +++ b/packages/x-textdecoder/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/x-textdecoder", - "version": "3.6.2-12", + "version": "3.7.0", "description": "A TextDecoder replacement", "browser": "browser.js", "main": "node.js", diff --git a/packages/x-textencoder/package.json b/packages/x-textencoder/package.json index 62fc4b7ca..acc90512d 100644 --- a/packages/x-textencoder/package.json +++ b/packages/x-textencoder/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/x-textencoder", - "version": "3.6.2-12", + "version": "3.7.0", "description": "A TextDecoder replacement", "browser": "browser.js", "main": "node.js", diff --git a/packages/x-ws/package.json b/packages/x-ws/package.json index 9f7c7c72e..a990e88b0 100644 --- a/packages/x-ws/package.json +++ b/packages/x-ws/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/x-ws", - "version": "3.6.2-12", + "version": "3.7.0", "description": "A cross-environment WebSocket replacement", "browser": "browser.js", "main": "node.js", diff --git a/yarn.lock b/yarn.lock index e8fe8765b..340fee27b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1443,9 +1443,9 @@ __metadata: languageName: node linkType: hard -"@eslint/eslintrc@npm:^0.1.3": - version: 0.1.3 - resolution: "@eslint/eslintrc@npm:0.1.3" +"@eslint/eslintrc@npm:^0.2.1": + version: 0.2.1 + resolution: "@eslint/eslintrc@npm:0.2.1" dependencies: ajv: ^6.12.4 debug: ^4.1.1 @@ -1457,7 +1457,7 @@ __metadata: lodash: ^4.17.19 minimatch: ^3.0.4 strip-json-comments: ^3.1.1 - checksum: e9c5eaa5e706bcedbba6e7e1a2bc85faa7e3a9edbe71375e07240d1b6540fbb88d907bd5e5841b42c2a7a9683dcf031ea052c447c3c9d81ba4d0b74f0dd67e5f + checksum: 99310cddf0f1abb2de4b5278293db6e2639445aab4e525f3c5f5b3b8ad53a59d6003a306954fb7ad15edd2f8a02b658d43418fa8b52ae2d07e074b24d991de2a languageName: node linkType: hard @@ -1712,9 +1712,9 @@ __metadata: languageName: node linkType: hard -"@polkadot/dev@npm:^0.59.10": - version: 0.59.10 - resolution: "@polkadot/dev@npm:0.59.10" +"@polkadot/dev@npm:^0.59.12": + version: 0.59.12 + resolution: "@polkadot/dev@npm:0.59.12" dependencies: "@babel/cli": ^7.12.1 "@babel/core": ^7.12.3 @@ -1736,7 +1736,7 @@ __metadata: "@babel/preset-typescript": ^7.12.1 "@babel/register": ^7.12.1 "@babel/runtime": ^7.12.1 - "@rushstack/eslint-patch": ^1.0.5 + "@rushstack/eslint-patch": ^1.0.6 "@typescript-eslint/eslint-plugin": 4.6.0 "@typescript-eslint/parser": 4.6.0 "@vue/component-compiler-utils": ^3.2.0 @@ -1747,8 +1747,8 @@ __metadata: browserslist: ^4.14.5 chalk: ^4.1.0 coveralls: ^3.1.0 - eslint: 7.11.0 - eslint-config-standard: ^15.0.1 + eslint: ^7.12.1 + eslint-config-standard: ^16.0.1 eslint-import-resolver-node: ^0.3.4 eslint-plugin-header: ^3.1.0 eslint-plugin-import: ^2.22.1 @@ -1801,7 +1801,7 @@ __metadata: polkadot-exec-typedoc: scripts/polkadot-exec-typedoc.js polkadot-exec-vuepress: scripts/polkadot-exec-vuepress.js polkadot-exec-webpack: scripts/polkadot-exec-webpack.js - checksum: 6bca7dd879f80c49637015475492c979e092b2aa68c925337709d5a142c2ba7496ab984d1012b2c5a429d30d47e128651b8af6cb074a81acbd0d8275a3c8b646 + checksum: e683db199506c22492c1a41b838844453620cbf4356920772f785618eabd056a3a8bc47a2da2e3ad5be7b58f14e0bbad2fa28458a4eca72e5156b28682ff19d9 languageName: node linkType: hard @@ -1810,18 +1810,18 @@ __metadata: resolution: "@polkadot/keyring@workspace:packages/keyring" dependencies: "@babel/runtime": ^7.12.1 - "@polkadot/util": ^3.6.2-12 - "@polkadot/util-crypto": ^3.6.2-12 + "@polkadot/util": ^3.7.0 + "@polkadot/util-crypto": ^3.7.0 languageName: unknown linkType: soft -"@polkadot/networks@^3.6.2-12, @polkadot/networks@workspace:packages/networks": +"@polkadot/networks@^3.7.0, @polkadot/networks@workspace:packages/networks": version: 0.0.0-use.local resolution: "@polkadot/networks@workspace:packages/networks" dependencies: "@babel/runtime": ^7.12.1 - "@polkadot/util": ^3.6.2-12 - "@polkadot/x-fetch": ^3.6.2-12 + "@polkadot/util": ^3.7.0 + "@polkadot/x-fetch": ^3.7.0 languageName: unknown linkType: soft @@ -1834,13 +1834,13 @@ __metadata: languageName: node linkType: hard -"@polkadot/util-crypto@^3.6.2-12, @polkadot/util-crypto@workspace:packages/util-crypto": +"@polkadot/util-crypto@^3.7.0, @polkadot/util-crypto@workspace:packages/util-crypto": version: 0.0.0-use.local resolution: "@polkadot/util-crypto@workspace:packages/util-crypto" dependencies: "@babel/runtime": ^7.12.1 - "@polkadot/networks": ^3.6.2-12 - "@polkadot/util": ^3.6.2-12 + "@polkadot/networks": ^3.7.0 + "@polkadot/util": ^3.7.0 "@polkadot/wasm-crypto": ^1.4.1 "@types/bn.js": ^4.11.6 "@types/create-hash": ^1.2.2 @@ -1861,13 +1861,13 @@ __metadata: languageName: unknown linkType: soft -"@polkadot/util@^3.6.2-12, @polkadot/util@workspace:packages/util": +"@polkadot/util@^3.7.0, @polkadot/util@workspace:packages/util": version: 0.0.0-use.local resolution: "@polkadot/util@workspace:packages/util" dependencies: "@babel/runtime": ^7.12.1 - "@polkadot/x-textdecoder": ^3.6.2-12 - "@polkadot/x-textencoder": ^3.6.2-12 + "@polkadot/x-textdecoder": ^3.7.0 + "@polkadot/x-textencoder": ^3.7.0 "@types/bn.js": ^4.11.6 bn.js: ^5.1.3 camelcase: ^5.3.1 @@ -1884,7 +1884,7 @@ __metadata: languageName: node linkType: hard -"@polkadot/x-fetch@^3.6.2-12, @polkadot/x-fetch@workspace:packages/x-fetch": +"@polkadot/x-fetch@^3.7.0, @polkadot/x-fetch@workspace:packages/x-fetch": version: 0.0.0-use.local resolution: "@polkadot/x-fetch@workspace:packages/x-fetch" dependencies: @@ -1894,7 +1894,7 @@ __metadata: languageName: unknown linkType: soft -"@polkadot/x-textdecoder@^3.6.2-12, @polkadot/x-textdecoder@workspace:packages/x-textdecoder": +"@polkadot/x-textdecoder@^3.7.0, @polkadot/x-textdecoder@workspace:packages/x-textdecoder": version: 0.0.0-use.local resolution: "@polkadot/x-textdecoder@workspace:packages/x-textdecoder" dependencies: @@ -1902,7 +1902,7 @@ __metadata: languageName: unknown linkType: soft -"@polkadot/x-textencoder@^3.6.2-12, @polkadot/x-textencoder@workspace:packages/x-textencoder": +"@polkadot/x-textencoder@^3.7.0, @polkadot/x-textencoder@workspace:packages/x-textencoder": version: 0.0.0-use.local resolution: "@polkadot/x-textencoder@workspace:packages/x-textencoder" dependencies: @@ -1920,10 +1920,10 @@ __metadata: languageName: unknown linkType: soft -"@rushstack/eslint-patch@npm:^1.0.5": - version: 1.0.5 - resolution: "@rushstack/eslint-patch@npm:1.0.5" - checksum: 76891efcaee71feea5446110d7ea382e51c8d91bf3fd6627c042f3b6bccdbb78085935eaff005bbe0d64ac503f221f3cd33b8add7487464d11eb6d6addd37771 +"@rushstack/eslint-patch@npm:^1.0.6": + version: 1.0.6 + resolution: "@rushstack/eslint-patch@npm:1.0.6" + checksum: cc01301f09d881da550a2f3c6a3f10b72dfb4c422b7a00a4b2e8bfc90d998aee06f08a6e7c9d03db89d5b286318d533435dc6c8c500884fe6ab05cb1309dfcc7 languageName: node linkType: hard @@ -1962,15 +1962,15 @@ __metadata: linkType: hard "@types/babel__core@npm:^7.0.0, @types/babel__core@npm:^7.1.7": - version: 7.1.10 - resolution: "@types/babel__core@npm:7.1.10" + version: 7.1.11 + resolution: "@types/babel__core@npm:7.1.11" dependencies: "@babel/parser": ^7.1.0 "@babel/types": ^7.0.0 "@types/babel__generator": "*" "@types/babel__template": "*" "@types/babel__traverse": "*" - checksum: fd013086d241527c708844ff379ec5204b31dfb4e50a427bc24e77172af74041f6eab650da16edf1a20f445595052505792ec7fa1978bb5f8f2c191bfc8c767d + checksum: 081ea9a093ce22ebbc7fd07c07298d84d551f1517159631a69953634509e88324d26199b012a20cca5da116222f9f3468b1ee98eb78f6bb4efb909c0e856f272 languageName: node linkType: hard @@ -2065,9 +2065,9 @@ __metadata: linkType: hard "@types/har-format@npm:*": - version: 1.2.4 - resolution: "@types/har-format@npm:1.2.4" - checksum: 8d0c62f99ea579b6aa23219f9e97c8ef70dc0254a419b4c9a2c602860f7d3d6da7cb867da4b15087d7bf2588f8dd40b6f941350ba2c04168a67892b5f2661fad + version: 1.2.5 + resolution: "@types/har-format@npm:1.2.5" + checksum: 1dbaa1d7cddb2fa0ddf533e8ae7f20bca2116738274a1a1e9fe2863b6c26e668b59ac4dfdfb45450d5c374de689721647ca891aa342e239049f69d5de3604cd9 languageName: node linkType: hard @@ -2736,9 +2736,9 @@ __metadata: linkType: hard "aws4@npm:^1.8.0": - version: 1.10.1 - resolution: "aws4@npm:1.10.1" - checksum: 53f2897324997542e3cfeca0b24f5960e2470eb8527f0b6587432a4607dcb8ca817955aef4297a3b429f1ca5fa688ba1b6bc57d744add41292ffcb59466392bb + version: 1.11.0 + resolution: "aws4@npm:1.11.0" + checksum: d30dce2b73839974894d8283a06c53e8374b74d643d3b08340d84c364e01158be011fcfd1a88f8462be946d69055313a3038202f2eafd155b039aaab3549ba21 languageName: node linkType: hard @@ -3059,12 +3059,12 @@ __metadata: linkType: hard "bufferutil@npm:^4.0.1": - version: 4.0.1 - resolution: "bufferutil@npm:4.0.1" + version: 4.0.2 + resolution: "bufferutil@npm:4.0.2" dependencies: node-gyp: latest - node-gyp-build: ~3.7.0 - checksum: f83b1ce112ffe60812573facf01a0c33e856a757a37d34afaafa73ff82bcd32ed816a0c22bfc31e108d9bbce6faa4886747e1f512899fb6235a3e3896bbe38c3 + node-gyp-build: ^4.2.0 + checksum: cb71bbdc609b6de49aaf2ff45fac5c64c55ff965f6bfe6f2bc357cc05afce69206a9ca1567011951b3f18b54dca24ef21be407d8ffce5a38a5f87bc2416140dd languageName: node linkType: hard @@ -3100,6 +3100,16 @@ __metadata: languageName: node linkType: hard +"call-bind@npm:^1.0.0": + version: 1.0.0 + resolution: "call-bind@npm:1.0.0" + dependencies: + function-bind: ^1.1.1 + get-intrinsic: ^1.0.0 + checksum: aeb82f8f5dfd56592c7dcef89367227daa60be4f8e7fdb7689d6c1f8712872911d7e31fddd3336534f45cea56d9a4e7d48889596ce6d2f1ada4507573306e6b1 + languageName: node + linkType: hard + "callsites@npm:^3.0.0": version: 3.1.0 resolution: "callsites@npm:3.1.0" @@ -3122,9 +3132,9 @@ __metadata: linkType: hard "caniuse-lite@npm:^1.0.30001135": - version: 1.0.30001153 - resolution: "caniuse-lite@npm:1.0.30001153" - checksum: 070c4a2c7f04e1fd00cdb12393a5f09d414d681814e5860626a1769a40474e7251a3d3ad0b988df25d37d0036580b2578a151fe4cdff571714f55b0f0f1afe57 + version: 1.0.30001154 + resolution: "caniuse-lite@npm:1.0.30001154" + checksum: 7e087e61d039da66d64595c64afc50032a7bb90d2a96859ad17272031d48806c59488aba04f2f69c98238c293167ec4b2e510a6f8ccf8d90705b340a77961aed languageName: node linkType: hard @@ -4055,9 +4065,9 @@ __metadata: linkType: hard "electron-to-chromium@npm:^1.3.571": - version: 1.3.584 - resolution: "electron-to-chromium@npm:1.3.584" - checksum: 34064db714d728f4495557eba05f454f0adb0de73c0b9125eb5fb837eb05fc42790e2e1a4df22b978176f2b8d30da2396132ba4abdb3cd26fe248085cc82f212 + version: 1.3.585 + resolution: "electron-to-chromium@npm:1.3.585" + checksum: a7cd8515631144a05e065d19ec6cc1ace5547f7bd81af5815f8dd4f2ff14cd1fd1aef95a6628b24e20d63b35fdaf5304efbb597231f0efa4670fde905e5a6b06 languageName: node linkType: hard @@ -4289,16 +4299,15 @@ __metadata: languageName: node linkType: hard -"eslint-config-standard@npm:^15.0.1": - version: 15.0.1 - resolution: "eslint-config-standard@npm:15.0.1" +"eslint-config-standard@npm:^16.0.1": + version: 16.0.1 + resolution: "eslint-config-standard@npm:16.0.1" peerDependencies: - eslint: ">=7.11.0" - eslint-plugin-import: ">=2.22.1" - eslint-plugin-node: ">=11.1.0" - eslint-plugin-promise: ">=4.2.1" - eslint-plugin-standard: ">=4.0.2" - checksum: e5e234126d309b37d25bc00d436b4cb3460ca818ed87411e241c69ef69c87fae217fea832028998e41b378a677e02994256963fbfb31dcd2bc2a96d42858d0e3 + eslint: ^7.12.1 + eslint-plugin-import: ^2.22.1 + eslint-plugin-node: ^11.1.0 + eslint-plugin-promise: ^4.2.1 + checksum: 496bd25045dd8cfba1d34d9b1d1cdd34a3243eebf924b147e9cf51661342a77a0af03582dd1fd4968101700f61d55a5437b14a12a90ef9b4c5d759065cc39449 languageName: node linkType: hard @@ -4472,12 +4481,12 @@ __metadata: languageName: node linkType: hard -"eslint@npm:7.11.0": - version: 7.11.0 - resolution: "eslint@npm:7.11.0" +"eslint@npm:^7.12.1": + version: 7.12.1 + resolution: "eslint@npm:7.12.1" dependencies: "@babel/code-frame": ^7.0.0 - "@eslint/eslintrc": ^0.1.3 + "@eslint/eslintrc": ^0.2.1 ajv: ^6.10.0 chalk: ^4.0.0 cross-spawn: ^7.0.2 @@ -4515,7 +4524,7 @@ __metadata: v8-compile-cache: ^2.0.3 bin: eslint: bin/eslint.js - checksum: 45ef6dc7b31684ca0f383ed9c6224e763197e1d49745542f4440e37286c947973388a6a7ebbf103eeee91ddb4af2652c5d22718f4130bfbbf4bd16a04103f82a + checksum: b3d11ea516d2932db5854ea942a546b711e6ee8735306627042bb9e2539e96844cc62cdb5826039f5d0509202936045c2cd7b84b457004c891a326f8eccae333 languageName: node linkType: hard @@ -5164,6 +5173,17 @@ fsevents@^1.2.7: languageName: node linkType: hard +"get-intrinsic@npm:^1.0.0": + version: 1.0.1 + resolution: "get-intrinsic@npm:1.0.1" + dependencies: + function-bind: ^1.1.1 + has: ^1.0.3 + has-symbols: ^1.0.1 + checksum: c38bc558f1eca73bde2d9e22c7798b06c4b93650f39b2053a875a23a6c00fbafb0919ad20fe0d3a3e16916a8a59450502f91e75a918d264456c8ded070fe93c4 + languageName: node + linkType: hard + "get-own-enumerable-property-symbols@npm:^3.0.0": version: 3.0.2 resolution: "get-own-enumerable-property-symbols@npm:3.0.2" @@ -6901,15 +6921,15 @@ fsevents@^1.2.7: linkType: hard "jsonfile@npm:^6.0.1": - version: 6.0.1 - resolution: "jsonfile@npm:6.0.1" + version: 6.1.0 + resolution: "jsonfile@npm:6.1.0" dependencies: graceful-fs: ^4.1.6 - universalify: ^1.0.0 + universalify: ^2.0.0 dependenciesMeta: graceful-fs: optional: true - checksum: ebd6932424db468226b0b525b5b8acefd97e46f4fc5f36232c94e928b405716b47b2d7c2342025ecd7a0219f2146ae613d33878b917505698b7dc36ebe082c11 + checksum: 9419c886abc6f8a5088cbb222b7bc17c76e8ee9f6c0e5c38781a4e09488166084f25247bc0b58e025b08c43064c82ae860ad89a992e35fc8cfae639323b7edbc languageName: node linkType: hard @@ -7572,14 +7592,14 @@ fsevents@^1.2.7: languageName: node linkType: hard -"node-gyp-build@npm:~3.7.0": - version: 3.7.0 - resolution: "node-gyp-build@npm:3.7.0" +"node-gyp-build@npm:^4.2.0": + version: 4.2.3 + resolution: "node-gyp-build@npm:4.2.3" bin: - node-gyp-build: ./bin.js - node-gyp-build-optional: ./optional.js - node-gyp-build-test: ./build-test.js - checksum: 61c7f2a9e44c5b23a0dc830e98cb0de3364894091daae0da471797627acedd06fe108107f4c840c2b0ff8bcfbdac8ec0c1767a3e159941eadd4c8fbbdc29a586 + node-gyp-build: bin.js + node-gyp-build-optional: optional.js + node-gyp-build-test: build-test.js + checksum: 8512c25498b1605dbe9d2605cac7f8996d18c35097b3079b232674b0f3b8f1559be6f531ec3a00a94f90a0a69ccc452edb62f8f6dfff8caa3abe4b729cc21b06 languageName: node linkType: hard @@ -7632,9 +7652,9 @@ fsevents@^1.2.7: linkType: hard "node-releases@npm:^1.1.61": - version: 1.1.64 - resolution: "node-releases@npm:1.1.64" - checksum: 09e85fd0eccee979c56c8582dac19a6f88fe4444f0ae0c2c55a7e70df10cf11530f76d3203150e9961fa59d0448cab406d450cef3bc4681f12c3edd070d68b36 + version: 1.1.65 + resolution: "node-releases@npm:1.1.65" + checksum: 7b8b1c118e3596376841ad44d33c55b93a3d3b7f9827ca48048579e58a81110ed3df00942ca7bd6c59d52adfdfb6da5ee1d33514b57ef8c9ee65d36bd0a3a609 languageName: node linkType: hard @@ -7798,14 +7818,14 @@ fsevents@^1.2.7: linkType: hard "object.assign@npm:^4.1.0, object.assign@npm:^4.1.1": - version: 4.1.1 - resolution: "object.assign@npm:4.1.1" + version: 4.1.2 + resolution: "object.assign@npm:4.1.2" dependencies: + call-bind: ^1.0.0 define-properties: ^1.1.3 - es-abstract: ^1.18.0-next.0 has-symbols: ^1.0.1 object-keys: ^1.1.1 - checksum: 2038905bbf7c07313df831e83e40fc4eba783d2d680533ec47c546e562e939902db69c83fea9bd836204aa3e01e8db0faa412d4f649c9825235cc8e5c1166dd1 + checksum: a5855cc6db3f64606c41ceb97cb9847e667d8240889d771d65638244be1d35c2e2ccb5762f437bb76abf4e98ab4634a9d302380398121cee288a44dce5028f54 languageName: node linkType: hard @@ -8643,9 +8663,9 @@ fsevents@^1.2.7: linkType: hard "regenerate@npm:^1.4.0": - version: 1.4.1 - resolution: "regenerate@npm:1.4.1" - checksum: 67fe7ea33291997b20634105c7b6787bcc03e137da348c1cc0d617b3d97d9ed1e05ce4b6dabcb86be7ddf198000f78275bcabd67e66889ba7daa296926f8eada + version: 1.4.2 + resolution: "regenerate@npm:1.4.2" + checksum: 54275a99effd8a439bcdd88942b61f68a769133df841e90d94df9ae7c250cb6537c0a28dd913116539772b3415edbcb3c8d81c22275595d3755cf0353976dfa4 languageName: node linkType: hard @@ -8991,7 +9011,7 @@ fsevents@^1.2.7: resolution: "root-workspace-0b6124@workspace:." dependencies: "@babel/core": ^7.12.3 - "@polkadot/dev": ^0.59.10 + "@polkadot/dev": ^0.59.12 "@polkadot/ts": ^0.3.53 "@types/jest": ^26.0.15 languageName: unknown @@ -10257,6 +10277,13 @@ fsevents@^1.2.7: languageName: node linkType: hard +"universalify@npm:^2.0.0": + version: 2.0.0 + resolution: "universalify@npm:2.0.0" + checksum: 36bfbdc97bd4b483596e66ea65e20663f5ab9ec3650157d99b075b7f97afcdefe46bbb23f89171dd75595d398cea3769a5b6d7130f5c66cae2a0f00904780f62 + languageName: node + linkType: hard + "unset-value@npm:^1.0.0": version: 1.0.0 resolution: "unset-value@npm:1.0.0" @@ -10329,12 +10356,12 @@ fsevents@^1.2.7: linkType: hard "utf-8-validate@npm:^5.0.2": - version: 5.0.2 - resolution: "utf-8-validate@npm:5.0.2" + version: 5.0.3 + resolution: "utf-8-validate@npm:5.0.3" dependencies: node-gyp: latest - node-gyp-build: ~3.7.0 - checksum: 1ca86a68ee4565141683cfdbf3c290cb746963be28040029717eb27b31ec305c0e0e99586af85eef060ed495617580fcc974250e15807a30a403d8df2a812984 + node-gyp-build: ^4.2.0 + checksum: 0204294d8584ffba171c6b0f97613a4a9c882152067672b45f533f2c640786042ee2b4aeb5f390d6a741eb93b0dc925404652a78c29f9348e6cd422cbdaa44ca languageName: node linkType: hard