Skip to content

Commit d80e3f5

Browse files
committed
Use separate web3 instance for gas estimations in case of acc with no bal
1 parent e2d575b commit d80e3f5

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

Assets/Thirdweb/Core/Scripts/ERC721.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public async Task<List<NFT>> GetAll(QueryAllParams queryParams = null)
9999
List<NFT> allNfts = await rawTokenData.ToNFTList();
100100
return allNfts;
101101
}
102-
catch (System.Exception e)
102+
catch (System.Exception)
103103
{
104104
List<NFT> allNfts = new List<NFT>();
105105
for (int i = start; i < end; i++)
@@ -463,7 +463,7 @@ public async Task<ClaimConditions> GetActive()
463463

464464
var data = await TransactionManager.ThirdwebRead<DropERC721Contract.GetClaimConditionByIdFunction, DropERC721Contract.GetClaimConditionByIdOutputDTO>(
465465
contractAddress,
466-
new DropERC721Contract.GetClaimConditionByIdFunction() { }
466+
new DropERC721Contract.GetClaimConditionByIdFunction() { ConditionId = id.ReturnValue1 }
467467
);
468468

469469
return new ClaimConditions()

Assets/Thirdweb/Core/Scripts/TransactionManager.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,11 @@ public static async Task<TransactionResult> ThirdwebWrite<TWFunction>(string con
4343
public static async Task<TransactionReceipt> ThirdwebWriteRawResult<TWFunction>(string contractAddress, TWFunction functionMessage, BigInteger? weiValue = null)
4444
where TWFunction : FunctionMessage, new()
4545
{
46-
functionMessage.FromAddress = await ThirdwebManager.Instance.SDK.wallet.GetAddress();
4746
functionMessage.AmountToSend = weiValue ?? 0;
48-
49-
var transactionHandler = ThirdwebManager.Instance.SDK.nativeSession.web3.Eth.GetContractTransactionHandler<TWFunction>();
50-
var gas = await transactionHandler.EstimateGasAsync(contractAddress, functionMessage);
51-
functionMessage.Gas = gas.Value < 100000 ? 100000 : gas;
47+
var gasEstimator = new Nethereum.Web3.Web3(ThirdwebManager.Instance.SDK.nativeSession.lastRPC).Eth.GetContractTransactionHandler<TWFunction>();
48+
var gas = await gasEstimator.EstimateGasAsync(contractAddress, functionMessage);
49+
functionMessage.Gas = gas.Value < 100000 ? 100000 : gas.Value;
50+
functionMessage.FromAddress = await ThirdwebManager.Instance.SDK.wallet.GetAddress();
5251

5352
if (
5453
ThirdwebManager.Instance.SDK.options.gasless != null
@@ -109,6 +108,7 @@ public static async Task<TransactionReceipt> ThirdwebWriteRawResult<TWFunction>(
109108
}
110109
else
111110
{
111+
var transactionHandler = ThirdwebManager.Instance.SDK.nativeSession.web3.Eth.GetContractTransactionHandler<TWFunction>();
112112
return await transactionHandler.SendRequestAndWaitForReceiptAsync(contractAddress, functionMessage);
113113
}
114114
}

0 commit comments

Comments
 (0)