Skip to content
Open
Changes from 1 commit
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
32 changes: 30 additions & 2 deletions Maskbook/Scene/Wallet/TokenDetail/View/TransactionCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,22 @@ extension TransactionCell {
guard let gasPrice = txToSpeedUp.transactionInfo?.gasPrice else { return }
guard let gasLimit = txToSpeedUp.transactionInfo?.gaslimit else { return }

let confirmModel = SendConfirmViewModel(selectedToken: txToSpeedUp.transactionInfo?.token, gasPrice: gasPrice * BigUInt(1.2), gasLimit: gasLimit, gasFeeNetModel: txToSpeedUp.transactionInfo?.gasNetModel)
var gasNetModel = txToSpeedUp.transactionInfo?.gasNetModel

if let maxFeePerGas = txToSpeedUp.transactionInfo?.gasNetModel?.suggestedMaxFeePerGas{
let gwei = NSDecimalNumber(string: maxFeePerGas).multiplying(by: NSDecimalNumber(string: "1.2"))
let roundBehavior = NSDecimalNumberHandler(roundingMode: .plain, scale: 0, raiseOnExactness: false, raiseOnOverflow: false, raiseOnUnderflow: false, raiseOnDivideByZero: false)
gasNetModel?.suggestedMaxFeePerGas = gwei.rounding(accordingToBehavior: roundBehavior).stringValue
}

if let maxPriorityFee = txToSpeedUp.transactionInfo?.gasNetModel?.suggestedMaxPriorityFeePerGas{
Comment thread
hydraCy marked this conversation as resolved.
Outdated
let gwei = NSDecimalNumber(string: maxPriorityFee).multiplying(by: NSDecimalNumber(string: "1.2"))
Comment thread
hydraCy marked this conversation as resolved.
Outdated
let roundBehavior = NSDecimalNumberHandler(roundingMode: .plain, scale: 0, raiseOnExactness: false, raiseOnOverflow: false, raiseOnUnderflow: false, raiseOnDivideByZero: false)
gasNetModel?.suggestedMaxPriorityFeePerGas = gwei.rounding(accordingToBehavior: roundBehavior).stringValue
}

let confirmModel = SendConfirmViewModel(selectedToken: txToSpeedUp.transactionInfo?.token, gasPrice: gasPrice * BigUInt(12) / BigUInt(10), gasLimit: gasLimit, gasFeeNetModel: gasNetModel)

Coordinator.main.present(
scene: .sendTransactionPopConfirm(sendConfirmViewModel: confirmModel, toAddress: toAddress, amount: amount, nonce: txToSpeedUp.nonce),
transition: .panModel(animated: true))
Expand All @@ -337,8 +351,22 @@ extension TransactionCell {
guard let gasLimit = txToSpeedUp.transactionInfo?.gaslimit else { return }

let token = WalletAssetManager.shared.getDefaultMainToken()

var gasNetModel = txToSpeedUp.transactionInfo?.gasNetModel

if let maxFeePerGas = txToSpeedUp.transactionInfo?.gasNetModel?.suggestedMaxFeePerGas{
let gwei = NSDecimalNumber(string: maxFeePerGas).multiplying(by: NSDecimalNumber(string: "1.5"))
Comment thread
hydraCy marked this conversation as resolved.
Outdated
let roundBehavior = NSDecimalNumberHandler(roundingMode: .plain, scale: 0, raiseOnExactness: false, raiseOnOverflow: false, raiseOnUnderflow: false, raiseOnDivideByZero: false)
gasNetModel?.suggestedMaxFeePerGas = gwei.rounding(accordingToBehavior: roundBehavior).stringValue
}

if let maxPriorityFee = txToSpeedUp.transactionInfo?.gasNetModel?.suggestedMaxPriorityFeePerGas{
Comment thread
hydraCy marked this conversation as resolved.
Outdated
let gwei = NSDecimalNumber(string: maxPriorityFee).multiplying(by: NSDecimalNumber(string: "1.5"))
let roundBehavior = NSDecimalNumberHandler(roundingMode: .plain, scale: 0, raiseOnExactness: false, raiseOnOverflow: false, raiseOnUnderflow: false, raiseOnDivideByZero: false)
gasNetModel?.suggestedMaxPriorityFeePerGas = gwei.rounding(accordingToBehavior: roundBehavior).stringValue
}

let confirmModel = SendConfirmViewModel(selectedToken: token, gasPrice: gasPrice * BigUInt(1.5), gasLimit: gasLimit, gasFeeNetModel: txToSpeedUp.transactionInfo?.gasNetModel)
let confirmModel = SendConfirmViewModel(selectedToken: token, gasPrice: gasPrice * BigUInt(15) / BigUInt(10), gasLimit: gasLimit, gasFeeNetModel: gasNetModel)

Coordinator.main.present(
scene: .sendTransactionPopConfirm(sendConfirmViewModel: confirmModel, toAddress: toAddress, amount: "0", nonce: txToSpeedUp.nonce),
Expand Down