Skip to content

Commit ee3e5f4

Browse files
authored
Changed getEtching call to also require blockheight (#49)
1 parent 462f33b commit ee3e5f4

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@magiceden-oss/runestone-lib",
3-
"version": "0.9.3-alpha",
3+
"version": "0.9.4-alpha",
44
"description": "",
55
"main": "./dist/index.js",
66
"types": "./dist/index.d.ts",

src/indexer/types.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,18 @@ export interface RunestoneStorage {
4343
saveBlockIndex(runeBlockIndex: RuneBlockIndex): Promise<void>;
4444

4545
/**
46-
* Get the etching that deployed the rune if it exists.
46+
* Get the etching that deployed the rune if it exists (up to given blockheight).
4747
* @param runeLocation rune id string representation
48+
* @param blockheight the block height
4849
*/
49-
getEtching(runeLocation: string): Promise<RuneEtching | null>;
50+
getEtching(runeLocation: string, blockheight: number): Promise<RuneEtching | null>;
5051

5152
/**
52-
* Get the total valid mint counts for rune.
53+
* Get the total valid mint counts for rune up to and including specified block height.
5354
* @param rune rune id string representation
54-
* @param blockhash hash to specify explicit block chain tip to use
55+
* @param blockheight block height to count up to
5556
*/
56-
getValidMintCount(runeLocation: string, blockhash: string): Promise<number>;
57+
getValidMintCount(runeLocation: string, blockheight: number): Promise<number>;
5758

5859
getRuneLocation(runeTicker: string): Promise<RuneLocation | null>;
5960

src/indexer/updater.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,8 @@ export class RuneUpdater implements RuneBlockIndex {
280280
for (const balance of balances.values()) {
281281
const runeIdString = RuneLocation.toString(balance.runeId);
282282
const etching =
283-
etchingByRuneId.get(runeIdString) ?? (await this._storage.getEtching(runeIdString));
283+
etchingByRuneId.get(runeIdString) ??
284+
(await this._storage.getEtching(runeIdString, this.block.height - 1));
284285
if (etching === null) {
285286
throw new Error('Rune should exist at this point');
286287
}
@@ -361,7 +362,8 @@ export class RuneUpdater implements RuneBlockIndex {
361362
);
362363

363364
const etching =
364-
etchingByRuneId.get(runeLocation) ?? (await this._storage.getEtching(runeLocation));
365+
etchingByRuneId.get(runeLocation) ??
366+
(await this._storage.getEtching(runeLocation, this.block.height - 1));
365367
if (etching === null || !etching.valid || !etching.terms) {
366368
return None;
367369
}
@@ -400,7 +402,7 @@ export class RuneUpdater implements RuneBlockIndex {
400402

401403
const totalMints =
402404
currentBlockMints.count +
403-
(await this._storage.getValidMintCount(runeLocation, this.block.previousblockhash));
405+
(await this._storage.getValidMintCount(runeLocation, this.block.height - 1));
404406

405407
if (totalMints >= cap) {
406408
return None;

0 commit comments

Comments
 (0)