Fix encoding missing gasPrice for swap response #6072

pull/6073/head
Krypto Pank 2 years ago
parent fa9a392bb4
commit 54e9f9c384
  1. 2
      AlphaWallet/Swap/Swap/ViewModels/SwapQuoteDetailsViewModel.swift
  2. 6
      modules/AlphaWalletFoundation/AlphaWalletFoundation/SwapToken/NativeSwap/SwapEstimate.swift
  3. 6
      modules/AlphaWalletFoundation/AlphaWalletFoundation/SwapToken/NativeSwap/UnsignedSwapTransaction.swift

@ -48,7 +48,7 @@ final class SwapQuoteDetailsViewModel {
type: step.type,
amount: pair.swapQuote.unsignedSwapTransaction.value,
amountUsd: pair.swapQuote.action.fromToken.priceUSD,
estimate: pair.swapQuote.unsignedSwapTransaction.gasPrice ?? .zero,
estimate: pair.swapQuote.unsignedSwapTransaction.gasPrice,
limit: pair.swapQuote.unsignedSwapTransaction.gasLimit,
token: pair.swapQuote.action.fromToken)

@ -21,11 +21,11 @@ public struct SwapEstimate {
public let type: String
public let amount: BigUInt
public let amountUsd: String
public let estimate: BigUInt
public let limit: BigUInt
public let estimate: BigUInt?
public let limit: BigUInt?
public let token: SwapQuote.Token
public init(type: String, amount: BigUInt, amountUsd: String, estimate: BigUInt, limit: BigUInt, token: SwapQuote.Token) {
public init(type: String, amount: BigUInt, amountUsd: String, estimate: BigUInt?, limit: BigUInt?, token: SwapQuote.Token) {
self.type = type
self.amount = amount
self.amountUsd = amountUsd

@ -22,7 +22,7 @@ public struct UnsignedSwapTransaction: Codable {
public let data: Data
public let from: AlphaWallet.Address
public let to: AlphaWallet.Address
public let gasLimit: BigUInt
public let gasLimit: BigUInt?
public let gasPrice: BigUInt?
public let value: BigUInt
@ -33,7 +33,7 @@ public struct UnsignedSwapTransaction: Codable {
let dataString = try container.decode(String.self, forKey: .data)
let fromString = try container.decode(String.self, forKey: .from)
let toString = try container.decode(String.self, forKey: .to)
let gasLimitString = try container.decode(String.self, forKey: .gasLimit)
let gasLimitString = try container.decodeIfPresent(String.self, forKey: .gasLimit)
let gasPriceString = try container.decodeIfPresent(String.self, forKey: .gasPrice)
let valueString = try container.decode(String.self, forKey: .value)
@ -41,7 +41,7 @@ public struct UnsignedSwapTransaction: Codable {
data = Data(hex: dataString)
from = try AlphaWallet.Address(string: fromString) ?? { throw ParsingError(fieldName: .from) }()
to = try AlphaWallet.Address(string: toString) ?? { throw ParsingError(fieldName: .to) }()
gasLimit = try BigUInt(gasLimitString.drop0x, radix: 16) ?? { throw ParsingError(fieldName: .gasLimit) }()
gasLimit = try gasLimitString.flatMap { BigUInt($0.drop0x, radix: 16) }
gasPrice = try gasPriceString.flatMap { BigUInt($0.drop0x, radix: 16) }
value = try BigUInt(valueString.drop0x, radix: 16) ?? { throw ParsingError(fieldName: .value) }()
}

Loading…
Cancel
Save