-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #227 from balancer-labs/develop
Develop
- Loading branch information
Showing
36 changed files
with
1,208 additions
and
880 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import cloneDeep from 'lodash.clonedeep'; | ||
import { PoolDataService, SubgraphPoolBase } from './types'; | ||
|
||
export class PoolCacher { | ||
private pools: SubgraphPoolBase[] = []; | ||
private _finishedFetching = false; | ||
|
||
constructor(private readonly poolDataService: PoolDataService) {} | ||
|
||
public get finishedFetching(): boolean { | ||
return this._finishedFetching; | ||
} | ||
|
||
public getPools(): SubgraphPoolBase[] { | ||
return cloneDeep(this.pools); | ||
} | ||
|
||
/* | ||
* Saves updated pools data to internal cache. | ||
*/ | ||
public async fetchPools(): Promise<boolean> { | ||
try { | ||
this.pools = await this.poolDataService.getPools(); | ||
this._finishedFetching = true; | ||
|
||
return true; | ||
} catch (err) { | ||
// On error clear all caches and return false so user knows to try again. | ||
this._finishedFetching = false; | ||
this.pools = []; | ||
console.error(`Error: fetchPools(): ${err.message}`); | ||
return false; | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.