import { JsonObjectStore } from '@dequanto/json/JsonObjectStore'; import { TTxWriterJson } from '../TxWriter'; import { GasWatcherTx, IGasWatcherCondition } from './GasWatcherTx'; export interface IGasWatcherStore { savePrice (enty: {date: Date, price: bigint}): Promise loadPrices (from: Date, toDate): Promise<{ date: Date, price: bigint }[]> saveTxs (pending: ReturnType[]): Promise loadTxs (): Promise[]> } type GasWatcherTxJson = { condition: IGasWatcherCondition writer: TTxWriterJson } export class GasWatcherStore implements IGasWatcherStore { protected jsonStore: JsonObjectStore constructor (public name = '') { this.jsonStore = new JsonObjectStore({ path: `./db/gaswatcher/txs${this.name}.json`, format: true, }) } async savePrice(enty: { date: Date; price: bigint; }): Promise { } async loadPrices(from: Date, toDate: any): Promise<{ date: Date; price: bigint; }[]> { return []; } async saveTxs(txs: GasWatcherTxJson[]): Promise { return this.jsonStore.save(txs); } async loadTxs(): Promise { return this.jsonStore.get(); } }