diff --git a/packages/snaps-sdk/src/jsx/components/form/AccountSelector.test.tsx b/packages/snaps-sdk/src/jsx/components/form/AccountSelector.test.tsx deleted file mode 100644 index 7904e60cbf..0000000000 --- a/packages/snaps-sdk/src/jsx/components/form/AccountSelector.test.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import { AccountSelector } from './AccountSelector'; - -describe('AccountSelector', () => { - it('returns an account selector element', () => { - const result = ( - - ); - - expect(result).toStrictEqual({ - type: 'AccountSelector', - props: { - name: 'account', - title: 'From account', - chainId: 'bip122:p2wpkh', - selectedAddress: 'bc1qc8dwyqua9elc3mzcxk93c70kjz8tcc92x0a8a6', - }, - key: null, - }); - }); -}); diff --git a/packages/snaps-sdk/src/jsx/components/form/AccountSelector.ts b/packages/snaps-sdk/src/jsx/components/form/AccountSelector.ts deleted file mode 100644 index 78f54cf63b..0000000000 --- a/packages/snaps-sdk/src/jsx/components/form/AccountSelector.ts +++ /dev/null @@ -1,52 +0,0 @@ -import type { CaipAccountAddress, CaipChainId } from '@metamask/utils'; - -import { createSnapComponent } from '../../component'; - -/** - * The props of the {@link AccountSelector} component. - * - * @property name - The name of the account selector. This is used to identify the - * state in the form data. - * @property title - The title of the account selector. This is displayed in the UI. - * @property chainId - The chain ID of the account selector. This should be a valid CAIP-2 chain ID. - * @property selectedAddress - The default selected address of the account selector. This should be a - * valid CAIP-10 account address. - */ -export type AccountSelectorProps = { - name: string; - title: string; - chainId: CaipChainId; - selectedAddress: CaipAccountAddress; -}; - -const TYPE = 'AccountSelector'; - -/** - * An account selector component, which is used to create an account selector. - * - * This component does not accept any children. - * - * @param props - The props of the component. - * @param props.name - The name of the account selector field. This is used to identify the - * state in the form data. - * @param props.title - The title of the account selector field. This is displayed in the UI. - * @param props.chainId - The chain ID of the account selector. This should be a valid CAIP-2 chain ID. - * @param props.selectedAddress - The selected address of the account selector. This should be a - * valid CAIP-10 account address. - * @returns An account selector element. - * @example - * - * @example - * - */ -export const AccountSelector = createSnapComponent< - AccountSelectorProps, - typeof TYPE ->(TYPE); - -/** - * An account selector element. - * - * @see AccountSelector - */ -export type AccountSelectorElement = ReturnType; diff --git a/packages/snaps-sdk/src/jsx/components/form/index.ts b/packages/snaps-sdk/src/jsx/components/form/index.ts index 4e47f9e9d0..3dc4221376 100644 --- a/packages/snaps-sdk/src/jsx/components/form/index.ts +++ b/packages/snaps-sdk/src/jsx/components/form/index.ts @@ -1,4 +1,3 @@ -import type { AccountSelectorElement } from './AccountSelector'; import type { ButtonElement } from './Button'; import type { CheckboxElement } from './Checkbox'; import type { DropdownElement } from './Dropdown'; @@ -12,7 +11,6 @@ import type { RadioGroupElement } from './RadioGroup'; import type { SelectorElement } from './Selector'; import type { SelectorOptionElement } from './SelectorOption'; -export * from './AccountSelector'; export * from './Button'; export * from './Checkbox'; export * from './Dropdown'; @@ -27,7 +25,6 @@ export * from './Selector'; export * from './SelectorOption'; export type StandardFormElement = - | AccountSelectorElement | ButtonElement | CheckboxElement | FormElement diff --git a/packages/snaps-sdk/src/jsx/validation.test.tsx b/packages/snaps-sdk/src/jsx/validation.test.tsx index ff42634d56..c58e462d1d 100644 --- a/packages/snaps-sdk/src/jsx/validation.test.tsx +++ b/packages/snaps-sdk/src/jsx/validation.test.tsx @@ -32,7 +32,6 @@ import { Selector, SelectorOption, Section, - AccountSelector, } from './components'; import { AddressStruct, @@ -70,7 +69,6 @@ import { SelectorStruct, SectionStruct, NotificationComponentsStruct, - AccountSelectorStruct, } from './validation'; describe('KeyStruct', () => { @@ -958,69 +956,6 @@ describe('FileInputStruct', () => { }); }); -describe('AccountSelectorStruct', () => { - it.each([ - , - , - ])('validates an account picker element', (value) => { - expect(is(value, AccountSelectorStruct)).toBe(true); - }); - - it.each([ - 'foo', - 42, - null, - undefined, - {}, - [], - // @ts-expect-error - Invalid props. - , - // @ts-expect-error - Invalid props. - - foo - , - // @ts-expect-error - Invalid props. - , - // @ts-expect-error - Invalid props. - , - // @ts-expect-error - Invalid props. - , - // @ts-expect-error - Invalid props. - , - , - , - foo, - - foo - , - - alt - , - ])('does not validate "%p"', (value) => { - expect(is(value, AddressStruct)).toBe(false); - }); -}); - describe('SelectorStruct', () => { it.each([ diff --git a/packages/snaps-sdk/src/jsx/validation.ts b/packages/snaps-sdk/src/jsx/validation.ts index b07da65ffb..8da02b5080 100644 --- a/packages/snaps-sdk/src/jsx/validation.ts +++ b/packages/snaps-sdk/src/jsx/validation.ts @@ -20,9 +20,7 @@ import { refine, } from '@metamask/superstruct'; import { - CaipAccountAddressStruct, CaipAccountIdStruct, - CaipChainIdStruct, hasProperty, HexChecksumAddressStruct, isPlainObject, @@ -49,7 +47,6 @@ import type { StringElement, } from './component'; import { - type AccountSelectorElement, type AddressElement, type BoldElement, type BoxElement, @@ -334,22 +331,6 @@ export const FileInputStruct: Describe = element( }, ); -/** - * A struct for the {@link AccountSelectorElement} type. - */ -export const AccountSelectorStruct: Describe = element( - 'AccountSelector', - { - name: string(), - title: string(), - chainId: CaipChainIdStruct as unknown as Struct< - Infer, - Infer - >, - selectedAddress: CaipAccountAddressStruct, - }, -); - /** * A subset of JSX elements that represent the tuple Box + Input of the Field children. */ @@ -843,7 +824,6 @@ export const JSXElementStruct: Describe = typedUnion([ SelectorStruct, SelectorOptionStruct, SectionStruct, - AccountSelectorStruct, ]); /**