Skip to content

Commit a270b30

Browse files
authoredMar 24, 2025··
Update send flow snap to use new AddressInput component (#3167)
Updated the send flow example snap to use the new `AddressInput` component.
1 parent e859203 commit a270b30

File tree

7 files changed

+5
-37
lines changed

7 files changed

+5
-37
lines changed
 

‎packages/examples/packages/send-flow/snap.manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"url": "https://github.com/MetaMask/snaps.git"
88
},
99
"source": {
10-
"shasum": "TBt+UJnVWgfYB6xDuI94gT0Ns1WPw4LdJKFcxeUH8Rg=",
10+
"shasum": "K4N1OVwbY1dfSZpc4QvAWprZVI0FQSR8KB5NZoOXPFY=",
1111
"location": {
1212
"npm": {
1313
"filePath": "dist/bundle.js",

‎packages/examples/packages/send-flow/src/components/SendFlow.tsx

-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import type { Account, Currency } from '../types';
1515
* @property selectedCurrency - The selected currency to display.
1616
* @property total - The total cost of the transaction.
1717
* @property fees - The fees for the transaction.
18-
* @property displayClearIcon - Whether to display the clear icon or not.
1918
* @property flushToAddress - Whether to flush the address field or not.
2019
* @property errors - The form errors.
2120
*/
@@ -25,7 +24,6 @@ export type SendFlowProps = {
2524
selectedCurrency: 'BTC' | '$';
2625
total: Currency;
2726
fees: Currency;
28-
displayClearIcon: boolean;
2927
flushToAddress?: boolean;
3028
errors?: {
3129
amount?: string;
@@ -43,7 +41,6 @@ export type SendFlowProps = {
4341
* @param props.total - The total cost of the transaction.
4442
* @param props.errors - The form errors.
4543
* @param props.fees - The fees for the transaction.
46-
* @param props.displayClearIcon - Whether to display the clear icon or not.
4744
* @param props.flushToAddress - Whether to flush the address field or not.
4845
* @returns The SendFlow component.
4946
*/
@@ -53,7 +50,6 @@ export const SendFlow: SnapComponent<SendFlowProps> = ({
5350
selectedCurrency,
5451
total,
5552
fees,
56-
displayClearIcon,
5753
flushToAddress,
5854
errors,
5955
}) => {
@@ -66,7 +62,6 @@ export const SendFlow: SnapComponent<SendFlowProps> = ({
6662
accounts={accounts}
6763
selectedCurrency={selectedCurrency}
6864
flushToAddress={flushToAddress}
69-
displayClearIcon={displayClearIcon}
7065
errors={errors}
7166
/>
7267
<TransactionSummary fees={fees} total={total} />

‎packages/examples/packages/send-flow/src/components/SendForm.tsx

+3-16
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import {
66
Icon,
77
Image,
88
Input,
9+
AddressInput,
910
Text,
1011
type SnapComponent,
1112
} from '@metamask/snaps-sdk/jsx';
1213

1314
import { AccountSelector } from './AccountSelector';
1415
import btcIcon from '../images/btc.svg';
15-
import jazzicon3 from '../images/jazzicon3.svg';
1616
import type { Account, SendFormErrors } from '../types';
1717

1818
/**
@@ -22,15 +22,13 @@ import type { Account, SendFormErrors } from '../types';
2222
* @property accounts - The available accounts.
2323
* @property errors - The form errors.
2424
* @property selectedCurrency - The selected currency to display.
25-
* @property displayClearIcon - Whether to display the clear icon or not.
2625
* @property flushToAddress - Whether to flush the address field or not.
2726
*/
2827
export type SendFormProps = {
2928
selectedAccount: string;
3029
accounts: Account[];
3130
errors?: SendFormErrors;
3231
selectedCurrency: 'BTC' | '$';
33-
displayClearIcon: boolean;
3432
flushToAddress?: boolean;
3533
};
3634

@@ -42,7 +40,6 @@ export type SendFormProps = {
4240
* @param props.accounts - The available accounts.
4341
* @param props.errors - The form errors.
4442
* @param props.selectedCurrency - The selected currency to display.
45-
* @param props.displayClearIcon - Whether to display the clear icon or not.
4643
* @param props.flushToAddress - Whether to flush the address field or not.
4744
* @returns The SendForm component.
4845
*/
@@ -51,7 +48,6 @@ export const SendForm: SnapComponent<SendFormProps> = ({
5148
accounts,
5249
errors,
5350
selectedCurrency,
54-
displayClearIcon,
5551
flushToAddress,
5652
}) => (
5753
<Form name="sendForm">
@@ -69,21 +65,12 @@ export const SendForm: SnapComponent<SendFormProps> = ({
6965
</Box>
7066
</Field>
7167
<Field label="To account" error={errors?.to}>
72-
<Box>
73-
<Image src={jazzicon3} />
74-
</Box>
75-
<Input
68+
<AddressInput
7669
name="to"
70+
chainId="eip155:0"
7771
placeholder="Enter receiving address"
7872
value={flushToAddress ? '' : undefined}
7973
/>
80-
{displayClearIcon && (
81-
<Box>
82-
<Button name="clear">
83-
<Icon name="close" color="primary" />
84-
</Button>
85-
</Box>
86-
)}
8774
</Field>
8875
</Form>
8976
);

‎packages/examples/packages/send-flow/src/images/jazzicon3.svg

-11
This file was deleted.

‎packages/examples/packages/send-flow/src/index.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ export const onUserInput: OnUserInputHandler = async ({
111111
selectedCurrency={selectedCurrency}
112112
total={total}
113113
fees={fees}
114-
displayClearIcon={Boolean(sendForm.to) && sendForm.to !== ''}
115114
errors={formErrors}
116115
/>
117116
),
@@ -138,7 +137,6 @@ export const onUserInput: OnUserInputHandler = async ({
138137
total={total}
139138
fees={fees}
140139
flushToAddress={true}
141-
displayClearIcon={false}
142140
errors={formErrors}
143141
/>
144142
),

‎packages/examples/packages/send-flow/src/utils.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ export async function generateSendFlow({
3737
selectedCurrency="BTC"
3838
total={{ amount: 0, fiat: 0 }}
3939
fees={fees}
40-
displayClearIcon={false}
4140
/>
4241
),
4342
context: {

‎packages/snaps-sdk/src/jsx/validation.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ import type {
4141
StringElement,
4242
} from './component';
4343
import type {
44-
AddressInputElement,
4544
AssetSelectorElement,
4645
AvatarElement,
4746
SkeletonElement,
4847
AddressElement,
48+
AddressInputElement,
4949
BoldElement,
5050
BoxElement,
5151
ButtonElement,

0 commit comments

Comments
 (0)
Please sign in to comment.