Skip to content

Commit

Permalink
Merge pull request #2982 from aura-nw/baseline/main_20240205
Browse files Browse the repository at this point in the history
Baseline/main 20240205
  • Loading branch information
nhphuc2411 authored Feb 5, 2024
2 parents 560a457 + ed24994 commit 5d7db46
Show file tree
Hide file tree
Showing 30 changed files with 589 additions and 536 deletions.
32 changes: 29 additions & 3 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import local from './core/utils/storage/local';
import { IUser } from './core/models/auth.models';
import { UserService } from './core/services/user.service';
import { EnvironmentService } from './core/data-services/environment.service';
import { IBCService } from './core/services/ibc.service';
import BigNumber from 'bignumber.js';

@Component({
selector: 'app-root',
Expand All @@ -31,6 +33,7 @@ export class AppComponent implements OnInit, OnDestroy {

destroyed$ = new Subject<void>();
coinMinimalDenom = this.environmentService.chainInfo.currencies[0].coinMinimalDenom;
excludedAddresses = this.environmentService.chainConfig.excludedAddresses;

constructor(
private commonService: CommonService,
Expand All @@ -42,6 +45,7 @@ export class AppComponent implements OnInit, OnDestroy {
private watchListService: WatchListService,
private userService: UserService,
private environmentService: EnvironmentService,
private ibcService: IBCService,
) {}

ngOnDestroy(): void {
Expand Down Expand Up @@ -92,8 +96,14 @@ export class AppComponent implements OnInit, OnDestroy {
}

getInfoCommon(): void {
this.commonService.status().subscribe((res) => {
getInfo(this.globals, res);
this.commonService.status().subscribe({
next: (res) => {
getInfo(this.globals, res);
this.environmentService.setLatestBlockHeight(res?.total_blocks || null);
},
error: () => {
this.environmentService.setLatestBlockHeight(null);
},
});
}

Expand Down Expand Up @@ -202,7 +212,7 @@ export class AppComponent implements OnInit, OnDestroy {
map((res) => {
const nativeData = res.find((k) => k.denom === this.coinMinimalDenom);
if (nativeData?.coin_id) {
local.setItem(STORAGE_KEYS.DATA_NATIVE, nativeData);
this.getDataNative(nativeData);
}
const listFilterIBC = res.filter((k) => k.denom !== this.coinMinimalDenom);
return listFilterIBC?.map((element) => ({
Expand All @@ -215,4 +225,20 @@ export class AppComponent implements OnInit, OnDestroy {
local.setItem(STORAGE_KEYS.LIST_TOKEN_IBC, listTokenIBC);
});
}

async getDataNative(nativeData) {
const tempTotal = await this.ibcService.getTotalSupplyLCD(this.coinMinimalDenom).catch(() => '0');
let totalSupply = BigNumber(_.get(tempTotal, 'data.amount.amount') || '0');

this.tokenService
.getListAmountNative(this.excludedAddresses)
.pipe(takeUntil(this.destroyed$))
.subscribe((res) => {
res?.data?.forEach((item) => {
totalSupply = totalSupply.minus(BigNumber(_.get(item, 'amount')));
});
nativeData['totalSupply'] = totalSupply.toFixed();
local.setItem(STORAGE_KEYS.DATA_NATIVE, nativeData);
});
}
}
15 changes: 7 additions & 8 deletions src/app/core/data-services/environment.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface IConfiguration {
nativeName: string;
};
chainConfig: {
excludedAddresses: string[];
stakingTime: string;
blockTime: number;
quotaSetPrivateName: number;
Expand Down Expand Up @@ -72,8 +73,9 @@ export class EnvironmentService {
configUri = './assets/config/config.json';
isMobile = false;
isNativeApp = false;
bondedTokensPoolAddress = null;
excludedAddresses = null;
config: BehaviorSubject<IConfiguration> = new BehaviorSubject(null);
latestBlockHeight$ = new BehaviorSubject<number | string>(undefined);

get configValue(): IConfiguration {
return this.config?.value;
Expand Down Expand Up @@ -149,6 +151,10 @@ export class EnvironmentService {
return _.get(this.configValue, 'api.coingecko');
}

setLatestBlockHeight(value: string | number) {
this.latestBlockHeight$.next(value);
}

destroyed$ = new Subject<void>();
breakpoint$ = this.layout.observe([Breakpoints.Small, Breakpoints.XSmall]).pipe(takeUntil(this.destroyed$));
constructor(
Expand Down Expand Up @@ -189,7 +195,6 @@ export class EnvironmentService {
await this.extendsTxType();

this.getNodeInfo();
this.getBondedAddress();
}

extendsTxType(): Promise<void> {
Expand Down Expand Up @@ -223,10 +228,4 @@ export class EnvironmentService {
} catch {}
}
}

getBondedAddress() {
this.http.get(`${this.chainInfo.rest}/${LCD_COSMOS.MODULE_ACCOUNTS}/bonded_tokens_pool`).subscribe((res: any) => {
this.bondedTokensPoolAddress = _.get(res, 'account.base_account.address');
});
}
}
4 changes: 4 additions & 0 deletions src/app/core/helpers/wallet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const isCoin98Browser = () => (window as any)?.coin98?.isMobile;
export const isLeapBrowser = () => (window as any)?.leap?.mode?.includes('mobile');
export const isKeplrBrowser = () => (window as any)?.keplr?.mode?.includes('mobile');
export const isMobileBrowser = () => isCoin98Browser() || isLeapBrowser() || isKeplrBrowser();
7 changes: 7 additions & 0 deletions src/app/core/services/block.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export class BlockService extends CommonService {
hash
height
time
tx_count
}
}
}
Expand Down Expand Up @@ -66,6 +67,7 @@ export class BlockService extends CommonService {
hash
height
time
tx_count
}
}
}
Expand Down Expand Up @@ -99,6 +101,7 @@ export class BlockService extends CommonService {
hash
height
time
tx_count
}
}
}
Expand All @@ -114,4 +117,8 @@ export class BlockService extends CommonService {
})
.pipe(map((res) => (res?.data ? res?.data[this.envDB] : null)));
}

getRawData(url): Observable<any> {
return this.http.get<any>(url);
}
}
6 changes: 5 additions & 1 deletion src/app/core/services/contract.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ export class ContractService extends CommonService {
filterName = `, ${filterName}`;
typeQuery = contractType?.includes(FILTER_ALL)
? `_or: [{code: {_or: [{type: {_in: $type}}, {_and: {type: {_is_null: true}}}]}}, {name: {_eq: "crates.io:cw4973"}}],`
: `_and: [{code: {type: {_in: $type}}}, {name: {_eq: "crates.io:cw4973"}}],`;
: (() => {
// CW4973 is CW721 Type
contractType = [ContractRegisterType.CW721];
return `_and: [{code: {type: {_in: $type}}}, {name: {_eq: "crates.io:cw4973"}}],`;
})();
}
} else if (
contractType?.includes(ContractRegisterType.CW721) ||
Expand Down
21 changes: 17 additions & 4 deletions src/app/core/services/token.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export class TokenService extends CommonService {
nativePrice$ = new BehaviorSubject<number>(null);
filterBalanceNative$ = new BehaviorSubject<number>(null);
totalTransfer$ = new BehaviorSubject<number>(null);
excludedAddresses = this.environmentService.chainConfig.excludedAddresses;

get tokensMarket() {
return this.tokensMarket$.getValue();
Expand All @@ -35,7 +36,7 @@ export class TokenService extends CommonService {
}

setTotalTransfer(value: number) {
this.totalTransfer$.next(value)
this.totalTransfer$.next(value);
}

constructor(
Expand Down Expand Up @@ -455,6 +456,7 @@ export class TokenService extends CommonService {
from
to
sender
height
cw20_contract {
smart_contract {
address
Expand Down Expand Up @@ -616,11 +618,17 @@ export class TokenService extends CommonService {
.pipe(map((res) => (res?.data ? res?.data[this.envDB] : null)));
}

getDenomHolder(payload: { denomHash: string; limit?: number; offset?: number; address?: string }): Observable<any> {
getDenomHolder(payload: {
denomHash: string;
limit?: number;
offset?: number;
address?: string;
isExcludedAddresses?: boolean;
}): Observable<any> {
const operationsDoc = `
query queryHolderIBC($denom: String = null, $limit: Int = null, $offset: Int = null, $address: String = null) {
query queryHolderIBC($denom: String = null, $limit: Int = null, $offset: Int = null, $address: String = null, $addressNotIn: [String!] = null) {
${this.envDB} {
account_balance(where: {account: {address: {_eq: $address}}, denom: {_eq: $denom}}, limit: $limit, offset: $offset, order_by: {amount: desc}) {
account_balance(where: {account: {address: {_eq: $address, _nin: $addressNotIn}}, denom: {_eq: $denom}}, limit: $limit, offset: $offset, order_by: {amount: desc}) {
account {
address
}
Expand All @@ -642,6 +650,7 @@ export class TokenService extends CommonService {
address: payload.address,
limit: payload.limit || 100,
offset: payload.offset || 0,
addressNotIn: payload.isExcludedAddresses ? this.excludedAddresses : [],
},
operationName: 'queryHolderIBC',
})
Expand All @@ -655,4 +664,8 @@ export class TokenService extends CommonService {
getAmountNative(address: string): Observable<any> {
return this.http.get<any>(`${this.apiUrl}/account/${address}`).pipe(catchError((_) => of([])));
}

getListAmountNative(address: string[]): Observable<any> {
return this.http.get<any>(`${this.apiUrl}/account/list/${address}`).pipe(catchError((_) => of([])));
}
}
11 changes: 4 additions & 7 deletions src/app/core/services/wallet.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ import { getSigner } from 'src/app/core/utils/signing/signer';
import { createSignBroadcast, getNetworkFee } from 'src/app/core/utils/signing/transaction-manager';
import { WalletBottomSheetComponent } from 'src/app/shared/components/wallet-connect/wallet-bottom-sheet/wallet-bottom-sheet.component';
import { WalletListComponent } from 'src/app/shared/components/wallet-connect/wallet-list/wallet-list.component';
import { STORAGE_KEYS } from '../constants/common.constant';
import { ESigningType, WALLET_PROVIDER } from '../constants/wallet.constant';
import { EnvironmentService } from '../data-services/environment.service';
import { isMobileBrowser } from '../helpers/wallet';
import { WalletStorage } from '../models/wallet';
import { getLastProvider, getSigningType } from '../utils/common/info-common';
import { getKeplr, handleErrors } from '../utils/keplr';
import local from '../utils/storage/local';
import { NgxToastrService } from './ngx-toastr.service';
import { STORAGE_KEYS } from '../constants/common.constant';

export type WalletKey = Partial<Key> | AccountResponse;

Expand Down Expand Up @@ -288,7 +289,7 @@ export class WalletService implements OnDestroy {
const lastProvider = getLastProvider();
const signingType = getSigningType(lastProvider);

if (this.isMobileMatched && !this.checkExistedCoin98() && lastProvider != WALLET_PROVIDER.LEAP) {
if (this.isMobileMatched && !isMobileBrowser()) {
const msgs = messageCreators[messageType](senderAddress, message, network);
let fee;
if (this.coin98Client) {
Expand Down Expand Up @@ -387,10 +388,6 @@ export class WalletService implements OnDestroy {
);
}

signMessage(base64String: string) {
return this.coin98Client.signArbitrary(this.wallet.bech32Address, base64String);
}

async execute(userAddress, contract_address, msg, feeGas = null) {
let signer;
let gasStep = this.chainInfo?.gasPriceStep?.average || 0.0025;
Expand Down Expand Up @@ -418,7 +415,7 @@ export class WalletService implements OnDestroy {

const lastProvider = getLastProvider();

if (this.isMobileMatched && !this.checkExistedCoin98() && lastProvider != WALLET_PROVIDER.LEAP) {
if (this.isMobileMatched && !isMobileBrowser()) {
return this.coin98Client.execute(userAddress, contract_address, msg, '', undefined, fee, undefined);
} else {
let signingType: ESigningType = getSigningType(lastProvider);
Expand Down
2 changes: 1 addition & 1 deletion src/app/global/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ export function convertDataBlock(data) {
const block = _.get(data, 'block').map((element) => {
const height = _.get(element, 'height');
const block_hash = _.get(element, 'hash');
const num_txs = _.get(element, 'txs.length') || _.get(element, 'data.block.data.txs.length') || 0;
const num_txs = _.get(element, 'tx_count') || 0;
const proposer = _.get(element, 'validator.description.moniker');
const operator_address = _.get(element, 'validator.operator_address');
const timestamp = _.get(element, 'time');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,10 @@ <h3 class="mb-3 fw-700 text--gray-light-2 mb-xl-0">Fungible Tokens ({{ pageData?
<td mat-cell *matCellDef="let element">
<div class="d-flex align-items-center">
<div>
<img *ngIf="element?.image" [src]="element?.image" class="image-token" alt="" />
<img *ngIf="!element?.image" [src]="defaultLogoAura" class="image-token" alt="" />
<img [appImg]="element?.image" [defaultImage]="defaultLogoAura" class="image-token" alt="" />
</div>
<div>
<a
class="d-flex align-items-center"
[routerLink]="['/tokens/token', element.contract_address]"
*ngIf="element.contract_address !== '-'">
<a class="d-flex align-items-center" [routerLink]="['/tokens/token', element.tokenUrl]">
<div class="d-flex align-items-center">
<div class="ml-2 body-03 fw-semibold">
{{ element.name | ellipsis: 30 }}
Expand All @@ -128,25 +124,6 @@ <h3 class="mb-3 fw-700 text--gray-light-2 mb-xl-0">Fungible Tokens ({{ pageData?
</div>
</div>
</a>
<div class="d-flex align-items-center" *ngIf="element.contract_address === '-'">
<div class="ml-2 body-03 fw-semibold">
{{ element.name | ellipsis: 19 }}
</div>

<div class="aura-tooltip-contain">
<div class="status cursor-pointer aura-tooltip-object">
<img
[src]="'assets/images/icons/circle-wavy-check.png' | imageS3"
alt=""
width="18"
height="18"
class="ml-1"
*ngIf="element.verify_status === 'VERIFIED'" />
</div>
<app-tooltip-customize [content]="element.verify_text || 'Verified by Aura Network'">
</app-tooltip-customize>
</div>
</div>
<span class="ml-2">{{ element.symbol }}</span>
</div>
</div>
Expand Down Expand Up @@ -250,10 +227,7 @@ <h3 class="mb-3 fw-700 text--gray-light-2 mb-xl-0">Fungible Tokens ({{ pageData?
{{ '< $0.01' }}
</div>
<ng-container *ngIf="element.value | gte: '0.01'">
<span
[appBigNumber]="element.balance"
[tokenPrice]="element.price"
[decimal]="0"></span>
<span [appBigNumber]="element.balance" [tokenPrice]="element.price" [decimal]="0"></span>
</ng-container>
</div>
<app-tooltip-customize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@

@media (max-width: 991.99px) {
.aura-table.coin-table td.mat-cell:nth-child(1),
.aura-table.coin-table td.mat-cell:nth-child(2) {
.aura-table.coin-table td.mat-cell:nth-child(2),
.aura-table.coin-table td.mat-cell:nth-child(3) {
min-width: 200px;
}
.aura-table.coin-table td.mat-cell:nth-child(3),
.aura-table.coin-table td.mat-cell:nth-child(4),
.aura-table.coin-table td.mat-cell:nth-child(5) {
min-width: 120px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,16 @@ export class TokenTableComponent implements OnChanges {
(item) => item.name?.toLowerCase().includes(txtSearch.toLowerCase()) || item.contract_address == txtSearch,
);
}

// Mapping token Url to navigare token detail page for Ibc and Native
searchList.map((token) => ({
...token,
tokenUrl:
(token?.type !== 'cw20'
? token.denom?.replace('ibc/', '') // Ibc and native link
: token.contract_address) || '',
}));

this.dataSource.data = [...searchList];
} else {
this.accountService.getAssetCW20ByOwner(payload).subscribe({
Expand All @@ -137,7 +147,16 @@ export class TokenTableComponent implements OnChanges {
return data;
});

lstToken = lstToken?.filter((k) => k?.symbol);
lstToken = lstToken
?.filter((k) => k?.symbol)
// Mapping token Url to navigare token detail page for Ibc and Native
.map((token) => ({
...token,
tokenUrl:
(token?.type !== 'cw20'
? token.denom?.replace('ibc/', '') // Ibc and native link
: token.contract_address) || '',
}));
// store datatable
this.dataTable = lstToken;
// Sort and slice 20 frist record.
Expand Down
Loading

0 comments on commit 5d7db46

Please sign in to comment.