Skip to content

Commit dffd5ac

Browse files
committed
redundant catch, better errors thrown
1 parent bce7bcc commit dffd5ac

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

Thirdweb/Thirdweb.Contracts/ThirdwebContract.cs

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,13 @@ public static async Task<T> Read<T>(ThirdwebContract contract, string method, pa
106106
{
107107
if (method.Contains("("))
108108
{
109-
try
110-
{
111-
var canonicalSignature = ExtractCanonicalSignature(method);
112-
var selector = Nethereum.Util.Sha3Keccack.Current.CalculateHash(canonicalSignature)[..8];
113-
function = contractRaw.GetFunctionBySignature(selector);
114-
}
115-
catch
116-
{
117-
function = contractRaw.GetFunction(method);
118-
}
109+
var canonicalSignature = ExtractCanonicalSignature(method);
110+
var selector = Nethereum.Util.Sha3Keccack.Current.CalculateHash(canonicalSignature)[..8];
111+
function = contractRaw.GetFunctionBySignature(selector);
112+
}
113+
else
114+
{
115+
throw new ArgumentException("Method signature not found in contract ABI.");
119116
}
120117
}
121118

@@ -142,16 +139,13 @@ public static async Task<ThirdwebTransaction> Prepare(IThirdwebWallet wallet, Th
142139
{
143140
if (method.Contains("("))
144141
{
145-
try
146-
{
147-
var canonicalSignature = ExtractCanonicalSignature(method);
148-
var selector = Nethereum.Util.Sha3Keccack.Current.CalculateHash(canonicalSignature)[..8];
149-
function = contractRaw.GetFunctionBySignature(selector);
150-
}
151-
catch
152-
{
153-
function = contractRaw.GetFunction(method);
154-
}
142+
var canonicalSignature = ExtractCanonicalSignature(method);
143+
var selector = Nethereum.Util.Sha3Keccack.Current.CalculateHash(canonicalSignature)[..8];
144+
function = contractRaw.GetFunctionBySignature(selector);
145+
}
146+
else
147+
{
148+
throw new ArgumentException("Method signature not found in contract ABI.");
155149
}
156150
}
157151

0 commit comments

Comments
 (0)