diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6f0f670b58..ce6200e9b7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -27,6 +27,20 @@ jobs: secrets: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + publish-storybook-pr: + name: Publish Storybook to `pr/${{ github.event.number }}` folder + # needs: lint-build-test + if: ${{ github.event_name == 'pull_request' }} + permissions: + contents: write + uses: ./.github/workflows/publish-github-pages.yml + with: + build_script: yarn workspace @metamask/snaps-sdk build && yarn workspace @metamask/snaps-storybook build && yarn workspace @metamask/snaps-sdk build:storybook + publish_dir: ./packages/snaps-sdk/storybook-static + destination_dir: storybook/pr/${{ github.event.number }} + secrets: + PUBLISH_PAGES_TOKEN: ${{ secrets.PUBLISH_PAGES_TOKEN }} + publish-staging-simulator: name: Publish Snaps Simulator to `staging` folder needs: lint-build-test diff --git a/.gitignore b/.gitignore index a55eda1e97..a749f98688 100644 --- a/.gitignore +++ b/.gitignore @@ -78,3 +78,6 @@ packages/examples/examples/webpack/index.html # Ubuntu package files .deb + +# Storybook +storybook-static diff --git a/packages/examples/packages/bip32/snap.manifest.json b/packages/examples/packages/bip32/snap.manifest.json index 50e29b8f16..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": "cG78m4B2d8yHgKq1rKrZsbGZApWbJyd3MNoBPGcjKUQ=", + "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 0edcccd845..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": "YvyYRUgAVoeYPTzZRjxKRYNAjJe5usTDyqQkKbGTFTo=", + "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 0b81df8052..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": "FQwKp8UTAOjE30njzUvGS2OElCud9Hyj2+xkfRGeqIk=", + "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 8a1474a74b..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": "VglMoBJGhWpq4P+2P0DXMHVL3oF5+W2D4tlJtH8kdvw=", + "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 5a1fd660dc..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": "FHyz1K8TqeKyGniGR77kZFwRcm7IkjBuQ1zBifDPHvo=", + "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 2b571e309e..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": "9bT28snShrLQ7/OHDWJT6qDXdlc/asYH7x8o6zqfuUo=", + "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 d65a4cf207..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": "bozHl8e7Md1GuWvLOXtPbKGejiE2gBOGV0cIg6M7zFc=", + "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 6ddcc0cbeb..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": "AKvlBnNv0PrE8VfPCdxMmbTMq451QKo9ggsERIMPEZc=", + "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 ee235d0c31..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": "60LZXNvbDxyYnWy5qP43Tj8UZTfnmUsjItCOpnLTju0=", + "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 49e5585e57..42c5c2c58a 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": "E6A+dO1EcNp9XYm9M0yEUafFXRM0W72ylmOhbA9FFio=", + "shasum": "GeSSonGmFmVw2NPGOhmX2JQWzexQ/sLlCpXZzoNACIM=", "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 591f066658..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": "GFAjUWW8q9iX+2J/wKFlVRjq1oJ377NW5qSVTbkYtIQ=", + "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 2903902c62..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": "37wMtBqKrmWF3CUdyQHZ3Ey86NpGnffqIq6GnqTf+Ro=", + "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 44d22d2841..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": "9eJQJL4e2McSiHzayvby/1zLdHvf7Uc9ppUUw7v+rHQ=", + "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 bf2054eeb4..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": "oyaKZ7cbZisTYS6p9+ol9+tbjfq2Yly3G5UDvIwDLOQ=", + "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 f0440bb7ec..5c8f02d5e1 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": "LfydCMo1VRRXKdciizK7HPLso/tVufqM0JGpWSts/os=", + "shasum": "Ko9xBAU/AMTQmdJHIKVaXEvIMRKil4LMaFj+3gS3eZo=", "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 5f9b25affd..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": "8MoLqit0ldP9dXby0k6nOsNPcfTVhHFwD+NDkGTLWpE=", + "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 3afeb23165..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": "dd2RRHpmyhOtK2A1mWqgzYz+AI/UG2gyFWUsuCjW/QY=", + "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 cb70769db2..dfc52fefc2 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": "wXoG3PQ8lhJu5MCXOoFXPd/eEzrkMzdCYNL5YKCzOXg=", + "shasum": "W+ulyMm/r+ExAYs52MITLfxJEm0s8AZGogXQANgUr/w=", "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 52164100bc..4d175f99e6 100644 --- a/packages/examples/packages/jsx/snap.manifest.json +++ b/packages/examples/packages/jsx/snap.manifest.json @@ -1,5 +1,5 @@ { - "version": "1.1.1", + "version": "1.1.0", "description": "MetaMask example snap demonstrating the use of JSX for UI components.", "proposedName": "JSX Example Snap", "repository": { @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/snaps.git" }, "source": { - "shasum": "8CWhVcRMrN0tSMtxV0UXNvvS6kwVVJ+xJxADZ1AMkxY=", + "shasum": "21SHurFxkqSSML7EDePnsByVZitSpvYweBaNv4IrpjQ=", "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 05842992da..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": "+bfsURFNxni7MV/98u6zHjp9QgzWIAXI2wud9ClfejM=", + "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 4d51936f4f..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": "U5POJ0kzznk+u1A4xxgFQX3LIU8QoVUqYYUylOUmUhs=", + "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 5c670ce520..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": "nP0QOJ+vurTLPgKtiYq2zWMxoBBfgZ4VkcQ8svyU1Sk=", + "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 592b6d22ac..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": "VSXdhOsUAKupm4JXWCZcQ4HFKNrmxD3LySAmJlRQkGQ=", + "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 249d61be3f..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": "AP1xFEuyMDWaiey+kkUzjlMl1tt4ey26cntnHHNix/s=", + "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 b2e96e7812..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": "R6xONAf4IA5HXDU2oyL732pa5T+Nhc6idkEr9Zo/fDo=", + "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 3b9b2464fb..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": "nOHygj95R/T+NtgyXLdS5YNxom7bflJoLGaSqAiLZNU=", + "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 d5c487b6ef..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": "z18RzBaiNCS+tdOltE3CD6s/S+nTZTVHjLotmaVgKN8=", + "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 3498ce2b03..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": "ZQJV6BNeSLTrnxxnbT+P+I1O9/novFlZcKVJuTxnRRM=", + "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 2498e0f7bd..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": "nXyQsrdxb0igyATQImUC4UyAw598ldkJCRuu/OZTvss=", + "shasum": "0PQHPzqWuahbPrh5XviC7NnEnRhA185kaAIdCZcOfqs=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/snaps-browserify-plugin/src/__snapshots__/plugin.test.ts.snap b/packages/snaps-browserify-plugin/src/__snapshots__/plugin.test.ts.snap index 31390990d2..e3dbf604df 100644 --- a/packages/snaps-browserify-plugin/src/__snapshots__/plugin.test.ts.snap +++ b/packages/snaps-browserify-plugin/src/__snapshots__/plugin.test.ts.snap @@ -108,7 +108,7 @@ exports[`plugin generates a source map 1`] = ` }; }, {}] }, {}, [1]); -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJyIiwiZSIsIm4iLCJ0IiwibyIsImkiLCJmIiwiYyIsInJlcXVpcmUiLCJ1IiwiYSIsIkVycm9yIiwiY29kZSIsInAiLCJleHBvcnRzIiwiY2FsbCIsImxlbmd0aCIsIm1vZHVsZSIsIm9uUnBjUmVxdWVzdCIsInJlcXVlc3QiLCJjb25zb2xlIiwibG9nIiwibWV0aG9kIiwiaWQiXSwic291cmNlcyI6WyIuLi8uLi9ub2RlX21vZHVsZXMvYnJvd3Nlci1wYWNrL19wcmVsdWRlLmpzIiwiX3N0cmVhbV8wLmpzIl0sInNvdXJjZXNDb250ZW50IjpbIihmdW5jdGlvbigpe2Z1bmN0aW9uIHIoZSxuLHQpe2Z1bmN0aW9uIG8oaSxmKXtpZighbltpXSl7aWYoIWVbaV0pe3ZhciBjPVwiZnVuY3Rpb25cIj09dHlwZW9mIHJlcXVpcmUmJnJlcXVpcmU7aWYoIWYmJmMpcmV0dXJuIGMoaSwhMCk7aWYodSlyZXR1cm4gdShpLCEwKTt2YXIgYT1uZXcgRXJyb3IoXCJDYW5ub3QgZmluZCBtb2R1bGUgJ1wiK2krXCInXCIpO3Rocm93IGEuY29kZT1cIk1PRFVMRV9OT1RfRk9VTkRcIixhfXZhciBwPW5baV09e2V4cG9ydHM6e319O2VbaV1bMF0uY2FsbChw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UE7SUFBQSxPQUFBRCxDQUFBO0VBQUE7RUFBQSxPQUFBSixDQUFBO0FBQUE7RUFBQSxjQUFBUSxPQUFBLEVBQUFTLE1BQUEsRUFBQUgsT0FBQTtJQ0NBRyxNQUFBLENBQUFILE9BQUEsQ0FBQUksWUFBQTtNQUFBQztJQUFBO01BQ0FDLE9BQUEsQ0FBQUMsR0FBQTtNQUVBO1FBQUFDLE1BQUE7UUFBQUM7TUFBQSxJQUFBSixPQUFBO01BQ0EsT0FBQUcsTUFBQSxHQUFBQyxFQUFBO0lBQ0EiLCJpZ25vcmVMaXN0IjpbXX0=" `; exports[`plugin processes files using Browserify 1`] = ` diff --git a/packages/snaps-cli/.depcheckrc.json b/packages/snaps-cli/.depcheckrc.json index 7b43678e53..3ff0569a63 100644 --- a/packages/snaps-cli/.depcheckrc.json +++ b/packages/snaps-cli/.depcheckrc.json @@ -11,6 +11,7 @@ "assert", "browser-pack", "buffer", + "core-js-compat", "eslint-config-*", "eslint-plugin-*", "events", diff --git a/packages/snaps-cli/src/__mocks__/fs.ts b/packages/snaps-cli/src/__mocks__/fs.ts index 47f3c10b0d..c77915752d 100644 --- a/packages/snaps-cli/src/__mocks__/fs.ts +++ b/packages/snaps-cli/src/__mocks__/fs.ts @@ -9,6 +9,7 @@ const { join, dirname } = jest.requireActual('path'); // to provide the files it's looking for. const BROWSERIFY_FILES = [ /* eslint-disable n/no-extraneous-require */ + join(dirname(require.resolve('core-js-compat')), 'data.json'), join(dirname(require.resolve('is-core-module/package.json')), 'core.json'), join(dirname(require.resolve('browser-pack/package.json')), '_prelude.js'), /* eslint-enable n/no-extraneous-require */ diff --git a/packages/snaps-execution-environments/lavamoat/build-system/policy.json b/packages/snaps-execution-environments/lavamoat/build-system/policy.json index f0cf64f764..e58d79bf87 100644 --- a/packages/snaps-execution-environments/lavamoat/build-system/policy.json +++ b/packages/snaps-execution-environments/lavamoat/build-system/policy.json @@ -22,6 +22,7 @@ }, "packages": { "@babel/core>@ampproject/remapping": true, + "@babel/core>@babel/code-frame": true, "@babel/core>@babel/generator": true, "@babel/core>@babel/helper-compilation-targets": true, "@babel/core>@babel/helper-module-transforms": true, @@ -35,7 +36,6 @@ "depcheck>@babel/parser": true, "depcheck>@babel/traverse": true, "depcheck>json5": true, - "lavamoat>@babel/code-frame": true, "tsup>debug": true } }, @@ -57,6 +57,68 @@ "tsup>sucrase>@jridgewell/gen-mapping>@jridgewell/sourcemap-codec": true } }, + "@babel/core>@babel/code-frame": { + "globals": { + "console.warn": true, + "process": true + }, + "packages": { + "@babel/core>@babel/code-frame>@babel/highlight": true, + "tsup>postcss>picocolors": true + } + }, + "@babel/core>@babel/code-frame>@babel/highlight": { + "globals": { + "process": true + }, + "packages": { + "@babel/core>@babel/code-frame>@babel/highlight>chalk": true, + "lavamoat>@babel/highlight>@babel/helper-validator-identifier": true, + "lavamoat>@babel/highlight>js-tokens": true, + "tsup>postcss>picocolors": true + } + }, + "@babel/core>@babel/code-frame>@babel/highlight>chalk": { + "globals": { + "process.env.TERM": true, + "process.platform": true + }, + "packages": { + "@babel/core>@babel/code-frame>@babel/highlight>chalk>ansi-styles": true, + "@babel/core>@babel/code-frame>@babel/highlight>chalk>escape-string-regexp": true, + "@babel/core>@babel/code-frame>@babel/highlight>chalk>supports-color": true + } + }, + "@babel/core>@babel/code-frame>@babel/highlight>chalk>ansi-styles": { + "packages": { + "@babel/core>@babel/code-frame>@babel/highlight>chalk>ansi-styles>color-convert": true + } + }, + "@babel/core>@babel/code-frame>@babel/highlight>chalk>ansi-styles>color-convert": { + "packages": { + "@babel/core>@babel/code-frame>@babel/highlight>chalk>ansi-styles>color-convert>color-name": true + } + }, + "@babel/core>@babel/code-frame>@babel/highlight>chalk>supports-color": { + "builtin": { + "os.release": true + }, + "globals": { + "process.env": true, + "process.platform": true, + "process.stderr": true, + "process.stdout": true, + "process.versions.node.split": true + }, + "packages": { + "@babel/core>@babel/code-frame>@babel/highlight>chalk>supports-color>has-flag": true + } + }, + "@babel/core>@babel/code-frame>@babel/highlight>chalk>supports-color>has-flag": { + "globals": { + "process.argv": true + } + }, "@babel/core>@babel/generator": { "globals": { "console.error": true, @@ -95,6 +157,7 @@ "path.basename": true, "path.dirname": true, "path.join": true, + "path.relative": true, "path.resolve": true }, "globals": { @@ -156,9 +219,9 @@ }, "@babel/core>@babel/template": { "packages": { + "@babel/core>@babel/code-frame": true, "@babel/core>@babel/types": true, - "depcheck>@babel/parser": true, - "lavamoat>@babel/code-frame": true + "depcheck>@babel/parser": true } }, "@babel/core>@babel/types": { @@ -187,6 +250,9 @@ } }, "@babel/preset-env": { + "builtin": { + "fs.readFileSync": true + }, "globals": { "console.log": true, "console.warn": true, @@ -195,12 +261,13 @@ }, "packages": { "@babel/core>@babel/helper-compilation-targets": true, - "@babel/core>@babel/types": true, "@babel/preset-env>@babel/compat-data": true, "@babel/preset-env>@babel/helper-plugin-utils": true, "@babel/preset-env>@babel/helper-validator-option": true, + "@babel/preset-env>@babel/plugin-bugfix-firefox-class-in-computed-class-key": true, "@babel/preset-env>@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": true, "@babel/preset-env>@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": true, + "@babel/preset-env>@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly": true, "@babel/preset-env>@babel/plugin-syntax-async-generators": true, "@babel/preset-env>@babel/plugin-syntax-class-properties": true, "@babel/preset-env>@babel/plugin-syntax-class-static-block": true, @@ -271,10 +338,15 @@ "@babel/preset-env>babel-plugin-polyfill-corejs2": true, "@babel/preset-env>babel-plugin-polyfill-corejs3": true, "@babel/preset-env>babel-plugin-polyfill-regenerator": true, - "@babel/preset-env>core-js-compat": true, "@babel/preset-env>semver": true } }, + "@babel/preset-env>@babel/plugin-bugfix-firefox-class-in-computed-class-key": { + "packages": { + "@babel/preset-env>@babel/helper-plugin-utils": true, + "depcheck>@babel/traverse>@babel/helper-environment-visitor": true + } + }, "@babel/preset-env>@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": { "packages": { "@babel/preset-env>@babel/helper-plugin-utils": true @@ -284,8 +356,15 @@ "packages": { "@babel/core": true, "@babel/preset-env>@babel/helper-plugin-utils": true, - "@babel/preset-env>@babel/plugin-transform-optional-chaining": true, - "@babel/preset-env>@babel/plugin-transform-spread>@babel/helper-skip-transparent-expression-wrappers": true + "@babel/preset-env>@babel/plugin-transform-for-of>@babel/helper-skip-transparent-expression-wrappers": true, + "@babel/preset-env>@babel/plugin-transform-optional-chaining": true + } + }, + "@babel/preset-env>@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly": { + "packages": { + "@babel/core": true, + "@babel/preset-env>@babel/helper-plugin-utils": true, + "depcheck>@babel/traverse>@babel/helper-environment-visitor": true } }, "@babel/preset-env>@babel/plugin-syntax-async-generators": { @@ -447,7 +526,6 @@ "@babel/core>@babel/helper-compilation-targets": true, "@babel/preset-env>@babel/helper-plugin-utils": true, "@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-annotate-as-pure": true, - "@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-optimise-call-expression": true, "@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-replace-supers": true, "depcheck>@babel/traverse>@babel/helper-environment-visitor": true, "depcheck>@babel/traverse>@babel/helper-function-name": true, @@ -460,16 +538,11 @@ "@babel/core>@babel/types": true } }, - "@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-optimise-call-expression": { - "packages": { - "@babel/core>@babel/types": true - } - }, "@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-replace-supers": { "packages": { "@babel/core": true, - "@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-optimise-call-expression": true, "@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-replace-supers>@babel/helper-member-expression-to-functions": true, + "@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-replace-supers>@babel/helper-optimise-call-expression": true, "depcheck>@babel/traverse>@babel/helper-environment-visitor": true } }, @@ -478,6 +551,11 @@ "@babel/core>@babel/types": true } }, + "@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-replace-supers>@babel/helper-optimise-call-expression": { + "packages": { + "@babel/core>@babel/types": true + } + }, "@babel/preset-env>@babel/plugin-transform-computed-properties": { "packages": { "@babel/core": true, @@ -578,7 +656,13 @@ "@babel/preset-env>@babel/plugin-transform-for-of": { "packages": { "@babel/core": true, - "@babel/preset-env>@babel/helper-plugin-utils": true + "@babel/preset-env>@babel/helper-plugin-utils": true, + "@babel/preset-env>@babel/plugin-transform-for-of>@babel/helper-skip-transparent-expression-wrappers": true + } + }, + "@babel/preset-env>@babel/plugin-transform-for-of>@babel/helper-skip-transparent-expression-wrappers": { + "packages": { + "@babel/core>@babel/types": true } }, "@babel/preset-env>@babel/plugin-transform-function-name": { @@ -679,7 +763,6 @@ "packages": { "@babel/core": true, "@babel/core>@babel/helper-compilation-targets": true, - "@babel/preset-env>@babel/compat-data": true, "@babel/preset-env>@babel/helper-plugin-utils": true, "@babel/preset-env>@babel/plugin-syntax-object-rest-spread": true, "@babel/preset-env>@babel/plugin-transform-parameters": true @@ -703,7 +786,7 @@ "@babel/core": true, "@babel/preset-env>@babel/helper-plugin-utils": true, "@babel/preset-env>@babel/plugin-syntax-optional-chaining": true, - "@babel/preset-env>@babel/plugin-transform-spread>@babel/helper-skip-transparent-expression-wrappers": true + "@babel/preset-env>@babel/plugin-transform-for-of>@babel/helper-skip-transparent-expression-wrappers": true } }, "@babel/preset-env>@babel/plugin-transform-parameters": { @@ -725,11 +808,11 @@ "packages": { "@babel/core": true, "@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-annotate-as-pure": true, - "@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-optimise-call-expression": true, "@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-replace-supers": true, "@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-replace-supers>@babel/helper-member-expression-to-functions": true, + "@babel/preset-env>@babel/plugin-transform-classes>@babel/helper-replace-supers>@babel/helper-optimise-call-expression": true, + "@babel/preset-env>@babel/plugin-transform-for-of>@babel/helper-skip-transparent-expression-wrappers": true, "@babel/preset-env>@babel/plugin-transform-private-methods>@babel/helper-create-class-features-plugin>semver": true, - "@babel/preset-env>@babel/plugin-transform-spread>@babel/helper-skip-transparent-expression-wrappers": true, "depcheck>@babel/traverse>@babel/helper-environment-visitor": true, "depcheck>@babel/traverse>@babel/helper-function-name": true, "depcheck>@babel/traverse>@babel/helper-split-export-declaration": true @@ -786,12 +869,7 @@ "packages": { "@babel/core": true, "@babel/preset-env>@babel/helper-plugin-utils": true, - "@babel/preset-env>@babel/plugin-transform-spread>@babel/helper-skip-transparent-expression-wrappers": true - } - }, - "@babel/preset-env>@babel/plugin-transform-spread>@babel/helper-skip-transparent-expression-wrappers": { - "packages": { - "@babel/core>@babel/types": true + "@babel/preset-env>@babel/plugin-transform-for-of>@babel/helper-skip-transparent-expression-wrappers": true } }, "@babel/preset-env>@babel/plugin-transform-sticky-regex": { @@ -1815,6 +1893,7 @@ "console.log": true }, "packages": { + "@babel/core>@babel/code-frame": true, "@babel/core>@babel/generator": true, "@babel/core>@babel/types": true, "depcheck>@babel/parser": true, @@ -1823,7 +1902,6 @@ "depcheck>@babel/traverse>@babel/helper-hoist-variables": true, "depcheck>@babel/traverse>@babel/helper-split-export-declaration": true, "depcheck>@babel/traverse>globals": true, - "lavamoat>@babel/code-frame": true, "tsup>debug": true } }, @@ -1930,7 +2008,7 @@ }, "eslint-plugin-import>object.values>es-abstract>has-property-descriptors": { "packages": { - "eslint-plugin-import>array-includes>get-intrinsic": true + "lavamoat>json-stable-stringify>call-bind>es-define-property": true } }, "eslint-plugin-import>tsconfig-paths": { @@ -2070,105 +2148,6 @@ "readable-stream": true } }, - "lavamoat>@babel/code-frame": { - "globals": { - "console.warn": true, - "process.emitWarning": true - }, - "packages": { - "lavamoat>@babel/code-frame>chalk": true, - "lavamoat>@babel/highlight": true - } - }, - "lavamoat>@babel/code-frame>chalk": { - "globals": { - "process.env.TERM": true, - "process.platform": true - }, - "packages": { - "lavamoat>@babel/code-frame>chalk>ansi-styles": true, - "lavamoat>@babel/code-frame>chalk>escape-string-regexp": true, - "lavamoat>@babel/code-frame>chalk>supports-color": true - } - }, - "lavamoat>@babel/code-frame>chalk>ansi-styles": { - "packages": { - "lavamoat>@babel/code-frame>chalk>ansi-styles>color-convert": true - } - }, - "lavamoat>@babel/code-frame>chalk>ansi-styles>color-convert": { - "packages": { - "lavamoat>@babel/code-frame>chalk>ansi-styles>color-convert>color-name": true - } - }, - "lavamoat>@babel/code-frame>chalk>supports-color": { - "builtin": { - "os.release": true - }, - "globals": { - "process.env": true, - "process.platform": true, - "process.stderr": true, - "process.stdout": true, - "process.versions.node.split": true - }, - "packages": { - "lavamoat>@babel/code-frame>chalk>supports-color>has-flag": true - } - }, - "lavamoat>@babel/code-frame>chalk>supports-color>has-flag": { - "globals": { - "process.argv": true - } - }, - "lavamoat>@babel/highlight": { - "packages": { - "lavamoat>@babel/highlight>@babel/helper-validator-identifier": true, - "lavamoat>@babel/highlight>chalk": true, - "lavamoat>@babel/highlight>js-tokens": true - } - }, - "lavamoat>@babel/highlight>chalk": { - "globals": { - "process.env.TERM": true, - "process.platform": true - }, - "packages": { - "lavamoat>@babel/highlight>chalk>ansi-styles": true, - "lavamoat>@babel/highlight>chalk>escape-string-regexp": true, - "lavamoat>@babel/highlight>chalk>supports-color": true - } - }, - "lavamoat>@babel/highlight>chalk>ansi-styles": { - "packages": { - "lavamoat>@babel/highlight>chalk>ansi-styles>color-convert": true - } - }, - "lavamoat>@babel/highlight>chalk>ansi-styles>color-convert": { - "packages": { - "lavamoat>@babel/highlight>chalk>ansi-styles>color-convert>color-name": true - } - }, - "lavamoat>@babel/highlight>chalk>supports-color": { - "builtin": { - "os.release": true - }, - "globals": { - "process.env": true, - "process.platform": true, - "process.stderr": true, - "process.stdout": true, - "process.versions.node.split": true - }, - "packages": { - "lavamoat>@babel/highlight>chalk>supports-color>has-flag": true - } - }, - "lavamoat>@babel/highlight>chalk>supports-color>has-flag": { - "globals": { - "process.argv": true - } - }, "lavamoat>@lavamoat/aa": { "builtin": { "node:fs.lstatSync": true, @@ -2194,10 +2173,16 @@ "packages": { "browserify>has>function-bind": true, "eslint-plugin-import>array-includes>get-intrinsic": true, + "lavamoat>json-stable-stringify>call-bind>es-define-property": true, "lavamoat>json-stable-stringify>call-bind>es-errors": true, "lavamoat>json-stable-stringify>call-bind>set-function-length": true } }, + "lavamoat>json-stable-stringify>call-bind>es-define-property": { + "packages": { + "eslint-plugin-import>array-includes>get-intrinsic": true + } + }, "lavamoat>json-stable-stringify>call-bind>set-function-length": { "packages": { "browserify>util>is-typed-array>gopd": true, @@ -2210,8 +2195,7 @@ "lavamoat>json-stable-stringify>call-bind>set-function-length>define-data-property": { "packages": { "browserify>util>is-typed-array>gopd": true, - "eslint-plugin-import>array-includes>get-intrinsic": true, - "eslint-plugin-import>object.values>es-abstract>has-property-descriptors": true, + "lavamoat>json-stable-stringify>call-bind>es-define-property": true, "lavamoat>json-stable-stringify>call-bind>es-errors": true } }, @@ -2313,8 +2297,36 @@ "console.log": true }, "packages": { - "depcheck>@babel/parser": true, - "depcheck>@babel/traverse": true + "lavamoat>lavamoat-tofu>@babel/parser": true, + "lavamoat>lavamoat-tofu>@babel/traverse": true + } + }, + "lavamoat>lavamoat-tofu>@babel/traverse": { + "globals": { + "console.log": true + }, + "packages": { + "@babel/core>@babel/code-frame": true, + "@babel/core>@babel/generator": true, + "depcheck>@babel/traverse>@babel/helper-environment-visitor": true, + "depcheck>@babel/traverse>@babel/helper-function-name": true, + "depcheck>@babel/traverse>@babel/helper-hoist-variables": true, + "depcheck>@babel/traverse>@babel/helper-split-export-declaration": true, + "depcheck>@babel/traverse>globals": true, + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/parser": true, + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/types": true, + "tsup>debug": true + } + }, + "lavamoat>lavamoat-tofu>@babel/traverse>@babel/types": { + "globals": { + "console.warn": true, + "process.env.BABEL_TYPES_8_BREAKING": true + }, + "packages": { + "@babel/core>@babel/types>@babel/helper-string-parser": true, + "@babel/core>@babel/types>to-fast-properties": true, + "lavamoat>@babel/highlight>@babel/helper-validator-identifier": true } }, "readable-stream": { @@ -2375,7 +2387,7 @@ }, "packages": { "terser>@jridgewell/source-map>@jridgewell/trace-mapping>@jridgewell/resolve-uri": true, - "terser>@jridgewell/source-map>@jridgewell/trace-mapping>@jridgewell/sourcemap-codec": true + "tsup>sucrase>@jridgewell/gen-mapping>@jridgewell/sourcemap-codec": true } }, "terser>@jridgewell/source-map>@jridgewell/trace-mapping>@jridgewell/resolve-uri": { @@ -2383,13 +2395,6 @@ "define": true } }, - "terser>@jridgewell/source-map>@jridgewell/trace-mapping>@jridgewell/sourcemap-codec": { - "globals": { - "Buffer": true, - "TextDecoder": true, - "define": true - } - }, "terser>acorn": { "globals": { "console": true, @@ -2420,6 +2425,16 @@ "tsup>debug>ms": true } }, + "tsup>postcss>picocolors": { + "builtin": { + "tty.isatty": true + }, + "globals": { + "process.argv": true, + "process.env": true, + "process.platform": true + } + }, "tsup>sucrase>@jridgewell/gen-mapping": { "globals": { "define": true diff --git a/packages/snaps-sdk/.depcheckrc.json b/packages/snaps-sdk/.depcheckrc.json index 15d64e734b..5cad348f10 100644 --- a/packages/snaps-sdk/.depcheckrc.json +++ b/packages/snaps-sdk/.depcheckrc.json @@ -5,6 +5,7 @@ "@lavamoat/preinstall-always-fail", "@metamask/auto-changelog", "@metamask/eslint-*", + "@storybook/addon-controls", "@types/*", "@typescript-eslint/*", "eslint-config-*", diff --git a/packages/snaps-sdk/.storybook/main.ts b/packages/snaps-sdk/.storybook/main.ts new file mode 100644 index 0000000000..6e24e2779a --- /dev/null +++ b/packages/snaps-sdk/.storybook/main.ts @@ -0,0 +1,17 @@ +import { StorybookConfig } from '@storybook/types'; + +const config: StorybookConfig = { + stories: ['../src/**/*.stories.tsx', '../src/**/*.mdx'], + framework: { + name: '@metamask/snaps-storybook', + options: {}, + }, + addons: [ + '@storybook/addon-controls', + ], + core: { + disableTelemetry: true, + } +}; + +export default config; diff --git a/packages/snaps-sdk/.storybook/preview.ts b/packages/snaps-sdk/.storybook/preview.ts new file mode 100644 index 0000000000..c8c7589ead --- /dev/null +++ b/packages/snaps-sdk/.storybook/preview.ts @@ -0,0 +1,7 @@ +import type { Preview } from '@metamask/snaps-storybook'; + +const preview: Preview = { + tags: ['autodocs'], +}; + +export default preview; diff --git a/packages/snaps-sdk/package.json b/packages/snaps-sdk/package.json index 95bba09e87..0ec5e7abba 100644 --- a/packages/snaps-sdk/package.json +++ b/packages/snaps-sdk/package.json @@ -42,6 +42,7 @@ "jsx-runtime.d.ts" ], "scripts": { + "start": "storybook dev --port 7000 --no-open", "test": "jest && yarn posttest", "posttest": "jest-it-up --margin 0.25", "test:ci": "yarn test", @@ -51,6 +52,7 @@ "lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write", "lint:changelog": "../../scripts/validate-changelog.sh @metamask/snaps-sdk", "build": "tsup --clean && yarn build:types", + "build:storybook": "storybook build --quiet", "build:types": "tsc --project tsconfig.build.json", "clean": "rimraf '*.tsbuildinfo' 'dist'", "publish:preview": "yarn npm publish --tag preview", @@ -72,6 +74,9 @@ "@metamask/eslint-config-jest": "^12.1.0", "@metamask/eslint-config-nodejs": "^12.1.0", "@metamask/eslint-config-typescript": "^12.1.0", + "@metamask/snaps-storybook": "workspace:^", + "@storybook/addon-controls": "^8.1.11", + "@storybook/types": "^8.1.11", "@swc/core": "1.3.78", "@types/jest": "^27.5.1", "@typescript-eslint/eslint-plugin": "^5.42.1", @@ -93,6 +98,7 @@ "prettier": "^2.7.1", "prettier-plugin-packagejson": "^2.2.11", "rimraf": "^4.1.2", + "storybook": "^8.1.11", "ts-jest": "^29.1.1", "tsup": "^8.0.1", "typescript": "~4.8.4" diff --git a/packages/snaps-sdk/src/jsx/component.ts b/packages/snaps-sdk/src/jsx/component.ts index 43ca510f4e..7315d0294b 100644 --- a/packages/snaps-sdk/src/jsx/component.ts +++ b/packages/snaps-sdk/src/jsx/component.ts @@ -1,9 +1,9 @@ import type { Json } from '@metamask/utils'; /** - * A key, which can be a string or a number. + * A key, i.e., a string value. */ -export type Key = string | number; +export type Key = string; /** * A JSON object. diff --git a/packages/snaps-sdk/src/jsx/components/Address.stories.tsx b/packages/snaps-sdk/src/jsx/components/Address.stories.tsx new file mode 100644 index 0000000000..58e101273c --- /dev/null +++ b/packages/snaps-sdk/src/jsx/components/Address.stories.tsx @@ -0,0 +1,31 @@ +import type { Meta, Story } from '@metamask/snaps-storybook'; + +import type { AddressProps } from './Address'; +import { Address } from './Address'; + +const meta: Meta = { + title: 'UI/Address', + component: Address, + argTypes: { + address: { + description: + 'The address to display. This must be a valid Ethereum address starting with `0x`.', + table: { + // eslint-disable-next-line no-template-curly-in-string + type: { summary: '`0x${string}`' }, + }, + }, + }, +}; + +export default meta; + +/** + * The address component renders an (Ethereum) address. + */ +export const Default: Story = { + render: (props) =>
, + args: { + address: '0x4bbeEB066eD09B7AEd07bF39EEe0460DFa261520', + }, +}; diff --git a/packages/snaps-sdk/src/jsx/components/Box.stories.tsx b/packages/snaps-sdk/src/jsx/components/Box.stories.tsx new file mode 100644 index 0000000000..4937cb913a --- /dev/null +++ b/packages/snaps-sdk/src/jsx/components/Box.stories.tsx @@ -0,0 +1,108 @@ +import type { Meta, Story } from '@metamask/snaps-storybook'; + +import type { BoxProps } from './Box'; +import { Box } from './Box'; +import { Button } from './form'; +import { Heading } from './Heading'; +import { Text } from './Text'; + +const meta: Meta = { + title: 'Layout/Box', + component: Box, + argTypes: { + direction: { + description: 'The direction in which to lay out the children.', + options: ['vertical', 'horizontal'], + control: { + type: 'inline-radio', + }, + table: { + defaultValue: { + summary: 'vertical', + }, + }, + }, + alignment: { + description: 'The alignment of the children in the box.', + options: ['start', 'center', 'end', 'space-between'], + control: { + type: 'select', + }, + table: { + defaultValue: { + summary: 'start', + }, + }, + }, + }, +}; + +export default meta; + +/** + * The default box, which renders its children in a vertical layout. + */ +export const Vertical: Story = { + render: (props) => ( + + Box + A box with some text, and a + + + ), + args: { + direction: 'vertical', + }, +}; + +/** + * The box with horizontal layout, which renders its children in a horizontal + * layout (i.e., next to each other instead of on top of each other). + */ +export const Horizontal: Story = { + render: (props) => ( + + Box + A box with some text, and a + + + ), + args: { + direction: 'horizontal', + }, +}; + +/** + * The box with center alignment, which centers its children. + */ +export const Centered: Story = { + render: (props) => ( + + Box + A box with some text, and a + + + ), + args: { + alignment: 'center', + }, +}; + +/** + * The box with space-between alignment, which spaces its children evenly. + * + * This only works with horizontal direction. + */ +export const SpaceBetween: Story = { + render: (props) => ( + + Box + A box with some text, and a + + + ), + args: { + direction: 'horizontal', + alignment: 'space-between', + }, +}; diff --git a/packages/snaps-sdk/src/jsx/components/Card.stories.tsx b/packages/snaps-sdk/src/jsx/components/Card.stories.tsx new file mode 100644 index 0000000000..4489021401 --- /dev/null +++ b/packages/snaps-sdk/src/jsx/components/Card.stories.tsx @@ -0,0 +1,88 @@ +import type { Meta, Story } from '@metamask/snaps-storybook'; + +import type { CardProps } from './Card'; +import { Card } from './Card'; + +const meta: Meta = { + title: 'UI/Card', + component: Card, + argTypes: { + title: { + description: 'The title of the card.', + }, + description: { + description: 'The description to show below the title.', + }, + value: { + description: 'The value to show on the right side.', + }, + extra: { + description: 'An additional value to show below the value.', + }, + image: { + description: + 'The image to show as part of the card. If provided, this must be an SVG string.', + table: { + type: { summary: 'string' }, + }, + }, + }, +}; + +export default meta; + +/** + * Format a number as a currency. + * + * @param value - The value to format. + * @returns The formatted currency. + */ +function formatCurrency(value: number): string { + return new Intl.NumberFormat('en-US', { + style: 'currency', + currency: 'USD', + }).format(value); +} + +/** + * The card component renders a card with a title, description, and value. + */ +export const Default: Story = { + render: (props) => , + args: { + title: 'Title', + description: 'This is a description.', + value: formatCurrency(1200), + extra: '0.12 ETH', + }, +}; + +/** + * A basic card, with just a title and value. + */ +export const Basic: Story = { + render: (props) => , + args: { + title: 'Title', + value: formatCurrency(1200), + }, +}; + +/** + * A card with an image. + */ +export const WithImage: Story = { + render: (props) => , + args: { + title: 'Title', + description: 'This is a description.', + value: formatCurrency(1200), + extra: '0.12 ETH', + image: ` + + + 32x32 + + `, + }, +}; diff --git a/packages/snaps-sdk/src/jsx/components/Container.stories.tsx b/packages/snaps-sdk/src/jsx/components/Container.stories.tsx new file mode 100644 index 0000000000..813d379f64 --- /dev/null +++ b/packages/snaps-sdk/src/jsx/components/Container.stories.tsx @@ -0,0 +1,58 @@ +import type { Meta, Story } from '@metamask/snaps-storybook'; + +import { Box } from './Box'; +import type { ContainerProps } from './Container'; +import { Container } from './Container'; +import { Footer } from './Footer'; +import { Button } from './form'; +import { Text } from './Text'; + +const meta: Meta = { + title: 'Layout/Container', + component: Container, + argTypes: { + children: { + description: 'The children of the container.', + table: { + type: { summary: 'BoxElement | [BoxElement, FooterElement]' }, + }, + }, + }, +}; + +export default meta; + +/** + * The container component does not render anything itself, but it is used to + * group other components, namely the `Box` and `Footer` components. + * + * It can contain a `Box` and a `Footer` or just a `Box`. + */ +export const Default: Story = { + render: (props) => , + args: { + children: [ + + This is a box containing the main content. + , +
+ +
, + ], + }, +}; + +/** + * A container with only a box. In this case the footer will be populated + * automatically with the default footer. + */ +export const BoxOnly: Story = { + render: (props) => , + args: { + children: ( + + This is a box containing the main content. + + ), + }, +}; diff --git a/packages/snaps-sdk/src/jsx/components/Copyable.stories.tsx b/packages/snaps-sdk/src/jsx/components/Copyable.stories.tsx new file mode 100644 index 0000000000..9bfd7a8c6c --- /dev/null +++ b/packages/snaps-sdk/src/jsx/components/Copyable.stories.tsx @@ -0,0 +1,66 @@ +import type { Meta, Story } from '@metamask/snaps-storybook'; + +import type { CopyableProps } from './Copyable'; +import { Copyable } from './Copyable'; + +const meta: Meta = { + title: 'UI/Copyable', + component: Copyable, + argTypes: { + value: { + description: 'The value to display.', + table: { + type: { summary: 'string' }, + }, + }, + + sensitive: { + description: 'Whether the value is sensitive and should be obscured.', + control: { + type: 'boolean', + }, + table: { + defaultValue: { + summary: 'false', + }, + type: { summary: 'boolean' }, + }, + }, + }, +}; + +export default meta; + +/** + * The copyable component renders a value which can be copied to the clipboard. + * It can also be used to display raw data. + */ +export const Default: Story = { + render: (props) => , + args: { + value: 'This is a copyable value.', + }, +}; + +/** + * Values can be sensitive, in which case they are obscured until the user + * reveals them. + */ +export const Sensitive: Story = { + render: (props) => , + args: { + sensitive: true, + value: 'This is a copyable value.', + }, +}; + +/** + * For long values, the copyable component will truncate the value and show a + * "more" button to expand the value. + */ +export const LongValue: Story = { + render: (props) => , + args: { + value: `0x${'4bbeEB066eD09B7AEd07bF39EEe0460DFa261520'.repeat(20)}`, + }, +}; diff --git a/packages/snaps-sdk/src/jsx/components/Divider.stories.tsx b/packages/snaps-sdk/src/jsx/components/Divider.stories.tsx new file mode 100644 index 0000000000..fcb57d4971 --- /dev/null +++ b/packages/snaps-sdk/src/jsx/components/Divider.stories.tsx @@ -0,0 +1,32 @@ +import type { Meta, Story } from '@metamask/snaps-storybook'; + +import { Box } from './Box'; +import { Divider } from './Divider'; +import { Text } from './Text'; + +const meta: Meta = { + title: 'Layout/Divider', + component: Divider, +}; + +export default meta; + +/** + * The divider component renders a horizontal line between elements. + */ +export const Default: Story = { + render: () => , +}; + +/** + * It can be used to separate sections of content. + */ +export const WithText: Story = { + render: () => ( + + Some text + + Some more text + + ), +}; diff --git a/packages/snaps-sdk/src/jsx/components/Footer.stories.tsx b/packages/snaps-sdk/src/jsx/components/Footer.stories.tsx new file mode 100644 index 0000000000..be431f9190 --- /dev/null +++ b/packages/snaps-sdk/src/jsx/components/Footer.stories.tsx @@ -0,0 +1,48 @@ +import type { Meta, Story } from '@metamask/snaps-storybook'; + +import type { FooterProps } from './Footer'; +import { Footer } from './Footer'; +import { Button } from './form'; + +const meta: Meta = { + title: 'Layout/Footer', + component: Footer, + argTypes: { + children: { + description: + 'The button(s) to render in the footer. If only one button is provided, a cancel button is added automatically.', + table: { + type: { + summary: 'Button | [Button, Button]', + }, + }, + }, + }, +}; + +export default meta; + +/** + * The footer component one custom button. A cancel button is added + * automatically if only one button is provided. + * + * When the user clicks the first button, the `onUserInput` handler is called + * with the name of the button (if provided). + */ +export const Default: Story = { + render: (props) =>