getGasPrice function
Implementation
UserOperationMiddlewareFn getGasPrice(
Web3Client client,
) {
return (ctx) async {
Object? eip1559Error;
try {
final gasPrices = await eip1559GasPrice(client);
ctx.op.maxFeePerGas = gasPrices['maxFeePerGas'];
ctx.op.maxPriorityFeePerGas = gasPrices['maxPriorityFeePerGas'];
return;
} catch (error) {
eip1559Error = error;
}
try {
final gasPrices = await legacyGasPrice(client);
ctx.op.maxFeePerGas = gasPrices['maxFeePerGas'];
ctx.op.maxPriorityFeePerGas = gasPrices['maxPriorityFeePerGas'];
return;
} catch (error) {
throw Exception('$eip1559Error, $error');
}
};
}