Use x-global inside x-randomvalues (#1354)
* Use x-global inside x-randomvalues * CHANGELOG
This commit is contained in:
@@ -2,10 +2,11 @@
|
||||
|
||||
Changes:
|
||||
|
||||
- Fix `util-crypto` bundle generation (adjust `x-randomvalues`)
|
||||
- Update `@noble/hashes` to 0.5.7 (0.5.6 version is broken for rollup)
|
||||
- Ensure package path is availble under ESM & CJS
|
||||
- Add all known Rococo genesis hashes
|
||||
- Upgrade 3rd party dependencies, including `bn.js` to latest
|
||||
- Ensure package path is availble under ESM & CJS
|
||||
|
||||
|
||||
## 8.2.2 Dec 19, 2021
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
// Copyright 2017-2022 @polkadot/x-randomvalues authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { xglobal } from '@polkadot/x-global';
|
||||
|
||||
export { packageInfo } from './packageInfo';
|
||||
|
||||
export function getRandomValues <T extends Uint8Array> (arr: T): T {
|
||||
return crypto.getRandomValues(arr);
|
||||
// We use x-global here - this prevents packagers such as rollup
|
||||
// confusing this with the "normal" Node.js import and stubbing it
|
||||
// (and also aligns with eg. x-fetch, where x-global is used)
|
||||
return xglobal.crypto.getRandomValues(arr);
|
||||
}
|
||||
|
||||
@@ -55,11 +55,15 @@
|
||||
log('polkadotKeyring');
|
||||
|
||||
const { Keyring } = polkadotKeyring;
|
||||
const { cryptoWaitReady } = polkadotUtilCrypto;
|
||||
|
||||
const keyring = new Keyring({ type: sr25519 });
|
||||
const alice = keyring.addFromUri('//Alice');
|
||||
cryptoWaitReady().then(() => {
|
||||
const keyring = new Keyring({ type: 'sr25519' });
|
||||
const alice = keyring.addFromUri('//Alice');
|
||||
|
||||
log('alice.address', alice.address);
|
||||
log('alice.address', alice.address);
|
||||
log('signature', u8aToHex(alice.sign('hello world')));
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user