FIx error handling logic in ord-data
This commit is contained in:
		
							parent
							
								
									3b9601a82e
								
							
						
					
					
						commit
						65f080d526
					
				@ -1,64 +1,56 @@
 | 
				
			|||||||
@if (error) {
 | 
					@if (minted) {
 | 
				
			||||||
  <div>
 | 
					  <ng-container i18n="ord.mint-n-runes">
 | 
				
			||||||
    <i>Error fetching data (code {{ error.status }})</i>
 | 
					    <span>Mint</span>
 | 
				
			||||||
  </div>
 | 
					    <span class="amount"> {{ minted >= 100000 ? (minted | amountShortener:undefined:undefined:true) : minted }} </span>
 | 
				
			||||||
} @else {
 | 
					    <ng-container *ngTemplateOutlet="runeName; context: { $implicit: runestone.mint.toString() }"></ng-container>
 | 
				
			||||||
  @if (minted) {
 | 
					  </ng-container>
 | 
				
			||||||
    <ng-container i18n="ord.mint-n-runes">
 | 
					}
 | 
				
			||||||
      <span>Mint</span>
 | 
					@if (runestone?.etching?.supply) {
 | 
				
			||||||
      <span class="amount"> {{ minted >= 100000 ? (minted | amountShortener:undefined:undefined:true) : minted }} </span>
 | 
					  @if (runestone?.etching.premine > 0) {
 | 
				
			||||||
      <ng-container *ngTemplateOutlet="runeName; context: { $implicit: runestone.mint.toString() }"></ng-container>
 | 
					    <ng-container i18n="ord.premine-n-runes">
 | 
				
			||||||
 | 
					      <span>Premine</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 {
 | 
				
			||||||
 | 
					    <ng-container i18n="ord.etch-rune">
 | 
				
			||||||
 | 
					      <span>Etching of</span>
 | 
				
			||||||
 | 
					      {{ runestone.etching.symbol }}
 | 
				
			||||||
 | 
					      <span class="name">{{ runestone.etching.spacedName }}</span>
 | 
				
			||||||
    </ng-container>
 | 
					    </ng-container>
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  @if (runestone?.etching?.supply) {
 | 
					}
 | 
				
			||||||
    @if (runestone?.etching.premine > 0) {
 | 
					@if (transferredRunes?.length && type === 'vout') {
 | 
				
			||||||
      <ng-container i18n="ord.premine-n-runes">
 | 
					  <div *ngFor="let rune of transferredRunes">
 | 
				
			||||||
        <span>Premine</span>
 | 
					    <ng-container i18n="ord.transfer-rune">
 | 
				
			||||||
        <span class="amount"> {{ runestone.etching.premine >= 100000 ? (toNumber(runestone.etching.premine) | amountShortener:undefined:undefined:true) : runestone.etching.premine }} </span>
 | 
					      <span>Transfer</span>
 | 
				
			||||||
        {{ runestone.etching.symbol }}
 | 
					      <ng-container *ngTemplateOutlet="runeName; context: { $implicit: rune.key }"></ng-container>
 | 
				
			||||||
        <span class="name">{{ runestone.etching.spacedName }}</span>
 | 
					    </ng-container>
 | 
				
			||||||
        <span> ({{ toNumber(runestone.etching.premine) / toNumber(runestone.etching.supply) * 100 | amountShortener:0}}% of total supply)</span>
 | 
					  </div>
 | 
				
			||||||
      </ng-container>
 | 
					}
 | 
				
			||||||
    } @else {
 | 
					 | 
				
			||||||
      <ng-container i18n="ord.etch-rune">
 | 
					 | 
				
			||||||
        <span>Etching of</span>
 | 
					 | 
				
			||||||
        {{ runestone.etching.symbol }}
 | 
					 | 
				
			||||||
        <span class="name">{{ runestone.etching.spacedName }}</span>
 | 
					 | 
				
			||||||
      </ng-container>
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  @if (transferredRunes?.length && type === 'vout') {
 | 
					 | 
				
			||||||
    <div *ngFor="let rune of transferredRunes">
 | 
					 | 
				
			||||||
      <ng-container i18n="ord.transfer-rune">
 | 
					 | 
				
			||||||
        <span>Transfer</span>
 | 
					 | 
				
			||||||
        <ng-container *ngTemplateOutlet="runeName; context: { $implicit: rune.key }"></ng-container>
 | 
					 | 
				
			||||||
      </ng-container>
 | 
					 | 
				
			||||||
    </div>
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @if (inscriptions?.length && type === 'vin') {
 | 
					@if (inscriptions?.length && type === 'vin') {
 | 
				
			||||||
    <div *ngFor="let contentType of inscriptionsData | keyvalue">
 | 
					  <div *ngFor="let contentType of inscriptionsData | keyvalue">
 | 
				
			||||||
      <div>
 | 
					 | 
				
			||||||
        <span class="badge badge-ord mr-1">{{ contentType.value.count > 1 ? contentType.value.count + " " : "" }}{{ contentType.value?.tag || contentType.key }}</span>
 | 
					 | 
				
			||||||
        <span class="badge badge-ord" *ngIf="contentType.value.totalSize > 0">{{ contentType.value.totalSize | bytes:2:'B':undefined:true }}</span>
 | 
					 | 
				
			||||||
        <a *ngIf="contentType.value.delegate" [routerLink]="['/tx' | relativeUrl, contentType.value.delegate]">
 | 
					 | 
				
			||||||
          <span i18n="ord.source-inscription">Source inscription</span>
 | 
					 | 
				
			||||||
        </a>
 | 
					 | 
				
			||||||
      </div>
 | 
					 | 
				
			||||||
      <pre *ngIf="contentType.value.json" class="name" style="white-space: pre-wrap; word-break: break-word;">{{ contentType.value.json | json }}</pre>
 | 
					 | 
				
			||||||
      <pre *ngIf="contentType.value.text" class="name" style="white-space: pre-wrap; word-break: break-word;">{{ contentType.value.text }}</pre>
 | 
					 | 
				
			||||||
      </div>
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  
 | 
					 | 
				
			||||||
  @if (!runestone && type === 'vout') {
 | 
					 | 
				
			||||||
    <div class="skeleton-loader" style="width: 50%;"></div>
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  @if (!inscriptions?.length && type === 'vin') {
 | 
					 | 
				
			||||||
    <div>
 | 
					    <div>
 | 
				
			||||||
      <i>Error decoding inscription data</i>
 | 
					      <span class="badge badge-ord mr-1">{{ contentType.value.count > 1 ? contentType.value.count + " " : "" }}{{ contentType.value?.tag || contentType.key }}</span>
 | 
				
			||||||
 | 
					      <span class="badge badge-ord" *ngIf="contentType.value.totalSize > 0">{{ contentType.value.totalSize | bytes:2:'B':undefined:true }}</span>
 | 
				
			||||||
 | 
					      <a *ngIf="contentType.value.delegate" [routerLink]="['/tx' | relativeUrl, contentType.value.delegate]">
 | 
				
			||||||
 | 
					        <span i18n="ord.source-inscription">Source inscription</span>
 | 
				
			||||||
 | 
					      </a>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
  }
 | 
					    <pre *ngIf="contentType.value.json" class="name" style="white-space: pre-wrap; word-break: break-word;">{{ contentType.value.json | json }}</pre>
 | 
				
			||||||
 | 
					    <pre *ngIf="contentType.value.text" class="name" style="white-space: pre-wrap; word-break: break-word;">{{ contentType.value.text }}</pre>
 | 
				
			||||||
 | 
					    </div>
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@if (!runestone && type === 'vout') {
 | 
				
			||||||
 | 
					  <div class="skeleton-loader" style="width: 50%;"></div>
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@if ((runestone && !minted && !runestone.etching?.supply && !transferredRunes?.length && type === 'vout') || (!inscriptions?.length && type === 'vin')) {
 | 
				
			||||||
 | 
					  <i i18n="error.decoding-data">Error decoding data</i>
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<ng-template #runeName let-id>
 | 
					<ng-template #runeName let-id>
 | 
				
			||||||
 | 
				
			|||||||
@ -1,5 +1,4 @@
 | 
				
			|||||||
import { ChangeDetectionStrategy, Component, Input, OnChanges, SimpleChanges } from '@angular/core';
 | 
					import { ChangeDetectionStrategy, Component, Input, OnChanges, SimpleChanges } from '@angular/core';
 | 
				
			||||||
import { HttpErrorResponse } from '@angular/common/http';
 | 
					 | 
				
			||||||
import { Runestone, Etching } from '../../shared/ord/rune.utils';
 | 
					import { Runestone, Etching } from '../../shared/ord/rune.utils';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export interface Inscription {
 | 
					export interface Inscription {
 | 
				
			||||||
@ -20,7 +19,6 @@ export class OrdDataComponent implements OnChanges {
 | 
				
			|||||||
  @Input() inscriptions: Inscription[];
 | 
					  @Input() inscriptions: Inscription[];
 | 
				
			||||||
  @Input() runestone: Runestone;
 | 
					  @Input() runestone: Runestone;
 | 
				
			||||||
  @Input() runeInfo: { [id: string]: { etching: Etching; txid: string } };
 | 
					  @Input() runeInfo: { [id: string]: { etching: Etching; txid: string } };
 | 
				
			||||||
  @Input() error: HttpErrorResponse;
 | 
					 | 
				
			||||||
  @Input() type: 'vin' | 'vout';
 | 
					  @Input() type: 'vin' | 'vout';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  toNumber = (value: bigint): number => Number(value);
 | 
					  toNumber = (value: bigint): number => Number(value);
 | 
				
			||||||
 | 
				
			|||||||
@ -103,7 +103,7 @@
 | 
				
			|||||||
              }">
 | 
					              }">
 | 
				
			||||||
                <td></td>
 | 
					                <td></td>
 | 
				
			||||||
                <td colspan="2">
 | 
					                <td colspan="2">
 | 
				
			||||||
                  <app-ord-data [inscriptions]="showOrdData[tx.txid + '-vin-' + vindex]['inscriptions']" [type]="'vin'" [error]="showOrdData[tx.txid + '-vin-' + vindex]['error']"></app-ord-data>
 | 
					                  <app-ord-data [inscriptions]="showOrdData[tx.txid + '-vin-' + vindex]['inscriptions']" [type]="'vin'"></app-ord-data>
 | 
				
			||||||
                </td>
 | 
					                </td>
 | 
				
			||||||
              </tr>
 | 
					              </tr>
 | 
				
			||||||
              <tr *ngIf="(showDetails$ | async) === true">
 | 
					              <tr *ngIf="(showDetails$ | async) === true">
 | 
				
			||||||
@ -297,7 +297,7 @@
 | 
				
			|||||||
                'highlight': this.address !== '' && (vout.scriptpubkey_address === this.address || (vout.scriptpubkey_type === 'p2pk' && vout.scriptpubkey.slice(2, -2) === this.address))
 | 
					                'highlight': this.address !== '' && (vout.scriptpubkey_address === this.address || (vout.scriptpubkey_type === 'p2pk' && vout.scriptpubkey.slice(2, -2) === this.address))
 | 
				
			||||||
              }">
 | 
					              }">
 | 
				
			||||||
                <td colspan="3">
 | 
					                <td colspan="3">
 | 
				
			||||||
                    <app-ord-data [runestone]="showOrdData[tx.txid + '-vout-' + vindex]['runestone']" [runeInfo]="showOrdData[tx.txid + '-vout-' + vindex]['runeInfo']" [type]="'vout'" [error]="showOrdData[tx.txid + '-vout-' + vindex]['error']"></app-ord-data>
 | 
					                    <app-ord-data [runestone]="showOrdData[tx.txid + '-vout-' + vindex]['runestone']" [runeInfo]="showOrdData[tx.txid + '-vout-' + vindex]['runeInfo']" [type]="'vout'"></app-ord-data>
 | 
				
			||||||
                </td>
 | 
					                </td>
 | 
				
			||||||
              </tr>
 | 
					              </tr>
 | 
				
			||||||
              <tr *ngIf="(showDetails$ | async) === true">
 | 
					              <tr *ngIf="(showDetails$ | async) === true">
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user