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

Add AddressInput component #3129

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

Add AddressInput component #3129

wants to merge 21 commits into from

Conversation

hmalik88
Copy link
Contributor

Closes #2812

This adds an AddressInput component that takes a CAIP-2 chainId to identify the chain the address needs resolution on and resolves to a display name and avatar (if it exists). The resolution is to be made against the user's own saved accounts.

Copy link

codecov bot commented Feb 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.94%. Comparing base (4832fd7) to head (b38a542).
Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3129   +/-   ##
=======================================
  Coverage   94.93%   94.94%           
=======================================
  Files         507      508    +1     
  Lines       11184    11197   +13     
  Branches     1722     1726    +4     
=======================================
+ Hits        10618    10631   +13     
  Misses        566      566           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hmalik88 hmalik88 marked this pull request as ready for review February 18, 2025 23:59
@hmalik88 hmalik88 requested a review from a team as a code owner February 18, 2025 23:59
Copy link
Contributor

@GuillaumeRx GuillaumeRx left a comment

Choose a reason for hiding this comment

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

The state shape of the AddressInput component is a CAIP-10 account ID. When a value prop is passed to the component we should construct the CAIP-10 account ID in state with the chainId prop.

@hmalik88
Copy link
Contributor Author

The state shape of the AddressInput component is a CAIP-10 account ID. When a value prop is passed to the component we should construct the CAIP-10 account ID in state with the chainId prop.

Updated the state

Copy link
Contributor

@GuillaumeRx GuillaumeRx left a comment

Choose a reason for hiding this comment

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

Please also update the type of the state to include CaipAccountIdStruct

Copy link
Contributor Author

Choose a reason for hiding this comment

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

placeholder and disabled weren't in the original ticket for this component, but I think it makes sense to include them.

Copy link
Contributor

@GuillaumeRx GuillaumeRx left a comment

Choose a reason for hiding this comment

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

Code LGTM, waiting for an extension PR

'AddressInput',
{
name: string(),
chainId: CaipChainIdStruct as unknown as Struct<CaipChainId, CaipChainId>,
Copy link
Member

Choose a reason for hiding this comment

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

Why is this necessary? Seems like an issue with CaipChainIdStruct.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Had to do this because of the way the struct is defined with definePattern I think, the error is:

Type 'Struct<{ key: Key | null; type: Struct<Name, Name>; props: { name: string; chainId: `${string}:${string}`; disabled?: boolean | undefined; value?: string | undefined; placeholder?: string | undefined; }; }, { ...; }>' is not assignable to type 'Describe<SnapElement<AddressInputProps, "AddressInput">>'.
  The types of 'schema.props.schema.chainId.schema' are incompatible between these types.
    Type 'null' is not assignable to type '`${string}:${string}`'

Copy link
Contributor

Choose a reason for hiding this comment

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

Yup we have this error everytime we use CaipChainIdStruct :(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed the error, needed to update StructSchema to have a case for CaipChainId.

Copy link

Choose a reason for hiding this comment

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

Hassan - test

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.

Implement AddressInput component
4 participants