Commit 69d36303 authored by chenqikuai's avatar chenqikuai

add types

parent faa56cd4
...@@ -31,7 +31,7 @@ export default VueTypedMixins().extend({ ...@@ -31,7 +31,7 @@ export default VueTypedMixins().extend({
props: { props: {
balance: [Number, Object], balance: [Number, Object],
selectedValue: String, selectedValue: String,
frozen: Number, frozen: [Number, Object],
optionsList: Array, optionsList: Array,
handleSelectChange: Function, handleSelectChange: Function,
}, },
......
...@@ -88,7 +88,7 @@ export default VueTypedMixins(AddressOverview).extend({ ...@@ -88,7 +88,7 @@ export default VueTypedMixins(AddressOverview).extend({
props: { props: {
balance: [Number, Object], balance: [Number, Object],
selectedValue: String, selectedValue: String,
frozen: Number, frozen: [Number, Object],
optionsList: Array, optionsList: Array,
handleSelectChange: Function, handleSelectChange: Function,
}, },
......
...@@ -6,6 +6,8 @@ import { ...@@ -6,6 +6,8 @@ import {
getVoterAddr, getVoterAddr,
getVoterAddrCount, getVoterAddrCount,
} from "@/service/api"; } from "@/service/api";
import { iExecAccount, iPack, iVote } from "@/types/address";
import { icustomized2Tx, iTx } from "@/types/trade";
import Rpc from "@/utils/Rpc"; import Rpc from "@/utils/Rpc";
import Vue from "vue"; import Vue from "vue";
...@@ -31,11 +33,11 @@ export default Vue.extend({ ...@@ -31,11 +33,11 @@ export default Vue.extend({
}, },
selectedOption: "1", selectedOption: "1",
loadingTxRecordTable: false, loadingTxRecordTable: false,
txRecordList: [] as any[], txRecordList: [] as icustomized2Tx[],
voteList: [] as any[], voteList: [] as iVote[],
selectedExecer: "", selectedExecer: "",
execAccount: [] as any[], execAccount: [] as iExecAccount[],
packList: [] as any[], packList: [] as iPack[],
loadingVote: false, loadingVote: false,
loadingPack: false, loadingPack: false,
}; };
...@@ -69,13 +71,13 @@ export default Vue.extend({ ...@@ -69,13 +71,13 @@ export default Vue.extend({
{ name: this.$t("lang.trade.consensusNode"), value: "2" }, { name: this.$t("lang.trade.consensusNode"), value: "2" },
]; ];
}, },
execerOptionsList(): any { execerOptionsList(): { name: string; value: string }[] {
return this.execAccount.map((i: any) => ({ return this.execAccount.map((i: any) => ({
name: i.execer, name: i.execer,
value: i.execer, value: i.execer,
})); }));
}, },
balance(): any { balance(): number {
return ( return (
this.execAccount.find((i: any) => i.execer === this.selectedExecer) || { this.execAccount.find((i: any) => i.execer === this.selectedExecer) || {
account: { account: {
...@@ -84,7 +86,7 @@ export default Vue.extend({ ...@@ -84,7 +86,7 @@ export default Vue.extend({
} }
)?.account?.balance; )?.account?.balance;
}, },
frozen(): any { frozen(): number {
return ( return (
this.execAccount.find((i: any) => i.execer === this.selectedExecer) || { this.execAccount.find((i: any) => i.execer === this.selectedExecer) || {
account: { account: {
...@@ -103,7 +105,7 @@ export default Vue.extend({ ...@@ -103,7 +105,7 @@ export default Vue.extend({
} }
}); });
}, },
checkGroup(arr: any[]) { checkGroup(arr: icustomized2Tx[]) {
arr.map((current, index) => { arr.map((current, index) => {
if (current.group_count > 1) { if (current.group_count > 1) {
current.tradeG = 1; //0-非交易组,1-交易组,3-交易组末条, 2-交易组首条 current.tradeG = 1; //0-非交易组,1-交易组,3-交易组末条, 2-交易组首条
......
...@@ -2,6 +2,8 @@ import Vue from "vue"; ...@@ -2,6 +2,8 @@ import Vue from "vue";
import { message } from "ant-design-vue"; import { message } from "ant-design-vue";
import { getRpc } from "ycc-api/dist/cmjs/service/Rpc"; import { getRpc } from "ycc-api/dist/cmjs/service/Rpc";
const Rpc = getRpc("/yccApi"); const Rpc = getRpc("/yccApi");
import { iBlockInBlockMixin, iGetBlocksRetResultItem } from "@/types/block";
export default Vue.extend({ export default Vue.extend({
data() { data() {
return { return {
...@@ -16,7 +18,7 @@ export default Vue.extend({ ...@@ -16,7 +18,7 @@ export default Vue.extend({
pageSize: 20, pageSize: 20,
total: 10, total: 10,
}, },
Blocks: [] as any[], Blocks: [] as iBlockInBlockMixin[],
}; };
}, },
mounted() { mounted() {
...@@ -38,8 +40,6 @@ export default Vue.extend({ ...@@ -38,8 +40,6 @@ export default Vue.extend({
} else { } else {
this.Loading = false; this.Loading = false;
message.warning({ message.warning({
// title: this.$t('components.tip'),
// message: data.error,
content: data.error as string, content: data.error as string,
}); });
} }
...@@ -75,23 +75,26 @@ export default Vue.extend({ ...@@ -75,23 +75,26 @@ export default Vue.extend({
Rpc.getBlocks(this.startHeight, this.endHeight, true).then((data) => { Rpc.getBlocks(this.startHeight, this.endHeight, true).then((data) => {
if (data.error === null) { if (data.error === null) {
const info = data.result.items.reverse().map((i: any) => ({ const info = (data.result.items as iGetBlocksRetResultItem[])
height: i.block.height, .reverse()
blockTime: i.block.blockTime, .map((i) => ({
minerHash: i.block.txs[0].from, height: i.block.height,
txCount: i.block.txs.length, blockTime: i.block.blockTime,
})); minerHash: i.block.txs[0].from,
txCount: i.block.txs.length,
}));
if (this.pages.currentPage === 1) { if (this.pages.currentPage === 1) {
this.Blocks = [...info, ...this.Blocks]; this.Blocks = [...info, ...this.Blocks];
this.Blocks.length = this.pages.pageSize; this.Blocks.length = this.pages.pageSize;
} else { } else {
this.Blocks = info; this.Blocks = info;
} }
info.map((i: any) => { info.map((i) => {
Rpc.getBlockHash(i.height).then((ret) => { Rpc.getBlockHash(i.height).then((ret) => {
( const the = this.Blocks.find(
this.Blocks.find((block) => block.height === i.height) || {} (block) => block.height === i.height
).hash = ret.result.hash; );
the && (the.hash = ret.result.hash);
this.Blocks = [...this.Blocks]; this.Blocks = [...this.Blocks];
}); });
}); });
......
...@@ -12,6 +12,9 @@ import { ...@@ -12,6 +12,9 @@ import {
getTxCountBewteenTimes, getTxCountBewteenTimes,
getTxList, getTxList,
} from "@/service/api"; } from "@/service/api";
import { icustomizedTx } from "@/types/trade";
export default Vue.extend({ export default Vue.extend({
data() { data() {
return { return {
...@@ -25,7 +28,7 @@ export default Vue.extend({ ...@@ -25,7 +28,7 @@ export default Vue.extend({
speed: 0, speed: 0,
tps: 0, tps: 0,
addressNumber: 0, addressNumber: 0,
latestTxs: [], latestTxs: [] as icustomizedTx[],
ticketCount: 0, ticketCount: 0,
timer: 0, timer: 0,
}; };
......
...@@ -4,6 +4,10 @@ import { getBlockOverviewAndRelativeHeight } from "ycc-api/dist/cmjs/service/blo ...@@ -4,6 +4,10 @@ import { getBlockOverviewAndRelativeHeight } from "ycc-api/dist/cmjs/service/blo
import { message } from "ant-design-vue"; import { message } from "ant-design-vue";
import { tradeAccuracy } from "@/utils/common"; import { tradeAccuracy } from "@/utils/common";
import { getConsensusList } from "@/utils/consensus"; import { getConsensusList } from "@/utils/consensus";
import {
iConsensusNodeTablListItem,
iGetTxByHashesRetTxItem,
} from "@/types/blockDetail";
const Rpc = getRpc("/yccApi"); const Rpc = getRpc("/yccApi");
export default Vue.extend({ export default Vue.extend({
data() { data() {
...@@ -13,7 +17,7 @@ export default Vue.extend({ ...@@ -13,7 +17,7 @@ export default Vue.extend({
txRecordFilterValue: "allTx", txRecordFilterValue: "allTx",
consensusNodeFilterValue: "allNode", consensusNodeFilterValue: "allNode",
consensusNodeTableList: [] as any[], consensusNodeTableList: [] as iConsensusNodeTablListItem[],
loadingConsensusNodeTable: false, loadingConsensusNodeTable: false,
overview: { overview: {
txCount: 0, txCount: 0,
...@@ -27,8 +31,8 @@ export default Vue.extend({ ...@@ -27,8 +31,8 @@ export default Vue.extend({
loadingOverview: false, loadingOverview: false,
loadingRelativeNumber: false, loadingRelativeNumber: false,
loadingTable: false, loadingTable: false,
allTrades: [] as any[], allTrades: [] as iGetTxByHashesRetTxItem[],
txHashes: [], txHashes: [] as string[],
pages: { pages: {
currentPage: 1, currentPage: 1,
pageSize: 10, pageSize: 10,
...@@ -48,15 +52,14 @@ export default Vue.extend({ ...@@ -48,15 +52,14 @@ export default Vue.extend({
this.consensusNodeTableList = getConsensusList(data.result.txs) this.consensusNodeTableList = getConsensusList(data.result.txs)
.map((i) => { .map((i) => {
return { return {
height: this.$route.query.height, height: Number(this.$route.query.height as string),
address: i.addr, address: i.addr,
reward: i.reward, reward: i.reward,
time: data.result.txs[0].blockTime, time: data.result.txs[0].blockTime,
type: i.type, type: i.type,
}; };
}) })
.sort((a, b) => (a.type === "pack" ? -1 : 0)); .sort((a) => (a.type === "pack" ? -1 : 0));
// this.searchIcon(data.result.txs);
this.allTrades = this.checkGroup(data.result.txs); this.allTrades = this.checkGroup(data.result.txs);
} else { } else {
message.warning(this.$t("components.tip") + data.error); message.warning(this.$t("components.tip") + data.error);
......
...@@ -20,9 +20,6 @@ export default Vue.extend({ ...@@ -20,9 +20,6 @@ export default Vue.extend({
} }
}); });
}, },
activated() {
this.init();
},
computed: { computed: {
tradeInTotalList(): any { tradeInTotalList(): any {
return [ return [
......
import { getTxCount, getTxList } from "@/service/api"; import { getTxCount, getTxList } from "@/service/api";
import { icustomized2Tx } from "@/types/trade";
import Vue from "vue"; import Vue from "vue";
export default Vue.extend({ export default Vue.extend({
data() { data() {
...@@ -9,7 +10,7 @@ export default Vue.extend({ ...@@ -9,7 +10,7 @@ export default Vue.extend({
pageSize: 20, pageSize: 20,
total: 10, total: 10,
}, },
txList: [] as any[], txList: [] as icustomized2Tx[],
loading: false, loading: false,
Timer: 0, Timer: 0,
}; };
...@@ -18,7 +19,7 @@ export default Vue.extend({ ...@@ -18,7 +19,7 @@ export default Vue.extend({
this.init(); this.init();
}, },
methods: { methods: {
checkGroup(arr: any[]) { checkGroup(arr: icustomized2Tx[]) {
arr.map((current, index) => { arr.map((current, index) => {
if (current.group_count > 1) { if (current.group_count > 1) {
current.tradeG = 1; //0-非交易组,1-交易组,3-交易组末条, 2-交易组首条 current.tradeG = 1; //0-非交易组,1-交易组,3-交易组末条, 2-交易组首条
......
import { iTx } from "./trade";
export interface iTxRecord {
tradeG: number;
}
export interface iVote extends iTx {
sender: string;
receiver: string;
time: number;
}
export interface iPack extends iTx {
sender: string;
receiver: string;
time: number;
}
export interface iExecAccount {
account: { addr: string; balance: number; currency: number; frozen: number };
execer: string;
}
export interface iBlockInBlockMixin {
height: number;
blockTime: number;
minerHash: string;
txCount: number;
hash?: string;
}
export interface iGetBlocksRetResultItemBlockTx {
chainID: number;
execer: string;
expire: number;
fee: number;
feefmt: string;
from: string;
hash: string;
nonce: number;
payload: any;
rawPayload: string;
signature: any;
to: string;
}
export interface iGetBlocksRetResultItemBlock {
blockTime: number;
difficulty: number;
height: number;
parentHash: string;
stateHash: string;
txHash: string;
txs: iGetBlocksRetResultItemBlockTx[];
version: number;
}
export interface iGetBlocksRetResultItemRecipt {
logs: any[];
ty: number;
tyName: string;
}
export interface iGetBlocksRetResultItem {
block: iGetBlocksRetResultItemBlock;
recipts: iGetBlocksRetResultItemRecipt[];
}
import {
iGetBlocksRetResultItemBlockTx,
iGetBlocksRetResultItemRecipt,
} from "./block";
export interface iConsensusNodeTablListItem {
height: number;
address: string;
reward: number;
time: number;
type: "pack" | "vote";
}
export interface iGetTxByHashesRetTxItemTx
extends iGetBlocksRetResultItemBlockTx {
amount: number;
amountfmt: string;
}
export interface iGetTxByHashesRetTxItem {
actionName: string;
amount: number;
assets: any[];
blockTime: number;
fromAddr: string;
fullHash: string;
height: number;
index: number;
proofs: any;
receipt: iGetBlocksRetResultItemRecipt;
tx: iGetTxByHashesRetTxItemTx;
txProofs: any;
}
...@@ -3,3 +3,33 @@ export interface iAsset { ...@@ -3,3 +3,33 @@ export interface iAsset {
exec: string; exec: string;
symbol: string; symbol: string;
} }
export interface iTx {
action_name: string;
amount: number;
assets: any[];
block_hash: string;
block_time: number;
execer: string;
fee: number;
from: string;
group_count: number;
hash: string;
height: number;
height_index: number;
index: number;
is_para: boolean;
is_withdraw: boolean;
next: string;
options: any;
success: boolean;
to: string;
}
export interface icustomizedTx extends iTx {
time_block: string;
}
export interface icustomized2Tx extends iTx {
tradeG: number;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment