Skip to content

Commit

Permalink
Merge pull request #2443 from aura-nw/baseline/main_20231002
Browse files Browse the repository at this point in the history
Baseline/main 20231002
  • Loading branch information
nhphuc2411 authored Oct 2, 2023
2 parents c28a3ad + 22359f0 commit 63a4c58
Show file tree
Hide file tree
Showing 134 changed files with 4,927 additions and 1,786 deletions.
2 changes: 0 additions & 2 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
"core-js",
"qrcode",
"@cosmjs/stargate",
"simplebar",
"simplebar-angular",
"@cosmjs/cosmwasm-stargate",
"@cosmjs/math",
"@cosmjs/amino",
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
"path": "^0.12.7",
"phosphor-icons": "^1.4.2",
"rxjs": "~6.6.0",
"simplebar-angular": "^2.3.4",
"socket.io-client": "^4.5.1",
"stream-browserify": "^3.0.0",
"stream-http": "^3.2.0",
Expand Down
9 changes: 5 additions & 4 deletions src/app/core/constants/account.constant.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ACCOUNT_TYPE_ENUM, ACCOUNT_WALLET_COLOR_ENUM, TabsAccount, TypeAccount, WalletAcount } from './account.enum';
import { ACCOUNT_TYPE_ENUM, ACCOUNT_WALLET_COLOR_ENUM, TabsAccount, TabsAccountLink, TypeAccount, WalletAcount } from './account.enum';

export const TYPE_ACCOUNT = [
{ label: ACCOUNT_TYPE_ENUM.All, value: TypeAccount.All },
Expand All @@ -18,7 +18,8 @@ export const ACCOUNT_WALLET_COLOR = [
];

export const TABS_TITLE_ACCOUNT = [
{ label: TabsAccount.Assets },
{ label: TabsAccount.Transactions },
{ label: TabsAccount.Stake },
{ label: TabsAccount.ExecutedTxs, value: TabsAccountLink.ExecutedTxs },
{ label: TabsAccount.AuraTxs, value: TabsAccountLink.AuraTxs },
{ label: TabsAccount.FtsTxs, value: TabsAccountLink.FtsTxs },
{ label: TabsAccount.NftTxs, value: TabsAccountLink.NftTxs },
];
19 changes: 16 additions & 3 deletions src/app/core/constants/account.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,17 @@ export enum WalletAcount {
}

export enum TabsAccount {
Assets = 'ASSETS',
Transactions = 'TRANSACTIONS',
Stake = 'STAKE',
ExecutedTxs = 'EXECUTED',
AuraTxs = 'COIN TRANSFER',
FtsTxs = 'TOKEN TRANSFER',
NftTxs = 'NFT TRANSFER',
}

export enum TabsAccountLink {
ExecutedTxs = 'execute',
AuraTxs = 'coin-transfer',
FtsTxs = 'token-transfer',
NftTxs = 'nft-transfer',
}

export enum StakeModeAccount {
Expand All @@ -64,3 +72,8 @@ export enum EAccountType {
PeriodicVestingAccount = 'cosmos-sdk/PeriodicVestingAccount',
DelayedVestingAccount = 'cosmos-sdk/DelayedVestingAccount',
}

export enum AccountTxType {
Sent = 'Sent',
Received = 'Received',
}
4 changes: 2 additions & 2 deletions src/app/core/constants/common.constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ export const TIME_OUT_CALL_API = 5000;
export const NUM_BLOCK = 10000;

export const CHART_RANGE = {
M_60: '60m',
H_24: '24h',
D_7: '7d',
D_30: '30d',
MONTH_12: '12M',
};
Expand All @@ -61,7 +61,7 @@ export const LENGTH_CHARACTER = {
TRANSACTION: 64
};

export const NULL_ADDRESS = "0".repeat(LENGTH_CHARACTER.ADDRESS);
export const NULL_ADDRESS = 'Null address';

export const TOKEN_ID_GET_PRICE = {
AURA: 'aura-network',
Expand Down
6 changes: 3 additions & 3 deletions src/app/core/helpers/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import ExcelExport from 'export-xlsx';
export function exportChart(data: any, range: string, isPrice: boolean, currDate: string) {
let type = '';
switch (range) {
case '60m':
type = 'in 60 minutes';
break;
case '24h':
type = 'in about 24 hours';
break;
case '7d':
type = 'in 7 days';
break;
case '30d':
type = 'in 30 days';
break;
Expand Down
10 changes: 8 additions & 2 deletions src/app/core/pipes/common-pipe.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
ConvertUauraToAura,
convertLogAmount,
decodeData,
displayTypeToolTip,
convertSmallNumber,
} from './common.pipe';
import { JsonPipe } from './json.pipe';

Expand All @@ -26,7 +28,9 @@ import { JsonPipe } from './json.pipe';
ReplaceIpfs,
ConvertUauraToAura,
convertLogAmount,
decodeData
decodeData,
displayTypeToolTip,
convertSmallNumber
],
imports: [CommonModule],
exports: [
Expand All @@ -40,7 +44,9 @@ import { JsonPipe } from './json.pipe';
ReplaceIpfs,
ConvertUauraToAura,
convertLogAmount,
decodeData
decodeData,
displayTypeToolTip,
convertSmallNumber
],
})
export class CommonPipeModule {}
67 changes: 67 additions & 0 deletions src/app/core/pipes/common.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import { EnvironmentService } from '../data-services/environment.service';
import { CommonService } from '../services/common.service';
import { balanceOf } from '../utils/common/parsing';
import { MaskPipe } from 'ngx-mask';
import * as _ from 'lodash';
import { TYPE_TRANSACTION } from '../constants/transaction.constant';
import { TRANSACTION_TYPE_ENUM } from '../constants/transaction.enum';

@Pipe({ name: 'calDate' })
export class pipeCalDate implements PipeTransform {
Expand Down Expand Up @@ -121,3 +124,67 @@ export class decodeData implements PipeTransform {
return atob(value);
}
}

@Pipe({ name: 'displayTypeToolTip' })
export class displayTypeToolTip implements PipeTransform {
transform(value: any): string {
let result = '';
value.forEach((element, index) => {
const typeMsg = element.type || element['@type'];
let type;
if (typeMsg === TRANSACTION_TYPE_ENUM.ExecuteContract) {
try {
let dataTemp = _.get(element, 'content.msg') || _.get(element, 'msg');
if (typeof dataTemp === 'string') {
try {
dataTemp = JSON.parse(dataTemp);
} catch (e) {}
}
let action = Object.keys(dataTemp)[0];
type = 'Contract: ' + action;
} catch (e) {}
} else {
type = _.find(TYPE_TRANSACTION, { label: typeMsg })?.value || typeMsg.split('.').pop();
}

if (index <= 4) {
if (result?.length > 0) {
result += ', ' + type;
} else {
result += type;
}
}
});
if (value?.length > 5) {
result += ', ...';
}
return result;
}
}

@Pipe({ name: 'convertSmallNumber' })
export class convertSmallNumber implements PipeTransform {
constructor() {}
transform(amount: number, decimal: number = 6): any {
let valueString = (new BigNumber(amount).toNumber() / Math.pow(10, decimal)).toString();
return displayFullNumber(valueString) !== '0.001' ? displayFullNumber(valueString) : '';
}
}

function displayFullNumber(x) {
if (Math.abs(x) < 1.0) {
var e = parseInt(x.toString().split('e-')[1]);
if (e) {
x *= Math.pow(10, e - 1);
x = '0.' + new Array(e).join('0') + x.toString().substring(2);
}
} else {
var e = parseInt(x.toString().split('+')[1]);
if (e > 20) {
e -= 20;
x /= Math.pow(10, e);
x += new Array(e + 1).join('0');
}
}
return x;
}
4 changes: 4 additions & 0 deletions src/app/core/services/soulbound.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,8 @@ export class SoulboundService extends CommonService {
getNotify(receiveAddress): Observable<any> {
return this.http.get<any>(`${this.apiUrl}/soulbound-token/notify/${receiveAddress}`);
}

countTotalABT(receiveAddress): Observable<any> {
return this.http.get<any>(`${this.apiUrl}/soulbound-token/count/${receiveAddress}`);
}
}
48 changes: 28 additions & 20 deletions src/app/core/services/token.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class TokenService extends CommonService {
address: payload?.keyword ? payload?.keyword : null,
limit: payload?.limit,
offset: payload?.offset,
date: payload?.date
date: payload?.date,
},
operationName: 'queryCW20ListToken',
})
Expand All @@ -71,7 +71,7 @@ export class TokenService extends CommonService {
if (textSearch?.length > 0) {
textSearch = '%' + textSearch + '%';
}
let querySort = `, order_by: {${payload.sort_column}: ${payload.sort_order}}`;
let querySort = `, order_by: [{${payload.sort_column}: ${payload.sort_order}}, {id: desc}]`;
const operationsDoc = `
query queryListCW721($limit: Int = 10, $offset: Int = 0, $contract_address: String = null, $name: String = null) {
${this.envDB} {
Expand Down Expand Up @@ -140,7 +140,7 @@ export class TokenService extends CommonService {
query: operationsDoc,
variables: {
address: address,
date: date
date: date,
},
operationName: 'queryCW20Detail',
})
Expand Down Expand Up @@ -235,11 +235,7 @@ export class TokenService extends CommonService {
.pipe(map((res) => (res?.data ? res?.data[this.envDB] : null)));
}

getListTokenHolder(
limit: string | number,
offset: string | number,
contractAddress: string,
): Observable<any> {
getListTokenHolder(limit: string | number, offset: string | number, contractAddress: string): Observable<any> {
const operationsDoc = `query queryCW20ListHolder($address: String, $limit: Int, $offset: Int) {
${this.envDB} {
cw20_holder(where: {cw20_contract: {smart_contract: {address: {_eq: $address}}}, amount: {_gt: "0"}}, limit: $limit, offset: $offset, order_by: {amount: desc}) {
Expand All @@ -260,16 +256,16 @@ export class TokenService extends CommonService {
`;

return this.http
.post<any>(this.graphUrl, {
query: operationsDoc,
variables: {
limit: limit,
offset: offset,
address: contractAddress,
},
operationName: 'queryCW20ListHolder',
})
.pipe(map((res) => (res?.data ? res?.data[this.envDB] : null)));
.post<any>(this.graphUrl, {
query: operationsDoc,
variables: {
limit: limit,
offset: offset,
address: contractAddress,
},
operationName: 'queryCW20ListHolder',
})
.pipe(map((res) => (res?.data ? res?.data[this.envDB] : null)));
}

getListTokenHolderNFT(payload) {
Expand Down Expand Up @@ -308,9 +304,21 @@ export class TokenService extends CommonService {
return this.http.get<any>(`${this.apiUrl}/metrics/token-market?coinId=${coinId}`);
}

getTokenMetrics({ rangeType, coinId, min, max }: { rangeType: RangeType; coinId: string; min: number; max: number }) {
getTokenMetrics({
rangeType,
coinId,
min,
max,
step,
}: {
rangeType: RangeType;
coinId: string;
min: number;
max: number;
step: number;
}) {
return this.http.get<any>(`${this.apiUrl}/metrics/token`, {
params: { rangeType, coinId, min, max },
params: { rangeType, coinId, min, max, step },
});
}

Expand Down
Loading

0 comments on commit 63a4c58

Please sign in to comment.