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

Pool units in account portfolio #658

Merged
merged 64 commits into from
Aug 10, 2023

Conversation

GhenadieVP
Copy link
Contributor

@GhenadieVP GhenadieVP commented Aug 7, 2023

Added Pool Units to account portfolio.

  • Collected the radix network stakes from the Fungible and NonFungible resources.
  • Collected pools from the Fungible Resources.
  • Linked with UI.
  • Update parts of the app to use more granular metadata keys due GW limitations.

How to test:

@GhenadieVP GhenadieVP changed the title WIP Pool units in account portfolio Pool units in account portfolio Aug 8, 2023
@GhenadieVP GhenadieVP marked this pull request as ready for review August 8, 2023 09:47
Base automatically changed from ABW-1695-pool-unit-asset-type to main August 8, 2023 10:09
associatedtype CodingKeyType: CodingKey = Self.CodingKeys
}

extension KeyedDecodingContainer {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like it's doing something with decoding nested optionals, but how does it differ from the default behaviour?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used to handle decoding of empty objects, for some reason the GW instead of sending back null, sends back an empty object. Which probably should be fixed on the backend side

Comment on lines 125 to 130
extract(
key: .validator,
keyPath: \.asGlobalAddress,
transform: ValidatorAddress.init(validatingAddress:)
)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very elegant, but if we want to use this pattern in even more places we could consider:

A. Turning extract into a property wrapper or macro
B. Defining a protocol to make the transform redundant, something like InitializableFromAddress

public typealias GetEntityDetails = @Sendable (_ addresses: [String]) async throws -> GatewayAPI.StateEntityDetailsResponse
public typealias GetEntityMetdata = @Sendable (_ address: String) async throws -> GatewayAPI.EntityMetadataCollection
public typealias GetEntityDetails = @Sendable (_ addresses: [String], _ explicitMetadata: [EntityMetadataKey], _ ledgerState: GatewayAPI.LedgerState?) async throws -> GatewayAPI.StateEntityDetailsResponse
public typealias GetEntityMetdata = @Sendable (_ address: String, _ explicitMetadata: [EntityMetadataKey]) async throws -> GatewayAPI.EntityMetadataCollection
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Elegant solution, even without the OptionSet...

Copy link
Contributor

@kugel3 kugel3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Maybe you should even spend the 5 minutes and turn the keys into an OptionalSet manually, it makes both logical and UX sense.

@maciek-rdx maciek-rdx self-requested a review August 8, 2023 11:09
Copy link
Contributor

@maciek-rdx maciek-rdx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one! I requested a bunch of changes here and there, but some of them you can treat more as suggestions. It'd be also nice to retain the working condition of the AssetsFeaturePreview 🙏

Copy link
Contributor

@maciek-rdx maciek-rdx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for changes and comments 🙌

Copy link
Contributor

@maciek-rdx maciek-rdx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One sec, the preview still doesn't work... It doesn't crash but displays no data. Looking 👀 Nevermind, I'll adjust the preview locally.

@maciek-rdx
Copy link
Contributor

Okay, fixing that preview is not as straightforward as I thought 😬 I think we may want to have a broader architectural discussion at some point. For now, I'm going to leave it as is

@GhenadieVP GhenadieVP merged commit c380623 into main Aug 10, 2023
5 checks passed
@GhenadieVP GhenadieVP deleted the fix/ABW-2009-pool-units-in-account-portfolio branch August 10, 2023 06:52
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants