From f72d86806c267777504cb483a94c2271accf5a34 Mon Sep 17 00:00:00 2001
From: TranTrungTien <71311738+TranTrungTien@users.noreply.github.com>
Date: Wed, 10 Jul 2024 12:02:29 +0700
Subject: [PATCH] [Fix][589] Fix set token info (#3603)
* [fix][598] fix set token info
* fix: token info (10 -> 29)
* fix: default native image
---
src/app/core/constants/token.constant.ts | 38 ++++++-------
.../data-services/api-cw20-token.service.ts | 3 +-
src/app/core/pipes/custom-pipe.module.ts | 3 ++
src/app/core/pipes/newline.pipe.ts | 14 +++++
src/app/core/services/token.service.ts | 15 +++---
.../evm-token-info-tab.component.html | 4 +-
.../evm-token-content.component.ts | 14 +++--
.../evm-token-detail.component.html | 2 +-
.../evm-token-summary.component.scss | 2 +
.../token-info-tab.component.html | 4 +-
.../token-detail/token-detail.component.html | 2 +-
.../token-detail/token-detail.component.ts | 54 +++++++++----------
.../token-summary.component.scss | 2 +-
13 files changed, 89 insertions(+), 68 deletions(-)
create mode 100644 src/app/core/pipes/newline.pipe.ts
diff --git a/src/app/core/constants/token.constant.ts b/src/app/core/constants/token.constant.ts
index 4a5779554..57191b478 100644
--- a/src/app/core/constants/token.constant.ts
+++ b/src/app/core/constants/token.constant.ts
@@ -51,14 +51,30 @@ export enum ETokenNFTTypeBE {
export const TOKEN_EVM_BURNT = '0x0000000000000000000000000000000000000000';
export const SOCIAL_MEDIA = {
- github: {
- name: 'github',
- icon: 'assets/icons/icons-svg/basic/github.svg',
+ youtube: {
+ name: 'youtube',
+ icon: 'assets/icons/icons-svg/basic/youtube.svg',
},
twitter: {
name: 'twitter',
icon: 'assets/icons/icons-svg/basic/twitter.svg',
},
+ discord: {
+ name: 'discord',
+ icon: 'assets/icons/icons-svg/basic/discord.svg',
+ },
+ telegram: {
+ name: 'telegram',
+ icon: 'assets/icons/icons-svg/basic/telegram.svg',
+ },
+ linkedin: {
+ name: 'linkedin',
+ icon: 'assets/icons/icons-svg/basic/linkedIn.svg',
+ },
+ github: {
+ name: 'github',
+ icon: 'assets/icons/icons-svg/basic/github.svg',
+ },
facebook: {
name: 'facebook',
icon: 'assets/icons/icons-svg/basic/fb-circle.svg',
@@ -67,26 +83,10 @@ export const SOCIAL_MEDIA = {
name: 'medium',
icon: 'assets/icons/icons-svg/basic/medium.svg',
},
- telegram: {
- name: 'telegram',
- icon: 'assets/icons/icons-svg/basic/telegram.svg',
- },
- youtube: {
- name: 'youtube',
- icon: 'assets/icons/icons-svg/basic/youtube.svg',
- },
otherWebsite: {
name: 'otherWebsite',
icon: 'assets/icons/icons-svg/basic/global.svg',
},
- discord: {
- name: 'discord',
- icon: 'assets/icons/icons-svg/basic/discord.svg',
- },
- linkedin: {
- name: 'linkedin',
- icon: 'assets/icons/icons-svg/basic/linkedIn.svg',
- },
};
export const USDC_ADDRESS = '0x80b5a32e4f032b2a058b4f29ec95eefeeb87adcd';
diff --git a/src/app/core/data-services/api-cw20-token.service.ts b/src/app/core/data-services/api-cw20-token.service.ts
index 34c30f862..4a2f15a4e 100644
--- a/src/app/core/data-services/api-cw20-token.service.ts
+++ b/src/app/core/data-services/api-cw20-token.service.ts
@@ -217,12 +217,13 @@ export class ApiCw20TokenService {
parseNativeToken(account, coinsMarkets) {
const nativeId = this.env.coingecko.ids[0];
const coinMarket = coinsMarkets.find((coin) => coin.coinId === nativeId);
+
return {
name: this.env.chainName,
symbol: this.currencies.coinDenom,
decimals: this.currencies.coinDecimals,
denom: this.currencies.coinMinimalDenom,
- image: this.currencies.coinImageUrl,
+ image: this.currencies.coinImageUrl || coinMarket?.image,
contract_address: '-',
balance: account.data.total,
price: coinMarket?.currentPrice || 0,
diff --git a/src/app/core/pipes/custom-pipe.module.ts b/src/app/core/pipes/custom-pipe.module.ts
index 37e1b09ea..8e7c42f45 100644
--- a/src/app/core/pipes/custom-pipe.module.ts
+++ b/src/app/core/pipes/custom-pipe.module.ts
@@ -14,6 +14,7 @@ import { ObjectKeysPipe } from './object-keys.pipe';
import { CombineTxsMsgPipe, EllipsisPipe } from './string.pipe';
import { NameTagTooltipPipe } from './tooltip.pipe';
import { HighlightFunctionPipe } from './highlight-function.pipe';
+import { NewlinePipe } from './newline.pipe';
@NgModule({
imports: [CommonModule],
@@ -43,6 +44,7 @@ import { HighlightFunctionPipe } from './highlight-function.pipe';
CapacityPipe,
EvmAddressPipe,
HighlightFunctionPipe,
+ NewlinePipe
],
exports: [
JsonPipe,
@@ -70,6 +72,7 @@ import { HighlightFunctionPipe } from './highlight-function.pipe';
CapacityPipe,
EvmAddressPipe,
HighlightFunctionPipe,
+ NewlinePipe
],
providers: [],
})
diff --git a/src/app/core/pipes/newline.pipe.ts b/src/app/core/pipes/newline.pipe.ts
new file mode 100644
index 000000000..61052a3e0
--- /dev/null
+++ b/src/app/core/pipes/newline.pipe.ts
@@ -0,0 +1,14 @@
+import { Pipe, PipeTransform } from '@angular/core';
+import { DomSanitizer } from '@angular/platform-browser';
+
+@Pipe({ name: 'newline' })
+export class NewlinePipe implements PipeTransform {
+ constructor(private sanitizer: DomSanitizer) {}
+ transform(value: string) {
+ if (!value) return null;
+ let replacedValue = value;
+ replacedValue = replacedValue?.replace(/\n/gi, '
');
+ return this.sanitizer.bypassSecurityTrustHtml(replacedValue);
+ }
+}
+
diff --git a/src/app/core/services/token.service.ts b/src/app/core/services/token.service.ts
index 1f2f16b15..7c5d0548b 100644
--- a/src/app/core/services/token.service.ts
+++ b/src/app/core/services/token.service.ts
@@ -968,14 +968,17 @@ export class TokenService extends CommonService {
mappingSocialProfiles(socialProfiles: { [key: string]: string }) {
if (!socialProfiles) return [];
- return Object.keys(socialProfiles)
- ?.filter((key) => socialProfiles[key])
- ?.map((key) => {
- return {
+ const socialMapping = [];
+ Object.keys(SOCIAL_MEDIA).forEach((key) => {
+ if (socialProfiles[key]) {
+ const social = {
name: SOCIAL_MEDIA[key]?.name,
icon: SOCIAL_MEDIA[key]?.icon,
url: socialProfiles[key],
- };
- });
+ }
+ socialMapping.push(social);
+ }
+ })
+ return socialMapping;
}
}
diff --git a/src/app/pages/evm-token/evm-token-content/evm-token-content-tab/evm-token-info-tab/evm-token-info-tab.component.html b/src/app/pages/evm-token/evm-token-content/evm-token-content-tab/evm-token-info-tab/evm-token-info-tab.component.html
index 6c4707ec1..a74a7cce9 100644
--- a/src/app/pages/evm-token/evm-token-content/evm-token-content-tab/evm-token-info-tab/evm-token-info-tab.component.html
+++ b/src/app/pages/evm-token/evm-token-content/evm-token-content-tab/evm-token-info-tab/evm-token-info-tab.component.html
@@ -1,6 +1,4 @@