Skip to content

Commit

Permalink
update after rebase and updade validation for empty Fields
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeRx committed Jun 26, 2024
1 parent f5eded1 commit b0d29d6
Show file tree
Hide file tree
Showing 34 changed files with 41 additions and 34 deletions.
2 changes: 1 addition & 1 deletion packages/examples/packages/bip32/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/bip44/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "MJMTC9FluALYjR+OWG88PkRuy6UoV4ljzzZFKDKGubo=",
"shasum": "X/WHY9l8UnQCDIc9mcxYJodqhSIVuXkbXdvU8g9g2q4=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/browserify/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "V3KG+PJgJFByudNBjZalk5Lbi8wpn45U9KgCJ5zai8k=",
"shasum": "Oj/vkgf9eDf1S41WapehD68XQeqWfcvEz63Bfizl8ww=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "vWH5q4YbhnASxrQ4FTQPewJdbmlLYVmBPy7wZGnucyE=",
"shasum": "FnZsozukN1WeI46J3iuRNBcFJ5qCjfABS+txXC2Sk5Q=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/cronjobs/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/dialogs/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/ethers-js/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "bQNNPR43ccMh4wEjKP1+gaFwzskeBq1e2XVynViFPio=",
"shasum": "uAialTJNkwpQqLK4HRY4VnLzGY4tSmWW6m27d0zfbCY=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/file-upload/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/get-entropy/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/get-file/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "2WkC3ANERYHIuBSIaWgwLZx0eTJ81YGPWBT3M8yHTTk=",
"shasum": "osDBY7OBEhSWI6sE+ri2RnnPh/2DrupqvfCi9Ukhj2k=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/home-page/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/images/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "fcZQ4CedTNafKCOzdJP8smIAWY7C/mH5QkbxHRY1dw8=",
"shasum": "Z2LLY7t3XvLyUK7eNjtWwUDAVBufX1dGT/MSeqvvfxM=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "9YRObcT8OuIChZltwbRLLqpAeHasRJaswiHEyEshYxs=",
"shasum": "TUAivGMDRGt6VLumYFFyJLGZ06MYKuezqr453TrQvIc=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "ARQRqFAc5Jmz222ZHFRccXXJBMQd0otOaG8UEGlXgBA=",
"shasum": "ZRXuzO9EfT+aWyG0OklNfV2Mj4Ov7/z7qGnbxrniA5c=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/json-rpc/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/jsx/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "8tKZ/zV6edYSnpZmxL8dIsuAmOJP1ch36xXGZ17hnnY=",
"shasum": "hMjW21jnLcKG07psWZahhjXBUCLnGbkpjpFNuO4T/ag=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "u2PeRFBSwSTk0EdMTKTYYIXgQ9Qh1pSscn8C0TUyXYk=",
"shasum": "HJeCUrT5HfVLNsJ6QOjjTAngSGpQkLq1igeAu/jmHLs=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/localization/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "tpyE+jYZvd7O0DkG8h4R6oQUbhysXPpt9laegc1FoO4=",
"shasum": "wXVqmYiZf68owCXvSTLjqooi1gBefarhr4i0dT5F7lw=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/manage-state/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "U2vQXBXGs2JSVkMQxK4pxu3Odqv/jKGyVObdqvusEds=",
"shasum": "GdsQAAEQ9GwoHUm76yR4v54MQdwIj9rdqcbH6WpwIac=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "YinZeCF81cpyqZDRhFruxDA7Nn8iMs71BOw6mdcZosU=",
"shasum": "niy1Zyq27xSH8feCHzSr4wX2tM/h3O2MhXMk/QZXJK8=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/packages/wasm/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "BmBGt2AIjSy+cD1WQGDWzCNJKx2CEUBl751AQzRNHzU=",
"shasum": "mBdDKVnxGKCoC3fhX9Xn43bMDCtZyZYMLaeXTvCngWE=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/MetaMask/snaps.git"
},
"source": {
"shasum": "cGDtdl4nhFTL3GZefTnfHg0pX74wQbvfoHkOlG8QG6U=",
"shasum": "5l4bR5PtIuTXCA2VxMwBf0pE26ILNaIVTmF+KycddbA=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
3 changes: 1 addition & 2 deletions packages/snaps-sdk/src/jsx/components/form/Field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ export type FieldProps = {
| DropdownElement
| FileInputElement
| InputElement
| CheckboxElement
| null;
| CheckboxElement;
};

const TYPE = 'Field';
Expand Down
2 changes: 1 addition & 1 deletion packages/snaps-sdk/src/jsx/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ const FieldChildStruct = nullUnion([
export const FieldStruct: Describe<FieldElement> = element('Field', {
label: optional(string()),
error: optional(string()),
children: nullable(FieldChildStruct),
children: FieldChildStruct,
});

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ const TEMPLATE_COMPONENTS: TemplateComponent[] = [
icon: 'field',
text: 'Field',
data: Field({
// @ts-expect-error - children is required
children: null,
}),
droppable: true,
Expand Down
3 changes: 2 additions & 1 deletion packages/snaps-simulator/src/features/builder/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 7 additions & 1 deletion packages/snaps-simulator/src/features/builder/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
BoxChildStruct,
FieldChildUnionStruct,
FormChildStruct,
Input,
type BoxElement,
type JSXElement,
} from '@metamask/snaps-sdk/jsx';
Expand Down Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit b0d29d6

Please sign in to comment.