diff --git a/package.json b/package.json index 90e9448..5966c9c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@magiceden-oss/runestone-lib", - "version": "0.9.3-alpha", + "version": "0.9.4-alpha", "description": "", "main": "./dist/index.js", "types": "./dist/index.d.ts", diff --git a/src/indexer/types.ts b/src/indexer/types.ts index cc5c5f9..4c6c0b2 100644 --- a/src/indexer/types.ts +++ b/src/indexer/types.ts @@ -43,17 +43,18 @@ export interface RunestoneStorage { saveBlockIndex(runeBlockIndex: RuneBlockIndex): Promise; /** - * Get the etching that deployed the rune if it exists. + * Get the etching that deployed the rune if it exists (up to given blockheight). * @param runeLocation rune id string representation + * @param blockheight the block height */ - getEtching(runeLocation: string): Promise; + getEtching(runeLocation: string, blockheight: number): Promise; /** - * Get the total valid mint counts for rune. + * Get the total valid mint counts for rune up to and including specified block height. * @param rune rune id string representation - * @param blockhash hash to specify explicit block chain tip to use + * @param blockheight block height to count up to */ - getValidMintCount(runeLocation: string, blockhash: string): Promise; + getValidMintCount(runeLocation: string, blockheight: number): Promise; getRuneLocation(runeTicker: string): Promise; diff --git a/src/indexer/updater.ts b/src/indexer/updater.ts index 570309d..8e7250c 100644 --- a/src/indexer/updater.ts +++ b/src/indexer/updater.ts @@ -280,7 +280,8 @@ export class RuneUpdater implements RuneBlockIndex { for (const balance of balances.values()) { const runeIdString = RuneLocation.toString(balance.runeId); const etching = - etchingByRuneId.get(runeIdString) ?? (await this._storage.getEtching(runeIdString)); + etchingByRuneId.get(runeIdString) ?? + (await this._storage.getEtching(runeIdString, this.block.height - 1)); if (etching === null) { throw new Error('Rune should exist at this point'); } @@ -361,7 +362,8 @@ export class RuneUpdater implements RuneBlockIndex { ); const etching = - etchingByRuneId.get(runeLocation) ?? (await this._storage.getEtching(runeLocation)); + etchingByRuneId.get(runeLocation) ?? + (await this._storage.getEtching(runeLocation, this.block.height - 1)); if (etching === null || !etching.valid || !etching.terms) { return None; } @@ -400,7 +402,7 @@ export class RuneUpdater implements RuneBlockIndex { const totalMints = currentBlockMints.count + - (await this._storage.getValidMintCount(runeLocation, this.block.previousblockhash)); + (await this._storage.getValidMintCount(runeLocation, this.block.height - 1)); if (totalMints >= cap) { return None;