diff --git a/examples/mud/CHANGELOG.md b/examples/mud/CHANGELOG.md index ed40433..35742d1 100644 --- a/examples/mud/CHANGELOG.md +++ b/examples/mud/CHANGELOG.md @@ -1,5 +1,15 @@ # web-demo +## 0.1.40 + +### Patch Changes + +- Updated dependencies + - ethereum-indexer-browser@0.6.13 + - event-processor-bleeps@0.0.41 + - event-processor-conquest-eth@0.0.41 + - event-processor-nfts@0.0.41 + ## 0.1.39 ### Patch Changes diff --git a/examples/mud/package.json b/examples/mud/package.json index 9b5b38a..43ac390 100644 --- a/examples/mud/package.json +++ b/examples/mud/package.json @@ -1,7 +1,7 @@ { "name": "mud-demo", "private": true, - "version": "0.1.39", + "version": "0.1.40", "type": "module", "scripts": { "dev": "vite", diff --git a/examples/web-demo/CHANGELOG.md b/examples/web-demo/CHANGELOG.md index 3c47341..7530f0e 100644 --- a/examples/web-demo/CHANGELOG.md +++ b/examples/web-demo/CHANGELOG.md @@ -1,5 +1,15 @@ # web-demo +## 0.1.40 + +### Patch Changes + +- Updated dependencies + - ethereum-indexer-browser@0.6.13 + - event-processor-bleeps@0.0.41 + - event-processor-conquest-eth@0.0.41 + - event-processor-nfts@0.0.41 + ## 0.1.39 ### Patch Changes diff --git a/examples/web-demo/package.json b/examples/web-demo/package.json index dd777f6..38f8909 100644 --- a/examples/web-demo/package.json +++ b/examples/web-demo/package.json @@ -1,7 +1,7 @@ { "name": "web-demo", "private": true, - "version": "0.1.39", + "version": "0.1.40", "type": "module", "scripts": { "dev": "vite", diff --git a/packages/ethereum-indexer-browser/CHANGELOG.md b/packages/ethereum-indexer-browser/CHANGELOG.md index 422e09f..581e4c1 100644 --- a/packages/ethereum-indexer-browser/CHANGELOG.md +++ b/packages/ethereum-indexer-browser/CHANGELOG.md @@ -1,5 +1,11 @@ # ethereum-indexer-browser +## 0.6.13 + +### Patch Changes + +- allow reading from file for deployments + ## 0.6.12 ### Patch Changes diff --git a/packages/ethereum-indexer-browser/package.json b/packages/ethereum-indexer-browser/package.json index e0d13bd..08d1696 100644 --- a/packages/ethereum-indexer-browser/package.json +++ b/packages/ethereum-indexer-browser/package.json @@ -1,6 +1,6 @@ { "name": "ethereum-indexer-browser", - "version": "0.6.12", + "version": "0.6.13", "publishConfig": { "access": "public" }, diff --git a/packages/ethereum-indexer-browser/src/storage/state/OnIndexedDB.ts b/packages/ethereum-indexer-browser/src/storage/state/OnIndexedDB.ts index 23ec098..9cee446 100644 --- a/packages/ethereum-indexer-browser/src/storage/state/OnIndexedDB.ts +++ b/packages/ethereum-indexer-browser/src/storage/state/OnIndexedDB.ts @@ -8,14 +8,29 @@ function getStorageID(name: string, chainId: string type StateData = AllData; -export function keepStateOnIndexedDB(name: string) { +export function keepStateOnIndexedDB(name: string, remote?: string) { return { fetch: async (context: ProcessorContext) => { const storageID = getStorageID(name, context.source.chainId, 'config' in context ? context.config : undefined); const existingState = await get>(storageID); + + let remoteState: StateData | undefined; + if (remote) { + try { + const response = await fetch(remote); + const json = await response.json(); + remoteState = json; + } catch(err) { + console.error(`failed to fetch remote-state`, err); + } + } + if (!existingState) { - return undefined; + return remoteState; } else { + if (remoteState && remoteState.lastSync.lastToBlock >= existingState.lastSync.lastToBlock) { + return remoteState; + } return existingState; } }, diff --git a/packages/ethereum-indexer-cli/CHANGELOG.md b/packages/ethereum-indexer-cli/CHANGELOG.md index df70cef..6ef33a3 100644 --- a/packages/ethereum-indexer-cli/CHANGELOG.md +++ b/packages/ethereum-indexer-cli/CHANGELOG.md @@ -1,5 +1,12 @@ # ethereum-indexer-cli +## 0.6.14 + +### Patch Changes + +- Updated dependencies + - ethereum-indexer-utils@0.6.9 + ## 0.6.13 ### Patch Changes diff --git a/packages/ethereum-indexer-cli/package.json b/packages/ethereum-indexer-cli/package.json index 1daf773..924c50d 100644 --- a/packages/ethereum-indexer-cli/package.json +++ b/packages/ethereum-indexer-cli/package.json @@ -1,6 +1,6 @@ { "name": "ethereum-indexer-cli", - "version": "0.6.13", + "version": "0.6.14", "description": "", "keywords": [], "author": "", diff --git a/packages/ethereum-indexer-server/CHANGELOG.md b/packages/ethereum-indexer-server/CHANGELOG.md index 9847bc4..596a709 100644 --- a/packages/ethereum-indexer-server/CHANGELOG.md +++ b/packages/ethereum-indexer-server/CHANGELOG.md @@ -1,5 +1,12 @@ # ethereum-indexer-server +## 0.6.17 + +### Patch Changes + +- Updated dependencies + - ethereum-indexer-utils@0.6.9 + ## 0.6.16 ### Patch Changes diff --git a/packages/ethereum-indexer-server/package.json b/packages/ethereum-indexer-server/package.json index bcbd298..9424a16 100644 --- a/packages/ethereum-indexer-server/package.json +++ b/packages/ethereum-indexer-server/package.json @@ -1,6 +1,6 @@ { "name": "ethereum-indexer-server", - "version": "0.6.16", + "version": "0.6.17", "description": "", "keywords": [], "author": "", diff --git a/packages/ethereum-indexer-streams/CHANGELOG.md b/packages/ethereum-indexer-streams/CHANGELOG.md index 5c7d684..5bc6873 100644 --- a/packages/ethereum-indexer-streams/CHANGELOG.md +++ b/packages/ethereum-indexer-streams/CHANGELOG.md @@ -1,5 +1,12 @@ # ethereum-indexer-server +## 0.6.16 + +### Patch Changes + +- Updated dependencies + - ethereum-indexer-utils@0.6.9 + ## 0.6.15 ### Patch Changes diff --git a/packages/ethereum-indexer-streams/package.json b/packages/ethereum-indexer-streams/package.json index 788e9a0..a891864 100644 --- a/packages/ethereum-indexer-streams/package.json +++ b/packages/ethereum-indexer-streams/package.json @@ -1,6 +1,6 @@ { "name": "ethereum-indexer-streams", - "version": "0.6.15", + "version": "0.6.16", "description": "", "keywords": [], "author": "", diff --git a/packages/ethereum-indexer-utils/CHANGELOG.md b/packages/ethereum-indexer-utils/CHANGELOG.md index 0abe14e..78507c0 100644 --- a/packages/ethereum-indexer-utils/CHANGELOG.md +++ b/packages/ethereum-indexer-utils/CHANGELOG.md @@ -1,5 +1,11 @@ # ethereum-indexer-utils +## 0.6.9 + +### Patch Changes + +- allow reading from file for deployments + ## 0.6.8 ### Patch Changes diff --git a/packages/ethereum-indexer-utils/package.json b/packages/ethereum-indexer-utils/package.json index 1d664aa..8e03948 100644 --- a/packages/ethereum-indexer-utils/package.json +++ b/packages/ethereum-indexer-utils/package.json @@ -1,6 +1,6 @@ { "name": "ethereum-indexer-utils", - "version": "0.6.8", + "version": "0.6.9", "description": "", "publishConfig": { "access": "public" diff --git a/packages/ethereum-indexer-utils/src/contracts.ts b/packages/ethereum-indexer-utils/src/contracts.ts index 791dace..6bec5e5 100644 --- a/packages/ethereum-indexer-utils/src/contracts.ts +++ b/packages/ethereum-indexer-utils/src/contracts.ts @@ -18,7 +18,34 @@ function mergeABIs(abi1: any[], abi2: any[]): any[] { return newABI; } -export function loadContracts(folder: string): IndexingSource { +export function loadContracts(folderOrFile: string): IndexingSource { + if (fs.statSync(folderOrFile).isDirectory()) { + return loadContractsFromFolder(folderOrFile); + } else { + return loadContractsFromFile(folderOrFile) + } +} + + +export function loadContractsFromFile(file: string): IndexingSource { + + let contractSTR = fs.readFileSync(file, 'utf-8'); + if (contractSTR.startsWith('export default {') && contractSTR.endsWith('} as const;')) { + contractSTR = contractSTR.slice(15, -10); + } + const contracts = JSON.parse(contractSTR); + + return { + chainId: contracts.chainId, + contracts: Object.keys(contracts.contracts).map( + (name) => (contracts as any).contracts[name], + ), + } +} + + + +export function loadContractsFromFolder(folder: string): IndexingSource { const contractsAdded: {[address: string]: {index: number}} = {}; const contractsData: ContractData[] = []; const files = fs.readdirSync(folder);