Skip to content

Commit c6b5a3c

Browse files
committed
Use basic Approve in ERC20.SetAllowance to trigger wallet UI
1 parent e420faf commit c6b5a3c

File tree

1 file changed

+1
-19
lines changed

1 file changed

+1
-19
lines changed

Assets/Thirdweb/Core/Scripts/ERC20.cs

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -165,25 +165,7 @@ public async Task<TransactionResult> SetAllowance(string spender, string amount)
165165
}
166166
else
167167
{
168-
CurrencyValue currentAllowance = await Allowance(spender);
169-
BigInteger diff = BigInteger.Parse(amount.ToWei()) - BigInteger.Parse(currentAllowance.value);
170-
171-
var result = new TransactionResult();
172-
if (diff == 0)
173-
{
174-
ThirdwebDebug.LogWarning($"Allowance is already of amount {amount} - Skipping request...");
175-
result = null;
176-
}
177-
else if (diff < 0)
178-
{
179-
return await TransactionManager.ThirdwebWrite(contractAddress, new TokenERC20Contract.DecreaseAllowanceFunction() { Spender = spender, SubtractedValue = diff * -1 });
180-
}
181-
else
182-
{
183-
return await TransactionManager.ThirdwebWrite(contractAddress, new TokenERC20Contract.IncreaseAllowanceFunction() { Spender = spender, AddedValue = diff });
184-
}
185-
186-
return result;
168+
return await TransactionManager.ThirdwebWrite(contractAddress, new TokenERC20Contract.ApproveFunction() { Spender = spender, Amount = BigInteger.Parse(amount.ToWei()) });
187169
}
188170
}
189171

0 commit comments

Comments
 (0)