Skip to content

Commit

Permalink
Merge pull request #2247 from aura-nw/baseline/main_20230822
Browse files Browse the repository at this point in the history
Baseline/main 20230822
  • Loading branch information
nhphuc2411 authored Aug 22, 2023
2 parents 2d36e6b + 6944aae commit 4ebda3e
Show file tree
Hide file tree
Showing 149 changed files with 2,710 additions and 932 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
"@ngx-translate/core": "^13.0.0",
"@ngx-translate/http-loader": "^6.0.0",
"@popperjs/core": "^2.11.4",
"@types/google-one-tap": "^1.2.2",
"@types/google.accounts": "^0.0.7",
"@types/lodash": "^4.14.184",
"angularx-qrcode": "^12.0.3",
"apexcharts": "^3.28.3",
Expand Down
6 changes: 6 additions & 0 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ const routes: Routes = [
path: 'community-pool',
loadChildren: () => import('./pages/community-pool/community-pool.module').then((m) => m.CommunityPoolModule),
},
{ path: 'login', loadChildren: () => import('./pages/login/login.module').then((m) => m.LoginModule) },
{ path: 'user', loadChildren: () => import('./pages/login/login.module').then((m) => m.LoginModule) },
{
path: 'profile',
loadChildren: () => import('./pages/profile/profile.module').then((m) => m.ProfileModule),
},
],
},
{ path: 'account', loadChildren: () => import('./pages/account/account.module').then((m) => m.AccountModule) },
Expand Down
6 changes: 2 additions & 4 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ export class AppComponent implements OnInit {
constructor(
private commonService: CommonService,
private globals: Globals,
private tokenService: TokenService,
) // private env: EnvironmentService
{}
private tokenService: TokenService, // private env: EnvironmentService
) {}
ngOnInit(): void {
this.getListNameTag();
this.getInfoCommon();
Expand Down Expand Up @@ -65,7 +64,6 @@ export class AppComponent implements OnInit {
getListNameTag(): void {
const payload = {
limit: 500,
keyword: [],
nextKey: 0,
};
this.commonService.getListNameTag(payload).subscribe((res) => {
Expand Down
5 changes: 5 additions & 0 deletions src/app/core/constants/profile.enum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export enum ProfileTab {
Setting = 'setting',
PrivateNameTag = 'private',
WatchList = 'watchList',
}
3 changes: 3 additions & 0 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 {
horoscopePathGraphql: string;
horoscopePathApi: string;
notice: { content: string; url: string };
googleClientId: string;
}

@Injectable()
Expand All @@ -49,6 +50,7 @@ export class EnvironmentService {
horoscopePathGraphql: '',
horoscopePathApi: '',
notice: { content: '', url: '' },
googleClientId: ''
});

get configValue(): IConfiguration {
Expand Down Expand Up @@ -86,6 +88,7 @@ export class EnvironmentService {
horoscopePathGraphql: config['horoscopePathGraphql'],
horoscopePathApi: config['horoscopePathApi'],
notice: config['notice'] || { content: '', url: '' },
googleClientId: config['googleClientId'] || '3465782004-hp7u6vlitgs109rl0emrsf1oc7bjvu08.apps.googleusercontent.com'
};

this.config.next(data);
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/helpers/error.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class ErrorInterceptor implements HttpInterceptor {
// auto logout if 401 response returned from api
// location.reload();
}
const error = err.error.message || err.statusText;
const error = err.error || err.statusText;
return throwError(error);
}))
}
Expand Down
16 changes: 9 additions & 7 deletions src/app/core/helpers/jwt.interceptor.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import { Injectable } from '@angular/core';
import { HttpRequest, HttpHandler, HttpEvent, HttpInterceptor } from '@angular/common/http';
import { Observable } from 'rxjs';
import { AuthenticationService } from '../services/auth.service';

@Injectable()
export class JwtInterceptor implements HttpInterceptor {
constructor(private authenticationService: AuthenticationService) {}
constructor() {}

intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
const currentUser = this.authenticationService.currentUserValue;
request = request.clone({
setHeaders: {
},
});
const accessToken = localStorage.getItem('accessToken');
if (accessToken) {
request = request.clone({
setHeaders: {
Authorization: 'Bearer ' + accessToken.replace(/"/g, ''),
},
});
}
return next.handle(request);
}
}
12 changes: 7 additions & 5 deletions src/app/core/helpers/timeout.interceptor.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable, InjectionToken, Inject } from '@angular/core';
import { HttpInterceptor, HttpHandler, HttpRequest } from '@angular/common/http';
import { empty, TimeoutError } from 'rxjs';
import { timeout, catchError } from 'rxjs/operators';
import { HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
import { Inject, Injectable, InjectionToken } from '@angular/core';
import { TimeoutError, throwError } from 'rxjs';
import { catchError, timeout } from 'rxjs/operators';

export const DEFAULT_TIMEOUT = new InjectionToken<number>('defaultTimeout');

Expand All @@ -20,7 +20,9 @@ export class RequestTimeoutHttpInterceptor implements HttpInterceptor {
timeout(this.defaultTimeout),
catchError((err) => {
if (err instanceof TimeoutError) console.error('Timeout has occurred', req.url);
return empty();

const error = err.error || err.statusText;
return throwError(error);
}),
);
}
Expand Down
39 changes: 37 additions & 2 deletions src/app/core/services/account.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class AccountService extends CommonService {
}

getAssetCW20ByOwner(payload): Observable<any> {
return this.http.post<any>(`${this.apiUrl}/cw20-tokens/get-by-owner/`, payload);
return this.http.get<any>(`${this.apiUrl}/cw20-tokens/get-by-owner/${payload?.account_address}`);
}

getAssetCW721ByOwner(payload): Observable<any> {
Expand Down Expand Up @@ -81,7 +81,7 @@ export class AccountService extends CommonService {
variables: {
limit: payload?.limit || 20,
offset: payload.offset,
contract_address: payload?.contractAddress,
contract_address: payload?.contractAddress || payload?.address,
nextKeyLastUpdatedHeight: payload?.nextKey,
nextKeyId: payload?.nextKeyId,
tokenId: payload?.token_id,
Expand All @@ -95,4 +95,39 @@ export class AccountService extends CommonService {
getTotalAssets(account_id: string): Observable<any> {
return this.http.get<any>(`${this.apiUrl}/cw20-tokens/total-asset/${account_id}`);
}

getListCollectionByOwner(payload): Observable<any> {
const operationsDoc = `
query queryListCollection($owner: String = null) {
${this.envDB} {
cw721_contract(where: {cw721_tokens: {owner: {_eq: $owner}, burned: {_eq: false}}, smart_contract: {name: {_neq: "crates.io:cw4973"}}}, order_by: {name: asc}) {
name
symbol
cw721_tokens_aggregate(where: {owner: {_eq: $owner}, burned: {_eq: false}}) {
aggregate {
count
}
}
smart_contract {
address
}
}
cw721_token_aggregate(where: {cw721_contract: {smart_contract: {name: {_neq: "crates.io:cw4973"}}}, owner: {_eq: $owner}, burned: {_eq: false}}) {
aggregate {
count
}
}
}
}
`;
return this.http
.post<any>(this.graphUrl, {
query: operationsDoc,
variables: {
owner: payload?.owner,
},
operationName: 'queryListCollection',
})
.pipe(map((res) => (res?.data ? res?.data[this.envDB] : null)));
}
}
12 changes: 7 additions & 5 deletions src/app/core/services/common.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import axios from 'axios';
import { formatDistanceToNowStrict } from 'date-fns';
import * as _ from 'lodash';
import * as moment from 'moment';
import { BehaviorSubject, Observable, Subject } from 'rxjs';
import { BehaviorSubject, Observable } from 'rxjs';
import { DATEFORMAT } from '../constants/common.constant';
import { STATUS_VALIDATOR } from '../constants/validator.enum';
import { EnvironmentService } from '../data-services/environment.service';
import { formatTimeInWords, formatWithSchema } from '../helpers/date';
import { Globals } from 'src/app/global/global';

@Injectable()
export class CommonService {
Expand Down Expand Up @@ -43,7 +42,7 @@ export class CommonService {
}

status(): Observable<any> {
return this._http.get<any>(`${this.horoscopeApi}/dashboard-statistics?chainid=${this.chainId}`);
return this._http.get<any>(`${this.horoscopeApi}/statistics/dashboard?chainid=${this.chainId}`);
}

getParamTallyingFromLCD() {
Expand Down Expand Up @@ -112,7 +111,10 @@ export class CommonService {
}

getListNameTag(payload) {
return this._http.post<any>(`${this.apiUrl}/name-tag/get-name-tag`, payload);
const params = _(payload).omitBy(_.isNull).omitBy(_.isUndefined).value();
return this._http.get<any>(`${this.apiUrl}/public-name-tag`, {
params,
});
}

setNameTag(address, listNameTag = []) {
Expand Down
4 changes: 2 additions & 2 deletions src/app/core/services/contract.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class ContractService extends CommonService {
const operationsDoc = `
query querySmartContractList($limit: Int = 100, $offset: Int = 0, $type: [String!], $address: String = null, $creator: String =null) {
${this.envDB} {
smart_contract(limit: $limit, offset: $offset, order_by: {updated_at: desc}, where: {${typeQuery} ${updateQuery} address: {_eq: $address}, creator: {_eq: $creator}}) {
smart_contract(limit: $limit, offset: $offset, order_by: {updated_at: desc}, where: {${typeQuery} ${updateQuery} address: {_eq: $address}, creator: {_eq: $creator}, status: {_eq: "LATEST"}}) {
address
name
code_id
Expand Down Expand Up @@ -123,7 +123,7 @@ export class ContractService extends CommonService {
const contractDoc = `
query queryContractDetail($contractAddress: String = null) {
${this.envDB} {
smart_contract(limit: 1, where: {address: {_eq: $contractAddress}}) {
smart_contract(limit: 1, where: {address: {_eq: $contractAddress}, status: {_eq: "LATEST"}}) {
address
creator
instantiate_hash
Expand Down
8 changes: 8 additions & 0 deletions src/app/core/services/ngx-toastr.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ export class NgxToastrService {
});
}

successWithTitle(message: string, title = '', configTimeOut = 5000): void {
this.toastrService.success(message, title, {
positionClass: this.POSITION_CLASS,
timeOut: configTimeOut,
toastClass: 'aura-toast'
});
}

successWithTap(message: string, title = ''): Observable<void> {
return this.toastrService.success(message, title, {
positionClass: this.POSITION_CLASS,
Expand Down
7 changes: 6 additions & 1 deletion src/app/core/services/token.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { LCD_COSMOS } from '../constants/url.constant';
import { EnvironmentService } from '../data-services/environment.service';
import { RangeType } from '../models/common.model';
import { CommonService } from './common.service';
import * as _ from 'lodash';

@Injectable()
export class TokenService extends CommonService {
Expand Down Expand Up @@ -59,7 +60,11 @@ export class TokenService extends CommonService {
}

getTokenMarketData(payload = {}): Observable<any> {
return this.http.post<any>(`${this.apiUrl}/cw20-tokens/token-market`, payload);
const params = _(payload).omitBy(_.isNull).omitBy(_.isUndefined).value();

return this.http.get<any>(`${this.apiUrl}/cw20-tokens/token-market`, {
params,
});
}

getListCW721Token(payload, textSearch = null): Observable<any> {
Expand Down
46 changes: 46 additions & 0 deletions src/app/core/services/user.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { EnvironmentService } from '../data-services/environment.service';
import { CommonService } from './common.service';

@Injectable()
export class UserService extends CommonService {
chainInfo = this.environmentService.configValue.chain_info;

constructor(private http: HttpClient, private environmentService: EnvironmentService) {
super(http, environmentService);
}

registerUser(payload): Observable<any> {
return this.http.post<any>(`${this.apiUrl}/users/register-with-password`, payload);
}

loginWithPassword(payload): Observable<any> {
return this.http.post<any>(`${this.apiUrl}/auth/login-with-password`, payload);
}

changePassword(payload): Observable<any> {
return this.http.post<any>(`${this.apiUrl}/users/change-password`, payload);
}

resendVerifyEmail(email: string): Observable<any> {
return this.http.get<any>(`${this.apiUrl}/auth/resend-verification-email/${email}`);
}

sendResetPasswordEmail(email: string): Observable<any> {
return this.http.get<any>(`${this.apiUrl}/auth/send-reset-password-email/${email}`);
}

resetPasswordWithCode(payload): Observable<any> {
return this.http.post<any>(`${this.apiUrl}/auth/reset-password`, payload);
}

loginWithGoogle(payload): Observable<any> {
return this.http.post<any>(`${this.apiUrl}/auth/google`, payload);
}

refreshToken(payload): Observable<any> {
return this.http.post<any>(`${this.apiUrl}/auth/refresh-token`, payload);
}
}
36 changes: 1 addition & 35 deletions src/app/core/services/validator.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class ValidatorService extends CommonService {
const operationsDoc = `
query getDataValidator($offset: Int = 0, $limit: Int = 10, $operatorAddress: String = null) {
${this.envDB} {
validator(limit: $limit, offset: $offset, order_by: {tokens: desc}, where: {operator_address: {_eq: $operatorAddress}}) {
validator(limit: $limit, offset: $offset, order_by: {tokens: desc}, where: {operator_address: {_eq: $operatorAddress}, status: {_neq: "UNRECOGNIZED"}}) {
account_address
commission
consensus_address
Expand Down Expand Up @@ -101,40 +101,6 @@ export class ValidatorService extends CommonService {
.pipe(map((res) => (res?.data ? res?.data[this.envDB] : null)));
}

getValidatorByListAddress(arrAddress) {
const operationsDoc = `
query getValidatorByListAddress($arrAddress: [String!]) {
${this.envDB} {
validator(where: {operator_address: {_in: $arrAddress}}, order_by: {tokens: desc}) {
account_address
commission
consensus_address
consensus_hex_address
created_at
delegator_shares
delegators_count
delegators_last_height
description
jailed
operator_address
status
tokens
image_url
}
}
}
`;
return this.http
.post<any>(this.graphUrl, {
query: operationsDoc,
variables: {
arrAddress: arrAddress || null,
},
operationName: 'getValidatorByListAddress',
})
.pipe(map((res) => (res?.data ? res?.data[this.envDB] : null)));
}

validatorsDetailListPower(address: string, limit = 10, nextKey = null) {
const operationsDoc = `
query validatorsDetailListPower($operator_address: String, $limit: Int = 10, $nextKey: Int = null) {
Expand Down
Loading

0 comments on commit 4ebda3e

Please sign in to comment.