From 8264bb008b548d4eba6a96f53f7b071166de9a6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=BF=97=E5=90=8C?= Date: Tue, 20 Apr 2021 16:10:25 +0800 Subject: [PATCH 1/3] Update MainService.Contracts.cs --- neo-cli/CLI/MainService.Contracts.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/neo-cli/CLI/MainService.Contracts.cs b/neo-cli/CLI/MainService.Contracts.cs index 7f89dd0dd..63f9279d2 100644 --- a/neo-cli/CLI/MainService.Contracts.cs +++ b/neo-cli/CLI/MainService.Contracts.cs @@ -54,6 +54,11 @@ private void OnInvokeCommand(UInt160 scriptHash, string operation, JArray contra { var gas = new BigDecimal(maxGas, NativeContract.GAS.Decimals); Signer[] signers = Array.Empty(); + if (sender != null && signerAccounts == null) + { + signerAccounts = new UInt160[1]{ sender }; + } + if (signerAccounts != null && !NoWallet()) { if (sender != null) From ec6dd7663988c62b022cc117ce3d6a1c3bd934e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=BF=97=E5=90=8C?= Date: Tue, 20 Apr 2021 16:14:21 +0800 Subject: [PATCH 2/3] format --- neo-cli/CLI/MainService.Contracts.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neo-cli/CLI/MainService.Contracts.cs b/neo-cli/CLI/MainService.Contracts.cs index 63f9279d2..5bcdb0ccc 100644 --- a/neo-cli/CLI/MainService.Contracts.cs +++ b/neo-cli/CLI/MainService.Contracts.cs @@ -56,7 +56,7 @@ private void OnInvokeCommand(UInt160 scriptHash, string operation, JArray contra Signer[] signers = Array.Empty(); if (sender != null && signerAccounts == null) { - signerAccounts = new UInt160[1]{ sender }; + signerAccounts = new UInt160[1] { sender }; } if (signerAccounts != null && !NoWallet()) From 09f145f1c04098d789a2c5ba69b5b1abe42f2bcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=BF=97=E5=90=8C?= Date: Tue, 20 Apr 2021 18:39:42 +0800 Subject: [PATCH 3/3] ProDog's feedback --- neo-cli/CLI/MainService.Contracts.cs | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/neo-cli/CLI/MainService.Contracts.cs b/neo-cli/CLI/MainService.Contracts.cs index 5bcdb0ccc..1d411108f 100644 --- a/neo-cli/CLI/MainService.Contracts.cs +++ b/neo-cli/CLI/MainService.Contracts.cs @@ -54,25 +54,19 @@ private void OnInvokeCommand(UInt160 scriptHash, string operation, JArray contra { var gas = new BigDecimal(maxGas, NativeContract.GAS.Decimals); Signer[] signers = Array.Empty(); - if (sender != null && signerAccounts == null) + if (!NoWallet() && sender != null) { - signerAccounts = new UInt160[1] { sender }; - } - - if (signerAccounts != null && !NoWallet()) - { - if (sender != null) + if (signerAccounts == null) + signerAccounts = new UInt160[1] { sender }; + else if (signerAccounts.Contains(sender) && signerAccounts[0] != sender) + { + var signersList = signerAccounts.ToList(); + signersList.Remove(sender); + signerAccounts = signersList.Prepend(sender).ToArray(); + } + else if (!signerAccounts.Contains(sender)) { - if (signerAccounts.Contains(sender) && signerAccounts[0] != sender) - { - var signersList = signerAccounts.ToList(); - signersList.Remove(sender); - signerAccounts = signersList.Prepend(sender).ToArray(); - } - else if (!signerAccounts.Contains(sender)) - { - signerAccounts = signerAccounts.Prepend(sender).ToArray(); - } + signerAccounts = signerAccounts.Prepend(sender).ToArray(); } signers = signerAccounts.Select(p => new Signer() { Account = p, Scopes = WitnessScope.CalledByEntry }).ToArray(); }