From ff7aa1b8ff63ff605c81bfd409309469a30a12be Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Fri, 27 Oct 2023 13:29:08 +0700 Subject: [PATCH 1/8] replace raw `extensions` with `extensionInstalled` --- package.json | 2 +- src/modals/Connect/Extension.tsx | 51 +++-- yarn.lock | 312 ++++++++++++++++--------------- 3 files changed, 187 insertions(+), 178 deletions(-) diff --git a/package.json b/package.json index 4684741168..4848dc1cfc 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "@fortawesome/free-solid-svg-icons": "^6.4.2", "@fortawesome/react-fontawesome": "^0.2.0", "@ledgerhq/hw-transport-webhid": "^6.27.19", - "@polkadot-cloud/assets": "^0.1.24", + "@polkadot-cloud/assets": "^0.1.26", "@polkadot-cloud/core": "^1.0.29", "@polkadot-cloud/react": "^0.1.98", "@polkadot-cloud/utils": "^0.0.23", diff --git a/src/modals/Connect/Extension.tsx b/src/modals/Connect/Extension.tsx index 3781d689b6..5dd5134b9d 100644 --- a/src/modals/Connect/Extension.tsx +++ b/src/modals/Connect/Extension.tsx @@ -19,15 +19,33 @@ export const Extension = ({ meta, size, flag }: ExtensionProps) => { const { t } = useTranslation('modals'); const { addNotification } = useNotifications(); const { connectExtensionAccounts } = useExtensionAccounts(); - const { extensions, extensionsStatus } = useExtensions(); + const { extensionsStatus, extensionInstalled } = useExtensions(); const { title, website, id } = meta; + const isInstalled = extensionInstalled(id); - const Icon = ExtensionIcons[id || ''] || undefined; + const status = !isInstalled ? 'not_found' : extensionsStatus[id]; + const disabled = status === 'connected' || !isInstalled; + const canConnect = isInstalled && status !== 'connected'; + + // Force re-render on click. + const [increment, setIncrement] = useState(0); - const extension = extensions.find((e) => e.id === id); - const status = !extension ? 'not_found' : extensionsStatus[id]; - const disabled = status === 'connected' || !extension; + // click to connect to extension + const handleClick = async () => { + if (canConnect) { + const connected = await connectExtensionAccounts(id); + // force re-render to display error messages + setIncrement(increment + 1); + if (connected) + addNotification({ + title: t('extensionConnected'), + subtitle: `${t('titleExtensionConnected', { title })}`, + }); + } + }; + + const Icon = ExtensionIcons[id || ''] || undefined; // determine message to be displayed based on extension status. let statusJsx; switch (status) { @@ -46,27 +64,8 @@ export const Extension = ({ meta, size, flag }: ExtensionProps) => { ); } - // force re-render on click - const [increment, setIncrement] = useState(0); - - // click to connect to extension - const handleClick = async () => { - if (status !== 'connected' && extension) { - const connected = await connectExtensionAccounts(extension); - // force re-render to display error messages - setIncrement(increment + 1); - - if (connected) { - addNotification({ - title: t('extensionConnected'), - subtitle: `${t('titleExtensionConnected', { title })}`, - }); - } - } - }; - return ( - +
@@ -86,7 +85,7 @@ export const Extension = ({ meta, size, flag }: ExtensionProps) => {
{flag && flag} - {extension ? statusJsx :

{t('notInstalled')}

} + {isInstalled ? statusJsx :

{t('notInstalled')}

}

{title}

diff --git a/yarn.lock b/yarn.lock index ad027ff3f2..9e9237cfe0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -355,9 +355,9 @@ eslint-visitor-keys "^3.3.0" "@eslint-community/regexpp@^4.5.1", "@eslint-community/regexpp@^4.6.1": - version "4.9.1" - resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.9.1.tgz#449dfa81a57a1d755b09aa58d826c1262e4283b4" - integrity sha512-Y27x+MBLjXa+0JWDhykM3+JE+il3kHKAEqabfEWq3SDhZjLYb6/BHL/JKFnH3fe207JaXkyDo685Oc2Glt6ifA== + version "4.10.0" + resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.10.0.tgz#548f6de556857c8bb73bbee70c35dc82a2e74d63" + integrity sha512-Cu96Sd2By9mCNTx2iyKOmq10v22jUVQv0lQnlGNy16oE9589yE+QADPbrMGCkA51cKZSg3Pu/aTJVTGfL/qjUA== "@eslint/eslintrc@^2.1.2": version "2.1.2" @@ -579,9 +579,14 @@ tslib "^2.6.0" "@polkadot-cloud/assets@^0.1.24": - version "0.1.24" - resolved "https://registry.yarnpkg.com/@polkadot-cloud/assets/-/assets-0.1.24.tgz#13b3ce04b63bda70a023e1fd71fa2998b739849b" - integrity sha512-HLpZ7NIYhALceeAHx6gdQKmYKxdrkd2GVphiWvvhoDgPBF586OQu+lv9Prldfi11+mY0EAC0MjGdreelr1Ma8Q== + version "0.1.25" + resolved "https://registry.yarnpkg.com/@polkadot-cloud/assets/-/assets-0.1.25.tgz#ad807e2b8671819396545df9507407811c712b03" + integrity sha512-3C6jzfSSaTq4TrfQ7RIbulz/r0D8JLDfeIO2A88GAG7GrMsA55o8mtCOvOSPH2Cn7byoghu9chSNwqGYvR6hGg== + +"@polkadot-cloud/assets@^0.1.26": + version "0.1.26" + resolved "https://registry.yarnpkg.com/@polkadot-cloud/assets/-/assets-0.1.26.tgz#f21bcbfac8922523465758a959fcbb27fcbb5d1d" + integrity sha512-1y5Vzymj8yR/+m8jiEbyp5Qfm9b/D8m15WEoBN4NoCLdnN3axKKnqpsyffBcEzM8jNlgoTCCuTbOkppQdEZINA== "@polkadot-cloud/core@^1.0.29": version "1.0.29" @@ -1089,74 +1094,74 @@ "@svgr/hast-util-to-babel-ast" "8.0.0" svg-parser "^2.0.4" -"@swc/core-darwin-arm64@1.3.93": - version "1.3.93" - resolved "https://registry.yarnpkg.com/@swc/core-darwin-arm64/-/core-darwin-arm64-1.3.93.tgz#aefd94625451988286bebccb1c072bae0a36bcdb" - integrity sha512-gEKgk7FVIgltnIfDO6GntyuQBBlAYg5imHpRgLxB1zSI27ijVVkksc6QwISzFZAhKYaBWIsFSVeL9AYSziAF7A== - -"@swc/core-darwin-x64@1.3.93": - version "1.3.93" - resolved "https://registry.yarnpkg.com/@swc/core-darwin-x64/-/core-darwin-x64-1.3.93.tgz#18409c6effdf508ddf1ebccfa77d35aaa6cd72f0" - integrity sha512-ZQPxm/fXdDQtn3yrYSL/gFfA8OfZ5jTi33yFQq6vcg/Y8talpZ+MgdSlYM0FkLrZdMTYYTNFiuBQuuvkA+av+Q== - -"@swc/core-linux-arm-gnueabihf@1.3.93": - version "1.3.93" - resolved "https://registry.yarnpkg.com/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.3.93.tgz#23a97bc94a8b2f23fb6cc4bc9d8936899e5eeff5" - integrity sha512-OYFMMI2yV+aNe3wMgYhODxHdqUB/jrK0SEMHHS44GZpk8MuBXEF+Mcz4qjkY5Q1EH7KVQqXb/gVWwdgTHpjM2A== - -"@swc/core-linux-arm64-gnu@1.3.93": - version "1.3.93" - resolved "https://registry.yarnpkg.com/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.3.93.tgz#7a17406a7cf76a959a617626d5ee2634ae9afa26" - integrity sha512-BT4dT78odKnJMNiq5HdjBsv29CiIdcCcImAPxeFqAeFw1LL6gh9nzI8E96oWc+0lVT5lfhoesCk4Qm7J6bty8w== - -"@swc/core-linux-arm64-musl@1.3.93": - version "1.3.93" - resolved "https://registry.yarnpkg.com/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.3.93.tgz#a30be7780090afefd3b8706398418cbe1d23db49" - integrity sha512-yH5fWEl1bktouC0mhh0Chuxp7HEO4uCtS/ly1Vmf18gs6wZ8DOOkgAEVv2dNKIryy+Na++ljx4Ym7C8tSJTrLw== - -"@swc/core-linux-x64-gnu@1.3.93": - version "1.3.93" - resolved "https://registry.yarnpkg.com/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.3.93.tgz#41e903fd82e059952d16051b442cbe65ee5b8cb3" - integrity sha512-OFUdx64qvrGJhXKEyxosHxgoUVgba2ztYh7BnMiU5hP8lbI8G13W40J0SN3CmFQwPP30+3oEbW7LWzhKEaYjlg== - -"@swc/core-linux-x64-musl@1.3.93": - version "1.3.93" - resolved "https://registry.yarnpkg.com/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.3.93.tgz#0866807545c44eac9b3254b374310ad5e1c573f9" - integrity sha512-4B8lSRwEq1XYm6xhxHhvHmKAS7pUp1Q7E33NQ2TlmFhfKvCOh86qvThcjAOo57x8DRwmpvEVrqvpXtYagMN6Ig== - -"@swc/core-win32-arm64-msvc@1.3.93": - version "1.3.93" - resolved "https://registry.yarnpkg.com/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.3.93.tgz#c72411dea2fd4f62a832f71a6e15424d849e7610" - integrity sha512-BHShlxtkven8ZjjvZ5QR6sC5fZCJ9bMujEkiha6W4cBUTY7ce7qGFyHmQd+iPC85d9kD/0cCiX/Xez8u0BhO7w== - -"@swc/core-win32-ia32-msvc@1.3.93": - version "1.3.93" - resolved "https://registry.yarnpkg.com/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.3.93.tgz#05c2b031b976af4ef81f5073ee114254678a5d5d" - integrity sha512-nEwNWnz4JzYAK6asVvb92yeylfxMYih7eMQOnT7ZVlZN5ba9WF29xJ6kcQKs9HRH6MvWhz9+wRgv3FcjlU6HYA== - -"@swc/core-win32-x64-msvc@1.3.93": - version "1.3.93" - resolved "https://registry.yarnpkg.com/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.3.93.tgz#f8748b3fd1879f13084b1b0814edf328c662935c" - integrity sha512-jibQ0zUr4kwJaQVwgmH+svS04bYTPnPw/ZkNInzxS+wFAtzINBYcU8s2PMWbDb2NGYiRSEeoSGyAvS9H+24JFA== +"@swc/core-darwin-arm64@1.3.95": + version "1.3.95" + resolved "https://registry.yarnpkg.com/@swc/core-darwin-arm64/-/core-darwin-arm64-1.3.95.tgz#e6b6363fc0a22ee3cd9a63130d2042d5027aae2c" + integrity sha512-VAuBAP3MNetO/yBIBzvorUXq7lUBwhfpJxYViSxyluMwtoQDhE/XWN598TWMwMl1ZuImb56d7eUsuFdjgY7pJw== + +"@swc/core-darwin-x64@1.3.95": + version "1.3.95" + resolved "https://registry.yarnpkg.com/@swc/core-darwin-x64/-/core-darwin-x64-1.3.95.tgz#7911a03f4e0f9359710d3d6ad1dba7b5569efe5d" + integrity sha512-20vF2rvUsN98zGLZc+dsEdHvLoCuiYq/1B+TDeE4oolgTFDmI1jKO+m44PzWjYtKGU9QR95sZ6r/uec0QC5O4Q== + +"@swc/core-linux-arm-gnueabihf@1.3.95": + version "1.3.95" + resolved "https://registry.yarnpkg.com/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.3.95.tgz#95a2c9fc6849df9f1944957669c82c559d65b24f" + integrity sha512-oEudEM8PST1MRNGs+zu0cx5i9uP8TsLE4/L9HHrS07Ck0RJ3DCj3O2fU832nmLe2QxnAGPwBpSO9FntLfOiWEQ== + +"@swc/core-linux-arm64-gnu@1.3.95": + version "1.3.95" + resolved "https://registry.yarnpkg.com/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.3.95.tgz#1914d42041469582e3cc56619890edbcc54e83d6" + integrity sha512-pIhFI+cuC1aYg+0NAPxwT/VRb32f2ia8oGxUjQR6aJg65gLkUYQzdwuUmpMtFR2WVf7WVFYxUnjo4UyMuyh3ng== + +"@swc/core-linux-arm64-musl@1.3.95": + version "1.3.95" + resolved "https://registry.yarnpkg.com/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.3.95.tgz#8d73822a5807575a572d6a2d6cb64587a9f19ce6" + integrity sha512-ZpbTr+QZDT4OPJfjPAmScqdKKaT+wGurvMU5AhxLaf85DuL8HwUwwlL0n1oLieLc47DwIJEMuKQkYhXMqmJHlg== + +"@swc/core-linux-x64-gnu@1.3.95": + version "1.3.95" + resolved "https://registry.yarnpkg.com/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.3.95.tgz#80467727ec11da3de49e6be2abf735964a808483" + integrity sha512-n9SuHEFtdfSJ+sHdNXNRuIOVprB8nbsz+08apKfdo4lEKq6IIPBBAk5kVhPhkjmg2dFVHVo4Tr/OHXM1tzWCCw== + +"@swc/core-linux-x64-musl@1.3.95": + version "1.3.95" + resolved "https://registry.yarnpkg.com/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.3.95.tgz#675a53ac037846bd1bb9840a95ebcb5289265d3b" + integrity sha512-L1JrVlsXU3LC0WwmVnMK9HrOT2uhHahAoPNMJnZQpc18a0paO9fqifPG8M/HjNRffMUXR199G/phJsf326UvVg== + +"@swc/core-win32-arm64-msvc@1.3.95": + version "1.3.95" + resolved "https://registry.yarnpkg.com/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.3.95.tgz#7f0b5d0d0a090c5c625bbc54ffaf427d861c068a" + integrity sha512-YaP4x/aZbUyNdqCBpC2zL8b8n58MEpOUpmOIZK6G1SxGi+2ENht7gs7+iXpWPc0sy7X3YPKmSWMAuui0h8lgAA== + +"@swc/core-win32-ia32-msvc@1.3.95": + version "1.3.95" + resolved "https://registry.yarnpkg.com/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.3.95.tgz#06e2778549a37f0b505b24fd8f40c1c038e29f3e" + integrity sha512-w0u3HI916zT4BC/57gOd+AwAEjXeUlQbGJ9H4p/gzs1zkSHtoDQghVUNy3n/ZKp9KFod/95cA8mbVF9t1+6epQ== + +"@swc/core-win32-x64-msvc@1.3.95": + version "1.3.95" + resolved "https://registry.yarnpkg.com/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.3.95.tgz#40f6b131e84ba6ed97f516edf0f9d5a766c0da64" + integrity sha512-5RGnMt0S6gg4Gc6QtPUJ3Qs9Un4sKqccEzgH/tj7V/DVTJwKdnBKxFZfgQ34OR2Zpz7zGOn889xwsFVXspVWNA== "@swc/core@^1.3.85": - version "1.3.93" - resolved "https://registry.yarnpkg.com/@swc/core/-/core-1.3.93.tgz#be4282aa44deffb0e5081a2613bac00335600630" - integrity sha512-690GRr1wUGmGYZHk7fUduX/JUwViMF2o74mnZYIWEcJaCcd9MQfkhsxPBtjeg6tF+h266/Cf3RPYhsFBzzxXcA== + version "1.3.95" + resolved "https://registry.yarnpkg.com/@swc/core/-/core-1.3.95.tgz#2743b8460e6f29385e3dbe49f3f66277ab233536" + integrity sha512-PMrNeuqIusq9DPDooV3FfNEbZuTu5jKAc04N3Hm6Uk2Fl49cqElLFQ4xvl4qDmVDz97n3n/C1RE0/f6WyGPEiA== dependencies: "@swc/counter" "^0.1.1" "@swc/types" "^0.1.5" optionalDependencies: - "@swc/core-darwin-arm64" "1.3.93" - "@swc/core-darwin-x64" "1.3.93" - "@swc/core-linux-arm-gnueabihf" "1.3.93" - "@swc/core-linux-arm64-gnu" "1.3.93" - "@swc/core-linux-arm64-musl" "1.3.93" - "@swc/core-linux-x64-gnu" "1.3.93" - "@swc/core-linux-x64-musl" "1.3.93" - "@swc/core-win32-arm64-msvc" "1.3.93" - "@swc/core-win32-ia32-msvc" "1.3.93" - "@swc/core-win32-x64-msvc" "1.3.93" + "@swc/core-darwin-arm64" "1.3.95" + "@swc/core-darwin-x64" "1.3.95" + "@swc/core-linux-arm-gnueabihf" "1.3.95" + "@swc/core-linux-arm64-gnu" "1.3.95" + "@swc/core-linux-arm64-musl" "1.3.95" + "@swc/core-linux-x64-gnu" "1.3.95" + "@swc/core-linux-x64-musl" "1.3.95" + "@swc/core-win32-arm64-msvc" "1.3.95" + "@swc/core-win32-ia32-msvc" "1.3.95" + "@swc/core-win32-x64-msvc" "1.3.95" "@swc/counter@^0.1.1": version "0.1.2" @@ -1228,11 +1233,11 @@ integrity sha512-YI/M/4HRImtNf3pJgbF+W6FrXovqj+T+/HpENLTooK9PnkacBsDpeP3IpHab40CClUfhNmdM2WTNP2sa2dni5Q== "@types/node@*": - version "20.8.7" - resolved "https://registry.yarnpkg.com/@types/node/-/node-20.8.7.tgz#ad23827850843de973096edfc5abc9e922492a25" - integrity sha512-21TKHHh3eUHIi2MloeptJWALuCu5H7HQTdTrWIFReA8ad+aggoX+lRes3ex7/FtpC+sVUpFMQ+QTfYr74mruiQ== + version "20.8.9" + resolved "https://registry.yarnpkg.com/@types/node/-/node-20.8.9.tgz#646390b4fab269abce59c308fc286dcd818a2b08" + integrity sha512-UzykFsT3FhHb1h7yD4CA4YhBHq545JC0YnEz41xkipN88eKQtL6rSgocL5tbAP6Ola9Izm/Aw4Ora8He4x0BHg== dependencies: - undici-types "~5.25.1" + undici-types "~5.26.4" "@types/prop-types@*": version "15.7.9" @@ -1268,9 +1273,9 @@ "@types/react" "*" "@types/react@*", "@types/react@^18.2.32": - version "18.2.32" - resolved "https://registry.yarnpkg.com/@types/react/-/react-18.2.32.tgz#7ec787730c45ee9a3c0ed150b19e95c31fe4608a" - integrity sha512-F0FVIZQ1x5Gxy/VYJb7XcWvCcHR28Sjwt1dXLspdIatfPq1MVACfnBDwKe6ANLxQ64riIJooXClpUR6oxTiepg== + version "18.2.33" + resolved "https://registry.yarnpkg.com/@types/react/-/react-18.2.33.tgz#055356243dc4350a9ee6c6a2c07c5cae12e38877" + integrity sha512-v+I7S+hu3PIBoVkKGpSYYpiBT1ijqEzWpzQD62/jm4K74hPpSP7FF9BnKG6+fg2+62weJYkkBWDJlZt5JO/9hg== dependencies: "@types/prop-types" "*" "@types/scheduler" "*" @@ -1455,14 +1460,14 @@ acorn-jsx@^5.3.2: integrity sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ== acorn-walk@^8.2.0: - version "8.2.0" - resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.2.0.tgz#741210f2e2426454508853a2f44d0ab83b7f69c1" - integrity sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA== + version "8.3.0" + resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.3.0.tgz#2097665af50fd0cf7a2dfccd2b9368964e66540f" + integrity sha512-FS7hV565M5l1R08MXqo8odwMTB02C2UqzB17RVgu9EyuYFBqJZ3/ZY97sQD5FewVu1UyDFc1yztUDrAwT0EypA== acorn@^8.10.0, acorn@^8.9.0: - version "8.10.0" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.10.0.tgz#8be5b3907a67221a81ab23c7889c4c5526b62ec5" - integrity sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw== + version "8.11.1" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.11.1.tgz#29c6f12c3002d884b6f8baa37089e1917425cd3d" + integrity sha512-IJTNCJMRHfRfb8un89z1QtS0x890C2QUrUxFMK8zy+RizcId6mfnqOf68Bu9YkDgpLYuvCm6aYbwDatXVZPjMQ== ajv@^6.12.4: version "6.12.6" @@ -1819,13 +1824,14 @@ cac@^6.7.14: resolved "https://registry.yarnpkg.com/cac/-/cac-6.7.14.tgz#804e1e6f506ee363cb0e3ccbb09cad5dd9870959" integrity sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ== -call-bind@^1.0.0, call-bind@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/call-bind/-/call-bind-1.0.2.tgz#b1d4e89e688119c3c9a903ad30abb2f6a919be3c" - integrity sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA== +call-bind@^1.0.0, call-bind@^1.0.2, call-bind@^1.0.4, call-bind@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/call-bind/-/call-bind-1.0.5.tgz#6fa2b7845ce0ea49bf4d8b9ef64727a2c2e2e513" + integrity sha512-C3nQxfFZxFRVoJoGKKI8y3MOEo129NQ+FgQ08iye+Mk4zNZZGdjfs06bVTr+DBSlA66Q2VEcMki/cUCP4SercQ== dependencies: - function-bind "^1.1.1" - get-intrinsic "^1.0.2" + function-bind "^1.1.2" + get-intrinsic "^1.2.1" + set-function-length "^1.1.1" callsites@^3.0.0: version "3.1.0" @@ -1843,9 +1849,9 @@ camelize@^1.0.0: integrity sha512-dU+Tx2fsypxTgtLoE36npi3UqcjSSMNYfkqgmoEhtZrraP5VWq0K7FkWVTYa8eMPtnU/G2txVsfdCJTn9uzpuQ== caniuse-lite@^1.0.30001541: - version "1.0.30001550" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001550.tgz#6ec6a2239eb2a8123cc26cfe0571db5c79eb8669" - integrity sha512-p82WjBYIypO0ukTsd/FG3Xxs+4tFeaY9pfT4amQL8KWtYH7H9nYwReGAbMTJ0hsmRO8IfDtsS6p3ZWj8+1c2RQ== + version "1.0.30001554" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001554.tgz#ba80d88dff9acbc0cd4b7535fc30e0191c5e2e2a" + integrity sha512-A2E3U//MBwbJVzebddm1YfNp7Nud5Ip+IPn4BozBmn4KqVX7AvluoIDFWjsv5OkGnKUXQVmMSoMKLa3ScCblcQ== chai@^4.3.10: version "4.3.10" @@ -2097,7 +2103,7 @@ default-browser@^4.0.0: execa "^7.1.1" titleize "^3.0.0" -define-data-property@^1.0.1: +define-data-property@^1.0.1, define-data-property@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/define-data-property/-/define-data-property-1.1.1.tgz#c35f7cd0ab09883480d12ac5cb213715587800b3" integrity sha512-E7uGkTzkk1d0ByLeSc6ZsFS79Axg+m1P/VsgYsxHgiuc3tFSj+MjMIwe90FC4lOAZzNBdY7kkO2P2wKdsQ1vgQ== @@ -2165,9 +2171,9 @@ dot-case@^3.0.4: tslib "^2.0.3" electron-to-chromium@^1.4.535: - version "1.4.559" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.559.tgz#050483c22c5eb2345017a8976a67b060559a33f4" - integrity sha512-iS7KhLYCSJbdo3rUSkhDTVuFNCV34RKs2UaB9Ecr7VlqzjjWW//0nfsFF5dtDmyXlZQaDYYtID5fjtC/6lpRug== + version "1.4.568" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.568.tgz#6ab444e120dd7fd9c3789eac54d3132b6cfcd0f9" + integrity sha512-3TCOv8+BY6Ltpt1/CmGBMups2IdKOyfEmz4J8yIS4xLSeMm0Rf+psSaxLuswG9qMKt+XbNbmADybtXGpTFlbDg== elliptic@^6.4.1: version "6.5.4" @@ -2218,25 +2224,25 @@ error-ex@^1.3.1: is-arrayish "^0.2.1" es-abstract@^1.22.1: - version "1.22.2" - resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.22.2.tgz#90f7282d91d0ad577f505e423e52d4c1d93c1b8a" - integrity sha512-YoxfFcDmhjOgWPWsV13+2RNjq1F6UQnfs+8TftwNqtzlmFzEXvlUwdrNrYeaizfjQzRMxkZ6ElWMOJIFKdVqwA== + version "1.22.3" + resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.22.3.tgz#48e79f5573198de6dee3589195727f4f74bc4f32" + integrity sha512-eiiY8HQeYfYH2Con2berK+To6GrK2RxbPawDkGq4UiCQQfZHb6wX9qQqkbpPqaxQFcl8d9QzZqo0tGE0VcrdwA== dependencies: array-buffer-byte-length "^1.0.0" arraybuffer.prototype.slice "^1.0.2" available-typed-arrays "^1.0.5" - call-bind "^1.0.2" + call-bind "^1.0.5" es-set-tostringtag "^2.0.1" es-to-primitive "^1.2.1" function.prototype.name "^1.1.6" - get-intrinsic "^1.2.1" + get-intrinsic "^1.2.2" get-symbol-description "^1.0.0" globalthis "^1.0.3" gopd "^1.0.1" - has "^1.0.3" has-property-descriptors "^1.0.0" has-proto "^1.0.1" has-symbols "^1.0.3" + hasown "^2.0.0" internal-slot "^1.0.5" is-array-buffer "^3.0.2" is-callable "^1.2.7" @@ -2246,7 +2252,7 @@ es-abstract@^1.22.1: is-string "^1.0.7" is-typed-array "^1.1.12" is-weakref "^1.0.2" - object-inspect "^1.12.3" + object-inspect "^1.13.1" object-keys "^1.1.1" object.assign "^4.1.4" regexp.prototype.flags "^1.5.1" @@ -2260,7 +2266,7 @@ es-abstract@^1.22.1: typed-array-byte-offset "^1.0.0" typed-array-length "^1.0.4" unbox-primitive "^1.0.2" - which-typed-array "^1.1.11" + which-typed-array "^1.1.13" es-iterator-helpers@^1.0.12: version "1.0.15" @@ -2283,20 +2289,20 @@ es-iterator-helpers@^1.0.12: safe-array-concat "^1.0.1" es-set-tostringtag@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/es-set-tostringtag/-/es-set-tostringtag-2.0.1.tgz#338d502f6f674301d710b80c8592de8a15f09cd8" - integrity sha512-g3OMbtlwY3QewlqAiMLI47KywjWZoEytKr8pf6iTC8uJq5bIAH52Z9pnQ8pVL6whrCto53JZDuUIsifGeLorTg== + version "2.0.2" + resolved "https://registry.yarnpkg.com/es-set-tostringtag/-/es-set-tostringtag-2.0.2.tgz#11f7cc9f63376930a5f20be4915834f4bc74f9c9" + integrity sha512-BuDyupZt65P9D2D2vA/zqcI3G5xRsklm5N3xCwuiy+/vKy8i0ifdsQP1sLgO4tZDSCaQUSnmC48khknGMV3D2Q== dependencies: - get-intrinsic "^1.1.3" - has "^1.0.3" + get-intrinsic "^1.2.2" has-tostringtag "^1.0.0" + hasown "^2.0.0" es-shim-unscopables@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/es-shim-unscopables/-/es-shim-unscopables-1.0.0.tgz#702e632193201e3edf8713635d083d378e510241" - integrity sha512-Jm6GPcCdC30eMLbZ2x8z2WuRwAws3zTBBKuusffYVUrNj/GVSUAZ+xKMaUpfNDR5IbyNA5LJbaecoUVbmUcB1w== + version "1.0.2" + resolved "https://registry.yarnpkg.com/es-shim-unscopables/-/es-shim-unscopables-1.0.2.tgz#1f6942e71ecc7835ed1c8a83006d8771a63a3763" + integrity sha512-J3yBRXCzDu4ULnQwxyToo/OjdMx6akgVC7K6few0a7F/0wLtmKKN7I73AH5T2836UuXRqN7Qg+IIUw/+YJksRw== dependencies: - has "^1.0.3" + hasown "^2.0.0" es-to-primitive@^1.2.1: version "1.2.1" @@ -2837,15 +2843,15 @@ get-func-name@^2.0.1, get-func-name@^2.0.2: resolved "https://registry.yarnpkg.com/get-func-name/-/get-func-name-2.0.2.tgz#0d7cf20cd13fda808669ffa88f4ffc7a3943fc41" integrity sha512-8vXOvuE167CtIc3OyItco7N/dpRtBbYOsPsXCz7X/PMnlGjYjSGuZJgM1Y7mmew7BKf9BqvLX2tnOVy1BBUsxQ== -get-intrinsic@^1.0.2, get-intrinsic@^1.1.1, get-intrinsic@^1.1.3, get-intrinsic@^1.2.0, get-intrinsic@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.2.1.tgz#d295644fed4505fc9cde952c37ee12b477a83d82" - integrity sha512-2DcsyfABl+gVHEfCOaTrWgyt+tb6MSEGmKq+kI5HwLbIYgjgmMcV8KQ41uaKz1xxUcn9tJtgFbQUEVcEbd0FYw== +get-intrinsic@^1.0.2, get-intrinsic@^1.1.1, get-intrinsic@^1.1.3, get-intrinsic@^1.2.0, get-intrinsic@^1.2.1, get-intrinsic@^1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.2.2.tgz#281b7622971123e1ef4b3c90fd7539306da93f3b" + integrity sha512-0gSo4ml/0j98Y3lngkFEot/zhiCeWsbYIlZ+uZOVgzLyLaUw7wxUL+nCTP0XJvJg1AXulJRI3UJi8GsbDuxdGA== dependencies: - function-bind "^1.1.1" - has "^1.0.3" + function-bind "^1.1.2" has-proto "^1.0.1" has-symbols "^1.0.3" + hasown "^2.0.0" get-stream@^6.0.0, get-stream@^6.0.1: version "6.0.1" @@ -2986,11 +2992,11 @@ has-flag@^4.0.0: integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== has-property-descriptors@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/has-property-descriptors/-/has-property-descriptors-1.0.0.tgz#610708600606d36961ed04c196193b6a607fa861" - integrity sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ== + version "1.0.1" + resolved "https://registry.yarnpkg.com/has-property-descriptors/-/has-property-descriptors-1.0.1.tgz#52ba30b6c5ec87fd89fa574bc1c39125c6f65340" + integrity sha512-VsX8eaIewvas0xnvinAe9bw4WfIeODpGYikiWYLH+dma0Jw6KHYqWiWfhQlgOVK8D6PvjubK5Uc4P0iIhIcNVg== dependencies: - get-intrinsic "^1.1.1" + get-intrinsic "^1.2.2" has-proto@^1.0.1: version "1.0.1" @@ -3120,12 +3126,12 @@ inherits@2, inherits@^2.0.1, inherits@^2.0.3, inherits@^2.0.4: integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== internal-slot@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/internal-slot/-/internal-slot-1.0.5.tgz#f2a2ee21f668f8627a4667f309dc0f4fb6674986" - integrity sha512-Y+R5hJrzs52QCG2laLn4udYVnxsfny9CpOhNhUvk/SSSVyF6T27FzRbF0sroPidSu3X8oEAkOn2K804mjpt6UQ== + version "1.0.6" + resolved "https://registry.yarnpkg.com/internal-slot/-/internal-slot-1.0.6.tgz#37e756098c4911c5e912b8edbf71ed3aa116f930" + integrity sha512-Xj6dv+PsbtwyPpEflsejS+oIZxmMlV44zAhG479uYu89MsjcYOhCFnNyKrkJrihbsiasQyY0afoCl/9BLR65bg== dependencies: - get-intrinsic "^1.2.0" - has "^1.0.3" + get-intrinsic "^1.2.2" + hasown "^2.0.0" side-channel "^1.0.4" is-array-buffer@^3.0.1, is-array-buffer@^3.0.2: @@ -3543,11 +3549,6 @@ lodash.throttle@^4.1.1: resolved "https://registry.yarnpkg.com/lodash.throttle/-/lodash.throttle-4.1.1.tgz#c23e91b710242ac70c37f1e1cda9274cc39bf2f4" integrity sha512-wIkUCfVKpVsWo3JSZlc+8MB5it+2AN5W8J7YVMST30UrvcQNZ1Okbj+rbVniijTWE6FGYy4XJq/rHkas8qJMLQ== -lodash@^4.17.21: - version "4.17.21" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" - integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== - loose-envify@^1.1.0, loose-envify@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf" @@ -3700,13 +3701,12 @@ no-case@^3.0.4: tslib "^2.0.3" nock@^13.3.4: - version "13.3.4" - resolved "https://registry.yarnpkg.com/nock/-/nock-13.3.4.tgz#4ed3ed1465a75c87833044a881dbdd6546337e8d" - integrity sha512-DDpmn5oLEdCTclEqweOT4U7bEpuoifBMFUXem9sA4turDAZ5tlbrEoWqCorwXey8CaAw44mst5JOQeVNiwtkhw== + version "13.3.6" + resolved "https://registry.yarnpkg.com/nock/-/nock-13.3.6.tgz#b279968ec8d076c2393810a6c9bf2d4d5b3a1071" + integrity sha512-lT6YuktKroUFM+27mubf2uqQZVy2Jf+pfGzuh9N6VwdHlFoZqvi4zyxFTVR1w/ChPqGY6yxGehHp6C3wqCASCw== dependencies: debug "^4.1.0" json-stringify-safe "^5.0.1" - lodash "^4.17.21" propagate "^2.0.0" node-domexception@^1.0.0: @@ -3752,10 +3752,10 @@ object-assign@^4.0.1, object-assign@^4.1.1: resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" integrity sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg== -object-inspect@^1.12.3, object-inspect@^1.9.0: - version "1.13.0" - resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.13.0.tgz#42695d3879e1cd5bda6df5062164d80c996e23e2" - integrity sha512-HQ4J+ic8hKrgIt3mqk6cVOVrW2ozL4KdvHlqpBv9vDYWx9ysAgENAdvy4FoGF+KFdhR7nQTNm5J0ctAeOwn+3g== +object-inspect@^1.13.1, object-inspect@^1.9.0: + version "1.13.1" + resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.13.1.tgz#b96c6109324ccfef6b12216a956ca4dc2ff94bc2" + integrity sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ== object-keys@^1.1.1: version "1.1.1" @@ -4376,9 +4376,9 @@ safe-regex-test@^1.0.0: is-regex "^1.1.4" sass@^1.69.3: - version "1.69.4" - resolved "https://registry.yarnpkg.com/sass/-/sass-1.69.4.tgz#10c735f55e3ea0b7742c6efa940bce30e07fbca2" - integrity sha512-+qEreVhqAy8o++aQfCJwp0sklr2xyEzkm9Pp/Igu9wNPoe7EZEQ8X/MBvvXggI2ql607cxKg/RKOwDj6pp2XDA== + version "1.69.5" + resolved "https://registry.yarnpkg.com/sass/-/sass-1.69.5.tgz#23e18d1c757a35f2e52cc81871060b9ad653dfde" + integrity sha512-qg2+UCJibLr2LCVOt3OlPhr/dqVHWOa9XtZf2OjbLs/T4VPSJ00udtgJxH3neXZm+QqX8B+3cU7RaLqp1iVfcQ== dependencies: chokidar ">=3.0.0 <4.0.0" immutable "^4.0.0" @@ -4408,6 +4408,16 @@ semver@^7.3.4, semver@^7.3.5, semver@^7.5.0, semver@^7.5.4: dependencies: lru-cache "^6.0.0" +set-function-length@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/set-function-length/-/set-function-length-1.1.1.tgz#4bc39fafb0307224a33e106a7d35ca1218d659ed" + integrity sha512-VoaqjbBJKiWtg4yRcKBQ7g7wnGnLV3M8oLvVWwOk2PdYY6PEFegR1vezXR0tw6fZGF9csVakIRjrJiy2veSBFQ== + dependencies: + define-data-property "^1.1.1" + get-intrinsic "^1.2.1" + gopd "^1.0.1" + has-property-descriptors "^1.0.0" + set-function-name@^2.0.0, set-function-name@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/set-function-name/-/set-function-name-2.0.1.tgz#12ce38b7954310b9f61faa12701620a0c882793a" @@ -4829,10 +4839,10 @@ unbox-primitive@^1.0.2: has-symbols "^1.0.3" which-boxed-primitive "^1.0.2" -undici-types@~5.25.1: - version "5.25.3" - resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.25.3.tgz#e044115914c85f0bcbb229f346ab739f064998c3" - integrity sha512-Ga1jfYwRn7+cP9v8auvEXN1rX3sWqlayd4HP7OKk4mZWylEmu3KzXDUGrQUN6Ol7qo1gPvB2e5gX6udnyEPgdA== +undici-types@~5.26.4: + version "5.26.5" + resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617" + integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA== universalify@^2.0.0: version "2.0.0" @@ -5076,13 +5086,13 @@ which-collection@^1.0.1: is-weakmap "^2.0.1" is-weakset "^2.0.1" -which-typed-array@^1.1.11, which-typed-array@^1.1.9: - version "1.1.11" - resolved "https://registry.yarnpkg.com/which-typed-array/-/which-typed-array-1.1.11.tgz#99d691f23c72aab6768680805a271b69761ed61a" - integrity sha512-qe9UWWpkeG5yzZ0tNYxDmd7vo58HDBc39mZ0xWWpolAGADdFOzkfamWLDxkOWcvHQKVmdTyQdLD4NOfjLWTKew== +which-typed-array@^1.1.11, which-typed-array@^1.1.13, which-typed-array@^1.1.9: + version "1.1.13" + resolved "https://registry.yarnpkg.com/which-typed-array/-/which-typed-array-1.1.13.tgz#870cd5be06ddb616f504e7b039c4c24898184d36" + integrity sha512-P5Nra0qjSncduVPEAr7xhoF5guty49ArDTwzJ/yNuPIbZppyRxFQsRCWrocxIY+CnMVG+qfbU2FmDKyvSGClow== dependencies: available-typed-arrays "^1.0.5" - call-bind "^1.0.2" + call-bind "^1.0.4" for-each "^0.3.3" gopd "^1.0.1" has-tostringtag "^1.0.0" From 13a6994ae8614bf22f97f6125032743782c1a8f7 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Fri, 27 Oct 2023 13:44:34 +0700 Subject: [PATCH 2/8] add short url support --- package.json | 2 +- src/modals/Connect/Extension.tsx | 7 +++++-- src/modals/Connect/types.ts | 2 +- yarn.lock | 17 ++++++----------- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index 4848dc1cfc..bc100a8e54 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "@fortawesome/free-solid-svg-icons": "^6.4.2", "@fortawesome/react-fontawesome": "^0.2.0", "@ledgerhq/hw-transport-webhid": "^6.27.19", - "@polkadot-cloud/assets": "^0.1.26", + "@polkadot-cloud/assets": "^0.1.27", "@polkadot-cloud/core": "^1.0.29", "@polkadot-cloud/react": "^0.1.98", "@polkadot-cloud/utils": "^0.0.23", diff --git a/src/modals/Connect/Extension.tsx b/src/modals/Connect/Extension.tsx index 5dd5134b9d..2726476f1f 100644 --- a/src/modals/Connect/Extension.tsx +++ b/src/modals/Connect/Extension.tsx @@ -64,6 +64,9 @@ export const Extension = ({ meta, size, flag }: ExtensionProps) => { ); } + const shortUrl = Array.isArray(website) ? website[0] : website; + const longUrl = Array.isArray(website) ? website[1] : website; + return ( @@ -94,11 +97,11 @@ export const Extension = ({ meta, size, flag }: ExtensionProps) => { diff --git a/src/modals/Connect/types.ts b/src/modals/Connect/types.ts index 8bc7792d5e..cec867e696 100644 --- a/src/modals/Connect/types.ts +++ b/src/modals/Connect/types.ts @@ -14,7 +14,7 @@ export interface ExtensionMetaProps { id: string; title: string; status?: string; - website: string; + website: string | [string, string]; } export interface ListWithInputProps { diff --git a/yarn.lock b/yarn.lock index 9e9237cfe0..bef5c645c2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -578,15 +578,10 @@ picocolors "^1.0.0" tslib "^2.6.0" -"@polkadot-cloud/assets@^0.1.24": - version "0.1.25" - resolved "https://registry.yarnpkg.com/@polkadot-cloud/assets/-/assets-0.1.25.tgz#ad807e2b8671819396545df9507407811c712b03" - integrity sha512-3C6jzfSSaTq4TrfQ7RIbulz/r0D8JLDfeIO2A88GAG7GrMsA55o8mtCOvOSPH2Cn7byoghu9chSNwqGYvR6hGg== - -"@polkadot-cloud/assets@^0.1.26": - version "0.1.26" - resolved "https://registry.yarnpkg.com/@polkadot-cloud/assets/-/assets-0.1.26.tgz#f21bcbfac8922523465758a959fcbb27fcbb5d1d" - integrity sha512-1y5Vzymj8yR/+m8jiEbyp5Qfm9b/D8m15WEoBN4NoCLdnN3axKKnqpsyffBcEzM8jNlgoTCCuTbOkppQdEZINA== +"@polkadot-cloud/assets@^0.1.24", "@polkadot-cloud/assets@^0.1.27": + version "0.1.27" + resolved "https://registry.yarnpkg.com/@polkadot-cloud/assets/-/assets-0.1.27.tgz#285192670ce8317e50d5e209ec363058bb3bda6e" + integrity sha512-rPF+R0sfgONODEVrQCjvV19NEyq+Vd/KiqkEngXhd7V604JMEktIiXRbSt9dNXijgbWm3C+usoAHDcBu/SjzKQ== "@polkadot-cloud/core@^1.0.29": version "1.0.29" @@ -1704,9 +1699,9 @@ binary-extensions@^2.0.0: resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d" integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA== -"bip32-ed25519@https://github.com/Zondax/bip32-ed25519": +"bip32-ed25519@git+https://github.com/Zondax/bip32-ed25519.git": version "0.0.4" - resolved "https://github.com/Zondax/bip32-ed25519#0949df01b5c93885339bc28116690292088f6134" + resolved "git+https://github.com/Zondax/bip32-ed25519.git#0949df01b5c93885339bc28116690292088f6134" dependencies: bn.js "^5.1.1" elliptic "^6.4.1" From 60f1bad88e1b296a92f19f92d2a27829dcc572c4 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Fri, 27 Oct 2023 15:32:18 +0700 Subject: [PATCH 3/8] don't use `extensions` --- src/library/Hooks/useSubmitExtrinsic/index.tsx | 10 ++++++---- src/modals/Accounts/index.tsx | 11 +++++++++-- src/modals/Connect/index.tsx | 7 ++++--- src/types/index.ts | 6 ++++++ 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/library/Hooks/useSubmitExtrinsic/index.tsx b/src/library/Hooks/useSubmitExtrinsic/index.tsx index f177c6e6d1..52ec9093a2 100644 --- a/src/library/Hooks/useSubmitExtrinsic/index.tsx +++ b/src/library/Hooks/useSubmitExtrinsic/index.tsx @@ -27,9 +27,9 @@ export const useSubmitExtrinsic = ({ }: UseSubmitExtrinsicProps): UseSubmitExtrinsic => { const { t } = useTranslation('library'); const { api } = useApi(); - const { extensions } = useExtensions(); const { buildPayload } = useBuildPayload(); const { activeProxy } = useActiveAccounts(); + const { extensionsStatus } = useExtensions(); const { addNotification } = useNotifications(); const { isProxySupported } = useProxySupported(); const { addPending, removePending } = useExtrinsics(); @@ -140,12 +140,14 @@ export const useSubmitExtrinsic = ({ // if `activeAccount` is imported from an extension, ensure it is enabled. if (!ManualSigners.includes(source)) { - const extension = extensions.find((e) => e.id === source); - if (extension === undefined) { + const extension = Object.keys(extensionsStatus).find( + (id) => id === source + ); + if (extension === undefined || !!window.injectedWeb3?.[source]) { throw new Error(`${t('walletNotFound')}`); } else { // summons extension popup if not already connected. - extension.enable(DappName); + window.injectedWeb3[source].enable(DappName); } } diff --git a/src/modals/Accounts/index.tsx b/src/modals/Accounts/index.tsx index 226094f84e..1f534ec27f 100644 --- a/src/modals/Accounts/index.tsx +++ b/src/modals/Accounts/index.tsx @@ -36,9 +36,9 @@ export const Accounts = () => { const { t } = useTranslation('modals'); const { balances } = useBalances(); const { getDelegates } = useProxies(); - const { extensions } = useExtensions(); const { bondedAccounts } = useBonded(); const { ledgers, getLocks } = useBalances(); + const { extensionsStatus } = useExtensions(); const { memberships } = usePoolMemberships(); const { replaceModal, @@ -128,7 +128,14 @@ export const Accounts = () => { // Resize if modal open upon state changes. useEffectIgnoreInitial(() => { if (modalStatus === 'open') setModalResize(); - }, [activeAccount, accounts, bondedAccounts, balances, ledgers, extensions]); + }, [ + activeAccount, + accounts, + bondedAccounts, + balances, + ledgers, + extensionsStatus, + ]); return ( diff --git a/src/modals/Connect/index.tsx b/src/modals/Connect/index.tsx index 14c8f4cd6c..1993face9b 100644 --- a/src/modals/Connect/index.tsx +++ b/src/modals/Connect/index.tsx @@ -32,11 +32,12 @@ import { ExtensionsWrapper } from './Wrappers'; export const Connect = () => { const { t } = useTranslation('modals'); - const { extensions } = useExtensions(); + const { extensionsStatus } = useExtensions(); + const { replaceModal, setModalHeight, modalMaxHeight } = useOverlay().modal; const installed = ExtensionsArray.filter((a) => - extensions.find((b) => b.id === a.id) + Object.keys(extensionsStatus).find((key) => key === a.id) ); const other = ExtensionsArray.filter( @@ -72,7 +73,7 @@ export const Connect = () => { // Resize modal on state change. useEffectIgnoreInitial(() => { refreshModalHeight(); - }, [section, readOnlyOpen, newProxyOpen, extensions]); + }, [section, readOnlyOpen, newProxyOpen, extensionsStatus]); useEffect(() => { window.addEventListener('resize', refreshModalHeight); diff --git a/src/types/index.ts b/src/types/index.ts index 7e92aeb0c7..62531f669c 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -5,6 +5,12 @@ import type React from 'react'; import type { FunctionComponent, SVGProps } from 'react'; import type { Theme } from 'contexts/Themes/types'; +declare global { + interface Window { + injectedWeb3?: AnyJson; + } +} + export type NetworkName = 'polkadot' | 'kusama' | 'westend'; export type Networks = Record; From d36b6eb55a73a1b99ba1e7955e911e458b27ca51 Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Fri, 27 Oct 2023 15:45:53 +0700 Subject: [PATCH 4/8] type, fix status --- src/library/Hooks/useSubmitExtrinsic/index.tsx | 16 +++++++++------- src/types/index.ts | 3 ++- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/library/Hooks/useSubmitExtrinsic/index.tsx b/src/library/Hooks/useSubmitExtrinsic/index.tsx index 52ec9093a2..70fabf3baa 100644 --- a/src/library/Hooks/useSubmitExtrinsic/index.tsx +++ b/src/library/Hooks/useSubmitExtrinsic/index.tsx @@ -140,15 +140,17 @@ export const useSubmitExtrinsic = ({ // if `activeAccount` is imported from an extension, ensure it is enabled. if (!ManualSigners.includes(source)) { - const extension = Object.keys(extensionsStatus).find( - (id) => id === source + const isInstalled = Object.entries(extensionsStatus).find( + ([id, status]) => id === source && status === 'connected' ); - if (extension === undefined || !!window.injectedWeb3?.[source]) { + + if (!isInstalled) throw new Error(`${t('walletNotFound')}`); + + if (!window?.injectedWeb3?.[source]) throw new Error(`${t('walletNotFound')}`); - } else { - // summons extension popup if not already connected. - window.injectedWeb3[source].enable(DappName); - } + + // summons extension popup if not already connected. + window.injectedWeb3[source].enable(DappName); } const onReady = () => { diff --git a/src/types/index.ts b/src/types/index.ts index 62531f669c..4a18a689f1 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -4,10 +4,11 @@ import type React from 'react'; import type { FunctionComponent, SVGProps } from 'react'; import type { Theme } from 'contexts/Themes/types'; +import type { ExtensionInjected } from '@polkadot-cloud/react/types'; declare global { interface Window { - injectedWeb3?: AnyJson; + injectedWeb3?: Record; } } From 5433272f37fef0d24c8c8a216a7d36c8ac84870d Mon Sep 17 00:00:00 2001 From: Ross Bulat Date: Fri, 27 Oct 2023 15:51:13 +0700 Subject: [PATCH 5/8] use extensionCanConnect --- src/modals/Connect/Extension.tsx | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/modals/Connect/Extension.tsx b/src/modals/Connect/Extension.tsx index 2726476f1f..7bc20dbbaf 100644 --- a/src/modals/Connect/Extension.tsx +++ b/src/modals/Connect/Extension.tsx @@ -19,13 +19,12 @@ export const Extension = ({ meta, size, flag }: ExtensionProps) => { const { t } = useTranslation('modals'); const { addNotification } = useNotifications(); const { connectExtensionAccounts } = useExtensionAccounts(); - const { extensionsStatus, extensionInstalled } = useExtensions(); + const { extensionsStatus, extensionInstalled, extensionCanConnect } = + useExtensions(); const { title, website, id } = meta; - const isInstalled = extensionInstalled(id); - const status = !isInstalled ? 'not_found' : extensionsStatus[id]; - const disabled = status === 'connected' || !isInstalled; - const canConnect = isInstalled && status !== 'connected'; + const isInstalled = extensionInstalled(id); + const canConnect = extensionCanConnect(id); // Force re-render on click. const [increment, setIncrement] = useState(0); @@ -48,7 +47,7 @@ export const Extension = ({ meta, size, flag }: ExtensionProps) => { const Icon = ExtensionIcons[id || ''] || undefined; // determine message to be displayed based on extension status. let statusJsx; - switch (status) { + switch (extensionsStatus[id]) { case 'connected': statusJsx =

{t('connected')}

; break; @@ -66,6 +65,7 @@ export const Extension = ({ meta, size, flag }: ExtensionProps) => { const shortUrl = Array.isArray(website) ? website[0] : website; const longUrl = Array.isArray(website) ? website[1] : website; + const disabled = extensionsStatus[id] === 'connected' || !isInstalled; return ( @@ -76,7 +76,6 @@ export const Extension = ({ meta, size, flag }: ExtensionProps) => {