Skip to content

Commit

Permalink
Update TonKit library to latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
ealymbaev committed Apr 17, 2024
1 parent a01fbf2 commit 49d8319
Show file tree
Hide file tree
Showing 13 changed files with 48,903 additions and 48,074 deletions.

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class TonAdapter {
}
}

private func handle(tonTransactions: [TonTransaction]) {
private func handle(tonTransactions: [TonTransactionWithTransfers]) {
let transactionRecords = tonTransactions.map { transactionRecord(tonTransaction: $0) }
transactionRecordsSubject.onNext(transactionRecords)
}
Expand All @@ -137,7 +137,7 @@ class TonAdapter {
return decimal / coinRate
}

private func transactionRecord(tonTransaction tx: TonTransaction) -> TonTransactionRecord {
private func transactionRecord(tonTransaction tx: TonTransactionWithTransfers) -> TonTransactionRecord {
switch tx.type {
case TransactionType.incoming:
return TonIncomingTransactionRecord(
Expand All @@ -162,11 +162,11 @@ class TonAdapter {
}
}

private func transactionsSingle(from: TransactionRecord?, type: TransactionType?, limit: Int) -> Single<[TransactionRecord]> {
let single: Single<[TonTransaction]> = Single.create { [tonKit] observer in
private func transactionsSingle(from: TransactionRecord?, type: TransactionType?, address: String?, limit: Int) -> Single<[TransactionRecord]> {
let single: Single<[TonTransactionWithTransfers]> = Single.create { [tonKit] observer in
let task = Task { [tonKit] in
do {
let tonTransactions = try await tonKit.transactions(fromTransactionHash: from?.transactionHash, type: type, limit: Int64(limit))
let tonTransactions = try await tonKit.transactions(fromTransactionHash: from?.transactionHash, type: type, address: address, limit: Int64(limit))
observer(.success(tonTransactions))
} catch {
observer(.error(error))
Expand Down Expand Up @@ -288,11 +288,11 @@ extension TonAdapter: ITransactionsAdapter {
.filter { !$0.isEmpty }
}

func transactionsSingle(from: TransactionRecord?, token _: Token?, filter: TransactionTypeFilter, address _: String?, limit: Int) -> Single<[TransactionRecord]> {
func transactionsSingle(from: TransactionRecord?, token _: Token?, filter: TransactionTypeFilter, address: String?, limit: Int) -> Single<[TransactionRecord]> {
switch filter {
case .all: return transactionsSingle(from: from, type: nil, limit: limit)
case .incoming: return transactionsSingle(from: from, type: TransactionType.incoming, limit: limit)
case .outgoing: return transactionsSingle(from: from, type: TransactionType.outgoing, limit: limit)
case .all: return transactionsSingle(from: from, type: nil, address: address, limit: limit)
case .incoming: return transactionsSingle(from: from, type: TransactionType.incoming, address: address, limit: limit)
case .outgoing: return transactionsSingle(from: from, type: TransactionType.outgoing, address: address, limit: limit)
default: return Single.just([])
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import TonKitKmm
class TonIncomingTransactionRecord: TonTransactionRecord {
let transfer: Transfer?

init(source: TransactionSource, transaction: TonTransaction, feeToken: Token, token: Token) {
init(source: TransactionSource, transaction: TonTransactionWithTransfers, feeToken: Token, token: Token) {
transfer = transaction.transfers.first.map { transfer in
Transfer(
address: transfer.src,
address: transfer.src.getNonBounceable(),
value: .coinValue(token: token, value: TonAdapter.amount(kitAmount: transfer.amount))
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class TonOutgoingTransactionRecord: TonTransactionRecord {
let transfers: [Transfer]
let totalValue: TransactionValue

init(source: TransactionSource, transaction: TonTransaction, feeToken: Token, token: Token) {
init(source: TransactionSource, transaction: TonTransactionWithTransfers, feeToken: Token, token: Token) {
var totalAmount: Decimal = 0

transfers = transaction.transfers.map { transfer in
Expand All @@ -16,7 +16,7 @@ class TonOutgoingTransactionRecord: TonTransactionRecord {
totalAmount += value

return Transfer(
address: transfer.dest,
address: transfer.dest.getNonBounceable(),
value: .coinValue(token: token, value: value)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class TonTransactionRecord: TransactionRecord {
let fee: TransactionValue?
let memo: String?

init(source: TransactionSource, transaction: TonTransaction, feeToken: Token) {
init(source: TransactionSource, transaction: TonTransactionWithTransfers, feeToken: Token) {
fee = transaction.fee.map { .coinValue(token: feeToken, value: TonAdapter.amount(kitAmount: $0)) }
memo = transaction.memo

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import RxSwift
class TransactionContactSelectViewModel: ObservableObject {
static let allowedBlockchainUids = EvmBlockchainManager.blockchainTypes.map(\.uid) + [
BlockchainType.tron.uid,
BlockchainType.ton.uid,
BlockchainType.zcash.uid,
]
private let disposeBag = DisposeBag()
Expand Down

0 comments on commit 49d8319

Please sign in to comment.