From 8d0c350e7316a5d5b3dd6ca436afe98336d50f40 Mon Sep 17 00:00:00 2001 From: Alexander Cyon Date: Wed, 27 Mar 2024 14:02:37 +0100 Subject: [PATCH] WIP --- RadixWallet.xcodeproj/project.pbxproj | 6 +++++- .../xcshareddata/swiftpm/Package.resolved | 8 ++++---- .../AccountPortfoliosClient+Interface.swift | 2 +- .../TransactionClient/TransactionClient+Live.swift | 14 +++++++------- .../ExecutionSummary+Extensions.swift | 7 ------- .../Core/SargonExtensions/SargonExtensions.swift | 13 +++++++++++++ .../ReceivingAccount+Reducer.swift | 2 +- .../Details/NonFungibleTokenDetails+View.swift | 4 ++-- .../SubmitTransaction/SubmitTransaction.swift | 4 ++-- .../TransactionReview+DepositExceptionsView.swift | 2 +- 10 files changed, 36 insertions(+), 26 deletions(-) create mode 100644 RadixWallet/Core/SargonExtensions/SargonExtensions.swift diff --git a/RadixWallet.xcodeproj/project.pbxproj b/RadixWallet.xcodeproj/project.pbxproj index 80fc554849..403a773ad5 100644 --- a/RadixWallet.xcodeproj/project.pbxproj +++ b/RadixWallet.xcodeproj/project.pbxproj @@ -11,6 +11,7 @@ 480E50D52B0C881000FC21D5 /* RecoverWalletWithoutProfileCoordinator+View.swift in Sources */ = {isa = PBXBuildFile; fileRef = 480E50D32B0C881000FC21D5 /* RecoverWalletWithoutProfileCoordinator+View.swift */; }; 48581B2F2B0206E600F885C0 /* TestUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 48581B2E2B0206E600F885C0 /* TestUtils.swift */; }; 48649AD52ADC7CAC006307CF /* AppIcon.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 48649AD42ADC7CAC006307CF /* AppIcon.xcassets */; }; + 4888297A2BB41D0700DFF8E1 /* SargonExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 488829792BB41D0700DFF8E1 /* SargonExtensions.swift */; }; 489122782B186F61005F2EEE /* AlternativeRectangularButtonStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 489122772B186F61005F2EEE /* AlternativeRectangularButtonStyle.swift */; }; 48AB4E842AE19F5B001B238E /* ProfileStore+AsyncSequence+Updates.swift in Sources */ = {isa = PBXBuildFile; fileRef = 48AB4E832AE19F5B001B238E /* ProfileStore+AsyncSequence+Updates.swift */; }; 48ABCF402AE54A1F00D6E87F /* iOS-dev-test.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 48ABCF3F2AE54A1F00D6E87F /* iOS-dev-test.xcconfig */; }; @@ -1319,6 +1320,7 @@ 481B44022ADC7FB3007945C1 /* RadixWallet.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = RadixWallet.xctestplan; sourceTree = ""; }; 48581B2E2B0206E600F885C0 /* TestUtils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestUtils.swift; sourceTree = ""; }; 48649AD42ADC7CAC006307CF /* AppIcon.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = AppIcon.xcassets; sourceTree = ""; }; + 488829792BB41D0700DFF8E1 /* SargonExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SargonExtensions.swift; sourceTree = ""; }; 489122772B186F61005F2EEE /* AlternativeRectangularButtonStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlternativeRectangularButtonStyle.swift; sourceTree = ""; }; 48AB4E832AE19F5B001B238E /* ProfileStore+AsyncSequence+Updates.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ProfileStore+AsyncSequence+Updates.swift"; sourceTree = ""; }; 48ABCF3F2AE54A1F00D6E87F /* iOS-dev-test.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "iOS-dev-test.xcconfig"; sourceTree = ""; }; @@ -6883,6 +6885,7 @@ E63257622BB2F0D400952051 /* KeysToSargon.swift */, E63257642BB314F600952051 /* ExecutionSummary+Extensions.swift */, E63257662BB3268800952051 /* Decimal192+Extensions.swift */, + 488829792BB41D0700DFF8E1 /* SargonExtensions.swift */, ); path = SargonExtensions; sourceTree = ""; @@ -7875,6 +7878,7 @@ 48CFC4032ADC10D900E77A5C /* KeychainClient+Mocked.swift in Sources */, 48CFC2B12ADC10D900E77A5C /* DerivePublicKeys+View.swift in Sources */, 48CFC3032ADC10D900E77A5C /* DebugManageFactorSources.swift in Sources */, + 4888297A2BB41D0700DFF8E1 /* SargonExtensions.swift in Sources */, 48CFC3212ADC10D900E77A5C /* NewConnection+Reducer.swift in Sources */, 48CFC5C92ADC10DA00E77A5C /* StackedViewsLayout.swift in Sources */, 48CFC45C2ADC10DA00E77A5C /* P2PLinksClient+Interface.swift in Sources */, @@ -9703,7 +9707,7 @@ repositoryURL = "https://github.com/radixdlt/sargon"; requirement = { kind = upToNextMajorVersion; - minimumVersion = 0.4.6; + minimumVersion = 0.5.1; }; }; /* End XCRemoteSwiftPackageReference section */ diff --git a/RadixWallet.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/RadixWallet.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 7ed8a73db5..9baa1de4e4 100644 --- a/RadixWallet.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/RadixWallet.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -114,8 +114,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/radixdlt/sargon", "state" : { - "revision" : "ec27f03edbecef16f59730112e20470d34dd0735", - "version" : "0.4.6" + "revision" : "8a81d143730eb4ce2bf65b35d934893780e58069", + "version" : "0.5.1" } }, { @@ -186,8 +186,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-collections.git", "state" : { - "branch" : "main", - "revision" : "b2c7faa198164f3d928b1ceec9ce373e22febb96" + "revision" : "94cf62b3ba8d4bed62680a282d4c25f9c63c2efb", + "version" : "1.1.0" } }, { diff --git a/RadixWallet/Clients/AccountPortfoliosClient/AccountPortfoliosClient+Interface.swift b/RadixWallet/Clients/AccountPortfoliosClient/AccountPortfoliosClient+Interface.swift index 171b43bbd5..d44d0f3503 100644 --- a/RadixWallet/Clients/AccountPortfoliosClient/AccountPortfoliosClient+Interface.swift +++ b/RadixWallet/Clients/AccountPortfoliosClient/AccountPortfoliosClient+Interface.swift @@ -71,7 +71,7 @@ extension AccountPortfoliosClient { if let poolAddressesToRefresh { for item in poolAddressesToRefresh { - cacheClient.removeFile(.onLedgerEntity(.resource(.pool(item)))) + cacheClient.removeFile(.onLedgerEntity(.resourcePool(item))) } } diff --git a/RadixWallet/Clients/TransactionClient/TransactionClient+Live.swift b/RadixWallet/Clients/TransactionClient/TransactionClient+Live.swift index a30b41ff0b..126236506c 100644 --- a/RadixWallet/Clients/TransactionClient/TransactionClient+Live.swift +++ b/RadixWallet/Clients/TransactionClient/TransactionClient+Live.swift @@ -138,23 +138,23 @@ extension TransactionClient { intentSignatures: IntentSignatures(signatures: Array(request.intentSignatures.map { IntentSignature(signatureWithPublicKey: $0.intoSargon()) })) ) - let signedIntentHash = try signedTransactionIntent.hash() + let signedIntentHash = signedTransactionIntent.hash() let notarySignature = try request.notary.sign( - hashOfMessage: signedIntentHash.hash + hashOfMessage: signedIntentHash.hash.data ) - let uncompiledNotarized = try NotarizedTransaction( + let uncompiledNotarized = NotarizedTransaction( signedIntent: signedTransactionIntent, - notarySignature: notarySignature.signature + notarySignature: NotarySignature(signature: notarySignature.intoSargon()) ) - let compiledNotarizedTXIntent = try uncompiledNotarized.compile() + let compiledNotarizedTXIntent = uncompiledNotarized.compile() - let txID = try request.transactionIntent.intentHash() + let txID = request.transactionIntent.hash() return .init( - notarized: compiledNotarizedTXIntent, + notarized: compiledNotarizedTXIntent.data, intent: request.transactionIntent, txID: txID ) diff --git a/RadixWallet/Core/SargonExtensions/ExecutionSummary+Extensions.swift b/RadixWallet/Core/SargonExtensions/ExecutionSummary+Extensions.swift index 009ae1c296..6fff53282a 100644 --- a/RadixWallet/Core/SargonExtensions/ExecutionSummary+Extensions.swift +++ b/RadixWallet/Core/SargonExtensions/ExecutionSummary+Extensions.swift @@ -5,10 +5,3 @@ extension ExecutionSummary { self.detailedClassification.first! } } - -// MARK: - NonFungibleGlobalID + CustomStringConvertible -extension NonFungibleGlobalID: CustomStringConvertible { - public var description: String { - fatalError("Sargon migration") - } -} diff --git a/RadixWallet/Core/SargonExtensions/SargonExtensions.swift b/RadixWallet/Core/SargonExtensions/SargonExtensions.swift new file mode 100644 index 0000000000..18c613212f --- /dev/null +++ b/RadixWallet/Core/SargonExtensions/SargonExtensions.swift @@ -0,0 +1,13 @@ +extension NotarySignature { + public init(signature: Sargon.SignatureWithPublicKey) { + fatalError("sargon migration") + } +} + +// MARK: - AssetsTransfersRecipient + Identifiable +extension AssetsTransfersRecipient: Identifiable { + public typealias ID = AccountAddress + public var id: ID { + accountAddress + } +} diff --git a/RadixWallet/Features/AssetTransferFeature/Components/TransferAccountList/ReceivingAccount/ReceivingAccount+Reducer.swift b/RadixWallet/Features/AssetTransferFeature/Components/TransferAccountList/ReceivingAccount/ReceivingAccount+Reducer.swift index 42bccfaf74..b227802972 100644 --- a/RadixWallet/Features/AssetTransferFeature/Components/TransferAccountList/ReceivingAccount/ReceivingAccount+Reducer.swift +++ b/RadixWallet/Features/AssetTransferFeature/Components/TransferAccountList/ReceivingAccount/ReceivingAccount+Reducer.swift @@ -76,7 +76,7 @@ extension AssetsTransfersRecipient { var name: String { switch self { case let .myOwnAccount(account): - account.displayName.rawValue + account.displayName.value case .foreignAccount: L10n.Common.account } diff --git a/RadixWallet/Features/AssetsFeature/Components/NonFungibleAssetList/Components/Details/NonFungibleTokenDetails+View.swift b/RadixWallet/Features/AssetsFeature/Components/NonFungibleAssetList/Components/Details/NonFungibleTokenDetails+View.swift index f45a46b15c..ecdbd44752 100644 --- a/RadixWallet/Features/AssetsFeature/Components/NonFungibleAssetList/Components/Details/NonFungibleTokenDetails+View.swift +++ b/RadixWallet/Features/AssetsFeature/Components/NonFungibleAssetList/Components/Details/NonFungibleTokenDetails+View.swift @@ -282,7 +282,7 @@ private extension String { var asDecimalDataField: ArbitraryDataFieldKind? { nilIfEmpty.map { - if let decimal = try? Decimal192(value: $0) { + if let decimal = try? Decimal192($0) { .decimal(decimal) } else { .primitive(self) @@ -292,7 +292,7 @@ private extension String { var asNonFungibleIDDataField: ArbitraryDataFieldKind? { nilIfEmpty.map { - if let id = try? NonFungibleLocalId.from(stringFormat: $0) { + if let id = try? NonFungibleLocalID(localId: $0) { .id(id) } else { .primitive(self) diff --git a/RadixWallet/Features/TransactionReviewFeature/SubmitTransaction/SubmitTransaction.swift b/RadixWallet/Features/TransactionReviewFeature/SubmitTransaction/SubmitTransaction.swift index a6142920d6..119032955f 100644 --- a/RadixWallet/Features/TransactionReviewFeature/SubmitTransaction/SubmitTransaction.swift +++ b/RadixWallet/Features/TransactionReviewFeature/SubmitTransaction/SubmitTransaction.swift @@ -125,7 +125,7 @@ public struct SubmitTransaction: Sendable, FeatureReducer { case let .submitTXResult(.success(txID)): state.status = .submitted - return .run { [endEpoch = state.notarizedTX.intent.header().endEpochExclusive] send in + return .run { [endEpoch = state.notarizedTX.intent.header.endEpochExclusive] send in do { try await submitTXClient.hasTXBeenCommittedSuccessfully(txID) await send(.internal(.statusUpdate(.committedSuccessfully))) @@ -137,7 +137,7 @@ public struct SubmitTransaction: Sendable, FeatureReducer { case let .temporarilyRejected(epoch): await send(.internal(.statusUpdate( .temporarilyRejected( - remainingProcessingTime: Int((endEpoch - epoch).rawValue) * epochDurationInMinutes + remainingProcessingTime: Int(endEpoch - epoch) * epochDurationInMinutes ) ))) case let .failed(reason): diff --git a/RadixWallet/Features/TransactionReviewFeature/TransactionReviewDepositExceptions/TransactionReview+DepositExceptionsView.swift b/RadixWallet/Features/TransactionReviewFeature/TransactionReviewDepositExceptions/TransactionReview+DepositExceptionsView.swift index 9850efedbd..9c59cc4c5e 100644 --- a/RadixWallet/Features/TransactionReviewFeature/TransactionReviewDepositExceptions/TransactionReview+DepositExceptionsView.swift +++ b/RadixWallet/Features/TransactionReviewFeature/TransactionReviewDepositExceptions/TransactionReview+DepositExceptionsView.swift @@ -7,7 +7,7 @@ extension TransactionReview { } public struct DepositExceptionsChange: Sendable, Identifiable, Hashable { - public var id: AccountAddress.ID { sargon() } + public var id: AccountAddress.ID { account.accountAddress.id } public let account: Profile.Network.Account public let resourcePreferenceChanges: IdentifiedArrayOf public let allowedDepositorChanges: IdentifiedArrayOf