-
Notifications
You must be signed in to change notification settings - Fork 19
/
UncleDetailsAdapter.ts
26 lines (22 loc) · 1 KB
/
UncleDetailsAdapter.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { IDataAdapter } from "plugin-api/IDataAdapter";
import { IUncleDetails } from "app/shared/data/uncle/IUncleDetails";
import { NotFoundError } from "app/shared/data/NotFoundError";
import { AlethioDataSource } from "app/eth-extended/AlethioDataSource";
import { IUncleByHashContext } from "app/eth-extended/context/IUncleByHashContext";
import { uncleByHashContextType } from "app/shared/context/uncleByHashContextType";
import { MementoDataSource } from "app/eth-memento/MementoDataSource";
export class UncleDetailsAdapter implements IDataAdapter<IUncleByHashContext, IUncleDetails> {
contextType = uncleByHashContextType;
constructor(private dataSource: AlethioDataSource | MementoDataSource) {
}
async load(context: IUncleByHashContext) {
try {
return await this.dataSource.stores.uncleDetailsStore.fetch(context.uncleHash);
} catch (e) {
if (e instanceof NotFoundError) {
return void 0;
}
throw e;
}
}
}