Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving the logic of the sent transaction #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Sources/TronKit/Core/Kit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion Sources/TronKit/Signer/Signer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import HsToolKit
public class Signer {
private let privateKey: Data

init(privateKey: Data) {
public init(privateKey: Data) {
self.privateKey = privateKey
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -42,7 +42,7 @@ struct TransactionResponse: ImmutableMappable, ITransactionResponse {
}
}

struct RawData: ImmutableMappable {
public struct RawData: ImmutableMappable {
let contract: Any?
let refBlockBytes: String
let refBlockHash: String
Expand Down
Original file line number Diff line number Diff line change
@@ -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())
Expand Down