-
Notifications
You must be signed in to change notification settings - Fork 639
Add AddressInput component
#3129
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
0e96a62
add address input component
hmalik88 0388d82
fix tests
hmalik88 d96265c
add address input to state creation utils
hmalik88 a63492d
update addressinput state
hmalik88 e20b655
lint fix
hmalik88 7475965
update types, use util to construct caip account id
hmalik88 c491b1f
Add placeholder and disabled prop
hmalik88 fe7dd0b
use parser from utils
hmalik88 b3d23a3
update import
hmalik88 1d0a65b
fix struct schema
hmalik88 613ec91
fixes after rebase
GuillaumeRx fb343af
re-add nextline
GuillaumeRx File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| { | ||
| "branches": 93.46, | ||
| "branches": 93.51, | ||
| "functions": 97.36, | ||
| "lines": 98.33, | ||
| "statements": 98.06 | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
packages/snaps-sdk/src/jsx/components/form/AddressInput.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import { AddressInput } from './AddressInput'; | ||
|
|
||
| describe('AddressInput', () => { | ||
| it('renders an address input', () => { | ||
| const result = <AddressInput name="address" chainId="eip155:1" />; | ||
|
|
||
| expect(result).toStrictEqual({ | ||
| type: 'AddressInput', | ||
| props: { | ||
| name: 'address', | ||
| chainId: 'eip155:1', | ||
| }, | ||
| key: null, | ||
| }); | ||
| }); | ||
| }); |
32 changes: 32 additions & 0 deletions
32
packages/snaps-sdk/src/jsx/components/form/AddressInput.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import type { CaipChainId } from '@metamask/utils'; | ||
|
|
||
| import { createSnapComponent } from '../../component'; | ||
|
|
||
| export type AddressInputProps = { | ||
| name: string; | ||
| value?: string | undefined; | ||
| chainId: CaipChainId; | ||
| placeholder?: string | undefined; | ||
| disabled?: boolean | undefined; | ||
| }; | ||
|
|
||
| const TYPE = 'AddressInput'; | ||
|
|
||
| /** | ||
| * An input component for entering an address. Resolves the address to a display name and avatar. | ||
| * | ||
| * @param props - The props of the component. | ||
| * @param props.name - The name of the input field. | ||
| * @param props.value - The value of the input field. | ||
| * @param props.chainId - The CAIP-2 chain ID of the address. | ||
| * @param props.placeholder - The placeholder text of the input field. | ||
| * @param props.disabled - Whether the input field is disabled. | ||
| * @returns An input element. | ||
| * @example | ||
| * <AddressInput name="address" value="0x1234567890123456789012345678901234567890" chainId="eip155:1" /> | ||
| */ | ||
| export const AddressInput = createSnapComponent<AddressInputProps, typeof TYPE>( | ||
| TYPE, | ||
| ); | ||
|
|
||
| export type AddressInputElement = ReturnType<typeof AddressInput>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.