replace rune parsing dependencies with minimal reimplementation
This commit is contained in:
@@ -7,23 +7,23 @@
|
||||
<ng-container i18n="ord.mint-n-runes">
|
||||
<span>Mint</span>
|
||||
<span class="amount"> {{ minted >= 100000 ? (minted | amountShortener:undefined:undefined:true) : minted }} </span>
|
||||
<ng-container *ngTemplateOutlet="runeName; context: { $implicit: runestone.mint.unwrap().toString() }"></ng-container>
|
||||
<ng-container *ngTemplateOutlet="runeName; context: { $implicit: runestone.mint.toString() }"></ng-container>
|
||||
</ng-container>
|
||||
}
|
||||
@if (totalSupply > -1) {
|
||||
@if (premined > 0) {
|
||||
@if (runestone?.etching?.supply) {
|
||||
@if (runestone?.etching.premine > 0) {
|
||||
<ng-container i18n="ord.premine-n-runes">
|
||||
<span>Premine</span>
|
||||
<span class="amount"> {{ premined >= 100000 ? (premined | amountShortener:undefined:undefined:true) : premined }} </span>
|
||||
{{ etchedSymbol }}
|
||||
<span class="name">{{ etchedName }}</span>
|
||||
<span> ({{ premined / totalSupply * 100 | amountShortener:0}}% of total supply)</span>
|
||||
<span class="amount"> {{ runestone.etching.premine >= 100000 ? (toNumber(runestone.etching.premine) | amountShortener:undefined:undefined:true) : runestone.etching.premine }} </span>
|
||||
{{ runestone.etching.symbol }}
|
||||
<span class="name">{{ runestone.etching.spacedName }}</span>
|
||||
<span> ({{ toNumber(runestone.etching.premine) / toNumber(runestone.etching.supply) * 100 | amountShortener:0}}% of total supply)</span>
|
||||
</ng-container>
|
||||
} @else {
|
||||
} @else {
|
||||
<ng-container i18n="ord.etch-rune">
|
||||
<span>Etching of</span>
|
||||
{{ etchedSymbol }}
|
||||
<span class="name">{{ etchedName }}</span>
|
||||
{{ runestone.etching.symbol }}
|
||||
<span class="name">{{ runestone.etching.spacedName }}</span>
|
||||
</ng-container>
|
||||
}
|
||||
}
|
||||
@@ -36,12 +36,6 @@
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- @if (runestone && !runestone?.etching && !runestone?.mint && !transferredRunes?.length && type === 'vout') {
|
||||
<div>
|
||||
<i>No content in this runestone</i>
|
||||
</div>
|
||||
} -->
|
||||
|
||||
@if (inscriptions?.length && type === 'vin') {
|
||||
<div *ngFor="let contentType of inscriptionsData | keyvalue">
|
||||
<div>
|
||||
@@ -68,8 +62,8 @@
|
||||
}
|
||||
|
||||
<ng-template #runeName let-id>
|
||||
{{ runeInfo[id]?.etching.symbol.isSome() ? runeInfo[id]?.etching.symbol.unwrap() : '' }}
|
||||
{{ runeInfo[id]?.etching.symbol || '' }}
|
||||
<a [routerLink]="id !== '1:0' ? ['/tx' | relativeUrl, runeInfo[id]?.txid] : null" [class.rune-link]="id !== '1:0'" [class.disabled]="id === '1:0'">
|
||||
<span class="name">{{ runeInfo[id]?.name }}</span>
|
||||
<span class="name">{{ runeInfo[id]?.etching.spacedName }}</span>
|
||||
</a>
|
||||
</ng-template>
|
||||
@@ -1,9 +1,6 @@
|
||||
import { ChangeDetectionStrategy, Component, Input, OnChanges, SimpleChanges } from '@angular/core';
|
||||
import { Runestone } from '../../shared/ord/rune/runestone';
|
||||
import { Etching } from '../../shared/ord/rune/etching';
|
||||
import { u128, u32, u8 } from '../../shared/ord/rune/integer';
|
||||
import { HttpErrorResponse } from '@angular/common/http';
|
||||
import { SpacedRune } from '../../shared/ord/rune/spacedrune';
|
||||
import { Runestone, Etching } from '../../shared/ord/rune.utils';
|
||||
|
||||
export interface Inscription {
|
||||
body?: Uint8Array;
|
||||
@@ -22,79 +19,34 @@ export interface Inscription {
|
||||
export class OrdDataComponent implements OnChanges {
|
||||
@Input() inscriptions: Inscription[];
|
||||
@Input() runestone: Runestone;
|
||||
@Input() runeInfo: { [id: string]: { etching: Etching; txid: string; name?: string; } };
|
||||
@Input() runeInfo: { [id: string]: { etching: Etching; txid: string } };
|
||||
@Input() error: HttpErrorResponse;
|
||||
@Input() type: 'vin' | 'vout';
|
||||
|
||||
toNumber = (value: bigint): number => Number(value);
|
||||
|
||||
// Inscriptions
|
||||
inscriptionsData: { [key: string]: { count: number, totalSize: number, text?: string; json?: JSON; tag?: string; delegate?: string } };
|
||||
// Rune mints
|
||||
minted: number;
|
||||
// Rune etching
|
||||
premined: number = -1;
|
||||
totalSupply: number = -1;
|
||||
etchedName: string;
|
||||
etchedSymbol: string;
|
||||
// Rune transfers
|
||||
transferredRunes: { key: string; etching: Etching; txid: string; name?: string; }[] = [];
|
||||
transferredRunes: { key: string; etching: Etching; txid: string }[] = [];
|
||||
|
||||
constructor() { }
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (changes.runestone && this.runestone) {
|
||||
|
||||
Object.keys(this.runeInfo).forEach((key) => {
|
||||
const rune = this.runeInfo[key].etching.rune.isSome() ? this.runeInfo[key].etching.rune.unwrap() : null;
|
||||
const spacers = this.runeInfo[key].etching.spacers.isSome() ? this.runeInfo[key].etching.spacers.unwrap() : u32(0);
|
||||
if (rune) {
|
||||
this.runeInfo[key].name = new SpacedRune(rune, Number(spacers)).toString();
|
||||
}
|
||||
this.transferredRunes.push({ key, ...this.runeInfo[key] });
|
||||
});
|
||||
|
||||
|
||||
if (this.runestone.mint.isSome() && this.runeInfo[this.runestone.mint.unwrap().toString()]) {
|
||||
const mint = this.runestone.mint.unwrap().toString();
|
||||
this.transferredRunes = Object.entries(this.runeInfo).map(([key, runeInfo]) => ({ key, ...runeInfo }));
|
||||
if (this.runestone.mint && this.runeInfo[this.runestone.mint.toString()]) {
|
||||
const mint = this.runestone.mint.toString();
|
||||
this.transferredRunes = this.transferredRunes.filter(rune => rune.key !== mint);
|
||||
const terms = this.runeInfo[mint].etching.terms.isSome() ? this.runeInfo[mint].etching.terms.unwrap() : null;
|
||||
let amount: u128;
|
||||
if (terms) {
|
||||
amount = terms.amount.isSome() ? terms.amount.unwrap() : u128(0);
|
||||
}
|
||||
const divisibility = this.runeInfo[mint].etching.divisibility.isSome() ? this.runeInfo[mint].etching.divisibility.unwrap() : u8(0);
|
||||
const terms = this.runeInfo[mint].etching.terms;
|
||||
const amount = terms?.amount;
|
||||
const divisibility = this.runeInfo[mint].etching.divisibility;
|
||||
if (amount) {
|
||||
this.minted = this.getAmount(amount, divisibility);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.runestone.etching.isSome()) {
|
||||
const etching = this.runestone.etching.unwrap();
|
||||
const rune = etching.rune.isSome() ? etching.rune.unwrap() : null;
|
||||
const spacers = etching.spacers.isSome() ? etching.spacers.unwrap() : u32(0);
|
||||
if (rune) {
|
||||
this.etchedName = new SpacedRune(rune, Number(spacers)).toString();
|
||||
}
|
||||
this.etchedSymbol = etching.symbol.isSome() ? etching.symbol.unwrap() : '';
|
||||
|
||||
const divisibility = etching.divisibility.isSome() ? etching.divisibility.unwrap() : u8(0);
|
||||
const premine = etching.premine.isSome() ? etching.premine.unwrap() : u128(0);
|
||||
if (premine) {
|
||||
this.premined = this.getAmount(premine, divisibility);
|
||||
} else {
|
||||
this.premined = 0;
|
||||
}
|
||||
const terms = etching.terms.isSome() ? etching.terms.unwrap() : null;
|
||||
let amount: u128;
|
||||
if (terms) {
|
||||
amount = terms.amount.isSome() ? terms.amount.unwrap() : u128(0);
|
||||
if (amount) {
|
||||
const cap = terms.cap.isSome() ? terms.cap.unwrap() : u128(0);
|
||||
this.totalSupply = this.premined + this.getAmount(amount, divisibility) * Number(cap);
|
||||
}
|
||||
} else {
|
||||
this.totalSupply = this.premined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (changes.inscriptions && this.inscriptions) {
|
||||
@@ -131,7 +83,7 @@ export class OrdDataComponent implements OnChanges {
|
||||
}
|
||||
}
|
||||
|
||||
getAmount(amount: u128 | bigint, divisibility: u8): number {
|
||||
getAmount(amount: bigint, divisibility: number): number {
|
||||
const divisor = BigInt(10) ** BigInt(divisibility);
|
||||
const result = amount / divisor;
|
||||
|
||||
|
||||
@@ -6,15 +6,14 @@ import { Outspend, Transaction, Vin, Vout } from '../../interfaces/electrs.inter
|
||||
import { ElectrsApiService } from '../../services/electrs-api.service';
|
||||
import { environment } from '../../../environments/environment';
|
||||
import { AssetsService } from '../../services/assets.service';
|
||||
import { filter, map, tap, switchMap, shareReplay, catchError } from 'rxjs/operators';
|
||||
import { filter, map, tap, switchMap, catchError } from 'rxjs/operators';
|
||||
import { BlockExtended } from '../../interfaces/node-api.interface';
|
||||
import { ApiService } from '../../services/api.service';
|
||||
import { PriceService } from '../../services/price.service';
|
||||
import { StorageService } from '../../services/storage.service';
|
||||
import { OrdApiService } from '../../services/ord-api.service';
|
||||
import { Inscription } from '../ord-data/ord-data.component';
|
||||
import { Runestone } from '../../shared/ord/rune/runestone';
|
||||
import { Etching } from '../../shared/ord/rune/etching';
|
||||
import { Etching, Runestone } from '../../shared/ord/rune.utils';
|
||||
|
||||
@Component({
|
||||
selector: 'app-transactions-list',
|
||||
@@ -261,7 +260,7 @@ export class TransactionsListComponent implements OnInit, OnChanges {
|
||||
tx.vout[i].isRunestone = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user