UNPKG

zkverifyjs

Version:

Submit proofs to zkVerify and query proof state with ease using our npm package.

24 lines 826 B
import { Keyring } from '@polkadot/api'; import { CHAIN_SS58_PREFIX } from "../../config/index.js"; /** * Sets up the account using the provided secret seed phrase. * * @param {string} secretSeedPhrase - The secret seed phrase used to create the account. * @returns {KeyringPair} The initialized account. * @throws Will throw an error if the seed phrase is invalid. */ export const setupAccount = secretSeedPhrase => { try { const keyring = new Keyring({ type: 'sr25519' }); keyring.setSS58Format(CHAIN_SS58_PREFIX); return keyring.addFromUri(secretSeedPhrase); } catch (error) { if (error instanceof Error) { throw new Error(`Invalid seed phrase provided: ${error.message}`); } else { throw new Error('An unknown error occurred while setting up the account.'); } } };