From 0c429d448628ee284dbafe86de5361c08d594216 Mon Sep 17 00:00:00 2001 From: Maarten Zuidhoorn Date: Thu, 20 Jun 2024 15:10:25 +0200 Subject: [PATCH 01/10] Support conditional children in most JSX components --- packages/snaps-sdk/CONTRIBUTING.md | 96 +++++++++++++++++ packages/snaps-sdk/src/jsx/component.ts | 7 +- .../snaps-sdk/src/jsx/components/Box.test.tsx | 18 ++++ packages/snaps-sdk/src/jsx/components/Box.ts | 2 +- .../src/jsx/components/Heading.test.tsx | 17 +++ .../src/jsx/components/Link.test.tsx | 18 ++++ packages/snaps-sdk/src/jsx/components/Link.ts | 2 +- packages/snaps-sdk/src/jsx/components/Text.ts | 2 +- .../src/jsx/components/Tooltip.test.tsx | 102 ++++++++++++++++++ .../snaps-sdk/src/jsx/components/Tooltip.ts | 1 + .../src/jsx/components/form/Dropdown.test.tsx | 69 ++++++++++++ .../src/jsx/components/form/Dropdown.ts | 4 +- .../src/jsx/components/form/Field.ts | 3 +- .../snaps-sdk/src/jsx/components/form/Form.ts | 2 +- .../src/jsx/components/form/Option.test.tsx | 34 ++++++ .../src/jsx/components/form/Option.ts | 3 +- .../jsx/components/formatting/Bold.test.tsx | 17 +++ .../src/jsx/components/formatting/Bold.ts | 1 + .../jsx/components/formatting/Italic.test.tsx | 17 +++ .../src/jsx/components/formatting/Italic.ts | 1 + packages/snaps-sdk/src/jsx/validation.ts | 26 +++-- packages/snaps-utils/src/ui.test.tsx | 39 +++++++ packages/snaps-utils/src/ui.tsx | 14 ++- 23 files changed, 474 insertions(+), 21 deletions(-) create mode 100644 packages/snaps-sdk/CONTRIBUTING.md create mode 100644 packages/snaps-sdk/src/jsx/components/Tooltip.test.tsx create mode 100644 packages/snaps-sdk/src/jsx/components/form/Dropdown.test.tsx create mode 100644 packages/snaps-sdk/src/jsx/components/form/Option.test.tsx diff --git a/packages/snaps-sdk/CONTRIBUTING.md b/packages/snaps-sdk/CONTRIBUTING.md new file mode 100644 index 0000000000..2c6be6e6ab --- /dev/null +++ b/packages/snaps-sdk/CONTRIBUTING.md @@ -0,0 +1,96 @@ +# Contributing + +## Adding new JSX components + +The MetaMask Snaps SDK uses JSX components for building user interfaces in +Snaps. To add a new component, follow these steps: + +1. Create a new file in the `src/jsx/components` directory, optionally in a + subdirectory if the component is part of a group of related components. +2. It is recommended to copy an existing component file and modify it to create + the new component. +3. Create a test for the new component, following the existing test files for + the other components. +4. Add the new component to the `src/jsx/components/index.ts` file, exporting it + from the file. + - This file also contains a `JSXElement` union type that should + be updated to include the new component. +5. Add validation for the component to `src/jsx/validation.ts`, making sure to + use the `Describe` helper type to ensure that the component is correctly + validated. + - Make sure to add tests for the validation in `src/jsx/validation.test.ts` + as well. +6. If the component is stateful, make sure to add it to the + `SnapInterfaceController` too. + - You can use [this PR](https://github.com/MetaMask/snaps/pull/2501) as a + reference. + +### Component props + +When adding a new component, make sure to document the props that the component +accepts. This can be done by adding a JSDoc comment to the component function +declaration, like so: + +```typescript +/** + * The props of the {@link Dropdown} component. + * + * @property name - The name of the dropdown. This is used to identify the + * state in the form data. + * @property value - The selected value of the dropdown. + * @property children - The children of the dropdown. + */ +export type DropdownProps = { + name: string; + value?: string | undefined; + children: MaybeArray; +}; +``` + +The props type should be exported from the component file and used in the +component function declaration, like so: + +```typescript +// ... +export const Dropdown = createSnapComponent(TYPE); +``` + +To ensure consistency, make sure to follow the existing patterns in the codebase +when documenting component props. + +#### Optional props + +Optional props should be both marked with a `?` in the type definition, and +also include `undefined` in the type definition. This is to ensure that the +component can be used with or without TypeScript's exact optional props feature. + +```typescript +export type ComponentProps = { + value?: string | undefined; +}; +``` + +#### Children + +In most cases, the children prop should be defined as `MaybeArray` to allow for +both a single child element or an array of child elements. There are some +exceptions to this rule, such as when the component only accepts a single child +element (e.g., `Field`). + +Children should also accept `boolean` and `null` values to allow for conditional +rendering of child elements. + +```typescript +export type ComponentProps = { + children: MaybeArray; +}; +``` + +If the children are optional, make sure to include `undefined` in the type and +add the `?` to the prop definition. + +```typescript +export type ComponentProps = { + children?: MaybeArray | undefined; +}; +``` diff --git a/packages/snaps-sdk/src/jsx/component.ts b/packages/snaps-sdk/src/jsx/component.ts index cb6ad32411..c17663772a 100644 --- a/packages/snaps-sdk/src/jsx/component.ts +++ b/packages/snaps-sdk/src/jsx/component.ts @@ -64,12 +64,13 @@ export type MaybeArray = Nestable; /** * A JSX node, which can be an element, a string, null, or an array of nodes. */ -export type SnapNode = MaybeArray; +export type SnapNode = MaybeArray; /** - * A JSX string element, which can be a string or an array of strings. + * A JSX string element, which can be a string or an array of strings, or + * booleans (for conditional rendering). */ -export type StringElement = MaybeArray; +export type StringElement = MaybeArray; /** * A JSX component. diff --git a/packages/snaps-sdk/src/jsx/components/Box.test.tsx b/packages/snaps-sdk/src/jsx/components/Box.test.tsx index b21bdadaaa..a03c797dbe 100644 --- a/packages/snaps-sdk/src/jsx/components/Box.test.tsx +++ b/packages/snaps-sdk/src/jsx/components/Box.test.tsx @@ -89,4 +89,22 @@ describe('Box', () => { }, }); }); + + it('renders a box with a conditional', () => { + const result = ( + + {false && Hello} + + ); + + expect(result).toStrictEqual({ + type: 'Box', + key: null, + props: { + direction: 'horizontal', + alignment: 'space-between', + children: false, + }, + }); + }); }); diff --git a/packages/snaps-sdk/src/jsx/components/Box.ts b/packages/snaps-sdk/src/jsx/components/Box.ts index 417616a45d..f50c7c6eea 100644 --- a/packages/snaps-sdk/src/jsx/components/Box.ts +++ b/packages/snaps-sdk/src/jsx/components/Box.ts @@ -10,7 +10,7 @@ import { createSnapComponent } from '../component'; */ export type BoxProps = { // We can't use `JSXElement` because it causes a circular reference. - children: MaybeArray; + children: MaybeArray; direction?: 'vertical' | 'horizontal' | undefined; alignment?: | 'start' diff --git a/packages/snaps-sdk/src/jsx/components/Heading.test.tsx b/packages/snaps-sdk/src/jsx/components/Heading.test.tsx index 5e33b8b4a1..cc2add3b04 100644 --- a/packages/snaps-sdk/src/jsx/components/Heading.test.tsx +++ b/packages/snaps-sdk/src/jsx/components/Heading.test.tsx @@ -24,4 +24,21 @@ describe('Heading', () => { }, }); }); + + it('renders a heading with a conditional value', () => { + const result = ( + + Hello + {false && 'world'} + + ); + + expect(result).toStrictEqual({ + type: 'Heading', + key: null, + props: { + children: ['Hello', false], + }, + }); + }); }); diff --git a/packages/snaps-sdk/src/jsx/components/Link.test.tsx b/packages/snaps-sdk/src/jsx/components/Link.test.tsx index 309a41348a..a28fedd27f 100644 --- a/packages/snaps-sdk/src/jsx/components/Link.test.tsx +++ b/packages/snaps-sdk/src/jsx/components/Link.test.tsx @@ -26,4 +26,22 @@ describe('Link', () => { }, }); }); + + it('renders a link with a conditional value', () => { + const result = ( + + Hello + {false && 'world'} + + ); + + expect(result).toStrictEqual({ + type: 'Link', + key: null, + props: { + href: 'https://example.com', + children: ['Hello', false], + }, + }); + }); }); diff --git a/packages/snaps-sdk/src/jsx/components/Link.ts b/packages/snaps-sdk/src/jsx/components/Link.ts index 8d22b7404c..c30ee70e52 100644 --- a/packages/snaps-sdk/src/jsx/components/Link.ts +++ b/packages/snaps-sdk/src/jsx/components/Link.ts @@ -6,7 +6,7 @@ import type { StandardFormattingElement } from './formatting'; * The children of the {@link Link} component. */ export type LinkChildren = MaybeArray< - string | StandardFormattingElement | null + string | StandardFormattingElement | boolean | null >; /** diff --git a/packages/snaps-sdk/src/jsx/components/Text.ts b/packages/snaps-sdk/src/jsx/components/Text.ts index 895dbb2ba7..4f62950a6d 100644 --- a/packages/snaps-sdk/src/jsx/components/Text.ts +++ b/packages/snaps-sdk/src/jsx/components/Text.ts @@ -7,7 +7,7 @@ import type { LinkElement } from './Link'; * The children of the {@link Text} component. */ export type TextChildren = MaybeArray< - string | StandardFormattingElement | LinkElement | null + string | boolean | StandardFormattingElement | LinkElement | null >; /** diff --git a/packages/snaps-sdk/src/jsx/components/Tooltip.test.tsx b/packages/snaps-sdk/src/jsx/components/Tooltip.test.tsx new file mode 100644 index 0000000000..3a63cb541b --- /dev/null +++ b/packages/snaps-sdk/src/jsx/components/Tooltip.test.tsx @@ -0,0 +1,102 @@ +import { Link } from './Link'; +import { Text } from './Text'; +import { Tooltip } from './Tooltip'; + +describe('Tooltip', () => { + it('renders a tooltip', () => { + const result = ( + Hello}> + World + + ); + + expect(result).toStrictEqual({ + type: 'Tooltip', + props: { + children: { + type: 'Text', + props: { + children: 'World', + }, + key: null, + }, + content: { + type: 'Text', + props: { + children: 'Hello', + }, + key: null, + }, + }, + key: null, + }); + }); + + it('renders a tooltip with a string content', () => { + const result = ( + + World + + ); + + expect(result).toStrictEqual({ + type: 'Tooltip', + props: { + children: { + type: 'Text', + props: { + children: 'World', + }, + key: null, + }, + content: 'Hello', + }, + key: null, + }); + }); + + it('renders a tooltip with a link content', () => { + const result = ( + Link}> + World + + ); + + expect(result).toStrictEqual({ + type: 'Tooltip', + props: { + children: { + type: 'Text', + props: { + children: 'World', + }, + key: null, + }, + content: { + type: 'Link', + props: { + children: 'Link', + href: 'https://example.com', + }, + key: null, + }, + }, + key: null, + }); + }); + + it('renders a tooltip with a conditional value', () => { + const result = ( + {false && World} + ); + + expect(result).toStrictEqual({ + type: 'Tooltip', + props: { + children: false, + content: 'Hello', + }, + key: null, + }); + }); +}); diff --git a/packages/snaps-sdk/src/jsx/components/Tooltip.ts b/packages/snaps-sdk/src/jsx/components/Tooltip.ts index c11795e8cd..e1932e94c8 100644 --- a/packages/snaps-sdk/src/jsx/components/Tooltip.ts +++ b/packages/snaps-sdk/src/jsx/components/Tooltip.ts @@ -9,6 +9,7 @@ export type TooltipChildren = | StandardFormattingElement | LinkElement | ImageElement + | boolean | null; /** diff --git a/packages/snaps-sdk/src/jsx/components/form/Dropdown.test.tsx b/packages/snaps-sdk/src/jsx/components/form/Dropdown.test.tsx new file mode 100644 index 0000000000..a43e4f91f7 --- /dev/null +++ b/packages/snaps-sdk/src/jsx/components/form/Dropdown.test.tsx @@ -0,0 +1,69 @@ +import { Dropdown } from './Dropdown'; +import { Option } from './Option'; + +describe('Dropdown', () => { + it('renders a dropdown with options', () => { + const result = ( + + + + + ); + + expect(result).toStrictEqual({ + type: 'Dropdown', + props: { + name: 'dropdown', + value: 'foo', + children: [ + { + type: 'Option', + props: { + value: 'foo', + children: 'Foo', + }, + key: null, + }, + { + type: 'Option', + props: { + value: 'bar', + children: 'Bar', + }, + key: null, + }, + ], + }, + key: null, + }); + }); + + it('renders a dropdown with a conditional option', () => { + const result = ( + + + {false && } + + ); + + expect(result).toStrictEqual({ + type: 'Dropdown', + props: { + name: 'dropdown', + value: 'foo', + children: [ + { + type: 'Option', + props: { + value: 'foo', + children: 'Foo', + }, + key: null, + }, + false, + ], + }, + key: null, + }); + }); +}); diff --git a/packages/snaps-sdk/src/jsx/components/form/Dropdown.ts b/packages/snaps-sdk/src/jsx/components/form/Dropdown.ts index 090907c993..66aa4c3ef9 100644 --- a/packages/snaps-sdk/src/jsx/components/form/Dropdown.ts +++ b/packages/snaps-sdk/src/jsx/components/form/Dropdown.ts @@ -10,10 +10,10 @@ import type { OptionElement } from './Option'; * @property value - The selected value of the dropdown. * @property children - The children of the dropdown. */ -type DropdownProps = { +export type DropdownProps = { name: string; value?: string | undefined; - children: MaybeArray; + children: MaybeArray; }; const TYPE = 'Dropdown'; diff --git a/packages/snaps-sdk/src/jsx/components/form/Field.ts b/packages/snaps-sdk/src/jsx/components/form/Field.ts index d2f87f38ba..093a949048 100644 --- a/packages/snaps-sdk/src/jsx/components/form/Field.ts +++ b/packages/snaps-sdk/src/jsx/components/form/Field.ts @@ -20,7 +20,8 @@ export type FieldProps = { | DropdownElement | FileInputElement | InputElement - | CheckboxElement; + | CheckboxElement + | boolean; }; const TYPE = 'Field'; diff --git a/packages/snaps-sdk/src/jsx/components/form/Form.ts b/packages/snaps-sdk/src/jsx/components/form/Form.ts index be1671c22f..e85ee6847d 100644 --- a/packages/snaps-sdk/src/jsx/components/form/Form.ts +++ b/packages/snaps-sdk/src/jsx/components/form/Form.ts @@ -11,7 +11,7 @@ import { createSnapComponent } from '../../component'; * the event handler. */ export type FormProps = { - children: MaybeArray; + children: MaybeArray; name: string; }; diff --git a/packages/snaps-sdk/src/jsx/components/form/Option.test.tsx b/packages/snaps-sdk/src/jsx/components/form/Option.test.tsx new file mode 100644 index 0000000000..6dba275bb6 --- /dev/null +++ b/packages/snaps-sdk/src/jsx/components/form/Option.test.tsx @@ -0,0 +1,34 @@ +import { Option } from './Option'; + +describe('Option', () => { + it('renders a dropdown option', () => { + const result = ; + + expect(result).toStrictEqual({ + type: 'Option', + props: { + value: 'foo', + children: 'Foo', + }, + key: null, + }); + }); + + it('renders a dropdown option with a conditional value', () => { + const result = ( + + ); + + expect(result).toStrictEqual({ + type: 'Option', + props: { + value: 'foo', + children: ['Foo', false], + }, + key: null, + }); + }); +}); diff --git a/packages/snaps-sdk/src/jsx/components/form/Option.ts b/packages/snaps-sdk/src/jsx/components/form/Option.ts index 91b6484ad2..0b571f6c6f 100644 --- a/packages/snaps-sdk/src/jsx/components/form/Option.ts +++ b/packages/snaps-sdk/src/jsx/components/form/Option.ts @@ -1,3 +1,4 @@ +import type { StringElement } from '../../component'; import { createSnapComponent } from '../../component'; /** @@ -9,7 +10,7 @@ import { createSnapComponent } from '../../component'; */ type OptionProps = { value: string; - children: string; + children: StringElement; }; const TYPE = 'Option'; diff --git a/packages/snaps-sdk/src/jsx/components/formatting/Bold.test.tsx b/packages/snaps-sdk/src/jsx/components/formatting/Bold.test.tsx index 225c42029c..dcd8dc95a2 100644 --- a/packages/snaps-sdk/src/jsx/components/formatting/Bold.test.tsx +++ b/packages/snaps-sdk/src/jsx/components/formatting/Bold.test.tsx @@ -24,4 +24,21 @@ describe('Bold', () => { key: null, }); }); + + it('returns a bold element with a conditional value', () => { + const result = ( + + Hello + {false && 'world'} + + ); + + expect(result).toStrictEqual({ + type: 'Bold', + props: { + children: ['Hello', false], + }, + key: null, + }); + }); }); diff --git a/packages/snaps-sdk/src/jsx/components/formatting/Bold.ts b/packages/snaps-sdk/src/jsx/components/formatting/Bold.ts index 93735beeff..4e18db72bb 100644 --- a/packages/snaps-sdk/src/jsx/components/formatting/Bold.ts +++ b/packages/snaps-sdk/src/jsx/components/formatting/Bold.ts @@ -10,6 +10,7 @@ export type BoldChildren = MaybeArray< | string // We have to specify the type here to avoid a circular reference. | SnapElement + | boolean | null >; diff --git a/packages/snaps-sdk/src/jsx/components/formatting/Italic.test.tsx b/packages/snaps-sdk/src/jsx/components/formatting/Italic.test.tsx index 68dcd6d6ea..cb0113352e 100644 --- a/packages/snaps-sdk/src/jsx/components/formatting/Italic.test.tsx +++ b/packages/snaps-sdk/src/jsx/components/formatting/Italic.test.tsx @@ -24,4 +24,21 @@ describe('Italic', () => { key: null, }); }); + + it('returns an italic element with a conditional value', () => { + const result = ( + + Hello + {false && 'world'} + + ); + + expect(result).toStrictEqual({ + type: 'Italic', + props: { + children: ['Hello', false], + }, + key: null, + }); + }); }); diff --git a/packages/snaps-sdk/src/jsx/components/formatting/Italic.ts b/packages/snaps-sdk/src/jsx/components/formatting/Italic.ts index ffa820428b..5a9ec0cd1a 100644 --- a/packages/snaps-sdk/src/jsx/components/formatting/Italic.ts +++ b/packages/snaps-sdk/src/jsx/components/formatting/Italic.ts @@ -8,6 +8,7 @@ export type ItalicChildren = MaybeArray< | string // We have to specify the type here to avoid a circular reference. | SnapElement + | boolean | null >; diff --git a/packages/snaps-sdk/src/jsx/validation.ts b/packages/snaps-sdk/src/jsx/validation.ts index 1c6a2ccc7a..94006a98b3 100644 --- a/packages/snaps-sdk/src/jsx/validation.ts +++ b/packages/snaps-sdk/src/jsx/validation.ts @@ -68,7 +68,7 @@ export const KeyStruct: Describe = nullUnion([string(), number()]); * A struct for the {@link StringElement} type. */ export const StringElementStruct: Describe = maybeArray( - string(), + nullUnion([string(), boolean()]), ); /** @@ -163,7 +163,7 @@ export const InputStruct: Describe = element('Input', { */ export const OptionStruct: Describe = element('Option', { value: string(), - children: string(), + children: StringElementStruct, }); /** @@ -172,7 +172,7 @@ export const OptionStruct: Describe = element('Option', { export const DropdownStruct: Describe = element('Dropdown', { name: string(), value: optional(string()), - children: maybeArray(OptionStruct), + children: maybeArray(nullUnion([OptionStruct, boolean()])), }); /** @@ -199,6 +199,7 @@ export const FieldStruct: Describe = element('Field', { FileInputStruct, InputStruct, CheckboxStruct, + boolean(), ]), }); @@ -208,8 +209,8 @@ export const FieldStruct: Describe = element('Field', { export const FormStruct: Describe = element('Form', { children: maybeArray( // eslint-disable-next-line @typescript-eslint/no-use-before-define - nullable(nullUnion([FieldStruct, lazy(() => BoxChildStruct)])), - ) as unknown as Struct, null>, + nullable(nullUnion([FieldStruct, lazy(() => BoxChildStruct), boolean()])), + ) as unknown as Struct, null>, name: string(), }); @@ -221,6 +222,7 @@ export const BoldStruct: Describe = element('Bold', { nullable( nullUnion([ string(), + boolean(), // eslint-disable-next-line @typescript-eslint/no-use-before-define lazy(() => ItalicStruct) as unknown as Struct< SnapElement @@ -238,6 +240,7 @@ export const ItalicStruct: Describe = element('Italic', { nullable( nullUnion([ string(), + boolean(), // eslint-disable-next-line @typescript-eslint/no-use-before-define lazy(() => BoldStruct) as unknown as Struct< SnapElement @@ -265,8 +268,8 @@ export const AddressStruct: Describe = element('Address', { export const BoxStruct: Describe = element('Box', { children: maybeArray( // eslint-disable-next-line @typescript-eslint/no-use-before-define - nullable(lazy(() => BoxChildStruct)), - ) as unknown as Struct, null>, + nullable(nullUnion([lazy(() => BoxChildStruct), boolean()])), + ) as unknown as Struct, null>, direction: optional(nullUnion([literal('horizontal'), literal('vertical')])), alignment: optional( nullUnion([ @@ -320,7 +323,9 @@ export const ImageStruct: Describe = element('Image', { */ export const LinkStruct: Describe = element('Link', { href: string(), - children: maybeArray(nullable(nullUnion([FormattingStruct, string()]))), + children: maybeArray( + nullable(nullUnion([FormattingStruct, string(), boolean()])), + ), }); /** @@ -328,7 +333,9 @@ export const LinkStruct: Describe = element('Link', { */ export const TextStruct: Describe = element('Text', { children: maybeArray( - nullable(nullUnion([string(), BoldStruct, ItalicStruct, LinkStruct])), + nullable( + nullUnion([string(), boolean(), BoldStruct, ItalicStruct, LinkStruct]), + ), ), alignment: optional( nullUnion([literal('start'), literal('center'), literal('end')]), @@ -345,6 +352,7 @@ export const TooltipChildStruct = nullUnion([ ItalicStruct, LinkStruct, ImageStruct, + boolean(), ]); /** diff --git a/packages/snaps-utils/src/ui.test.tsx b/packages/snaps-utils/src/ui.test.tsx index 8bd5c20f3d..ea60f37c88 100644 --- a/packages/snaps-utils/src/ui.test.tsx +++ b/packages/snaps-utils/src/ui.test.tsx @@ -785,6 +785,45 @@ describe('getJsxChildren', () => { ]); }); + it('removes falsy children from the array', () => { + const element = ( + + Hello + {false && Foo} + World + + ); + + expect(getJsxChildren(element)).toStrictEqual([ + Hello, + World, + ]); + }); + + it('removes falsy children from a text element', () => { + const element = ( + + Hello + {false && 'Foo'} + World + + ); + + expect(getJsxChildren(element)).toStrictEqual(['Hello', 'World']); + }); + + it('removes `true` children from the array', () => { + const element = ( + + Hello + {true} + World + + ); + + expect(getJsxChildren(element)).toStrictEqual(['Hello', 'World']); + }); + it('flattens the children array', () => { const element = ( diff --git a/packages/snaps-utils/src/ui.tsx b/packages/snaps-utils/src/ui.tsx index 6ba648315a..8e6cb66373 100644 --- a/packages/snaps-utils/src/ui.tsx +++ b/packages/snaps-utils/src/ui.tsx @@ -438,6 +438,18 @@ export function hasChildren( return hasProperty(element.props, 'children'); } +/** + * Filter a JSX child to remove `null`, `undefined`, plain booleans, and empty + * strings. + * + * @param child - The JSX child to filter. + * @returns `true` if the child is not `null`, `undefined`, a plain boolean, or + * an empty string, `false` otherwise. + */ +function filterJsxChild(child: JSXElement | string | boolean | null): boolean { + return Boolean(child) && child !== true; +} + /** * Get the children of a JSX element as an array. If the element has only one * child, the child is returned as an array. @@ -450,7 +462,7 @@ export function getJsxChildren(element: JSXElement): (JSXElement | string)[] { if (Array.isArray(element.props.children)) { // @ts-expect-error - Each member of the union type has signatures, but // none of those signatures are compatible with each other. - return element.props.children.filter(Boolean).flat(Infinity); + return element.props.children.filter(filterJsxChild).flat(Infinity); } if (element.props.children) { From c0c31da35456248a47774de14abc2a1f2a4ad787 Mon Sep 17 00:00:00 2001 From: MetaMask Bot Date: Thu, 20 Jun 2024 13:17:51 +0000 Subject: [PATCH 02/10] Update example snaps --- packages/examples/packages/bip32/snap.manifest.json | 2 +- packages/examples/packages/bip44/snap.manifest.json | 2 +- packages/examples/packages/browserify-plugin/snap.manifest.json | 2 +- packages/examples/packages/browserify/snap.manifest.json | 2 +- packages/examples/packages/client-status/snap.manifest.json | 2 +- packages/examples/packages/cronjobs/snap.manifest.json | 2 +- packages/examples/packages/dialogs/snap.manifest.json | 2 +- packages/examples/packages/ethereum-provider/snap.manifest.json | 2 +- packages/examples/packages/ethers-js/snap.manifest.json | 2 +- packages/examples/packages/file-upload/snap.manifest.json | 2 +- packages/examples/packages/get-entropy/snap.manifest.json | 2 +- packages/examples/packages/get-file/snap.manifest.json | 2 +- packages/examples/packages/home-page/snap.manifest.json | 2 +- packages/examples/packages/images/snap.manifest.json | 2 +- packages/examples/packages/interactive-ui/snap.manifest.json | 2 +- .../invoke-snap/packages/consumer-signer/snap.manifest.json | 2 +- .../invoke-snap/packages/core-signer/snap.manifest.json | 2 +- packages/examples/packages/json-rpc/snap.manifest.json | 2 +- packages/examples/packages/jsx/snap.manifest.json | 2 +- packages/examples/packages/lifecycle-hooks/snap.manifest.json | 2 +- packages/examples/packages/localization/snap.manifest.json | 2 +- packages/examples/packages/manage-state/snap.manifest.json | 2 +- packages/examples/packages/network-access/snap.manifest.json | 2 +- packages/examples/packages/notifications/snap.manifest.json | 2 +- packages/examples/packages/rollup-plugin/snap.manifest.json | 2 +- .../examples/packages/signature-insights/snap.manifest.json | 2 +- .../examples/packages/transaction-insights/snap.manifest.json | 2 +- packages/examples/packages/wasm/snap.manifest.json | 2 +- packages/examples/packages/webpack-plugin/snap.manifest.json | 2 +- 29 files changed, 29 insertions(+), 29 deletions(-) diff --git a/packages/examples/packages/bip32/snap.manifest.json b/packages/examples/packages/bip32/snap.manifest.json index 35a97a1475..dced6abb97 100644 --- a/packages/examples/packages/bip32/snap.manifest.json +++ b/packages/examples/packages/bip32/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "7AJkQic0kErNfOuBozGOUaJ5U5Z24yOV28zHL+WEPz0=", + "shasum": "Myfiv00eKUdOQh/6VURJt/NLEHvF7t8p+arvI8ZEy2E=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/bip44/snap.manifest.json b/packages/examples/packages/bip44/snap.manifest.json index ed5acb595d..0c1f0b6412 100644 --- a/packages/examples/packages/bip44/snap.manifest.json +++ b/packages/examples/packages/bip44/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "R/jtwKJg/6gTCuMrphuKHZkTtUlggfwnNgKiOXx11GU=", + "shasum": "kEd5v0Da+ONo/Pemo/W/+Rj+DCBcMlq8UoDkR3j+7hg=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/browserify-plugin/snap.manifest.json b/packages/examples/packages/browserify-plugin/snap.manifest.json index d461c74fa0..1029c477be 100644 --- a/packages/examples/packages/browserify-plugin/snap.manifest.json +++ b/packages/examples/packages/browserify-plugin/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "u7x/swxx6XHT7G0BDY8mJkwcY/mP/i4YmdYaRQ/QKZY=", + "shasum": "AtCtWmMVDhVL7nTsaqqCnm+M9tNQpPsp+i/w3G+dvK0=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/browserify/snap.manifest.json b/packages/examples/packages/browserify/snap.manifest.json index e246e23315..df0aaa0662 100644 --- a/packages/examples/packages/browserify/snap.manifest.json +++ b/packages/examples/packages/browserify/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "105XsceecyaQZ+reC6ZNusiOJVUMBoNSYK4PHvREPQw=", + "shasum": "vMjY250Ko3ULV8mMenZFFKbTfHYY8HLQizQJkOK/Ee0=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/client-status/snap.manifest.json b/packages/examples/packages/client-status/snap.manifest.json index 5aef27eb43..e227bb5819 100644 --- a/packages/examples/packages/client-status/snap.manifest.json +++ b/packages/examples/packages/client-status/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "9Ttl+TbR7gufQzhQx4o/keKeINCjio65rjLWOlP36NM=", + "shasum": "uo2UGVZKuD4tO104OeC7Y2oBkpLPrvJWWyGPJTWPVD4=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/cronjobs/snap.manifest.json b/packages/examples/packages/cronjobs/snap.manifest.json index ff794a8fe1..642b38627e 100644 --- a/packages/examples/packages/cronjobs/snap.manifest.json +++ b/packages/examples/packages/cronjobs/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "0NNqpKgq/+zNokLs67+6vrA+kZxvDnDe9PWrX6X8Goc=", + "shasum": "NuMOVeN5RPc/tuAINdZLD7Q0wccvhS9w0YLCq7JXs8M=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/dialogs/snap.manifest.json b/packages/examples/packages/dialogs/snap.manifest.json index a2a3144243..f0ba60b41c 100644 --- a/packages/examples/packages/dialogs/snap.manifest.json +++ b/packages/examples/packages/dialogs/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "tDbsxyvQUz2VoKmIzIXbLr3mtJfNewiHzoEjW7X6c8k=", + "shasum": "7Zm7WDQ4Dvg8YnbqTacXu0oC3C25O1oMJkPnLW+r5co=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/ethereum-provider/snap.manifest.json b/packages/examples/packages/ethereum-provider/snap.manifest.json index 79ee74c52d..ab6a9fb35a 100644 --- a/packages/examples/packages/ethereum-provider/snap.manifest.json +++ b/packages/examples/packages/ethereum-provider/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "8/P91GreWpqGOWLGAntmd3Kyu6A3WMelRIWUuxKcsGI=", + "shasum": "k0CibdCt3wsBIq47PPqzR193o2VjuddFrcOribmHHmc=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/ethers-js/snap.manifest.json b/packages/examples/packages/ethers-js/snap.manifest.json index afb4738193..0cd225ecbf 100644 --- a/packages/examples/packages/ethers-js/snap.manifest.json +++ b/packages/examples/packages/ethers-js/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "1bLwZCxQusG/VCAswAJ5ohHF6fBgiQtTLhQG1Mby4HI=", + "shasum": "pFmqP6z84qAB39wGZcxFQifiNlDOKT7QBPMeKDKNRwg=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/file-upload/snap.manifest.json b/packages/examples/packages/file-upload/snap.manifest.json index ff9b4d4c18..5b0ca54a5b 100644 --- a/packages/examples/packages/file-upload/snap.manifest.json +++ b/packages/examples/packages/file-upload/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "9m0//6LmoFrxb/Mpkjlr7eNRe9HK92iKJgtqtijlkFw=", + "shasum": "OK/QqfPZc/L7VitrdRypHggyR4/4PnAG/j9erpJfJww=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/get-entropy/snap.manifest.json b/packages/examples/packages/get-entropy/snap.manifest.json index 764d362693..7321643b24 100644 --- a/packages/examples/packages/get-entropy/snap.manifest.json +++ b/packages/examples/packages/get-entropy/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "sKg86tSHApZz49OdruONj63Yhts7zDlyLF2lpf6sguw=", + "shasum": "lFmdEJF/RldpN7/U6roJJm9BqSI5Bb/Whzh6dockQAw=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/get-file/snap.manifest.json b/packages/examples/packages/get-file/snap.manifest.json index ba9cd98a97..024f13679b 100644 --- a/packages/examples/packages/get-file/snap.manifest.json +++ b/packages/examples/packages/get-file/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "0vuiA3xbMMPYDMcE7ytDmXM0B4wwc+b90Ncy114JU24=", + "shasum": "oX0FZa9+kdiEHrtU1sMbUCJMoXpiM9ur2W7WG8s/OW8=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/home-page/snap.manifest.json b/packages/examples/packages/home-page/snap.manifest.json index 34e5273135..1b4e69090f 100644 --- a/packages/examples/packages/home-page/snap.manifest.json +++ b/packages/examples/packages/home-page/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "I2MgHF7MuMKoGGKMSJTB2TAdRNt3ThuAs7N5QLqsFwc=", + "shasum": "YV8OblLCDm1crxxmNDvWA3W8FL5Im3754++56NBSbUY=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/images/snap.manifest.json b/packages/examples/packages/images/snap.manifest.json index 9de489cf9c..88d724b5d4 100644 --- a/packages/examples/packages/images/snap.manifest.json +++ b/packages/examples/packages/images/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "F+ZTNm0I7LeuhiRfFLz34sEn1nQrHEmZ4vbl4V1buiU=", + "shasum": "wquuFPu3DiUvPAXvUsSwnYN6l8SltYivBAlMdfHXLS4=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/interactive-ui/snap.manifest.json b/packages/examples/packages/interactive-ui/snap.manifest.json index d0b3a94d16..1f51775aa1 100644 --- a/packages/examples/packages/interactive-ui/snap.manifest.json +++ b/packages/examples/packages/interactive-ui/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "LSk+GmGMP8byzHX013+Fnj8hPWxFD1ctKE7FwmXwUZ4=", + "shasum": "AYkzHZhTfVEuyZbMIOrbwX+fTYIm97M2rs/iwXEG954=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/invoke-snap/packages/consumer-signer/snap.manifest.json b/packages/examples/packages/invoke-snap/packages/consumer-signer/snap.manifest.json index 951f2c349d..ec3d881736 100644 --- a/packages/examples/packages/invoke-snap/packages/consumer-signer/snap.manifest.json +++ b/packages/examples/packages/invoke-snap/packages/consumer-signer/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "gRoujvXbGzclQmIEgWQQvuKxeeTXt4jt8Kv+SggT5I8=", + "shasum": "7mRu1KFdFY6XxJCVdUBj+vHOgiuEtdbuQ7pNXrwVZdw=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/invoke-snap/packages/core-signer/snap.manifest.json b/packages/examples/packages/invoke-snap/packages/core-signer/snap.manifest.json index cf2c2e4664..290cd9dde2 100644 --- a/packages/examples/packages/invoke-snap/packages/core-signer/snap.manifest.json +++ b/packages/examples/packages/invoke-snap/packages/core-signer/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "pgKvkVBqtJ4sPb6shDMNXiDc1C8apmV4+WfN6ciavKg=", + "shasum": "DMgBdNXhzY5eanbB+zfrshV+NfhYhwcf3N7+OpXOfVg=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/json-rpc/snap.manifest.json b/packages/examples/packages/json-rpc/snap.manifest.json index 5e624673b7..a4ff828cc7 100644 --- a/packages/examples/packages/json-rpc/snap.manifest.json +++ b/packages/examples/packages/json-rpc/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "MDjrpUYVTAW1NxWp544Gn4DcF0t6GoDBQIR3F+zeqtI=", + "shasum": "y06YrfQGNwFwo/kH3HfwJaWNYQu5C6UAKuZlafLWYHk=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/jsx/snap.manifest.json b/packages/examples/packages/jsx/snap.manifest.json index d188a8a74a..1da343a63e 100644 --- a/packages/examples/packages/jsx/snap.manifest.json +++ b/packages/examples/packages/jsx/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "G9fNyPGqUsjlqzMskFKEkdy04ny6eZDBBlXSajmQcN8=", + "shasum": "6qUXiZopZ2r/V/Hd6v8v4OjP2IKpBwMu5WAZjO4Ikgs=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/lifecycle-hooks/snap.manifest.json b/packages/examples/packages/lifecycle-hooks/snap.manifest.json index ec8df0fe47..8f374bf06b 100644 --- a/packages/examples/packages/lifecycle-hooks/snap.manifest.json +++ b/packages/examples/packages/lifecycle-hooks/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "1Vo2b7dgicVZYWx6DMTlnkDnK6UBbk4fmilSsLKwSDg=", + "shasum": "XKLkCOhCgU+yQ2Z+qnX7mSrlduxJeqMqBd5nqKKdz6Q=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/localization/snap.manifest.json b/packages/examples/packages/localization/snap.manifest.json index 10ca7dc40f..05c2117df1 100644 --- a/packages/examples/packages/localization/snap.manifest.json +++ b/packages/examples/packages/localization/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "czQq93Uay+jE8HZvwSViZfMdDQTPn0ClMJaH34VN0dc=", + "shasum": "ZFIL9SrOEbTWaUDGIJZXZJPJFGraq3sPiWM8bC2tLy4=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/manage-state/snap.manifest.json b/packages/examples/packages/manage-state/snap.manifest.json index 230a3667b3..21adc7e4f1 100644 --- a/packages/examples/packages/manage-state/snap.manifest.json +++ b/packages/examples/packages/manage-state/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "Vr0QhrtHYgg7DFczqQc4KEkAkKrOCOAc3ZnNesEVZ+w=", + "shasum": "lvCLamKc9tutH9zT6ECKjMoVgKxaueZxEm2Soy+GIX0=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/network-access/snap.manifest.json b/packages/examples/packages/network-access/snap.manifest.json index dc4a0e6564..f6dbf4f567 100644 --- a/packages/examples/packages/network-access/snap.manifest.json +++ b/packages/examples/packages/network-access/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "6btrG6bcFAWosjSF/ldUuTd3sXNlYxVsRm0gcTJRE2M=", + "shasum": "osTfC/2Y6+aDcYtRj6N7YxVRLfVgNEHAmL7Km8nkwI4=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/notifications/snap.manifest.json b/packages/examples/packages/notifications/snap.manifest.json index b26add1a30..c501cb588b 100644 --- a/packages/examples/packages/notifications/snap.manifest.json +++ b/packages/examples/packages/notifications/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "khCrwAziXNhRJrV8cHp3hfRyudXVBYVB3Cew7YpWDG0=", + "shasum": "xM6Q/SRD4ivSYzwqD2NhmlVQ5v2RHLnEN8ohxWtWcBU=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/rollup-plugin/snap.manifest.json b/packages/examples/packages/rollup-plugin/snap.manifest.json index 03ac09d8de..6ac46703ac 100644 --- a/packages/examples/packages/rollup-plugin/snap.manifest.json +++ b/packages/examples/packages/rollup-plugin/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "7wOe/70O/A4BoUF5+CabV0Rjivnnv2D/xcQ1AlAZdw0=", + "shasum": "9DHCPiYk3FZZqg0rdsH0YIJFL3x8BfUH3jcZAD2gqA4=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/signature-insights/snap.manifest.json b/packages/examples/packages/signature-insights/snap.manifest.json index d0e13487f4..bc64d3110a 100644 --- a/packages/examples/packages/signature-insights/snap.manifest.json +++ b/packages/examples/packages/signature-insights/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "5dDSK6C4XDIT1ukZh1nEimci2a+z0hnqUNEqi7qBNAk=", + "shasum": "SBw2f5d1MMrve92+z+rGmPpJ5hJmyuMi1N6Pza/9nXU=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/transaction-insights/snap.manifest.json b/packages/examples/packages/transaction-insights/snap.manifest.json index 3b2e3be783..8a6d8cdab6 100644 --- a/packages/examples/packages/transaction-insights/snap.manifest.json +++ b/packages/examples/packages/transaction-insights/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "8kKJRiaM18IxSr89svPvmzGIjRszgJvmfLkJxJLyFA4=", + "shasum": "FBzAQuGVTVij6SLPkzro0OmcEPNXKT1NLHjiY3rUcxQ=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/wasm/snap.manifest.json b/packages/examples/packages/wasm/snap.manifest.json index eb730f138c..686dd749ab 100644 --- a/packages/examples/packages/wasm/snap.manifest.json +++ b/packages/examples/packages/wasm/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "DGgaRZmS8KSVnUzCq/V7f9TauAelSCFe9sg3myXrWks=", + "shasum": "xEkfElvZ0ndhl1PcdkqDL6gicxdKxae/aKDl011Tgs4=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/webpack-plugin/snap.manifest.json b/packages/examples/packages/webpack-plugin/snap.manifest.json index 54f4234e1c..f6bc3fabda 100644 --- a/packages/examples/packages/webpack-plugin/snap.manifest.json +++ b/packages/examples/packages/webpack-plugin/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "U4Zhw9ZpNVXJHoYfuYJ4a6j/ynAaFXxZYUYo0DSESVs=", + "shasum": "+x5V9w2ybgWUj2j/DvhKFRI3yo0ng8zhQ/BFN55F7yw=", "location": { "npm": { "filePath": "dist/bundle.js", From d2adce85179722cbcb734e478ebd333df41f5cf9 Mon Sep 17 00:00:00 2001 From: Maarten Zuidhoorn Date: Tue, 25 Jun 2024 10:51:26 +0200 Subject: [PATCH 03/10] Simplify component children types --- packages/snaps-sdk/CONTRIBUTING.md | 8 +- packages/snaps-sdk/jest.config.js | 6 +- packages/snaps-sdk/src/internals/jsx.ts | 2 +- packages/snaps-sdk/src/jsx/component.ts | 12 +- packages/snaps-sdk/src/jsx/components/Box.ts | 4 +- packages/snaps-sdk/src/jsx/components/Link.ts | 6 +- packages/snaps-sdk/src/jsx/components/Text.ts | 6 +- .../src/jsx/components/form/Dropdown.ts | 4 +- .../snaps-sdk/src/jsx/components/form/Form.ts | 4 +- .../src/jsx/components/form/Option.ts | 2 + .../src/jsx/components/formatting/Bold.ts | 8 +- .../src/jsx/components/formatting/Italic.ts | 6 +- .../snaps-sdk/src/jsx/validation.test.tsx | 2 +- packages/snaps-sdk/src/jsx/validation.ts | 109 +++++++++--------- packages/snaps-sdk/tsconfig.json | 3 +- 15 files changed, 90 insertions(+), 92 deletions(-) diff --git a/packages/snaps-sdk/CONTRIBUTING.md b/packages/snaps-sdk/CONTRIBUTING.md index 2c6be6e6ab..236c5563cd 100644 --- a/packages/snaps-sdk/CONTRIBUTING.md +++ b/packages/snaps-sdk/CONTRIBUTING.md @@ -72,8 +72,8 @@ export type ComponentProps = { #### Children -In most cases, the children prop should be defined as `MaybeArray` to allow for -both a single child element or an array of child elements. There are some +In most cases, the children prop should be defined as `SnapsChildren` to allow +for both a single child element or an array of child elements. There are some exceptions to this rule, such as when the component only accepts a single child element (e.g., `Field`). @@ -82,7 +82,7 @@ rendering of child elements. ```typescript export type ComponentProps = { - children: MaybeArray; + children: SnapsChildren; // Nestable; }; ``` @@ -91,6 +91,6 @@ add the `?` to the prop definition. ```typescript export type ComponentProps = { - children?: MaybeArray | undefined; + children?: SnapsChildren | undefined; }; ``` diff --git a/packages/snaps-sdk/jest.config.js b/packages/snaps-sdk/jest.config.js index f188496908..17019b1bfa 100644 --- a/packages/snaps-sdk/jest.config.js +++ b/packages/snaps-sdk/jest.config.js @@ -4,7 +4,11 @@ const { resolve } = require('path'); const baseConfig = require('../../jest.config.base'); module.exports = deepmerge(baseConfig, { - collectCoverageFrom: ['!./src/**/index.ts'], + collectCoverageFrom: [ + '!./src/**/index.ts', + '!./src/types/global.ts', + '!./src/types/images.ts', + ], coverageThreshold: { global: { diff --git a/packages/snaps-sdk/src/internals/jsx.ts b/packages/snaps-sdk/src/internals/jsx.ts index 82d311b9d2..ea9350bbf8 100644 --- a/packages/snaps-sdk/src/internals/jsx.ts +++ b/packages/snaps-sdk/src/internals/jsx.ts @@ -90,7 +90,7 @@ export type Describe = Struct>; */ export function nullUnion( structs: [head: Head, ...tail: Tail], -) { +): Struct | InferStructTuple[number], null> { return union(structs) as unknown as Struct< Infer | InferStructTuple[number], null diff --git a/packages/snaps-sdk/src/jsx/component.ts b/packages/snaps-sdk/src/jsx/component.ts index c17663772a..43ca510f4e 100644 --- a/packages/snaps-sdk/src/jsx/component.ts +++ b/packages/snaps-sdk/src/jsx/component.ts @@ -51,26 +51,22 @@ export type SnapElement< export type Nestable = Type | Nestable[]; /** - * A type that can be a single value or an array of values. + * A type that can be a single value or an array of values, a boolean, or null. * * @template Type - The type that can be an array. - * @example - * type MaybeArrayString = MaybeArray; - * const maybeArrayString: MaybeArrayString = 'hello'; - * const maybeArrayStringArray: MaybeArrayString = ['hello', 'world']; */ -export type MaybeArray = Nestable; +export type SnapsChildren = Nestable; /** * A JSX node, which can be an element, a string, null, or an array of nodes. */ -export type SnapNode = MaybeArray; +export type SnapNode = SnapsChildren; /** * A JSX string element, which can be a string or an array of strings, or * booleans (for conditional rendering). */ -export type StringElement = MaybeArray; +export type StringElement = SnapsChildren; /** * A JSX component. diff --git a/packages/snaps-sdk/src/jsx/components/Box.ts b/packages/snaps-sdk/src/jsx/components/Box.ts index f50c7c6eea..a58b502aac 100644 --- a/packages/snaps-sdk/src/jsx/components/Box.ts +++ b/packages/snaps-sdk/src/jsx/components/Box.ts @@ -1,4 +1,4 @@ -import type { GenericSnapElement, MaybeArray } from '../component'; +import type { GenericSnapElement, SnapsChildren } from '../component'; import { createSnapComponent } from '../component'; /** @@ -10,7 +10,7 @@ import { createSnapComponent } from '../component'; */ export type BoxProps = { // We can't use `JSXElement` because it causes a circular reference. - children: MaybeArray; + children: SnapsChildren; direction?: 'vertical' | 'horizontal' | undefined; alignment?: | 'start' diff --git a/packages/snaps-sdk/src/jsx/components/Link.ts b/packages/snaps-sdk/src/jsx/components/Link.ts index c30ee70e52..047ba7b0ed 100644 --- a/packages/snaps-sdk/src/jsx/components/Link.ts +++ b/packages/snaps-sdk/src/jsx/components/Link.ts @@ -1,13 +1,11 @@ -import type { MaybeArray } from '../component'; +import type { SnapsChildren } from '../component'; import { createSnapComponent } from '../component'; import type { StandardFormattingElement } from './formatting'; /** * The children of the {@link Link} component. */ -export type LinkChildren = MaybeArray< - string | StandardFormattingElement | boolean | null ->; +export type LinkChildren = SnapsChildren; /** * The props of the {@link Link} component. diff --git a/packages/snaps-sdk/src/jsx/components/Text.ts b/packages/snaps-sdk/src/jsx/components/Text.ts index 4f62950a6d..7d18e1c3b0 100644 --- a/packages/snaps-sdk/src/jsx/components/Text.ts +++ b/packages/snaps-sdk/src/jsx/components/Text.ts @@ -1,4 +1,4 @@ -import type { MaybeArray } from '../component'; +import type { SnapsChildren } from '../component'; import { createSnapComponent } from '../component'; import type { StandardFormattingElement } from './formatting'; import type { LinkElement } from './Link'; @@ -6,8 +6,8 @@ import type { LinkElement } from './Link'; /** * The children of the {@link Text} component. */ -export type TextChildren = MaybeArray< - string | boolean | StandardFormattingElement | LinkElement | null +export type TextChildren = SnapsChildren< + string | StandardFormattingElement | LinkElement >; /** diff --git a/packages/snaps-sdk/src/jsx/components/form/Dropdown.ts b/packages/snaps-sdk/src/jsx/components/form/Dropdown.ts index 66aa4c3ef9..f0c476fb2b 100644 --- a/packages/snaps-sdk/src/jsx/components/form/Dropdown.ts +++ b/packages/snaps-sdk/src/jsx/components/form/Dropdown.ts @@ -1,4 +1,4 @@ -import type { MaybeArray } from '../../component'; +import type { SnapsChildren } from '../../component'; import { createSnapComponent } from '../../component'; import type { OptionElement } from './Option'; @@ -13,7 +13,7 @@ import type { OptionElement } from './Option'; export type DropdownProps = { name: string; value?: string | undefined; - children: MaybeArray; + children: SnapsChildren; }; const TYPE = 'Dropdown'; diff --git a/packages/snaps-sdk/src/jsx/components/form/Form.ts b/packages/snaps-sdk/src/jsx/components/form/Form.ts index e85ee6847d..879d0c2b84 100644 --- a/packages/snaps-sdk/src/jsx/components/form/Form.ts +++ b/packages/snaps-sdk/src/jsx/components/form/Form.ts @@ -1,4 +1,4 @@ -import type { GenericSnapElement, MaybeArray } from '../../component'; +import type { GenericSnapElement, SnapsChildren } from '../../component'; import { createSnapComponent } from '../../component'; // TODO: Add `onSubmit` prop to the `FormProps` type. @@ -11,7 +11,7 @@ import { createSnapComponent } from '../../component'; * the event handler. */ export type FormProps = { - children: MaybeArray; + children: SnapsChildren; name: string; }; diff --git a/packages/snaps-sdk/src/jsx/components/form/Option.ts b/packages/snaps-sdk/src/jsx/components/form/Option.ts index 0b571f6c6f..8a4e452ef1 100644 --- a/packages/snaps-sdk/src/jsx/components/form/Option.ts +++ b/packages/snaps-sdk/src/jsx/components/form/Option.ts @@ -1,5 +1,7 @@ import type { StringElement } from '../../component'; import { createSnapComponent } from '../../component'; +// eslint-disable-next-line @typescript-eslint/no-unused-vars +import { Dropdown } from './Dropdown'; /** * The props of the {@link Option} component. diff --git a/packages/snaps-sdk/src/jsx/components/formatting/Bold.ts b/packages/snaps-sdk/src/jsx/components/formatting/Bold.ts index 4e18db72bb..c98eb27c34 100644 --- a/packages/snaps-sdk/src/jsx/components/formatting/Bold.ts +++ b/packages/snaps-sdk/src/jsx/components/formatting/Bold.ts @@ -1,17 +1,15 @@ -import type { JsonObject, MaybeArray, SnapElement } from '../../component'; +import type { JsonObject, SnapElement, SnapsChildren } from '../../component'; import { createSnapComponent } from '../../component'; // eslint-disable-next-line @typescript-eslint/no-unused-vars -import type { Text } from '../Text'; +import { Text } from '../Text'; /** * The children of the {@link Bold} component. */ -export type BoldChildren = MaybeArray< +export type BoldChildren = SnapsChildren< | string // We have to specify the type here to avoid a circular reference. | SnapElement - | boolean - | null >; /** diff --git a/packages/snaps-sdk/src/jsx/components/formatting/Italic.ts b/packages/snaps-sdk/src/jsx/components/formatting/Italic.ts index 5a9ec0cd1a..03e2f421a0 100644 --- a/packages/snaps-sdk/src/jsx/components/formatting/Italic.ts +++ b/packages/snaps-sdk/src/jsx/components/formatting/Italic.ts @@ -1,15 +1,13 @@ -import type { JsonObject, MaybeArray, SnapElement } from '../../component'; +import type { JsonObject, SnapElement, SnapsChildren } from '../../component'; import { createSnapComponent } from '../../component'; /** * The children of the {@link Italic} component. */ -export type ItalicChildren = MaybeArray< +export type ItalicChildren = SnapsChildren< | string // We have to specify the type here to avoid a circular reference. | SnapElement - | boolean - | null >; /** diff --git a/packages/snaps-sdk/src/jsx/validation.test.tsx b/packages/snaps-sdk/src/jsx/validation.test.tsx index 98ccfff126..a2db491599 100644 --- a/packages/snaps-sdk/src/jsx/validation.test.tsx +++ b/packages/snaps-sdk/src/jsx/validation.test.tsx @@ -73,7 +73,7 @@ describe('StringElementStruct', () => { expect(is(['foo', 'bar'], StringElementStruct)).toBe(true); }); - it.each([null, undefined, {}])('does not validate "%p"', (value) => { + it.each([undefined, {}])('does not validate "%p"', (value) => { expect(is(value, StringElementStruct)).toBe(false); }); }); diff --git a/packages/snaps-sdk/src/jsx/validation.ts b/packages/snaps-sdk/src/jsx/validation.ts index 94006a98b3..6effc11c35 100644 --- a/packages/snaps-sdk/src/jsx/validation.ts +++ b/packages/snaps-sdk/src/jsx/validation.ts @@ -4,7 +4,7 @@ import { isPlainObject, JsonStruct, } from '@metamask/utils'; -import type { Struct } from 'superstruct'; +import type { Infer, Struct } from 'superstruct'; import { is, boolean, @@ -18,7 +18,11 @@ import { string, tuple, } from 'superstruct'; -import type { ObjectSchema } from 'superstruct/dist/utils'; +import type { + AnyStruct, + InferStructTuple, + ObjectSchema, +} from 'superstruct/dist/utils'; import type { Describe } from '../internals'; import { literal, nullUnion, svg } from '../internals'; @@ -27,7 +31,6 @@ import type { GenericSnapElement, JsonObject, Key, - MaybeArray, Nestable, SnapElement, StringElement, @@ -67,9 +70,9 @@ export const KeyStruct: Describe = nullUnion([string(), number()]); /** * A struct for the {@link StringElement} type. */ -export const StringElementStruct: Describe = maybeArray( - nullUnion([string(), boolean()]), -); +export const StringElementStruct: Describe = children([ + string(), +]); /** * A struct for the {@link GenericSnapElement} type. @@ -86,7 +89,9 @@ export const ElementStruct: Describe = object({ * @param struct - The struct for the type to test. * @returns The struct for the nestable type. */ -function nestable(struct: Struct) { +function nestable( + struct: Struct, +): Struct, any> { const nestableStruct: Struct> = nullUnion([ struct, array(lazy(() => nestableStruct)), @@ -96,15 +101,19 @@ function nestable(struct: Struct) { } /** - * A helper function for creating a struct for a {@link MaybeArray} type. + * A helper function for creating a struct which allows children of a specific + * type, as well as `null` and `boolean`. * - * @param struct - The struct for the maybe array type. - * @returns The struct for the maybe array type. - */ -function maybeArray( - struct: Struct, -): Struct, any> { - return nestable(struct); + * @param structs - The structs to allow as children. + * @returns The struct for the children. + */ +function children( + structs: [head: Head, ...tail: Tail], +): Struct< + Nestable | InferStructTuple[number] | boolean | null>, + null +> { + return nestable(nullable(nullUnion([...structs, boolean()]))); } /** @@ -172,7 +181,7 @@ export const OptionStruct: Describe = element('Option', { export const DropdownStruct: Describe = element('Dropdown', { name: string(), value: optional(string()), - children: maybeArray(nullUnion([OptionStruct, boolean()])), + children: children([OptionStruct]), }); /** @@ -207,10 +216,10 @@ export const FieldStruct: Describe = element('Field', { * A struct for the {@link FormElement} type. */ export const FormStruct: Describe = element('Form', { - children: maybeArray( + children: children( // eslint-disable-next-line @typescript-eslint/no-use-before-define - nullable(nullUnion([FieldStruct, lazy(() => BoxChildStruct), boolean()])), - ) as unknown as Struct, null>, + [FieldStruct, lazy(() => BoxChildStruct), boolean()], + ) as unknown as Struct, null>, name: string(), }); @@ -218,36 +227,28 @@ export const FormStruct: Describe = element('Form', { * A struct for the {@link BoldElement} type. */ export const BoldStruct: Describe = element('Bold', { - children: maybeArray( - nullable( - nullUnion([ - string(), - boolean(), - // eslint-disable-next-line @typescript-eslint/no-use-before-define - lazy(() => ItalicStruct) as unknown as Struct< - SnapElement - >, - ]), - ), - ), + children: children([ + string(), + boolean(), + // eslint-disable-next-line @typescript-eslint/no-use-before-define + lazy(() => ItalicStruct) as unknown as Struct< + SnapElement + >, + ]), }); /** * A struct for the {@link ItalicElement} type. */ export const ItalicStruct: Describe = element('Italic', { - children: maybeArray( - nullable( - nullUnion([ - string(), - boolean(), - // eslint-disable-next-line @typescript-eslint/no-use-before-define - lazy(() => BoldStruct) as unknown as Struct< - SnapElement - >, - ]), - ), - ), + children: children([ + string(), + boolean(), + // eslint-disable-next-line @typescript-eslint/no-use-before-define + lazy(() => BoldStruct) as unknown as Struct< + SnapElement + >, + ]), }); export const FormattingStruct: Describe = nullUnion([ @@ -266,10 +267,10 @@ export const AddressStruct: Describe = element('Address', { * A struct for the {@link BoxElement} type. */ export const BoxStruct: Describe = element('Box', { - children: maybeArray( + children: children( // eslint-disable-next-line @typescript-eslint/no-use-before-define - nullable(nullUnion([lazy(() => BoxChildStruct), boolean()])), - ) as unknown as Struct, null>, + [lazy(() => BoxChildStruct), boolean()], + ) as unknown as Struct, null>, direction: optional(nullUnion([literal('horizontal'), literal('vertical')])), alignment: optional( nullUnion([ @@ -323,20 +324,20 @@ export const ImageStruct: Describe = element('Image', { */ export const LinkStruct: Describe = element('Link', { href: string(), - children: maybeArray( - nullable(nullUnion([FormattingStruct, string(), boolean()])), - ), + children: children([FormattingStruct, string(), boolean()]), }); /** * A struct for the {@link TextElement} type. */ export const TextStruct: Describe = element('Text', { - children: maybeArray( - nullable( - nullUnion([string(), boolean(), BoldStruct, ItalicStruct, LinkStruct]), - ), - ), + children: children([ + string(), + boolean(), + BoldStruct, + ItalicStruct, + LinkStruct, + ]), alignment: optional( nullUnion([literal('start'), literal('center'), literal('end')]), ), diff --git a/packages/snaps-sdk/tsconfig.json b/packages/snaps-sdk/tsconfig.json index 13936c8364..720c045579 100644 --- a/packages/snaps-sdk/tsconfig.json +++ b/packages/snaps-sdk/tsconfig.json @@ -12,5 +12,6 @@ "jsx.d.ts", "jsx-runtime.d.ts", "jsx-dev-runtime.d.ts" - ] + ], + "exclude": ["./dist"] } From 013410a37e0e40af0358a124703437a85139ccd5 Mon Sep 17 00:00:00 2001 From: Maarten Zuidhoorn Date: Tue, 25 Jun 2024 11:03:55 +0200 Subject: [PATCH 04/10] Update example shasums and fix type issues --- packages/examples/packages/bip32/snap.manifest.json | 2 +- packages/examples/packages/bip44/snap.manifest.json | 2 +- .../packages/browserify-plugin/snap.manifest.json | 2 +- packages/examples/packages/browserify/snap.manifest.json | 2 +- .../examples/packages/client-status/snap.manifest.json | 2 +- packages/examples/packages/cronjobs/snap.manifest.json | 2 +- packages/examples/packages/dialogs/snap.manifest.json | 2 +- .../packages/ethereum-provider/snap.manifest.json | 2 +- packages/examples/packages/ethers-js/snap.manifest.json | 2 +- packages/examples/packages/file-upload/snap.manifest.json | 2 +- packages/examples/packages/get-entropy/snap.manifest.json | 2 +- packages/examples/packages/get-file/snap.manifest.json | 2 +- packages/examples/packages/home-page/snap.manifest.json | 2 +- packages/examples/packages/images/snap.manifest.json | 2 +- .../examples/packages/interactive-ui/snap.manifest.json | 2 +- .../packages/consumer-signer/snap.manifest.json | 2 +- .../invoke-snap/packages/core-signer/snap.manifest.json | 2 +- packages/examples/packages/json-rpc/snap.manifest.json | 2 +- packages/examples/packages/jsx/snap.manifest.json | 2 +- .../examples/packages/lifecycle-hooks/snap.manifest.json | 2 +- .../examples/packages/localization/snap.manifest.json | 2 +- .../examples/packages/manage-state/snap.manifest.json | 2 +- .../examples/packages/network-access/snap.manifest.json | 2 +- .../examples/packages/notifications/snap.manifest.json | 2 +- .../examples/packages/rollup-plugin/snap.manifest.json | 2 +- .../packages/signature-insights/snap.manifest.json | 2 +- .../packages/transaction-insights/snap.manifest.json | 2 +- packages/examples/packages/wasm/snap.manifest.json | 2 +- .../examples/packages/webpack-plugin/snap.manifest.json | 2 +- packages/snaps-jest/src/matchers.ts | 8 ++++++-- packages/snaps-sdk/tsconfig.json | 3 +-- packages/snaps-utils/src/ui.tsx | 4 ++-- 32 files changed, 38 insertions(+), 35 deletions(-) diff --git a/packages/examples/packages/bip32/snap.manifest.json b/packages/examples/packages/bip32/snap.manifest.json index dced6abb97..81498b8aaf 100644 --- a/packages/examples/packages/bip32/snap.manifest.json +++ b/packages/examples/packages/bip32/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "Myfiv00eKUdOQh/6VURJt/NLEHvF7t8p+arvI8ZEy2E=", + "shasum": "Paw1MvcKp4fAIaHD7wOjms0TM6v0+9UrSindsKiIT2U=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/bip44/snap.manifest.json b/packages/examples/packages/bip44/snap.manifest.json index 0c1f0b6412..327a208923 100644 --- a/packages/examples/packages/bip44/snap.manifest.json +++ b/packages/examples/packages/bip44/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "kEd5v0Da+ONo/Pemo/W/+Rj+DCBcMlq8UoDkR3j+7hg=", + "shasum": "TdU+l8244ylKZfMGvU4zVxcsjNneDaOcGlsksIzbVxI=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/browserify-plugin/snap.manifest.json b/packages/examples/packages/browserify-plugin/snap.manifest.json index 1029c477be..40522e9a1b 100644 --- a/packages/examples/packages/browserify-plugin/snap.manifest.json +++ b/packages/examples/packages/browserify-plugin/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "AtCtWmMVDhVL7nTsaqqCnm+M9tNQpPsp+i/w3G+dvK0=", + "shasum": "WyGF29tepKkbA72BLSay+O0HmuBKeX6xVls18XGUPJ0=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/browserify/snap.manifest.json b/packages/examples/packages/browserify/snap.manifest.json index df0aaa0662..3fe9ce5007 100644 --- a/packages/examples/packages/browserify/snap.manifest.json +++ b/packages/examples/packages/browserify/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "vMjY250Ko3ULV8mMenZFFKbTfHYY8HLQizQJkOK/Ee0=", + "shasum": "jhy7YR2US99yHnczuyLNq7wfXffFsXN+McgE7i+HtQw=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/client-status/snap.manifest.json b/packages/examples/packages/client-status/snap.manifest.json index e227bb5819..282a561709 100644 --- a/packages/examples/packages/client-status/snap.manifest.json +++ b/packages/examples/packages/client-status/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "uo2UGVZKuD4tO104OeC7Y2oBkpLPrvJWWyGPJTWPVD4=", + "shasum": "h5z+EGOVyd8FjthPUfK+8KndCsHVd/dJWQbEV5HV7Pk=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/cronjobs/snap.manifest.json b/packages/examples/packages/cronjobs/snap.manifest.json index 642b38627e..a3427b2868 100644 --- a/packages/examples/packages/cronjobs/snap.manifest.json +++ b/packages/examples/packages/cronjobs/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "NuMOVeN5RPc/tuAINdZLD7Q0wccvhS9w0YLCq7JXs8M=", + "shasum": "ZPu4DoRwnCQNfpTF005B0AvJ5NPCPyV1GGtKRUpm5x8=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/dialogs/snap.manifest.json b/packages/examples/packages/dialogs/snap.manifest.json index f0ba60b41c..7c3978dd10 100644 --- a/packages/examples/packages/dialogs/snap.manifest.json +++ b/packages/examples/packages/dialogs/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "7Zm7WDQ4Dvg8YnbqTacXu0oC3C25O1oMJkPnLW+r5co=", + "shasum": "ea8+eIv5lXEiUUr/jhYv4O5zTAEHHkFgP1dvE0FjqyY=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/ethereum-provider/snap.manifest.json b/packages/examples/packages/ethereum-provider/snap.manifest.json index ab6a9fb35a..735736cd14 100644 --- a/packages/examples/packages/ethereum-provider/snap.manifest.json +++ b/packages/examples/packages/ethereum-provider/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "k0CibdCt3wsBIq47PPqzR193o2VjuddFrcOribmHHmc=", + "shasum": "LC5iXkcfN/MGtp2xYrlVceu1Bk/t8+Q9A4hmcn1n4DI=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/ethers-js/snap.manifest.json b/packages/examples/packages/ethers-js/snap.manifest.json index 0cd225ecbf..d4e558f0c2 100644 --- a/packages/examples/packages/ethers-js/snap.manifest.json +++ b/packages/examples/packages/ethers-js/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "pFmqP6z84qAB39wGZcxFQifiNlDOKT7QBPMeKDKNRwg=", + "shasum": "qjKEBv3E1LSeoe6b8ea45bvyC38xxA9O+m19++WQHAc=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/file-upload/snap.manifest.json b/packages/examples/packages/file-upload/snap.manifest.json index 5b0ca54a5b..34f334cc17 100644 --- a/packages/examples/packages/file-upload/snap.manifest.json +++ b/packages/examples/packages/file-upload/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "OK/QqfPZc/L7VitrdRypHggyR4/4PnAG/j9erpJfJww=", + "shasum": "IVgoNs8h1fS3imREb3FdCLB5Zf9qmyVwFcILUK9Xt7E=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/get-entropy/snap.manifest.json b/packages/examples/packages/get-entropy/snap.manifest.json index 7321643b24..b0ca7e4d9d 100644 --- a/packages/examples/packages/get-entropy/snap.manifest.json +++ b/packages/examples/packages/get-entropy/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "lFmdEJF/RldpN7/U6roJJm9BqSI5Bb/Whzh6dockQAw=", + "shasum": "vTdjnqfw1FFAu/GdTETN6naPNZLvBKQveKb5SfgarRM=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/get-file/snap.manifest.json b/packages/examples/packages/get-file/snap.manifest.json index 024f13679b..e35965977b 100644 --- a/packages/examples/packages/get-file/snap.manifest.json +++ b/packages/examples/packages/get-file/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "oX0FZa9+kdiEHrtU1sMbUCJMoXpiM9ur2W7WG8s/OW8=", + "shasum": "FzazaYSj1m1eJbWO3x4CVkrZj95VfbnzbO7P8mfJnNI=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/home-page/snap.manifest.json b/packages/examples/packages/home-page/snap.manifest.json index 1b4e69090f..7604399fe6 100644 --- a/packages/examples/packages/home-page/snap.manifest.json +++ b/packages/examples/packages/home-page/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "YV8OblLCDm1crxxmNDvWA3W8FL5Im3754++56NBSbUY=", + "shasum": "8AKxcoo/a6Xxfj6TUhcEs2aEXMwxibJLcWPRiXI9mig=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/images/snap.manifest.json b/packages/examples/packages/images/snap.manifest.json index 88d724b5d4..6363f52668 100644 --- a/packages/examples/packages/images/snap.manifest.json +++ b/packages/examples/packages/images/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "wquuFPu3DiUvPAXvUsSwnYN6l8SltYivBAlMdfHXLS4=", + "shasum": "HiZjEop93vH1rfFXz4k7SPgxiaUeGzXPvpjeMAcb0NU=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/interactive-ui/snap.manifest.json b/packages/examples/packages/interactive-ui/snap.manifest.json index 1f51775aa1..bf178fa52e 100644 --- a/packages/examples/packages/interactive-ui/snap.manifest.json +++ b/packages/examples/packages/interactive-ui/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "AYkzHZhTfVEuyZbMIOrbwX+fTYIm97M2rs/iwXEG954=", + "shasum": "sZTDQUyjc2KheUbOG0H/CIVYRLiCHAj9LRwaE8GIooM=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/invoke-snap/packages/consumer-signer/snap.manifest.json b/packages/examples/packages/invoke-snap/packages/consumer-signer/snap.manifest.json index ec3d881736..5b7ae65f1e 100644 --- a/packages/examples/packages/invoke-snap/packages/consumer-signer/snap.manifest.json +++ b/packages/examples/packages/invoke-snap/packages/consumer-signer/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "7mRu1KFdFY6XxJCVdUBj+vHOgiuEtdbuQ7pNXrwVZdw=", + "shasum": "xwnHVWihUs6GD1HCciN89gkTzKcMqISeBROgEUN4wgk=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/invoke-snap/packages/core-signer/snap.manifest.json b/packages/examples/packages/invoke-snap/packages/core-signer/snap.manifest.json index 290cd9dde2..7f0c7bdb20 100644 --- a/packages/examples/packages/invoke-snap/packages/core-signer/snap.manifest.json +++ b/packages/examples/packages/invoke-snap/packages/core-signer/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "DMgBdNXhzY5eanbB+zfrshV+NfhYhwcf3N7+OpXOfVg=", + "shasum": "K+/ZeTU0gQlrcwy0oCKaxjpxpv8f8GLYbkAv6ZLZhls=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/json-rpc/snap.manifest.json b/packages/examples/packages/json-rpc/snap.manifest.json index a4ff828cc7..fd0d1524bb 100644 --- a/packages/examples/packages/json-rpc/snap.manifest.json +++ b/packages/examples/packages/json-rpc/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "y06YrfQGNwFwo/kH3HfwJaWNYQu5C6UAKuZlafLWYHk=", + "shasum": "IN1A0Mn2HzGMv+1DskqAOdGq7Z/VswhldNMetQFn7WY=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/jsx/snap.manifest.json b/packages/examples/packages/jsx/snap.manifest.json index 1da343a63e..4af8d665bf 100644 --- a/packages/examples/packages/jsx/snap.manifest.json +++ b/packages/examples/packages/jsx/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "6qUXiZopZ2r/V/Hd6v8v4OjP2IKpBwMu5WAZjO4Ikgs=", + "shasum": "2bTgXzMoOamgCLZor3obQ5SPdFMY+jIQpuHWHtFzEbs=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/lifecycle-hooks/snap.manifest.json b/packages/examples/packages/lifecycle-hooks/snap.manifest.json index 8f374bf06b..def0c7b809 100644 --- a/packages/examples/packages/lifecycle-hooks/snap.manifest.json +++ b/packages/examples/packages/lifecycle-hooks/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "XKLkCOhCgU+yQ2Z+qnX7mSrlduxJeqMqBd5nqKKdz6Q=", + "shasum": "QPc5ZS6VlcPrDtb3GPyk7vOq/g/hItqSqkq9H6Al3Wg=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/localization/snap.manifest.json b/packages/examples/packages/localization/snap.manifest.json index 05c2117df1..fb8c85ea6b 100644 --- a/packages/examples/packages/localization/snap.manifest.json +++ b/packages/examples/packages/localization/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "ZFIL9SrOEbTWaUDGIJZXZJPJFGraq3sPiWM8bC2tLy4=", + "shasum": "3u0roIrlyn6qhMMtTc/U36RkuhiB4oF8DFu9H1h5bbc=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/manage-state/snap.manifest.json b/packages/examples/packages/manage-state/snap.manifest.json index 21adc7e4f1..9343116b76 100644 --- a/packages/examples/packages/manage-state/snap.manifest.json +++ b/packages/examples/packages/manage-state/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "lvCLamKc9tutH9zT6ECKjMoVgKxaueZxEm2Soy+GIX0=", + "shasum": "0iSgKQXeEePTFOenbfI1FS/N5mB403Z9Et7mn+qwxzo=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/network-access/snap.manifest.json b/packages/examples/packages/network-access/snap.manifest.json index f6dbf4f567..4f0ab319c4 100644 --- a/packages/examples/packages/network-access/snap.manifest.json +++ b/packages/examples/packages/network-access/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "osTfC/2Y6+aDcYtRj6N7YxVRLfVgNEHAmL7Km8nkwI4=", + "shasum": "XHg6R5zNIYiH4dHBwqO2Om0TMvK8koQu6WOe6CcvRio=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/notifications/snap.manifest.json b/packages/examples/packages/notifications/snap.manifest.json index c501cb588b..c627744b10 100644 --- a/packages/examples/packages/notifications/snap.manifest.json +++ b/packages/examples/packages/notifications/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "xM6Q/SRD4ivSYzwqD2NhmlVQ5v2RHLnEN8ohxWtWcBU=", + "shasum": "ZEUzTVWOhCkH9K+WmtspfXEu16imY9ee4HdK7wH8hew=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/rollup-plugin/snap.manifest.json b/packages/examples/packages/rollup-plugin/snap.manifest.json index 6ac46703ac..c8e658acb5 100644 --- a/packages/examples/packages/rollup-plugin/snap.manifest.json +++ b/packages/examples/packages/rollup-plugin/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "9DHCPiYk3FZZqg0rdsH0YIJFL3x8BfUH3jcZAD2gqA4=", + "shasum": "2u8Ff+LVeGGDTlSIqX1tyfRECv4nf13rwm11sKZ4/Qg=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/signature-insights/snap.manifest.json b/packages/examples/packages/signature-insights/snap.manifest.json index bc64d3110a..f5d695aa86 100644 --- a/packages/examples/packages/signature-insights/snap.manifest.json +++ b/packages/examples/packages/signature-insights/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "SBw2f5d1MMrve92+z+rGmPpJ5hJmyuMi1N6Pza/9nXU=", + "shasum": "Xpb9v3Lycj3WJ15xvBbTmHuYZR4vb9iyhnkgATh18po=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/transaction-insights/snap.manifest.json b/packages/examples/packages/transaction-insights/snap.manifest.json index 8a6d8cdab6..becdd93249 100644 --- a/packages/examples/packages/transaction-insights/snap.manifest.json +++ b/packages/examples/packages/transaction-insights/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "FBzAQuGVTVij6SLPkzro0OmcEPNXKT1NLHjiY3rUcxQ=", + "shasum": "unSCLB8GJ5KyYT3YfHSMDFcD5ClGtWcWbJZ7eIpjlk4=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/wasm/snap.manifest.json b/packages/examples/packages/wasm/snap.manifest.json index 686dd749ab..32e5ff7e65 100644 --- a/packages/examples/packages/wasm/snap.manifest.json +++ b/packages/examples/packages/wasm/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "xEkfElvZ0ndhl1PcdkqDL6gicxdKxae/aKDl011Tgs4=", + "shasum": "yUK4OmLGC/zSUUc/Nqlj2rPQ/Oy0/Rx7+su/pEL83uU=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/webpack-plugin/snap.manifest.json b/packages/examples/packages/webpack-plugin/snap.manifest.json index f6bc3fabda..c9589df85d 100644 --- a/packages/examples/packages/webpack-plugin/snap.manifest.json +++ b/packages/examples/packages/webpack-plugin/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "+x5V9w2ybgWUj2j/DvhKFRI3yo0ng8zhQ/BFN55F7yw=", + "shasum": "OtUyvj24INOaosESd2O9fN5hnxBSW//UctFgaY+Ha3A=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/snaps-jest/src/matchers.ts b/packages/snaps-jest/src/matchers.ts index 92d90bae23..e5702ec68a 100644 --- a/packages/snaps-jest/src/matchers.ts +++ b/packages/snaps-jest/src/matchers.ts @@ -11,7 +11,11 @@ import type { ComponentOrElement, Component, } from '@metamask/snaps-sdk'; -import type { JSXElement, SnapNode } from '@metamask/snaps-sdk/jsx'; +import type { + GenericSnapElement, + JSXElement, + SnapNode, +} from '@metamask/snaps-sdk/jsx'; import { isJSXElementUnsafe } from '@metamask/snaps-sdk/jsx'; import { getJsxElementFromComponent } from '@metamask/snaps-utils'; import type { Json } from '@metamask/utils'; @@ -234,7 +238,7 @@ export function serialiseJsx(node: SnapNode, indentation = 0): string { return ''; } - const { type, props } = node; + const { type, props } = node as GenericSnapElement; const trailingNewline = indentation > 0 ? '\n' : ''; if (hasProperty(props, 'children')) { diff --git a/packages/snaps-sdk/tsconfig.json b/packages/snaps-sdk/tsconfig.json index 720c045579..13936c8364 100644 --- a/packages/snaps-sdk/tsconfig.json +++ b/packages/snaps-sdk/tsconfig.json @@ -12,6 +12,5 @@ "jsx.d.ts", "jsx-runtime.d.ts", "jsx-dev-runtime.d.ts" - ], - "exclude": ["./dist"] + ] } diff --git a/packages/snaps-utils/src/ui.tsx b/packages/snaps-utils/src/ui.tsx index 8e6cb66373..1a7a6d313a 100644 --- a/packages/snaps-utils/src/ui.tsx +++ b/packages/snaps-utils/src/ui.tsx @@ -5,7 +5,7 @@ import type { ItalicChildren, JSXElement, LinkElement, - MaybeArray, + Nestable, RowChildren, StandardFormattingElement, TextChildren, @@ -433,7 +433,7 @@ export function getTotalTextLength(component: Component): number { export function hasChildren( element: Element, ): element is Element & { - props: { children: MaybeArray }; + props: { children: Nestable }; } { return hasProperty(element.props, 'children'); } From 4fff8c84dd1141a5009f794937426e7ca3488dc3 Mon Sep 17 00:00:00 2001 From: Maarten Zuidhoorn Date: Tue, 25 Jun 2024 11:15:18 +0200 Subject: [PATCH 05/10] Fix snaps-utils coverage --- packages/snaps-utils/coverage.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/snaps-utils/coverage.json b/packages/snaps-utils/coverage.json index a5ffcef354..4990dcaaee 100644 --- a/packages/snaps-utils/coverage.json +++ b/packages/snaps-utils/coverage.json @@ -1,6 +1,6 @@ { - "branches": 96.75, + "branches": 96.77, "functions": 98.76, - "lines": 98.84, + "lines": 98.85, "statements": 94.92 } From 427e8a5dd14875d8d58976c9dfd4cd0649e36542 Mon Sep 17 00:00:00 2001 From: Maarten Zuidhoorn Date: Tue, 25 Jun 2024 11:41:14 +0200 Subject: [PATCH 06/10] Remove boolean from Field component --- packages/snaps-sdk/src/jsx/components/form/Field.ts | 3 +-- packages/snaps-sdk/src/jsx/validation.ts | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/snaps-sdk/src/jsx/components/form/Field.ts b/packages/snaps-sdk/src/jsx/components/form/Field.ts index 093a949048..d2f87f38ba 100644 --- a/packages/snaps-sdk/src/jsx/components/form/Field.ts +++ b/packages/snaps-sdk/src/jsx/components/form/Field.ts @@ -20,8 +20,7 @@ export type FieldProps = { | DropdownElement | FileInputElement | InputElement - | CheckboxElement - | boolean; + | CheckboxElement; }; const TYPE = 'Field'; diff --git a/packages/snaps-sdk/src/jsx/validation.ts b/packages/snaps-sdk/src/jsx/validation.ts index 6effc11c35..e162a97225 100644 --- a/packages/snaps-sdk/src/jsx/validation.ts +++ b/packages/snaps-sdk/src/jsx/validation.ts @@ -208,7 +208,6 @@ export const FieldStruct: Describe = element('Field', { FileInputStruct, InputStruct, CheckboxStruct, - boolean(), ]), }); From 51d284d4b319ab3cb61d8d3720c002ef146ad55d Mon Sep 17 00:00:00 2001 From: Maarten Zuidhoorn Date: Tue, 25 Jun 2024 11:42:16 +0200 Subject: [PATCH 07/10] Update contributing guide --- packages/snaps-sdk/CONTRIBUTING.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/snaps-sdk/CONTRIBUTING.md b/packages/snaps-sdk/CONTRIBUTING.md index 236c5563cd..d16e8cdecb 100644 --- a/packages/snaps-sdk/CONTRIBUTING.md +++ b/packages/snaps-sdk/CONTRIBUTING.md @@ -43,7 +43,7 @@ declaration, like so: export type DropdownProps = { name: string; value?: string | undefined; - children: MaybeArray; + children: SnapsChildren; }; ``` @@ -78,7 +78,8 @@ exceptions to this rule, such as when the component only accepts a single child element (e.g., `Field`). Children should also accept `boolean` and `null` values to allow for conditional -rendering of child elements. +rendering of child elements. This is handled automatically by the +`SnapsChildren` type. ```typescript export type ComponentProps = { From 9533bcd6cb91dc017ea271468f5fb903631f3468 Mon Sep 17 00:00:00 2001 From: Maarten Zuidhoorn Date: Tue, 25 Jun 2024 11:47:35 +0200 Subject: [PATCH 08/10] Change Option to only take a single string instead of a StringElement --- .../examples/packages/bip32/snap.manifest.json | 2 +- .../examples/packages/bip44/snap.manifest.json | 2 +- .../browserify-plugin/snap.manifest.json | 2 +- .../packages/browserify/snap.manifest.json | 2 +- .../packages/client-status/snap.manifest.json | 2 +- .../packages/cronjobs/snap.manifest.json | 2 +- .../packages/dialogs/snap.manifest.json | 2 +- .../ethereum-provider/snap.manifest.json | 2 +- .../packages/ethers-js/snap.manifest.json | 2 +- .../packages/file-upload/snap.manifest.json | 2 +- .../packages/get-entropy/snap.manifest.json | 2 +- .../packages/get-file/snap.manifest.json | 2 +- .../packages/home-page/snap.manifest.json | 2 +- .../packages/images/snap.manifest.json | 2 +- .../packages/interactive-ui/snap.manifest.json | 2 +- .../consumer-signer/snap.manifest.json | 2 +- .../packages/core-signer/snap.manifest.json | 2 +- .../packages/json-rpc/snap.manifest.json | 2 +- .../examples/packages/jsx/snap.manifest.json | 2 +- .../lifecycle-hooks/snap.manifest.json | 2 +- .../packages/localization/snap.manifest.json | 2 +- .../packages/manage-state/snap.manifest.json | 2 +- .../packages/network-access/snap.manifest.json | 2 +- .../packages/notifications/snap.manifest.json | 2 +- .../packages/rollup-plugin/snap.manifest.json | 2 +- .../signature-insights/snap.manifest.json | 2 +- .../transaction-insights/snap.manifest.json | 2 +- .../examples/packages/wasm/snap.manifest.json | 2 +- .../packages/webpack-plugin/snap.manifest.json | 2 +- .../src/jsx/components/form/Option.test.tsx | 18 ------------------ .../src/jsx/components/form/Option.ts | 3 +-- packages/snaps-sdk/src/jsx/validation.ts | 2 +- 32 files changed, 31 insertions(+), 50 deletions(-) diff --git a/packages/examples/packages/bip32/snap.manifest.json b/packages/examples/packages/bip32/snap.manifest.json index 81498b8aaf..4263ac402a 100644 --- a/packages/examples/packages/bip32/snap.manifest.json +++ b/packages/examples/packages/bip32/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "Paw1MvcKp4fAIaHD7wOjms0TM6v0+9UrSindsKiIT2U=", + "shasum": "31c28sD4FsnT5AULXF2f5eN7iFqOrrCtdE0Ci3XhdYA=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/bip44/snap.manifest.json b/packages/examples/packages/bip44/snap.manifest.json index 327a208923..f0bbac1db8 100644 --- a/packages/examples/packages/bip44/snap.manifest.json +++ b/packages/examples/packages/bip44/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "TdU+l8244ylKZfMGvU4zVxcsjNneDaOcGlsksIzbVxI=", + "shasum": "F8umX6ibuhH1ASBxnoN8GaGo1LE8zE9ahQmnhfB/w+4=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/browserify-plugin/snap.manifest.json b/packages/examples/packages/browserify-plugin/snap.manifest.json index 40522e9a1b..c0de564033 100644 --- a/packages/examples/packages/browserify-plugin/snap.manifest.json +++ b/packages/examples/packages/browserify-plugin/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "WyGF29tepKkbA72BLSay+O0HmuBKeX6xVls18XGUPJ0=", + "shasum": "E3C1cZqVCd3yMoPWu1CZ0EFCccoMU1qwFeYgfdsVRNE=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/browserify/snap.manifest.json b/packages/examples/packages/browserify/snap.manifest.json index 3fe9ce5007..d48e16c55b 100644 --- a/packages/examples/packages/browserify/snap.manifest.json +++ b/packages/examples/packages/browserify/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "jhy7YR2US99yHnczuyLNq7wfXffFsXN+McgE7i+HtQw=", + "shasum": "5XCJq4Wk9xZREQ+fhCPe36Y/XoE5zQWtgwo7s9CVkLo=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/client-status/snap.manifest.json b/packages/examples/packages/client-status/snap.manifest.json index 282a561709..9e548c930a 100644 --- a/packages/examples/packages/client-status/snap.manifest.json +++ b/packages/examples/packages/client-status/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "h5z+EGOVyd8FjthPUfK+8KndCsHVd/dJWQbEV5HV7Pk=", + "shasum": "f9mN2RXTGTpOgMCJJEw4gKMxD5pnwX9iEzN7uwD0hyM=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/cronjobs/snap.manifest.json b/packages/examples/packages/cronjobs/snap.manifest.json index a3427b2868..4254d542c6 100644 --- a/packages/examples/packages/cronjobs/snap.manifest.json +++ b/packages/examples/packages/cronjobs/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "ZPu4DoRwnCQNfpTF005B0AvJ5NPCPyV1GGtKRUpm5x8=", + "shasum": "ogz/CDOrL/5h5eZAIhDHc+lPhM00154OECWokO0DdwI=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/dialogs/snap.manifest.json b/packages/examples/packages/dialogs/snap.manifest.json index 7c3978dd10..26025dc6f0 100644 --- a/packages/examples/packages/dialogs/snap.manifest.json +++ b/packages/examples/packages/dialogs/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "ea8+eIv5lXEiUUr/jhYv4O5zTAEHHkFgP1dvE0FjqyY=", + "shasum": "lAN8Csyf0HsFkfxsi01msDAdLusKLuPnGmtbcZGH+L0=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/ethereum-provider/snap.manifest.json b/packages/examples/packages/ethereum-provider/snap.manifest.json index 735736cd14..3d6b824427 100644 --- a/packages/examples/packages/ethereum-provider/snap.manifest.json +++ b/packages/examples/packages/ethereum-provider/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "LC5iXkcfN/MGtp2xYrlVceu1Bk/t8+Q9A4hmcn1n4DI=", + "shasum": "o+VevN11IEZxklZjSyfhVSB5slBKWW0K6hKFck7LgH4=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/ethers-js/snap.manifest.json b/packages/examples/packages/ethers-js/snap.manifest.json index d4e558f0c2..f465651645 100644 --- a/packages/examples/packages/ethers-js/snap.manifest.json +++ b/packages/examples/packages/ethers-js/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "qjKEBv3E1LSeoe6b8ea45bvyC38xxA9O+m19++WQHAc=", + "shasum": "vYA+3gTFQtkm/gMBuqF8IKATR5zYEBslQn4E9ZjeQZo=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/file-upload/snap.manifest.json b/packages/examples/packages/file-upload/snap.manifest.json index 34f334cc17..dfc6db12bc 100644 --- a/packages/examples/packages/file-upload/snap.manifest.json +++ b/packages/examples/packages/file-upload/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "IVgoNs8h1fS3imREb3FdCLB5Zf9qmyVwFcILUK9Xt7E=", + "shasum": "Y8FjAWQERPZnXFiHwMDpR5yF0loWMbOdJjdvO+uYf5A=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/get-entropy/snap.manifest.json b/packages/examples/packages/get-entropy/snap.manifest.json index b0ca7e4d9d..c24a5b2bc7 100644 --- a/packages/examples/packages/get-entropy/snap.manifest.json +++ b/packages/examples/packages/get-entropy/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "vTdjnqfw1FFAu/GdTETN6naPNZLvBKQveKb5SfgarRM=", + "shasum": "LoFFGA3qj24Pe9Vr/Hpv0KAxUwI80Qdb3ihWR7M7Eag=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/get-file/snap.manifest.json b/packages/examples/packages/get-file/snap.manifest.json index e35965977b..0d51902516 100644 --- a/packages/examples/packages/get-file/snap.manifest.json +++ b/packages/examples/packages/get-file/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "FzazaYSj1m1eJbWO3x4CVkrZj95VfbnzbO7P8mfJnNI=", + "shasum": "E5ZJ6XhrkUVcH19inuDA64yZQg92JuW8xO2HD0NaWY0=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/home-page/snap.manifest.json b/packages/examples/packages/home-page/snap.manifest.json index 7604399fe6..eb6106ccbb 100644 --- a/packages/examples/packages/home-page/snap.manifest.json +++ b/packages/examples/packages/home-page/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "8AKxcoo/a6Xxfj6TUhcEs2aEXMwxibJLcWPRiXI9mig=", + "shasum": "LQXgfkmMDLHqG23UE+vq7V2NTV2G+okrbWGtitICkBY=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/images/snap.manifest.json b/packages/examples/packages/images/snap.manifest.json index 6363f52668..141f2d78cd 100644 --- a/packages/examples/packages/images/snap.manifest.json +++ b/packages/examples/packages/images/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "HiZjEop93vH1rfFXz4k7SPgxiaUeGzXPvpjeMAcb0NU=", + "shasum": "JFhngXwNXV1gfnin9435etNBL/Y4vEYrWImgZZCILD0=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/interactive-ui/snap.manifest.json b/packages/examples/packages/interactive-ui/snap.manifest.json index bf178fa52e..87414fe614 100644 --- a/packages/examples/packages/interactive-ui/snap.manifest.json +++ b/packages/examples/packages/interactive-ui/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "sZTDQUyjc2KheUbOG0H/CIVYRLiCHAj9LRwaE8GIooM=", + "shasum": "Pi3qH8IlyNlERthaWzFGRxJGZb+XDJ89QdkY4XDxTqo=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/invoke-snap/packages/consumer-signer/snap.manifest.json b/packages/examples/packages/invoke-snap/packages/consumer-signer/snap.manifest.json index 5b7ae65f1e..d1abd7abbd 100644 --- a/packages/examples/packages/invoke-snap/packages/consumer-signer/snap.manifest.json +++ b/packages/examples/packages/invoke-snap/packages/consumer-signer/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "xwnHVWihUs6GD1HCciN89gkTzKcMqISeBROgEUN4wgk=", + "shasum": "K/YoIRPCc1i39hakRMVA/Eqnqc7MY+36G8I6/Ca1gqc=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/invoke-snap/packages/core-signer/snap.manifest.json b/packages/examples/packages/invoke-snap/packages/core-signer/snap.manifest.json index 7f0c7bdb20..73af548b37 100644 --- a/packages/examples/packages/invoke-snap/packages/core-signer/snap.manifest.json +++ b/packages/examples/packages/invoke-snap/packages/core-signer/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "K+/ZeTU0gQlrcwy0oCKaxjpxpv8f8GLYbkAv6ZLZhls=", + "shasum": "DFc9t3YIo2l+iK0uST4anZvk3OVnR9roGokhha5SNaw=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/json-rpc/snap.manifest.json b/packages/examples/packages/json-rpc/snap.manifest.json index fd0d1524bb..cb0db2bf16 100644 --- a/packages/examples/packages/json-rpc/snap.manifest.json +++ b/packages/examples/packages/json-rpc/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "IN1A0Mn2HzGMv+1DskqAOdGq7Z/VswhldNMetQFn7WY=", + "shasum": "gneP1YqODXq++KJZjTtuGjr1RB8izfkURNyyWxu9Uac=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/jsx/snap.manifest.json b/packages/examples/packages/jsx/snap.manifest.json index 4af8d665bf..3d08e82f82 100644 --- a/packages/examples/packages/jsx/snap.manifest.json +++ b/packages/examples/packages/jsx/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "2bTgXzMoOamgCLZor3obQ5SPdFMY+jIQpuHWHtFzEbs=", + "shasum": "whLo5E6I9SsxqOEhqSoZCmSSAi9y00t5IIoB95zj56g=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/lifecycle-hooks/snap.manifest.json b/packages/examples/packages/lifecycle-hooks/snap.manifest.json index def0c7b809..be1775bfec 100644 --- a/packages/examples/packages/lifecycle-hooks/snap.manifest.json +++ b/packages/examples/packages/lifecycle-hooks/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "QPc5ZS6VlcPrDtb3GPyk7vOq/g/hItqSqkq9H6Al3Wg=", + "shasum": "4FnjVvoeQC7msz0OdpwMatXvXlXyPPXxEwlhRUOt6Io=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/localization/snap.manifest.json b/packages/examples/packages/localization/snap.manifest.json index fb8c85ea6b..dd9e12e627 100644 --- a/packages/examples/packages/localization/snap.manifest.json +++ b/packages/examples/packages/localization/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "3u0roIrlyn6qhMMtTc/U36RkuhiB4oF8DFu9H1h5bbc=", + "shasum": "bb9yl3sUFSzfelkwY7LgGK9OOQlQI7lpPMwdOBsFTK4=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/manage-state/snap.manifest.json b/packages/examples/packages/manage-state/snap.manifest.json index 9343116b76..f437eba6ae 100644 --- a/packages/examples/packages/manage-state/snap.manifest.json +++ b/packages/examples/packages/manage-state/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "0iSgKQXeEePTFOenbfI1FS/N5mB403Z9Et7mn+qwxzo=", + "shasum": "DPp7KHenp69URctJORMZuDaibhxInE43yiwPLEXPwJw=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/network-access/snap.manifest.json b/packages/examples/packages/network-access/snap.manifest.json index 4f0ab319c4..0da0a35e46 100644 --- a/packages/examples/packages/network-access/snap.manifest.json +++ b/packages/examples/packages/network-access/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "XHg6R5zNIYiH4dHBwqO2Om0TMvK8koQu6WOe6CcvRio=", + "shasum": "GhbegDCUE81gFKKZLRBBf/D2hfEOU9NfAczaTR0sOYc=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/notifications/snap.manifest.json b/packages/examples/packages/notifications/snap.manifest.json index c627744b10..f5fa87d9f3 100644 --- a/packages/examples/packages/notifications/snap.manifest.json +++ b/packages/examples/packages/notifications/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "ZEUzTVWOhCkH9K+WmtspfXEu16imY9ee4HdK7wH8hew=", + "shasum": "AaxZSpg3ajf3EphiCRvndaiJshfP8PLZh90I8lMGTPg=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/rollup-plugin/snap.manifest.json b/packages/examples/packages/rollup-plugin/snap.manifest.json index c8e658acb5..274912db72 100644 --- a/packages/examples/packages/rollup-plugin/snap.manifest.json +++ b/packages/examples/packages/rollup-plugin/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "2u8Ff+LVeGGDTlSIqX1tyfRECv4nf13rwm11sKZ4/Qg=", + "shasum": "z3FmXq08vm9sXiJI4wfkPbZ7sBB8gdsPOrcVuEVa0xM=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/signature-insights/snap.manifest.json b/packages/examples/packages/signature-insights/snap.manifest.json index f5d695aa86..537db3391b 100644 --- a/packages/examples/packages/signature-insights/snap.manifest.json +++ b/packages/examples/packages/signature-insights/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "Xpb9v3Lycj3WJ15xvBbTmHuYZR4vb9iyhnkgATh18po=", + "shasum": "PfW4LfNyQP9K9MD/ZPF/oumq7RJf/SyJU2jeoUSJ2aM=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/transaction-insights/snap.manifest.json b/packages/examples/packages/transaction-insights/snap.manifest.json index becdd93249..5a79e6d690 100644 --- a/packages/examples/packages/transaction-insights/snap.manifest.json +++ b/packages/examples/packages/transaction-insights/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "unSCLB8GJ5KyYT3YfHSMDFcD5ClGtWcWbJZ7eIpjlk4=", + "shasum": "3r3+aNEdyR7CWPvBmmSCuZY+FTA+eFdkulS+0a2+KYU=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/wasm/snap.manifest.json b/packages/examples/packages/wasm/snap.manifest.json index 32e5ff7e65..f48e2fd2de 100644 --- a/packages/examples/packages/wasm/snap.manifest.json +++ b/packages/examples/packages/wasm/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "yUK4OmLGC/zSUUc/Nqlj2rPQ/Oy0/Rx7+su/pEL83uU=", + "shasum": "PLD8S8Lsjnkabuv6I1DxuMvdkjvbDF9o1Sc3X5zfAr4=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/webpack-plugin/snap.manifest.json b/packages/examples/packages/webpack-plugin/snap.manifest.json index c9589df85d..84c816d15b 100644 --- a/packages/examples/packages/webpack-plugin/snap.manifest.json +++ b/packages/examples/packages/webpack-plugin/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "OtUyvj24INOaosESd2O9fN5hnxBSW//UctFgaY+Ha3A=", + "shasum": "e79yLA9JvLIWDuBMPXLYFNKT+6Tpun4yAkAUJEx/vrA=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/snaps-sdk/src/jsx/components/form/Option.test.tsx b/packages/snaps-sdk/src/jsx/components/form/Option.test.tsx index 6dba275bb6..0c6a5eb3b2 100644 --- a/packages/snaps-sdk/src/jsx/components/form/Option.test.tsx +++ b/packages/snaps-sdk/src/jsx/components/form/Option.test.tsx @@ -13,22 +13,4 @@ describe('Option', () => { key: null, }); }); - - it('renders a dropdown option with a conditional value', () => { - const result = ( - - ); - - expect(result).toStrictEqual({ - type: 'Option', - props: { - value: 'foo', - children: ['Foo', false], - }, - key: null, - }); - }); }); diff --git a/packages/snaps-sdk/src/jsx/components/form/Option.ts b/packages/snaps-sdk/src/jsx/components/form/Option.ts index 8a4e452ef1..6466ce068c 100644 --- a/packages/snaps-sdk/src/jsx/components/form/Option.ts +++ b/packages/snaps-sdk/src/jsx/components/form/Option.ts @@ -1,4 +1,3 @@ -import type { StringElement } from '../../component'; import { createSnapComponent } from '../../component'; // eslint-disable-next-line @typescript-eslint/no-unused-vars import { Dropdown } from './Dropdown'; @@ -12,7 +11,7 @@ import { Dropdown } from './Dropdown'; */ type OptionProps = { value: string; - children: StringElement; + children: string; }; const TYPE = 'Option'; diff --git a/packages/snaps-sdk/src/jsx/validation.ts b/packages/snaps-sdk/src/jsx/validation.ts index e162a97225..b523b653d9 100644 --- a/packages/snaps-sdk/src/jsx/validation.ts +++ b/packages/snaps-sdk/src/jsx/validation.ts @@ -172,7 +172,7 @@ export const InputStruct: Describe = element('Input', { */ export const OptionStruct: Describe = element('Option', { value: string(), - children: StringElementStruct, + children: string(), }); /** From 119fa18d3fb173279bc7ec73b315b880f7f3d22a Mon Sep 17 00:00:00 2001 From: Maarten Zuidhoorn Date: Tue, 25 Jun 2024 11:59:40 +0200 Subject: [PATCH 09/10] Simplify types some more --- packages/examples/packages/bip32/snap.manifest.json | 2 +- packages/examples/packages/bip44/snap.manifest.json | 2 +- .../packages/browserify-plugin/snap.manifest.json | 2 +- packages/examples/packages/browserify/snap.manifest.json | 2 +- .../examples/packages/client-status/snap.manifest.json | 2 +- packages/examples/packages/cronjobs/snap.manifest.json | 2 +- packages/examples/packages/dialogs/snap.manifest.json | 2 +- .../packages/ethereum-provider/snap.manifest.json | 2 +- packages/examples/packages/ethers-js/snap.manifest.json | 2 +- .../examples/packages/file-upload/snap.manifest.json | 2 +- .../examples/packages/get-entropy/snap.manifest.json | 2 +- packages/examples/packages/get-file/snap.manifest.json | 2 +- packages/examples/packages/home-page/snap.manifest.json | 2 +- packages/examples/packages/images/snap.manifest.json | 2 +- .../examples/packages/interactive-ui/snap.manifest.json | 2 +- .../packages/consumer-signer/snap.manifest.json | 2 +- .../invoke-snap/packages/core-signer/snap.manifest.json | 2 +- packages/examples/packages/json-rpc/snap.manifest.json | 2 +- packages/examples/packages/jsx/snap.manifest.json | 2 +- .../examples/packages/lifecycle-hooks/snap.manifest.json | 2 +- .../examples/packages/localization/snap.manifest.json | 2 +- .../examples/packages/manage-state/snap.manifest.json | 2 +- .../examples/packages/network-access/snap.manifest.json | 2 +- .../examples/packages/notifications/snap.manifest.json | 2 +- .../examples/packages/rollup-plugin/snap.manifest.json | 2 +- .../packages/signature-insights/snap.manifest.json | 2 +- .../packages/transaction-insights/snap.manifest.json | 2 +- packages/examples/packages/wasm/snap.manifest.json | 2 +- .../examples/packages/webpack-plugin/snap.manifest.json | 2 +- packages/snaps-sdk/src/jsx/validation.ts | 9 +++++---- 30 files changed, 34 insertions(+), 33 deletions(-) diff --git a/packages/examples/packages/bip32/snap.manifest.json b/packages/examples/packages/bip32/snap.manifest.json index 4263ac402a..c2d9c58e42 100644 --- a/packages/examples/packages/bip32/snap.manifest.json +++ b/packages/examples/packages/bip32/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "31c28sD4FsnT5AULXF2f5eN7iFqOrrCtdE0Ci3XhdYA=", + "shasum": "okOtnPSp63QzvGqnfiFeIj9upF+l2GUcuX0hld/8zS4=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/bip44/snap.manifest.json b/packages/examples/packages/bip44/snap.manifest.json index f0bbac1db8..97604f0591 100644 --- a/packages/examples/packages/bip44/snap.manifest.json +++ b/packages/examples/packages/bip44/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "F8umX6ibuhH1ASBxnoN8GaGo1LE8zE9ahQmnhfB/w+4=", + "shasum": "9Wtu1MGgCNlXREDrOX5nYcUe+E8jESmmCEveUBR8n/c=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/browserify-plugin/snap.manifest.json b/packages/examples/packages/browserify-plugin/snap.manifest.json index c0de564033..5ddf379d04 100644 --- a/packages/examples/packages/browserify-plugin/snap.manifest.json +++ b/packages/examples/packages/browserify-plugin/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "E3C1cZqVCd3yMoPWu1CZ0EFCccoMU1qwFeYgfdsVRNE=", + "shasum": "U3DkPSJLzf4OO7/Ybma4bBYP0fp+QpwrQXjHHyyVrW4=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/browserify/snap.manifest.json b/packages/examples/packages/browserify/snap.manifest.json index d48e16c55b..8bfa88fd0f 100644 --- a/packages/examples/packages/browserify/snap.manifest.json +++ b/packages/examples/packages/browserify/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "5XCJq4Wk9xZREQ+fhCPe36Y/XoE5zQWtgwo7s9CVkLo=", + "shasum": "O0+BkKmGK6BN1eYbct7KQEnvW3CRks/YrNUPzG79qlE=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/client-status/snap.manifest.json b/packages/examples/packages/client-status/snap.manifest.json index 9e548c930a..86b703ddbf 100644 --- a/packages/examples/packages/client-status/snap.manifest.json +++ b/packages/examples/packages/client-status/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "f9mN2RXTGTpOgMCJJEw4gKMxD5pnwX9iEzN7uwD0hyM=", + "shasum": "f8zeIa09pXt1W8vKHjDjznEdSjC2OBn3QVIijtHUwPg=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/cronjobs/snap.manifest.json b/packages/examples/packages/cronjobs/snap.manifest.json index 4254d542c6..58b7451a41 100644 --- a/packages/examples/packages/cronjobs/snap.manifest.json +++ b/packages/examples/packages/cronjobs/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "ogz/CDOrL/5h5eZAIhDHc+lPhM00154OECWokO0DdwI=", + "shasum": "v4TY+hN5aUAIdvb31+YEvWCR/Dhc5eSoqv4QZAjgE6w=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/dialogs/snap.manifest.json b/packages/examples/packages/dialogs/snap.manifest.json index 26025dc6f0..51070db29e 100644 --- a/packages/examples/packages/dialogs/snap.manifest.json +++ b/packages/examples/packages/dialogs/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "lAN8Csyf0HsFkfxsi01msDAdLusKLuPnGmtbcZGH+L0=", + "shasum": "OSa/uP5sUDFb9cgnyJF43CHugmssYIbVYFJGXutEOJ8=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/ethereum-provider/snap.manifest.json b/packages/examples/packages/ethereum-provider/snap.manifest.json index 3d6b824427..171097edd4 100644 --- a/packages/examples/packages/ethereum-provider/snap.manifest.json +++ b/packages/examples/packages/ethereum-provider/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "o+VevN11IEZxklZjSyfhVSB5slBKWW0K6hKFck7LgH4=", + "shasum": "UIm8NaJ2HQ+b0/gwzMrUolBPH94WaX0krT2j2vqS8Sw=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/ethers-js/snap.manifest.json b/packages/examples/packages/ethers-js/snap.manifest.json index f465651645..4584b0170e 100644 --- a/packages/examples/packages/ethers-js/snap.manifest.json +++ b/packages/examples/packages/ethers-js/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "vYA+3gTFQtkm/gMBuqF8IKATR5zYEBslQn4E9ZjeQZo=", + "shasum": "2hc5tU0+vTc55vOTJm8pDwaZJBGCCrzwrkSY/ob/C/w=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/file-upload/snap.manifest.json b/packages/examples/packages/file-upload/snap.manifest.json index dfc6db12bc..e564841621 100644 --- a/packages/examples/packages/file-upload/snap.manifest.json +++ b/packages/examples/packages/file-upload/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "Y8FjAWQERPZnXFiHwMDpR5yF0loWMbOdJjdvO+uYf5A=", + "shasum": "+uPTb3bOlEydaXXUp1YaaCuR77bs/KYlnnsDrc983DY=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/get-entropy/snap.manifest.json b/packages/examples/packages/get-entropy/snap.manifest.json index c24a5b2bc7..9a75bed592 100644 --- a/packages/examples/packages/get-entropy/snap.manifest.json +++ b/packages/examples/packages/get-entropy/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "LoFFGA3qj24Pe9Vr/Hpv0KAxUwI80Qdb3ihWR7M7Eag=", + "shasum": "9dG5S/QzV8DC7DQ10d4pp65QYKhGdsSYpUVQXM5qBN0=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/get-file/snap.manifest.json b/packages/examples/packages/get-file/snap.manifest.json index 0d51902516..eeabc23825 100644 --- a/packages/examples/packages/get-file/snap.manifest.json +++ b/packages/examples/packages/get-file/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "E5ZJ6XhrkUVcH19inuDA64yZQg92JuW8xO2HD0NaWY0=", + "shasum": "bLUkDZXvhV/kAyeqPFVp3Bd0SPk42AVkVtfWTWKoBd4=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/home-page/snap.manifest.json b/packages/examples/packages/home-page/snap.manifest.json index eb6106ccbb..3edb7ad92e 100644 --- a/packages/examples/packages/home-page/snap.manifest.json +++ b/packages/examples/packages/home-page/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "LQXgfkmMDLHqG23UE+vq7V2NTV2G+okrbWGtitICkBY=", + "shasum": "6Q2MkQCJd9UneQoCp3vxQGGQ8Ajrsf86BTiPBR4CIlk=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/images/snap.manifest.json b/packages/examples/packages/images/snap.manifest.json index 141f2d78cd..df253bf6d4 100644 --- a/packages/examples/packages/images/snap.manifest.json +++ b/packages/examples/packages/images/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "JFhngXwNXV1gfnin9435etNBL/Y4vEYrWImgZZCILD0=", + "shasum": "b6z/vd9UzvmbWax8XEqdu1Da6c0U8nx2fW8O3e3OVhU=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/interactive-ui/snap.manifest.json b/packages/examples/packages/interactive-ui/snap.manifest.json index 87414fe614..eab44755f8 100644 --- a/packages/examples/packages/interactive-ui/snap.manifest.json +++ b/packages/examples/packages/interactive-ui/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "Pi3qH8IlyNlERthaWzFGRxJGZb+XDJ89QdkY4XDxTqo=", + "shasum": "V/YxuQSq7yqlK2h/zypPPaEWeloh0J9tVMjPGYm0Mgo=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/invoke-snap/packages/consumer-signer/snap.manifest.json b/packages/examples/packages/invoke-snap/packages/consumer-signer/snap.manifest.json index d1abd7abbd..e27b65d4c6 100644 --- a/packages/examples/packages/invoke-snap/packages/consumer-signer/snap.manifest.json +++ b/packages/examples/packages/invoke-snap/packages/consumer-signer/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "K/YoIRPCc1i39hakRMVA/Eqnqc7MY+36G8I6/Ca1gqc=", + "shasum": "5+rhF05TzrBN+IAV/3tL2OElXjDV3JTMpRA6ZicthAs=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/invoke-snap/packages/core-signer/snap.manifest.json b/packages/examples/packages/invoke-snap/packages/core-signer/snap.manifest.json index 73af548b37..5945408e91 100644 --- a/packages/examples/packages/invoke-snap/packages/core-signer/snap.manifest.json +++ b/packages/examples/packages/invoke-snap/packages/core-signer/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "DFc9t3YIo2l+iK0uST4anZvk3OVnR9roGokhha5SNaw=", + "shasum": "z7xE1BJuNCfznRO3/1C3Et1FT/oKATYB3nrchlIIjTk=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/json-rpc/snap.manifest.json b/packages/examples/packages/json-rpc/snap.manifest.json index cb0db2bf16..0c7c7a06bf 100644 --- a/packages/examples/packages/json-rpc/snap.manifest.json +++ b/packages/examples/packages/json-rpc/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "gneP1YqODXq++KJZjTtuGjr1RB8izfkURNyyWxu9Uac=", + "shasum": "P6W+9HEzJ6H0XuZX6lERuskbzYdOATjxbW+NjcjUmPA=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/jsx/snap.manifest.json b/packages/examples/packages/jsx/snap.manifest.json index 3d08e82f82..6e1d67824c 100644 --- a/packages/examples/packages/jsx/snap.manifest.json +++ b/packages/examples/packages/jsx/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "whLo5E6I9SsxqOEhqSoZCmSSAi9y00t5IIoB95zj56g=", + "shasum": "g1h6l5PmU3C2tXZyfdsXRmcxGWR7rmfsVLw45t3eEtg=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/lifecycle-hooks/snap.manifest.json b/packages/examples/packages/lifecycle-hooks/snap.manifest.json index be1775bfec..ab0734ff5a 100644 --- a/packages/examples/packages/lifecycle-hooks/snap.manifest.json +++ b/packages/examples/packages/lifecycle-hooks/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "4FnjVvoeQC7msz0OdpwMatXvXlXyPPXxEwlhRUOt6Io=", + "shasum": "o89z7gAMsuZ88FMA2m+7LjmH0ZXStQ4VV5joHlza15A=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/localization/snap.manifest.json b/packages/examples/packages/localization/snap.manifest.json index dd9e12e627..175fa3e730 100644 --- a/packages/examples/packages/localization/snap.manifest.json +++ b/packages/examples/packages/localization/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "bb9yl3sUFSzfelkwY7LgGK9OOQlQI7lpPMwdOBsFTK4=", + "shasum": "O0whqPrZ7Iqr4RGBdWIi7nMcXPa/X08whUVOLT9V/ws=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/manage-state/snap.manifest.json b/packages/examples/packages/manage-state/snap.manifest.json index f437eba6ae..6e069e38a7 100644 --- a/packages/examples/packages/manage-state/snap.manifest.json +++ b/packages/examples/packages/manage-state/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "DPp7KHenp69URctJORMZuDaibhxInE43yiwPLEXPwJw=", + "shasum": "UxIvaI4TmlafrguqYUWmJ/L8iz57LSgLBBkYmqzOhaI=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/network-access/snap.manifest.json b/packages/examples/packages/network-access/snap.manifest.json index 0da0a35e46..e0c816a4f5 100644 --- a/packages/examples/packages/network-access/snap.manifest.json +++ b/packages/examples/packages/network-access/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "GhbegDCUE81gFKKZLRBBf/D2hfEOU9NfAczaTR0sOYc=", + "shasum": "9qUDCBIHh+FgaJSYylelB3JB1VcPmgNBESZZGNKK3/4=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/notifications/snap.manifest.json b/packages/examples/packages/notifications/snap.manifest.json index f5fa87d9f3..5148d74219 100644 --- a/packages/examples/packages/notifications/snap.manifest.json +++ b/packages/examples/packages/notifications/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "AaxZSpg3ajf3EphiCRvndaiJshfP8PLZh90I8lMGTPg=", + "shasum": "vfs20ja+DvBv5vZukhW2Y38sJY1CL3zEA14JS7725Ao=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/rollup-plugin/snap.manifest.json b/packages/examples/packages/rollup-plugin/snap.manifest.json index 274912db72..911b0a7300 100644 --- a/packages/examples/packages/rollup-plugin/snap.manifest.json +++ b/packages/examples/packages/rollup-plugin/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "z3FmXq08vm9sXiJI4wfkPbZ7sBB8gdsPOrcVuEVa0xM=", + "shasum": "Gmn3gYzZm188ctTJgWVvvXsBCMnqKgy5MvmwHQEYowM=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/signature-insights/snap.manifest.json b/packages/examples/packages/signature-insights/snap.manifest.json index 537db3391b..ebe94a6c4f 100644 --- a/packages/examples/packages/signature-insights/snap.manifest.json +++ b/packages/examples/packages/signature-insights/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "PfW4LfNyQP9K9MD/ZPF/oumq7RJf/SyJU2jeoUSJ2aM=", + "shasum": "Qj1+BivQzIMmikoDbUznJQJoEW/8BTaQaseCOcON+Zw=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/transaction-insights/snap.manifest.json b/packages/examples/packages/transaction-insights/snap.manifest.json index 5a79e6d690..007d250169 100644 --- a/packages/examples/packages/transaction-insights/snap.manifest.json +++ b/packages/examples/packages/transaction-insights/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "3r3+aNEdyR7CWPvBmmSCuZY+FTA+eFdkulS+0a2+KYU=", + "shasum": "9kalAse/bhDXFV4vXXNSlNZt/jxm1KkGkC1DF2nDcW8=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/wasm/snap.manifest.json b/packages/examples/packages/wasm/snap.manifest.json index f48e2fd2de..14182e6360 100644 --- a/packages/examples/packages/wasm/snap.manifest.json +++ b/packages/examples/packages/wasm/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "PLD8S8Lsjnkabuv6I1DxuMvdkjvbDF9o1Sc3X5zfAr4=", + "shasum": "fNPOi4FAZa4IXTEj/gZyBBx93NmiFlv2wGABRXK+3TY=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/webpack-plugin/snap.manifest.json b/packages/examples/packages/webpack-plugin/snap.manifest.json index 84c816d15b..d4866e1bce 100644 --- a/packages/examples/packages/webpack-plugin/snap.manifest.json +++ b/packages/examples/packages/webpack-plugin/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "e79yLA9JvLIWDuBMPXLYFNKT+6Tpun4yAkAUJEx/vrA=", + "shasum": "A5g5mxLzrae+3ShTHi1QDLdeHRDuUt4dGjwC2Mq/1NE=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/snaps-sdk/src/jsx/validation.ts b/packages/snaps-sdk/src/jsx/validation.ts index b523b653d9..507adf73d6 100644 --- a/packages/snaps-sdk/src/jsx/validation.ts +++ b/packages/snaps-sdk/src/jsx/validation.ts @@ -33,6 +33,7 @@ import type { Key, Nestable, SnapElement, + SnapsChildren, StringElement, } from './component'; import type { @@ -217,8 +218,8 @@ export const FieldStruct: Describe = element('Field', { export const FormStruct: Describe = element('Form', { children: children( // eslint-disable-next-line @typescript-eslint/no-use-before-define - [FieldStruct, lazy(() => BoxChildStruct), boolean()], - ) as unknown as Struct, null>, + [FieldStruct, lazy(() => BoxChildStruct)], + ) as unknown as Struct, null>, name: string(), }); @@ -268,8 +269,8 @@ export const AddressStruct: Describe = element('Address', { export const BoxStruct: Describe = element('Box', { children: children( // eslint-disable-next-line @typescript-eslint/no-use-before-define - [lazy(() => BoxChildStruct), boolean()], - ) as unknown as Struct, null>, + [lazy(() => BoxChildStruct)], + ) as unknown as Struct, null>, direction: optional(nullUnion([literal('horizontal'), literal('vertical')])), alignment: optional( nullUnion([ From e73b63d1f42a977506ef5adbad17fee698e88f5a Mon Sep 17 00:00:00 2001 From: Maarten Zuidhoorn Date: Tue, 25 Jun 2024 12:12:42 +0200 Subject: [PATCH 10/10] Remove more redundant boolean structs --- packages/examples/packages/bip32/snap.manifest.json | 2 +- packages/examples/packages/bip44/snap.manifest.json | 2 +- .../packages/browserify-plugin/snap.manifest.json | 2 +- .../examples/packages/browserify/snap.manifest.json | 2 +- .../packages/client-status/snap.manifest.json | 2 +- .../examples/packages/cronjobs/snap.manifest.json | 2 +- .../examples/packages/dialogs/snap.manifest.json | 2 +- .../packages/ethereum-provider/snap.manifest.json | 2 +- .../examples/packages/ethers-js/snap.manifest.json | 2 +- .../examples/packages/file-upload/snap.manifest.json | 2 +- .../examples/packages/get-entropy/snap.manifest.json | 2 +- .../examples/packages/get-file/snap.manifest.json | 2 +- .../examples/packages/home-page/snap.manifest.json | 2 +- packages/examples/packages/images/snap.manifest.json | 2 +- .../packages/interactive-ui/snap.manifest.json | 2 +- .../packages/consumer-signer/snap.manifest.json | 2 +- .../packages/core-signer/snap.manifest.json | 2 +- .../examples/packages/json-rpc/snap.manifest.json | 2 +- packages/examples/packages/jsx/snap.manifest.json | 2 +- .../packages/lifecycle-hooks/snap.manifest.json | 2 +- .../packages/localization/snap.manifest.json | 2 +- .../packages/manage-state/snap.manifest.json | 2 +- .../packages/network-access/snap.manifest.json | 2 +- .../packages/notifications/snap.manifest.json | 2 +- .../packages/rollup-plugin/snap.manifest.json | 2 +- .../packages/signature-insights/snap.manifest.json | 2 +- .../packages/transaction-insights/snap.manifest.json | 2 +- packages/examples/packages/wasm/snap.manifest.json | 2 +- .../packages/webpack-plugin/snap.manifest.json | 2 +- packages/snaps-sdk/src/jsx/validation.ts | 12 ++---------- 30 files changed, 31 insertions(+), 39 deletions(-) diff --git a/packages/examples/packages/bip32/snap.manifest.json b/packages/examples/packages/bip32/snap.manifest.json index c2d9c58e42..01bb717540 100644 --- a/packages/examples/packages/bip32/snap.manifest.json +++ b/packages/examples/packages/bip32/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "okOtnPSp63QzvGqnfiFeIj9upF+l2GUcuX0hld/8zS4=", + "shasum": "WfupwVnHUswiO0x/o2coJ0oj85v1x0j7wx1c5lYxP+o=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/bip44/snap.manifest.json b/packages/examples/packages/bip44/snap.manifest.json index 97604f0591..9227bb7049 100644 --- a/packages/examples/packages/bip44/snap.manifest.json +++ b/packages/examples/packages/bip44/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "9Wtu1MGgCNlXREDrOX5nYcUe+E8jESmmCEveUBR8n/c=", + "shasum": "+WhZ7cQ8dqA46bL5kzblh/1+GRShg87VtAS5N8N8+bU=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/browserify-plugin/snap.manifest.json b/packages/examples/packages/browserify-plugin/snap.manifest.json index 5ddf379d04..9375e7acb6 100644 --- a/packages/examples/packages/browserify-plugin/snap.manifest.json +++ b/packages/examples/packages/browserify-plugin/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "U3DkPSJLzf4OO7/Ybma4bBYP0fp+QpwrQXjHHyyVrW4=", + "shasum": "cvVZ8a8g9/b3tXhh9d1zf1GU11WvqcwVnR90ilpGSGw=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/browserify/snap.manifest.json b/packages/examples/packages/browserify/snap.manifest.json index 8bfa88fd0f..8036034a6d 100644 --- a/packages/examples/packages/browserify/snap.manifest.json +++ b/packages/examples/packages/browserify/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "O0+BkKmGK6BN1eYbct7KQEnvW3CRks/YrNUPzG79qlE=", + "shasum": "fuKiL65m1QakTuad3sCbK8YzRLNgVb9o/gSg80FK4RE=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/client-status/snap.manifest.json b/packages/examples/packages/client-status/snap.manifest.json index 86b703ddbf..72b5268f16 100644 --- a/packages/examples/packages/client-status/snap.manifest.json +++ b/packages/examples/packages/client-status/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "f8zeIa09pXt1W8vKHjDjznEdSjC2OBn3QVIijtHUwPg=", + "shasum": "I8VkGGWoxhalUw5IIncvCY/InJ15yst1MTnICJ6jUZ4=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/cronjobs/snap.manifest.json b/packages/examples/packages/cronjobs/snap.manifest.json index 58b7451a41..43edc28bdf 100644 --- a/packages/examples/packages/cronjobs/snap.manifest.json +++ b/packages/examples/packages/cronjobs/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "v4TY+hN5aUAIdvb31+YEvWCR/Dhc5eSoqv4QZAjgE6w=", + "shasum": "bt0ymBAUIDJC0ksow6/BO2+TCm8l5f4I7myCg/tXJfc=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/dialogs/snap.manifest.json b/packages/examples/packages/dialogs/snap.manifest.json index 51070db29e..b075fc627a 100644 --- a/packages/examples/packages/dialogs/snap.manifest.json +++ b/packages/examples/packages/dialogs/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "OSa/uP5sUDFb9cgnyJF43CHugmssYIbVYFJGXutEOJ8=", + "shasum": "P87ZOtKfVhN78E9zEw5fTGWhgKG0assHA1MZQNAZ0Xk=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/ethereum-provider/snap.manifest.json b/packages/examples/packages/ethereum-provider/snap.manifest.json index 171097edd4..fa8141d3db 100644 --- a/packages/examples/packages/ethereum-provider/snap.manifest.json +++ b/packages/examples/packages/ethereum-provider/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "UIm8NaJ2HQ+b0/gwzMrUolBPH94WaX0krT2j2vqS8Sw=", + "shasum": "sNKcZWHKrpSkWmsHD9nw4SNjuYehxTTXI+PhF0PAyP4=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/ethers-js/snap.manifest.json b/packages/examples/packages/ethers-js/snap.manifest.json index 4584b0170e..1d47aba947 100644 --- a/packages/examples/packages/ethers-js/snap.manifest.json +++ b/packages/examples/packages/ethers-js/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "2hc5tU0+vTc55vOTJm8pDwaZJBGCCrzwrkSY/ob/C/w=", + "shasum": "y9N2+eSpLMWFxoH+gmVT9u7oR95EP8QaYnlFNowAdZE=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/file-upload/snap.manifest.json b/packages/examples/packages/file-upload/snap.manifest.json index e564841621..9d3f223841 100644 --- a/packages/examples/packages/file-upload/snap.manifest.json +++ b/packages/examples/packages/file-upload/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "+uPTb3bOlEydaXXUp1YaaCuR77bs/KYlnnsDrc983DY=", + "shasum": "axxTRcxOlRzfmwdfTGo0MGMGxIXqxWW3ZMcvgZgU0RU=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/get-entropy/snap.manifest.json b/packages/examples/packages/get-entropy/snap.manifest.json index 9a75bed592..ed2353e8d1 100644 --- a/packages/examples/packages/get-entropy/snap.manifest.json +++ b/packages/examples/packages/get-entropy/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "9dG5S/QzV8DC7DQ10d4pp65QYKhGdsSYpUVQXM5qBN0=", + "shasum": "+Dq7vWhymZkiKZPixpzPOac9GYNFd3NXZmThe+RP5Rk=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/get-file/snap.manifest.json b/packages/examples/packages/get-file/snap.manifest.json index eeabc23825..6b5d699162 100644 --- a/packages/examples/packages/get-file/snap.manifest.json +++ b/packages/examples/packages/get-file/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "bLUkDZXvhV/kAyeqPFVp3Bd0SPk42AVkVtfWTWKoBd4=", + "shasum": "YONnSNnY1QXI799OnXcq7pOJ9mB2mf0TKA+hwrXei0M=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/home-page/snap.manifest.json b/packages/examples/packages/home-page/snap.manifest.json index 3edb7ad92e..c73b1a2ac8 100644 --- a/packages/examples/packages/home-page/snap.manifest.json +++ b/packages/examples/packages/home-page/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "6Q2MkQCJd9UneQoCp3vxQGGQ8Ajrsf86BTiPBR4CIlk=", + "shasum": "A9oCcxfQ/Ze21a+qSjmFEMjpyJDZTXBEUF/eEtzr00g=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/images/snap.manifest.json b/packages/examples/packages/images/snap.manifest.json index df253bf6d4..add7df61c4 100644 --- a/packages/examples/packages/images/snap.manifest.json +++ b/packages/examples/packages/images/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "b6z/vd9UzvmbWax8XEqdu1Da6c0U8nx2fW8O3e3OVhU=", + "shasum": "QpOZlqHNXUWxJEkcks0CEg15OO3HSximP79r+3hronM=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/interactive-ui/snap.manifest.json b/packages/examples/packages/interactive-ui/snap.manifest.json index eab44755f8..41f4417d82 100644 --- a/packages/examples/packages/interactive-ui/snap.manifest.json +++ b/packages/examples/packages/interactive-ui/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "V/YxuQSq7yqlK2h/zypPPaEWeloh0J9tVMjPGYm0Mgo=", + "shasum": "hFzGG0OogA6v6B3SOokVHVqTRuuTyLdA9iULpuifFAo=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/invoke-snap/packages/consumer-signer/snap.manifest.json b/packages/examples/packages/invoke-snap/packages/consumer-signer/snap.manifest.json index e27b65d4c6..db046d352f 100644 --- a/packages/examples/packages/invoke-snap/packages/consumer-signer/snap.manifest.json +++ b/packages/examples/packages/invoke-snap/packages/consumer-signer/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "5+rhF05TzrBN+IAV/3tL2OElXjDV3JTMpRA6ZicthAs=", + "shasum": "cRsMxa73YE9a7rrLfAvqWkL7LtqDCt1KQifgF4bA/YA=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/invoke-snap/packages/core-signer/snap.manifest.json b/packages/examples/packages/invoke-snap/packages/core-signer/snap.manifest.json index 5945408e91..4ad17151e9 100644 --- a/packages/examples/packages/invoke-snap/packages/core-signer/snap.manifest.json +++ b/packages/examples/packages/invoke-snap/packages/core-signer/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "z7xE1BJuNCfznRO3/1C3Et1FT/oKATYB3nrchlIIjTk=", + "shasum": "o4UgAxX2mrxEIUbi2og85R/dECjjg+q51X0t1x8KXb4=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/json-rpc/snap.manifest.json b/packages/examples/packages/json-rpc/snap.manifest.json index 0c7c7a06bf..47371a682b 100644 --- a/packages/examples/packages/json-rpc/snap.manifest.json +++ b/packages/examples/packages/json-rpc/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "P6W+9HEzJ6H0XuZX6lERuskbzYdOATjxbW+NjcjUmPA=", + "shasum": "3F5KdhaTzO0rYEAOJ9Y7Q0COWJqXOqcyTkG0FqdZ05s=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/jsx/snap.manifest.json b/packages/examples/packages/jsx/snap.manifest.json index 6e1d67824c..724d061e6d 100644 --- a/packages/examples/packages/jsx/snap.manifest.json +++ b/packages/examples/packages/jsx/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "g1h6l5PmU3C2tXZyfdsXRmcxGWR7rmfsVLw45t3eEtg=", + "shasum": "NUAroyflmKAfjOcXwHF9PWN9Ioa9AbakdYBBduNtlEI=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/lifecycle-hooks/snap.manifest.json b/packages/examples/packages/lifecycle-hooks/snap.manifest.json index ab0734ff5a..053f42c014 100644 --- a/packages/examples/packages/lifecycle-hooks/snap.manifest.json +++ b/packages/examples/packages/lifecycle-hooks/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "o89z7gAMsuZ88FMA2m+7LjmH0ZXStQ4VV5joHlza15A=", + "shasum": "Hpmj/t7F9hsI52wGOdI+ak3W8yYLsQAKDrwT5tVhnYg=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/localization/snap.manifest.json b/packages/examples/packages/localization/snap.manifest.json index 175fa3e730..6509b6bf1f 100644 --- a/packages/examples/packages/localization/snap.manifest.json +++ b/packages/examples/packages/localization/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "O0whqPrZ7Iqr4RGBdWIi7nMcXPa/X08whUVOLT9V/ws=", + "shasum": "wtOoGYeD+m/9PFLtyVgAEOLeJaZbmScyb5ovC1S4AWA=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/manage-state/snap.manifest.json b/packages/examples/packages/manage-state/snap.manifest.json index 6e069e38a7..620898c380 100644 --- a/packages/examples/packages/manage-state/snap.manifest.json +++ b/packages/examples/packages/manage-state/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "UxIvaI4TmlafrguqYUWmJ/L8iz57LSgLBBkYmqzOhaI=", + "shasum": "3CUmmQR8Rm9YPrR2vYdg97SGUzUndQf3OgYrUzlvLI4=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/network-access/snap.manifest.json b/packages/examples/packages/network-access/snap.manifest.json index e0c816a4f5..febf56b2b8 100644 --- a/packages/examples/packages/network-access/snap.manifest.json +++ b/packages/examples/packages/network-access/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "9qUDCBIHh+FgaJSYylelB3JB1VcPmgNBESZZGNKK3/4=", + "shasum": "VDkYGW0UgbTFLVuhnjjbYCJvHlMaFRfklmdUK3wyl4w=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/notifications/snap.manifest.json b/packages/examples/packages/notifications/snap.manifest.json index 5148d74219..6b5d15498a 100644 --- a/packages/examples/packages/notifications/snap.manifest.json +++ b/packages/examples/packages/notifications/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "vfs20ja+DvBv5vZukhW2Y38sJY1CL3zEA14JS7725Ao=", + "shasum": "6os9tFCmhv3HTapJ6Mzr5eG04r28c+hjgD/cLSDraEY=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/rollup-plugin/snap.manifest.json b/packages/examples/packages/rollup-plugin/snap.manifest.json index 911b0a7300..db64fce1ce 100644 --- a/packages/examples/packages/rollup-plugin/snap.manifest.json +++ b/packages/examples/packages/rollup-plugin/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "Gmn3gYzZm188ctTJgWVvvXsBCMnqKgy5MvmwHQEYowM=", + "shasum": "rG0w/CpDp7pUUEYz6z6LB/t2UtOnLPq3tXNC0ZuI5p4=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/signature-insights/snap.manifest.json b/packages/examples/packages/signature-insights/snap.manifest.json index ebe94a6c4f..4be49df722 100644 --- a/packages/examples/packages/signature-insights/snap.manifest.json +++ b/packages/examples/packages/signature-insights/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "Qj1+BivQzIMmikoDbUznJQJoEW/8BTaQaseCOcON+Zw=", + "shasum": "3sWzEjRApKpX8lrHwPjB4f0kuvwx7o1ZiuPxqTrEl3s=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/transaction-insights/snap.manifest.json b/packages/examples/packages/transaction-insights/snap.manifest.json index 007d250169..e9b59740d1 100644 --- a/packages/examples/packages/transaction-insights/snap.manifest.json +++ b/packages/examples/packages/transaction-insights/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "9kalAse/bhDXFV4vXXNSlNZt/jxm1KkGkC1DF2nDcW8=", + "shasum": "h6yDf1EBo4mpSb1qqHGQiutSvuExPmtthseHyuXhsvQ=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/wasm/snap.manifest.json b/packages/examples/packages/wasm/snap.manifest.json index 14182e6360..118c2f6141 100644 --- a/packages/examples/packages/wasm/snap.manifest.json +++ b/packages/examples/packages/wasm/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "fNPOi4FAZa4IXTEj/gZyBBx93NmiFlv2wGABRXK+3TY=", + "shasum": "VWTxqVgjWnanv5fmejkDm5Gz+yiKveFROceWqIg6vi0=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/examples/packages/webpack-plugin/snap.manifest.json b/packages/examples/packages/webpack-plugin/snap.manifest.json index d4866e1bce..d0db864731 100644 --- a/packages/examples/packages/webpack-plugin/snap.manifest.json +++ b/packages/examples/packages/webpack-plugin/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "A5g5mxLzrae+3ShTHi1QDLdeHRDuUt4dGjwC2Mq/1NE=", + "shasum": "0PQHPzqWuahbPrh5XviC7NnEnRhA185kaAIdCZcOfqs=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/snaps-sdk/src/jsx/validation.ts b/packages/snaps-sdk/src/jsx/validation.ts index 507adf73d6..64a38ac4ef 100644 --- a/packages/snaps-sdk/src/jsx/validation.ts +++ b/packages/snaps-sdk/src/jsx/validation.ts @@ -229,7 +229,6 @@ export const FormStruct: Describe = element('Form', { export const BoldStruct: Describe = element('Bold', { children: children([ string(), - boolean(), // eslint-disable-next-line @typescript-eslint/no-use-before-define lazy(() => ItalicStruct) as unknown as Struct< SnapElement @@ -243,7 +242,6 @@ export const BoldStruct: Describe = element('Bold', { export const ItalicStruct: Describe = element('Italic', { children: children([ string(), - boolean(), // eslint-disable-next-line @typescript-eslint/no-use-before-define lazy(() => BoldStruct) as unknown as Struct< SnapElement @@ -324,20 +322,14 @@ export const ImageStruct: Describe = element('Image', { */ export const LinkStruct: Describe = element('Link', { href: string(), - children: children([FormattingStruct, string(), boolean()]), + children: children([FormattingStruct, string()]), }); /** * A struct for the {@link TextElement} type. */ export const TextStruct: Describe = element('Text', { - children: children([ - string(), - boolean(), - BoldStruct, - ItalicStruct, - LinkStruct, - ]), + children: children([string(), BoldStruct, ItalicStruct, LinkStruct]), alignment: optional( nullUnion([literal('start'), literal('center'), literal('end')]), ),