// Copyright 2017-2020 @polkadot/example-vue authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. import { Prefix } from '@polkadot/util-crypto/address/types'; import Vue, { VNode } from 'vue'; import keyring from '@polkadot/ui-keyring'; import settings from '@polkadot/ui-settings'; import { mnemonicGenerate, cryptoWaitReady } from '@polkadot/util-crypto'; import Identicon from '@polkadot/vue-identicon'; interface Account { address: string; phrase: string; } interface Data extends Account { ss58Format: Prefix; ss58Options: { text: string; value: string | number }[]; } const ss58Options = settings.availablePrefixes.filter((_, index): boolean => index !== 0); function generateAccount (ss58Format: Prefix = 42): Account { const phrase = mnemonicGenerate(12); const { address } = keyring.createFromUri(phrase); return { address: keyring.encodeAddress(address, ss58Format), phrase }; } const Example = Vue.extend({ template: `