Resolve "BCMR Adapter: Create BaseBCMR and HTTP implementation"
This commit is contained in:
committed by
Emergent Reasons
parent
6d0a36248d
commit
e4020a996c
@@ -0,0 +1,25 @@
|
||||
import { BaseBCMR } from './base-bcmr.js';
|
||||
|
||||
import { BCMRHttp } from './bcmr-http.js';
|
||||
|
||||
export class BCMRComposite extends BaseBCMR {
|
||||
constructor(public readonly bridges: Array<BCMRHttp>) {
|
||||
super();
|
||||
}
|
||||
|
||||
async getTokenData(categoryId: string) {
|
||||
const getTokenDataPromises = this.bridges.map((bridge) =>
|
||||
bridge.getTokenData(categoryId),
|
||||
);
|
||||
|
||||
try {
|
||||
const data = await Promise.any(getTokenDataPromises);
|
||||
|
||||
return data;
|
||||
} catch (error: unknown) {
|
||||
throw new Error(
|
||||
`Unable to get token metadata from any of the BCMR indexers. Detailed error: ${error}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user