Skip to content

Commit

Permalink
Revert "Add AccountSelector component (#2764)"
Browse files Browse the repository at this point in the history
This reverts commit 73d00a0.
  • Loading branch information
GuillaumeRx committed Oct 7, 2024
1 parent 72e23f0 commit edb935d
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 165 deletions.

This file was deleted.

52 changes: 0 additions & 52 deletions packages/snaps-sdk/src/jsx/components/form/AccountSelector.ts

This file was deleted.

3 changes: 0 additions & 3 deletions packages/snaps-sdk/src/jsx/components/form/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { AccountSelectorElement } from './AccountSelector';
import type { ButtonElement } from './Button';
import type { CheckboxElement } from './Checkbox';
import type { DropdownElement } from './Dropdown';
Expand All @@ -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';
Expand All @@ -27,7 +25,6 @@ export * from './Selector';
export * from './SelectorOption';

export type StandardFormElement =
| AccountSelectorElement
| ButtonElement
| CheckboxElement
| FormElement
Expand Down
65 changes: 0 additions & 65 deletions packages/snaps-sdk/src/jsx/validation.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import {
Selector,
SelectorOption,
Section,
AccountSelector,
} from './components';
import {
AddressStruct,
Expand Down Expand Up @@ -70,7 +69,6 @@ import {
SelectorStruct,
SectionStruct,
NotificationComponentsStruct,
AccountSelectorStruct,
} from './validation';

describe('KeyStruct', () => {
Expand Down Expand Up @@ -958,69 +956,6 @@ describe('FileInputStruct', () => {
});
});

describe('AccountSelectorStruct', () => {
it.each([
<AccountSelector
name="account"
title="From Account"
chainId="bip122:000000000019d6689c085ae165831e93"
selectedAddress="128Lkh3S7CkDTBZ8W7BbpsN3YYizJMp8p6"
/>,
<AccountSelector
name="account"
title="From Account"
chainId="eip155:1"
selectedAddress="0x1234567890123456789012345678901234567890"
/>,
])('validates an account picker element', (value) => {
expect(is(value, AccountSelectorStruct)).toBe(true);
});

it.each([
'foo',
42,
null,
undefined,
{},
[],
// @ts-expect-error - Invalid props.
<AccountSelector />,
// @ts-expect-error - Invalid props.
<AccountSelector>
<Text>foo</Text>
</AccountSelector>,
// @ts-expect-error - Invalid props.
<AccountSelector name="account" />,
// @ts-expect-error - Invalid props.
<AccountSelector title="From Account" />,
// @ts-expect-error - Invalid props.
<AccountSelector chainId="bip122:000000000019d6689c085ae165831e93" />,
// @ts-expect-error - Invalid props.
<AccountSelector selectedAddress="128Lkh3S7CkDTBZ8W7BbpsN3YYizJMp8p6" />,
<AccountSelector
name="account"
title="From Account"
chainId="foo:bar"
selectedAddress="0x1234567890123456789012345678901234567890"
/>,
<AccountSelector
name="account"
title="From Account"
chainId="eip155:1"
selectedAddress="0x123"
/>,
<Text>foo</Text>,
<Box>
<Text>foo</Text>
</Box>,
<Row label="label">
<Image src="<svg />" alt="alt" />
</Row>,
])('does not validate "%p"', (value) => {
expect(is(value, AddressStruct)).toBe(false);
});
});

describe('SelectorStruct', () => {
it.each([
<Selector name="foo" title="Title">
Expand Down
20 changes: 0 additions & 20 deletions packages/snaps-sdk/src/jsx/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ import {
refine,
} from '@metamask/superstruct';
import {
CaipAccountAddressStruct,
CaipAccountIdStruct,
CaipChainIdStruct,
hasProperty,
HexChecksumAddressStruct,
isPlainObject,
Expand All @@ -49,7 +47,6 @@ import type {
StringElement,
} from './component';
import {
type AccountSelectorElement,
type AddressElement,
type BoldElement,
type BoxElement,
Expand Down Expand Up @@ -334,22 +331,6 @@ export const FileInputStruct: Describe<FileInputElement> = element(
},
);

/**
* A struct for the {@link AccountSelectorElement} type.
*/
export const AccountSelectorStruct: Describe<AccountSelectorElement> = element(
'AccountSelector',
{
name: string(),
title: string(),
chainId: CaipChainIdStruct as unknown as Struct<
Infer<typeof CaipChainIdStruct>,
Infer<typeof CaipChainIdStruct>
>,
selectedAddress: CaipAccountAddressStruct,
},
);

/**
* A subset of JSX elements that represent the tuple Box + Input of the Field children.
*/
Expand Down Expand Up @@ -843,7 +824,6 @@ export const JSXElementStruct: Describe<JSXElement> = typedUnion([
SelectorStruct,
SelectorOptionStruct,
SectionStruct,
AccountSelectorStruct,
]);

/**
Expand Down

0 comments on commit edb935d

Please sign in to comment.