diff --git a/CHANGELOG.md b/CHANGELOG.md index 7551d07d..53accfd3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ -# 0.13.x +# 0.13.1 -- Added a build-time optional asm.js fallback for the WASM libraries when WebAssembly is not available, i.e. on React Native. To enable this, add `CRYPTO_ASM=1` to your environment config. (i.e. `CRYPTO_ASM=1 yarn build`) +- Added an asm.js fallback which is active for React Native via the `"react-native"` entry in `package.json`. Ensure that you run the build step with the `NODE_OPTIONS=--max_old_space_size=8192` flags, since the asm.js bundle is large. (For RN the full command would therefore be `NODE_OPTIONS=--max_old_space_size=8192 npm start`) # 0.12.1 diff --git a/lerna.json b/lerna.json index 8cfa3d6c..b82d3b46 100644 --- a/lerna.json +++ b/lerna.json @@ -9,5 +9,5 @@ "packages": [ "packages/*" ], - "version": "0.13.0-beta.4" + "version": "0.13.0" } diff --git a/package.json b/package.json index 2e4957e4..ea81df6f 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "devDependencies": { "@babel/core": "^7.5.4", "@polkadot/dev": "^0.30.0-beta.23", - "@polkadot/util": "^0.94.0-beta.18", + "@polkadot/util": "^0.94.0-beta.19", "override-require": "^1.1.1" } } diff --git a/packages/wasm-crypto/package.json b/packages/wasm-crypto/package.json index d183b2d4..a664dd92 100644 --- a/packages/wasm-crypto/package.json +++ b/packages/wasm-crypto/package.json @@ -1,6 +1,6 @@ { "name": "@polkadot/wasm-crypto", - "version": "0.13.0-beta.4", + "version": "0.13.0", "author": "Jaco Greeff ", "files": [ "crypto-polyfill.js", diff --git a/packages/wasm-crypto/src/js/wasm_promise.js b/packages/wasm-crypto/src/js/wasm_promise.js index 26099906..22a76289 100644 --- a/packages/wasm-crypto/src/js/wasm_promise.js +++ b/packages/wasm-crypto/src/js/wasm_promise.js @@ -6,23 +6,22 @@ const pkg = require('./package.json'); const asm = require('./wasm_asm_stub'); const bytes = require('./wasm_wasm'); -const js = require('./wasm'); +const imports = require('./wasm'); module.exports = async function createExportPromise () { - const imports = { - './wasm': js - }; + try { + const { instance } = await WebAssembly.instantiate(bytes, { './wasm': imports }); - if (WebAssembly) { - try { - const { instance } = await WebAssembly.instantiate(bytes, imports); - - return instance.exports; - } catch (error) { - console.error(`ERROR: Unable to initialize WebAssembly for ${pkg.name} ${pkg.version}`); - console.error(error); + return instance.exports; + } catch (error) { + // if we have a valid supplied asm.js, return that + if (asm && asm.ext_blake2b) { + return asm; } - } - return asm; + console.error(`ERROR: Unable to initialize ${pkg.name} ${pkg.version}`); + console.error(error); + + return null; + } }; diff --git a/yarn.lock b/yarn.lock index a8d816c3..6242155d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2030,10 +2030,10 @@ typescript "^3.5.3" vuepress "^1.0.2" -"@polkadot/util@^0.94.0-beta.18": - version "0.94.0-beta.18" - resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-0.94.0-beta.18.tgz#363581e1092a1972d1f14df0db18d85a3a27f380" - integrity sha512-SzcKGFeskHQMdrZDnsRQ72lFYkUBWAJBAhjMrpUZR0iMvOSnjaX663034PLr3hvUKunh9W6NjQHJAOrpBgaFfA== +"@polkadot/util@^0.94.0-beta.19": + version "0.94.0-beta.19" + resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-0.94.0-beta.19.tgz#ed2f379cc644e5663941ac9058050e6227bb9c23" + integrity sha512-jJaMPXuCW7Ch+AKvu4YYT39uL2l/JwKL4jPQDO4StVshyOfr5fvpMSGxE2NGbsntFjLqvb0kODIsv2sFdbMF4Q== dependencies: "@babel/runtime" "^7.5.5" "@types/bn.js" "^4.11.5"