Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ABW-3821] Pre Authorization general UI #1371

Merged
merged 67 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
2fcd3fb
WIP
matiasbzurovski Oct 16, 2024
ab48dba
wip
matiasbzurovski Oct 16, 2024
4811e0c
WIP
matiasbzurovski Oct 17, 2024
24e8819
WIP
matiasbzurovski Oct 17, 2024
b30f519
merge main
matiasbzurovski Oct 17, 2024
3778a7f
WIP
matiasbzurovski Oct 21, 2024
957b8a3
WIP
matiasbzurovski Oct 21, 2024
bf90c75
WIP
matiasbzurovski Oct 21, 2024
6cdea3c
WIP
matiasbzurovski Oct 21, 2024
4dd4d35
move more stuff to common
matiasbzurovski Oct 21, 2024
69af0a6
WIP
matiasbzurovski Oct 21, 2024
c001881
Accounts and Proofs are now using ObservableState
matiasbzurovski Oct 21, 2024
a7711f8
add sections and clean a bit the UI
matiasbzurovski Oct 21, 2024
c1ef09d
move more models under common
matiasbzurovski Oct 21, 2024
78924ad
rename to InteractionReview
matiasbzurovski Oct 21, 2024
a24e6ae
move ValidatorsView
matiasbzurovski Oct 21, 2024
c49662f
move ExpandableHeadingView and UnknownDappsComponents
matiasbzurovski Oct 21, 2024
58af003
move the last one
matiasbzurovski Oct 21, 2024
68fec2b
show on Home
matiasbzurovski Oct 21, 2024
4287c70
InteractionReviewDapps use ObservableState
matiasbzurovski Oct 22, 2024
349c7dc
wip middle sections
matiasbzurovski Oct 22, 2024
f406c97
more changes
matiasbzurovski Oct 22, 2024
1656031
move deposit and settings to sections
matiasbzurovski Oct 22, 2024
76b65f4
implement for validators in Section as well
matiasbzurovski Oct 22, 2024
650637e
clean up TransactionReview
matiasbzurovski Oct 22, 2024
c67c60f
FungibleTokenDetails use ObservableState
matiasbzurovski Oct 22, 2024
6b89519
Non Fungible Details as well
matiasbzurovski Oct 22, 2024
955c46f
more changes
matiasbzurovski Oct 22, 2024
5e5af4a
migrate PreAuthorizationReview & Sections to old way
matiasbzurovski Oct 23, 2024
7fe96f2
fix for HideResourceView warning
matiasbzurovski Oct 23, 2024
5a50a88
show Proofs inside Sections when neccessary
matiasbzurovski Oct 23, 2024
8de0e95
load dynamic summary
matiasbzurovski Oct 23, 2024
9082805
move tests from Home to DappInteractionFlow
matiasbzurovski Oct 23, 2024
e93cad5
use real dApp Metadata
matiasbzurovski Oct 23, 2024
c26ebef
set up for TransactionSummary
matiasbzurovski Oct 23, 2024
6ce9605
hide raw button until reviewed preAuth available
matiasbzurovski Oct 25, 2024
4ef9e88
fix HeadingView to always have the same frame
matiasbzurovski Oct 25, 2024
38f4fd1
possible dApp calls
matiasbzurovski Oct 25, 2024
617c6eb
add InfoLink support
matiasbzurovski Oct 25, 2024
2af392c
set lineSpacing of feesInfo
matiasbzurovski Oct 25, 2024
ad311d9
Merge branch 'main' into ABW-3821-pre-auth-ui
matiasbzurovski Oct 28, 2024
f594f53
handle preAuhtorization request
matiasbzurovski Oct 25, 2024
4ab916d
temporary fix until Strings merged
matiasbzurovski Oct 28, 2024
0901430
local Sargon
matiasbzurovski Oct 28, 2024
8c8e5ec
use real models
matiasbzurovski Oct 28, 2024
aa3cdd5
handle failure
matiasbzurovski Oct 28, 2024
0cb5347
move raw alert to parent views
matiasbzurovski Oct 29, 2024
3b2f76e
add button to create sample PreAuthorization from Account Dev Prefere…
matiasbzurovski Oct 29, 2024
7852725
delete ReviewRawTransactionView
matiasbzurovski Oct 29, 2024
d65e57d
update to RawManifest view
matiasbzurovski Oct 29, 2024
dbba2c7
Merge branch 'main' into ABW-3821-pre-auth-ui
matiasbzurovski Oct 30, 2024
d692742
Merge branch 'main' into ABW-3821-pre-auth-ui
matiasbzurovski Oct 30, 2024
6ccdbdf
update with latest Sargon version
matiasbzurovski Oct 30, 2024
c785117
localise new views
matiasbzurovski Oct 30, 2024
7ccad4b
use new Localization strings on common views
matiasbzurovski Oct 30, 2024
b671c5f
show possible dApp calls only for open manifests
matiasbzurovski Oct 30, 2024
0a57abe
remove ReviewPreAuthorization and PreAuthorizationToReview, and inste…
matiasbzurovski Oct 30, 2024
5776e0b
fix info link
matiasbzurovski Nov 4, 2024
29b100b
test directly with dApp
matiasbzurovski Nov 4, 2024
9cdf6db
updates
matiasbzurovski Nov 4, 2024
0be24a3
VisibleHeaderView
matiasbzurovski Nov 4, 2024
7b4deac
Revert "VisibleHeaderView"
matiasbzurovski Nov 4, 2024
ee7d68c
updates
matiasbzurovski Nov 5, 2024
eb3b78a
rename DappInteractionModels
matiasbzurovski Nov 5, 2024
85b7b55
add TimeFormatter tests
matiasbzurovski Nov 5, 2024
dd60106
formatter
matiasbzurovski Nov 5, 2024
bfec7d1
updates to time formatter
matiasbzurovski Nov 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
340 changes: 254 additions & 86 deletions RadixWallet.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "7d3590b225945abb1bc0ab6c684b005c28c64bdc204afcc2d34c3e379ef8a3c8",
"originHash" : "7f25d08c2d5bfce10ead9a90a371e548d360b6e5e8779b8ad654bfac475f1dc8",
"pins" : [
{
"identity" : "anycodable",
Expand Down Expand Up @@ -112,10 +112,10 @@
{
"identity" : "sargon",
"kind" : "remoteSourceControl",
"location" : "https://github.com/radixdlt/sargon",
"location" : "https://github.com/radixdlt/sargon/",
"state" : {
"revision" : "37a51f2c19e65746e618424499c5e37637648a73",
"version" : "1.1.38"
"revision" : "83e13eb11037733a9edfe2c2c70d1efeb63e0831",
"version" : "1.1.42"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ extension OnLedgerEntitiesClient {
resourceQuantifier: FungibleResourceIndicator,
poolContributions: [some TrackedPoolInteraction] = [] as [TrackedPoolContribution],
validatorStakes: [TrackedValidatorStake] = [],
entities: TransactionReview.ResourcesInfo = [:],
resourceAssociatedDapps: TransactionReview.ResourceAssociatedDapps? = nil,
entities: InteractionReview.Sections.ResourcesInfo = [:],
resourceAssociatedDapps: InteractionReview.Sections.ResourceAssociatedDapps? = nil,
networkID: NetworkID,
defaultDepositGuarantee: Decimal192 = 1
) async throws -> ResourceBalance {
Expand Down Expand Up @@ -81,8 +81,8 @@ extension OnLedgerEntitiesClient {
_ resource: OnLedgerEntity.Resource,
amount: Decimal192,
poolContributions: [some TrackedPoolInteraction] = [],
entities: TransactionReview.ResourcesInfo = [:],
resourceAssociatedDapps: TransactionReview.ResourceAssociatedDapps? = nil,
entities: InteractionReview.Sections.ResourcesInfo = [:],
resourceAssociatedDapps: InteractionReview.Sections.ResourceAssociatedDapps? = nil,
networkID: NetworkID,
guarantee: TransactionGuarantee?,
hiddenResources: [ResourceIdentifier]
Expand Down Expand Up @@ -189,7 +189,7 @@ extension OnLedgerEntitiesClient {
// MARK: Non-fungibles

func nonFungibleResourceBalances(
_ resourceInfo: TransactionReview.ResourceInfo,
_ resourceInfo: InteractionReview.Sections.ResourceInfo,
resourceAddress: ResourceAddress,
resourceQuantifier: NonFungibleResourceIndicator,
unstakeData: [NonFungibleGlobalId: UnstakeData] = [:],
Expand Down Expand Up @@ -321,7 +321,7 @@ extension OnLedgerEntitiesClient {
}
}

extension TransactionReview.ResourceInfo {
extension InteractionReview.Sections.ResourceInfo {
var metadata: OnLedgerEntity.Metadata {
switch self {
case let .left(resource):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import Foundation

// MARK: - PreAuthorizationFailure
enum PreAuthorizationFailure: Sendable, LocalizedError, Equatable {
case failedToGetPreview(FailedToGetPreview)

var errorDescription: String? {
switch self {
case let .failedToGetPreview(error):
error.localizedDescription
}
}
}

extension PreAuthorizationFailure {
var errorKindAndMessage: (errorKind: DappWalletInteractionErrorType, message: String?) {
switch self {
case .failedToGetPreview:
(errorKind: .failedToPrepareTransaction, message: errorDescription)
}
}
}

// MARK: PreAuthorizationFailure.FailedToGetPreview
extension PreAuthorizationFailure {
enum FailedToGetPreview: Sendable, LocalizedError, Equatable {
case failedToAnalyse(Error)

var errorDescription: String? {
switch self {
case let .failedToAnalyse(error):
"Failed to analyse PreAuthorization Preview: \(error.localizedDescription)"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Foundation

struct PreAuthorizationPreview: Sendable, Hashable {
let kind: PreAuthToReview
let networkID: NetworkID

var manifest: SubintentManifest {
switch kind {
case let .open(open):
open.manifest
case let .enclosed(enclosed):
enclosed.manifest
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// MARK: - PreAuthorizationClient
struct PreAuthorizationClient: Sendable {
var getPreview: GetPreview
}

// MARK: PreAuthorizationClient.GetPreview
extension PreAuthorizationClient {
typealias GetPreview = @Sendable (GetPreviewRequest) async throws -> PreAuthorizationPreview
}

// MARK: PreAuthorizationClient.GetPreviewRequest
extension PreAuthorizationClient {
struct GetPreviewRequest: Hashable, Sendable {
let unvalidatedManifest: UnvalidatedSubintentManifest
let nonce: Nonce
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
extension PreAuthorizationClient: DependencyKey {
static var liveValue: Self {
@Dependency(\.gatewaysClient) var gatewaysClient

@Sendable
func analysePreview(request: GetPreviewRequest) async throws -> PreAuthToReview {
do {
return try await SargonOS.shared.analysePreAuthPreview(
instructions: request.unvalidatedManifest.subintentManifestString,
blobs: request.unvalidatedManifest.blobs,
nonce: request.nonce
)
} catch {
throw PreAuthorizationFailure.failedToGetPreview(.failedToAnalyse(error))
}
}

let getPreview: GetPreview = { request in
let kind = try await analysePreview(request: request)
let networkID = await gatewaysClient.getCurrentNetworkID()

return PreAuthorizationPreview(
kind: kind,
networkID: networkID
)
}

return Self(
getPreview: getPreview
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
extension DependencyValues {
var preAuthorizationClient: PreAuthorizationClient {
get { self[PreAuthorizationClient.self] }
set { self[PreAuthorizationClient.self] = newValue }
}
}

// MARK: - PreAuthorizationClient + TestDependencyKey
extension PreAuthorizationClient: TestDependencyKey {
static let previewValue = Self.noop

static let noop = Self(
getPreview: { _ in throw NoopError() }
)

static let testValue = Self(
getPreview: unimplemented("\(Self.self).getPreview")
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -515,8 +515,8 @@ private func key(factorSourceID: FactorSourceIDFromHash) -> KeychainClient.Key {

extension OverlayWindowClient.Item.AlertState {
fileprivate static let missingMnemonicAlert = Self(
title: { TextState(L10n.TransactionReview.NoMnemonicError.title) },
message: { TextState(L10n.TransactionReview.NoMnemonicError.text) }
title: { TextState(L10n.Common.NoMnemonicAlert.title) },
message: { TextState(L10n.Common.NoMnemonicAlert.text) }
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ extension TransactionClient {
return try await SargonOS.shared.analyseTransactionPreview(
instructions: request.unvalidatedManifest.transactionManifestString,
blobs: request.unvalidatedManifest.blobs,
message: request.message,
areInstructionsOriginatingFromHost: request.isWalletTransaction,
nonce: request.nonce,
notaryPublicKey: .ed25519(request.ephemeralNotaryPublicKey.intoSargon())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ extension AccountCard where Trailing == EmptyView, Bottom == EmptyView {
)
}

init(kind: Kind = .innerCompact, account: TransactionReview.ReviewAccount) {
init(kind: Kind = .innerCompact, account: InteractionReview.ReviewAccount) {
switch account {
case let .user(account):
self.init(kind: kind, account: account)
Expand Down Expand Up @@ -98,7 +98,7 @@ private extension AccountForDisplay {

private extension AccountAddress {
var asDataSource: AccountCardDataSource {
.init(title: L10n.TransactionReview.externalAccountName, ledgerIdentifiable: .address(.account(self)), gradient: .external)
.init(title: L10n.InteractionReview.externalAccountName, ledgerIdentifiable: .address(.account(self)), gradient: .external)
}
}

Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ struct DevAccountPreferences: Sendable, FeatureReducer {
} catch: { error, _ in
loggerGlobal.warning("Failed to create manifest which turns account into dapp definition account type, error: \(error)")
}

#endif
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ extension InfoLinkSheet {
case dashboard
case bridging
case payingaccount
case preauthorizations
case possibledappcalls
}
}

Expand Down Expand Up @@ -153,6 +155,10 @@ extension InfoLinkSheet.GlossaryItem {
L10n.InfoLink.Glossary.bridging
case .payingaccount:
L10n.InfoLink.Glossary.payingaccount
case .preauthorizations:
L10n.InfoLink.Glossary.preauthorizations
case .possibledappcalls:
L10n.InfoLink.Glossary.possibledappcalls
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import ComposableArchitecture
import SwiftUI

// MARK: - FungibleTokenDetails
@Reducer
struct FungibleTokenDetails: Sendable, FeatureReducer {
@ObservableState
struct State: Sendable, Hashable {
let resourceAddress: ResourceAddress
var resource: Loadable<OnLedgerEntity.Resource>
Expand All @@ -27,6 +29,8 @@ struct FungibleTokenDetails: Sendable, FeatureReducer {
}
}

typealias Action = FeatureAction<Self>

enum ViewAction: Sendable, Equatable {
case closeButtonTapped
case task
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,6 @@ import ComposableArchitecture
import SwiftUI

extension FungibleTokenDetails.State {
var viewState: FungibleTokenDetails.ViewState {
.init(
detailsHeader: detailsHeader,
thumbnail: {
let iconURL = resource.metadata.get(\.iconURL, prefetched: ownedFungibleResource?.metadata)
return isXRD ? .success(.xrd) : iconURL.map { .other($0) }
}(),
details: .init(
description: resource.metadata.get(\.description, prefetched: ownedFungibleResource?.metadata),
infoUrl: resource.metadata.infoURL,
resourceAddress: resourceAddress,
isXRD: isXRD,
validatorAddress: nil,
resourceName: resource.metadata.name,
currentSupply: resource.totalSupply.map { $0?.formatted() ?? L10n.AssetDetails.supplyUnkown },
divisibility: resource.divisibility,
arbitraryDataFields: resource.metadata.arbitraryItems.asDataFields,
behaviors: resource.behaviors,
tags: {
let tags = resource.metadata.get(\.tags, prefetched: ownedFungibleResource?.metadata)
return isXRD ? tags.map { $0 + [.officialRadix] } : tags
}()
)
)
}

var detailsHeader: DetailsContainerWithHeaderViewState {
.init(
title: resource.metadata.get(\.name, prefetched: ownedFungibleResource?.metadata).map { $0 ?? L10n.Account.PoolUnits.unknownPoolUnitName },
Expand All @@ -36,40 +10,53 @@ extension FungibleTokenDetails.State {
symbol: resource.metadata.get(\.symbol, prefetched: ownedFungibleResource?.metadata)
)
}

var thumbnail: Loadable<Thumbnail.TokenContent> {
let iconURL = resource.metadata.get(\.iconURL, prefetched: ownedFungibleResource?.metadata)
return isXRD ? .success(.xrd) : iconURL.map { .other($0) }
}

var details: AssetResourceDetailsSection.ViewState {
.init(
description: resource.metadata.get(\.description, prefetched: ownedFungibleResource?.metadata),
infoUrl: resource.metadata.infoURL,
resourceAddress: resourceAddress,
isXRD: isXRD,
validatorAddress: nil,
resourceName: resource.metadata.name,
currentSupply: resource.totalSupply.map { $0?.formatted() ?? L10n.AssetDetails.supplyUnkown },
divisibility: resource.divisibility,
arbitraryDataFields: resource.metadata.arbitraryItems.asDataFields,
behaviors: resource.behaviors,
tags: {
let tags = resource.metadata.get(\.tags, prefetched: ownedFungibleResource?.metadata)
return isXRD ? tags.map { $0 + [.officialRadix] } : tags
}()
)
}
}

// MARK: - FungibleTokenDetails.View
extension FungibleTokenDetails {
struct ViewState: Equatable {
let detailsHeader: DetailsContainerWithHeaderViewState
let thumbnail: Loadable<Thumbnail.TokenContent>
let details: AssetResourceDetailsSection.ViewState
}

@MainActor
struct View: SwiftUI.View {
private let store: StoreOf<FungibleTokenDetails>

init(store: StoreOf<FungibleTokenDetails>) {
self.store = store
}
let store: StoreOf<FungibleTokenDetails>

var body: some SwiftUI.View {
WithViewStore(store, observe: \.viewState, send: { .view($0) }) { viewStore in
DetailsContainerWithHeaderView(viewState: viewStore.detailsHeader) {
viewStore.send(.closeButtonTapped)
WithPerceptionTracking {
DetailsContainerWithHeaderView(viewState: store.detailsHeader) {
store.send(.view(.closeButtonTapped))
} thumbnailView: {
Thumbnail(token: viewStore.thumbnail.wrappedValue ?? .other(nil), size: .veryLarge)
Thumbnail(token: store.thumbnail.wrappedValue ?? .other(nil), size: .veryLarge)
} detailsView: {
VStack(spacing: .medium1) {
AssetResourceDetailsSection(viewState: viewStore.details)
AssetResourceDetailsSection(viewState: store.details)

HideResource.View(store: store.hideResource)
}
.padding(.bottom, .medium1)
}
.task { @MainActor in
await viewStore.send(.task).finish()
await store.send(.view(.task)).finish()
}
}
}
Expand Down
Loading
Loading