Skip to content

Commit

Permalink
Merge pull request #667 from nova-wallet/develop
Browse files Browse the repository at this point in the history
v6.2.1
  • Loading branch information
ERussel committed May 19, 2023
2 parents d090f9d + a3982fe commit 96b3dd6
Show file tree
Hide file tree
Showing 14 changed files with 80 additions and 54 deletions.
4 changes: 2 additions & 2 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ abstract_target 'novawalletAll' do
pod 'Kingfisher', :inhibit_warnings => true
pod 'SVGKit', :git => 'https://github.com/SVGKit/SVGKit.git', :tag => '3.0.0'
pod 'SwiftRLP', :git => 'https://github.com/ERussel/SwiftRLP.git'
pod 'Starscream', :git => 'https://github.com/ERussel/Starscream.git', :tag => '4.0.5'
pod 'Starscream', :git => 'https://github.com/ERussel/Starscream.git', :tag => '4.0.8'
pod 'CDMarkdownKit', :git => 'https://github.com/nova-wallet/CDMarkdownKit.git', :tag => '2.5.2'
pod 'web3swift', :git => 'https://github.com/web3swift-team/web3swift.git', :tag => '3.0.6'
pod 'WalletConnectSwiftV2', :git => 'https://github.com/WalletConnect/WalletConnectSwiftV2.git', :tag => '1.5.14'
Expand All @@ -38,7 +38,7 @@ abstract_target 'novawalletAll' do
pod 'RobinHood', '~> 2.6.0'
pod 'CommonWallet/Core', :git => 'https://github.com/ERussel/Capital-iOS.git', :tag => '1.16.0'
pod 'Sourcery', '~> 1.4'
pod 'Starscream', :git => 'https://github.com/ERussel/Starscream.git', :tag => '4.0.5'
pod 'Starscream', :git => 'https://github.com/ERussel/Starscream.git', :tag => '4.0.8'

end

Expand Down
12 changes: 6 additions & 6 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ PODS:
- SoraUI/Controls
- SoraUI/Skrull (1.11.1)
- Sourcery (1.4.1)
- Starscream (4.0.5)
- Starscream (4.0.8)
- SubstrateSdk (1.13.0):
- BigInt (~> 5.0)
- IrohaCrypto/ed25519 (~> 0.9.0)
Expand Down Expand Up @@ -165,7 +165,7 @@ DEPENDENCIES:
- SoraKeystore (~> 1.0.0)
- SoraUI (from `https://github.com/ERussel/UIkit-iOS.git`, tag `1.11.1`)
- Sourcery (~> 1.4)
- Starscream (from `https://github.com/ERussel/Starscream.git`, tag `4.0.5`)
- Starscream (from `https://github.com/ERussel/Starscream.git`, tag `4.0.8`)
- SubstrateSdk (from `https://github.com/nova-wallet/substrate-sdk-ios.git`, tag `1.13.0`)
- SVGKit (from `https://github.com/SVGKit/SVGKit.git`, tag `3.0.0`)
- SwiftFormat/CLI (~> 0.47.13)
Expand Down Expand Up @@ -217,7 +217,7 @@ EXTERNAL SOURCES:
:tag: 1.11.1
Starscream:
:git: https://github.com/ERussel/Starscream.git
:tag: 4.0.5
:tag: 4.0.8
SubstrateSdk:
:git: https://github.com/nova-wallet/substrate-sdk-ios.git
:tag: 1.13.0
Expand Down Expand Up @@ -248,7 +248,7 @@ CHECKOUT OPTIONS:
:tag: 1.11.1
Starscream:
:git: https://github.com/ERussel/Starscream.git
:tag: 4.0.5
:tag: 4.0.8
SubstrateSdk:
:git: https://github.com/nova-wallet/substrate-sdk-ios.git
:tag: 1.13.0
Expand Down Expand Up @@ -288,7 +288,7 @@ SPEC CHECKSUMS:
SoraKeystore: 92cff6e2a12f212dd64ed089970ff7c365247b1c
SoraUI: e5ceb2cffe40145e589aa464e2e0a8d054011e0b
Sourcery: db66600e8b285c427701821598d07cf3c7e6c476
Starscream: 8cc648110705c09a15f0de84352c7f9595b7cb05
Starscream: b676ee89781677a2d8d36029a78c970710e2d3eb
SubstrateSdk: aad6725e00295219ee9722b1975175ef4db3f4a6
SVGKit: 132b010efbf57ec345309fe4a7f627c0a40c5d63
SwiftFormat: 73573b89257437c550b03d934889725fbf8f75e5
Expand All @@ -301,6 +301,6 @@ SPEC CHECKSUMS:
web3swift: 944e76579b953a7b7e81dbb351c6dc0ed1defe63
xxHash-Swift: 30bd6a7507b3b7348a277c49b1cb6346c2905ec7

PODFILE CHECKSUM: 17dc836b964fd661520c3c70f3d2c1d46620dd66
PODFILE CHECKSUM: 7401829850c56fe153f46655dbfad25e61b9927c

COCOAPODS: 1.11.3
3 changes: 2 additions & 1 deletion novawallet/Common/Configs/ApplicationConfigs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ extension ApplicationConfig: ApplicationConfigProtocol {
}

var paritySignerTroubleshoutingURL: URL {
URL(string: "https://github.com/nova-wallet/nova-utils/wiki/Parity-Signer-troubleshooting")!
// swiftlint:disable:next line_length
URL(string: "https://docs.novawallet.io/nova-wallet-wiki/welcome-to-nova-wallet/hardware-wallets#parity-signer-troubleshooting")!
}

var ledgerGuideURL: URL {
Expand Down
5 changes: 5 additions & 0 deletions novawallet/Common/Extension/UIKit/Style/UILabel+Style.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,9 @@ extension UILabel.Style {
textColor: R.color.colorTextPrimary()!,
font: .semiBoldTitle3
)

static let sourceCodePrimary = UILabel.Style(
textColor: R.color.colorTextPrimary()!,
font: .regularFootnote
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ private struct DefaultSocketFactory: WebSocketFactory {
urlRequest.addValue("allowed.domain.com", forHTTPHeaderField: "Origin")

let engine = WSEngine(
transport: TCPTransport(),
transport: FoundationTransport(),
certPinner: FoundationSecurity(),
compressionHandler: nil
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ final class DAppMetamaskAuthorizedState: DAppMetamaskBaseState {
provideResponse(for: messageId, results: addresses, nextState: self)
}

private func sendTransaction(from message: MetamaskMessage) {
private func sendTransaction(from message: MetamaskMessage, host: String) {
guard let transactionInfo = message.object else {
let error = MetamaskError.invalidParams(with: "transaction missing")
provideError(for: message.identifier, error: error, nextState: self)
Expand All @@ -28,10 +28,15 @@ final class DAppMetamaskAuthorizedState: DAppMetamaskBaseState {
requestId: requestId
)

stateMachine?.emit(messageId: requestId, signingOperation: transactionInfo, nextState: nextState)
stateMachine?.emit(
messageId: requestId,
signingOperation: transactionInfo,
host: host,
nextState: nextState
)
}

private func signPersonalMessage(from message: MetamaskMessage) {
private func signPersonalMessage(from message: MetamaskMessage, host: String) {
guard
let hexString = message.object?.data?.stringValue,
let signingHashedData = try? Data(
Expand All @@ -43,10 +48,10 @@ final class DAppMetamaskAuthorizedState: DAppMetamaskBaseState {
return
}

emitSigningBytesOperation(for: message, hashedData: signingHashedData)
emitSigningBytesOperation(for: message, host: host, hashedData: signingHashedData)
}

private func signTypedData(from message: MetamaskMessage) {
private func signTypedData(from message: MetamaskMessage, host: String) {
guard
let hexString = message.object?.data?.stringValue,
let signingHashedData = try? Data(hexString: hexString) else {
Expand All @@ -56,10 +61,10 @@ final class DAppMetamaskAuthorizedState: DAppMetamaskBaseState {
return
}

emitSigningBytesOperation(for: message, hashedData: signingHashedData)
emitSigningBytesOperation(for: message, host: host, hashedData: signingHashedData)
}

private func emitSigningBytesOperation(for message: MetamaskMessage, hashedData: Data) {
private func emitSigningBytesOperation(for message: MetamaskMessage, host: String, hashedData: Data) {
let requestId = message.identifier
let nextState = DAppMetamaskSigningState(
stateMachine: stateMachine,
Expand All @@ -69,7 +74,12 @@ final class DAppMetamaskAuthorizedState: DAppMetamaskBaseState {

let signingJson = JSON.stringValue(hashedData.toHex(includePrefix: true))

stateMachine?.emit(messageId: requestId, signingOperation: signingJson, nextState: nextState)
stateMachine?.emit(
messageId: requestId,
signingOperation: signingJson,
host: host,
nextState: nextState
)
}
}

Expand All @@ -86,7 +96,7 @@ extension DAppMetamaskAuthorizedState: DAppMetamaskStateProtocol {
dataSource.fetchEthereumAddresses(for: chain.chainId).first?.toEthereumAddressWithChecksum()
}

func handle(message: MetamaskMessage, host _: String, dataSource: DAppBrowserStateDataSource) {
func handle(message: MetamaskMessage, host: String, dataSource: DAppBrowserStateDataSource) {
do {
switch message.name {
case .requestAccounts:
Expand All @@ -112,11 +122,11 @@ extension DAppMetamaskAuthorizedState: DAppMetamaskStateProtocol {
}
)
case .signTransaction:
sendTransaction(from: message)
sendTransaction(from: message, host: host)
case .signPersonalMessage:
signPersonalMessage(from: message)
signPersonalMessage(from: message, host: host)
case .signTypedMessage:
signTypedData(from: message)
signTypedData(from: message, host: host)
}
} catch {
stateMachine?.emit(error: error, nextState: self)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ class DAppMetamaskBaseState {
self.chain = chain
}

func extendingMetamaskChainWithSubstrate(_ chain: MetamaskChain, dataSource: DAppBrowserStateDataSource) -> MetamaskChain {
func extendingMetamaskChainWithSubstrate(
_ chain: MetamaskChain,
dataSource: DAppBrowserStateDataSource
) -> MetamaskChain {
if let substrateChain = dataSource.fetchChainByEthereumChainId(chain.chainId) {
return chain.appending(iconUrl: substrateChain.icon.absoluteString)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ protocol DAppMetamaskStateMachineProtocol: AnyObject {
func emit(
messageId: MetamaskMessage.Id,
signingOperation: JSON,
host: String,
nextState: DAppMetamaskStateProtocol
)
func emitReload(with postExecutionScript: DAppScriptResponse, nextState: DAppMetamaskStateProtocol)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ final class DAppMetamaskTransport {

private func createConfirmationRequest(
messageId: MetamaskMessage.Id,
from signingOperation: JSON
host: String,
signingOperation: JSON
) -> DAppOperationRequest? {
guard let dataSource = dataSource,
let accountId = try? state?.fetchSelectedAddress(from: dataSource)?.toAccountId() else {
Expand All @@ -29,7 +30,7 @@ final class DAppMetamaskTransport {
identifier: "\(messageId)",
wallet: dataSource.wallet,
accountId: accountId,
dApp: dataSource.dApp?.url.absoluteString ?? "",
dApp: host,
dAppIcon: dataSource.dApp?.icon,
operationData: signingOperation
)
Expand Down Expand Up @@ -74,6 +75,7 @@ extension DAppMetamaskTransport: DAppMetamaskStateMachineProtocol {
func emit(
messageId: MetamaskMessage.Id,
signingOperation: JSON,
host: String,
nextState: DAppMetamaskStateProtocol
) {
guard let dataSource = dataSource else {
Expand All @@ -82,7 +84,12 @@ extension DAppMetamaskTransport: DAppMetamaskStateMachineProtocol {

state = nextState

if let request = createConfirmationRequest(messageId: messageId, from: signingOperation) {
if
let request = createConfirmationRequest(
messageId: messageId,
host: host,
signingOperation: signingOperation
) {
if
let chain = DAppEitherChain.createFromMetamask(
chain: nextState.chain,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ final class DAppTxDetailsViewController: UIViewController, ViewHolder {
private func setupLocalization() {
let languages = selectedLocale.rLanguages

title = R.string.localizable.commonConfirmTitle(preferredLanguages: languages)
rootView.titleLabel.text = R.string.localizable.commonTxDetails(preferredLanguages: languages)
title = R.string.localizable.commonTxDetails(preferredLanguages: languages)
rootView.titleLabel.text = R.string.localizable.dappSignOperationDetailsSubtitle(
preferredLanguages: languages
)
}
}

Expand Down
46 changes: 20 additions & 26 deletions novawallet/Modules/DApp/DAppTxDetails/DAppTxDetailsViewLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,24 @@ final class DAppTxDetailsViewLayout: UIView {
return view
}()

let backgroundView: RoundedView = {
let view = RoundedView()
let backgroundView: RoundedView = .create { view in
view.applyFilledBackgroundStyle()
view.fillColor = R.color.colorContainerBackground()!
view.highlightedFillColor = R.color.colorContainerBackground()!
view.strokeColor = R.color.colorContainerBorder()!
view.highlightedStrokeColor = R.color.colorContainerBorder()!
view.strokeWidth = 0.5
view.cornerRadius = 12.0
return view
}()
}

let titleLabel: UILabel = {
let label = UILabel()
label.textColor = R.color.colorTextSecondary()
label.font = .caption1
return label
}()
let titleLabel: UILabel = .create { label in
label.apply(style: .caption1Secondary)
}

let detailsLabel: UILabel = {
let label = UILabel()
label.textColor = R.color.colorTextPrimary()
label.font = .regularFootnote
let detailsLabel: UILabel = .create { label in
label.apply(style: .sourceCodePrimary)
label.numberOfLines = 0
return label
}()
}

override init(frame: CGRect) {
super.init(frame: frame)
Expand All @@ -53,25 +48,24 @@ final class DAppTxDetailsViewLayout: UIView {
make.leading.trailing.bottom.equalToSuperview()
}

scrollView.addSubview(backgroundView)
backgroundView.snp.makeConstraints { make in
scrollView.addSubview(titleLabel)
titleLabel.snp.makeConstraints { make in
make.top.equalToSuperview().inset(16.0)
make.leading.trailing.equalToSuperview().inset(16.0)
make.width.equalTo(self).offset(-32.0)
make.bottom.equalToSuperview().inset(16.0)
}

backgroundView.addSubview(titleLabel)
titleLabel.snp.makeConstraints { make in
make.top.equalToSuperview().inset(8.0)
scrollView.addSubview(backgroundView)
backgroundView.snp.makeConstraints { make in
make.top.equalTo(titleLabel.snp.bottom).offset(16.0)
make.leading.trailing.equalToSuperview().inset(16.0)
make.width.equalTo(self).offset(-32.0)
make.bottom.equalToSuperview().inset(16.0)
}

backgroundView.addSubview(detailsLabel)
detailsLabel.snp.makeConstraints { make in
make.top.equalTo(titleLabel.snp.bottom).offset(0.0)
make.leading.trailing.equalToSuperview().inset(16.0)
make.bottom.equalToSuperview().inset(8.0)
make.top.bottom.equalToSuperview().inset(8)
make.leading.trailing.equalToSuperview().inset(12.0)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ final class WalletConnectSessionCell: PlainBaseTableViewCell<WalletConnectSessio
contentDisplayView.titleView.stackView.alignment = .center

titleLabel.apply(style: .regularSubhedlinePrimary)
titleLabel.textAlignment = .left

contentDisplayView.titleView.sView.spacing = 2.0

Expand Down
1 change: 1 addition & 0 deletions novawallet/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,7 @@
"dapp.auth.title" = "Allow “%@” to access your account addresses?";
"common.account.address" = "Account address";
"dapp.sign.extrinsic.failed" = "Failed to sign requested operation";
"dapp.sign.operation.details.subtitle" = "Make sure the operation is correct";
"common.all" = "All";
"dapp.list.search" = "Search by name or enter URL";
"dapp.browser.close.confirmation" = "Are you sure you want to close this screen?\nYour changes will not be applied.";
Expand Down
1 change: 1 addition & 0 deletions novawallet/ru.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,7 @@
"dapp.auth.title" = "Разрешить “%@” доступ к адресам вашего кошелька?";
"common.account.address" = "Адрес аккаунта";
"dapp.sign.extrinsic.failed" = "Не удалось подписать запрошенную операцию";
"dapp.sign.operation.details.subtitle" = "Убедитесь, что операция правильная";
"common.all" = "Все";
"dapp.list.search" = "Введите имя или URL";
"dapp.browser.close.confirmation" = "Вы уверены, что хотите закрыть этот экран?\nВсе изменения не будут применены.";
Expand Down

0 comments on commit 96b3dd6

Please sign in to comment.