Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/serenity' into release/euphoria_…
Browse files Browse the repository at this point in the history
…20240724
  • Loading branch information
TranTrungTien committed Jul 24, 2024
2 parents b376f8b + 3445ef9 commit 106dd84
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 102 deletions.
2 changes: 1 addition & 1 deletion scripts/feature-flags/euphoria/config.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "devTest": false, "enhanceEventLog": true, "setTokenInfo": false }
{ "devTest": false, "enhanceEventLog": true, "setTokenInfo": true }
2 changes: 2 additions & 0 deletions src/app/core/pipes/newline.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export class NewlinePipe implements PipeTransform {
if (!value) return null;
let replacedValue = value;
replacedValue = replacedValue?.replace(/\n/gi, '<br/>');
replacedValue = replacedValue?.replace(/ /gi, '&nbsp;');

return this.sanitizer.bypassSecurityTrustHtml(replacedValue);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/dashboard/dashboard.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<div class="d-flex flex-column px-lg-4 flex-shrink-0 flex-grow-1">
<div class="d-flex flex-column align-items-start flex-shrink-0 flex-grow-1">
<div class="d-flex align-items-center justify-content-center py-4 px-2 py-lg-6 px-xl-6">
<img [appImg]="chainLogo" alt="chain-logo" height="36" />
<img [appImg]="tokenInfo.image" alt="chain-logo" height="36" />
<div class="h1 h2-mob mb-0 ml-4 text--white fw-700 fw-semibold-mob">
{{ nativeName | uppercase }}
</div>
Expand Down
3 changes: 1 addition & 2 deletions src/app/pages/dashboard/dashboard.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
NUMBER_6_DIGIT,
PAGE_EVENT,
TIMEOUT_ERROR,
TITLE_LOGO,
} from '../../core/constants/common.constant';
import { Globals, convertDataBlock, convertDataTransactionSimple } from '../../global/global';
import { CHART_CONFIG, DASHBOARD_AREA_SERIES_CHART_OPTIONS, DASHBOARD_CHART_OPTIONS } from './dashboard-chart-options';
Expand Down Expand Up @@ -64,7 +63,6 @@ export class DashboardComponent implements OnInit, AfterViewInit, OnDestroy {
coinInfo = this.environmentService.chainInfo.currencies[0];
bannerList = this.environmentService.banner;
coingeckoCoinId = this.environmentService.coingecko.ids[0];
chainLogo = TITLE_LOGO;
nativeName = this.environmentService.environment.nativeName;

chart: IChartApi = null;
Expand Down Expand Up @@ -95,6 +93,7 @@ export class DashboardComponent implements OnInit, AfterViewInit, OnDestroy {
priceChangePercentage24h: number;
totalVolume: number;
totalSupply: number;
image: string;
};

originalData = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,26 +82,17 @@ export class EvmTokenDetailComponent implements OnInit {
address: this.contractAddress,
};

this.tokenService.getEvmTokenDetail(payload).subscribe({
next: (res) => {
const token = res.erc20_contract[0];
if (!token) {
this.loading = false;
this.errTxt = 'No Data';
return;
}

this.tokenService.tokensMarket$
.pipe(
filter((data) => _.isArray(data)),
take(1),
)
.subscribe((item) => {

let tokenMarket = null;
if(token?.address === USDC_ADDRESS) tokenMarket = item.find((element) => element.coinId === USDC_COIN_ID);
else tokenMarket = item.find((element) => element.denom === token?.address);

this.tokenService.getTokenDetail(this.contractAddress).subscribe({
next: (tokenMarket) => {
this.tokenService.getEvmTokenDetail(payload).subscribe({
next: (res) => {
const token = res.erc20_contract[0];
if (!token) {
this.loading = false;
this.errTxt = 'No Data';
return;
}

this.tokenDetail = {
...token,
supplyAmount: token.total_supply,
Expand All @@ -119,20 +110,21 @@ export class EvmTokenDetailComponent implements OnInit {
socialProfiles: this.tokenService?.mappingSocialProfiles(tokenMarket?.socialProfiles)
};
this.getAssetsDetail();
});
},
error: (e) => {
if (e.name === TIMEOUT_ERROR) {
this.errTxt = e.message;
} else {
this.errTxt = e.status + ' ' + e.statusText;
}
this.loading = false;
},
complete: () => {
this.loading = false;
},
});
},
error: (e) => {
if (e.name === TIMEOUT_ERROR) {
this.errTxt = e.message;
} else {
this.errTxt = e.status + ' ' + e.statusText;
}
this.loading = false;
},
complete: () => {
this.loading = false;
},
});
}
})
}

getTokenDetailNFT(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { EnvironmentService } from 'src/app/core/data-services/environment.servi
import { TableTemplate } from 'src/app/core/models/common.model';
import { CommonService } from 'src/app/core/services/common.service';
import { IBCService } from 'src/app/core/services/ibc.service';
import { TokenService } from 'src/app/core/services/token.service';
import { PaginatorComponent } from 'src/app/shared/components/paginator/paginator.component';

@Component({
Expand Down Expand Up @@ -66,6 +67,7 @@ export class TransferAssetsComponent {
private ibcService: IBCService,
private commonService: CommonService,
private route: ActivatedRoute,
private tokenService: TokenService,
) {}

ngOnInit(): void {
Expand All @@ -90,9 +92,9 @@ export class TransferAssetsComponent {
type: 'send_packet',
};
this.ibcService.getTransferAsset(payload).subscribe({
next: (res) => {
next: async (res) => {
if (res.view_ibc_channel_detail_statistic?.length > 0) {
const txs = this.convertTxAssets(res.view_ibc_channel_detail_statistic);
const txs = await this.convertTxAssets(res.view_ibc_channel_detail_statistic);
this.lstSendingRaw = txs;
this.dataIBCSending.data = [...txs];
}
Expand Down Expand Up @@ -148,9 +150,9 @@ export class TransferAssetsComponent {
type: 'recv_packet',
};
this.ibcService.getTransferAsset(payload).subscribe({
next: (res) => {
next: async (res) => {
if (res.view_ibc_channel_detail_statistic?.length > 0) {
const txs = this.convertTxAssets(res.view_ibc_channel_detail_statistic);
const txs = await this.convertTxAssets(res.view_ibc_channel_detail_statistic);
this.lstSendingReceive = txs;
this.dataIBCReceiving.data = [...txs];
}
Expand Down Expand Up @@ -179,23 +181,43 @@ export class TransferAssetsComponent {
}
}

convertTxAssets(data) {
const txs = data?.map((data) => {
let denom = _.get(data, 'denom');
let dataDenom;
if (denom?.includes('/')) {
denom = 'ibc/' + sha256(denom)?.toUpperCase();
dataDenom = this.commonService.mappingNameIBC(denom);
} else {
dataDenom = { decimals: this.coinInfo.coinDecimals, symbol: denom === this.denom ? this.assetName : denom };
}
return {
amount: _.get(data, 'amount'),
denom,
dataDenom,
total_messages: _.get(data, 'total_messages'),
};
getTokenImage(denom: string) {
return new Promise((resolve) => {
this.tokenService.getTokenDetail(denom).subscribe({
next: (res) => {
resolve(res?.image);
},
error: (e) => {
resolve(null);
}
});
});
}

async convertTxAssets(data) {
const txs = await Promise.all(
data?.map(async (data) => {
let denom = _.get(data, 'denom');
let dataDenom;
if (denom?.includes('/')) {
denom = 'ibc/' + sha256(denom)?.toUpperCase();
dataDenom = this.commonService.mappingNameIBC(denom);
} else {
const image = await this.getTokenImage(denom);
dataDenom = {
decimals: this.coinInfo.coinDecimals,
symbol: denom === this.denom ? this.assetName : denom,
image,
};
}
return {
amount: _.get(data, 'amount'),
denom,
dataDenom,
total_messages: _.get(data, 'total_messages'),
};
}),
);
return txs;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export class TokenContentComponent implements OnInit {
this.tabsBackup = this.TABS;
}
}
this.tabsBackup = this.TABS;
});

if (local.getItem(STORAGE_KEYS.IS_VERIFY_TAB) == 'true') {
Expand Down
85 changes: 43 additions & 42 deletions src/app/pages/token-cosmos/token-detail/token-detail.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,48 +65,49 @@ export class TokenDetailComponent implements OnInit {
getCW20Detail(): void {
let now = new Date();
now.setDate(now.getDate() - 1);
this.tokenService.getTokenDetail(this.contractAddress).subscribe((tokenMarket) => {
this.tokenService
.getCW20Detail(this.contractAddress, this.datePipe.transform(now, DATEFORMAT.DATE_ONLY))
.subscribe({
next: (res) => {
const data = _.get(res, `smart_contract`);
if (data.length > 0) {
const token = data[0];
token.contract_address = token.address;
token.name = tokenMarket?.name || token.cw20_contract.name;
token.symbol = tokenMarket?.symbol || token.cw20_contract.symbol;
token.decimals = token.cw20_contract.decimal;
token.type = this.contractType.CW20;
token.max_total_supply = tokenMarket?.max_supply || 0;
token.price = tokenMarket?.currentPrice || 0;
token.verify_status = tokenMarket?.verifyStatus || '';
token.verify_text = tokenMarket?.verifyText || '';
token.modeToken = EModeToken.CWToken;
token.priceChangePercentage24h = tokenMarket?.priceChangePercentage24h || 0;
token.contract_verification = token.code?.code_id_verifications[0]?.verification_status;
token.supplyAmount = BigNumber(token.cw20_contract?.total_supply).dividedBy(
BigNumber(10).pow(token.decimals),
);
token.officialSite = tokenMarket?.officialSite;
token.overviewInfo = tokenMarket?.overviewInfo;
token.socialProfiles = this.tokenService?.mappingSocialProfiles(tokenMarket?.socialProfiles);

this.tokenDetail = token;
}
},
error: (e) => {
if (e.name === TIMEOUT_ERROR) {
this.errTxt = e.message;
} else {
this.errTxt = e.status + ' ' + e.statusText;
}
this.loading = false;
},
complete: () => {
this.loading = false;
},
});
this.tokenService.getTokenDetail(this.contractAddress).subscribe({
next: (tokenMarket) => {
this.tokenService
.getCW20Detail(this.contractAddress, this.datePipe.transform(now, DATEFORMAT.DATE_ONLY))
.subscribe({
next: (res) => {
const data = _.get(res, `smart_contract`);
if (data.length > 0) {
const token = data[0];
token.contract_address = token.address;
token.name = tokenMarket?.name || token.cw20_contract.name;
token.symbol = tokenMarket?.symbol || token.cw20_contract.symbol;
token.decimals = token.cw20_contract.decimal;
token.type = this.contractType.CW20;
token.max_total_supply = tokenMarket?.max_supply || 0;
token.price = tokenMarket?.currentPrice || 0;
token.verify_status = tokenMarket?.verifyStatus || '';
token.verify_text = tokenMarket?.verifyText || '';
token.modeToken = EModeToken.CWToken;
token.priceChangePercentage24h = tokenMarket?.priceChangePercentage24h || 0;
token.contract_verification = token.code?.code_id_verifications[0]?.verification_status;
token.supplyAmount = BigNumber(token.cw20_contract?.total_supply).dividedBy(
BigNumber(10).pow(token.decimals),
);
token.officialSite = tokenMarket?.officialSite;
token.overviewInfo = tokenMarket?.overviewInfo;
token.socialProfiles = this.tokenService?.mappingSocialProfiles(tokenMarket?.socialProfiles);
this.tokenDetail = token;
}
},
error: (e) => {
if (e.name === TIMEOUT_ERROR) {
this.errTxt = e.message;
} else {
this.errTxt = e.status + ' ' + e.statusText;
}
this.loading = false;
},
complete: () => {
this.loading = false;
},
});
}
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@

#contentError.line-claim-v {
-webkit-line-clamp: 3;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class EvmTransactionComponent implements OnChanges {
memo: string;
type: string;
contractAddress?: string;
inputData: { [key: string]: string };
inputData: string;
eventLog: {
id: number;
contractName?: string;
Expand Down

0 comments on commit 106dd84

Please sign in to comment.