From 1e1d1d6d290152109d3ece9ccbd09a838462d741 Mon Sep 17 00:00:00 2001 From: Oksana Didusenko Date: Mon, 11 Nov 2024 17:15:56 +0200 Subject: [PATCH 1/2] Update send --- Sources/TronKit/Core/Kit.swift | 3 ++- .../TronGrid/ExtensionApi/TransactionResponse.swift | 6 +++--- .../TronGrid/FullNode/CreatedTransactionResponse.swift | 8 ++++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Sources/TronKit/Core/Kit.swift b/Sources/TronKit/Core/Kit.swift index 325b437..6530c13 100644 --- a/Sources/TronKit/Core/Kit.swift +++ b/Sources/TronKit/Core/Kit.swift @@ -118,9 +118,10 @@ public extension Kit { transactionManager.tagTokens() } - func send(contract: Contract, signer: Signer, feeLimit: Int? = 0) async throws { + func send(contract: Contract, signer: Signer, feeLimit: Int? = 0) async throws -> CreatedTransactionResponse { let newTransaction = try await transactionSender.sendTransaction(contract: contract, signer: signer, feeLimit: feeLimit) transactionManager.handle(newTransaction: newTransaction) + return newTransaction } func accountActive(address: Address) async throws -> Bool { diff --git a/Sources/TronKit/TronGrid/ExtensionApi/TransactionResponse.swift b/Sources/TronKit/TronGrid/ExtensionApi/TransactionResponse.swift index 95906a5..b50d2f9 100644 --- a/Sources/TronKit/TronGrid/ExtensionApi/TransactionResponse.swift +++ b/Sources/TronKit/TronGrid/ExtensionApi/TransactionResponse.swift @@ -5,7 +5,7 @@ protocol ITransactionResponse { var blockTimestamp: Int { get } } -struct TransactionResponse: ImmutableMappable, ITransactionResponse { +public struct TransactionResponse: ImmutableMappable, ITransactionResponse { let ret: [Ret] let signature: [String] let txId: Data @@ -32,7 +32,7 @@ struct TransactionResponse: ImmutableMappable, ITransactionResponse { rawData = try map.value("raw_data") } - struct Ret: ImmutableMappable { + public struct Ret: ImmutableMappable { let contractRet: String let fee: Int @@ -42,7 +42,7 @@ struct TransactionResponse: ImmutableMappable, ITransactionResponse { } } - struct RawData: ImmutableMappable { + public struct RawData: ImmutableMappable { let contract: Any? let refBlockBytes: String let refBlockHash: String diff --git a/Sources/TronKit/TronGrid/FullNode/CreatedTransactionResponse.swift b/Sources/TronKit/TronGrid/FullNode/CreatedTransactionResponse.swift index a11c9ea..9b2840f 100644 --- a/Sources/TronKit/TronGrid/FullNode/CreatedTransactionResponse.swift +++ b/Sources/TronKit/TronGrid/FullNode/CreatedTransactionResponse.swift @@ -1,10 +1,10 @@ import Foundation import ObjectMapper -struct CreatedTransactionResponse: ImmutableMappable { - let txID: Data - let rawData: TransactionResponse.RawData - let rawDataHex: Data +public struct CreatedTransactionResponse: ImmutableMappable { + public let txID: Data + public let rawData: TransactionResponse.RawData + public let rawDataHex: Data public init(map: Map) throws { txID = try map.value("txID", using: HexDataTransform()) From 46971b72531b0ceb6ff43c5e006a2f4408d34717 Mon Sep 17 00:00:00 2001 From: Maksym Vereshchaka Date: Fri, 6 Dec 2024 14:30:19 +0200 Subject: [PATCH 2/2] Update Signer initialization to public mode access --- Sources/TronKit/Signer/Signer.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/TronKit/Signer/Signer.swift b/Sources/TronKit/Signer/Signer.swift index 52fbd7f..f4ec99e 100644 --- a/Sources/TronKit/Signer/Signer.swift +++ b/Sources/TronKit/Signer/Signer.swift @@ -7,7 +7,7 @@ import HsToolKit public class Signer { private let privateKey: Data - init(privateKey: Data) { + public init(privateKey: Data) { self.privateKey = privateKey }