-
Notifications
You must be signed in to change notification settings - Fork 579
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
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. 🚀 New features to boost your workflow:
|
There was a problem hiding this 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.
Updated the state |
There was a problem hiding this 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
There was a problem hiding this comment.
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.
There was a problem hiding this 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>, |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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}`'
There was a problem hiding this comment.
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
:(
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hassan - test
Closes #2812
This adds an
AddressInput
component that takes a CAIP-2chainId
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.