Skip to content

Commit

Permalink
Improve pending transaction handling + add explorer to CLO
Browse files Browse the repository at this point in the history
  • Loading branch information
vikmeup committed Apr 16, 2018
1 parent 325de27 commit c93645d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Trust/EtherClient/ChainState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ class ChainState {
func confirmations(fromBlock: Int) -> Int? {
guard fromBlock > 0 else { return nil }
let block = latestBlock - fromBlock
guard latestBlock != 0, block > 0 else { return nil }
return max(0, block)
guard latestBlock != 0, block >= 0 else { return nil }
return max(1, block)
}
deinit {
NotificationCenter.default.removeObserver(self)
Expand Down
4 changes: 3 additions & 1 deletion Trust/InCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@ class InCoordinator: Coordinator {
showTab(.wallet)

// activate all view controllers.
let _ = [Tabs.wallet, Tabs.transactions].map { tabBarController.viewControllers?[$0.index].view }
[Tabs.wallet, Tabs.transactions].forEach {
tabBarController.viewControllers?[$0.index].view
}

keystore.recentlyUsedWallet = account
}
Expand Down
4 changes: 3 additions & 1 deletion Trust/Settings/Types/ConfigExplorer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ struct ConfigExplorer {
return "https://poaexplorer.com"
case .sokol:
return "https://sokol-explorer.poa.network"
case .custom, .callisto:
case .callisto:
return "https://explorer.callisto.network/tx/"
case .custom:
return .none
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,24 @@ import XCTest

class TransactionViewModelTests: XCTestCase {

func testErrorState() {
let viewModel = TransactionViewModel(transaction: .make(state: .error), config: .make(), chainState: .make(), currentWallet: .make())
func testPendingState() {
let blockNumber = 0
let chainState: ChainState = .make()
chainState.latestBlock = blockNumber

let viewModel = TransactionViewModel(transaction: .make(blockNumber: blockNumber), config: .make(), chainState: chainState, currentWallet: .make())

XCTAssertEqual(.none, viewModel.confirmations)
}

func testPendingState() {
func testConfirmedState() {
let blockNumber = 1
let chainState: ChainState = .make()
chainState.latestBlock = blockNumber

let viewModel = TransactionViewModel(transaction: .make(blockNumber: blockNumber), config: .make(), chainState: chainState, currentWallet: .make())

XCTAssertEqual(.none, viewModel.confirmations)
XCTAssertEqual(1, viewModel.confirmations)
}

func testCompleteStateWhenLatestBlockBehind() {
Expand Down

0 comments on commit c93645d

Please sign in to comment.