Skip to content

Commit

Permalink
Merge commit '2fca47b244eaeb26eacdbfd7bbf5f7aba16d373c' into release/…
Browse files Browse the repository at this point in the history
…2.11.0
  • Loading branch information
bigearsenal committed Jan 19, 2024
2 parents 2486a4e + 2fca47b commit b9bad49
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 28 deletions.
22 changes: 0 additions & 22 deletions Packages/KeyAppKit/Sources/Wormhole/Model/SendFees.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,3 @@ public struct SendFees: Codable, Hashable, Equatable {
case bridgeFeeInToken = "bridge_fee_in_token"
}
}

public extension SendFees {
/// Total amount in fiat.
var totalInFiat: CurrencyAmount {
CurrencyAmount(usd: 0)
+ arbiter?.asCurrencyAmount
+ networkFee?.asCurrencyAmount
+ messageAccountRent?.asCurrencyAmount
+ bridgeFee?.asCurrencyAmount
}

/// Total in Crypto
var totalInCrypto: CryptoAmount? {
guard let arbiter, let networkFeeInToken, let messageAccountRentInToken, let bridgeFeeInToken else {
return nil
}
return arbiter.asCryptoAmount
+ networkFeeInToken.asCryptoAmount
+ messageAccountRentInToken.asCryptoAmount
+ bridgeFeeInToken.asCryptoAmount
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,14 @@ struct WormholeSendInputStateAdapter: Equatable {
var fees: String {
switch state {
case let .ready(_, output, _):
return "\(currencyFormatter.string(amount: output.fees.totalInFiat))"
if let arbiter = output.fees.arbiter?.asCryptoAmount {
return "\(cryptoFormatter.string(amount: arbiter))"
} else {
return ""
}
case let .error(_, output, _):
if let output {
return "\(currencyFormatter.string(amount: output.fees.totalInFiat))"
if let output, let arbiter = output.fees.arbiter?.asCryptoAmount {
return "\(cryptoFormatter.string(amount: arbiter))"
} else {
return ""
}
Expand Down Expand Up @@ -140,13 +144,13 @@ struct WormholeSendInputStateAdapter: Equatable {
}

var disableSwitch: Bool {
input?.solanaAccount.price == nil
true
}

var totalCryptoAmount: String {
if let input {
let arbiterFee = output?.fees.arbiter?.asCryptoAmount ?? input.amount.with(amount: 0)
return cryptoFormatter.string(amount: input.amount + arbiterFee)
let totalAmount = output?.fees.totalAmount?.asCryptoAmount ?? input.amount.with(amount: 0)
return cryptoFormatter.string(amount: totalAmount)
} else {
return "N/A"
}
Expand Down

0 comments on commit b9bad49

Please sign in to comment.