diff --git a/Sources/KukaiCoreSwift/Models/BakingBad/TzKTTransaction.swift b/Sources/KukaiCoreSwift/Models/BakingBad/TzKTTransaction.swift index 0fbc3cb..748410d 100644 --- a/Sources/KukaiCoreSwift/Models/BakingBad/TzKTTransaction.swift +++ b/Sources/KukaiCoreSwift/Models/BakingBad/TzKTTransaction.swift @@ -250,10 +250,10 @@ public struct TzKTTransaction: Codable, CustomStringConvertible, Hashable, Ident try container.encode(newDelegate, forKey: .newDelegate) try container.encodeIfPresent(baker, forKey: .baker) try container.encode(parameter, forKey: .parameter) - try container.encode(bakerFee.rpcRepresentation, forKey: .bakerFee) - try container.encode(storageFee.rpcRepresentation, forKey: .storageFee) - try container.encode(allocationFee.rpcRepresentation, forKey: .allocationFee) - try container.encode(amount.rpcRepresentation, forKey: .amount) + try container.encode(bakerFee.toRpcDecimal(), forKey: .bakerFee) + try container.encode(storageFee.toRpcDecimal(), forKey: .storageFee) + try container.encode(allocationFee.toRpcDecimal(), forKey: .allocationFee) + try container.encode(amount.toRpcDecimal(), forKey: .amount) try container.encode(status.rawValue, forKey: .status) try container.encode(hasInternals, forKey: .hasInternals) try container.encode(tokenTransfersCount, forKey: .tokenTransfersCount) @@ -343,9 +343,11 @@ public struct TzKTTransaction: Codable, CustomStringConvertible, Hashable, Ident } else if self.kind == "stake" { self.subType = .stake + self.primaryToken = createPrimaryToken() } else if self.kind == "unstake" { self.subType = .unstake + self.primaryToken = createPrimaryToken() } else { if self.type == .delegation { diff --git a/Tests/KukaiCoreSwiftTests/Clients/TzKTClientTests.swift b/Tests/KukaiCoreSwiftTests/Clients/TzKTClientTests.swift index fbe3706..1b72f6f 100644 --- a/Tests/KukaiCoreSwiftTests/Clients/TzKTClientTests.swift +++ b/Tests/KukaiCoreSwiftTests/Clients/TzKTClientTests.swift @@ -232,6 +232,7 @@ class TzKTClientTests: XCTestCase { XCTAssert(group.groupType == .unstake, group.groupType.rawValue) XCTAssert(group.transactions.count == 1, group.transactions.count.description) XCTAssert(group.transactions.first?.amount.description == "1", group.transactions.first?.amount.description ?? "-") + XCTAssert(group.transactions.first?.primaryToken?.balance.description == "1", group.transactions.first?.primaryToken?.balance.description ?? "-") XCTAssert(group.transactions.first?.baker?.address == "tz1YgDUQV2eXm8pUWNz3S5aWP86iFzNp4jnD", group.transactions.first?.baker?.address ?? "-") XCTAssert(group.transactions.first?.baker?.alias == "Baking Benjamins", group.transactions.first?.baker?.alias ?? "-") XCTAssert(group.hash == "ooyVR1r5vt3K4JGoVnH2XLQjwAVpoZaAkfdG1PssCPPovi7m1FL", group.hash) @@ -241,6 +242,7 @@ class TzKTClientTests: XCTestCase { XCTAssert(group.groupType == .stake, group.groupType.rawValue) XCTAssert(group.transactions.count == 1, group.transactions.count.description) XCTAssert(group.transactions.first?.amount.description == "10", group.transactions.first?.amount.description ?? "-") + XCTAssert(group.transactions.first?.primaryToken?.balance.description == "10", group.transactions.first?.primaryToken?.balance.description ?? "-") XCTAssert(group.transactions.first?.baker?.address == "tz1YgDUQV2eXm8pUWNz3S5aWP86iFzNp4jnD", group.transactions.first?.baker?.address ?? "-") XCTAssert(group.transactions.first?.baker?.alias == "Baking Benjamins", group.transactions.first?.baker?.alias ?? "-") XCTAssert(group.hash == "opPGcuZ459ZGR11RXaL2rRDtKnHFC9o5JQdyBHj3Qua4BMBkAsi", group.hash) diff --git a/Tests/KukaiCoreSwiftTests/Models/TzKTTransactionTests.swift b/Tests/KukaiCoreSwiftTests/Models/TzKTTransactionTests.swift index a0f1923..0be2ccf 100644 --- a/Tests/KukaiCoreSwiftTests/Models/TzKTTransactionTests.swift +++ b/Tests/KukaiCoreSwiftTests/Models/TzKTTransactionTests.swift @@ -97,7 +97,7 @@ final class TzKTTransactionTests: XCTestCase { transaction.processAdditionalData(withCurrentWalletAddress: "tz1abc") if let json = try? JSONEncoder().encode(transaction), let jsonString = String(data: json, encoding: .utf8) { - XCTAssert(jsonString.count == 952, jsonString.count.description) + XCTAssert(jsonString.count == 944, jsonString.count.description) } else { XCTFail() }