Skip to content

Commit

Permalink
Merge pull request #128 from Ashuaidehao/dev-back
Browse files Browse the repository at this point in the history
Dev back
  • Loading branch information
Ashuaidehao authored Aug 8, 2021
2 parents 604e7b4 + 98c2790 commit 3d3ec69
Show file tree
Hide file tree
Showing 28 changed files with 362 additions and 304 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Your feedbacks and suggestions are welcome. Please submit issues.

## Required Tools and Dependencies for development

1. [Visual Studio 2019](https://visualstudio.microsoft.com/) and [.NET Core 3.1](https://dotnet.microsoft.com/download)
1. [Visual Studio 2019](https://visualstudio.microsoft.com/) and [.NET Core 5.0](https://dotnet.microsoft.com/download)
2. [Node.js](https://nodejs.org/)

## Build and Run
Expand Down
33 changes: 33 additions & 0 deletions neo3-gui/neo3-gui.tests/OpCodeParser_Test.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Neo;
using Neo.Common.Utility;
using Neo.VM;

namespace neo3_gui.tests
{
[TestClass]
public class OpCodeParser_Test
{
[TestMethod]
public void Test()
{

var script =
"0d4501e70f75f78a0bc128ea55c53bffec7f0d2fa4da5793e5c810d3faf78bcf0f517a73d98e5911db9d13bfeaa69a4ab84a356241aa11e23b970be6cf2fe06aeb1cc60108d7699fe00e9ae224bfeca82e49af360d30ff80edf972ad2d323461e82778af33453db04a34275cfbbe2af1eb692eece921b16a4b18a16a1d8ce850baab32ef01e041b3b53218b755a58cc84a938de52e648f00e010ee1ea87f0a0eb12af9d7427fc477dbf566e0fca084017ec2bae5e1a1bbb9539c59170cf687e45a8ddeba0e01feb56c064339cc468d3ade9179754887579f04b612c4c2cc5c1d8f6c0781246071f68900248c6b56724135428600988f0b850d5464d59206f820a9590445663a01449d1a8b4e08ed8e06ee250d57a701f390aed87dcb75456d112661035733b1944fc5f66f5c417041ab7180134f2ef1729f714bd02de35d3bef10f554843dad2d000c000c000dc60100000000ffffffffffffff7fdef0100970c3cb67e2c8066a6a97d3c1669d03fc91045bbe1b84eec97b0ad08932824d90bd7c27c90a413483c3635b59f3d3a040e1ab74485c99614e835e2bd02bda7e1ab674e41ac8254b11fb06361b70d57591551da475c7ffc7e3f3ce6dde3fd1ad4bca7e978ada9f9154365f63c855f468a19c8ad3e59d4778c531d4b0c6113bf9607778b900067b3c67a0fb82dbfd13017b226c6561646572223a352c227672665f76616c7565223a22424c6769682f62574378672b54617a5a326253496a556354586e2f2f754679575a6e5876377953774467744a474e377a4d7974442f7637424341536a634f676b7754656d414c68786e636458566252335a75324e4952673d222c227672665f70726f6f66223a2266465074723936425a735461514269766c43693370715a47696241496832384c534d506f4f6b6a4f4b7376686475447a30324e7861753659313171686874384f514e7751323347787a58513638694239774b334f76673d3d222c226c6173745f636f6e6669675f626c6f636b5f6e756d223a31323135303736372c226e65775f636861696e5f636f6e666967223a6e756c6c7d00000000000000000000000000000000000000000cf0ef20702f6edd397bf6181e391867ba23ec77d2ad717748ab8d914d9ec1e5db74afa605000000000000002064c809ee29044d8cd6ad05dce818c5d8000ed816d0e74c04fb97c5246d29356420fd03f64d5c82a6123d30528507c709e14bda44f4ab3d8ff399c5d5f4d90cd8d2144f5f702b3f459f222d371052940bb9ce2d86d2ed58000000000000001442e54382e86dcdca09e0da8bb67e2fac4d49874406756e6c6f636b4a14cf76e28bd0062c4a478ee35561011319f3cfa4d2140482c3d160c011bf95d2b7ed3b5da7688181ce67009c9f060000000000000000000000000000000000000000000000000000000015c01f0c12766572696679416e644578656375746554780c142a774fa0404f020254f6db20616cf13adc448d6141627d5b52"
.HexToBytes();


var instructions = OpCodeConverter.Parse(script);
foreach (var instructionInfo in instructions)
{
Console.WriteLine($"My:{instructionInfo.OpCode},{instructionInfo.OpData?.ToHexString()}");

}
}
}
}
13 changes: 0 additions & 13 deletions neo3-gui/neo3-gui.tests/TestBlockchain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,5 @@ public static class TestBlockchain
{
public static readonly NeoSystem TheNeoSystem;

static TestBlockchain()
{
Console.WriteLine("initialize NeoSystem");
TheNeoSystem = new NeoSystem();

// Ensure that blockchain is loaded

var _ = Blockchain.Singleton;
}

public static void InitializeMockNeoSystem()
{
}
}
}
2 changes: 1 addition & 1 deletion neo3-gui/neo3-gui/ClientApp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion neo3-gui/neo3-gui/ClientApp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "neo-gui",
"version": "1.3.0",
"version": "1.3.1",
"private": true,
"main": "main.js",
"homepage": "./",
Expand Down
12 changes: 7 additions & 5 deletions neo3-gui/neo3-gui/ClientApp/src/components/Contract/upgrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@ class ContractUpgrade extends React.Component {
selectNef = async () => {
this.opendialog("nef", async (res) => {
let nef = res.filePaths[0];
let manifest = nef.substring(0, nef.length - 3) + "manifest.json";
if (fs.existsSync(manifest)) {
await this.setState({ manipath: manifest });
if (nef) {
let manifest = nef.substring(0, nef.length - 3) + "manifest.json";
if (fs.existsSync(manifest)) {
await this.setState({ manipath: manifest });
}
await this.setState({ nefpath: nef, isOpenDialog: false });
this.onFill()
}
await this.setState({ nefpath: nef, isOpenDialog: false });
this.onFill()
});
};
selectMani = async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { Component } from "react";
import { Link } from "react-router-dom";
import { Layout, Row, Col, Typography } from "antd";

import Sync from "../components/sync";
import Sync from "./sync";
import "../static/css/site.css";
import "../static/css/home.css";
import img from "../static/images/logo.svg";
Expand Down
26 changes: 1 addition & 25 deletions neo3-gui/neo3-gui/ClientApp/src/core/authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,5 @@ function Authenticated(Component) {
return Component.AuthenticatedComponent;
}

function unAuthenticated(Component) {
// 组件有已登陆的模块 直接返回 (防止重新渲染)
if (Component.AuthenticatedComponent) {
return Component.AuthenticatedComponent;
}

// 创建验证组件
@inject("walletStore")
@observer
class AuthenticatedComponent extends React.Component {
render() {
const walletOpen = walletStore.isOpen;
console.log(walletOpen);
return (
<div style={{ width: "100%" }}>
{walletOpen ? <Component {...this.props} /> : <Wallet />}
</div>
);
}
}

Component.AuthenticatedComponent = AuthenticatedComponent;
return Component.AuthenticatedComponent;
}

export { Authenticated, unAuthenticated };
export { Authenticated };
9 changes: 5 additions & 4 deletions neo3-gui/neo3-gui/ClientApp/src/core/request.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
import axios from "axios";
import { message } from "antd";
import { method } from "lodash";
import Config from "../config";

let count = 0;
const request = async (method, params) => {
// 默认Axios Post方法
const url = "http://localhost:8081";
const url = Config.RPCURL;
if (method === "") {
message.error("method null");
return;
}
var options = Object.assign(
{
id: "1",
id: count,
method: method,
},
{ params: params }
);

count++;
return await axios.post(url, options);
};

Expand Down
2 changes: 1 addition & 1 deletion neo3-gui/neo3-gui/ClientApp/src/router/router.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import {BrowserRouter, Route , Switch,Redirect} from 'react-router-dom';
import Home from '../pages/home'
import Home from '../components/home'
import Sync from '../components/sync';

import Chain from '../components/Chain/chain';
Expand Down
54 changes: 32 additions & 22 deletions neo3-gui/neo3-gui/Common/Analyzers/BlockAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class BlockAnalyzerResult
public readonly IDictionary<UInt160, AssetInfo> AssetInfos = new Dictionary<UInt160, AssetInfo>();

/// <summary>
///
/// accounts of balance changed
/// </summary>
public readonly HashSet<AccountAsset> BalanceChangeAccounts = new HashSet<AccountAsset>();
}
Expand Down Expand Up @@ -100,41 +100,37 @@ private void AnalysisAppExecuteResult(Blockchain.ApplicationExecuted appExec)
execResult.Notifications = appExec.Notifications.Select(n => n.ToNotificationInfo()).ToList();
Result.ExecuteResultInfos.Add(execResult);

foreach (var contract in execResult.Notifications.Select(n => n.Contract).Distinct())
{
var asset = AssetCache.GetAssetInfo(contract, _snapshot);
if (asset != null)
{
Result.AssetInfos[asset.Asset] = asset;
}
}

if (execResult.VMState.HasFlag(VMState.FAULT))
if (execResult.VMState.HasFlag(VMState.FAULT) || execResult.Notifications.IsEmpty())
{
//no need to track
return;
}

if (execResult.Notifications.IsEmpty())
{
//no need to track
return;
}

//foreach (var contract in execResult.Notifications.Select(n => n.Contract).Distinct())
//{
// var asset = AssetCache.GetAssetInfo(contract, _snapshot);
// if (asset != null)
// {
// Result.AssetInfos[asset.Asset] = asset;
// }
//}
foreach (var notification in appExec.Notifications)
{
switch (notification.EventName)
{
case "transfer":
case "Transfer":
ProcessTransfer(notification, appExec);
break;
case "Deploy":
ProcessDeploy(notification, appExec);
break;
case "Update":
ProcessUpdate(notification, appExec);
break;
case "Destory":
ProcessDestory(notification, appExec);
break;
case "transfer":
case "Transfer":
ProcessTransfer(notification, appExec);
break;
default:
break;
}
Expand Down Expand Up @@ -206,7 +202,21 @@ private void ProcessDeploy(NotifyEventArgs notification, Blockchain.ApplicationE

private void ProcessUpdate(NotifyEventArgs notification, Blockchain.ApplicationExecuted appExec)
{

if (notification.State.Count != 1) { return; }
var hash = notification.State[0].GetByteSafely();
if (hash == null || hash.Length != 20) { return; }
var contractHash = new UInt160(hash);
if (!Result.ContractChangeEvents.ContainsKey(appExec.Transaction.Hash))
{
Result.ContractChangeEvents[appExec.Transaction.Hash] = new List<ContractEventInfo>();
}
ContractState contract = NativeContract.ContractManagement.GetContract(_snapshot, contractHash);
Result.ContractChangeEvents[appExec.Transaction.Hash].Add(new ContractEventInfo() { Contract = contractHash, Name = contract?.Manifest.Name, Event = ContractEventType.Migrate });
var asset = AssetCache.GetAssetInfoFromChain(contractHash, _snapshot);
if (asset != null)
{
Result.AssetInfos[asset.Asset] = asset;
}
}

private void ProcessDestory(NotifyEventArgs notification, Blockchain.ApplicationExecuted appExec)
Expand Down
Loading

0 comments on commit 3d3ec69

Please sign in to comment.