Skip to content

Commit 28a9fbd

Browse files
authored
Merge pull request #880 from Adamant-im/trello.com/c/1lX3h2xx
[trello.com/c/1lX3h2xx] fix eth transaction show 0 instead of pending
2 parents 4f94bcd + c919ae0 commit 28a9fbd

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

Adamant/Models/EthTransaction.swift

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ struct EthTransaction: @unchecked Sendable {
5050
let from: String
5151
let to: String
5252
let gasUsed: Decimal?
53-
let gasPrice: Decimal
53+
let gasPrice: Decimal?
5454
let confirmations: String?
5555
let isError: Bool
5656
let receiptStatus: TransactionReceipt.TXStatus
@@ -149,10 +149,10 @@ extension EthTransaction: TransactionDetails {
149149
var feeCurrencySymbol: String? { EthWalletService.currencySymbol }
150150

151151
var feeValue: Decimal? {
152-
guard let gasUsed = gasUsed else {
153-
return nil
154-
}
155-
152+
guard let gasUsed = gasUsed,
153+
let gasPrice
154+
else { return nil }
155+
156156
return gasPrice * gasUsed
157157
}
158158

@@ -207,12 +207,14 @@ extension CodableTransaction {
207207
txValue = nil
208208
}
209209

210-
let feePrice: BigUInt
211-
if type == .eip1559 {
212-
feePrice = (maxFeePerGas ?? BigUInt(0)) + (maxPriorityFeePerGas ?? BigUInt(0))
213-
} else {
214-
feePrice = gasPrice ?? BigUInt(0)
215-
}
210+
let feePrice: BigUInt? = {
211+
if type == .eip1559 {
212+
guard let maxFeePerGas, let maxPriorityFeePerGas else { return nil }
213+
return maxFeePerGas + maxPriorityFeePerGas
214+
} else {
215+
return gasPrice
216+
}
217+
}()
216218

217219
let gasPrice = gasPrice ?? feePrice
218220

@@ -223,7 +225,7 @@ extension CodableTransaction {
223225
from: sender?.address ?? "",
224226
to: recipient.address,
225227
gasUsed: gasUsed?.asDecimal(exponent: 0),
226-
gasPrice: gasPrice.asDecimal(exponent: EthWalletService.currencyExponent),
228+
gasPrice: gasPrice?.asDecimal(exponent: EthWalletService.currencyExponent),
227229
confirmations: confirmations,
228230
isError: receiptStatus != .failed,
229231
receiptStatus: receiptStatus,

0 commit comments

Comments
 (0)