import { executeCommand } from './execute/execute' ; import Transport from '../transport' ; import { commands } from "./execute/command" ; import { target } from '../config/param' ; import { CODE } from '../config/status/code' ; import { SDKError , APDUError } from '../error/errorHandle' ; param { Transport } transport param { string } signedCommand return { Promise < { status : boolean , statusCode : string , msg : string } > } export const backupSeed = async ( transport , signature ) : Promise < boolean > => { const { statusCode , msg } = await executeCommand ( transport , commands . BACKUP_REGISTER_DATA , target . SE , signature , undefined , undefined ) ; if ( statusCode === CODE . _9000 ) { return true ; } else { throw new APDUError ( commands . BACKUP_REGISTER_DATA , statusCode , msg ) ; } } ; param { Transport } transport return { Promise < { status : boolean , statusCode : string , msg : string } > } export const recoverSeed = async ( transport ) : Promise < boolean > => { const { statusCode , msg } = await executeCommand ( transport , commands . RECOVER_REGISER_DATA , target . SE ) ; if ( statusCode === CODE . _9000 ) { return true ; } else { throw new APDUError ( commands . RECOVER_REGISER_DATA , statusCode , msg ) ; } } ; param { Transport } transport return { boolean } export const checkBackupStatus = async ( transport ) : Promise < boolean > => { const { statusCode , msg , outputData } = await executeCommand ( transport , commands . CHECK_BACKUP_RECOVER , target . SE ) ; if ( statusCode === CODE . _9000 ) { return outputData === '01' ? true : false ; } else { throw new APDUError ( commands . CHECK_BACKUP_RECOVER , statusCode , msg ) ; } } ; param { Transport } transport param { string } signedCommand return { Promise < { status : boolean , statusCode : string , msg : string } > } export const deleteSeedBackup = async ( transport , signature ) => { const { statusCode , msg } = await executeCommand ( transport , commands . DELETE_REGISTER_BACKUP , target . SE , signature , undefined , undefined ) ; if ( statusCode === CODE . _9000 ) { return true ; } else { throw new APDUError ( commands . DELETE_REGISTER_BACKUP , statusCode , msg ) ; } } ;