Skip to content

Commit 92f7600

Browse files
authored
Renamed rune to runeName for external types (#40)
1 parent dabeff4 commit 92f7600

File tree

5 files changed

+69
-66
lines changed

5 files changed

+69
-66
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.6.1-alpha",
3+
"version": "0.6.2-alpha",
44
"description": "",
55
"main": "./dist/index.js",
66
"types": "./dist/index.d.ts",

src/indexer/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class RunestoneIndexer {
4040
if (this._network === Network.MAINNET) {
4141
this._storage.seedEtchings([
4242
{
43-
rune: 'UNCOMMON•GOODS',
43+
runeName: 'UNCOMMON•GOODS',
4444
runeId: { block: 1, tx: 0 },
4545
txid: '0000000000000000000000000000000000000000000000000000000000000000',
4646
valid: true,

src/indexer/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export type RuneUtxoBalance = {
111111
address?: string;
112112
scriptPubKey: Buffer;
113113
runeId: RuneLocation;
114-
rune: string;
114+
runeName: string;
115115
amount: bigint;
116116
};
117117

@@ -141,7 +141,7 @@ export type RuneEtchingSpec = RuneEtchingBase & { rune?: string };
141141

142142
export type RuneEtching = ({ valid: false } | ({ valid: true } & RuneEtchingBase)) & {
143143
runeId: RuneLocation;
144-
rune: string;
144+
runeName: string;
145145
txid: string;
146146
};
147147

src/indexer/updater.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -273,20 +273,21 @@ export class RuneUpdater implements RuneBlockIndex {
273273
continue;
274274
}
275275

276-
const runeByRuneId = new Map(
277-
this.etchings.map((etching) => [RuneLocation.toString(etching.runeId), etching.rune])
276+
const runeNameByRuneId = new Map(
277+
this.etchings.map((etching) => [RuneLocation.toString(etching.runeId), etching.runeName])
278278
);
279279
for (const balance of balances.values()) {
280280
const runeIdString = RuneLocation.toString(balance.runeId);
281-
const rune =
282-
runeByRuneId.get(runeIdString) ?? (await this._storage.getEtching(runeIdString))?.rune;
283-
if (rune === undefined) {
281+
const runeName =
282+
runeNameByRuneId.get(runeIdString) ??
283+
(await this._storage.getEtching(runeIdString))?.runeName;
284+
if (runeName === undefined) {
284285
throw new Error('Rune should exist at this point');
285286
}
286287

287288
this.utxoBalances.push({
288289
runeId: balance.runeId,
289-
rune,
290+
runeName,
290291
amount: balance.amount,
291292
scriptPubKey: Buffer.from(output.scriptPubKey.hex),
292293
txid: tx.txid,
@@ -331,7 +332,9 @@ export class RuneUpdater implements RuneBlockIndex {
331332
if (
332333
rune.value < this._minimum.value ||
333334
rune.reserved ||
334-
this.etchings.find((etching) => etching.rune === rune.toString()) ||
335+
this.etchings.find(
336+
(etching) => SpacedRune.fromString(etching.runeName).rune.toString() === rune.toString()
337+
) ||
335338
(await this._storage.getRuneLocation(rune.toString())) !== null ||
336339
!(await this.txCommitsToRune(tx, rune))
337340
) {
@@ -509,7 +512,7 @@ export class RuneUpdater implements RuneBlockIndex {
509512
const { divisibility, terms, premine, spacers, symbol } = artifact.etching.unwrap();
510513
this.etchings.push({
511514
valid: true,
512-
rune: new SpacedRune(rune, Number(spacers.map(Number).unwrapOr(0))).toString(),
515+
runeName: new SpacedRune(rune, Number(spacers.map(Number).unwrapOr(0))).toString(),
513516
runeId,
514517
txid,
515518
...(divisibility.isSome() ? { divisibility: divisibility.map(Number).unwrap() } : {}),
@@ -560,7 +563,7 @@ export class RuneUpdater implements RuneBlockIndex {
560563
valid: false,
561564
runeId,
562565
txid,
563-
rune: rune.toString(),
566+
runeName: rune.toString(),
564567
});
565568
}
566569
}

0 commit comments

Comments
 (0)