A collection of useful crypto utilities for Polkadot ecosystem projects
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Core initialization functions to prepare the WebAssembly crypto backend before using cryptographic operations.
Waits for the crypto WebAssembly backend to initialize and returns a promise indicating success or failure.
/**
* Wait for the crypto WebAssembly backend to initialize
* @returns Promise that resolves to true on success, false on failure
*/
function cryptoWaitReady(): Promise<boolean>;Usage Example:
import { cryptoWaitReady } from "@polkadot/util-crypto";
// Wait for crypto to be ready before performing operations
const isReady = await cryptoWaitReady();
if (isReady) {
// Safe to use crypto functions
console.log("Crypto backend is ready");
} else {
console.error("Failed to initialize crypto backend");
}Synchronously checks if the crypto WebAssembly backend is ready for use.
/**
* Check if the crypto WebAssembly backend is ready
* @returns true if ready, false otherwise
*/
function cryptoIsReady(): boolean;Usage Example:
import { cryptoIsReady, cryptoWaitReady } from "@polkadot/util-crypto";
// Check if already ready
if (cryptoIsReady()) {
// Use crypto functions immediately
} else {
// Need to wait
await cryptoWaitReady();
}cryptoWaitReady() before using any cryptographic functionsInstall with Tessl CLI
npx tessl i tessl/npm-polkadot--util-crypto