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

Introduce Sargon: Radix Engine Toolkit (RET) removed #1032

Merged
merged 155 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
155 commits
Select commit Hold shift + click to select a range
bc68de3
remove Swift Engine Toolkit swift package dependency
CyonAlexRDX Feb 8, 2024
5da0c5a
wip
CyonAlexRDX Feb 9, 2024
bee43f8
wip
CyonAlexRDX Feb 9, 2024
2406b94
wip
CyonAlexRDX Feb 9, 2024
7a693c6
wip
CyonAlexRDX Feb 9, 2024
355a0af
revert incorrect changes
CyonAlexRDX Feb 9, 2024
839a78b
wip
CyonAlexRDX Feb 9, 2024
f63e3d8
bump Xcode Version to 15.1
CyonAlexRDX Feb 9, 2024
aa2e766
SWIFT_ENABLE_BATCH_MODE = NO
CyonAlexRDX Feb 10, 2024
6c9ad42
compiles! Have to re-comment out ThirdPartyDeposits+Reducer
CyonAlexRDX Feb 12, 2024
86ff01a
fix
CyonAlexRDX Feb 12, 2024
4e57f54
revert
CyonAlexRDX Feb 12, 2024
8c3316f
WIP
CyonAlexRDX Feb 12, 2024
7ce0a81
Remove Engine RETPublicKey
CyonAlexRDX Feb 12, 2024
ef0b5c0
Remove Engine RETSignature
CyonAlexRDX Feb 12, 2024
8fb8bfc
Remove Engine RETSignatureWithPublicKey
CyonAlexRDX Feb 12, 2024
787372f
WIP
CyonAlexRDX Feb 12, 2024
6f0e835
WIP
CyonAlexRDX Feb 12, 2024
ac24dd2
WIP
CyonAlexRDX Feb 12, 2024
0aeea49
WIP
CyonAlexRDX Feb 12, 2024
a954530
WIP
CyonAlexRDX Feb 12, 2024
164a001
WIP
CyonAlexRDX Feb 12, 2024
22ba27b
WIP
CyonAlexRDX Feb 12, 2024
ebfc5db
WIP
CyonAlexRDX Feb 12, 2024
2c005dc
WIP
CyonAlexRDX Feb 12, 2024
a5b2e24
WIP
CyonAlexRDX Feb 12, 2024
c5fda00
WIP
CyonAlexRDX Feb 12, 2024
d8d335c
WIP
CyonAlexRDX Feb 12, 2024
ed2d997
WIP
CyonAlexRDX Feb 12, 2024
91c08cc
WIP
CyonAlexRDX Feb 12, 2024
b1cf4e0
WIP
CyonAlexRDX Feb 12, 2024
c1ff116
WIP
CyonAlexRDX Feb 12, 2024
62be2db
WIP
CyonAlexRDX Feb 12, 2024
5948b6f
WIP
CyonAlexRDX Feb 12, 2024
2158bee
WIP
CyonAlexRDX Feb 12, 2024
4291f57
WIP
CyonAlexRDX Feb 12, 2024
bcf42d4
Remove RETAddress
CyonAlexRDX Feb 12, 2024
fadf697
Remove ManifestBuilder
CyonAlexRDX Feb 12, 2024
6ddc3e7
Remove ResourceSpecified
CyonAlexRDX Feb 12, 2024
2256c27
WIP
CyonAlexRDX Feb 12, 2024
423da8e
WIP
CyonAlexRDX Feb 12, 2024
930a455
WIP
CyonAlexRDX Feb 12, 2024
39d3d22
WIP
CyonAlexRDX Feb 12, 2024
da19a15
WIP
CyonAlexRDX Feb 12, 2024
c7a40f6
WIP
CyonAlexRDX Feb 12, 2024
d7fb5d4
WIP
CyonAlexRDX Feb 12, 2024
237c141
WIP
CyonAlexRDX Feb 12, 2024
0d17c56
WIP
CyonAlexRDX Feb 12, 2024
ba81e8b
WIP
CyonAlexRDX Feb 12, 2024
3072736
hiding instructions on TXManifest
CyonAlexRDX Feb 12, 2024
bd8ca8c
WIP
CyonAlexRDX Feb 12, 2024
6b147a7
WIP
CyonAlexRDX Feb 12, 2024
3a17198
WIP
CyonAlexRDX Feb 12, 2024
5d83a97
WIP
CyonAlexRDX Feb 12, 2024
028b1df
WIP
CyonAlexRDX Feb 12, 2024
29d26ac
WIP
CyonAlexRDX Feb 12, 2024
085299d
WIP
CyonAlexRDX Feb 12, 2024
7e7a97c
WIP
CyonAlexRDX Feb 12, 2024
fc34307
WIP
CyonAlexRDX Feb 12, 2024
3b4f6a4
WIP
CyonAlexRDX Feb 12, 2024
6369b32
WIP
CyonAlexRDX Feb 12, 2024
deaa45d
merge main
CyonAlexRDX Feb 12, 2024
a1b477d
WIP
CyonAlexRDX Feb 12, 2024
a5faa05
WIP
CyonAlexRDX Feb 13, 2024
02c5b8f
WIP
CyonAlexRDX Feb 13, 2024
a741eda
remove unused address types and entity types
CyonAlexRDX Feb 13, 2024
259a3d9
remove badly merged enginekit folder
CyonAlexRDX Feb 14, 2024
0372d4e
merge
CyonAlexRDX Mar 11, 2024
0c1f4fa
merge
CyonAlexRDX Mar 17, 2024
503e7ec
WIP
CyonAlexRDX Mar 17, 2024
2882360
WIP
CyonAlexRDX Mar 17, 2024
c3d19d9
transfers
CyonAlexRDX Mar 18, 2024
88e8c7f
bump xcode to 15.2
CyonAlexRDX Mar 18, 2024
6701366
merge
CyonAlexRDX Mar 22, 2024
1c35156
fix
CyonAlexRDX Mar 22, 2024
c2ac127
move away from Sargon namespaces
CyonAlexRDX Mar 22, 2024
700bab0
wip
CyonAlexRDX Mar 22, 2024
1fb408a
WIP
CyonAlexRDX Mar 22, 2024
c002ade
WIP
CyonAlexRDX Mar 25, 2024
8165b5e
Rename RETDecimal -> Decimal192
CyonAlexRDX Mar 25, 2024
ac6e66f
WIP
CyonAlexRDX Mar 25, 2024
5a25f14
WIP
CyonAlexRDX Mar 25, 2024
4929197
WIP
CyonAlexRDX Mar 25, 2024
e48832f
merge
CyonAlexRDX Mar 25, 2024
44d397a
WIP
CyonAlexRDX Mar 25, 2024
58428ee
WIP
CyonAlexRDX Mar 26, 2024
3162c26
Merge branch 'main' into ret_extraction_second_attempt
CyonAlexRDX Mar 26, 2024
fdd9512
WIP
CyonAlexRDX Mar 26, 2024
8d0c350
WIP
CyonAlexRDX Mar 27, 2024
4780257
WIP
CyonAlexRDX Mar 28, 2024
5d92862
merge
CyonAlexRDX Mar 28, 2024
26b4853
WIP
CyonAlexRDX Mar 28, 2024
f5f1e8e
WIP
CyonAlexRDX Mar 28, 2024
fa006c4
Merge branch 'main' into ret_extraction_second_attempt
CyonAlexRDX Mar 28, 2024
96021b7
WIP
CyonAlexRDX Mar 28, 2024
9a31246
WIP
CyonAlexRDX Mar 28, 2024
6615fcb
WIP
CyonAlexRDX Mar 28, 2024
f0ae7b1
WIP
CyonAlexRDX Mar 28, 2024
5022753
WIP
CyonAlexRDX Mar 28, 2024
a981f2e
WIP
CyonAlexRDX Mar 28, 2024
31fc2a0
WIP
CyonAlexRDX Mar 28, 2024
02ba6db
WIP
CyonAlexRDX Mar 28, 2024
3ca30d9
WIP
CyonAlexRDX Mar 28, 2024
7b4b457
WIP
CyonAlexRDX Mar 28, 2024
3d1cafa
WIP
CyonAlexRDX Mar 28, 2024
79841ed
WIP
CyonAlexRDX Mar 28, 2024
2abace0
WIP
CyonAlexRDX Mar 28, 2024
d4ae3b0
WIP
CyonAlexRDX Mar 28, 2024
5b0620f
WIP
CyonAlexRDX Mar 28, 2024
cede14e
WIP
CyonAlexRDX Mar 28, 2024
ccedccb
WIP
CyonAlexRDX Mar 28, 2024
90998a0
WIP
CyonAlexRDX Mar 28, 2024
a2de68d
WIP
CyonAlexRDX Mar 28, 2024
fd3bffc
WIP
CyonAlexRDX Mar 28, 2024
e840257
WIP
CyonAlexRDX Mar 29, 2024
52f24d5
WIP
CyonAlexRDX Mar 29, 2024
c812c3e
WIP
CyonAlexRDX Mar 29, 2024
1f88f86
fix bug where all ResourceAddresses accidentally got treated as XRD.
CyonAlexRDX Mar 29, 2024
a9bc3b1
WIP
CyonAlexRDX Mar 29, 2024
9c172a6
WIP
CyonAlexRDX Mar 29, 2024
ffdc8ec
WIP
CyonAlexRDX Mar 30, 2024
324f586
merge with conflicts
CyonAlexRDX Apr 3, 2024
adfcb7d
WIP
CyonAlexRDX Apr 3, 2024
bd362d2
revert xcode version bump
CyonAlexRDX Apr 3, 2024
3b5f145
swiftformat 0.53.5
CyonAlexRDX Apr 3, 2024
58d5467
WIP
CyonAlexRDX Apr 3, 2024
d8af9d2
revert regression of TXID formatting.
CyonAlexRDX Apr 4, 2024
5aaddd8
Revert localized error change (revert back to 'TXID' instead of 'Inte…
CyonAlexRDX Apr 4, 2024
93f52f8
revert Message as optional.
CyonAlexRDX Apr 4, 2024
920cbaa
fix unit tests
CyonAlexRDX Apr 4, 2024
428ec94
fix prod
CyonAlexRDX Apr 4, 2024
8a4dabc
merge
CyonAlexRDX Apr 4, 2024
4d61691
Sargon build info in settings
CyonAlexRDX Apr 4, 2024
81207d3
PR review fixes
CyonAlexRDX Apr 4, 2024
0ab3460
fix bug where create multiple fungible tokens did not work
CyonAlexRDX Apr 4, 2024
2c15d2b
revert xcode 15.3 usage (prodced package resolved)
CyonAlexRDX Apr 4, 2024
106e0e2
fixes
CyonAlexRDX Apr 4, 2024
a5e89cd
Merge branch 'main' into ret_extraction_second_attempt
CyonAlexRDX Apr 4, 2024
b1d028a
Bump Sargon to 0.6.6 - filter out global ComponentAddresses
CyonAlexRDX Apr 4, 2024
0970eba
bump sargon to 0.6.7 fixing icon url
CyonAlexRDX Apr 5, 2024
b8a9c13
bump sargon to 0.6.8 with NFT image fixes
CyonAlexRDX Apr 5, 2024
06d4434
remove dead code
CyonAlexRDX Apr 5, 2024
01260c9
merge
CyonAlexRDX Apr 5, 2024
11d2e6b
resolved
CyonAlexRDX Apr 5, 2024
165337c
bump Sargon to 0.6.10
CyonAlexRDX Apr 5, 2024
0779b44
WIP
CyonAlexRDX Apr 5, 2024
ff694ac
use comparable Dec
CyonAlexRDX Apr 5, 2024
8eb5544
Nice! Sargon can do 16 instead of 14 decimal places of precision when…
CyonAlexRDX Apr 6, 2024
23032df
Bump Sargon to 0.6.11
CyonAlexRDX Apr 8, 2024
e33f8e8
Merge branch 'main' into ret_extraction_second_attempt
CyonAlexRDX Apr 8, 2024
b392f88
revert xcode 15.3 usage (prodced package resolved) - again
CyonAlexRDX Apr 8, 2024
7c9e577
merge
CyonAlexRDX Apr 8, 2024
4d07997
bump sargon to 0.6.17
CyonAlexRDX Apr 9, 2024
cec6eb7
Merge branch 'main' into ret_extraction_second_attempt
CyonAlexRDX Apr 9, 2024
1e5ee4a
Merge branch 'main' into ret_extraction_second_attempt
GhenadieVP Apr 12, 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
218 changes: 41 additions & 177 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" : "3313f884630244f405efa4cdbbcb2486d097b16289931114ea3c6826384f24b9",
"originHash" : "5781e493b3b5935431690908af86b207cf3426348bd3a1d90bc542f5896251ea",
"pins" : [
{
"identity" : "anycodable",
Expand Down Expand Up @@ -118,6 +118,15 @@
"version" : "11.6.4"
}
},
{
"identity" : "sargon",
"kind" : "remoteSourceControl",
"location" : "https://github.com/radixdlt/sargon",
"state" : {
"revision" : "bfc6ca53983aa71d73f4c7009f95b7f475933634",
"version" : "0.6.17"
}
},
{
"identity" : "screenshotpreventing-ios",
"kind" : "remoteSourceControl",
Expand Down Expand Up @@ -186,8 +195,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-collections.git",
"state" : {
"branch" : "main",
"revision" : "b2c7faa198164f3d928b1ceec9ce373e22febb96"
"revision" : "94cf62b3ba8d4bed62680a282d4c25f9c63c2efb",
"version" : "1.1.0"
}
},
{
Expand Down Expand Up @@ -244,15 +253,6 @@
"revision" : "db33f4084304e2ef47c8b4d2949f0eb286f95b90"
}
},
{
"identity" : "swift-engine-toolkit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/radixdlt/swift-engine-toolkit",
"state" : {
"branch" : "1.0.12_update",
"revision" : "4cf2edc92a430d4f59547d405e4c2c4bc5c912fe"
}
},
{
"identity" : "swift-identified-collections",
"kind" : "remoteSourceControl",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,38 +44,34 @@ extension AccountPortfoliosClient {
@Dependency(\.cacheClient) var cacheClient

let changedAccounts: [Profile.Network.Account.EntityAddress]?
let resourceAddressesToRefresh: [Address]?
let poolAddressesToRefresh: [PoolAddress]?
do {
let manifest = intent.manifest()
let manifest = intent.manifest

let involvedAccounts = try await transactionClient.myInvolvedEntities(manifest)
changedAccounts = involvedAccounts.accountsDepositedInto
.union(involvedAccounts.accountsWithdrawnFrom)
.map(\.address)

let involvedAddresses = manifest.extractAddresses()
let involvedPoolAddresses = manifest.involvedPoolAddresses
/// Refresh the resources if an operation on resource pool is involved,
/// reason being that contributing or withdrawing from a resource pool modifies the totalSupply
if involvedAddresses.contains(where: \.key.isResourcePool) {
if !involvedPoolAddresses.isEmpty {
/// A little bit too aggressive, as any other resource will also be refreshed.
/// But at this stage we cannot determine(without making additional calls) the pool unit related fungible resource
resourceAddressesToRefresh = involvedAddresses
.filter { $0.key == .globalFungibleResourceManager || $0.key.isResourcePool }
.values
.flatMap(identity)
.compactMap { try? $0.asSpecific() }
poolAddressesToRefresh = involvedPoolAddresses
} else {
resourceAddressesToRefresh = nil
poolAddressesToRefresh = nil
}
} catch {
loggerGlobal.warning("Could get transactionClient.myInvolvedEntities: \(error.localizedDescription)")
changedAccounts = nil
resourceAddressesToRefresh = nil
poolAddressesToRefresh = nil
}

if let resourceAddressesToRefresh {
for item in resourceAddressesToRefresh {
cacheClient.removeFile(.onLedgerEntity(.resource(item.asGeneral)))
if let poolAddressesToRefresh {
for item in poolAddressesToRefresh {
cacheClient.removeFile(.onLedgerEntity(.address(.pool(item))))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,15 @@ extension AccountPortfoliosClient: DependencyKey {
}

@Sendable
func fetchAccountPortfolios(_ accountAddresses: [AccountAddress], _ forceRefresh: Bool) async throws -> [AccountPortfolio] {
func fetchAccountPortfolios(
_ accountAddresses: [AccountAddress],
_ forceRefresh: Bool
) async throws -> [AccountPortfolio] {
let gateway = await gatewaysClient.getCurrentGateway()
await state.setRadixGateway(gateway)
if forceRefresh {
for accountAddress in accountAddresses {
cacheClient.removeFolder(.onLedgerEntity(.account(accountAddress.asGeneral)))
cacheClient.removeFolder(.init(address: accountAddress))
}
}

Expand All @@ -91,12 +94,12 @@ extension AccountPortfoliosClient: DependencyKey {
let allResources: [ResourceAddress] = {
if gateway == .mainnet {
/// Only Mainnet resources have prices
return (currentAccounts + accounts).flatMap(\.resourcesWithPrices) + [.mainnetXRDAddress]
return (currentAccounts + accounts).flatMap(\.resourcesWithPrices) + [.mainnetXRD]
} else {
#if DEBUG
/// Helpful for testing on stokenet
return [
.mainnetXRDAddress,
.mainnetXRD,
try! .init(validatingAddress:
"resource_rdx1t4tjx4g3qzd98nayqxm7qdpj0a0u8ns6a0jrchq49dyfevgh6u0gj3"
),
Expand Down Expand Up @@ -128,9 +131,12 @@ extension AccountPortfoliosClient: DependencyKey {
}

@Sendable
func fetchAccountPortfolio(_ accountAddress: AccountAddress, _ forceRefresh: Bool) async throws -> AccountPortfolio {
func fetchAccountPortfolio(
_ accountAddress: AccountAddress,
_ forceRefresh: Bool
) async throws -> AccountPortfolio {
if forceRefresh {
cacheClient.removeFolder(.onLedgerEntity(.account(accountAddress.asGeneral)))
cacheClient.removeFolder(.init(address: accountAddress))
}

let account = try await onLedgerEntitiesClient.getAccount(accountAddress)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@ import Foundation

// MARK: - Definition
extension AccountPortfoliosClient {
public struct AccountPortfolio: Sendable, Hashable {
public struct AccountPortfolio: Sendable, Hashable, CustomDebugStringConvertible {
public var account: OnLedgerEntity.Account
public var poolUnitDetails: Loadable<[OnLedgerEntitiesClient.OwnedResourcePoolDetails]> = .idle
public var stakeUnitDetails: Loadable<IdentifiedArrayOf<OnLedgerEntitiesClient.OwnedStakeDetails>> = .idle

var isCurrencyAmountVisible: Bool = true
var fiatCurrency: FiatCurrency = .usd
public var debugDescription: String {
account.debugDescription
}
}

/// Internal state that holds all loaded portfolios.
actor State {
typealias TokenPrices = [ResourceAddress: RETDecimal]
typealias TokenPrices = [ResourceAddress: Decimal192]
let portfoliosSubject: AsyncCurrentValueSubject<Loadable<[AccountAddress: AccountPortfolio]>> = .init(.loading)
var tokenPrices: TokenPrices = [:]

Expand Down Expand Up @@ -129,7 +132,7 @@ extension AccountPortfoliosClient.State {
let price = {
#if DEBUG
if gateway != .mainnet {
if resourceAddress == .mainnetXRDAddress {
if resourceAddress == .mainnetXRD {
return self.tokenPrices[resourceAddress]
} else {
return self.tokenPrices.values.randomElement()
Expand Down Expand Up @@ -198,7 +201,7 @@ private extension AccountPortfoliosClient.AccountPortfolio {
private extension OnLedgerEntity.OwnedFungibleResources {
mutating func updateFiatWorth(_ change: (ResourceAddress, ResourceAmount) -> FiatWorth?) {
xrdResource.mutate { resource in
resource.amount.fiatWorth = change(.mainnetXRDAddress, resource.amount)
resource.amount.fiatWorth = change(.mainnetXRD, resource.amount)
}

nonXrdResources.mutateAll { resource in
Expand All @@ -213,7 +216,7 @@ private extension MutableCollection where Element == OnLedgerEntitiesClient.Owne
mutating func updateFiatWorth(_ change: (ResourceAddress, ResourceAmount) -> FiatWorth?) {
mutateAll { detail in
detail.xrdResource?.redemptionValue.mutate { amount in
amount.fiatWorth = change(.mainnetXRDAddress, amount)
amount.fiatWorth = change(.mainnetXRD, amount)
}

detail.nonXrdResources.mutateAll { resource in
Expand All @@ -230,11 +233,11 @@ private extension MutableCollection where Element == OnLedgerEntitiesClient.Owne
mutating func updateFiatWorth(_ change: (ResourceAddress, ResourceAmount) -> FiatWorth?) {
mutateAll { detail in
detail.stakeUnitResource.mutate {
$0.amount.fiatWorth = change(.mainnetXRDAddress, $0.amount)
$0.amount.fiatWorth = change(.mainnetXRD, $0.amount)
}
detail.stakeClaimTokens.mutate {
$0.stakeClaims.mutateAll { token in
token.claimAmount.fiatWorth = change(.mainnetXRDAddress, token.claimAmount)
token.claimAmount.fiatWorth = change(.mainnetXRD, token.claimAmount)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,10 @@ extension AccountsClient {
try await saveVirtualAccounts([account])
}
}

// FIXME: Delete this TEMPORARY bridge, once Wallet uses Sargon Profile!
extension AccountsClient {
public func fromSargon(_ sargonAccount: Sargon.Account) async throws -> Profile.Network.Account {
try await getAccountByAddress(sargonAccount.address)
}
}
Loading
Loading