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

Show all metadata and mark the locked ones with lock icon #1010

Merged
merged 18 commits into from
Jun 28, 2024

Conversation

micbakos-rdx
Copy link
Contributor

@micbakos-rdx micbakos-rdx commented Jun 26, 2024

Description

Asset details dialog got upgraded to support, non standard metadata. The metadata are received from Gateway paginated.

UI

We display the non standard metadata in the same manner we display the NF Data. Using the MetadataView. This view got 2 changes:
1. PublicKeys and PublicKeyHashes display in 1 line with ... on the end and can be copied.
2. The lock icon is introduced for metadata that have is_locked = true
3. The previously known as AssetMetadataRow is renamed to MetadataView and became modular to either accept metadata or primitive values (used for standard metadata)
4. The non standard metadata will be shown at the bottom with a divider.

Also the claim button in the NFT dialog has been updated.

Note

We need to clarify on UI how name, symbol and icon_url will display their locked property when they are locked.
The decision was to put the lock icon only in the non standard metadata.

How to test

  • Here is a manifest that creates some NFT collections with multiple metadata on the collection resource.
    many-metadata.txt

Videos

meta.webm

PR submission checklist

  • I have tested account to account transfer flow and have confirmed that it works

@@ -208,16 +242,19 @@ fun EntityMetadataItem.toMetadata(): Metadata? = when (val typed = value.typed)
Metadata.Primitive(
key = key,
value = "${it.resourceAddress}:${it.nonFungibleId}",
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't here we also use NonFungibleGlobalId as a type, same as for MetadataNonFungibleGlobalIdValue above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops missed that.

@@ -37,23 +109,23 @@ class StateDatabaseConverters {
// Behaviours
@TypeConverter
fun stringToBehaviours(string: String?): BehavioursColumn? {
return string?.let { BehavioursColumn(behaviours = json.decodeFromString(string)) }
return string?.let { json.decodeFromString(string) }
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we should use same json as we use for gateway models serialization?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No it is different, this is how the column is serialized into a json string. Room stores metadata in a custom type called MetadataColumn which uses this serialisation logic inside. Also the Metadata type we have defined is a domain model and not a GW one.

details: StateEntityDetailsResponseItemDetails?,
type: ResourceEntityType,
synced: Instant
): ResourceEntity {
val metadata = metadataCollection?.toMetadata().orEmpty()
val metadataColumn = if (implicitMetadata != null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

what is the difference between explicit/implicit metadata?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Explicit metadata are the ones we request when we communicate with GW and GW ensures that we will receive them. Also known as standard metadata. For example a resource may have defined 150 metadata. If you do a simple entity details request, on the first response we will only receive the first page of them (100) and we need to paginate them in order to get the other 50.

Although we need to somehow make sure that some metadata will be received since are crucial to rendering the UI without the need of pagination, like name, symbol, description, icon_url....

So for these requests you will see that we put ExplicitMetadataKey.forAssets in order to retrieve in the explicit_metadata field these crucial ones we need for ui.

When the user navigates to asset details, we can also display the rest of the metadata (besides the explicit ones). Decided to call them implicit. If we know that there is a page to be paginated, this is the time we do it.

) {
KeyView()
MetadataKeyView(key = key, isLocked = isLocked)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it is worth to allocate some max width to the metadata key, I noticed that for some metadata names, long ones, there is not much space left for the value. When increasing font size a bit in the system (from already quite big default setting on samsung), value is pushed out of the screen

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I saw that too. It is a bit tricky this one. Since we need to see if both key and value cannot be squeezed into a single row. If I added a max width to the key, and a value was too small, you would see a key being separated in two lines while there would clearly be way for the value in the same row.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jakub-rdx I pushed a commit ditching the Row and replacing it with constraint layout. It works better know. If a key has more than 30 chars it divides the space a little better.

text = metadata.value,
style = style,
color = color,
textAlign = if (isRenderedInNewLine) TextAlign.Start else TextAlign.End,
Copy link
Contributor

Choose a reason for hiding this comment

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

minor: maybe we can declare textAlign before when claus once and use it in all cases?

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 not applicable in all cases though. There are cases where we align start only.

Copy link
Contributor

@jakub-rdx jakub-rdx left a comment

Choose a reason for hiding this comment

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

Works good, great work in generalizing metadata views! Only one comment about metadata key width

Copy link
Contributor

@giannis-rdx giannis-rdx left a comment

Choose a reason for hiding this comment

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

tested and it seems to be working fine 👌🏽

@@ -234,57 +233,47 @@ class AccountsStateCache @Inject constructor(
result
}

private fun Flow<MutableMap<AccountAddress, AccountCachedData>>.compileAccountAddressAssets(): Flow<List<AccountAddressWithAssets>> =
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should better keep the return type, unless it is extremely obvious what it returns.

Copy link
Contributor

Choose a reason for hiding this comment

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

it's so much easier to read the code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I did that but detekt complains

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes I did that but detekt complains

What? 😮

Copy link
Contributor

Choose a reason for hiding this comment

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

this and the other one is unused, right?
good that you removed them.

Copy link
Contributor

@sergiupuhalschi-rdx sergiupuhalschi-rdx left a comment

Choose a reason for hiding this comment

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

Tested and it works fine

Copy link

sonarcloud bot commented Jun 28, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 40%)

See analysis details on SonarCloud

@micbakos-rdx micbakos-rdx merged commit f72bf3d into main Jun 28, 2024
8 of 9 checks passed
@micbakos-rdx micbakos-rdx deleted the feature/all-metadata branch June 28, 2024 13:33
@micbakos-rdx micbakos-rdx restored the feature/all-metadata branch June 28, 2024 14:30
@micbakos-rdx micbakos-rdx mentioned this pull request Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants