Skip to content

Commit

Permalink
Add ui for NFT (#52)
Browse files Browse the repository at this point in the history
* Add ui for NFT

* rename contracts folders and classes to be similar to the contract name
  • Loading branch information
dangershony authored Apr 1, 2022
1 parent be5b765 commit fcbf4ca
Show file tree
Hide file tree
Showing 11 changed files with 254 additions and 19 deletions.
21 changes: 14 additions & 7 deletions src/Blockcore.Explorer/ClientApp/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ import { ContractCodeComponent } from './explorer/contract-code/contract-code.co
import { MempoolComponent } from './explorer/mempool/mempool.component';
import { SearchGlobalComponent } from './search-global/search-global.component';
import { OrphansComponent } from './explorer/orphans/orphans.component';
import { ContractDaoComponent } from "./explorer/contract-dao/contract-dao.component";
import { ContractTokenComponent } from './explorer/contract-token/contract-token.component';
import { ContractDaoContractComponent } from "./explorer/contract-daocontract/contract-daocontract.component";
import { ContractStandardTokenComponent } from './explorer/contract-standardtoken/contract-standardtoken.component';
import { ContractListComponent } from './explorer/contract-list/contract-list.component';
import { ContractListByTypeComponent } from './explorer/contract-listbytype/contract-listbytype.component';
import { ContractNonFungibleTokenComponent } from './explorer/contract-nonfungibletoken/contract-nonfungibletoken.component';

const routes: Routes = [
{
Expand Down Expand Up @@ -134,12 +135,12 @@ const routes: Routes = [
}
},
{
path: ':chain/explorer/contract-dao/:address', component: ContractDaoComponent, resolve: {
path: ':chain/explorer/contract-daocontract/:address', component: ContractDaoContractComponent, resolve: {
chain: LoadingResolverService
}
},
{
path: ':chain/explorer/contract-token/:address', component: ContractTokenComponent, resolve: {
path: ':chain/explorer/contract-standardtoken/:address', component: ContractStandardTokenComponent, resolve: {
chain: LoadingResolverService
}
},
Expand All @@ -153,6 +154,11 @@ const routes: Routes = [
chain: LoadingResolverService
}
},
{
path: ':chain/explorer/contract-nonfungibletoken/:address', component: ContractNonFungibleTokenComponent, resolve: {
chain: LoadingResolverService
}
},
];

@NgModule({
Expand Down Expand Up @@ -191,10 +197,11 @@ const routes: Routes = [
ContractAddressComponent,
ContractCodeComponent,
OrphansComponent,
ContractDaoComponent,
ContractTokenComponent,
ContractDaoContractComponent,
ContractStandardTokenComponent,
ContractListComponent,
ContractListByTypeComponent
ContractListByTypeComponent,
ContractNonFungibleTokenComponent
],
imports: [
BrowserModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,24 @@ export class ContractAddressComponent implements OnInit, OnDestroy {
if (this.transaction.contractCodeType == "DAOContract") {

this.contractCodeTypeLink = true;
this.contractCodeTypeLinkPath = "contract-dao";
this.contractCodeTypeLinkPath = "contract-" + this.transaction.contractCodeType.toLowerCase();
this.contractCodeTypeLinkParam = this.transaction.contractAddress;
}

if (this.transaction.contractCodeType == "StandardToken") {

this.contractCodeTypeLink = true;
this.contractCodeTypeLinkPath = "contract-token";
this.contractCodeTypeLinkPath = "contract-" + this.transaction.contractCodeType.toLowerCase();
this.contractCodeTypeLinkParam = this.transaction.contractAddress;
}

if (this.transaction.contractCodeType == "NonFungibleToken") {

this.contractCodeTypeLink = true;
this.contractCodeTypeLinkPath = "contract-" + this.transaction.contractCodeType.toLowerCase() ;
this.contractCodeTypeLinkParam = this.transaction.contractAddress;
}

}

async updateTransactions(url) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import {ActivatedRoute, Router} from "@angular/router";
import {SetupService} from "../../services/setup.service";

@Component({
selector: 'app-contract-dao-component',
templateUrl: './contract-dao.component.html'
selector: 'app-contract-daocontract-component',
templateUrl: './contract-daocontract.component.html'
})

export class ContractDaoComponent implements OnInit,OnDestroy{
export class ContractDaoContractComponent implements OnInit,OnDestroy{
daoContract: any;
deposits: any;
proposals: any;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<app-search></app-search>

<div class="box">
<div *ngIf="transaction">
<div class="grid-hash">
<div>
<span class="grid-hash-left"><i class="fas fa-hashtag"></i></span>
<span class="grid-hash-middle breakable">{{transaction.contractAddress}}</span>
<span class="grid-hash-right">
<div class="grid-double">
</div>
</span>
</div>
</div>
</div>
</div>

<div class="box">

<h3><i class="fas fa-receipt"></i>&nbsp;&nbsp;Non Fungible Token Details</h3>

<app-progress class="centered" *ngIf="!transaction"></app-progress>
<app-error class="centered" [error]="error"></app-error>

<div class="grid-label-value" *ngIf="transaction">


<div>
<span>Token name</span>
<span>{{transaction.name }}</span>
</div>
<div>
<span>Token symbol</span>
<span>{{transaction.symbol}}</span>
</div>
<div>
<span>Owner Only Minting</span>
<span>{{transaction.ownerOnlyMinting | yes }}</span>
</div>
<div>
<span>Contract Type</span>
<span>{{transaction.contractType}}</span>
</div>
<div>
<span>Owner</span>
<span><a [routerLink]="['../../contract-address', transaction.contractAddress, transaction.owner]">{{transaction.owner}}</a></span>
</div>
<div>
<span>Contract Address</span>
<span><a [routerLink]="['../../contract-address', transaction.contractAddress]">{{transaction.contractAddress}}</a></span>
</div>
<div>
<span>Created on Transaction</span>
<span><a [routerLink]="['../../','contract-transaction', transaction.contractCreateTransactionId]">{{transaction.contractCreateTransactionId | slice:0:20}}</a></span>
</div>

<div *ngIf="transaction.error">
<span>Error</span>
<span>{{transaction.error}}</span>
</div>

</div>
</div>

<div class="box">

<h3>Tokens</h3>

<app-progress class="centered" *ngIf="!transactions">Loading transactions...</app-progress>

<div *ngIf="errorTransactions">
<span class="muted">Error: </span> <span class="negative">{{errorTransactions.title}}</span><br><br>
{{errorTransactions.errors | json}}
</div>

<div *ngIf="transactions">

<div class="scrollable " style="max-height:500px" appDetectScroll [bottomOffset]="400" [topOffset]="500">
<div class="grid-list-contract-nft" *ngFor="let item of transactions">

<span class="left">Token Id: {{item.id}}</span>
<span class="left">Burned: {{item.isBurned | yes }}</span>
<span class="left"><a [routerLink]="['../../','address', item.owner]">{{item.owner }}</a></span>
<span class="left">{{item.uri}}</span>

<div class="box left">
<h3>Sales History</h3>
<span><pre style="max-width: 1270px; overflow: auto;">{{item.salesHistory | json}}</pre></span>

</div>

</div>

<br>
<app-progress class="centered" *ngIf="loading">Loading more transactions...</app-progress>
</div>
</div>

</div>


Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import { Component, HostBinding, OnInit, OnDestroy, HostListener } from '@angular/core';
import { ActivatedRoute, Route, Router } from '@angular/router';
import { ApiComponent } from 'src/app/api/api.component';
import { ApiService, HttpError } from 'src/app/services/api.service';
import { SetupService } from 'src/app/services/setup.service';
import { ScrollEvent } from 'src/app/shared/scroll.directive';

@Component({
selector: 'app-contract-nonfungibletoken-component',
templateUrl: './contract-nonfungibletoken.component.html'
})
export class ContractNonFungibleTokenComponent implements OnInit, OnDestroy {
@HostBinding('class.content-centered-top') hostClass = true;

info: any;
node: any;
blockchain: any;
network: any;
configuration: any;
consensus: any;
peers: any;
blocks: any;
transactions: any;
transaction: any;

contractCodeTypeLink = false;
contractCodeTypeLinkPath: any;
contractCodeTypeLinkParam: any;

timerInfo: any;
timerBlocks: any;
timerTransactions: any;
address: any;
filterAddress: any;
balance: any;
detailsVisible = false;
lastBlockHeight: number;
subscription: any;
limit = 10;
loading = false;
count = 0;
total: any;
link: string;
error: any;
errorTransactions: any;
navPath: any;

constructor(
private api: ApiService,
private router: Router,
public setup: SetupService,
private activatedRoute: ActivatedRoute) {

this.activatedRoute.paramMap.subscribe(async params => {
const id: any = params.get('address');
console.log('Address:', id);

const idFilter: any = params.get('filterAddress');
console.log('filterAddress:', idFilter);

this.transactions = null;
this.address = id;
this.filterAddress = idFilter;

try {
this.transaction = await this.api.getContractNonFungibleTokenTransaction(id);
this.transactions = this.transaction.tokens;

} catch (err) {
if (err.message[0] === '{') {
this.error = JSON.parse(err.message);
} else {
this.error = err;
}
}
});
}

amount(outputs: any[]) {
const filteredOutputs = outputs.filter(o => o.address === this.address);
const amount = filteredOutputs.reduce((acc, item) => acc + item.balance, 0);

return amount;
}

async ngOnInit() {

}

toggleDetails() {
this.detailsVisible = !this.detailsVisible;
}

ngOnDestroy(): void {

}
}

Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { SetupService } from 'src/app/services/setup.service';
import { ScrollEvent } from 'src/app/shared/scroll.directive';

@Component({
selector: 'app-contract-token-component',
templateUrl: './contract-token.component.html'
selector: 'app-contract-standardtoken-component',
templateUrl: './contract-standardtoken.component.html'
})
export class ContractTokenComponent implements OnInit, OnDestroy {
export class ContractStandardTokenComponent implements OnInit, OnDestroy {
@HostBinding('class.content-centered-top') hostClass = true;

info: any;
Expand Down Expand Up @@ -63,7 +63,7 @@ export class ContractTokenComponent implements OnInit, OnDestroy {
this.filterAddress = idFilter;

try {
this.transaction = await this.api.getContractTokenTransaction(id);
this.transaction = await this.api.getContractStandardTokenTransaction(id);
this.transactions = this.transaction.tokenHolders;

} catch (err) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,24 @@ export class ContractTransactionComponent implements OnInit, OnDestroy {
if (this.transaction.contractCodeType == "DAOContract") {

this.contractCodeTypeLink = true;
this.contractCodeTypeLinkPath = "contract-dao";
this.contractCodeTypeLinkPath = "contract-" + this.transaction.contractCodeType.toLowerCase();
this.contractCodeTypeLinkParam = contractAddress;
}

if (this.transaction.contractCodeType == "StandardToken") {

this.contractCodeTypeLink = true;
this.contractCodeTypeLinkPath = "contract-token";
this.contractCodeTypeLinkPath = "contract-" + this.transaction.contractCodeType.toLowerCase();
this.contractCodeTypeLinkParam = contractAddress;
}

if (this.transaction.contractCodeType == "NonFungibleToken") {

this.contractCodeTypeLink = true;
this.contractCodeTypeLinkPath = "contract-" + this.transaction.contractCodeType.toLowerCase();
this.contractCodeTypeLinkParam = contractAddress;
}

}
}

Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,19 @@ export class ApiService {
return this.downloadRelative('/query/cirrus/contract/dao/' + address);
}

async getContractTokenTransaction(address: string) {
async getContractStandardTokenTransaction(address: string) {
return this.downloadRelative('/query/cirrus/contract/standardtoken/' + address);
}

async getContractList() {
return this.downloadRelative('/query/cirrus/contract/list/');
}

async getContractNonFungibleTokenTransaction(address: string) {
return this.downloadRelative('/query/cirrus/contract/nonfungibletoken/' + address);
}


parseLinkHeader(linkHeader: string) {
const sections = linkHeader.split(', ');
//const links: Record<string, string> = { };
Expand Down
8 changes: 8 additions & 0 deletions src/Blockcore.Explorer/ClientApp/src/styles/blockcore.scss
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,14 @@ footer {
grid-template-columns: auto auto;
}

.grid-list-contract-nft {
font-size: 0.75em;
margin: 1em;
display: grid;
gap: 0.6em;
grid-template-columns: 100%;
}

.grid-list-contract-list {
font-size: 0.75em;
margin: 1em;
Expand Down

0 comments on commit fcbf4ca

Please sign in to comment.