-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Description - Updates the snap to use latest version of Snaps Dynamic UI (JSX components) - Removed "ENS disclaimer message" in place of conditionally rendering ENS instructions in the `WatchForm` closes: https://github.com/orgs/MetaMask/projects/75/views/6?pane=issue&itemId=67344493 ## Screenshots Ethereum Mainnet <img width="342" alt="Screenshot 2024-07-30 at 4 29 27 PM" src="https://github.com/user-attachments/assets/c84afd20-06f7-46d4-b874-d684e555ed30"> Other network <img width="357" alt="Screenshot 2024-07-30 at 4 30 04 PM" src="https://github.com/user-attachments/assets/b52144b2-faac-4d31-a510-8a02481509cb">
- Loading branch information
Showing
15 changed files
with
1,705 additions
and
1,476 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 was deleted.
Oops, something went wrong.
This file contains 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,19 @@ | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-nocheck | ||
import { RowVariant } from '@metamask/snaps-sdk'; | ||
import type { SnapComponent } from '@metamask/snaps-sdk/jsx'; | ||
import { Row, Text } from '@metamask/snaps-sdk/jsx'; | ||
|
||
export type ErrorMessageProps = { | ||
message: string; | ||
}; | ||
|
||
export const ErrorMessage: SnapComponent<ErrorMessageProps> = ({ | ||
message, | ||
}: ErrorMessageProps) => { | ||
return ( | ||
<Row label="Error" variant={RowVariant.Critical}> | ||
<Text>{message}</Text> | ||
</Row> | ||
); | ||
}; |
This file contains 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,21 @@ | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-nocheck | ||
import type { SnapComponent } from '@metamask/snaps-sdk/jsx'; | ||
import { Box, Divider, Heading, Spinner, Text } from '@metamask/snaps-sdk/jsx'; | ||
|
||
export type SpinnerWithMessageProps = { | ||
message?: string; | ||
}; | ||
|
||
export const SpinnerWithMessage: SnapComponent<SpinnerWithMessageProps> = ({ | ||
message, | ||
}: SpinnerWithMessageProps) => { | ||
return ( | ||
<Box> | ||
<Heading>Processing</Heading> | ||
<Divider /> | ||
{message && <Text>{message}</Text>} | ||
<Spinner /> | ||
</Box> | ||
); | ||
}; |
This file contains 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,40 @@ | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-nocheck | ||
import { isValidAddress } from '@ethereumjs/util'; | ||
import type { SnapComponent } from '@metamask/snaps-sdk/jsx'; | ||
import { | ||
Address, | ||
Box, | ||
Divider, | ||
Heading, | ||
Spinner, | ||
Text, | ||
} from '@metamask/snaps-sdk/jsx'; | ||
import type { Hex } from '@metamask/utils'; | ||
import { add0x, getChecksumAddress, isValidHexAddress } from '@metamask/utils'; | ||
|
||
export type SuccessMessageProps = { | ||
value?: string; | ||
message?: string; | ||
withSpinner?: boolean; | ||
}; | ||
|
||
export const SuccessMessage: SnapComponent<SuccessMessageProps> = ({ | ||
value, | ||
message, | ||
withSpinner, | ||
}: SuccessMessageProps) => { | ||
return ( | ||
<Box> | ||
<Heading>Success</Heading> | ||
<Divider /> | ||
<Text>{message}</Text> | ||
{value && (isValidHexAddress(value as Hex) || isValidAddress(value)) ? ( | ||
<Address address={getChecksumAddress(add0x(value)) as Hex} /> | ||
) : ( | ||
<Text>{value}</Text> | ||
)} | ||
{withSpinner && <Spinner />} | ||
</Box> | ||
); | ||
}; |
This file contains 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,69 @@ | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-nocheck | ||
import { ButtonType } from '@metamask/snaps-sdk'; | ||
import type { SnapComponent } from '@metamask/snaps-sdk/jsx'; | ||
import { | ||
Box, | ||
Button, | ||
Field, | ||
Form, | ||
Heading, | ||
Input, | ||
Text, | ||
} from '@metamask/snaps-sdk/jsx'; | ||
|
||
import { | ||
WATCH_FORM_DESCRIPTION, | ||
WATCH_FORM_DESCRIPTION_MAINNET, | ||
WATCH_FORM_HEADER, | ||
WATCH_FORM_INPUT_LABEL, | ||
WATCH_FORM_INPUT_PLACEHOLDER, | ||
WATCH_FORM_INPUT_PLACEHOLDER_MAINNET, | ||
WATCH_FORM_INSTRUCTIONS, | ||
} from '../content'; | ||
|
||
export enum WatchFormNames { | ||
AddressForm = 'address-form', | ||
AddressInput = 'address-input', | ||
SubmitButton = 'submit', | ||
} | ||
|
||
export type WatchFormProps = { | ||
onMainnet: boolean; | ||
}; | ||
|
||
export const WatchForm: SnapComponent<WatchFormProps> = ({ | ||
onMainnet, | ||
}: WatchFormProps) => { | ||
return ( | ||
<Box> | ||
<Heading>{WATCH_FORM_HEADER}</Heading> | ||
<Text> | ||
{onMainnet ? WATCH_FORM_DESCRIPTION_MAINNET : WATCH_FORM_DESCRIPTION} | ||
</Text> | ||
<Text>{WATCH_FORM_INSTRUCTIONS}</Text> | ||
<Form name={WatchFormNames.AddressForm}> | ||
<Field label={WATCH_FORM_INPUT_LABEL}> | ||
<Input | ||
name={WatchFormNames.AddressInput} | ||
type="text" | ||
placeholder={ | ||
onMainnet | ||
? WATCH_FORM_INPUT_PLACEHOLDER_MAINNET | ||
: WATCH_FORM_INPUT_PLACEHOLDER | ||
} | ||
/> | ||
</Field> | ||
<Box direction="horizontal" alignment="space-around"> | ||
<Button | ||
name={WatchFormNames.SubmitButton} | ||
type={ButtonType.Submit} | ||
variant="primary" | ||
> | ||
Watch | ||
</Button> | ||
</Box> | ||
</Form> | ||
</Box> | ||
); | ||
}; |
Oops, something went wrong.