Add Solana priority fees (#23214)

Add support for Solana priority fees
This commit is contained in:
Nick von Pentz
2024-06-10 11:06:39 -04:00
committed by GitHub
parent d05bd7d8ff
commit 3248b2f695
51 changed files with 2306 additions and 293 deletions
@@ -13,8 +13,10 @@ import org.chromium.brave_wallet.mojom.AssetRatioService;
import org.chromium.brave_wallet.mojom.AssetTimePrice;
import org.chromium.brave_wallet.mojom.BlockchainRegistry;
import org.chromium.brave_wallet.mojom.BlockchainToken;
import org.chromium.brave_wallet.mojom.BraveWalletConstants;
import org.chromium.brave_wallet.mojom.JsonRpcService;
import org.chromium.brave_wallet.mojom.NetworkInfo;
import org.chromium.brave_wallet.mojom.SolanaFeeEstimation;
import org.chromium.brave_wallet.mojom.SolanaTxManagerProxy;
import org.chromium.brave_wallet.mojom.TransactionInfo;
import org.chromium.brave_wallet.mojom.TxService;
@@ -324,7 +326,7 @@ public class AsyncUtils {
}
public static class GetSolanaEstimatedTxFeeResponseContext extends SingleResponseBaseContext
implements SolanaTxManagerProxy.GetEstimatedTxFee_Response {
implements SolanaTxManagerProxy.GetSolanaTxFeeEstimation_Response {
public Long fee;
public Integer error;
public String errorMessage;
@@ -335,8 +337,11 @@ public class AsyncUtils {
}
@Override
public void call(long fee, int error, String errorMessage) {
this.fee = fee;
public void call(SolanaFeeEstimation fee, int error, String errorMessage) {
this.fee =
fee.baseFee
+ (((long) fee.computeUnits * fee.feePerComputeUnit)
/ BraveWalletConstants.MICRO_LAMPORTS_PER_LAMPORT);
this.error = error;
this.errorMessage = errorMessage;
super.fireResponseCompleteCallback();
@@ -60,20 +60,23 @@ public class SolanaTransactionsGasHelper {
estimatesContexts.add(estimatesContext);
if (mActivity.get() != null)
mActivity.get().getSolanaTxManagerProxy().getEstimatedTxFee(
txInfo.chainId, txInfo.id, estimatesContext);
mActivity
.get()
.getSolanaTxManagerProxy()
.getSolanaTxFeeEstimation(txInfo.chainId, txInfo.id, estimatesContext);
}
estimatesMultiResponse.setWhenAllCompletedAction(() -> {
for (AsyncUtils.GetSolanaEstimatedTxFeeResponseContext estimatesContext :
estimatesContexts) {
if (estimatesContext.error != SolanaProviderError.SUCCESS) {
continue;
}
mPerTxFee.put(estimatesContext.txMetaId, estimatesContext.fee);
}
estimatesMultiResponse.setWhenAllCompletedAction(
() -> {
for (AsyncUtils.GetSolanaEstimatedTxFeeResponseContext estimatesContext :
estimatesContexts) {
if (estimatesContext.error != SolanaProviderError.SUCCESS) {
continue;
}
mPerTxFee.put(estimatesContext.txMetaId, estimatesContext.fee);
}
runWhenDone.run();
});
runWhenDone.run();
});
}
}