Skip to content

Commit

Permalink
fix: await reponse
Browse files Browse the repository at this point in the history
  • Loading branch information
sakulstra committed Jun 5, 2024
1 parent 84d30a1 commit 9140e74
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ The `customStorageProvider` is a simple file based cache that fetches "new" data
If no cache is found the cache will try to refresh automatically.

```
import {localCacheAdapter} from '@bgd-labs/aave-v3-governance-cache/localCache';
import {customStorageProvider} from '@bgd-labs/aave-v3-governance-cache/localCache';
import {customStorageProvider} from '@bgd-labs/aave-v3-governance-cache/fileSystem';
const cachingLayer = localCacheAdapter;
const cachingLayer = customStorageProvider();
const payload = cachingLayer.getPayload({chainId, payloadsController, payloadId});
const proposal = cachingLayer.getProposal({chainId, governance, proposalId});
Expand Down
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bgd-labs/aave-v3-governance-cache",
"version": "1.0.2",
"version": "1.0.4",
"sideEffects": false,
"files": [
"cache",
Expand All @@ -16,11 +16,15 @@
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"./localCache": {
"./customStorageProvider": {
"types": "./dist/customStorageProvider.d.ts",
"default": "./dist/providers/customStorageProvider.js"
},
"./github": {
"./fileSystemStorageAdapter": {
"types": "./dist/fileSystem.d.ts",
"default": "./dist/providers/storage/fileSystem.js"
},
"./githubPagesProvider": {
"types": "./dist/githubPagesProvider.d.ts",
"default": "./dist/providers/githubPagesProvider.js"
},
Expand Down
2 changes: 1 addition & 1 deletion src/providers/fallbackProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const fallbackProvider = <T extends GovernanceCacheAdapter>(
async getPayload(args) {
for (let i = 0; i < providers.length; i++) {
try {
const response = providers[i].getPayload(args);
const response = await providers[i].getPayload(args);
return response;
} catch (e) {
console.log('falling back to next provider');
Expand Down
2 changes: 1 addition & 1 deletion src/providers/githubPagesProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function getPath() {
return 'https://bgd-labs.github.io/v3-governance-cache/cache/';
}

export const githubPagesCacheAdapter: GovernanceCacheAdapter = {
export const githubPagesProvider: GovernanceCacheAdapter = {
async getPayload({chainId, payloadsController, payloadId}) {
const path = `${chainId.toString()}/${payloadsController}/payloads/${payloadId}.json`;
const cache = (await (await fetch(getPath() + path)).json()) as PayloadCacheRaw;
Expand Down
2 changes: 1 addition & 1 deletion src/providers/storage/fileSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ const syncPayloadsCache: GovernanceCacheAdapterWithSync['syncPayloadsCache'] = a
return newData;
};

export const fileSystemStorage: GovernanceCacheAdapterWithSync = {
export const fileSystemStorageAdapter: GovernanceCacheAdapterWithSync = {
async getPayload({chainId, payloadsController, payloadId}) {
const path = `${chainId.toString()}/${payloadsController}/payloads`;
const cache = readJSONCache<PayloadCacheRaw>(path, payloadId);
Expand Down

0 comments on commit 9140e74

Please sign in to comment.