Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions csharp/src/Common/Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Nethereum.Web3" Version="4.29.0" />
<PackageReference Include="Temporalio.Extensions.Hosting" Version="1.5.0" />
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.3.0" />
<PackageReference Include="Nethereum.Util" Version="4.29.0" />
Expand Down
17 changes: 17 additions & 0 deletions csharp/src/Common/Extensions/Web3ClientExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Nethereum.Hex.HexTypes;
using Nethereum.Web3;
using System.Numerics;

namespace Train.Solver.Common.Extensions;

public static class Web3ClientExtensions
{
public static async Task<BigInteger> GetMaxPriorityFeePerGasAsync(this IWeb3 web3)
{
var request = new Nethereum.JsonRpc.Client.RpcRequest(Guid.NewGuid().ToString(), "eth_maxPriorityFeePerGas");

var response = await web3.Client.SendRequestAsync<string>(request);

return new HexBigInteger(response);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public class EthereumEIP1559FeeEstimator(ISmartNodeInvoker smartNodeInvoker) : F

public virtual int HighPriorityBlockCount => 5;

private const string MinMaxPriorityFeePerGas = "1";

public override BigInteger CalculateFee(Block block, Transaction transaction, EVMTransactionReceipt receipt)
{
return receipt.GasUsed * (block.BaseFeePerGas + transaction.MaxPriorityFeePerGas.Value);
Expand Down Expand Up @@ -66,15 +68,14 @@ async Task<Fee> GetFeeAmountAsync(
suggestedFees.BaseFee.Value.CompoundInterestRate(MaximumBaseFeeIncreasePerBlock, blockCount);

// Node returns 0 but transfer service throws exception in case of 0
suggestedFees.MaxPriorityFeePerGas += 1;
suggestedFees.MaxPriorityFeePerGas =
suggestedFees.MaxPriorityFeePerGas.Value.PercentageIncrease(feePercentageIncrease);
var maxPriorityFeePerGas = BigInteger.Parse(MinMaxPriorityFeePerGas);
maxPriorityFeePerGas += (await web3.GetMaxPriorityFeePerGasAsync()).PercentageIncrease(feePercentageIncrease);

return new Fee(
feeCurrency.Symbol,
feeCurrency.Decimals,
new EIP1559Data(
suggestedFees.MaxPriorityFeePerGas.Value,
maxPriorityFeePerGas,
increasedBaseFee,
gasLimit));
}
Expand Down
2 changes: 1 addition & 1 deletion csharp/src/Workflow.Solana/Workflow.Solana.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Nethereum.Web3Lite" Version="4.29.0" />
<PackageReference Include="Nethereum.Web3" Version="4.29.0" />
<PackageReference Include="Solnet.Extensions" Version="6.1.0" />
<PackageReference Include="Flurl.Http" Version="4.0.2" />
</ItemGroup>
Expand Down