From 07588fe5dc9b4519610a6a462ba16deb6f20da86 Mon Sep 17 00:00:00 2001 From: bettybao1209 Date: Tue, 19 Jan 2021 10:58:25 +0800 Subject: [PATCH 1/6] update walelt --- src/OracleService/OracleService.cs | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/OracleService/OracleService.cs b/src/OracleService/OracleService.cs index 5b94f034c..950931631 100644 --- a/src/OracleService/OracleService.cs +++ b/src/OracleService/OracleService.cs @@ -32,7 +32,8 @@ public class OracleService : Plugin, IPersistencePlugin { private const int RefreshInterval = 1000 * 60 * 3; - private NEP6Wallet wallet; + private Wallet wallet; + private IWalletProvider walletProvider; private readonly ConcurrentDictionary pendingQueue = new ConcurrentDictionary(); private readonly ConcurrentDictionary finishedCache = new ConcurrentDictionary(); private Timer timer; @@ -73,24 +74,16 @@ public override void Dispose() private void OnStart() { if (started) return; - string password = GetService().ReadUserInput("password", true); - if (password.Length == 0) - { - Console.WriteLine("Cancelled"); - return; - } - wallet = new NEP6Wallet(Settings.Default.Wallet); - try + walletProvider = GetService(); + if (walletProvider is null) { - wallet.Unlock(password); - } - catch (System.Security.Cryptography.CryptographicException) - { - Console.WriteLine($"Failed to open wallet"); + Console.WriteLine("Please open wallet first!"); return; } + wallet = walletProvider.GetWallet(); + using (var snapshot = Blockchain.Singleton.GetSnapshot()) { if (!CheckOracleAvaiblable(snapshot, out ECPoint[] oracles)) throw new ArgumentException("The oracle service is unavailable"); From 0c4030c4c970527f4390a0b6e2304adb8354a8ef Mon Sep 17 00:00:00 2001 From: bettybao1209 Date: Tue, 19 Jan 2021 11:10:49 +0800 Subject: [PATCH 2/6] redefine walletProvider --- src/OracleService/OracleService.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/OracleService/OracleService.cs b/src/OracleService/OracleService.cs index 950931631..39b049e41 100644 --- a/src/OracleService/OracleService.cs +++ b/src/OracleService/OracleService.cs @@ -33,7 +33,6 @@ public class OracleService : Plugin, IPersistencePlugin private const int RefreshInterval = 1000 * 60 * 3; private Wallet wallet; - private IWalletProvider walletProvider; private readonly ConcurrentDictionary pendingQueue = new ConcurrentDictionary(); private readonly ConcurrentDictionary finishedCache = new ConcurrentDictionary(); private Timer timer; @@ -75,7 +74,7 @@ private void OnStart() { if (started) return; - walletProvider = GetService(); + var walletProvider = GetService(); if (walletProvider is null) { Console.WriteLine("Please open wallet first!"); From 9f12c4c0a449304332ab831bf895bf16489be27c Mon Sep 17 00:00:00 2001 From: bettybao1209 Date: Tue, 19 Jan 2021 15:59:32 +0800 Subject: [PATCH 3/6] syc neo --- src/Directory.Build.props | 2 +- src/OracleService/OracleService.cs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index d06c47eb3..a3c857bd4 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -15,7 +15,7 @@ - + diff --git a/src/OracleService/OracleService.cs b/src/OracleService/OracleService.cs index 39b049e41..0271cdc16 100644 --- a/src/OracleService/OracleService.cs +++ b/src/OracleService/OracleService.cs @@ -10,6 +10,7 @@ using Neo.Network.P2P.Payloads; using Neo.Persistence; using Neo.SmartContract; +using Neo.SmartContract.Manifest; using Neo.SmartContract.Native; using Neo.VM; using Neo.Wallets; @@ -333,7 +334,8 @@ public static Transaction CreateResponseTx(StoreView snapshot, OracleRequest req var oracleContract = NativeContract.ContractManagement.GetContract(snapshot, NativeContract.Oracle.Hash); var engine = ApplicationEngine.Create(TriggerType.Verification, tx, snapshot.Clone()); - engine.LoadContract(oracleContract, "verify", CallFlags.None, true); + ContractMethodDescriptor md = oracleContract.Manifest.Abi.GetMethod("verify", -1); + engine.LoadContract(oracleContract, md, CallFlags.None); engine.Push("verify"); if (engine.Execute() != VMState.HALT) return null; tx.NetworkFee += engine.GasConsumed; From 31bd15413dd475da11665f798ba80476ca5b7158 Mon Sep 17 00:00:00 2001 From: Shargon Date: Tue, 19 Jan 2021 09:52:12 +0100 Subject: [PATCH 4/6] Clean settings --- src/OracleService/OracleService/config.json | 1 - src/OracleService/Settings.cs | 2 -- 2 files changed, 3 deletions(-) diff --git a/src/OracleService/OracleService/config.json b/src/OracleService/OracleService/config.json index e08d8f6c2..7fd7f08ce 100644 --- a/src/OracleService/OracleService/config.json +++ b/src/OracleService/OracleService/config.json @@ -1,7 +1,6 @@ { "PluginConfiguration": { "Nodes": [], - "Wallet": "", "MaxTaskTimeout": 432000000, "AllowPrivateHost": false, "AllowedContentTypes": [ "application/json" ], diff --git a/src/OracleService/Settings.cs b/src/OracleService/Settings.cs index 282de2dc1..333100733 100644 --- a/src/OracleService/Settings.cs +++ b/src/OracleService/Settings.cs @@ -17,7 +17,6 @@ public HttpsSettings(IConfigurationSection section) class Settings { public string[] Nodes { get; } - public string Wallet { get; } public TimeSpan MaxTaskTimeout { get; } public bool AllowPrivateHost { get; } public string[] AllowedContentTypes { get; } @@ -28,7 +27,6 @@ class Settings private Settings(IConfigurationSection section) { Nodes = section.GetSection("Nodes").GetChildren().Select(p => p.Get()).ToArray(); - Wallet = section.GetValue("Wallet"); MaxTaskTimeout = TimeSpan.FromMilliseconds(section.GetValue("MaxTaskTimeout", 432000000)); AllowPrivateHost = section.GetValue("AllowPrivateHost", false); AllowedContentTypes = section.GetSection("AllowedContentTypes").GetChildren().Select(p => p.Get()).ToArray(); From ad97e56da0e1b272c80e6d47bd748cbf7a4981d1 Mon Sep 17 00:00:00 2001 From: bettybao1209 Date: Tue, 19 Jan 2021 17:54:17 +0800 Subject: [PATCH 5/6] check wallet if null --- src/OracleService/OracleService.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/OracleService/OracleService.cs b/src/OracleService/OracleService.cs index 0271cdc16..f23709817 100644 --- a/src/OracleService/OracleService.cs +++ b/src/OracleService/OracleService.cs @@ -76,14 +76,15 @@ private void OnStart() if (started) return; var walletProvider = GetService(); - if (walletProvider is null) + + wallet = walletProvider.GetWallet(); + + if (wallet is null) { Console.WriteLine("Please open wallet first!"); return; } - wallet = walletProvider.GetWallet(); - using (var snapshot = Blockchain.Singleton.GetSnapshot()) { if (!CheckOracleAvaiblable(snapshot, out ECPoint[] oracles)) throw new ArgumentException("The oracle service is unavailable"); From 00f6b28d2e297762803cf833e4477bfe27b7945e Mon Sep 17 00:00:00 2001 From: Erik Zhang Date: Tue, 19 Jan 2021 18:07:31 +0800 Subject: [PATCH 6/6] Update OracleService.cs --- src/OracleService/OracleService.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/OracleService/OracleService.cs b/src/OracleService/OracleService.cs index f23709817..04274b6ad 100644 --- a/src/OracleService/OracleService.cs +++ b/src/OracleService/OracleService.cs @@ -14,7 +14,6 @@ using Neo.SmartContract.Native; using Neo.VM; using Neo.Wallets; -using Neo.Wallets.NEP6; using System; using System.Collections.Concurrent; using System.Collections.Generic; @@ -75,9 +74,7 @@ private void OnStart() { if (started) return; - var walletProvider = GetService(); - - wallet = walletProvider.GetWallet(); + wallet = GetService().GetWallet(); if (wallet is null) {