Skip to content

Commit

Permalink
Merge pull request #1675 from aura-nw/baseline/main_20230318
Browse files Browse the repository at this point in the history
Baseline/main 20230318
  • Loading branch information
nhphuc2411 authored Mar 18, 2023
2 parents a651860 + c1178b5 commit 38cf3e9
Show file tree
Hide file tree
Showing 14 changed files with 199 additions and 81 deletions.
3 changes: 3 additions & 0 deletions src/app/core/constants/messages.constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export const MESSAGES_CODE = {
SUCCESSFUL: { Code: 'SUCCESSFUL', Message: 'Successfully!' },
};

//v0.45.11
export const MESSAGES_CODE_STAKING = {
2: { Code: 2, Message: 'empty validator address' },
3: { Code: 3, Message: 'validator does not exist' },
Expand Down Expand Up @@ -50,6 +51,7 @@ export const MESSAGES_CODE_STAKING = {
39: { Code: 39, Message: 'empty validator public key' },
};

//v0.45.11
export const MESSAGES_CODE_PROPOSAL = {
2: { Code: 2, Message: 'unknown proposal' },
3: { Code: 3, Message: 'inactive proposal' },
Expand All @@ -64,6 +66,7 @@ export const MESSAGES_CODE_PROPOSAL = {
9: { Code: 9, Message: 'no handler exists for proposal type' },
};

//v0.45.11
export const MESSAGES_CODE_CONTRACT = {
2: { Code: 2, Message: 'create wasm contract failed' },
3: { Code: 3, Message: 'contract account already exists' },
Expand Down
7 changes: 6 additions & 1 deletion src/app/core/services/wallet.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,12 @@ export class WalletService implements OnDestroy {
let signingClient;
if (this.isMobileMatched && !this.checkExistedCoin98()) {
const msgs = messageCreators[messageType](senderAddress, message, network);
const fee: StdFee = await getNetworkFee(network, senderAddress, msgs, '');
let fee;
if (this.coin98Client) {
fee = this.coin98Client.getGasEstimateMobile(network, messageType, validatorsCount);
} else {
fee = await getNetworkFee(network, senderAddress, msgs, '');
}

return this.makeSignDocData(senderAddress, {
msgs,
Expand Down
19 changes: 19 additions & 0 deletions src/app/core/utils/coin98-client.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { Client } from '@coin98-com/connect-sdk';
import { requestParameter } from '@coin98-com/connect-sdk/dist/types/client';
import { StdSignDoc } from '@cosmjs/amino';
import { calculateFee } from '@cosmjs/stargate';
import { ChainInfo } from '@keplr-wallet/types';
import { getFee } from './signing/fee';

export type ConnectResponse = {
result: any;
Expand Down Expand Up @@ -165,4 +167,21 @@ export class Coin98Client {
],
});
}

getGasEstimateMobile(network, messageType, validatorsCount) {
const gasPrice = network.gasPriceStep.average.toString() + network.currencies[0].coinMinimalDenom;
const gasEstimate = validatorsCount ? getFee(messageType, validatorsCount) : getFee(messageType);
const calGasPrice = calculateFee(Math.round(+gasEstimate), gasPrice);
const result = {
amount: [
{
denom: network.currencies[0].coinMinimalDenom,
amount: (calGasPrice?.amount[0]?.amount || network.gasPriceStep.average)?.toString(),
},
],
gas: validatorsCount ? getFee(messageType, validatorsCount) : getFee(messageType),
};

return result;
}
}
5 changes: 4 additions & 1 deletion src/app/core/utils/signing/transaction-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { calculateFee, DeliverTxResponse, SigningStargateClient, StdFee } from '
import { ChainInfo } from '@keplr-wallet/types';
import { TRANSACTION_TYPE_ENUM } from '../../constants/transaction.enum';
import { KEPLR_ERRORS } from '../../constants/wallet.constant';
import { getFee } from './fee';
import { messageCreators } from './messages';
import { getSigner } from './signer';

Expand All @@ -24,15 +25,17 @@ export async function createSignBroadcast(
} else {
// success
const messagesSend = messageCreators[messageType](senderAddress, message, network);
const fee: StdFee = await getNetworkFee(network, senderAddress, messagesSend, '');
let fee;
let client;

if (coin98Client) {
client = coin98Client;
fee = client.getGasEstimateMobile(network, messageType, validatorsCount);
} else {
const signer = await getSigner(signingType, chainId);

client = await SigningStargateClient.connectWithSigner(network.rpc, signer);
fee = await getNetworkFee(network, senderAddress, messagesSend, '');
}

try {
Expand Down
3 changes: 2 additions & 1 deletion src/app/pages/dashboard/dashboard.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,9 @@
</div>
</div>
</div>
<div class="w-100">
<div class="w-100 position-relative">
<div id="chart"></div>
<div class="line-chart"></div>
</div>
</div>
</div>
Expand Down
40 changes: 20 additions & 20 deletions src/app/pages/dashboard/dashboard.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
}

@media (max-width: 992px) {
.aura-table.blocks, .aura-table.transaction {
.aura-table.blocks,
.aura-table.transaction {
th {
min-width: 140px;
&:last-child {
Expand Down Expand Up @@ -72,20 +73,15 @@
background-color: var(--aura-gray-9);
padding: 8px;
}
.tv-lightweight-charts table tr:last-child {
//border-top: 1.5px solid #FFA741;
position: relative;
&::after {
content: '';
position: absolute;
left: 0;
right: 0;
top: 0;
width: 100%;
height: 1.5px;
z-index: 2;
background: linear-gradient(113.1deg, #5EE6D0 13.45%, #BFC6FF 50.33%, #FFBA69 85.05%);
}
.line-chart {
position: absolute;
bottom: 24px;
left: 0;
right: 0;
z-index: 10;
height: 1.5px;
background: linear-gradient(113.1deg, #5ee6d0 13.45%, #bfc6ff 50.33%, #ffba69 85.05%);
width: 100%;
}
}
.button-switch-stage {
Expand Down Expand Up @@ -212,18 +208,22 @@ ul {
bottom: 0;
}
&:before {
background: url("../../../assets/icons/icons-svg/basic/github-2.svg") no-repeat center;
background: url('../../../assets/icons/icons-svg/basic/github-2.svg') no-repeat center;
background-size: contain;
opacity: 1;
}
&:after {
background: url("../../../assets/icons/icons-svg/white/github-2.svg") no-repeat center;
background: url('../../../assets/icons/icons-svg/white/github-2.svg') no-repeat center;
background-size: contain;
opacity: 0;
}
&:hover {
&:before { opacity: 0; }
&:after { opacity: 1; }
&:before {
opacity: 0;
}
&:after {
opacity: 1;
}
}
}
i.icon-info {
Expand Down Expand Up @@ -252,7 +252,7 @@ img.icon-brand {
font-weight: 400;
font-size: 14px;
line-height: 18px;
border: 1px solid #494C58;
border: 1px solid #494c58;
border-radius: 8px;
max-width: 100%;
text-overflow: ellipsis;
Expand Down
22 changes: 20 additions & 2 deletions src/app/pages/dashboard/dashboard.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import { timeToUnix } from 'src/app/core/helpers/date';
import { exportChart } from 'src/app/core/helpers/export';
import { ProposalService } from 'src/app/core/services/proposal.service';
import { TokenService } from 'src/app/core/services/token.service';
import { WalletService } from 'src/app/core/services/wallet.service';
import { getInfo } from 'src/app/core/utils/common/info-common';
import { RangeType, TableTemplate } from '../../../app/core/models/common.model';
import { TableTemplate } from '../../../app/core/models/common.model';
import { BlockService } from '../../../app/core/services/block.service';
import { CommonService } from '../../../app/core/services/common.service';
import { TransactionService } from '../../../app/core/services/transaction.service';
Expand Down Expand Up @@ -85,6 +86,7 @@ export class DashboardComponent implements OnInit, AfterViewInit, OnDestroy {

originalData = [];
originalDataArr = [];
cacheData = [];
logicalRangeChange$ = new Subject<{ from: number; to: number }>();
endData = false;

Expand All @@ -101,6 +103,7 @@ export class DashboardComponent implements OnInit, AfterViewInit, OnDestroy {
private proposalService: ProposalService,
private maskService: MaskPipe,
private token: TokenService,
private walletService: WalletService,
) {}

ngOnInit(): void {
Expand All @@ -115,14 +118,23 @@ export class DashboardComponent implements OnInit, AfterViewInit, OnDestroy {
this.getCoinInfo(this.chartRange);
this.currDate = moment(new Date()).format('DDMMYYYY_HHMMSS');
this.getVotingPeriod();
// re-draw chart when connect coin98 app in mobile
this.walletService.wallet$.subscribe((wallet) => {
if (this.originalData.length === 0) {
this.originalData = this.cacheData;
this.chart.remove();
this.chart = createChart(document.getElementById('chart'), DASHBOARD_CHART_OPTIONS);
this.areaSeries = this.chart.addAreaSeries(DASHBOARD_AREA_SERIES_CHART_OPTIONS);
this.subscribeVisibleLogicalRangeChange();
}
});
}

// config chart
initChart() {
this.chart = createChart(document.getElementById('chart'), DASHBOARD_CHART_OPTIONS);
this.areaSeries = this.chart.addAreaSeries(DASHBOARD_AREA_SERIES_CHART_OPTIONS);
this.initTooltip();

this.subscribeVisibleLogicalRangeChange();
}

Expand Down Expand Up @@ -155,6 +167,9 @@ export class DashboardComponent implements OnInit, AfterViewInit, OnDestroy {

this.originalData = [...res?.data, ...this.originalData];
this.originalDataArr = [...chartData, ...this.originalDataArr];
if (this.originalData.length > 0) {
this.cacheData = this.originalData;
}
this.areaSeries.setData(this.originalDataArr);
} else {
this.endData = true;
Expand Down Expand Up @@ -308,6 +323,9 @@ export class DashboardComponent implements OnInit, AfterViewInit, OnDestroy {
const { dataX, dataY } = this.parseDataFromApi(res.data);

this.originalData = [...this.originalData, ...res?.data];
if (this.originalData.length > 0) {
this.cacheData = this.originalData;
}
this.drawChartFirstTime(dataX, dataY);
this.chartEvent();
}
Expand Down
Loading

0 comments on commit 38cf3e9

Please sign in to comment.