Compare commits

...
37 Commits
Author SHA1 Message Date
github-actions[bot] 6ce3e3d67c [CI Skip] release/stable 6.3.1
skip-checks: true
2022-07-21 05:20:47 +00:00
Jaco af4ed8a1db 6.3.1 (#405) 2022-07-21 08:15:29 +03:00
github-actions[bot] 57248e7ce4 [CI Skip] bump/beta 6.2.4-10-x
skip-checks: true
2022-07-19 06:50:16 +00:00
Jaco fe91118385 Optimize packed WASM base64 decoding loop (#404) 2022-07-19 09:45:11 +03:00
github-actions[bot] b36cd04348 [CI Skip] bump/beta 6.2.4-9-x
skip-checks: true
2022-07-19 05:50:20 +00:00
Jaco 8ae4176af6 Bump dev deps (#403) 2022-07-19 08:45:50 +03:00
github-actions[bot] 775b64f1bd [CI Skip] bump/beta 6.2.4-8-x
skip-checks: true
2022-07-15 10:02:49 +00:00
Jaco 66ebae8c62 Slight adjustment to tests (#402)
* Slight adjustment to tests

* beforeAll adjustment

* Adjust test forEach

* Test import map removal

* Adjust

* Remove input import_map template
2022-07-15 12:57:59 +03:00
github-actions[bot] c925bcf8d9 [CI Skip] bump/beta 6.2.4-7-x
skip-checks: true
2022-07-11 13:43:28 +00:00
Jaco beb995d507 Adjust import_map.in.json (#401) 2022-07-11 16:36:57 +03:00
github-actions[bot] 1523a53e10 [CI Skip] bump/beta 6.2.4-6-x
skip-checks: true
2022-07-11 06:08:08 +00:00
Jaco 188f7d3edc Bump common (#400) 2022-07-11 09:02:04 +03:00
github-actions[bot] 6da14ce25b [CI Skip] bump/beta 6.2.4-5-x
skip-checks: true
2022-07-11 05:25:44 +00:00
Jaco 9cacf07fe3 Bump dev (#399) 2022-07-11 08:20:04 +03:00
github-actions[bot] d0258cb3f3 [CI Skip] bump/beta 6.2.4-4-x
skip-checks: true
2022-07-09 08:01:12 +00:00
Jaco b5ae0089d1 Single deno step (aligning with other repos) (#396)
* Single deno step (aligning with other repos)

* skip root mod.ts
2022-07-09 10:56:18 +03:00
github-actions[bot] e07bd1eb00 [CI Skip] bump/beta 6.2.4-3-x
skip-checks: true
2022-07-08 21:41:19 +00:00
Jaco 6d79a71d93 Bump dev deps (#395) 2022-07-09 00:36:12 +03:00
github-actions[bot] c3289ca919 [CI Skip] bump/beta 6.2.4-2-x
skip-checks: true
2022-07-08 13:37:31 +00:00
Jaco b7648e5883 Adjust eslint config (#394) 2022-07-08 16:32:39 +03:00
github-actions[bot] 03b487ae81 [CI Skip] bump/beta 6.2.4-1-x
skip-checks: true
2022-07-08 07:46:21 +00:00
Jaco b1350bd8b4 Adjust size stats output on build (#393) 2022-07-08 10:41:42 +03:00
github-actions[bot] 1516d23ea4 [CI Skip] bump/beta 6.2.4-0-x
skip-checks: true
2022-07-08 04:50:05 +00:00
Jaco 9abaae980f Bump dev (#392)
* Bump dev

* Rebump
2022-07-08 07:44:57 +03:00
github-actions[bot] 370a529668 [CI Skip] release/stable 6.2.3
skip-checks: true
2022-07-07 06:42:17 +00:00
Jaco b7486f4f3b 6.2.3 (w/ dev publish fix) (#391) 2022-07-07 09:37:32 +03:00
Jaco ff4a877ef9 6.2.3 (#390)
* 6.2.3

* Skip extra installs on linting (non-build)
2022-07-07 09:19:49 +03:00
github-actions[bot] e0f741db37 [CI Skip] bump/beta 6.2.3-4-x
skip-checks: true
2022-07-06 11:09:51 +00:00
Jaco 3107861322 Adjust issue template (#389) 2022-07-06 14:04:54 +03:00
github-actions[bot] 7eff345003 [CI Skip] bump/beta 6.2.3-3-x
skip-checks: true
2022-07-06 10:24:19 +00:00
Jaco 00f7da2136 Bump depv deps (#388) 2022-07-06 13:19:14 +03:00
github-actions[bot] 150a143163 [CI Skip] bump/beta 6.2.3-2-x
skip-checks: true
2022-07-06 09:51:51 +00:00
Jaco f31ec881ef Additional platform-specific tests (#387)
* Additional platform-specific tests

* align casing

* Step rename

* lenIn/lenOut for deno

* Remove install ls

* Run deno tests on full suite

* trigger
2022-07-06 12:46:38 +03:00
github-actions[bot] 0b838d2055 [CI Skip] bump/beta 6.2.3-1-x
skip-checks: true
2022-07-05 21:27:10 +00:00
Jaco b68aefe64d Additional CI actions (#386) 2022-07-06 00:21:24 +03:00
github-actions[bot] 9340c296ee [CI Skip] bump/beta 6.2.3-0-x
skip-checks: true
2022-07-04 06:40:44 +00:00
Jaco 132ed20d18 Bump common (#385) 2022-07-04 09:33:42 +03:00
44 changed files with 1006 additions and 910 deletions
-1
View File
@@ -1 +0,0 @@
6.2.2
-14
View File
@@ -1,14 +0,0 @@
7
3.2.2
3.2.3
3.2.4
4.0.2
4.1.2
6.1.2
6.1.3
6.1.4
6.1.5
6.2.2
+1 -1
View File
@@ -8,7 +8,7 @@ module.exports = {
ignorePatterns: [
...base.ignorePatterns,
'**/target/*',
'**/build-wasm/*'
'**/test/*.ts'
],
parserOptions: {
...base.parserOptions,
+49 -13
View File
@@ -1,50 +1,86 @@
<!--
For general support, howto, coding and bundling questions, please use the Substrate & Polkadot StackExchange at https://substrate.stackexchange.com/ and get other ecosystem developers involved. This issues in this repository are meant for the tracking of feature requests and bug reports.
For general support, howto, coding and bundling questions, please
use the Substrate & Polkadot StackExchange at
While all issues are looked at non-bug and non-features would take quite a bit longer to get to and may yield less than satisfactory responses in this format.
https://substrate.stackexchange.com/
Additionally, please ensure you have done a search on the existing and closed issues before logging a new request. This saves time on all sides.
and get other ecosystem developers involved. This issues in this
repository are meant for the tracking of feature requests and bug
reports.
While all issues are looked at non-bug and non-features would take
quite a bit longer to get to and may yield less than satisfactory
responses in this format.
Additionally, please ensure you have done a search on the existing
and closed issues before logging a new request. This saves time on
all sides.
-->
* **I'm submitting a ...**
<!--- Try and classify your actual report -->
<!---
REQUIRED:
Classify the type of report your are submitting
-->
- [ ] Bug report
- [ ] Feature request
- [ ] Support request (please bear the comments above in mind)
- [ ] Support request
- [ ] Other
* **What is the current behavior and expected behavior?**
<!--- If you're describing a bug, tell us what should happen -->
<!--- If you're suggesting a change/improvement, tell us how it should work -->
<!---
REQUIRED:
If you're describing a bug, tell us what should happen. If you're
suggesting a change/improvement, tell us how it should work.
-->
* **What is the motivation for changing the behavior?**
<!--- Not obligatory, but suggest a motivation for the request -->
<!--- or ideas how to implement the addition or change -->
<!---
OPTIONAL:
Suggest a motivation for the request or ideas how to implement the
addition or change
-->
* **Please tell us about your environment:**
<!--- Include as many relevant details about the environment you experienced the issue in -->
<!--- Also snsure that you have tested against the latest stable releases if a bug -->
<!---
REQUIRED:
Include as many relevant details about the environment in which you
experienced the issue. Also ensure that you have tested against the
latest stable releases if you believe this to be a bug
-->
- Version:
- Environment:
- [ ] Node.js
- [ ] Browser
- [ ] Other (limited support for other environments available)
- [ ] Other (limited support for other environments)
- Language:
- [ ] JavaScript
- [ ] TypeScript
- [ ] TypeScript (include tsc --version)
- [ ] Other
+9 -2
View File
@@ -5,15 +5,22 @@ jobs:
pr:
strategy:
matrix:
step: ['lint', 'test', 'build']
step: ['lint', 'test', 'build', 'deno']
name: ${{ matrix.step }}
runs-on: ubuntu-latest
env:
YARN_ENABLE_SCRIPTS: false
steps:
- uses: actions/checkout@v2
- uses: denoland/setup-deno@v1
with:
deno-version: vx.x.x
- name: ${{ matrix.step }}
if: always()
run: |
yarn install --immutable | grep -v 'YN0013'
./scripts/install-build-deps.sh
if [ "${{ matrix.step }}" != "lint" ]; then
./scripts/install-build-deps.sh
fi
yarn polkadot-dev-deno-map
yarn ${{ matrix.step }}
+3 -6
View File
@@ -1,19 +1,16 @@
binaryen/
bindgen/
build/
build-cjs/
build-esm/
build-deno/
build-docs/
build-wasm/
build-*/
bytes/
coverage/
docs/.vuepress/dist/
node_modules/
pkg/
target/
tmp/
wabt/
/import_map.json
/mod.ts
.DS_Store
.env.local
.env.development.local
+18
View File
@@ -1,5 +1,23 @@
# CHANGELOG
## 6.3.1 Jul 21, 2022
Changes:
- Optimize packed WASM base64 decoding loop
- Adjust test environment (no duplication)
- Adjust CI check steps, align with other org repos
- Remove unneeded `import_map.in.json` for Deno tests
## 6.2.3 Jul 7, 2022
Changes:
- Optimize WASM init with pre-allocated buffers
- Additional platform-specific tests
## 6.2.2 Jul 4, 2022
Changes:
+1 -1
View File
@@ -1,4 +1,4 @@
450 Jaco 6.2.2 (#384)
469 Jaco 6.3.1 (#405)
1 Evgeny Fixed type (#121)
1 Shunfan Zhou Support sr25519 agreement (#209)
1 Steve Degosserie Expose Schnorrkel's VRF capabilities (#170)
+12 -3
View File
@@ -10,7 +10,12 @@
"url": "https://github.com/polkadot-js/wasm.git"
},
"sideEffects": false,
"version": "6.2.2",
"type": "module",
"version": "6.3.1",
"versions": {
"git": "6.3.1",
"npm": "6.3.1"
},
"workspaces": [
"packages/*"
],
@@ -22,17 +27,21 @@
"build:rollup": "polkadot-exec-rollup --config",
"build:wasm": "./scripts/build.sh",
"clean": "./scripts/clean.sh",
"deno": "yarn deno:build && yarn deno:check",
"deno:build": "WITH_DENO=1 yarn build",
"deno:check": "deno check --import-map=import_map.json mod.ts",
"lint": "polkadot-dev-run-lint",
"postinstall": "polkadot-dev-yarn-only",
"test": "yarn test:wasm-crypto:rust",
"test:wasm-crypto:deno": "deno test --allow-read --import-map=import_map.json packages/wasm-crypto/test/deno.ts",
"test:wasm-crypto:js": "yarn test:wasm-crypto:js:jest && yarn test:wasm-crypto:js:node",
"test:wasm-crypto:js:jest": "polkadot-dev-run-test ./test/jest.spec.js",
"test:wasm-crypto:js:node": "cd packages/wasm-crypto && node ./test/wasm.cjs && node ./test/asm.cjs",
"test:wasm-crypto:rust": "cd packages/wasm-crypto && RUST_BACKTRACE=full cargo test --release -- --test-threads=1 --nocapture"
},
"devDependencies": {
"@babel/core": "^7.18.6",
"@polkadot/dev": "^0.67.50",
"@babel/core": "^7.18.9",
"@polkadot/dev": "^0.67.84",
"fflate": "^0.7.3",
"override-require": "^1.1.1"
},
+4 -4
View File
@@ -20,14 +20,14 @@
"./detectPackage.cjs"
],
"type": "module",
"version": "6.2.2",
"version": "6.3.1",
"main": "index.js",
"dependencies": {
"@babel/runtime": "^7.18.6"
"@babel/runtime": "^7.18.9"
},
"devDependencies": {
"@polkadot/util": "^9.7.1",
"@polkadot/x-randomvalues": "^9.7.1"
"@polkadot/util": "^10.0.2",
"@polkadot/x-randomvalues": "^10.0.2"
},
"peerDependencies": {
"@polkadot/util": "*",
+1 -1
View File
@@ -3,4 +3,4 @@
// Do not edit, auto-generated by @polkadot/dev
export const packageInfo = { name: '@polkadot/wasm-bridge', path: 'auto', type: 'auto', version: '6.2.2' };
export const packageInfo = { name: '@polkadot/wasm-bridge', path: 'auto', type: 'auto', version: '6.3.1' };
+3 -3
View File
@@ -17,13 +17,13 @@
},
"sideEffects": false,
"type": "module",
"version": "6.2.2",
"version": "6.3.1",
"main": "index.js",
"dependencies": {
"@babel/runtime": "^7.18.6"
"@babel/runtime": "^7.18.9"
},
"devDependencies": {
"@polkadot/util": "^9.7.1"
"@polkadot/util": "^10.0.2"
},
"peerDependencies": {
"@polkadot/util": "*"
@@ -3,4 +3,4 @@
// Do not edit, auto-generated by @polkadot/dev
export const packageInfo = { name: '@polkadot/wasm-crypto-asmjs', path: 'auto', type: 'auto', version: '6.2.2' };
export const packageInfo = { name: '@polkadot/wasm-crypto-asmjs', path: 'auto', type: 'auto', version: '6.3.1' };
+7 -7
View File
@@ -20,19 +20,19 @@
"./detectPackage.cjs"
],
"type": "module",
"version": "6.2.2",
"version": "6.3.1",
"browser": "wasm.js",
"main": "wasm.js",
"react-native": "asm.js",
"dependencies": {
"@babel/runtime": "^7.18.6",
"@polkadot/wasm-bridge": "6.2.2",
"@polkadot/wasm-crypto-asmjs": "6.2.2",
"@polkadot/wasm-crypto-wasm": "6.2.2"
"@babel/runtime": "^7.18.9",
"@polkadot/wasm-bridge": "6.3.1",
"@polkadot/wasm-crypto-asmjs": "6.3.1",
"@polkadot/wasm-crypto-wasm": "6.3.1"
},
"devDependencies": {
"@polkadot/util": "^9.7.1",
"@polkadot/x-randomvalues": "^9.7.1"
"@polkadot/util": "^10.0.2",
"@polkadot/x-randomvalues": "^10.0.2"
},
"peerDependencies": {
"@polkadot/util": "*",
+1 -1
View File
@@ -3,4 +3,4 @@
// Do not edit, auto-generated by @polkadot/dev
export const packageInfo = { name: '@polkadot/wasm-crypto-init', path: 'auto', type: 'auto', version: '6.2.2' };
export const packageInfo = { name: '@polkadot/wasm-crypto-init', path: 'auto', type: 'auto', version: '6.3.1' };
+4 -4
View File
@@ -17,14 +17,14 @@
},
"sideEffects": false,
"type": "module",
"version": "6.2.2",
"version": "6.3.1",
"main": "index.js",
"dependencies": {
"@babel/runtime": "^7.18.6",
"@polkadot/wasm-util": "6.2.2"
"@babel/runtime": "^7.18.9",
"@polkadot/wasm-util": "6.3.1"
},
"devDependencies": {
"@polkadot/util": "^9.7.1"
"@polkadot/util": "^10.0.2"
},
"peerDependencies": {
"@polkadot/util": "*"
+2 -2
View File
@@ -3,7 +3,7 @@
import { base64Decode, unzlibSync } from '@polkadot/wasm-util';
import { bytes, sizeUncompressed } from './cjs/bytes.js';
import { bytes, lenIn, lenOut } from './cjs/bytes.js';
export { packageInfo } from './packageInfo';
@@ -16,4 +16,4 @@ export { packageInfo } from './packageInfo';
* Upon loading the exposed bytes will be decoded and decompressed form this
* specific format and returned.
*/
export const wasmBytes = unzlibSync(base64Decode(bytes), new Uint8Array(sizeUncompressed));
export const wasmBytes = unzlibSync(base64Decode(bytes, new Uint8Array(lenIn)), new Uint8Array(lenOut));
+2 -2
View File
@@ -3,6 +3,6 @@
export declare const bytes: string;
export declare const sizeCompressed: number;
export declare const lenIn: number;
export declare const sizeUncompressed: number;
export declare const lenOut: number;
+2 -2
View File
@@ -3,6 +3,6 @@
module.exports.bytes = '';
module.exports.sizeCompressed = 0;
module.exports.lenIn = 0;
module.exports.sizeUncompressed = 0;
module.exports.lenOut = 0;
+2 -2
View File
@@ -3,6 +3,6 @@
export declare const bytes: string;
export declare const sizeCompressed: number;
export declare const lenIn: number;
export declare const sizeUncompressed: number;
export declare const lenOut: number;
+2 -2
View File
@@ -3,6 +3,6 @@
export const bytes = '';
export const sizeCompressed = 0;
export const lenIn = 0;
export const sizeUncompressed = 0;
export const lenOut = 0;
+1 -1
View File
@@ -3,4 +3,4 @@
// Do not edit, auto-generated by @polkadot/dev
export const packageInfo = { name: '@polkadot/wasm-crypto-wasm', path: 'auto', type: 'auto', version: '6.2.2' };
export const packageInfo = { name: '@polkadot/wasm-crypto-wasm', path: 'auto', type: 'auto', version: '6.3.1' };
+9 -9
View File
@@ -28,19 +28,19 @@
"./initWasmAsm.cjs"
],
"type": "module",
"version": "6.2.2",
"version": "6.3.1",
"main": "index.js",
"dependencies": {
"@babel/runtime": "^7.18.6",
"@polkadot/wasm-bridge": "6.2.2",
"@polkadot/wasm-crypto-asmjs": "6.2.2",
"@polkadot/wasm-crypto-init": "6.2.2",
"@polkadot/wasm-crypto-wasm": "6.2.2",
"@polkadot/wasm-util": "6.2.2"
"@babel/runtime": "^7.18.9",
"@polkadot/wasm-bridge": "6.3.1",
"@polkadot/wasm-crypto-asmjs": "6.3.1",
"@polkadot/wasm-crypto-init": "6.3.1",
"@polkadot/wasm-crypto-wasm": "6.3.1",
"@polkadot/wasm-util": "6.3.1"
},
"devDependencies": {
"@polkadot/util": "^9.7.1",
"@polkadot/x-randomvalues": "^9.7.1"
"@polkadot/util": "^10.0.2",
"@polkadot/x-randomvalues": "^10.0.2"
},
"peerDependencies": {
"@polkadot/util": "*",
+1 -1
View File
@@ -3,4 +3,4 @@
// Do not edit, auto-generated by @polkadot/dev
export const packageInfo = { name: '@polkadot/wasm-crypto', path: 'auto', type: 'auto', version: '6.2.2' };
export const packageInfo = { name: '@polkadot/wasm-crypto', path: 'auto', type: 'auto', version: '6.3.1' };
@@ -3,13 +3,12 @@
const { assert } = require('@polkadot/util');
const wasm = require('../../build');
const bip39 = require('./bip39.cjs');
const ed25519 = require('./ed25519.cjs');
const hashing = require('./hashing.cjs');
const secp256k1 = require('./secp256k1.cjs');
const sr25519 = require('./sr25519.cjs');
const vrf = require('./vrf.cjs');
const bip39 = require('./bip39.js');
const ed25519 = require('./ed25519.js');
const hashing = require('./hashing.js');
const secp256k1 = require('./secp256k1.js');
const sr25519 = require('./sr25519.js');
const vrf = require('./vrf.js');
const tests = {
// We place secp256k1 first, this allows the interaction with it in the
@@ -23,51 +22,53 @@ const tests = {
...hashing
};
async function beforeAll (name) {
async function beforeAll (name, wasm) {
const result = await wasm.waitReady();
console.log(`*** waitReady()=${result} for ${wasm.bridge.type}`);
assert(name.toLowerCase() === wasm.bridge.type, `Incorrect environment laucnhed, expected ${name.toLowerCase()}, found ${wasm.bridge.type}`);
assert(name.toLowerCase() === wasm.bridge.type, `Incorrect environment launched, expected ${name.toLowerCase()}, found ${wasm.bridge.type}`);
return result;
}
function runAll (name) {
function runAll (name, wasm) {
const failed = [];
let count = 0;
Object.keys(tests).forEach((name) => {
const timerId = `\t${name}`;
Object
.entries(tests)
.forEach(([name, test]) => {
const timerId = `\t${name}`;
count++;
count++;
try {
console.time(timerId);
console.log();
console.log(timerId);
try {
console.time(timerId);
console.log();
console.log(timerId);
tests[name](wasm);
test(wasm);
console.timeEnd(timerId);
} catch (error) {
console.error();
console.error(error);
console.timeEnd(timerId);
} catch (error) {
console.error();
console.error(error);
failed.push(name);
}
});
failed.push(name);
}
});
if (failed.length) {
throw new Error(`\n*** ${name}: FAILED: ${failed.length} of ${count}: ${failed.join(', ')}`);
}
}
function runUnassisted (name) {
function runUnassisted (name, wasm) {
console.log(`\n*** ${name}: Running tests`);
beforeAll(name)
.then(() => runAll(name))
beforeAll(name, wasm)
.then(() => runAll(name, wasm))
.then(() => {
console.log(`\n*** ${name}: All passed`);
process.exit(0);
@@ -82,6 +83,5 @@ module.exports = {
beforeAll,
runAll,
runUnassisted,
tests,
wasm
tests
};
@@ -0,0 +1 @@
{ "type": "commonjs" }
+3 -2
View File
@@ -4,6 +4,7 @@
require('./alias-imports.cjs');
require('@polkadot/wasm-crypto/initOnlyAsm');
const { runUnassisted } = require('./all/index.cjs');
const wasm = require('../build');
const { runUnassisted } = require('./all/index.js');
runUnassisted('ASM');
runUnassisted('ASM', wasm);
+20
View File
@@ -0,0 +1,20 @@
// Copyright 2019-2022 @polkadot/wasm-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { createRequire } from 'https://deno.land/std@0.107.0/node/module.ts';
import * as wasm from '../build-deno/mod.ts';
declare const globalThis: Record<string, unknown>;
// ensure we set require on globalThis, it is used is all/*.js
const require = globalThis.require = createRequire(import.meta.url);
const { beforeAll, tests } = require('./all/index.js');
await beforeAll('wasm', wasm);
Object
.entries<(wasm: unknown) => void>(tests)
.forEach(([name, test]) => {
Deno.test(name, () => test(wasm));
});
+3 -2
View File
@@ -5,11 +5,12 @@
* @jest-environment jsdom
*/
import { beforeAll as beforeAllFn, tests, wasm } from './all/index.cjs';
import * as wasm from '../build';
import { beforeAll as beforeAllFn, tests } from './all/index.js';
describe('wasm-crypto', () => {
beforeAll(async () => {
await beforeAllFn('wasm');
await beforeAllFn('wasm', wasm);
});
Object.keys(tests).forEach((name) => {
+3 -2
View File
@@ -3,6 +3,7 @@
require('./alias-imports.cjs');
const { runUnassisted } = require('./all/index.cjs');
const wasm = require('../build');
const { runUnassisted } = require('./all/index.js');
runUnassisted('WASM');
runUnassisted('WASM', wasm);
+3
View File
@@ -5,6 +5,9 @@
"outDir": "./build",
"rootDir": "./src"
},
"exclude": [
"**/test/*.ts"
],
"references": [
{ "path": "../wasm-bridge/tsconfig.build.json" },
{ "path": "../wasm-crypto-init/tsconfig.build.json" },
+3 -3
View File
@@ -20,13 +20,13 @@
"./detectPackage.cjs"
],
"type": "module",
"version": "6.2.2",
"version": "6.3.1",
"main": "index.js",
"dependencies": {
"@babel/runtime": "^7.18.6"
"@babel/runtime": "^7.18.9"
},
"devDependencies": {
"@polkadot/util": "^9.7.1"
"@polkadot/util": "^10.0.2"
},
"peerDependencies": {
"@polkadot/util": "*"
+25 -12
View File
@@ -1,31 +1,44 @@
// Copyright 2019-2022 @polkadot/wasm-util authors & contributors
// SPDX-License-Identifier: Apache-2.0
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
// Use an array for our indexer - this is faster than using map access. In
// this case we assume ASCII-only inputs, so we cannot overflow the array
const chr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
const map = new Array<number>(256);
// We use charCodeAt for access here and in the decoder loop - this is faster
// on lookups (array + numbers) and also faster than accessing the specific
// character via data[i]
for (let i = 0; i < chr.length; i++) {
map[chr.charCodeAt(i)] = i;
}
/**
* @name base64Decode
* @description
* A fail-safe base64Decoding function that operates in all environments. Unlike
* decoding from Buffer (Node.js only) or atob (browser-only) this implementation
* is slightly slower, but it is platform independent.
* A base64Decoding function that operates in all environments. Unlike decoding
* from Buffer (Node.js only) or atob (browser-only) this implementation is
* slightly slower, but it is platform independent.
*
* For our usage, since we have access to the static final size (where used), we
* decode to a specified output buffer. This also means we have applied a number
* of optimizations based on this - checking output position instead of chars.
*/
export function base64Decode (data: string): Uint8Array {
// TODO: For Node.js speedups, we could add an explicit base64Node.ts implementation
// that would be (via export maps) be available in that environment only
const bytes = [];
export function base64Decode (data: string, out: Uint8Array): Uint8Array {
const len = out.length;
let byte = 0;
let bits = 0;
let pos = -1;
for (let i = 0; i < data.length && data[i] !== '='; i++) {
for (let i = 0; pos < len; i++) {
// each character represents 6 bits
byte = (byte << 6) | chars.indexOf(data[i]);
byte = (byte << 6) | map[data.charCodeAt(i)];
// each byte needs to contain 8 bits
if ((bits += 6) >= 8) {
bytes.push((byte >>> (bits -= 8)) & 0xff);
out[++pos] = (byte >>> (bits -= 8)) & 0xff;
}
}
return Uint8Array.from(bytes);
return out;
}
+1 -1
View File
@@ -3,4 +3,4 @@
// Do not edit, auto-generated by @polkadot/dev
export const packageInfo = { name: '@polkadot/wasm-util', path: 'auto', type: 'auto', version: '6.2.2' };
export const packageInfo = { name: '@polkadot/wasm-util', path: 'auto', type: 'auto', version: '6.3.1' };
+17 -11
View File
@@ -13,18 +13,24 @@ cd packages
PKG_NAME=wasm-crypto ../scripts/build-wasm.sh
yarn test:wasm-crypto:js
if [ -z "$WITH_DENO" ]; then
yarn test:wasm-crypto:js
else
yarn test:wasm-crypto:deno
fi
echo ""
echo "*** wasm-crypto"
ls -alR wasm-crypto/build
echo ""
echo "*** wasm-crypto-asmjs"
ls -alR wasm-crypto-asmjs/build
echo ""
echo "*** wasm-crypto-wasm"
ls -alR wasm-crypto-wasm/build
# echo ""
# echo "*** wasm-crypto"
# ls -alR wasm-crypto/build
# echo ""
# echo "*** wasm-crypto-asmjs"
# ls -alR wasm-crypto-asmjs/build
# echo ""
# echo "*** wasm-crypto-wasm"
# ls -alR wasm-crypto-wasm/build
cd ..
yarn build:rollup
if [ -z "$WITH_DENO" ]; then
yarn build:rollup
fi
+2 -2
View File
@@ -48,12 +48,12 @@ if [ ! -d "binaryen" ]; then
echo "*** Downloading binaryen"
curl -L $BINARYEN_REPO/releases/download/$BINARYEN_VER/$BINARYEN_ZIP.tar.gz | tar xz
mv binaryen-$BINARYEN_VER binaryen
ls -alR binaryen
# ls -alR binaryen
fi
if [ ! -d "bindgen" ]; then
echo "*** Downloading bindgen"
curl -L $BINDGEN_REPO/releases/download/$BINDGEN_VER/$BINDGEN_ZIP.tar.gz | tar xz
mv $BINDGEN_ZIP bindgen
ls -alR bindgen
# ls -alR bindgen
fi
+16 -20
View File
@@ -6,34 +6,30 @@ const fs = require('fs');
const mkdirp = require('mkdirp');
const { formatNumber } = require('@polkadot/util');
const DIR_DENO = `./${process.env.PKG_NAME}-wasm/build-deno/deno`;
const DIR_CJS = `./${process.env.PKG_NAME}-wasm/build/cjs`;
const HDR = `// Copyright 2019-${new Date().getFullYear()} @polkadot/${process.env.PKG_NAME}-wasm authors & contributors\n// SPDX-License-Identifier: Apache-2.0\n\n// Generated as part of the build, do not edit\n`;
const data = fs.readFileSync(`./${process.env.PKG_NAME}/build-wasm/wasm_opt.wasm`);
const compressed = Buffer.from(fflate.zlibSync(data, { level: 9 }));
const denoDir = `./${process.env.PKG_NAME}-wasm/build-deno/deno`;
const base64 = compressed.toString('base64');
console.log(`*** Compressed WASM: ${formatNumber(data.length)} -> ${formatNumber(compressed.length)} (${(100 * compressed.length / data.length).toFixed(2)}%)`);
console.log(`*** Compressed WASM: in=${formatNumber(data.length)}, out=${formatNumber(compressed.length)}, opt=${(100 * compressed.length / data.length).toFixed(2)}%, base64=${formatNumber(base64.length)}`);
mkdirp.sync(denoDir);
mkdirp.sync(DIR_DENO);
fs.writeFileSync(`./${process.env.PKG_NAME}-wasm/build/cjs/bytes.js`, `// Copyright 2019-${new Date().getFullYear()} @polkadot/${process.env.PKG_NAME}-wasm authors & contributors
// SPDX-License-Identifier: Apache-2.0
fs.writeFileSync(`${DIR_CJS}/bytes.js`, `${HDR}
const lenIn = ${compressed.length};
const lenOut = ${data.length};
const bytes = '${base64}';
// Generated as part of the build, do not edit
const sizeCompressed = ${compressed.length};
const sizeUncompressed = ${data.length};
const bytes = '${compressed.toString('base64')}';
module.exports = { bytes, sizeCompressed, sizeUncompressed };
module.exports = { bytes, lenIn, lenOut };
`);
fs.writeFileSync(`${denoDir}/bytes.js`, `// Copyright 2019-${new Date().getFullYear()} @polkadot/${process.env.PKG_NAME}-wasm authors & contributors
// SPDX-License-Identifier: Apache-2.0
fs.writeFileSync(`${DIR_DENO}/bytes.js`, `${HDR}
export const lenIn = ${compressed.length};
// Generated as part of the build, do not edit
export const lenOut = ${data.length};
export const sizeCompressed = ${compressed.length};
export const sizeUncompressed = ${data.length};
export const bytes = '${compressed.toString('base64')}';
export const bytes = '${base64}';
`);
+744 -742
View File
File diff suppressed because it is too large Load Diff