From 88022a02306ad7afacb9ff075e100a7b75c382fd Mon Sep 17 00:00:00 2001 From: Hecate2 <2474101468@qq.com> Date: Fri, 23 Aug 2024 16:35:24 +0800 Subject: [PATCH 1/2] improve error message when wrong wallet is opened --- src/Neo/Wallets/Helper.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Neo/Wallets/Helper.cs b/src/Neo/Wallets/Helper.cs index b8427d078d..5beae49ab9 100644 --- a/src/Neo/Wallets/Helper.cs +++ b/src/Neo/Wallets/Helper.cs @@ -119,7 +119,8 @@ public static long CalculateNetworkFee(this Transaction tx, DataCache snapshot, { var contract = NativeContract.ContractManagement.GetContract(snapshot, hash); if (contract is null) - throw new ArgumentException($"The smart contract or address {hash} is not found"); + throw new ArgumentException($"The smart contract or address {hash} ({hash.ToAddress(settings.AddressVersion)}) is not found. " + + $"If this is your wallet address and you want to sign a transaction with it, make sure you have opened this wallet."); var md = contract.Manifest.Abi.GetMethod(ContractBasicMethod.Verify, ContractBasicMethod.VerifyPCount); if (md is null) throw new ArgumentException($"The smart contract {contract.Hash} haven't got verify method"); From 736e2a6968229dd113e968a7d76958801b868537 Mon Sep 17 00:00:00 2001 From: Hecate2 <2474101468@qq.com> Date: Fri, 23 Aug 2024 16:54:27 +0800 Subject: [PATCH 2/2] update tests --- .../Neo.Plugins.RpcServer.Tests/UT_RpcServer.SmartContract.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/Neo.Plugins.RpcServer.Tests/UT_RpcServer.SmartContract.cs b/tests/Neo.Plugins.RpcServer.Tests/UT_RpcServer.SmartContract.cs index f994137258..9a8b87da9a 100644 --- a/tests/Neo.Plugins.RpcServer.Tests/UT_RpcServer.SmartContract.cs +++ b/tests/Neo.Plugins.RpcServer.Tests/UT_RpcServer.SmartContract.cs @@ -102,7 +102,8 @@ public void TestInvokeFunction() Assert.AreEqual(resp["diagnostics"]["invokedcontracts"]["call"][0]["hash"], NeoToken.NEO.Hash.ToString()); Assert.IsTrue(((JArray)resp["diagnostics"]["storagechanges"]).Count == 4); Assert.AreEqual(resp["state"], nameof(VM.VMState.HALT)); - Assert.AreEqual(resp["exception"], $"The smart contract or address {MultisigScriptHash.ToString()} is not found"); + Assert.AreEqual(resp["exception"], $"The smart contract or address {MultisigScriptHash} ({MultisigAddress}) is not found. " + + $"If this is your wallet address and you want to sign a transaction with it, make sure you have opened this wallet."); JArray notifications = (JArray)resp["notifications"]; Assert.AreEqual(notifications.Count, 2); Assert.AreEqual(notifications[0]["eventname"].AsString(), "Transfer");