Rename TransferType -> TransactionType. Name was misleading for a long time

pull/2311/head
Hwee-Boon Yar 4 years ago
parent 517e209d8d
commit e7f1ae7ada
  1. 8
      AlphaWallet.xcodeproj/project.pbxproj
  2. 16
      AlphaWallet/Browser/Coordinators/QRCodeResolutionCoordinator.swift
  3. 10
      AlphaWallet/Browser/Types/DappAction.swift
  4. 3
      AlphaWallet/Browser/ViewControllers/BrowserViewController.swift
  5. 4
      AlphaWallet/Core/Coordinators/CustomUrlSchemeCoordinator.swift
  6. 2
      AlphaWallet/TokenScriptClient/Models/FunctionOrigin.swift
  7. 2
      AlphaWallet/Tokens/Coordinators/ClaimPaidOrderCoordinator.swift
  8. 34
      AlphaWallet/Tokens/Coordinators/SingleChainTokenCoordinator.swift
  9. 8
      AlphaWallet/Tokens/Coordinators/TokensCoordinator.swift
  10. 4
      AlphaWallet/Tokens/ViewControllers/TokenInstanceViewController.swift
  11. 28
      AlphaWallet/Tokens/ViewControllers/TokenViewController.swift
  12. 4
      AlphaWallet/Tokens/ViewControllers/TokensCardViewController.swift
  13. 14
      AlphaWallet/Tokens/ViewModels/TokenViewControllerViewModel.swift
  14. 5
      AlphaWallet/Tokens/Views/TokenInstanceWebView.swift
  15. 12
      AlphaWallet/Transactions/Coordinators/TokensCardCoordinator.swift
  16. 6
      AlphaWallet/Transfer/Controllers/TransactionConfigurator.swift
  17. 2
      AlphaWallet/Transfer/Coordinators/PaymentCoordinator.swift
  18. 12
      AlphaWallet/Transfer/Coordinators/SendCoordinator.swift
  19. 8
      AlphaWallet/Transfer/Coordinators/TransferNFTCoordinator.swift
  20. 2
      AlphaWallet/Transfer/Types/PaymentFlow.swift
  21. 9
      AlphaWallet/Transfer/Types/TransactionType.swift
  22. 6
      AlphaWallet/Transfer/Types/UnconfirmedTransaction.swift
  23. 46
      AlphaWallet/Transfer/ViewControllers/SendViewController.swift
  24. 2
      AlphaWallet/Transfer/ViewControllers/TransactionConfirmationViewController.swift
  25. 6
      AlphaWallet/Transfer/ViewModels/ConfigureTransactionViewModel.swift
  26. 8
      AlphaWallet/Transfer/ViewModels/SendHeaderViewViewModel.swift
  27. 28
      AlphaWallet/Transfer/ViewModels/SendViewModel.swift
  28. 10
      AlphaWallet/Transfer/ViewModels/TransactionConfirmationViewModel.swift
  29. 4
      AlphaWalletTests/Coordinators/SendCoordinatorTests.swift
  30. 4
      AlphaWalletTests/Factories/UnconfirmedTransaction.swift

@ -67,7 +67,7 @@
296105931FA2AA2100292494 /* UnsignedTransaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 296105921FA2AA2100292494 /* UnsignedTransaction.swift */; };
296105951FA2DEF000292494 /* TransactionDirection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 296105941FA2DEF000292494 /* TransactionDirection.swift */; };
296106CC1F776FD00006164B /* WalletCoordinatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 296106CB1F776FD00006164B /* WalletCoordinatorTests.swift */; };
296106D01F778A8D0006164B /* TransferType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 296106CF1F778A8D0006164B /* TransferType.swift */; };
296106D01F778A8D0006164B /* TransactionType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 296106CF1F778A8D0006164B /* TransactionType.swift */; };
2961BD071FB146EB00C4B840 /* ChainState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2961BD061FB146EB00C4B840 /* ChainState.swift */; };
2961BD091FB14B6D00C4B840 /* Config.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2961BD081FB14B6D00C4B840 /* Config.swift */; };
2963A2881FC401490095447D /* LocalizedOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2963A2871FC401490095447D /* LocalizedOperation.swift */; };
@ -884,7 +884,7 @@
296105921FA2AA2100292494 /* UnsignedTransaction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnsignedTransaction.swift; sourceTree = "<group>"; };
296105941FA2DEF000292494 /* TransactionDirection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransactionDirection.swift; sourceTree = "<group>"; };
296106CB1F776FD00006164B /* WalletCoordinatorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalletCoordinatorTests.swift; sourceTree = "<group>"; };
296106CF1F778A8D0006164B /* TransferType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransferType.swift; sourceTree = "<group>"; };
296106CF1F778A8D0006164B /* TransactionType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransactionType.swift; sourceTree = "<group>"; };
2961BD061FB146EB00C4B840 /* ChainState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChainState.swift; sourceTree = "<group>"; };
2961BD081FB14B6D00C4B840 /* Config.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Config.swift; sourceTree = "<group>"; };
2963A2871FC401490095447D /* LocalizedOperation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalizedOperation.swift; sourceTree = "<group>"; };
@ -2496,7 +2496,7 @@
isa = PBXGroup;
children = (
2963B6AE1F9823E6003063C1 /* UnconfirmedTransaction.swift */,
296106CF1F778A8D0006164B /* TransferType.swift */,
296106CF1F778A8D0006164B /* TransactionType.swift */,
29B6AED51F7CA4A700EC6DE3 /* TransactionConfiguration.swift */,
29B933F71F8609FF009FCABB /* PaymentFlow.swift */,
299B5E461FD2C87F0051361C /* ConfigureTransactionError.swift */,
@ -4348,7 +4348,7 @@
29FC9BC61F830899000209CD /* MigrationInitializerForOneChainPerDatabase.swift in Sources */,
29AD8A091F93F8B2008E10E7 /* Session.swift in Sources */,
29BB94971F6FCD60009B09CC /* SendViewModel.swift in Sources */,
296106D01F778A8D0006164B /* TransferType.swift in Sources */,
296106D01F778A8D0006164B /* TransactionType.swift in Sources */,
29E14FDB1F7F4F3D00185568 /* Transaction.swift in Sources */,
BBF4F9B72029D0B3009E04C0 /* GasViewModel.swift in Sources */,
AA26C628204134C500318B9B /* TokenCardTableViewCellWithoutCheckbox.swift in Sources */,

@ -11,7 +11,7 @@ import PromiseKit
protocol QRCodeResolutionCoordinatorDelegate: class {
func coordinator(_ coordinator: QRCodeResolutionCoordinator, didResolveAddress address: AlphaWallet.Address, action: ScanQRCodeAction)
func coordinator(_ coordinator: QRCodeResolutionCoordinator, didResolveTransferType transferType: TransferType, token: TokenObject)
func coordinator(_ coordinator: QRCodeResolutionCoordinator, didResolveTransactionType transactionType: TransactionType, token: TokenObject)
func coordinator(_ coordinator: QRCodeResolutionCoordinator, didResolveWalletConnectURL url: WCURL)
func coordinator(_ coordinator: QRCodeResolutionCoordinator, didResolveString value: String)
func coordinator(_ coordinator: QRCodeResolutionCoordinator, didResolveURL url: URL)
@ -137,7 +137,7 @@ extension QRCodeResolutionCoordinator: ScanQRCodeCoordinatorDelegate {
let data = CheckEIP681Params(protocolName: protocolName, address: address, functionName: function, params: params, rpcServer: rpcServer)
self.checkEIP681(data).done { result in
delegate.coordinator(self, didResolveTransferType: result.transferType, token: result.token)
delegate.coordinator(self, didResolveTransactionType: result.transactionType, token: result.token)
}.cauterize()
}
case .other(let value):
@ -205,8 +205,8 @@ extension QRCodeResolutionCoordinator: ScanQRCodeCoordinatorDelegate {
let rpcServer: RPCServer
}
private func checkEIP681(_ params: CheckEIP681Params) -> Promise<(transferType: TransferType, token: TokenObject)> {
return Eip681Parser(protocolName: params.protocolName, address: params.address, functionName: params.functionName, params: params.params).parse().then { result -> Promise<(transferType: TransferType, token: TokenObject)> in
private func checkEIP681(_ params: CheckEIP681Params) -> Promise<(transactionType: TransactionType, token: TokenObject)> {
return Eip681Parser(protocolName: params.protocolName, address: params.address, functionName: params.functionName, params: params.params).parse().then { result -> Promise<(transactionType: TransactionType, token: TokenObject)> in
guard let (contract: contract, customServer, recipient, maybeScientificAmountString) = result.parameters else {
return .init(error: CheckEIP681Error.parameterInvalid)
}
@ -220,9 +220,9 @@ extension QRCodeResolutionCoordinator: ScanQRCodeCoordinatorDelegate {
EtherNumberFormatter.full.string(from: $0, decimals: token.decimals)
}
let transferType = TransferType(token: token, recipient: recipient, amount: amount)
let transactionType = TransactionType(token: token, recipient: recipient, amount: amount)
return .value((transferType, token))
return .value((transactionType, token))
} else {
return Promise { resolver in
fetchContractDataFor(address: contract, storage: storage, assetDefinitionStore: self.assetDefinitionStore) { result in
@ -242,9 +242,9 @@ extension QRCodeResolutionCoordinator: ScanQRCodeCoordinatorDelegate {
let amount = maybeScientificAmountString.scientificAmountToBigInt.flatMap {
EtherNumberFormatter.full.string(from: $0, decimals: token.decimals)
}
let transferType = TransferType(token: token, recipient: recipient, amount: amount)
let transactionType = TransactionType(token: token, recipient: recipient, amount: amount)
resolver.fulfill((transferType, token))
resolver.fulfill((transactionType, token))
}
}
}

@ -14,12 +14,12 @@ enum DappAction {
}
extension DappAction {
static func fromCommand(_ command: DappCommand, transfer: Transfer) -> DappAction {
static func fromCommand(_ command: DappCommand, server: RPCServer, transactionType: TransactionType) -> DappAction {
switch command.name {
case .signTransaction:
return .signTransaction(DappAction.makeUnconfirmedTransaction(command.object, transfer: transfer))
return .signTransaction(DappAction.makeUnconfirmedTransaction(command.object, server: server, transactionType: transactionType))
case .sendTransaction:
return .sendTransaction(DappAction.makeUnconfirmedTransaction(command.object, transfer: transfer))
return .sendTransaction(DappAction.makeUnconfirmedTransaction(command.object, server: server, transactionType: transactionType))
case .signMessage:
let data = command.object["data"]?.value ?? ""
return .signMessage(data)
@ -34,7 +34,7 @@ extension DappAction {
}
}
private static func makeUnconfirmedTransaction(_ object: [String: DappCommandObjectValue], transfer: Transfer) -> UnconfirmedTransaction {
private static func makeUnconfirmedTransaction(_ object: [String: DappCommandObjectValue], server: RPCServer, transactionType: TransactionType) -> UnconfirmedTransaction {
let to = AlphaWallet.Address(string: object["to"]?.value ?? "")
let value = BigInt((object["value"]?.value ?? "0").drop0x, radix: 16) ?? BigInt()
let nonce: BigInt? = {
@ -51,7 +51,7 @@ extension DappAction {
}()
let data = Data(hex: object["data"]?.value ?? "0x")
return UnconfirmedTransaction(
transferType: transfer.type,
transactionType: transactionType,
value: value,
recipient: nil,
contract: to,

@ -231,8 +231,7 @@ extension BrowserViewController: WKScriptMessageHandler {
guard let command = DappAction.fromMessage(message) else { return }
let requester = DAppRequester(title: webView.title, url: webView.url)
let token = TokensDataStore.token(forServer: server)
let transfer = Transfer(server: server, type: .dapp(token, requester))
let action = DappAction.fromCommand(command, transfer: transfer)
let action = DappAction.fromCommand(command, server: server, transactionType: .dapp(token, requester))
delegate?.didCall(action: action, callbackID: command.id, inBrowserViewController: self)
}

@ -80,7 +80,7 @@ class CustomUrlSchemeCoordinator: Coordinator {
} else {
amountConsideringDecimals = ""
}
let transferType = TransferType(token: tokenObject, recipient: recipient, amount: amountConsideringDecimals)
delegate?.openSendPaymentFlow(.send(type: transferType), server: server, inCoordinator: self)
let transactionType = TransactionType(token: tokenObject, recipient: recipient, amount: amountConsideringDecimals)
delegate?.openSendPaymentFlow(.send(type: transactionType), server: server, inCoordinator: self)
}
}

@ -271,7 +271,7 @@ struct FunctionOrigin {
}
//TODO feels ike everything can just be in `.tokenScript`. But have to check dapp, it includes other parameters like gas
return .success(UnconfirmedTransaction(
transferType: .tokenScript(tokenObject),
transactionType: .tokenScript(tokenObject),
value: BigInt(value),
recipient: nil,
contract: originContractOrRecipientAddress,

@ -69,7 +69,7 @@ class ClaimPaidOrderCoordinator: Coordinator {
case .success(let payload):
let account = strongSelf.session.account.address
let transaction = UnconfirmedTransaction(
transferType: .claimPaidErc875MagicLink(strongSelf.tokenObject),
transactionType: .claimPaidErc875MagicLink(strongSelf.tokenObject),
value: BigInt(strongSelf.signedOrder.order.price),
recipient: nil,
contract: strongSelf.signedOrder.order.contractAddress,

@ -390,31 +390,31 @@ class SingleChainTokenCoordinator: Coordinator {
return try! Realm(configuration: migration.config)
}
func show(fungibleToken token: TokenObject, transferType: TransferType) {
func show(fungibleToken token: TokenObject, transactionType: TransactionType) {
guard let transactionsStore = createTransactionsStore() else { return }
let viewController = TokenViewController(session: session, tokensDataStore: storage, assetDefinition: assetDefinitionStore, transferType: transferType, token: token)
let viewController = TokenViewController(session: session, tokensDataStore: storage, assetDefinition: assetDefinitionStore, transactionType: transactionType, token: token)
viewController.delegate = self
let viewModel = TokenViewControllerViewModel(transferType: transferType, session: session, tokensStore: storage, transactionsStore: transactionsStore, assetDefinitionStore: assetDefinitionStore)
let viewModel = TokenViewControllerViewModel(transactionType: transactionType, session: session, tokensStore: storage, transactionsStore: transactionsStore, assetDefinitionStore: assetDefinitionStore)
viewController.configure(viewModel: viewModel)
viewController.navigationItem.leftBarButtonItem = UIBarButtonItem(image: R.image.backWhite(), style: .plain, target: self, action: #selector(dismiss))
navigationController.pushViewController(viewController, animated: true)
refreshTokenViewControllerUponAssetDefinitionChanges(viewController, forTransferType: transferType, transactionsStore: transactionsStore)
refreshTokenViewControllerUponAssetDefinitionChanges(viewController, forTransactionType: transactionType, transactionsStore: transactionsStore)
}
private func refreshTokenViewControllerUponAssetDefinitionChanges(_ viewController: TokenViewController, forTransferType transferType: TransferType, transactionsStore: TransactionsStorage) {
private func refreshTokenViewControllerUponAssetDefinitionChanges(_ viewController: TokenViewController, forTransactionType transactionType: TransactionType, transactionsStore: TransactionsStorage) {
assetDefinitionStore.subscribeToBodyChanges { [weak self] contract in
guard let strongSelf = self else { return }
guard contract.sameContract(as: transferType.contract) else { return }
let viewModel = TokenViewControllerViewModel(transferType: transferType, session: strongSelf.session, tokensStore: strongSelf.storage, transactionsStore: transactionsStore, assetDefinitionStore: strongSelf.assetDefinitionStore)
guard contract.sameContract(as: transactionType.contract) else { return }
let viewModel = TokenViewControllerViewModel(transactionType: transactionType, session: strongSelf.session, tokensStore: strongSelf.storage, transactionsStore: transactionsStore, assetDefinitionStore: strongSelf.assetDefinitionStore)
viewController.configure(viewModel: viewModel)
}
assetDefinitionStore.subscribeToSignatureChanges { [weak self] contract in
guard let strongSelf = self else { return }
guard contract.sameContract(as: transferType.contract) else { return }
let viewModel = TokenViewControllerViewModel(transferType: transferType, session: strongSelf.session, tokensStore: strongSelf.storage, transactionsStore: transactionsStore, assetDefinitionStore: strongSelf.assetDefinitionStore)
guard contract.sameContract(as: transactionType.contract) else { return }
let viewModel = TokenViewControllerViewModel(transactionType: transactionType, session: strongSelf.session, tokensStore: strongSelf.storage, transactionsStore: transactionsStore, assetDefinitionStore: strongSelf.assetDefinitionStore)
viewController.configure(viewModel: viewModel)
}
}
@ -550,7 +550,7 @@ extension SingleChainTokenCoordinator: TokensCardCoordinatorDelegate {
}
}
extension TransferType {
extension TransactionType {
func uniswapHolder(theme: UniswapHolder.Theme) -> UniswapHolder {
switch self {
@ -579,17 +579,17 @@ extension UITraitCollection {
extension SingleChainTokenCoordinator: TokenViewControllerDelegate {
func didTapErc20ExchangeOnUniswap(forTransferType transferType: TransferType, inViewController viewController: TokenViewController) {
func didTapErc20ExchangeOnUniswap(forTransactionType transactionType: TransactionType, inViewController viewController: TokenViewController) {
let theme = viewController.traitCollection.uniswapTheme
delegate?.didPressErc20ExchangeOnUniswap(for: transferType.uniswapHolder(theme: theme), in: self)
delegate?.didPressErc20ExchangeOnUniswap(for: transactionType.uniswapHolder(theme: theme), in: self)
}
func didTapSend(forTransferType transferType: TransferType, inViewController viewController: TokenViewController) {
delegate?.didPress(for: .send(type: transferType), inCoordinator: self)
func didTapSend(forTransactionType transactionType: TransactionType, inViewController viewController: TokenViewController) {
delegate?.didPress(for: .send(type: transactionType), inCoordinator: self)
}
func didTapReceive(forTransferType transferType: TransferType, inViewController viewController: TokenViewController) {
func didTapReceive(forTransactionType transactionType: TransactionType, inViewController viewController: TokenViewController) {
delegate?.didPress(for: .request, inCoordinator: self)
}
@ -597,9 +597,9 @@ extension SingleChainTokenCoordinator: TokenViewControllerDelegate {
delegate?.didTap(transaction: transaction, inViewController: viewController, in: self)
}
func didTap(action: TokenInstanceAction, transferType: TransferType, viewController: TokenViewController) {
func didTap(action: TokenInstanceAction, transactionType: TransactionType, viewController: TokenViewController) {
let token: TokenObject
switch transferType {
switch transactionType {
case .ERC20Token(let erc20Token, _, _):
token = erc20Token
case .dapp, .ERC721Token, .ERC875Token, .ERC875TokenOrder, .ERC721ForTicketToken, .tokenScript, .claimPaidErc875MagicLink:

@ -184,9 +184,9 @@ extension TokensCoordinator: TokensViewControllerDelegate {
guard let coordinator = singleChainTokenCoordinator(forServer: server) else { return }
switch token.type {
case .nativeCryptocurrency:
coordinator.show(fungibleToken: token, transferType: .nativeCryptocurrency(token, destination: .none, amount: nil))
coordinator.show(fungibleToken: token, transactionType: .nativeCryptocurrency(token, destination: .none, amount: nil))
case .erc20:
coordinator.show(fungibleToken: token, transferType: .ERC20Token(token, destination: nil, amount: nil))
coordinator.show(fungibleToken: token, transactionType: .ERC20Token(token, destination: nil, amount: nil))
case .erc721:
coordinator.showTokenList(for: .send(type: .ERC721Token(token)), token: token)
case .erc875, .erc721ForTickets:
@ -240,10 +240,10 @@ extension TokensCoordinator: QRCodeResolutionCoordinatorDelegate {
removeCoordinator(coordinator)
}
func coordinator(_ coordinator: QRCodeResolutionCoordinator, didResolveTransferType transferType: TransferType, token: TokenObject) {
func coordinator(_ coordinator: QRCodeResolutionCoordinator, didResolveTransactionType transactionType: TransactionType, token: TokenObject) {
removeCoordinator(coordinator)
let paymentFlow = PaymentFlow.send(type: transferType)
let paymentFlow = PaymentFlow.send(type: transactionType)
delegate?.didPress(for: paymentFlow, server: token.server, in: self)
}

@ -144,8 +144,8 @@ class TokenInstanceViewController: UIViewController, TokenVerifiableStatusViewCo
}
func transfer() {
let transferType = TransferType(token: tokenObject)
delegate?.didPressTransfer(token: tokenObject, tokenHolder: tokenHolder, forPaymentFlow: .send(type: transferType), in: self)
let transactionType = TransactionType(token: tokenObject)
delegate?.didPressTransfer(token: tokenObject, tokenHolder: tokenHolder, forPaymentFlow: .send(type: transactionType), in: self)
}
private func handle(action: TokenInstanceAction) {

@ -6,27 +6,27 @@ import BigInt
import PromiseKit
protocol TokenViewControllerDelegate: class, CanOpenURL {
func didTapErc20ExchangeOnUniswap(forTransferType transferType: TransferType, inViewController viewController: TokenViewController)
func didTapSend(forTransferType transferType: TransferType, inViewController viewController: TokenViewController)
func didTapReceive(forTransferType transferType: TransferType, inViewController viewController: TokenViewController)
func didTapErc20ExchangeOnUniswap(forTransactionType transactionType: TransactionType, inViewController viewController: TokenViewController)
func didTapSend(forTransactionType transactionType: TransactionType, inViewController viewController: TokenViewController)
func didTapReceive(forTransactionType transactionType: TransactionType, inViewController viewController: TokenViewController)
func didTap(transaction: Transaction, inViewController viewController: TokenViewController)
func didTap(action: TokenInstanceAction, transferType: TransferType, viewController: TokenViewController)
func didTap(action: TokenInstanceAction, transactionType: TransactionType, viewController: TokenViewController)
}
class TokenViewController: UIViewController {
private let headerViewRefreshInterval: TimeInterval = 5.0
private let roundedBackground = RoundedBackground()
lazy private var header = {
return TokenViewControllerHeaderView(contract: transferType.contract)
return TokenViewControllerHeaderView(contract: transactionType.contract)
}()
lazy private var headerViewModel = SendHeaderViewViewModel(server: session.server, token: token, transferType: transferType)
lazy private var headerViewModel = SendHeaderViewViewModel(server: session.server, token: token, transactionType: transactionType)
private var viewModel: TokenViewControllerViewModel?
private var tokenHolder: TokenHolder?
private let token: TokenObject
private let session: WalletSession
private let tokensDataStore: TokensDataStore
private let assetDefinitionStore: AssetDefinitionStore
private let transferType: TransferType
private let transactionType: TransactionType
private let tableView = UITableView(frame: .zero, style: .plain)
private let buttonsBar = ButtonsBar(configuration: .combined(buttons: 2))
private lazy var tokenScriptFileStatusHandler = XMLHandler(token: token, assetDefinitionStore: assetDefinitionStore)
@ -34,12 +34,12 @@ class TokenViewController: UIViewController {
weak var delegate: TokenViewControllerDelegate?
init(session: WalletSession, tokensDataStore: TokensDataStore, assetDefinition: AssetDefinitionStore, transferType: TransferType, token: TokenObject) {
init(session: WalletSession, tokensDataStore: TokensDataStore, assetDefinition: AssetDefinitionStore, transactionType: TransactionType, token: TokenObject) {
self.token = token
self.session = session
self.tokensDataStore = tokensDataStore
self.assetDefinitionStore = assetDefinition
self.transferType = transferType
self.transactionType = transactionType
super.init(nibName: nil, bundle: nil)
hidesBottomBarWhenPushed = true
@ -158,7 +158,7 @@ class TokenViewController: UIViewController {
}
private func configureBalanceViewModel() {
switch transferType {
switch transactionType {
case .nativeCryptocurrency:
session.balanceViewModel.subscribe { [weak self] viewModel in
guard let celf = self, let viewModel = viewModel else { return }
@ -193,15 +193,15 @@ class TokenViewController: UIViewController {
}
@objc private func send() {
delegate?.didTapSend(forTransferType: transferType, inViewController: self)
delegate?.didTapSend(forTransactionType: transactionType, inViewController: self)
}
@objc private func receive() {
delegate?.didTapReceive(forTransferType: transferType, inViewController: self)
delegate?.didTapReceive(forTransactionType: transactionType, inViewController: self)
}
@objc private func erc20ExchangeOnUniswap() {
delegate?.didTapErc20ExchangeOnUniswap(forTransferType: transferType, inViewController: self)
delegate?.didTapErc20ExchangeOnUniswap(forTransactionType: transactionType, inViewController: self)
}
@objc private func actionButtonTapped(sender: UIButton) {
@ -232,7 +232,7 @@ class TokenViewController: UIViewController {
//no-op shouldn't have reached here since the button should be disabled. So just do nothing to be safe
}
} else {
delegate?.didTap(action: action, transferType: transferType, viewController: self)
delegate?.didTap(action: action, transactionType: transactionType, viewController: self)
}
}
break

@ -207,8 +207,8 @@ class TokensCardViewController: UIViewController, TokenVerifiableStatusViewContr
func transfer() {
guard let selectedTokenHolder = selectedTokenHolder else { return }
let transferType = TransferType(token: viewModel.token)
delegate?.didPressTransfer(token: viewModel.token, tokenHolder: selectedTokenHolder, for: .send(type: transferType), tokenHolders: viewModel.tokenHolders, in: self)
let transactionType = TransactionType(token: viewModel.token)
delegate?.didPressTransfer(token: viewModel.token, tokenHolder: selectedTokenHolder, for: .send(type: transactionType), tokenHolders: viewModel.tokenHolders, in: self)
}
private func handle(action: TokenInstanceAction) {

@ -6,14 +6,14 @@ import BigInt
import PromiseKit
struct TokenViewControllerViewModel {
private let transferType: TransferType
private let transactionType: TransactionType
private let session: WalletSession
private let tokensStore: TokensDataStore
private let transactionsStore: TransactionsStorage
private let assetDefinitionStore: AssetDefinitionStore
var token: TokenObject? {
switch transferType {
switch transactionType {
case .nativeCryptocurrency:
//TODO might as well just make .nativeCryptocurrency hold the TokenObject instance too
return TokensDataStore.etherToken(forServer: session.server)
@ -101,7 +101,7 @@ struct TokenViewControllerViewModel {
}
var fungibleBalance: BigInt? {
switch transferType {
switch transactionType {
case .nativeCryptocurrency:
let string: String? = session.balanceViewModel.value?.amountShort
return string.flatMap { EtherNumberFormatter.full.number(from: $0, decimals: session.server.decimals) }
@ -112,14 +112,14 @@ struct TokenViewControllerViewModel {
}
}
init(transferType: TransferType, session: WalletSession, tokensStore: TokensDataStore, transactionsStore: TransactionsStorage, assetDefinitionStore: AssetDefinitionStore) {
self.transferType = transferType
init(transactionType: TransactionType, session: WalletSession, tokensStore: TokensDataStore, transactionsStore: TransactionsStorage, assetDefinitionStore: AssetDefinitionStore) {
self.transactionType = transactionType
self.session = session
self.tokensStore = tokensStore
self.transactionsStore = transactionsStore
self.assetDefinitionStore = assetDefinitionStore
switch transferType {
switch transactionType {
case .nativeCryptocurrency:
self.recentTransactions = Array(transactionsStore.objects.lazy
.filter({ $0.state == .completed || $0.state == .pending })
@ -143,7 +143,7 @@ struct TokenViewControllerViewModel {
}
var destinationAddress: AlphaWallet.Address {
return transferType.contract
return transactionType.contract
}
var backgroundColor: UIColor {

@ -430,11 +430,10 @@ extension TokenInstanceWebView: WKScriptMessageHandler {
return
}
//TODO clean up this. Some of these are wrong, eg: Transfer(). They are only here so we can sign personal message
//TODO clean up this. Some of these are wrong, eg: transactionType. They are only here so we can sign personal message
let requester = DAppRequester(title: webView.title, url: webView.url)
let token = TokensDataStore.token(forServer: server)
let transfer = Transfer(server: server, type: .dapp(token, requester))
let action = DappAction.fromCommand(command, transfer: transfer)
let action = DappAction.fromCommand(command, server: server, transactionType: .dapp(token, requester))
switch wallet.type {
case .real(let account):

@ -345,8 +345,8 @@ class TokensCardCoordinator: NSObject, Coordinator {
private func sellViaActivitySheet(tokenHolder: TokenHolder, linkExpiryDate: Date, ethCost: Ether, paymentFlow: PaymentFlow, in viewController: UIViewController, sender: UIView) {
let server: RPCServer
switch paymentFlow {
case .send(let transferType):
server = transferType.server
case .send(let transactionType):
server = transactionType.server
case .request:
return
}
@ -373,8 +373,8 @@ class TokensCardCoordinator: NSObject, Coordinator {
private func transferViaActivitySheet(tokenHolder: TokenHolder, linkExpiryDate: Date, paymentFlow: PaymentFlow, in viewController: UIViewController, sender: UIView) {
let server: RPCServer
switch paymentFlow {
case .send(let transferType):
server = transferType.server
case .send(let transactionType):
server = transactionType.server
case .request:
return
}
@ -655,8 +655,8 @@ extension TokensCardCoordinator: TransferTokensCardViaWalletAddressViewControlle
case .real:
switch paymentFlow {
case .send:
if case .send(let transferType) = paymentFlow {
let coordinator = TransferNFTCoordinator(navigationController: navigationController, transferType: transferType, tokenHolder: tokenHolder, recipient: recipient, keystore: keystore, session: session, ethPrice: ethPrice, analyticsCoordinator: analyticsCoordinator)
if case .send(let transactionType) = paymentFlow {
let coordinator = TransferNFTCoordinator(navigationController: navigationController, transactionType: transactionType, tokenHolder: tokenHolder, recipient: recipient, keystore: keystore, session: session, ethPrice: ethPrice, analyticsCoordinator: analyticsCoordinator)
addCoordinator(coordinator)
coordinator.delegate = self
coordinator.start()

@ -39,7 +39,7 @@ class TransactionConfigurator {
}
var toAddress: AlphaWallet.Address? {
switch transaction.transferType {
switch transaction.transactionType {
case .nativeCryptocurrency:
return transaction.recipient
case .dapp, .ERC20Token, .ERC875Token, .ERC875TokenOrder, .ERC721Token, .ERC721ForTicketToken, .tokenScript, .claimPaidErc875MagicLink:
@ -49,7 +49,7 @@ class TransactionConfigurator {
var value: BigInt {
//TODO why not all `transaction.value`? Shouldn't the other types of transactions make sure their `transaction.value` is 0?
switch transaction.transferType {
switch transaction.transactionType {
case .nativeCryptocurrency, .dapp: return transaction.value
case .ERC20Token: return 0
case .ERC875Token: return 0
@ -211,7 +211,7 @@ class TransactionConfigurator {
private static func createConfiguration(server: RPCServer, transaction: UnconfirmedTransaction, account: AlphaWallet.Address) -> TransactionConfiguration {
do {
switch transaction.transferType {
switch transaction.transactionType {
case .dapp:
return createConfiguration(server: server, transaction: transaction, gasLimit: transaction.gasLimit ?? GasLimitConfiguration.maxGasLimit, data: transaction.data ?? .init())
case .nativeCryptocurrency:

@ -49,7 +49,7 @@ class PaymentCoordinator: Coordinator {
switch (flow, session.account.type) {
case (.send(let type), .real(let account)):
let coordinator = SendCoordinator(
transferType: type,
transactionType: type,
navigationController: navigationController,
session: session,
keystore: keystore,

@ -12,7 +12,7 @@ protocol SendCoordinatorDelegate: class, CanOpenURL {
}
class SendCoordinator: Coordinator {
private let transferType: TransferType
private let transactionType: TransactionType
private let session: WalletSession
private let account: AlphaWallet.Address
private let keystore: Keystore
@ -32,7 +32,7 @@ class SendCoordinator: Coordinator {
weak var delegate: SendCoordinatorDelegate?
init(
transferType: TransferType,
transactionType: TransactionType,
navigationController: UINavigationController = UINavigationController(),
session: WalletSession,
keystore: Keystore,
@ -43,7 +43,7 @@ class SendCoordinator: Coordinator {
assetDefinitionStore: AssetDefinitionStore,
analyticsCoordinator: AnalyticsCoordinator?
) {
self.transferType = transferType
self.transactionType = transactionType
self.navigationController = navigationController
self.navigationController.modalPresentationStyle = .formSheet
self.session = session
@ -58,7 +58,7 @@ class SendCoordinator: Coordinator {
func start() {
sendViewController.configure(viewModel:
.init(transferType: sendViewController.transferType,
.init(transactionType: sendViewController.transactionType,
session: session,
storage: sendViewController.storage
)
@ -78,7 +78,7 @@ class SendCoordinator: Coordinator {
session: session,
storage: storage,
account: account,
transferType: transferType,
transactionType: transactionType,
cryptoPrice: ethPrice,
assetDefinitionStore: assetDefinitionStore
)
@ -86,7 +86,7 @@ class SendCoordinator: Coordinator {
if navigationController.viewControllers.isEmpty {
controller.navigationItem.leftBarButtonItem = UIBarButtonItem(title: R.string.localizable.cancel(), style: .plain, target: self, action: #selector(dismiss))
}
switch transferType {
switch transactionType {
case .nativeCryptocurrency(_, let destination, let amount):
controller.targetAddressTextField.value = destination?.stringValue ?? ""
if let amount = amount {

@ -11,7 +11,7 @@ protocol TransferNFTCoordinatorDelegate: class {
class TransferNFTCoordinator: Coordinator {
private let navigationController: UINavigationController
private let transferType: TransferType
private let transactionType: TransactionType
private let tokenHolder: TokenHolder
private let recipient: AlphaWallet.Address
private let keystore: Keystore
@ -21,9 +21,9 @@ class TransferNFTCoordinator: Coordinator {
var coordinators: [Coordinator] = []
weak var delegate: TransferNFTCoordinatorDelegate?
init(navigationController: UINavigationController, transferType: TransferType, tokenHolder: TokenHolder, recipient: AlphaWallet.Address, keystore: Keystore, session: WalletSession, ethPrice: Subscribable<Double>, analyticsCoordinator: AnalyticsCoordinator?) {
init(navigationController: UINavigationController, transactionType: TransactionType, tokenHolder: TokenHolder, recipient: AlphaWallet.Address, keystore: Keystore, session: WalletSession, ethPrice: Subscribable<Double>, analyticsCoordinator: AnalyticsCoordinator?) {
self.navigationController = navigationController
self.transferType = transferType
self.transactionType = transactionType
self.tokenHolder = tokenHolder
self.recipient = recipient
self.keystore = keystore
@ -34,7 +34,7 @@ class TransferNFTCoordinator: Coordinator {
func start() {
let transaction = UnconfirmedTransaction(
transferType: transferType,
transactionType: transactionType,
value: BigInt(0),
recipient: recipient,
contract: tokenHolder.contractAddress,

@ -3,6 +3,6 @@
import Foundation
enum PaymentFlow {
case send(type: TransferType)
case send(type: TransactionType)
case request
}

@ -3,12 +3,7 @@
import Foundation
import BigInt
struct Transfer {
let server: RPCServer
let type: TransferType
}
enum TransferType {
enum TransactionType {
init(token: TokenObject, recipient: AddressOrEnsName? = nil, amount: String? = nil) {
self = {
switch token.type {
@ -49,7 +44,7 @@ enum TransferType {
}
}
extension TransferType {
extension TransactionType {
var symbol: String {
switch self {

@ -4,7 +4,7 @@ import Foundation
import BigInt
struct UnconfirmedTransaction {
let transferType: TransferType
let transactionType: TransactionType
let value: BigInt
let recipient: AlphaWallet.Address?
let contract: AlphaWallet.Address?
@ -24,7 +24,7 @@ struct UnconfirmedTransaction {
let indices: [UInt16]?
init(
transferType: TransferType,
transactionType: TransactionType,
value: BigInt,
recipient: AlphaWallet.Address?,
contract: AlphaWallet.Address?,
@ -35,7 +35,7 @@ struct UnconfirmedTransaction {
gasPrice: BigInt? = nil,
nonce: BigInt? = nil
) {
self.transferType = transferType
self.transactionType = transactionType
self.value = value
self.recipient = recipient
self.contract = contract

@ -45,11 +45,11 @@ class SendViewController: UIViewController {
//We storing link to make sure that only one alert is displaying on the screen.
private weak var invalidTokenAlert: UIViewController?
let targetAddressTextField = AddressTextField()
lazy var amountTextField = AmountTextField(tokenObject: transferType.tokenObject)
lazy var amountTextField = AmountTextField(tokenObject: transactionType.tokenObject)
weak var delegate: SendViewControllerDelegate?
var transferType: TransferType {
return viewModel.transferType
var transactionType: TransactionType {
return viewModel.transactionType
}
let storage: TokensDataStore
@ -59,7 +59,7 @@ class SendViewController: UIViewController {
session: WalletSession,
storage: TokensDataStore,
account: AlphaWallet.Address,
transferType: TransferType,
transactionType: TransactionType,
cryptoPrice: Subscribable<Double>,
assetDefinitionStore: AssetDefinitionStore
) {
@ -68,7 +68,7 @@ class SendViewController: UIViewController {
self.storage = storage
self.ethPrice = cryptoPrice
self.assetDefinitionStore = assetDefinitionStore
self.viewModel = .init(transferType: transferType, session: session, storage: storage)
self.viewModel = .init(transactionType: transactionType, session: session, storage: storage)
super.init(nibName: nil, bundle: nil)
@ -219,7 +219,7 @@ class SendViewController: UIViewController {
amountTextField.statusLabel.text = viewModel.availableLabelText
amountTextField.availableTextHidden = viewModel.availableTextHidden
switch transferType {
switch transactionType {
case .nativeCryptocurrency(_, let recipient, let amount):
if let recipient = recipient {
targetAddressTextField.value = recipient.stringValue
@ -256,7 +256,7 @@ class SendViewController: UIViewController {
}
private func updateNavigationTitle() {
title = "\(R.string.localizable.send()) \(transferType.symbol)"
title = "\(R.string.localizable.send()) \(transactionType.symbol)"
}
@objc func send() {
@ -264,7 +264,7 @@ class SendViewController: UIViewController {
targetAddressTextField.errorState = .none
amountTextField.errorState = .none
let checkIfGreaterThanZero: Bool
switch transferType {
switch transactionType {
case .nativeCryptocurrency, .dapp, .tokenScript, .claimPaidErc875MagicLink:
checkIfGreaterThanZero = false
case .ERC20Token, .ERC875Token, .ERC875TokenOrder, .ERC721Token, .ERC721ForTicketToken:
@ -279,10 +279,10 @@ class SendViewController: UIViewController {
return
}
let transaction = UnconfirmedTransaction(
transferType: transferType,
transactionType: transactionType,
value: value,
recipient: recipient,
contract: transferType.contractForFungibleSend,
contract: transactionType.contractForFungibleSend,
data: nil
)
delegate?.didPressConfirm(transaction: transaction, in: self, amount: amountTextField.ethCost)
@ -299,17 +299,17 @@ class SendViewController: UIViewController {
private func configureBalanceViewModel() {
currentSubscribableKeyForNativeCryptoCurrencyBalance.flatMap { session.balanceViewModel.unsubscribe($0) }
currentSubscribableKeyForNativeCryptoCurrencyPrice.flatMap { ethPrice.unsubscribe($0) }
switch transferType {
switch transactionType {
case .nativeCryptocurrency(_, let recipient, let amount):
currentSubscribableKeyForNativeCryptoCurrencyBalance = session.balanceViewModel.subscribe { [weak self] viewModel in
guard let celf = self else { return }
guard celf.storage.token(forContract: celf.viewModel.transferType.contract) != nil else { return }
celf.configureFor(contract: celf.viewModel.transferType.contract, recipient: recipient, amount: amount, shouldConfigureBalance: false)
guard celf.storage.token(forContract: celf.viewModel.transactionType.contract) != nil else { return }
celf.configureFor(contract: celf.viewModel.transactionType.contract, recipient: recipient, amount: amount, shouldConfigureBalance: false)
}
session.refresh(.ethBalance)
case .ERC20Token(let token, let recipient, let amount):
let amount = amount.flatMap { EtherNumberFormatter.full.number(from: $0, decimals: token.decimals) }
configureFor(contract: viewModel.transferType.contract, recipient: recipient, amount: amount, shouldConfigureBalance: false)
configureFor(contract: viewModel.transactionType.contract, recipient: recipient, amount: amount, shouldConfigureBalance: false)
case .ERC875Token, .ERC875TokenOrder, .ERC721Token, .ERC721ForTicketToken, .dapp, .tokenScript, .claimPaidErc875MagicLink:
break
}
@ -319,9 +319,9 @@ class SendViewController: UIViewController {
guard let result = QRCodeValueParser.from(string: result) else { return }
switch result {
case .address(let recipient):
guard let tokenObject = storage.token(forContract: viewModel.transferType.contract) else { return }
guard let tokenObject = storage.token(forContract: viewModel.transactionType.contract) else { return }
let amountAsIntWithDecimals = EtherNumberFormatter.full.number(from: amountTextField.ethCost, decimals: tokenObject.decimals)
configureFor(contract: transferType.contract, recipient: .address(recipient), amount: amountAsIntWithDecimals)
configureFor(contract: transactionType.contract, recipient: .address(recipient), amount: amountAsIntWithDecimals)
activateAmountView()
case .eip681(let protocolName, let address, let functionName, let params):
checkAndFillEIP681Details(protocolName: protocolName, address: address, functionName: functionName, params: params)
@ -396,21 +396,21 @@ class SendViewController: UIViewController {
private func configureFor(contract: AlphaWallet.Address, recipient: AddressOrEnsName?, amount: BigInt?, shouldConfigureBalance: Bool = true) {
guard let tokenObject = storage.token(forContract: contract) else { return }
let amount = amount.flatMap { EtherNumberFormatter.full.string(from: $0, decimals: tokenObject.decimals) }
let transferType: TransferType
let transactionType: TransactionType
if let amount = amount, amount != "0" {
transferType = TransferType(token: tokenObject, recipient: recipient, amount: amount)
transactionType = TransactionType(token: tokenObject, recipient: recipient, amount: amount)
} else {
switch viewModel.transferType {
switch viewModel.transactionType {
case .nativeCryptocurrency(_, _, let amount):
transferType = TransferType(token: tokenObject, recipient: recipient, amount: amount.flatMap { EtherNumberFormatter().string(from: $0, units: .ether) })
transactionType = TransactionType(token: tokenObject, recipient: recipient, amount: amount.flatMap { EtherNumberFormatter().string(from: $0, units: .ether) })
case .ERC20Token(_, _, let amount):
transferType = TransferType(token: tokenObject, recipient: recipient, amount: amount)
transactionType = TransactionType(token: tokenObject, recipient: recipient, amount: amount)
case .ERC875Token, .ERC875TokenOrder, .ERC721Token, .ERC721ForTicketToken, .dapp, .tokenScript, .claimPaidErc875MagicLink:
transferType = TransferType(token: tokenObject, recipient: recipient, amount: nil)
transactionType = TransactionType(token: tokenObject, recipient: recipient, amount: nil)
}
}
configure(viewModel: .init(transferType: transferType, session: session, storage: storage), shouldConfigureBalance: shouldConfigureBalance)
configure(viewModel: .init(transactionType: transactionType, session: session, storage: storage), shouldConfigureBalance: shouldConfigureBalance)
}
}

@ -186,7 +186,7 @@ class TransactionConfirmationViewController: UIViewController {
strongSelf.generateSubviews()
}
switch sendFungiblesViewModel.transferType {
switch sendFungiblesViewModel.transactionType {
case .nativeCryptocurrency:
sendFungiblesViewModel.session.balanceViewModel.subscribe { [weak self] balanceBaseViewModel in
guard let strongSelf = self else { return }

@ -7,7 +7,7 @@ struct ConfigureTransactionViewModel {
var selectedConfigurationType: TransactionConfigurationType
let server: RPCServer
let ethPrice: Subscribable<Double>
let transferType: TransferType
let transactionType: TransactionType
var configurationToEdit: EditedTransactionConfiguration
var configurationTypes: [TransactionConfigurationType]
var configurations: TransactionConfigurations {
@ -24,7 +24,7 @@ struct ConfigureTransactionViewModel {
self.configurationTypes = ConfigureTransactionViewModel.sortedConfigurationTypes(fromConfigurations: configurations)
self.configurations = configurations
self.currencyRate = currencyRate
transferType = configurator.transaction.transferType
transactionType = configurator.transaction.transactionType
selectedConfigurationType = configurator.selectedConfigurationType
configurationToEdit = EditedTransactionConfiguration(configuration: configurator.configurations.custom)
}
@ -48,7 +48,7 @@ struct ConfigureTransactionViewModel {
}
var isDataInputHidden: Bool {
switch transferType {
switch transactionType {
case .nativeCryptocurrency, .dapp, .tokenScript, .claimPaidErc875MagicLink:
return false
case .ERC20Token, .ERC875Token, .ERC875TokenOrder, .ERC721Token, .ERC721ForTicketToken:

@ -4,17 +4,17 @@ import UIKit
struct SendHeaderViewViewModel {
private let token: TokenObject
private let transferType: TransferType
private let transactionType: TransactionType
let server: RPCServer
var title: String
var ticker: CoinTicker?
var currencyAmount: String?
var isShowingValue: Bool = true
init(server: RPCServer, token: TokenObject, transferType: TransferType) {
init(server: RPCServer, token: TokenObject, transactionType: TransactionType) {
self.server = server
self.token = token
self.transferType = transferType
self.transactionType = transactionType
title = ""
ticker = nil
currencyAmount = nil
@ -54,7 +54,7 @@ struct SendHeaderViewViewModel {
if server.isTestnet {
return nil
} else {
switch transferType {
switch transactionType {
case .nativeCryptocurrency:
if isShowingValue {
return tokenValueAttributedString

@ -8,16 +8,16 @@ struct SendViewModel {
private let session: WalletSession
private let storage: TokensDataStore
let transferType: TransferType
let transactionType: TransactionType
init(transferType: TransferType, session: WalletSession, storage: TokensDataStore) {
self.transferType = transferType
init(transactionType: TransactionType, session: WalletSession, storage: TokensDataStore) {
self.transactionType = transactionType
self.session = session
self.storage = storage
}
var destinationAddress: AlphaWallet.Address {
return transferType.contract
return transactionType.contract
}
var backgroundColor: UIColor {
@ -25,7 +25,7 @@ struct SendViewModel {
}
var token: TokenObject? {
switch transferType {
switch transactionType {
case .nativeCryptocurrency:
return nil
case .ERC20Token(let token, _, _):
@ -63,11 +63,11 @@ struct SendViewModel {
}
var amountTextFieldPair: AmountTextField.Pair {
return AmountTextField.Pair(left: .cryptoCurrency(transferType.tokenObject), right: .usd)
return AmountTextField.Pair(left: .cryptoCurrency(transactionType.tokenObject), right: .usd)
}
var selectCurrencyButtonHidden: Bool {
switch transferType {
switch transactionType {
case .nativeCryptocurrency:
guard let currentTokenInfo = storage.tickers?[destinationAddress], currentTokenInfo.price_usd > 0 else {
return true
@ -79,7 +79,7 @@ struct SendViewModel {
}
var currencyButtonHidden: Bool {
switch transferType {
switch transactionType {
case .nativeCryptocurrency, .ERC20Token:
return false
case .ERC875Token, .ERC875TokenOrder, .ERC721Token, .ERC721ForTicketToken, .dapp, .tokenScript, .claimPaidErc875MagicLink:
@ -88,15 +88,15 @@ struct SendViewModel {
}
var availableLabelText: String? {
switch transferType {
switch transactionType {
case .nativeCryptocurrency:
if let balance = session.balance {
let value = EtherNumberFormatter.plain.string(from: balance.value)
return R.string.localizable.sendAvailable("\(value) \(transferType.symbol)")
return R.string.localizable.sendAvailable("\(value) \(transactionType.symbol)")
}
case .ERC20Token(let token, _, _):
let value = EtherNumberFormatter.plain.string(from: token.valueBigInt, decimals: token.decimals)
return R.string.localizable.sendAvailable("\(value) \(transferType.symbol)")
return R.string.localizable.sendAvailable("\(value) \(transactionType.symbol)")
case .dapp, .ERC721ForTicketToken, .ERC721Token, .ERC875Token, .ERC875TokenOrder, .tokenScript, .claimPaidErc875MagicLink:
break
}
@ -105,7 +105,7 @@ struct SendViewModel {
}
var availableTextHidden: Bool {
switch transferType {
switch transactionType {
case .nativeCryptocurrency:
return session.balance == nil
case .ERC20Token(let token, _, _):
@ -119,7 +119,7 @@ struct SendViewModel {
func validatedAmount(value amountString: String, checkIfGreaterThanZero: Bool = true) -> BigInt? {
let parsedValue: BigInt? = {
switch transferType {
switch transactionType {
case .nativeCryptocurrency, .dapp, .tokenScript, .claimPaidErc875MagicLink:
return EtherNumberFormatter.full.number(from: amountString, units: .ether)
case .ERC20Token(let token, _, _):
@ -139,7 +139,7 @@ struct SendViewModel {
return nil
}
switch transferType {
switch transactionType {
case .nativeCryptocurrency:
if let balance = session.balance, balance.value < value {
return nil

@ -130,7 +130,7 @@ extension TransactionConfirmationViewModel {
var ensName: String? { recipientResolver.ensName }
var addressString: String? { recipientResolver.address?.eip55String }
var openedSections = Set<Int>()
let transferType: TransferType
let transactionType: TransactionType
let session: WalletSession
let recipientResolver: RecipientResolver
let ethPrice: Subscribable<Double>
@ -141,7 +141,7 @@ extension TransactionConfirmationViewModel {
init(configurator: TransactionConfigurator, assetDefinitionStore: AssetDefinitionStore, recipientResolver: RecipientResolver, amount: String, ethPrice: Subscribable<Double>) {
self.configurator = configurator
self.transferType = configurator.transaction.transferType
self.transactionType = configurator.transaction.transactionType
self.session = configurator.session
self.assetDefinitionStore = assetDefinitionStore
self.recipientResolver = recipientResolver
@ -170,7 +170,7 @@ extension TransactionConfirmationViewModel {
}
var formattedAmountValue: String {
switch transferType {
switch transactionType {
case .nativeCryptocurrency(let token, _, _):
let cryptoToDollarSymbol = Constants.Currency.usd
let double = Double(amount) ?? 0
@ -370,7 +370,7 @@ extension TransactionConfirmationViewModel {
}
private let configurator: TransactionConfigurator
private let transferType: TransferType
private let transactionType: TransactionType
private let session: WalletSession
private let tokenInstanceName: String?
@ -390,7 +390,7 @@ extension TransactionConfirmationViewModel {
init(configurator: TransactionConfigurator, recipientResolver: RecipientResolver, ethPrice: Subscribable<Double>, tokenInstanceName: String?) {
self.configurator = configurator
self.transferType = configurator.transaction.transferType
self.transactionType = configurator.transaction.transactionType
self.session = configurator.session
self.recipientResolver = recipientResolver
self.ethPrice = ethPrice

@ -8,7 +8,7 @@ class SendCoordinatorTests: XCTestCase {
func testRootViewController() {
let coordinator = SendCoordinator(
transferType: .nativeCryptocurrency(TokenObject(), destination: .none, amount: nil),
transactionType: .nativeCryptocurrency(TokenObject(), destination: .none, amount: nil),
navigationController: FakeNavigationController(),
session: .make(),
keystore: FakeKeystore(),
@ -27,7 +27,7 @@ class SendCoordinatorTests: XCTestCase {
func testDestination() {
let address: AlphaWallet.Address = .make()
let coordinator = SendCoordinator(
transferType: .nativeCryptocurrency(TokenObject(), destination: .init(address: address), amount: nil),
transactionType: .nativeCryptocurrency(TokenObject(), destination: .init(address: address), amount: nil),
navigationController: FakeNavigationController(),
session: .make(),
keystore: FakeKeystore(),

@ -6,7 +6,7 @@ import BigInt
extension UnconfirmedTransaction {
static func make(
transferType: TransferType = .nativeCryptocurrency(TokenObject(), destination: .none, amount: nil),
transactionType: TransactionType = .nativeCryptocurrency(TokenObject(), destination: .none, amount: nil),
value: BigInt = BigInt(1),
to: AlphaWallet.Address = .make(),
data: Data = Data(),
@ -15,7 +15,7 @@ extension UnconfirmedTransaction {
nonce: BigInt? = BigInt(1)
) -> UnconfirmedTransaction {
return UnconfirmedTransaction(
transferType: transferType,
transactionType: transactionType,
value: value,
recipient: nil,
contract: to,

Loading…
Cancel
Save