Skip to content

Commit

Permalink
ex from
Browse files Browse the repository at this point in the history
  • Loading branch information
0xFirekeeper committed Apr 12, 2024
1 parent 6cda515 commit af54507
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Thirdweb.Tests/Thirdweb.Transactions.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ArgumentException>(() => ThirdwebTransaction.Create(client, wallet, txInput, BigInteger.Zero));
var ex = await Assert.ThrowsAsync<ArgumentException>(() => ThirdwebTransaction.Create(client, wallet, txInput, BigInteger.Zero));
Assert.Contains("Transaction sender (from) must match wallet address", ex.Message);
}

[Fact]
Expand Down
5 changes: 3 additions & 2 deletions Thirdweb/Thirdweb.Transactions/ThirdwebTransaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ private ThirdwebTransaction(ThirdwebClient client, IThirdwebWallet wallet, Trans

public static async Task<ThirdwebTransaction> 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))
Expand Down

0 comments on commit af54507

Please sign in to comment.