UNPKG

@shapeshiftoss/fiosdk

Version:

The Foundation for Interwallet Operability (FIO) is a consortium of leading blockchain wallets, exchanges and payments providers that seeks to accelerate blockchain adoption by reducing the risk, complexity, and inconvenience of sending and receiving cryp

34 lines (26 loc) 843 B
import { PrivateKey } from '@shapeshiftoss/fiojs' import { Transactions } from '../Transactions' export abstract class Query<T> extends Transactions { abstract ENDPOINT: string abstract getData(): Promise<any> async decrypt(result: any): Promise<any> { } isEncrypted = false async execute(publicKey: string, privateKey: PrivateKey = ''): Promise<any> { this.publicKey = publicKey this.privateKey = privateKey if (!this.isEncrypted) { return this.executeCall(this.getEndPoint(), JSON.stringify(await this.getData())) } else { try { const result = await this.executeCall(this.getEndPoint(), JSON.stringify(await this.getData())) return await this.decrypt(result) } catch (error) { throw error } } } getEndPoint(): string { return this.ENDPOINT } }