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

feat: snaps dynamic UI #12429

Open
wants to merge 76 commits into
base: main
Choose a base branch
from
Open

feat: snaps dynamic UI #12429

wants to merge 76 commits into from

Conversation

Daniel-Cross
Copy link
Contributor

@Daniel-Cross Daniel-Cross commented Nov 26, 2024

Description

This PR integrates the Snaps Dynamic UI controller and components to allow different dialog prompts to show on the screen.

Related issues

Fixes:

Manual testing steps

  1. Make a Flask build
  2. Go to: https://metamask.github.io/snaps/test-snaps/latest/ in the in app browser
  3. Connect the Snaps Dialog snap
  4. Try to launch the different snaps prompts.

Screenshots/Recordings

Before

After

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@Daniel-Cross Daniel-Cross self-assigned this Dec 16, 2024
@Daniel-Cross Daniel-Cross added team-accounts team-snaps-platform Snaps Platform team Run Smoke E2E Triggers smoke e2e on Bitrise labels Dec 16, 2024
@Daniel-Cross Daniel-Cross changed the title feature: snaps dynamic UI feat: snaps dynamic UI Dec 16, 2024
Copy link
Contributor

github-actions bot commented Dec 16, 2024

https://bitrise.io/ Bitrise

❌❌❌ pr_smoke_e2e_pipeline failed on Bitrise! ❌❌❌

Commit hash: 04876a5
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/d474e6c3-86f1-4359-84e2-7c0517478204

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

Tip

  • Check the documentation if you have any doubts on how to understand the failure on bitrise


import { UIComponentFactory } from './types';

export const input: UIComponentFactory<InputElement> = ({
Copy link
Member

Choose a reason for hiding this comment

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

Would be great to update this to the latest logic from the extension

export const heading: UIComponentFactory<IconElement> = ({ element }) => ({
element: 'Icon',
props: {
name: element.props.name,
Copy link
Member

Choose a reason for hiding this comment

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

We should consider the name being invalid here, same applies to sizing and color, we have remapping of these values on the extension for that reason

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Defaults values needed for fallback

}) => ({
element: 'SheetHeader',
props: {
title: e.props.children,
Copy link
Member

Choose a reason for hiding this comment

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

We should add support for sizing here

Comment on lines +21 to +23
mapToTemplate({
...params,
element: child as JSXElement,
Copy link
Member

Choose a reason for hiding this comment

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

Seems like a bunch of params aren't being passed down to the children here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add to templateChildren:

  useFooter,
  onCancel,
  promptLegacyProps,
  t,

* @param file - The file to upload.
* @param form - The name of the form containing the input.
*/
const handleFileChange: HandleFileChange = (name, file, form) => {
Copy link
Member

Choose a reason for hiding this comment

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

Since we don't have the file input we can remove this and uploadFile for now

variant: TextVariant.BodyMDBold,
ellipsizeMode: TextWrap.TailEllipsis,
color: TextColor.Default,
...(element.props as ExtendedTextProps),
Copy link
Member

Choose a reason for hiding this comment

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

What additional props are we trying to pass here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Try removing this line


export const address: UIComponentFactory<AddressElement> = ({ element }) => ({
element: 'AddressElement',
props: element.props as ExtendedAddressProps,
Copy link
Member

Choose a reason for hiding this comment

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

Looks like none of the props that Snaps are passing are supported in the address component

We also will need to support CAIP-10 addresses in addition to ethereum addresses

Maybe worth omitting the address component for now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Update based on extension file but omit this file for now

Copy link
Member

Choose a reason for hiding this comment

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

This file seems like it should be in the folder above it

Copy link
Member

Choose a reason for hiding this comment

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

Can we name the test files the same as the file they are testing?

Copy link
Member

Choose a reason for hiding this comment

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

Can we name the test files the same as the file they are testing?

Warning = 'warning',
}

export const getDelineatorTitle = (type: DelineatorType) => {
Copy link
Member

@FrederikBolding FrederikBolding Jan 17, 2025

Choose a reason for hiding this comment

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

As far as I can tell this isn't used anywhere

Same for the enum 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.

I'll double check

Copy link
Member

Choose a reason for hiding this comment

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

Is the preferred pattern on mobile to have Index files for every component?

Seems harder to find things then, but maybe I'm missing something

Linking.openURL(href);
};

export const SnapUILink: React.FC<SnapUILinkProps> = ({ href, children }) => (
Copy link
Member

Choose a reason for hiding this comment

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

We should make a note that this component should show a modal for links when not using preinstalled Snaps

: FlexDirection.Column,
justifyContent: generateJustifyContent(element.props.alignment),
color: TextColor.Default,
...(element.props as ViewProps),
Copy link
Member

Choose a reason for hiding this comment

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

What additional props are we trying to support here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Check extension file and compare

buttonProps.label = element.props.children;
}

return {
Copy link
Member

Choose a reason for hiding this comment

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

We'll need to map over the children and remap props here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Check extension file and compare

import { UIComponentFactory } from './types';

export const card: UIComponentFactory<CardElement> = ({ element }) => ({
element: 'Card',
Copy link
Member

Choose a reason for hiding this comment

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

You've added SnapUICard but this seems to use another component?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Two possible Card files SnapUICard and Card. Card currently called possibly by mistake.

>
<Box gap={4} alignItems={AlignItems.center}>
{image && (
<Image
Copy link
Member

Choose a reason for hiding this comment

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

This should probably be SnapUIImage

element: children,
} as UIComponentParams<ButtonElement>);
return {
element: 'SnapUIFooterButton',
Copy link
Member

Choose a reason for hiding this comment

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

Seems like we haven't implemented this component

import { UIComponentFactory } from './types';

export const value: UIComponentFactory<ValueElement> = ({ element: e }) => ({
element: 'ConfirmInfoRowValueDouble',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ConfirmInfoRowValueDouble not found in current implementation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could be called infoValue or something similar

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Check extension code to implement the Text file from there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants