Skip to content

Commit

Permalink
Merge pull request #108 from Ashuaidehao/dev-back
Browse files Browse the repository at this point in the history
rc2
  • Loading branch information
Ashuaidehao authored May 11, 2021
2 parents d1a158e + cbe16b1 commit 246a533
Show file tree
Hide file tree
Showing 13 changed files with 90 additions and 25 deletions.
2 changes: 1 addition & 1 deletion neo
Submodule neo updated 101 files
2 changes: 1 addition & 1 deletion neo3-gui/neo3-gui/Common/Consoles/CliSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class LoggerSettings

public LoggerSettings(IConfigurationSection section)
{
this.Path = string.Format(section.GetValue("Path", "Logs_{0}"), CliSettings.Default.Protocol.Magic.ToString("X8"));
this.Path = section.GetValue("Path", "Logs_{0}");
this.ConsoleOutput = section.GetValue("ConsoleOutput", false);
this.Active = section.GetValue("Active", false);
}
Expand Down
6 changes: 3 additions & 3 deletions neo3-gui/neo3-gui/Common/Consoles/MainService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ private bool SignAndSendTx(Transaction tx)
ContractParametersContext context;
try
{
context = new ContractParametersContext(NeoSystem.StoreView, tx);
context = new ContractParametersContext(NeoSystem.StoreView, tx, CliSettings.Default.Protocol.Network);
}
catch (InvalidOperationException ex)
{
Expand Down Expand Up @@ -982,7 +982,7 @@ private bool OnSendCommand(string[] args)
return true;
}

ContractParametersContext context = new ContractParametersContext(snapshot, tx);
ContractParametersContext context = new ContractParametersContext(snapshot, tx, CliSettings.Default.Protocol.Network);
CurrentWallet.Sign(context);
if (context.Completed)
{
Expand Down Expand Up @@ -1272,7 +1272,7 @@ public void OpenWallet(string path, string password)
}
}


private void WriteBlocks(uint start, uint count, string path, bool writeStart)
{
uint end = start + count - 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static LevelDbContext()
Directory.CreateDirectory("Data_Track");
}
}
public LevelDbContext() : this(Path.Combine("Data_Track", $"TransactionLog_LevelDB_{CliSettings.Default.Protocol.Magic}"))
public LevelDbContext() : this(Path.Combine("Data_Track", $"TransactionLog_LevelDB_{CliSettings.Default.Protocol.Network}"))
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static SQLiteContext()
}
}

public SQLiteContext() : this(Path.Combine($"Data_Track", $"track.{CliSettings.Default.Protocol.Magic}.db"))
public SQLiteContext() : this(Path.Combine($"Data_Track", $"track.{CliSettings.Default.Protocol.Network}.db"))
{
}

Expand Down
2 changes: 1 addition & 1 deletion neo3-gui/neo3-gui/Common/Storage/TrackDB.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static TrackDB()

public TrackDB()
{
_magic = CliSettings.Default.Protocol.Magic;
_magic = CliSettings.Default.Protocol.Network;
_sqldb = new SQLiteContext(Path.Combine($"Data_Track", $"track.{_magic}.db"));
_leveldb = new LevelDbContext(Path.Combine("Data_Track", $"TransactionLog_LevelDB_{_magic}"));

Expand Down
2 changes: 1 addition & 1 deletion neo3-gui/neo3-gui/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ public static bool SignContext(this Wallet wallet, ContractParametersContext sig
/// <returns></returns>
public static (bool, ContractParametersContext) TrySignTx(this Wallet wallet, Transaction tx)
{
var context = new ContractParametersContext(GetDefaultSnapshot(), tx);
var context = new ContractParametersContext(GetDefaultSnapshot(), tx, CliSettings.Default.Protocol.Network);
var signResult = wallet.SignContext(context);
if (signResult)
{
Expand Down
2 changes: 1 addition & 1 deletion neo3-gui/neo3-gui/Models/Contracts/ManifestModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public ManifestModel(ContractManifest manifest)
/// The trusts field is an array containing a set of contract hashes or group public keys. It can also be assigned with a wildcard *. If it is a wildcard *, then it means that it trusts any contract.
/// If a contract is trusted, the user interface will not give any warnings when called by the contract.
/// </summary>
public WildcardContainer<UInt160> Trusts { get; set; }
public WildcardContainer<ContractPermissionDescriptor> Trusts { get; set; }


public string[] SupportedStandards
Expand Down
Binary file modified neo3-gui/neo3-gui/Plugins/LevelDBStore.dll
Binary file not shown.
65 changes: 65 additions & 0 deletions neo3-gui/neo3-gui/Services/ApiServices/ContractApiService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,71 @@ public async Task<object> DeployContract(string nefPath, string manifestPath = n
return result;
}



public async Task<object> UpdateContract(UInt160 contractHash, string nefPath, string manifestPath = null, bool sendTx = false, UInt160 sender = null)
{
if (CurrentWallet == null)
{
return Error(ErrorCode.WalletNotOpen);
}
if (nefPath.IsNull())
{
return Error(ErrorCode.ParameterIsNull, "nefPath is empty.");
}
if (manifestPath.IsNull())
{
manifestPath = Path.ChangeExtension(nefPath, ".manifest.json");
}
// Read nef
NefFile nefFile = ReadNefFile(nefPath);
// Read manifest
ContractManifest manifest = ReadManifestFile(manifestPath);
// Basic script checks
await CheckBadOpcode(nefFile.Script);

// Build script
using ScriptBuilder sb = new ScriptBuilder();
sb.EmitDynamicCall(contractHash, "update", nefFile.ToArray(), manifest.ToJson().ToString(), null);
var script = sb.ToArray();

var singers = new Signer[] { new Signer() { Account = sender, Scopes = WitnessScope.Global } };
Transaction tx;
try
{
tx = CurrentWallet.MakeTransaction(Helpers.GetDefaultSnapshot(), script, sender, singers);
}
catch (InvalidOperationException ex)
{
return Error(ErrorCode.EngineFault, ex.GetExMessage());
}
catch (Exception ex)
{
if (ex.Message.Contains("Insufficient GAS"))
{
return Error(ErrorCode.GasNotEnough);
}
throw;
}

var result = new DeployResultModel
{
ContractHash = contractHash,
GasConsumed = new BigDecimal((BigInteger)tx.SystemFee, NativeContract.GAS.Decimals)
};
if (sendTx)
{
var (signSuccess, context) = CurrentWallet.TrySignTx(tx);
if (!signSuccess)
{
return Error(ErrorCode.SignFail, context.SafeSerialize());
}
await tx.Broadcast();
result.TxId = tx.Hash;
}
return result;
}

public async Task<object> InvokeContract(InvokeContractParameterModel para)
{
if (CurrentWallet == null)
Expand Down
18 changes: 9 additions & 9 deletions neo3-gui/neo3-gui/config.private.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"ApplicationConfiguration": {
"Logger": {
"Path": "Logs",
"ConsoleOutput": false,
"Active": false
},
"Storage": {
"Engine": "LevelDBStore",
"Path": "Data_LevelDB_55555"
Expand All @@ -8,24 +13,19 @@
"Port": 30333,
"WsPort": 30334
},
"UnlockWallet": {
"Path": "",
"Password": "",
"IsActive": false
},
"PluginURL": "https://github.com/neo-project/neo-modules/releases/download/v{1}/{0}.zip"
},
"ProtocolConfiguration": {
"Magic": 55555,
"Network": 55555,
"MillisecondsPerBlock": 15000,
"MaxTraceableBlocks": 2102400,
"ValidatorsCount": 1,
"StandbyCommittee": [
"021b3f15c2c98e99794c2121a0f3683803edcf488e621480f6050fd6b01432e18b"
"021821807f923a3da004fb73871509d7635bcc05f41edef2a3ca5c941d8bbc1231"
],
"SeedList": [
//"127.0.0.1:10333"
"128.1.61.238:30333"
"20.198.249.57:30333"
]
}
}
}
9 changes: 5 additions & 4 deletions neo3-gui/neo3-gui/config.testnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
},
"Storage": {
"Engine": "LevelDBStore",
"Path": "Data_LevelDB_827601742"
"Path": "Data_LevelDB_844378958"
},
"P2P": {
"Port": 30333,
"WsPort": 30334
"Port": 20333,
"WsPort": 20334
},
"UnlockWallet": {
"Path": "",
Expand All @@ -21,7 +21,7 @@
"PluginURL": "https://github.com/neo-project/neo-modules/releases/download/v{1}/{0}.zip"
},
"ProtocolConfiguration": {
"Magic": 827601742,
"Network": 844378958,
"MillisecondsPerBlock": 15000,
"MaxTraceableBlocks": 2102400,
"ValidatorsCount": 7,
Expand All @@ -43,3 +43,4 @@
]
}
}

3 changes: 1 addition & 2 deletions neo3-gui/neo3-gui/neo3-gui.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@

<ItemGroup>
<PackageReference Include="EFCore.BulkExtensions" Version="3.1.1" />
<PackageReference Include="Neo" Version="3.0.0-rc1" />
<PackageReference Include="Neo" Version="3.0.0-rc2" />
<PackageReference Include="Neo.LevelDb.Dev" Version="3.0.0-pre4" />
<PackageReference Include="System.ServiceProcess.ServiceController" Version="4.6.0" />
</ItemGroup>


<ItemGroup>
<!--<ProjectReference Include="..\..\neo\src\neo\neo.csproj" />-->
</ItemGroup>
Expand Down

0 comments on commit 246a533

Please sign in to comment.