Skip to content

Commit

Permalink
Merge pull request #1774 from aura-nw/baseline/main_20230410
Browse files Browse the repository at this point in the history
Baseline/main 20230410
  • Loading branch information
nhphuc2411 authored Apr 10, 2023
2 parents 2ed49a7 + f579e8d commit dd02069
Show file tree
Hide file tree
Showing 19 changed files with 867 additions and 784 deletions.
53 changes: 53 additions & 0 deletions src/app/core/constants/messages.constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ export const MESSAGES_CODE_STAKING = {
37: { Code: 37, Message: 'invalid historical info' },
38: { Code: 38, Message: 'no historical info found' },
39: { Code: 39, Message: 'empty validator public key' },
40: { Code: 40, Message: 'unbonding operation not found' },
41: { Code: 41, Message: 'cannot un-hold unbonding operation that is not on hold' },
};

//v0.45.11
Expand Down Expand Up @@ -95,3 +97,54 @@ export const MESSAGES_CODE_CONTRACT = {
26: { Code: 26, Message: 'top-level key is not allowed' },
27: { Code: 27, Message: 'max query stack size exceeded' },
};

//v0.45.11
export const MESSAGES_CODE_SDK = {
1: { Code: 1, Message: 'internal' },
2: { Code: 2, Message: 'tx parse error' },
3: { Code: 3, Message: 'invalid sequence' },
4: { Code: 4, Message: 'unauthorized', },
5: { Code: 5, Message: 'insufficient funds' },
6: { Code: 6, Message: 'unknown request' },
7: { Code: 7, Message: 'invalid address' },
8: { Code: 8, Message: 'invalid pubkey' },
9: { Code: 9, Message: 'unknown address' },
10: { Code: 10, Message: 'invalid coins' },
11: { Code: 11, Message: 'out of gas' },
12: { Code: 12, Message: 'memo too large' },
13: { Code: 13, Message: 'insufficient fee' },
14: { Code: 14, Message: 'maximum number of signatures exceeded' },
15: { Code: 15, Message: 'no signatures supplied' },
16: { Code: 16, Message: 'failed to marshal JSON bytes' },
17: { Code: 17, Message: 'failed to unmarshal JSON bytes' },
18: { Code: 18, Message: 'invalid request' },
19: { Code: 19, Message: 'tx already in mempool' },
20: { Code: 20, Message: 'mempool is full' },
21: { Code: 21, Message: 'tx too large' },
22: { Code: 22, Message: 'key not found' },
23: { Code: 23, Message: 'invalid account password' },
24: { Code: 24, Message: 'tx intended signer does not match the given signer' },
25: { Code: 25, Message: 'invalid gas adjustment' },
26: { Code: 26, Message: 'invalid height' },
27: { Code: 27, Message: 'invalid version' },
28: { Code: 28, Message: 'invalid chain-id' },
29: { Code: 29, Message: 'invalid type' },
30: { Code: 30, Message: 'tx timeout height' },
31: { Code: 31, Message: 'unknown extension options' },
32: { Code: 32, Message: 'incorrect account sequence' },
33: { Code: 33, Message: 'failed packing protobuf message to Any' },
34: { Code: 34, Message: 'failed unpacking protobuf message from Any' },
35: { Code: 35, Message: 'internal logic error' },
36: { Code: 36, Message: 'conflict' },
37: { Code: 37, Message: 'feature not supported' },
38: { Code: 38, Message: 'not found' },
39: { Code: 39, Message: 'Internal IO error' },
40: { Code: 40, Message: 'error in app.toml' },
111222: { Code: 111222, Message: 'panic' },
};

export enum TYPE_CODE_SPACE {
SDK = 'sdk',
STAKING = 'staking',
GOV = 'gov',
}
1 change: 1 addition & 0 deletions src/app/core/constants/transaction.constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const TYPE_TRANSACTION = [
{ label: TRANSACTION_TYPE_ENUM.Unjail, value: TypeTransaction.Unjail },
{ label: TRANSACTION_TYPE_ENUM.StoreCode, value: TypeTransaction.StoreCode },
{ label: TRANSACTION_TYPE_ENUM.InstantiateContract, value: TypeTransaction.InstantiateContract },
{ label: TRANSACTION_TYPE_ENUM.InstantiateContract2, value: TypeTransaction.InstantiateContract },
{ label: TRANSACTION_TYPE_ENUM.ExecuteContract, value: TypeTransaction.ExecuteContract },
{ label: TRANSACTION_TYPE_ENUM.ModifyWithdrawAddress, value: TypeTransaction.ModifyWithdrawAddress },
{ label: TRANSACTION_TYPE_ENUM.JoinPool, value: TypeTransaction.JoinPool },
Expand Down
5 changes: 4 additions & 1 deletion src/app/core/constants/transaction.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export enum TRANSACTION_TYPE_ENUM {
Unjail = '/cosmos.slashing.v1beta1.MsgUnjail',
StoreCode = '/cosmwasm.wasm.v1.MsgStoreCode',
InstantiateContract = '/cosmwasm.wasm.v1.MsgInstantiateContract',
InstantiateContract2 = '/cosmwasm.wasm.v1.MsgInstantiateContract2',
ExecuteContract = '/cosmwasm.wasm.v1.MsgExecuteContract',
ModifyWithdrawAddress = '/cosmos.distribution.v1beta1.MsgSetWithdrawAddress',
JoinPool = '/osmosis.gamm.v1beta1.MsgJoinPool',
Expand Down Expand Up @@ -109,7 +110,9 @@ export enum ModeExecuteTransaction {
Buy = 'buy',
Take = 'take',
UnEquip = 'unequip',
AcceptOffer = 'accept_nft_offer'
AcceptOffer = 'accept_nft_offer',
Send = 'send',
ProvideLiquidity = 'provide_liquidity',
}

export enum pipeTypeData {
Expand Down
35 changes: 27 additions & 8 deletions src/app/core/services/mapping-error.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { DATE_TIME_WITH_MILLISECOND, TIME_OUT_CALL_API } from '../constants/common.constant';
import { MESSAGES_CODE_PROPOSAL, MESSAGES_CODE_STAKING } from '../constants/messages.constant';
import { MESSAGES_CODE_PROPOSAL, MESSAGES_CODE_SDK, MESSAGES_CODE_STAKING, TYPE_CODE_SPACE } from '../constants/messages.constant';
import { CodeTransaction } from '../constants/transaction.enum';
import { EnvironmentService } from '../data-services/environment.service';
import { CommonService } from './common.service';
Expand All @@ -25,16 +25,35 @@ export class MappingErrorService extends CommonService {
this.timeStaking = (Number(this.timeStaking) / DATE_TIME_WITH_MILLISECOND).toString();
}

checkMappingError(message, code, isProposal = false) {
checkMappingError(message, code, codeSpace = TYPE_CODE_SPACE.SDK) {
if (code === CodeTransaction.Success) {
message = this.translate.instant('NOTICE.SUCCESS_TRANSACTION');
return message;
}
let temp = MESSAGES_CODE_STAKING[code]?.Message || 'error';
if (isProposal) {
temp = MESSAGES_CODE_PROPOSAL[code]?.Message || 'error';

let codeTemp = code;
if (+code !== parseInt(code, 10)) {
const index = code.indexOf('code');
if (index) {
// get value of code from string
codeTemp = code.slice(index + 5, index + 8).trim();
}
}
message = temp ? temp.charAt(0).toUpperCase() + temp.slice(1) : 'Error';

let temp = 'Error';
switch (codeSpace) {
case TYPE_CODE_SPACE.GOV:
temp = MESSAGES_CODE_STAKING[codeTemp]?.Message;
break;
case TYPE_CODE_SPACE.STAKING:
temp = MESSAGES_CODE_STAKING[codeTemp]?.Message;
break;
default:
temp = MESSAGES_CODE_SDK[codeTemp]?.Message;
break;
}

message = temp ? temp.charAt(0).toUpperCase() + temp.slice(1) : code;
return message;
}

Expand Down Expand Up @@ -65,12 +84,12 @@ export class MappingErrorService extends CommonService {
const res = await this.transactionService.txsDetailLcd(id);
let numberCode = res?.data?.tx_response?.code;
let message = res?.data?.tx_response?.raw_log;
message = this.checkMappingError(message, numberCode, res?.data?.tx_response?.codespace);
if (numberCode !== undefined) {
if (!!!numberCode && numberCode === CodeTransaction.Success) {
message = this.translate.instant('NOTICE.SUCCESS_TRANSACTION');
this.toastr.success(message);
setTimeout(() => {
}, TIME_OUT_CALL_API);
setTimeout(() => {}, TIME_OUT_CALL_API);
} else {
this.toastr.error(message);
}
Expand Down
13 changes: 11 additions & 2 deletions src/app/global/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,19 @@ export function getAmount(arrayMsg, type, rawRog = '', coinMinimalDenom = '') {
0;
} else if (type === eTransType.CreateValidator) {
amount = itemMessage?.value?.amount || 0;
} else if (type === eTransType.ExecuteAuthz) {
itemMessage?.msgs.forEach((element) => {
amount += +element?.amount?.amount;
});
}
} catch {}

if (itemMessage && amount >= 0) {
amount = amount / NUMBER_CONVERT || 0;
amountFormat = amount;
if (
(type === TRANSACTION_TYPE_ENUM.GetReward && arrayMsg?.length > 1) ||
((type === TRANSACTION_TYPE_ENUM.GetReward || type === TRANSACTION_TYPE_ENUM.Undelegate) &&
arrayMsg?.length > 1) ||
type === TRANSACTION_TYPE_ENUM.MultiSend ||
type === TRANSACTION_TYPE_ENUM.PeriodicVestingAccount
) {
Expand Down Expand Up @@ -175,6 +180,10 @@ export function getDataInfo(arrayMsg, addressContract, rawLog = '') {
(k) => k.key === 'receiver' && k.value.length <= LENGTH_CHARACTER.ADDRESS,
)?.value || null;
} catch (e) {}
} else if (method === ModeExecuteTransaction.Send) {
toAddress = itemMessage?.msg?.send?.contract;
} else if (method === ModeExecuteTransaction.ProvideLiquidity) {
toAddress = itemMessage?.contract;
}
break;
case eTransType.Deposit:
Expand Down Expand Up @@ -235,7 +244,7 @@ export function convertDataTransaction(data, coinInfo) {
}
});
}
const type = _.find(TYPE_TRANSACTION, { label: _type })?.value || 'TBD';
const type = _.find(TYPE_TRANSACTION, { label: _type })?.value || 'Execute';

const status =
_.get(element, 'tx_response.code') == CodeTransaction.Success
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ <h2 class="mb-0 text--white">NFTs ({{ pageData.length || 0 }}<span *ngIf="nextKe
</div>
<!-- Filter -->
<div class="mb-6 d-lg-flex align-items-center justify-content-between">
<div class="h1 mb-0 text-gradient">$ {{ totalValue || 0 | number: global.formatNumber2Decimal }}</div>
<div class="h1 mb-0 text-gradient">
<!-- $ {{ totalValue || 0 | number: global.formatNumber2Decimal }}-->
</div>
<form (ngSubmit)="searchTokenNft()" class="aura-form single-input-field account-search-form mt-4 mt-lg-0">
<div class="input-group">
<input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ export class WriteContractComponent implements OnInit {
.catch((error) => {
msg.isLoading = false;
if (!error.toString().includes('Request rejected')) {
msgError = error.toString().includes('out of gas') ? 'out of gas' : msgError;
this.toastr.error(msgError);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class PopupAddGrantComponent implements OnInit {
private feeGrantService: FeeGrantService,
private dialog: MatDialog,
public translate: TranslateService,
private mappingErrorService: MappingErrorService
private mappingErrorService: MappingErrorService,
) {}

ngOnInit(): void {
Expand Down Expand Up @@ -176,7 +176,8 @@ export class PopupAddGrantComponent implements OnInit {
this.closeDialog(hash);
} else {
if (error != 'Request rejected') {
this.toastr.error(error);
let errorMessage = this.mappingErrorService.checkMappingError('', error);
this.toastr.error(errorMessage);
}
}
};
Expand All @@ -194,7 +195,8 @@ export class PopupAddGrantComponent implements OnInit {

checkFormValid(): boolean {
const granter = this.walletService.wallet?.bech32Address;
const { grantee_address, expiration_time, period_amount, period_day, amount, isExecute, execute_contract } = this.grantForm.value;
const { grantee_address, expiration_time, period_amount, period_day, amount, isExecute, execute_contract } =
this.grantForm.value;

this.formValid = false;
this.isInvalidAddress = false;
Expand Down
20 changes: 4 additions & 16 deletions src/app/pages/proposal/proposal-vote/proposal-vote.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component, Inject, OnInit } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { TIME_OUT_CALL_API } from 'src/app/core/constants/common.constant';
import { TYPE_CODE_SPACE } from 'src/app/core/constants/messages.constant';
import { CodeTransaction } from 'src/app/core/constants/transaction.enum';
import { ESigningType, SIGNING_MESSAGE_TYPES } from 'src/app/core/constants/wallet.constant';
import { EnvironmentService } from 'src/app/core/data-services/environment.service';
Expand Down Expand Up @@ -55,28 +56,15 @@ export class ProposalVoteComponent implements OnInit {
this.toastr.loading(hash);
this.dialogRef.close();
setTimeout(() => {
this.checkDetailTx(hash, 'Error Voting');
this.mappingErrorService.checkDetailTx(hash);
}, TIME_OUT_CALL_API);
} else if (error) {
this.toastr.error(error);
let errorMessage = this.mappingErrorService.checkMappingError('', error);
this.toastr.error(errorMessage);
this.closeVoteForm();
}
}

async checkDetailTx(id, message) {
const res = await this.transactionService.txsDetailLcd(id);
let numberCode = res?.data?.tx_response?.code;
message = res?.data?.tx_response?.raw_log || message;
message = this.mappingErrorService.checkMappingError(message, numberCode, true);
if (numberCode !== undefined) {
if (numberCode === CodeTransaction.Success) {
this.toastr.success(message);
} else {
this.toastr.error(message);
}
}
}

onSubmitVoteForm() {
this.proposalVote();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
<div class="d-flex">
<div class="body-02 text--gray-5 fixed-col">Holders:</div>
<div class="body-02 text--gray-1">
{{ tokenDetail?.holder || 0 }}
{{ tokenDetail?.holder || 0 | mask : 'separator.0' }}
<span
class="ml-1 {{ tokenDetail.isHolderUp ? 'text--green-3' : 'text--red-3' }}"
*ngIf="!tokenDetail.isNFTContract">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ <h1 class="mb-0 text--white fw-500-mob">Non-Fungible Tokens (NFT)</h1>
<th mat-header-cell *matHeaderCellDef>Token</th>
<td mat-cell *matCellDef="let element" class="title-cell py-4">
<div class="d-flex">
<!-- <img [src]="element.image || defaultLogoToken" width="18" height="18" /> -->
<div>
<a [routerLink]="['/tokens/token-nft', element.contract_address]" class="text--primary">
{{ element.name | stringEllipsis : 16 }}
Expand All @@ -71,6 +70,12 @@ <h1 class="mb-0 text--white fw-500-mob">Non-Fungible Tokens (NFT)</h1>
}}</a>
</td>
</ng-container>
<ng-container matColumnDef="total_tx">
<th mat-header-cell *matHeaderCellDef mat-sort-header>Total Transactions</th>
<td mat-cell *matCellDef="let element" class="vertical-align-top py-4">
{{ element.total_tx | number }}
</td>
</ng-container>
<ng-container matColumnDef="transfers_24h">
<th mat-header-cell *matHeaderCellDef mat-sort-header>Transfers (24H)</th>
<td mat-cell *matCellDef="let element" class="vertical-align-top py-4">
Expand All @@ -79,15 +84,6 @@ <h1 class="mb-0 text--white fw-500-mob">Non-Fungible Tokens (NFT)</h1>
</ng-container>
</td>
</ng-container>
<ng-container matColumnDef="transfers_3d">
<th mat-header-cell *matHeaderCellDef mat-sort-header>Transfers (3D)</th>
<td mat-cell *matCellDef="let element" class="vertical-align-top py-4">
<ng-container *ngIf="element.transfers_3d; else noData">
{{ element.transfers_3d | number }}
</ng-container>
</td>
</ng-container>

<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>
<tr class="mat-row" *matNoDataRow>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export class TokenCw721Component implements OnInit {
{ matColumnDef: 'id', headerCellDef: 'id' },
{ matColumnDef: 'token', headerCellDef: 'name' },
{ matColumnDef: 'tokenContract', headerCellDef: 'tokenContract' },
{ matColumnDef: 'total_tx', headerCellDef: 'total_tx' },
{ matColumnDef: 'transfers_24h', headerCellDef: 'transfer' },
{ matColumnDef: 'transfers_3d', headerCellDef: 'transfer3d' },
];
displayedColumns: string[] = this.templates.map((dta) => dta.matColumnDef);
pageData: PageEvent = {
Expand All @@ -39,7 +39,7 @@ export class TokenCw721Component implements OnInit {
sort: MatSort;
typeSortBy = {
transfers24h: 'transfers_24h',
transfers3d: 'transfers_3d',
totalTx: 'total_tx',
};
sortBy = this.typeSortBy.transfers24h;
sortOrder = 'desc';
Expand Down Expand Up @@ -128,8 +128,8 @@ export class TokenCw721Component implements OnInit {
this.sortOrder = sort.direction;
this.getTokenData();
return 0;
case 'transfers_3d':
this.sortBy = this.typeSortBy.transfers3d;
case 'total_tx':
this.sortBy = this.typeSortBy.totalTx;
this.sortOrder = sort.direction;
this.getTokenData();
return 0;
Expand Down
Loading

0 comments on commit dd02069

Please sign in to comment.