Skip to content

Commit

Permalink
contract invoke refac
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashuaidehao committed Sep 23, 2022
1 parent 62b27a4 commit b3ec0c8
Show file tree
Hide file tree
Showing 26 changed files with 592 additions and 452 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@
"transaction info": "Transaction Info",
"transactions": "Transactions",
"unconfirmed transactions": "Unconfirmed Transactions",
"witness": "Witness"
"witness": "Witness",
"search input-invalid": "input block is not exist"
},
"button": {
"cancel": "Cancel",
Expand Down Expand Up @@ -194,11 +195,12 @@
"please input password": "Please input password",
"please select file location": "Please select file location",
"search": {
"chain-hint": "Pelese input height",
"chain-hint": "Please input height or hash",
"check again": "Please check input",
"hash unexist": "The hash not exist,please check again",
"hash-hint": "Pelese input hash",
"height unexist": "The height not exist,please check again"
"height unexist": "The height not exist,please check again",
"asset-search-hint": "please input asset hash"
},
"select account": "Select Address",
"select path": "Select Path",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@
"transaction info": "交易信息",
"transactions": "交易列表",
"unconfirmed transactions": "待确认交易",
"witness": "见证人"
"witness": "见证人",
"search input-invalid": "查询的区块不存在"
},
"button": {
"cancel": "取消",
Expand Down Expand Up @@ -194,11 +195,12 @@
"please input password": "请输入密码",
"please select file location": "请选择文件存储位置",
"search": {
"chain-hint": "输入需要查找的 height",
"chain-hint": "输入需要查找的高度或Hash",
"check again": "请检查输入是否正确",
"hash unexist": "该合约hash不存在,请查证后再输入",
"hash-hint": "输入需要查找的脚本散列",
"height unexist": "该高度不存在,请查证后再输入"
"height unexist": "该高度不存在,请查证后再输入",
"asset-search-hint": "请输入资产Hash"
},
"select account": "选择地址",
"select path": "选择路径",
Expand Down
2 changes: 2 additions & 0 deletions neo3-gui/neo3-gui/ClientApp/src/components/Chain/asset.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Sync from "../sync";
import { withTranslation, useTranslation } from "react-i18next";
import { postAsync } from "../../core/request";
import "../../static/css/chain.css";
import AssetSearch from "./assetSearch";

export default function ChainAsset() {
const { Content } = Layout;
Expand Down Expand Up @@ -78,6 +79,7 @@ export default function ChainAsset() {
/>
</div>
</Col>
<AssetSearch></AssetSearch>
</Row>
<div className="pv1"></div>
</Content>
Expand Down
92 changes: 92 additions & 0 deletions neo3-gui/neo3-gui/ClientApp/src/components/Chain/assetSearch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/* eslint-disable */
import React from "react";
import "antd/dist/antd.css";
import { Input, message } from "antd";
import Topath from "../Common/topath";
import { ArrowRightOutlined, SearchOutlined } from "@ant-design/icons";
import { withTranslation } from "react-i18next";
import { postAsync } from "../../core/request";

@withTranslation()
class AssetSearch extends React.Component {
constructor(props) {
super(props);
this.state = {
size: "default",
path: "",
disabled: false,
cname: "search-content",
};
}
addClass = (e) => {
this.stopPropagation(e);
this.setState({
cname: "search-content height-sea show-child",
disabled: true,
});
document.addEventListener("click", this.removeClass);
};
removeClass = () => {
if (this.state.disabled) {
this.setState({
cname: "search-content height-sea",
disabled: false,
});
}
document.removeEventListener("click", this.removeClass);
setTimeout(
() =>
this.setState({
cname: "search-content",
disabled: false,
}),
500
);
};
stopPropagation(e) {
e.nativeEvent.stopImmediatePropagation();
}
searchAsset = async () => {
const { t } = this.props;
let hash = this.refs.sinput.input.value.trim();
if (!hash || hash.length != 42) {
message.info(t("search.check again"));
return;
}
let response = await postAsync("GetContract", {
contractHash: hash,
});
if (response.msgType === -1) {
message.info(t("search.check again"));
return;
}
this.setState({ topath: "/chain/asset:" + hash });
};
render = () => {
const { t } = this.props;
return (
<div className="search-area">
<Topath topath={this.state.topath}></Topath>
<div className="search-btn">
<SearchOutlined className="inset-btn" onClick={this.addClass} />
</div>
<div className={this.state.cname}>
<div
className="search-detail"
ref="sarea"
onClick={this.stopPropagation}
>
<Input
placeholder={t("search.asset-search-hint")}
onPressEnter={this.searchAsset}
ref="sinput"
suffix={<ArrowRightOutlined onClick={this.searchAsset} />}
/>
</div>
</div>
</div>
);
};
}

export default AssetSearch;
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export default function BlockDetail() {
const [height, setHeight] = useState(0);
const [blockdetail, setBlockDetail] = useState({});
const [translist, setTransList] = useState([]);
let blockHeight = Number(location.pathname.split(":").pop());
let identity = location.pathname.split(":").pop();
let blockHeight = Number(identity);
useEffect(() => {
postAsync("GetBlock", { index: blockHeight })
.then(function (data) {
Expand All @@ -25,9 +26,6 @@ export default function BlockDetail() {
return;
}
setBlockDetail(data.result);
})
.catch(function (error) {
console.log(error);
});

postAsync("QueryTransactions", { blockHeight: blockHeight, limit: 500, })
Expand All @@ -37,9 +35,6 @@ export default function BlockDetail() {
return;
}
setTransList(msg.result.list);
})
.catch(function (error) {
console.log(error);
});
}, [height]);
return (
Expand Down
3 changes: 1 addition & 2 deletions neo3-gui/neo3-gui/ClientApp/src/components/Chain/chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ import {
Button,
PageHeader,
} from "antd";
import Chainsearch from "./searcharea";
import Chainsearch from "./chainSearch";
import Sync from "../sync";
import { withTranslation } from "react-i18next";

import "../../static/css/contract.css";
import { postAsync } from "../../core/request";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint-disable */
import React from "react";
import "antd/dist/antd.css";
import axios from "axios";
import { Input, message } from "antd";
import Topath from "../Common/topath";
import { ArrowRightOutlined, SearchOutlined } from "@ant-design/icons";
Expand Down Expand Up @@ -49,19 +48,24 @@ class Chainsearch extends React.Component {
}
searchChain = async () => {
const { t } = this.props;
let _height = Number(this.refs.sinput.input.value.trim());
if (!_height && _height != 0) {
let input = this.refs.sinput.input.value.trim();
let blockHeight = 0;
let blockHash = null;
if (input.length == 66) {
blockHash = input
} else {
blockHeight = Number(input);
}
if (!input) {
message.info(t("search.check again"));
return;
}
let response = await postAsync("GetBlock", {
index: _height,
});
let response = !blockHash ? (await postAsync("GetBlock", { index: blockHeight })) : (await postAsync("GetBlockByHash", { hash: blockHash }));
if (response.msgType === -1) {
message.info(t("blockchain.height unexist"));
message.info(t("blockchain.search input-invalid"));
return;
}
this.setState({ topath: "/chain/detail:" + _height });
this.setState({ topath: "/chain/detail:" + response.result.blockHeight });
};
render = () => {
const { t } = this.props;
Expand Down
115 changes: 0 additions & 115 deletions neo3-gui/neo3-gui/ClientApp/src/components/Chain/hashdetail.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ class DataConverter {
return Buffer.from(hexString, "hex").toString("base64");
}


/**
* input: 'Y6OYnLSplXGqADltPHFV+upAmLo=',output:'63a3989cb4a99571aa00396d3c7155faea4098ba'
* @param {*} base64String
*/
fromBase64String(base64String) {
return Buffer.from(base64String, "base64").toString("hex");
}

/**
* Encode hex string to utf8 string,input:'7472616e73666572',output:'transfer'
* @param {*} hexString
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { observer, inject } from "mobx-react";
import { withRouter } from "react-router-dom";
import "antd/dist/antd.css";
import { message, Modal, Radio } from "antd";
import axios from "axios";
import { Addressdetail, Changepass, Setting } from "./menuaction";
import {
ReadOutlined,
Expand Down
Loading

0 comments on commit b3ec0c8

Please sign in to comment.