Skip to content

Commit

Permalink
Accomodate changes in codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
prathamesh0 committed Sep 16, 2022
1 parent 9dfd2bf commit f054f8f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
8 changes: 8 additions & 0 deletions packages/codegen/src/templates/fill-state-template.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ export const fillState = async (

const blockHash = blocks[0].blockHash;

// Create initial state for contracts
await indexer.createInit(blockHash, blockNumber);

// Fill state for each contract in contractEntitiesMap
const contractStatePromises = Array.from(contractEntitiesMap.entries())
.map(async ([contractAddress, entities]): Promise<void> => {
Expand Down Expand Up @@ -90,7 +93,12 @@ export const fillState = async (

// Persist subgraph state to the DB
await indexer.dumpSubgraphState(blockHash, true);

// Create checkpoints
await indexer.processCheckpoint(blockHash);
}

// TODO: Push state to IPFS

log(`Filled state for subgraph entities in range: [${startBlock}, ${endBlock}]`);
};
8 changes: 7 additions & 1 deletion packages/codegen/src/templates/indexer-template.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -419,14 +419,20 @@ export class Indexer implements IPLDIndexerInterface {
return this._baseIndexer.createStateCheckpoint(contractAddress, block, data);
}

// Method to be used by checkpoint CLI.
// Method to be used by export-state CLI.
async createCheckpoint (contractAddress: string, blockHash: string): Promise<string | undefined> {
const block = await this.getBlockProgress(blockHash);
assert(block);

return this._baseIndexer.createCheckpoint(this, contractAddress, block);
}

// Method to be used by fill-state CLI.
async createInit (blockHash: string, blockNumber: number): Promise<void> {
// Create initial state for contracts.
await this._baseIndexer.createInit(this, blockHash, blockNumber);
}

async saveOrUpdateIPLDBlock (ipldBlock: IPLDBlock): Promise<IPLDBlock> {
return this._baseIndexer.saveOrUpdateIPLDBlock(ipldBlock);
}
Expand Down

0 comments on commit f054f8f

Please sign in to comment.