diff --git a/packages/examples/packages/bip32/snap.manifest.json b/packages/examples/packages/bip32/snap.manifest.json index fd38d9e54b..a8ec1df143 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": "4zgPgkn2ZLn4uD4GHZ1QSIC5Pdgh0WwI+FAVtiExJPg=", + "shasum": "MbHxjakCrWiyX0tsCZoQRcFcgrCczQFEK5/wNQDdnVQ=", "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 274f70ffb9..7b1e804e52 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": "Pv3qQ6of+cBw8JeVZcO58YWHqY5FnzU87H1H+gEE+kc=", + "shasum": "15V07QO9rPDxPn3vM4QskfsKQGGmzjGflj8AD7gCgnc=", "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 96d9a5d2d8..83cab54813 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": "sC/3Z2MXiF336XZ/bFRfS7eE+nX/7teuW9PhA3deCPo=", + "shasum": "6Yw5uiOs0N8thZeEJf+tKmJ8GqRxQsoXlDJWF3Ft35k=", "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 14fbd160d7..d1576e604a 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": "4nvcNAdMjH7MT0jAQHBI6X2LTEBXRImuCBCIF/Oh/9Y=", + "shasum": "uwos2jlig0JLSfBnuF2gj9bjhPlKv/zq5Ik3uTUJs3E=", "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 10e21bc20f..ac7c587e06 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": "gHYWcYRMvSbB2Q+bk1JyWgQbg26+9WFa9nc1vj2eTUU=", + "shasum": "w5mkryEZrWmUSvZh9WJfKewEkSboNJqxIKMnzLjs5Tc=", "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 6be6a87a33..9a8dae9312 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": "w5/SzBe4VbTbid7bHZeCZdxKeOCeSf5w9kNEL5uwVbY=", + "shasum": "h1O3m93jIDMy1cP6UKW6RpBLHhTYspOPtk0MKzjM1a4=", "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 7ac265ee3d..21764f03c2 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": "RCg+DDDUyY5KdMIEqBeI7D2pwLEsJIZuyjGjTnTZiYs=", + "shasum": "kLSj4y8r3qnWPzULPiLa9SLqUyg+/FzAPwe4PYVgENc=", "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 43e17f5436..f86cffb746 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": "Cj9dHXqaNSmUSFpJ+TW/VOVTl1Gf993Cv0kgQ48xrW8=", + "shasum": "pAw1i97eZQAkVu1vghgoOKBdA5EImKc8HuC3rQyLo7k=", "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 f1cab383bd..f9eb9d4578 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": "Ze39WMAzwt/l29hfMFZHtg3R76ElyKvZprsMPXyS3Ls=", + "shasum": "Qzn8peIrwXUfXNesYS9XrxOPiEy8rcuGp8srLV+BWcE=", "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 e2e7109b27..21062f07ae 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": "gkz2lclCxtHr4KKR6+hx7jaW6ZVUTnW9u1wiDLTPn94=", + "shasum": "+HIIeV9viXaz8FnZVqkw9Nkuh2Sx9H5pUKhwuLa3KME=", "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 a37fab4282..4b7179c4b6 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": "K7iRS0dQTJSbvpDI8YADlMSTWlbk0kOBu3ysYNJFd30=", + "shasum": "KJq1GMNeYwapzQnIPrIvxxDcBWjWxJ4VX0XhOh3MnxE=", "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 3a7587ec32..6b2971b0ec 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": "ydgtHOH564F5/4XR1KgP86xIx02n11ZKexzVbA0ps5Q=", + "shasum": "5r5oP5gpDJTFwyl/ENQqBwXI5UOUm7qbVSPfmwcIvCQ=", "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 b21b2e9791..cd71aa6713 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": "Es5I4QVvhmqRbzDDoarvdcSG9KUKXfWchFDw5WKG4i0=", + "shasum": "8t+J0F/sTqNNnqUCz162R6hPctEnc07oW0z8o7Dko4E=", "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 1a4406d58e..8e776aafc8 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": "3y0kkz6IcK830KAogudokwqCx4qlDAzlpQ1Hek3o3Nw=", + "shasum": "FXwUfZ5XutKqwGSvsu6gzkVeMl/S2hQkLAZxoec+vEI=", "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 3a26c9044b..124adb6ab2 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": "4rE0OtUTBu/rh1SQB71ZO3Rvq0xVIToTV2JSckxrs2Y=", + "shasum": "Ti3lOIvzy79CF4lIb28GfwWljhHOaXgRc64saz4Xw4M=", "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 01e7d94269..bbb312becf 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": "94YpRvpZXv1STY9O8FHbKKT0s2E5wmyoNZrgTBQooyo=", + "shasum": "9SkOP5UJx3DPOQjfBS1nqHKbZ53iZSLA0ZU8IWB3rvI=", "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 8b178c963d..3cf4e15214 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": "334bZoNjf8+WEDVs6iVOHfZwY0/dCVhl3k14MvD/OPM=", + "shasum": "m+48XkzG/QoB1xCFb7nScz35JBF2YQ/1TErbk686A1M=", "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 e67cc86906..72b98dfc99 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": "2Ylq4JT1L3Zy8EFW+ZNhoj1R/PDBbFo/hMetjw02UBo=", + "shasum": "+0li4JLmwPIiG4z076VHqxkJGR9NN5sg4lKZwYeCsEU=", "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 5c02347175..1ad3b7ff70 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": "zP+4QCvzFeywzussgNC1XBDvgnkOMF/Fo68TBuqyFlI=", + "shasum": "k9Fr3RnjZx7YPAVlGbrBH3UYUsG7GdAPzflruPIrv68=", "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 e091e3b5c3..3574f9dece 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": "jLIZFbivIBXqN7bUS1XPXkxFMQ+2Bq0WmnEx+dGoj7E=", + "shasum": "Z87KmxfrWTMYEMbWKMXvYhtgRVSijrh06cb27sHYkqM=", "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 e1f01ed569..49ecd0ab09 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": "vWnPIKH4gz8N4AW27G74mUJlmkbqzNLbJjiZyy/xMlE=", + "shasum": "POX0xo+6nKE7IhUiUkviTG/mHybamAIm2t0LUnbLd1M=", "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 503be579df..ce0cb9cbaf 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": "OuMpcZu/d0s3ULofM93+3jgjRWPd5vFADAlIMZ9sENM=", + "shasum": "Y8KVZuDM3e1U50xMXTYSXLb70dg/y4+rLV85D2n9XI0=", "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 d279c3c2ee..05f9fa4c84 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": "N8sNz2AAOI5l4jkzXpS8ciATfmqUrH2dBhFeNk1U7x0=", + "shasum": "mCWOnK1aznB5S9fAlPfc6pvmjVvzlqGaA4JwmZjXih0=", "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 ec9de253b3..8c33bc46aa 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": "ZT2B0c7xFGz4w9WnVLs+gNANdyTzB7dABrYSQ2TNycE=", + "shasum": "0f/5PGd4YO2rmUpjl7vGEKSP62rkQU/hj7E6fK2qGCE=", "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 12ca2d10b1..a162e39d60 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": "h6zM4xieBFVcuBrJmRvJ53Rg6PYCeCyyse6I1ZSqwUA=", + "shasum": "WkcGZ3jJbpsex4ZJG1XWMqPoovy0dYLck4wUXw0S5h0=", "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 e91d2be906..6de3eb8c06 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": "DpFlgyKIAD6NDEKKWC5Om3vPw1lV7erEO4QV3np2sk0=", + "shasum": "/Wqo8YM1Pp9qP4dPUgCWnOnUUE18oQM1DwGDBF46zws=", "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 750793698a..774a6f4000 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": "/0U0RvqomIeWSQn0sPHtSb2MY7bA09nG3+ECYTPL1QM=", + "shasum": "JMWUcD0TWYI1zTaZZZtafIXtCaSuFp2h+AE8QMPAesM=", "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 82406b5659..7c7fa09b45 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": "MdYw3PCl4SDlm+bnz8RdrJm0VjSR+GdFhaRYMhLWmR4=", + "shasum": "C/UhBYE7tgtN6vABq2tIkuy6CF6szdd0z1wRteq50/U=", "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 c7e008ce06..ec99810576 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": "iPfVADXhKq0tMKLttqygu4NdODzRTdhZSkS3NOHWbvQ=", + "shasum": "7AR5lG7nZB7CutWzHZUoyJp3NKS4VtWzxStcXhgIQWk=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/snaps-sdk/src/jsx/components/form/Button.ts b/packages/snaps-sdk/src/jsx/components/form/Button.ts index 4e95f60e2e..da9179e8d8 100644 --- a/packages/snaps-sdk/src/jsx/components/form/Button.ts +++ b/packages/snaps-sdk/src/jsx/components/form/Button.ts @@ -1,5 +1,7 @@ -import type { StringElement } from '../../component'; +import type { SnapsChildren, StringElement } from '../../component'; import { createSnapComponent } from '../../component'; +import type { IconElement } from '../Icon'; +import type { ImageElement } from '../Image'; // TODO: Add the `onClick` prop to the `ButtonProps` type. @@ -16,7 +18,7 @@ import { createSnapComponent } from '../../component'; * @property disabled - Whether the button is disabled. Defaults to `false`. */ export type ButtonProps = { - children: StringElement; + children: SnapsChildren; name?: string | undefined; type?: 'button' | 'submit' | undefined; variant?: 'primary' | 'destructive' | undefined; diff --git a/packages/snaps-sdk/src/jsx/validation.test.tsx b/packages/snaps-sdk/src/jsx/validation.test.tsx index 4b74fb447d..713b5b1578 100644 --- a/packages/snaps-sdk/src/jsx/validation.test.tsx +++ b/packages/snaps-sdk/src/jsx/validation.test.tsx @@ -158,6 +158,12 @@ describe('ButtonStruct', () => { , , , + , + , ])('validates a button element', (value) => { expect(is(value, ButtonStruct)).toBe(true); }); diff --git a/packages/snaps-sdk/src/jsx/validation.ts b/packages/snaps-sdk/src/jsx/validation.ts index b0ff653037..de0f12d3d4 100644 --- a/packages/snaps-sdk/src/jsx/validation.ts +++ b/packages/snaps-sdk/src/jsx/validation.ts @@ -143,11 +143,34 @@ function element( }); } +/** + * A struct for the {@link ImageElement} type. + */ +export const ImageStruct: Describe = element('Image', { + src: svg(), + alt: optional(string()), +}); + +const IconNameStruct: Struct<`${IconName}`, null> = nullUnion( + Object.values(IconName).map((name) => literal(name)) as any, +); + +/** + * A struct for the {@link IconElement} type. + */ +export const IconStruct: Describe = element('Icon', { + name: IconNameStruct, + color: optional( + nullUnion([literal('default'), literal('primary'), literal('muted')]), + ), + size: optional(nullUnion([literal('md'), literal('inherit')])), +}); + /** * A struct for the {@link ButtonElement} type. */ export const ButtonStruct: Describe = element('Button', { - children: StringElementStruct, + children: children([StringElementStruct, ImageStruct, IconStruct]), name: optional(string()), type: optional(nullUnion([literal('button'), literal('submit')])), variant: optional(nullUnion([literal('primary'), literal('destructive')])), @@ -426,14 +449,6 @@ export const HeadingStruct: Describe = element('Heading', { children: StringElementStruct, }); -/** - * A struct for the {@link ImageElement} type. - */ -export const ImageStruct: Describe = element('Image', { - src: svg(), - alt: optional(string()), -}); - /** * A struct for the {@link LinkElement} type. */ @@ -442,21 +457,6 @@ export const LinkStruct: Describe = element('Link', { children: children([FormattingStruct, string()]), }); -const IconNameStruct: Struct<`${IconName}`, null> = nullUnion( - Object.values(IconName).map((name) => literal(name)) as any, -); - -/** - * A struct for the {@link IconElement} type. - */ -export const IconStruct: Describe = element('Icon', { - name: IconNameStruct, - color: optional( - nullUnion([literal('default'), literal('primary'), literal('muted')]), - ), - size: optional(nullUnion([literal('md'), literal('inherit')])), -}); - /** * A struct for the {@link TextElement} type. */