Merge pull request #668 from alpha-wallet/add-open-etherscan-button-for-erc20-token-cards

Add open etherscan button for erc20 token cards
pull/670/head
James Sangalli 6 years ago committed by GitHub
commit 57f99f0b7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      AlphaWallet/InCoordinator.swift
  2. 16
      AlphaWallet/Transfer/Coordinators/PaymentCoordinator.swift
  3. 16
      AlphaWallet/Transfer/Coordinators/SendCoordinator.swift
  4. 37
      AlphaWallet/Transfer/ViewControllers/SendViewController.swift

@ -50,12 +50,6 @@ class InCoordinator: Coordinator {
}.first
}
var tokensCardCoordinator: TokensCardCoordinator? {
return self.coordinators.compactMap {
$0 as? TokensCardCoordinator
}.first
}
var tabBarController: UITabBarController? {
return self.navigationController.viewControllers.first as? UITabBarController
}

@ -4,7 +4,7 @@ import Foundation
import UIKit
import TrustKeystore
protocol PaymentCoordinatorDelegate: class {
protocol PaymentCoordinatorDelegate: class, CanOpenURL {
func didFinish(_ result: ConfirmResult, in coordinator: PaymentCoordinator)
func didCancel(in coordinator: PaymentCoordinator)
}
@ -97,3 +97,17 @@ extension PaymentCoordinator: RequestCoordinatorDelegate {
cancel()
}
}
extension PaymentCoordinator: CanOpenURL {
func didPressViewContractWebPage(forContract contract: String, in viewController: UIViewController) {
delegate?.didPressViewContractWebPage(forContract: contract, in: viewController)
}
func didPressViewContractWebPage(_ url: URL, in viewController: UIViewController) {
delegate?.didPressViewContractWebPage(url, in: viewController)
}
func didPressOpenWebPage(_ url: URL, in viewController: UIViewController) {
delegate?.didPressOpenWebPage(url, in: viewController)
}
}

@ -5,7 +5,7 @@ import UIKit
import BigInt
import TrustKeystore
protocol SendCoordinatorDelegate: class {
protocol SendCoordinatorDelegate: class, CanOpenURL {
func didFinish(_ result: ConfirmResult, in coordinator: SendCoordinator)
func didCancel(in coordinator: SendCoordinator)
}
@ -120,3 +120,17 @@ extension SendCoordinator: SendViewControllerDelegate {
navigationController.pushViewController(controller, animated: true)
}
}
extension SendCoordinator: CanOpenURL {
func didPressViewContractWebPage(forContract contract: String, in viewController: UIViewController) {
delegate?.didPressViewContractWebPage(forContract: contract, in: viewController)
}
func didPressViewContractWebPage(_ url: URL, in viewController: UIViewController) {
delegate?.didPressViewContractWebPage(url, in: viewController)
}
func didPressOpenWebPage(_ url: URL, in viewController: UIViewController) {
delegate?.didPressOpenWebPage(url, in: viewController)
}
}

@ -11,7 +11,7 @@ import BigInt
import TrustKeystore
import MBProgressHUD
protocol SendViewControllerDelegate: class {
protocol SendViewControllerDelegate: class, CanOpenURL {
func didPressConfirm(
transaction: UnconfirmedTransaction,
transferType: TransferType,
@ -19,7 +19,7 @@ protocol SendViewControllerDelegate: class {
)
}
class SendViewController: UIViewController, CanScanQRCode {
class SendViewController: UIViewController, CanScanQRCode, TokenVerifiableStatusViewController {
let roundedBackground = RoundedBackground()
let header = SendHeaderView()
let targetAddressTextField = AddressTextField()
@ -55,6 +55,25 @@ class SendViewController: UIViewController, CanScanQRCode {
var balanceViewModel: BalanceBaseViewModel?
weak var delegate: SendViewControllerDelegate?
let config: Config
var contract: String {
//Only ERC20 tokens are relevant here
switch transferType {
case .ERC20Token(let token):
return token.contract
case .ether:
return "0x"
case .dapp:
return "0x"
case .ERC875Token:
return "0x"
case .ERC875TokenOrder:
return "0x"
case .ERC721Token:
return "0x"
}
}
let session: WalletSession
let account: Account
let transferType: TransferType
@ -83,9 +102,14 @@ class SendViewController: UIViewController, CanScanQRCode {
self.transferType = transferType
self.storage = storage
self.ethPrice = ethPrice
self.config = Config()
super.init(nibName: nil, bundle: nil)
if case .ERC20Token = transferType {
updateNavigationRightBarButtons(isVerified: false, hasShowInfoButton: false)
}
configureBalanceViewModel()
roundedBackground.translatesAutoresizingMaskIntoConstraints = false
@ -445,3 +469,12 @@ extension SendViewController: AddressTextFieldDelegate {
return true
}
}
extension SendViewController: VerifiableStatusViewController {
func showInfo() {
}
func showContractWebPage() {
delegate?.didPressViewContractWebPage(forContract: contract, in: self)
}
}

Loading…
Cancel
Save