From af54507c6e0f08d0cdf3b7def3351d0d949e3433 Mon Sep 17 00:00:00 2001 From: 0xFirekeeper <0xFirekeeper@gmail.com> Date: Sat, 13 Apr 2024 00:56:35 +0300 Subject: [PATCH] ex from --- Thirdweb.Tests/Thirdweb.Transactions.Tests.cs | 3 ++- Thirdweb/Thirdweb.Transactions/ThirdwebTransaction.cs | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Thirdweb.Tests/Thirdweb.Transactions.Tests.cs b/Thirdweb.Tests/Thirdweb.Transactions.Tests.cs index b815b78..bbe6b96 100644 --- a/Thirdweb.Tests/Thirdweb.Transactions.Tests.cs +++ b/Thirdweb.Tests/Thirdweb.Transactions.Tests.cs @@ -36,7 +36,8 @@ public async Task Create_ThrowsOnInvalidAddress() var client = ThirdwebClient.Create(secretKey: _secretKey); var wallet = await PrivateKeyWallet.Create(client, _testPrivateKey); var txInput = new TransactionInput() { From = "0x123" }; - _ = await Assert.ThrowsAsync(() => ThirdwebTransaction.Create(client, wallet, txInput, BigInteger.Zero)); + var ex = await Assert.ThrowsAsync(() => ThirdwebTransaction.Create(client, wallet, txInput, BigInteger.Zero)); + Assert.Contains("Transaction sender (from) must match wallet address", ex.Message); } [Fact] diff --git a/Thirdweb/Thirdweb.Transactions/ThirdwebTransaction.cs b/Thirdweb/Thirdweb.Transactions/ThirdwebTransaction.cs index c7cd2f4..d5411cf 100644 --- a/Thirdweb/Thirdweb.Transactions/ThirdwebTransaction.cs +++ b/Thirdweb/Thirdweb.Transactions/ThirdwebTransaction.cs @@ -32,8 +32,9 @@ private ThirdwebTransaction(ThirdwebClient client, IThirdwebWallet wallet, Trans public static async Task Create(ThirdwebClient client, IThirdwebWallet wallet, TransactionInput txInput, BigInteger chainId) { - txInput.From ??= await wallet.GetAddress(); - return await wallet.GetAddress() != txInput.From + var address = await wallet.GetAddress(); + txInput.From ??= address; + return address != txInput.From ? throw new ArgumentException("Transaction sender (from) must match wallet address") : client == null ? throw new ArgumentNullException(nameof(client))