From b0d29d66ddd2db6c43c27acfaf0f6c8669518cdf Mon Sep 17 00:00:00 2001 From: Guillaume Roux Date: Wed, 26 Jun 2024 13:33:07 +0200 Subject: [PATCH] update after rebase and updade validation for empty Fields --- 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-sdk/src/jsx/components/form/Field.ts | 3 +-- packages/snaps-sdk/src/jsx/validation.ts | 2 +- .../features/builder/components/TemplateComponentList.tsx | 1 + .../snaps-simulator/src/features/builder/utils.test.ts | 3 ++- packages/snaps-simulator/src/features/builder/utils.ts | 8 +++++++- 34 files changed, 41 insertions(+), 34 deletions(-) diff --git a/packages/examples/packages/bip32/snap.manifest.json b/packages/examples/packages/bip32/snap.manifest.json index dad9a36df3..07876f8e21 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": "8/Mr0b0oeGWE/q/c92K65WzbkycM7YeeAEMLD8Y0fXc=", + "shasum": "9w5Iae8s4lRIAdw/BwQmC3x1gHc7lgHdbVxrKTuXkLk=", "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 5e246b4ab2..8f09494c69 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": "MJMTC9FluALYjR+OWG88PkRuy6UoV4ljzzZFKDKGubo=", + "shasum": "X/WHY9l8UnQCDIc9mcxYJodqhSIVuXkbXdvU8g9g2q4=", "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 580fb37159..5bfe732550 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": "wRAgYZS5C5B3jdmpT/X0t7bI1m3n+h9D7qnK+7Buvbw=", + "shasum": "ahN1zyPd+MvigIQiAlWmhYO3k5KJ9y4qhXv6x7wuopE=", "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 c6a2f8813a..5b861cf478 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": "V3KG+PJgJFByudNBjZalk5Lbi8wpn45U9KgCJ5zai8k=", + "shasum": "Oj/vkgf9eDf1S41WapehD68XQeqWfcvEz63Bfizl8ww=", "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 c867001400..052774f6ed 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": "vWH5q4YbhnASxrQ4FTQPewJdbmlLYVmBPy7wZGnucyE=", + "shasum": "FnZsozukN1WeI46J3iuRNBcFJ5qCjfABS+txXC2Sk5Q=", "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 afb464524f..04f14d2a35 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": "yFi92dzJviUDgewXEm7iaIQi7tC+tt7a0v++OGGpaM8=", + "shasum": "YovJ0S9hnYHRhhNdkQ6nQjWcPzEfccmdh8K/uJKvuTE=", "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 a09def055e..e730c295b8 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": "3+FfXpbdaUJQGXpuS9HM8Bki3gtsHpFvlvCKEZ04yhM=", + "shasum": "S8G6+gBMfHCm8ZQS3jhmKnpg/9UDSsvJxFALNqXcHRE=", "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 b4070b7208..6ff5abd16b 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": "d0iHV/ctlmJkNxMaMTh/OSkZkXy8D9p2JTJiIBwNOOw=", + "shasum": "0YwDgG1QuqT8Tt6B6pAcET+G3XLk08LVm0vr1Jhb5ps=", "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 7f24c9005f..ca8ebcb3a4 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": "bQNNPR43ccMh4wEjKP1+gaFwzskeBq1e2XVynViFPio=", + "shasum": "uAialTJNkwpQqLK4HRY4VnLzGY4tSmWW6m27d0zfbCY=", "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 e69cd44344..2fd8348167 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": "xK+V+VsfDfpBQuevEy4Ieg2GtxJIjKPiygc/oJ+k2Io=", + "shasum": "DvLZLe5bNznD68rxLRAykxyDHDK1ncDlxMiSGwMqHCI=", "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 7f0b3931f8..d55f3ef373 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": "RqDUsJkpWtSZti+7RMHmxbLlbwuiG+cUl7JnaxaBfU8=", + "shasum": "zXNyZfVwSH6jm8CJhAtVO75B/lLE2kMwncGU1u6IPxA=", "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 142fd006b3..25e01319aa 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": "2WkC3ANERYHIuBSIaWgwLZx0eTJ81YGPWBT3M8yHTTk=", + "shasum": "osDBY7OBEhSWI6sE+ri2RnnPh/2DrupqvfCi9Ukhj2k=", "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 0002ca5762..b997e5cd1f 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": "6QS5l+DDRAtafIC0IfcZC7PLoN+ETZ/Rbhrf8BC3kOU=", + "shasum": "DyQgR4P57XFydoZApWF13IoF5YRkfEUkt9R5C0+ZJzw=", "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 a6a8032206..f72e3fba57 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": "fcZQ4CedTNafKCOzdJP8smIAWY7C/mH5QkbxHRY1dw8=", + "shasum": "Z2LLY7t3XvLyUK7eNjtWwUDAVBufX1dGT/MSeqvvfxM=", "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 fd57b675b5..e437f7960f 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": "9YRObcT8OuIChZltwbRLLqpAeHasRJaswiHEyEshYxs=", + "shasum": "TUAivGMDRGt6VLumYFFyJLGZ06MYKuezqr453TrQvIc=", "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 7d876a2ea7..5d5f384bc2 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": "ARQRqFAc5Jmz222ZHFRccXXJBMQd0otOaG8UEGlXgBA=", + "shasum": "ZRXuzO9EfT+aWyG0OklNfV2Mj4Ov7/z7qGnbxrniA5c=", "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 cc0cae5151..1d8a4def1b 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": "YdeGvHvXGfqmcQo/vkTxO+Prwt32IjYLgbgAEiKKpz0=", + "shasum": "LqR9SrGJLKzpTJhxqk8+Rq8VzPHlwrma4098aStglG4=", "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 f8e3345b75..e3077d6c88 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": "slCc1hSMDWjFzf+nDLJWS90mz34tBwjjDxssLpuTuxs=", + "shasum": "wst7/kyZfSdACnvtkdhMXQW/t1jbj8zSrpx98uVRHng=", "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 89846c894b..de4da2cd6d 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": "8tKZ/zV6edYSnpZmxL8dIsuAmOJP1ch36xXGZ17hnnY=", + "shasum": "hMjW21jnLcKG07psWZahhjXBUCLnGbkpjpFNuO4T/ag=", "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 27324c7c90..5631eadc7e 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": "u2PeRFBSwSTk0EdMTKTYYIXgQ9Qh1pSscn8C0TUyXYk=", + "shasum": "HJeCUrT5HfVLNsJ6QOjjTAngSGpQkLq1igeAu/jmHLs=", "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 2445cf4cc5..09ccd7d116 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": "tpyE+jYZvd7O0DkG8h4R6oQUbhysXPpt9laegc1FoO4=", + "shasum": "wXVqmYiZf68owCXvSTLjqooi1gBefarhr4i0dT5F7lw=", "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 68d6def881..81a306dba6 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": "w6AHudZxoQLwT1yl3nFBKXm9C4OZ5LRi8tNuHw7z+Fo=", + "shasum": "ZShGZbY62sEZDP1LI16/NaTo9n6bmQ+OQECZKfY06xY=", "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 6ca666e4f5..b553ddf2a5 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": "i4Wd65tgQ36ByBhHq/Y5i4Z6WrASHTSYzMDC71Th/Is=", + "shasum": "TQ3Co28nkOO8I56wwcDTmpoVoXKTDH5+WsrCIYVwC1U=", "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 f39fceaec1..1616e55cb1 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": "U2vQXBXGs2JSVkMQxK4pxu3Odqv/jKGyVObdqvusEds=", + "shasum": "GdsQAAEQ9GwoHUm76yR4v54MQdwIj9rdqcbH6WpwIac=", "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 1e6367bc01..4c990bd514 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": "f2ZTVxtTT5vprGyggIdEh1A7X/+g9UpK/DSE0tVGR1Q=", + "shasum": "uJOGLDi5LlWpN+ixx50bQAl58RlMQOMu7AQY70YpaVQ=", "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 8a8ab16f34..ff66bf71a4 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": "2h8tHQqi+od6yWpZX+PcxOkcPLhoTPhpTEnhO0tw+aI=", + "shasum": "OP6jw3TuYfTEuLZ8qmo4RJeCTB7xK3yMNk1txC+EChM=", "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 f06ac10c9c..7318eb4181 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": "YinZeCF81cpyqZDRhFruxDA7Nn8iMs71BOw6mdcZosU=", + "shasum": "niy1Zyq27xSH8feCHzSr4wX2tM/h3O2MhXMk/QZXJK8=", "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 e23fe614ad..5c65eb6bbb 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": "BmBGt2AIjSy+cD1WQGDWzCNJKx2CEUBl751AQzRNHzU=", + "shasum": "mBdDKVnxGKCoC3fhX9Xn43bMDCtZyZYMLaeXTvCngWE=", "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 e17ce4bf41..3d3afc2fef 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": "cGDtdl4nhFTL3GZefTnfHg0pX74wQbvfoHkOlG8QG6U=", + "shasum": "5l4bR5PtIuTXCA2VxMwBf0pE26ILNaIVTmF+KycddbA=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/snaps-sdk/src/jsx/components/form/Field.ts b/packages/snaps-sdk/src/jsx/components/form/Field.ts index 629ac250ed..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 - | null; + | CheckboxElement; }; const TYPE = 'Field'; diff --git a/packages/snaps-sdk/src/jsx/validation.ts b/packages/snaps-sdk/src/jsx/validation.ts index f7744ad91e..befdbd5508 100644 --- a/packages/snaps-sdk/src/jsx/validation.ts +++ b/packages/snaps-sdk/src/jsx/validation.ts @@ -245,7 +245,7 @@ const FieldChildStruct = nullUnion([ export const FieldStruct: Describe = element('Field', { label: optional(string()), error: optional(string()), - children: nullable(FieldChildStruct), + children: FieldChildStruct, }); /** diff --git a/packages/snaps-simulator/src/features/builder/components/TemplateComponentList.tsx b/packages/snaps-simulator/src/features/builder/components/TemplateComponentList.tsx index 35e037862d..ffd5dccf4f 100644 --- a/packages/snaps-simulator/src/features/builder/components/TemplateComponentList.tsx +++ b/packages/snaps-simulator/src/features/builder/components/TemplateComponentList.tsx @@ -94,6 +94,7 @@ const TEMPLATE_COMPONENTS: TemplateComponent[] = [ icon: 'field', text: 'Field', data: Field({ + // @ts-expect-error - children is required children: null, }), droppable: true, diff --git a/packages/snaps-simulator/src/features/builder/utils.test.ts b/packages/snaps-simulator/src/features/builder/utils.test.ts index bdf3f63350..cbaa3e18ad 100644 --- a/packages/snaps-simulator/src/features/builder/utils.test.ts +++ b/packages/snaps-simulator/src/features/builder/utils.test.ts @@ -118,7 +118,8 @@ describe('nodeModelsToComponent', () => { id: 5, parent: 4, text: 'child', - data: Field({ children: null }), + // @ts-expect-error children is required. + data: Field({ children: [] }), }, { id: 6, diff --git a/packages/snaps-simulator/src/features/builder/utils.ts b/packages/snaps-simulator/src/features/builder/utils.ts index 68a4071707..cd3e63cbd4 100644 --- a/packages/snaps-simulator/src/features/builder/utils.ts +++ b/packages/snaps-simulator/src/features/builder/utils.ts @@ -3,6 +3,7 @@ import { BoxChildStruct, FieldChildUnionStruct, FormChildStruct, + Input, type BoxElement, type JSXElement, } from '@metamask/snaps-sdk/jsx'; @@ -56,7 +57,12 @@ export function isValidBoxChild(child: JSXElement) { * @returns True if the node is a valid form children, otherwise false. */ export function isValidFormChild(child: JSXElement) { - return is(child, FormChildStruct); + // Add a children to the Field to pass validation. + const childCopy = deepClone(child); + if (childCopy.type === 'Field') { + childCopy.props.children = Input({ name: 'input' }); + } + return is(childCopy, FormChildStruct); } /**