Commit 69d36303 authored by chenqikuai's avatar chenqikuai

add types

parent faa56cd4
......@@ -31,7 +31,7 @@ export default VueTypedMixins().extend({
props: {
balance: [Number, Object],
selectedValue: String,
frozen: Number,
frozen: [Number, Object],
optionsList: Array,
handleSelectChange: Function,
},
......
......@@ -88,7 +88,7 @@ export default VueTypedMixins(AddressOverview).extend({
props: {
balance: [Number, Object],
selectedValue: String,
frozen: Number,
frozen: [Number, Object],
optionsList: Array,
handleSelectChange: Function,
},
......
......@@ -6,6 +6,8 @@ import {
getVoterAddr,
getVoterAddrCount,
} from "@/service/api";
import { iExecAccount, iPack, iVote } from "@/types/address";
import { icustomized2Tx, iTx } from "@/types/trade";
import Rpc from "@/utils/Rpc";
import Vue from "vue";
......@@ -31,11 +33,11 @@ export default Vue.extend({
},
selectedOption: "1",
loadingTxRecordTable: false,
txRecordList: [] as any[],
voteList: [] as any[],
txRecordList: [] as icustomized2Tx[],
voteList: [] as iVote[],
selectedExecer: "",
execAccount: [] as any[],
packList: [] as any[],
execAccount: [] as iExecAccount[],
packList: [] as iPack[],
loadingVote: false,
loadingPack: false,
};
......@@ -69,13 +71,13 @@ export default Vue.extend({
{ name: this.$t("lang.trade.consensusNode"), value: "2" },
];
},
execerOptionsList(): any {
execerOptionsList(): { name: string; value: string }[] {
return this.execAccount.map((i: any) => ({
name: i.execer,
value: i.execer,
}));
},
balance(): any {
balance(): number {
return (
this.execAccount.find((i: any) => i.execer === this.selectedExecer) || {
account: {
......@@ -84,7 +86,7 @@ export default Vue.extend({
}
)?.account?.balance;
},
frozen(): any {
frozen(): number {
return (
this.execAccount.find((i: any) => i.execer === this.selectedExecer) || {
account: {
......@@ -103,7 +105,7 @@ export default Vue.extend({
}
});
},
checkGroup(arr: any[]) {
checkGroup(arr: icustomized2Tx[]) {
arr.map((current, index) => {
if (current.group_count > 1) {
current.tradeG = 1; //0-非交易组,1-交易组,3-交易组末条, 2-交易组首条
......
......@@ -2,6 +2,8 @@ import Vue from "vue";
import { message } from "ant-design-vue";
import { getRpc } from "ycc-api/dist/cmjs/service/Rpc";
const Rpc = getRpc("/yccApi");
import { iBlockInBlockMixin, iGetBlocksRetResultItem } from "@/types/block";
export default Vue.extend({
data() {
return {
......@@ -16,7 +18,7 @@ export default Vue.extend({
pageSize: 20,
total: 10,
},
Blocks: [] as any[],
Blocks: [] as iBlockInBlockMixin[],
};
},
mounted() {
......@@ -38,8 +40,6 @@ export default Vue.extend({
} else {
this.Loading = false;
message.warning({
// title: this.$t('components.tip'),
// message: data.error,
content: data.error as string,
});
}
......@@ -75,23 +75,26 @@ export default Vue.extend({
Rpc.getBlocks(this.startHeight, this.endHeight, true).then((data) => {
if (data.error === null) {
const info = data.result.items.reverse().map((i: any) => ({
height: i.block.height,
blockTime: i.block.blockTime,
minerHash: i.block.txs[0].from,
txCount: i.block.txs.length,
}));
const info = (data.result.items as iGetBlocksRetResultItem[])
.reverse()
.map((i) => ({
height: i.block.height,
blockTime: i.block.blockTime,
minerHash: i.block.txs[0].from,
txCount: i.block.txs.length,
}));
if (this.pages.currentPage === 1) {
this.Blocks = [...info, ...this.Blocks];
this.Blocks.length = this.pages.pageSize;
} else {
this.Blocks = info;
}
info.map((i: any) => {
info.map((i) => {
Rpc.getBlockHash(i.height).then((ret) => {
(
this.Blocks.find((block) => block.height === i.height) || {}
).hash = ret.result.hash;
const the = this.Blocks.find(
(block) => block.height === i.height
);
the && (the.hash = ret.result.hash);
this.Blocks = [...this.Blocks];
});
});
......
......@@ -12,6 +12,9 @@ import {
getTxCountBewteenTimes,
getTxList,
} from "@/service/api";
import { icustomizedTx } from "@/types/trade";
export default Vue.extend({
data() {
return {
......@@ -25,7 +28,7 @@ export default Vue.extend({
speed: 0,
tps: 0,
addressNumber: 0,
latestTxs: [],
latestTxs: [] as icustomizedTx[],
ticketCount: 0,
timer: 0,
};
......
......@@ -4,6 +4,10 @@ import { getBlockOverviewAndRelativeHeight } from "ycc-api/dist/cmjs/service/blo
import { message } from "ant-design-vue";
import { tradeAccuracy } from "@/utils/common";
import { getConsensusList } from "@/utils/consensus";
import {
iConsensusNodeTablListItem,
iGetTxByHashesRetTxItem,
} from "@/types/blockDetail";
const Rpc = getRpc("/yccApi");
export default Vue.extend({
data() {
......@@ -13,7 +17,7 @@ export default Vue.extend({
txRecordFilterValue: "allTx",
consensusNodeFilterValue: "allNode",
consensusNodeTableList: [] as any[],
consensusNodeTableList: [] as iConsensusNodeTablListItem[],
loadingConsensusNodeTable: false,
overview: {
txCount: 0,
......@@ -27,8 +31,8 @@ export default Vue.extend({
loadingOverview: false,
loadingRelativeNumber: false,
loadingTable: false,
allTrades: [] as any[],
txHashes: [],
allTrades: [] as iGetTxByHashesRetTxItem[],
txHashes: [] as string[],
pages: {
currentPage: 1,
pageSize: 10,
......@@ -48,15 +52,14 @@ export default Vue.extend({
this.consensusNodeTableList = getConsensusList(data.result.txs)
.map((i) => {
return {
height: this.$route.query.height,
height: Number(this.$route.query.height as string),
address: i.addr,
reward: i.reward,
time: data.result.txs[0].blockTime,
type: i.type,
};
})
.sort((a, b) => (a.type === "pack" ? -1 : 0));
// this.searchIcon(data.result.txs);
.sort((a) => (a.type === "pack" ? -1 : 0));
this.allTrades = this.checkGroup(data.result.txs);
} else {
message.warning(this.$t("components.tip") + data.error);
......
......@@ -20,9 +20,6 @@ export default Vue.extend({
}
});
},
activated() {
this.init();
},
computed: {
tradeInTotalList(): any {
return [
......
import { getTxCount, getTxList } from "@/service/api";
import { icustomized2Tx } from "@/types/trade";
import Vue from "vue";
export default Vue.extend({
data() {
......@@ -9,7 +10,7 @@ export default Vue.extend({
pageSize: 20,
total: 10,
},
txList: [] as any[],
txList: [] as icustomized2Tx[],
loading: false,
Timer: 0,
};
......@@ -18,7 +19,7 @@ export default Vue.extend({
this.init();
},
methods: {
checkGroup(arr: any[]) {
checkGroup(arr: icustomized2Tx[]) {
arr.map((current, index) => {
if (current.group_count > 1) {
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 {
exec: 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