Display token instance name for NFT transfer in actionsheet

pull/2305/head
Hwee-Boon Yar 4 years ago
parent d4d45a30eb
commit 3289059f21
  1. 2
      AlphaWallet/Localization/en.lproj/Localizable.strings
  2. 2
      AlphaWallet/Localization/es.lproj/Localizable.strings
  3. 2
      AlphaWallet/Localization/ja.lproj/Localizable.strings
  4. 2
      AlphaWallet/Localization/ko.lproj/Localizable.strings
  5. 2
      AlphaWallet/Localization/zh-Hans.lproj/Localizable.strings
  6. 6
      AlphaWallet/Transfer/Coordinators/TransactionConfirmationCoordinator.swift
  7. 3
      AlphaWallet/Transfer/Coordinators/TransferNFTCoordinator.swift
  8. 23
      AlphaWallet/Transfer/ViewModels/TransactionConfirmationViewModel.swift

@ -500,6 +500,6 @@
"transactionConfirmation.Send.Section.Balance.new.title" = "(New: %@ %@)";
"transactionConfirmation.Send.Section.Amount.title" = "Amount";
"transactionConfirmation.Send.Section.Recipient.title" = "Recipient";
"transactionConfirmation.Send.Section.TokenId.title" = "Token ID";
"transactionConfirmation.Send.Section.TokenId.title" = "Token";
"transactionConfirmation.authorisation.reason" = "Authorize to confirm transaction";
"transactionConfirmation.keystore.accessKey.sign" = "Accessing to perform transfer";

@ -500,6 +500,6 @@
"transactionConfirmation.Send.Section.Balance.new.title" = "(New: %@ %@)";
"transactionConfirmation.Send.Section.Amount.title" = "Amount";
"transactionConfirmation.Send.Section.Recipient.title" = "Recipient";
"transactionConfirmation.Send.Section.TokenId.title" = "Token Id";
"transactionConfirmation.Send.Section.TokenId.title" = "Token";
"transactionConfirmation.authorisation.reason" = "Authorize to confirm transaction";
"transactionConfirmation.keystore.accessKey.sign" = "Accessing to perform transfer";

@ -500,6 +500,6 @@
"transactionConfirmation.Send.Section.Balance.new.title" = "(New: %@ %@)";
"transactionConfirmation.Send.Section.Amount.title" = "Amount";
"transactionConfirmation.Send.Section.Recipient.title" = "Recipient";
"transactionConfirmation.Send.Section.TokenId.title" = "Token ID";
"transactionConfirmation.Send.Section.TokenId.title" = "Token";
"transactionConfirmation.authorisation.reason" = "Authorize to confirm transaction";
"transactionConfirmation.keystore.accessKey.sign" = "Accessing to perform transfer";

@ -500,6 +500,6 @@
"transactionConfirmation.Send.Section.Balance.new.title" = "(New: %@ %@)";
"transactionConfirmation.Send.Section.Amount.title" = "Amount";
"transactionConfirmation.Send.Section.Recipient.title" = "Recipient";
"transactionConfirmation.Send.Section.TokenId.title" = "Token ID";
"transactionConfirmation.Send.Section.TokenId.title" = "Token";
"transactionConfirmation.authorisation.reason" = "Authorize to confirm transaction";
"transactionConfirmation.keystore.accessKey.sign" = "Accessing to perform transfer";

@ -500,6 +500,6 @@
"transactionConfirmation.Send.Section.Balance.new.title" = "(New: %@ %@)";
"transactionConfirmation.Send.Section.Amount.title" = "Amount";
"transactionConfirmation.Send.Section.Recipient.title" = "Recipient";
"transactionConfirmation.Send.Section.TokenId.title" = "Token ID";
"transactionConfirmation.Send.Section.TokenId.title" = "Token";
"transactionConfirmation.authorisation.reason" = "Authorize to confirm transaction";
"transactionConfirmation.keystore.accessKey.sign" = "Accessing to perform transfer";

@ -14,19 +14,19 @@ enum TransactionConfirmationConfiguration {
case tokenScriptTransaction(confirmType: ConfirmType, contract: AlphaWallet.Address, keystore: Keystore, ethPrice: Subscribable<Double>)
case dappTransaction(confirmType: ConfirmType, keystore: Keystore, ethPrice: Subscribable<Double>)
case sendFungiblesTransaction(confirmType: ConfirmType, keystore: Keystore, assetDefinitionStore: AssetDefinitionStore, amount: String, ethPrice: Subscribable<Double>)
case sendNftTransaction(confirmType: ConfirmType, keystore: Keystore, ethPrice: Subscribable<Double>)
case sendNftTransaction(confirmType: ConfirmType, keystore: Keystore, ethPrice: Subscribable<Double>, tokenInstanceName: String?)
case claimPaidErc875MagicLink(confirmType: ConfirmType, keystore: Keystore, price: BigUInt, ethPrice: Subscribable<Double>, numberOfTokens: UInt)
var confirmType: ConfirmType {
switch self {
case .dappTransaction(let confirmType, _, _), .sendFungiblesTransaction(let confirmType, _, _, _, _), .sendNftTransaction(let confirmType, _, _), .tokenScriptTransaction(let confirmType, _, _, _), .claimPaidErc875MagicLink(let confirmType, _, _, _, _):
case .dappTransaction(let confirmType, _, _), .sendFungiblesTransaction(let confirmType, _, _, _, _), .sendNftTransaction(let confirmType, _, _, _), .tokenScriptTransaction(let confirmType, _, _, _), .claimPaidErc875MagicLink(let confirmType, _, _, _, _):
return confirmType
}
}
var keystore: Keystore {
switch self {
case .dappTransaction(_, let keystore, _), .sendFungiblesTransaction(_, let keystore, _, _, _), .sendNftTransaction(_, let keystore, _), .tokenScriptTransaction(_, _, let keystore, _), .claimPaidErc875MagicLink(_, let keystore, _, _, _), .claimPaidErc875MagicLink(_, let keystore, _, _, _):
case .dappTransaction(_, let keystore, _), .sendFungiblesTransaction(_, let keystore, _, _, _), .sendNftTransaction(_, let keystore, _, _), .tokenScriptTransaction(_, _, let keystore, _), .claimPaidErc875MagicLink(_, let keystore, _, _, _), .claimPaidErc875MagicLink(_, let keystore, _, _, _):
return keystore
}
}

@ -42,7 +42,8 @@ class TransferNFTCoordinator: Coordinator {
tokenId: tokenHolder.tokens[0].id,
indices: tokenHolder.indices
)
let configuration: TransactionConfirmationConfiguration = .sendNftTransaction(confirmType: .signThenSend, keystore: keystore, ethPrice: ethPrice)
let tokenInstanceName = tokenHolder.values["name"]?.stringValue
let configuration: TransactionConfirmationConfiguration = .sendNftTransaction(confirmType: .signThenSend, keystore: keystore, ethPrice: ethPrice, tokenInstanceName: tokenInstanceName)
let coordinator = TransactionConfirmationCoordinator(navigationController: navigationController, session: session, transaction: transaction, configuration: configuration, analyticsCoordinator: analyticsCoordinator)
addCoordinator(coordinator)
coordinator.delegate = self

@ -19,9 +19,9 @@ enum TransactionConfirmationViewModel {
case .sendFungiblesTransaction(_, _, let assetDefinitionStore, let amount, let ethPrice):
let resolver = RecipientResolver(address: configurator.transaction.recipient)
self = .sendFungiblesTransaction(.init(configurator: configurator, assetDefinitionStore: assetDefinitionStore, recipientResolver: resolver, amount: amount, ethPrice: ethPrice))
case .sendNftTransaction(_, _, let ethPrice):
case .sendNftTransaction(_, _, let ethPrice, let tokenInstanceName):
let resolver = RecipientResolver(address: configurator.transaction.recipient)
self = .sendNftTransaction(.init(configurator: configurator, recipientResolver: resolver, ethPrice: ethPrice))
self = .sendNftTransaction(.init(configurator: configurator, recipientResolver: resolver, ethPrice: ethPrice, tokenInstanceName: tokenInstanceName))
case .claimPaidErc875MagicLink(_, _, let price, let ethPrice, let numberOfTokens):
self = .claimPaidErc875MagicLink(.init(configurator: configurator, price: price, ethPrice: ethPrice, numberOfTokens: numberOfTokens))
}
@ -355,6 +355,7 @@ extension TransactionConfirmationViewModel {
private let configurator: TransactionConfigurator
private let transferType: TransferType
private let session: WalletSession
private let tokenInstanceName: String?
private var configurationTitle: String {
configurator.selectedConfigurationType.title
@ -370,12 +371,13 @@ extension TransactionConfirmationViewModel {
return Section.allCases
}
init(configurator: TransactionConfigurator, recipientResolver: RecipientResolver, ethPrice: Subscribable<Double>) {
init(configurator: TransactionConfigurator, recipientResolver: RecipientResolver, ethPrice: Subscribable<Double>, tokenInstanceName: String?) {
self.configurator = configurator
self.transferType = configurator.transaction.transferType
self.session = configurator.session
self.recipientResolver = recipientResolver
self.ethPrice = ethPrice
self.tokenInstanceName = tokenInstanceName
}
func isSubviewsHidden(section: Int, row: Int) -> Bool {
@ -410,9 +412,18 @@ extension TransactionConfirmationViewModel {
let gasFee = gasFeeString(withConfigurator: configurator, cryptoToDollarRate: cryptoToDollarRate)
return .init(title: configurationTitle, placeholder: placeholder, details: gasFee, configuration: configuration)
case .tokenId:
//TODO be good to display the token instance's name or equivalent too
let tokenId = configurator.transaction.tokenId.flatMap({ String($0) }) ?? ""
return .init(title: tokenId, placeholder: placeholder, configuration: configuration)
let tokenId = configurator.transaction.tokenId.flatMap({ String($0) })
let title: String
if let tokenInstanceName = tokenInstanceName, !tokenInstanceName.isEmpty {
if let tokenId = tokenId {
title = "\(tokenInstanceName) (\(tokenId))"
} else {
title = tokenInstanceName
}
} else {
title = tokenId ?? ""
}
return .init(title: title, placeholder: placeholder, configuration: configuration)
case .recipient:
return .init(title: recipientResolver.value, placeholder: placeholder, configuration: configuration)
}

Loading…
Cancel
Save