import { BlockchainCode } from "@emeraldwallet/core" ; import { SeedReference , Uuid } from "@emeraldpay/emerald-vault-core" ; export enum KeySourceType { SEED_SELECTED , SEED_GENERATE , SEED_IMPORT , PK_ANY , PK_WEB3_JSON , PK_RAW , LEDGER } export interface SeedSelected { type : KeySourceType . SEED_SELECTED ; id : string ; } export interface SeedCreate { type : KeySourceType . SEED_GENERATE | KeySourceType . SEED_IMPORT ; mnemonic ? : string ; password ? : string ; } export interface PkImportAny { type : KeySourceType . PK_ANY ; } export interface PkImportRaw { type : KeySourceType . PK_RAW ; pk : string ; password : string ; } export interface PkImportJson { type : KeySourceType . PK_WEB3_JSON ; json : string ; } export interface LedgerSeed { type : KeySourceType . LEDGER ; id ? : Uuid ; } export type KeysSource = SeedSelected | SeedCreate | PkImportJson | PkImportRaw | PkImportAny | 'empty' | 'start-ledger' | LedgerSeed ; export function isSeedSelected ( obj ) { return typeof obj == 'object' && obj . type == KeySourceType . SEED_SELECTED ; } export function isSeedCreate ( obj ) { return typeof obj == 'object' && ( obj . type == KeySourceType . SEED_GENERATE || obj . type == KeySourceType . SEED_IMPORT ) ; } export function isPk ( obj ) { return typeof obj == 'object' && ( obj . type == KeySourceType . PK_WEB3_JSON || obj . type == KeySourceType . PK_RAW || obj . type == KeySourceType . PK_ANY ) ; } export function isLedger ( obj ) { return typeof obj == "object" && obj . type == KeySourceType . LEDGER ; } export function isLedgerStart ( obj ) { return typeof obj == "string" && obj == "start-ledger" ; } export function isPkJson ( obj ) { return isPk ( obj ) && obj . type == KeySourceType . PK_WEB3_JSON ; } export function isPkRaw ( obj ) { return isPk ( obj ) && obj . type == KeySourceType . PK_RAW ; } export interface TWalletOptions { label ? : string ; } export interface Result { type : KeysSource ; options : TWalletOptions ; blockchains : BlockchainCode [ ] ; seedAccount ? : number ; seed ? : SeedReference ; addresses ? : Partial < Record < BlockchainCode , string > > ; } export function defaultResult ( ) { return { type : 'empty' , options : { } , blockchains : [ ] , addresses : { } , } ; } export interface StepDescription { title : string ; code : string ; } export interface StepDetails { index : number ; code : string ; }