From 843d3fec9923d7415f2909b1dbebf122019f951a Mon Sep 17 00:00:00 2001 From: huhuanming Date: Wed, 18 Dec 2024 00:05:13 +0800 Subject: [PATCH 01/32] add new button --- .gitignore | 3 +- packages/injected/src/injectedExtension.ts | 2 +- .../inpage-providers-hub/package.json | 3 +- .../src/floatingButton/index.ts | 876 ++++++++++++++++++ .../src/floatingButton/type.ts | 52 ++ .../src/injectWeb3Provider.ts | 5 +- 6 files changed, 937 insertions(+), 4 deletions(-) create mode 100644 packages/providers/inpage-providers-hub/src/floatingButton/index.ts create mode 100644 packages/providers/inpage-providers-hub/src/floatingButton/type.ts diff --git a/.gitignore b/.gitignore index abfd883a..b8b50771 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,5 @@ yarn-error.log package.json.lerna_backup lerna-debug.log .env -.vscode \ No newline at end of file +.vscode +.history \ No newline at end of file diff --git a/packages/injected/src/injectedExtension.ts b/packages/injected/src/injectedExtension.ts index 0fce9c60..47db5e87 100644 --- a/packages/injected/src/injectedExtension.ts +++ b/packages/injected/src/injectedExtension.ts @@ -13,7 +13,7 @@ const bridge = (): JsBridgeExtInjected => }); injectJsBridge(bridge); -injectWeb3Provider(); +injectWeb3Provider({ showFloatingButton: true }); console.log('OneKey Provider Ready ', performance.now()); diff --git a/packages/providers/inpage-providers-hub/package.json b/packages/providers/inpage-providers-hub/package.json index 67ce2f81..fac5bd39 100644 --- a/packages/providers/inpage-providers-hub/package.json +++ b/packages/providers/inpage-providers-hub/package.json @@ -50,7 +50,8 @@ "@onekeyfe/onekey-ton-provider": "2.1.23", "@onekeyfe/onekey-tron-provider": "2.1.23", "@onekeyfe/onekey-webln-provider": "2.1.23", - "web3": "^1.7.3" + "web3": "^1.7.3", + "preact": "^10.25.1" }, "devDependencies": { "@playwright/test": "^1.43.1", diff --git a/packages/providers/inpage-providers-hub/src/floatingButton/index.ts b/packages/providers/inpage-providers-hub/src/floatingButton/index.ts new file mode 100644 index 00000000..4e76fb5c --- /dev/null +++ b/packages/providers/inpage-providers-hub/src/floatingButton/index.ts @@ -0,0 +1,876 @@ +import { h, render } from 'preact'; +import { useEffect, useMemo, useRef, useState } from 'preact/hooks'; +import { + IHostSecurity, + EHostSecurityLevel, +} from './type' + +let isInjected = false; + +const logoStyle = { + width: '28px', + height: '28px', +}; + +const textStyle = { + color: 'rgba(0, 0, 0, 0.61)', + fontSize: '13px', + marginLeft: '8px', +}; + +const containerId = 'onekey-floating-widget'; + +const useOutsideClick = ( + ref: { current?: HTMLElement }, + callback: () => void, +) => { + useEffect(() => { + const handleClickOutside = (event: { target: unknown }) => { + if ( + ref.current && + !ref.current.contains(event.target as HTMLElement | null) + ) { + callback(); + } + }; + document.addEventListener('mousedown', handleClickOutside); + return () => { + document.removeEventListener('mousedown', handleClickOutside); + }; + }, [callback, ref]); +}; + +function CloseDialog({ onClose }: { onClose: () => void }) { + const dialogRef = useRef(); + useOutsideClick(dialogRef, onClose); + return h( + 'div', + { + style: { + background: 'rgba(255, 255, 255, 1)', + padding: '14px', + position: 'absolute', + right: '134px', + border: '1px rgba(0, 0, 0, 0.13) solid', + top: '60px', + width: '170px', + borderRadius: '15px', + }, + ref: dialogRef, + }, + [ + h( + 'div', + { + style: { + color: 'rgba(0, 0, 0, 1)', + fontSize: '12px', + fontWeight: '400', + }, + }, + 'Hide on this site', + ), + h( + 'div', + { + style: { + marginTop: '4px', + marginBottom: '8px', + color: 'rgba(0, 0, 0, 1)', + fontSize: '12px', + fontWeight: '400', + }, + }, + 'Disable', + ), + h( + 'div', + { + style: { + color: 'rgb(156, 156, 156)', + fontSize: '10px', + fontWeight: '400', + }, + }, + 'Can be re-enabled in settings.', + ), + ], + ); +} + +function IconButton({ + isExpanded, + onClick, + dataLoaded, +}: { + isExpanded: boolean; + onClick: () => void; + dataLoaded: boolean; +}) { + const [showCloseButton, setIsShowCloseButton] = useState(false); + const [showCloseDialog, setIsShowCloseDialog] = useState(false); + return [ + h( + 'div', + { + style: { + display: 'flex', + alignItems: 'center', + width: '184px', + position: 'relative', + cursor: 'pointer', + padding: '8px', + }, + onMouseEnter: () => { + if (isExpanded || showCloseDialog) { + return; + } + setIsShowCloseButton(true); + }, + onMouseLeave: () => setIsShowCloseButton(false), + onClick: () => { + if (showCloseDialog) { + return; + } + setIsShowCloseButton(false); + onClick(); + }, + }, + [ + h('img', { + src: 'https://asset.onekey-asset.com/app-monorepo/bb7a4e71aba56b405faf9278776d57d73b829708/favicon.png', + style: logoStyle, + }), + !dataLoaded + ? h( + 'span', + { + style: textStyle, + }, + isExpanded ? 'Fetching dApp info...' : '', + ) + : null, + h('div', { + style: { + position: 'absolute', + left: '0px', + bottom: '-10px', + opacity: showCloseButton ? 1 : 0, + }, + children: h( + 'svg', + { + width: '15', + height: '15', + viewBox: '0 0 15 15', + fill: 'none', + xmlns: 'http://www.w3.org/2000/svg', + }, + [ + h('path', { + 'fill-rule': 'evenodd', + 'clip-rule': 'evenodd', + d: 'M6.5 1.5C3.73858 1.5 1.5 3.73858 1.5 6.5C1.5 9.26142 3.73858 11.5 6.5 11.5C9.26142 11.5 11.5 9.26142 11.5 6.5C11.5 3.73858 9.26142 1.5 6.5 1.5ZM0.25 6.5C0.25 3.04822 3.04822 0.25 6.5 0.25C9.95178 0.25 12.75 3.04822 12.75 6.5C12.75 9.95178 9.95178 12.75 6.5 12.75C3.04822 12.75 0.25 9.95178 0.25 6.5ZM4.18306 4.18306C4.42714 3.93898 4.82286 3.93898 5.06694 4.18306L6.5 5.61612L7.93306 4.18306C8.17714 3.93898 8.57286 3.93898 8.81694 4.18306C9.06102 4.42714 9.06102 4.82286 8.81694 5.06694L7.38388 6.5L8.81694 7.93306C9.06102 8.17714 9.06102 8.57286 8.81694 8.81694C8.57286 9.06102 8.17714 9.06102 7.93306 8.81694L6.5 7.38388L5.06694 8.81694C4.82286 9.06102 4.42714 9.06102 4.18306 8.81694C3.93898 8.57286 3.93898 8.17714 4.18306 7.93306L5.61612 6.5L4.18306 5.06694C3.93898 4.82286 3.93898 4.42714 4.18306 4.18306Z', + fill: '#C8C8C8', + }), + ], + ), + onClick: (event: MouseEvent) => { + event.stopPropagation(); + setIsShowCloseButton(false); + setIsShowCloseDialog(true); + }, + }), + !isExpanded && showCloseDialog + ? h(CloseDialog, { + onClose: () => { + setIsShowCloseDialog(false); + }, + }) + : null, + ], + ), + ]; +} + +function SecurityInfoRow({ + title, + children, +}: { + title: string; + children: any; +}) { + return h( + 'div', + { + style: { + display: 'flex', + height: '16px', + flexDirection: 'row', + justifyContent: 'space-between', + alignItems: 'center', + padding: '0 8px', + }, + }, + [ + h( + 'span', + { + style: { + color: 'rgba(0, 0, 0, 0.61)', + fontWeight: '500', + fontSize: '11.2px', + }, + }, + title, + ), + children, + ], + ); +} + +function SecurityRiskDetectionRow({ + securityInfo, +}: { + securityInfo: IHostSecurity; +}) { + const { securityElement, securityStatus } = useMemo(() => { + const security = + securityInfo?.checkSources + .filter((item) => item.riskLevel === EHostSecurityLevel.Security) + .map((item) => item.name) + .join(' & ') || ''; + if (security) { + return { + securityStatus: EHostSecurityLevel.Security, + securityElement: [ + h( + 'span', + { + style: { + color: 'rgba(0, 0, 0, 0.88)', + fontWeight: '500', + fontSize: '11.2px', + }, + }, + 'Verified', + ), + h( + 'svg', + { + width: '13', + height: '14', + viewBox: '0 0 13 14', + fill: 'none', + xmlns: 'http://www.w3.org/2000/svg', + }, + [ + h('path', { + 'fill-rule': 'evenodd', + 'clip-rule': 'evenodd', + d: 'M5.7827 2.03938C6.21439 1.54254 6.98582 1.54254 7.41751 2.03938L8.14191 2.87311C8.14557 2.87733 8.15115 2.87935 8.15666 2.87848L9.2475 2.70544C9.89755 2.60232 10.4885 3.09819 10.4998 3.75627L10.5188 4.86059C10.5189 4.86617 10.5219 4.8713 10.5267 4.87418L11.4735 5.4428C12.0378 5.78165 12.1718 6.54136 11.7574 7.05277L11.0622 7.91094C11.0586 7.91528 11.0576 7.92112 11.0594 7.9264L11.4193 8.97061C11.6337 9.59289 11.248 10.261 10.6019 10.3864L9.51762 10.5969C9.51214 10.5979 9.5076 10.6018 9.5056 10.607L9.11004 11.6382C8.87432 12.2527 8.14941 12.5166 7.57382 12.1973L6.60796 11.6616C6.60307 11.6589 6.59714 11.6589 6.59226 11.6616L5.62639 12.1973C5.05081 12.5166 4.3259 12.2527 4.09017 11.6382L3.69462 10.607C3.69262 10.6018 3.68807 10.5979 3.68259 10.5969L2.59836 10.3864C1.95224 10.261 1.56652 9.59289 1.78095 8.97061L2.14079 7.9264C2.14261 7.92112 2.14158 7.91528 2.13806 7.91094L1.44279 7.05277C1.02846 6.54137 1.16241 5.78165 1.72667 5.4428L2.67353 4.87418C2.67831 4.8713 2.68128 4.86617 2.68137 4.86059L2.70038 3.75628C2.71171 3.09819 3.30266 2.60232 3.95272 2.70544L5.04355 2.87848C5.04907 2.87935 5.05464 2.87733 5.0583 2.87311L5.7827 2.03938ZM8.31057 6.5772C8.51885 6.36893 8.51885 6.03124 8.31057 5.82296C8.10229 5.61468 7.76461 5.61468 7.55633 5.82296L6.06678 7.3125L5.6439 6.88962C5.43562 6.68134 5.09794 6.68134 4.88966 6.88962C4.68138 7.0979 4.68138 7.43559 4.88966 7.64387L5.5011 8.25531C5.81352 8.56773 6.32005 8.56773 6.63247 8.25531L8.31057 6.5772Z', + fill: '#006B3B', + 'fill-opacity': '0.906', + }), + ], + ), + ], + }; + } + const highSecurity = + securityInfo?.checkSources + .filter((item) => item.riskLevel === EHostSecurityLevel.High) + .map((item) => item.name) + .join(' & ') || ''; + + if (highSecurity) { + return { + securityStatus: EHostSecurityLevel.High, + securityElement: [ + h( + 'span', + { + style: { + color: 'rgba(0, 0, 0, 0.88)', + fontWeight: '500', + fontSize: '11.2px', + }, + }, + 'Malicious site', + ), + h( + 'svg', + { + width: '18', + height: '16', + viewBox: '0 0 18 16', + fill: 'none', + xmlns: 'http://www.w3.org/2000/svg', + }, + [ + h('path', { + 'fill-rule': 'evenodd', + 'clip-rule': 'evenodd', + d: 'M6.83981 2.21151C7.8045 0.557753 10.194 0.557748 11.1587 2.21151L17.007 12.2371C17.9792 13.9038 16.777 15.9968 14.8475 15.9968H3.15098C1.22151 15.9968 0.0193263 13.9038 0.991535 12.2371L6.83981 2.21151ZM9.00008 5.99683C9.46032 5.99683 9.83342 6.36992 9.83342 6.83016V9.33016C9.83342 9.7904 9.46032 10.1635 9.00008 10.1635C8.53984 10.1635 8.16675 9.7904 8.16675 9.33016V6.83016C8.16675 6.36992 8.53984 5.99683 9.00008 5.99683ZM7.95842 11.8302C7.95842 11.2549 8.42478 10.7885 9.00008 10.7885C9.57538 10.7885 10.0417 11.2549 10.0417 11.8302C10.0417 12.4055 9.57538 12.8718 9.00008 12.8718C8.42478 12.8718 7.95842 12.4055 7.95842 11.8302Z', + fill: '#BB0007', + 'fill-opacity': '0.836', + }), + ], + ), + ], + }; + } + + const mediumSecurity = + securityInfo?.checkSources + .filter((item) => + [EHostSecurityLevel.Medium, EHostSecurityLevel.Low].includes( + item.riskLevel, + ), + ) + .map((item) => item.name) + .join(' & ') || ''; + if (mediumSecurity) { + return { + securityStatus: EHostSecurityLevel.High, + securityElement: [ + h( + 'span', + { + style: { + color: 'rgba(0, 0, 0, 0.88)', + fontWeight: '500', + fontSize: '11.2px', + }, + }, + 'Suspected malicious behavior', + ), + h( + 'svg', + { + width: '16', + height: '16', + viewBox: '0 0 16 16', + fill: 'none', + xmlns: 'http://www.w3.org/2000/svg', + }, + [ + h('path', { + 'fill-rule': 'evenodd', + 'clip-rule': 'evenodd', + d: 'M3.96786 0.159913C3.52858 0.159899 3.14962 0.159886 2.83748 0.185389C2.50802 0.212306 2.18034 0.271736 1.86503 0.432398C1.39462 0.672081 1.01217 1.05453 0.772486 1.52494C0.611824 1.84025 0.552394 2.16794 0.525477 2.49739C0.499974 2.80953 0.499986 3.18849 0.500001 3.62776V11.692C0.499986 12.1313 0.499974 12.5103 0.525477 12.8224C0.552394 13.1519 0.611824 13.4796 0.772486 13.7949C1.01217 14.2653 1.39462 14.6477 1.86503 14.8874C2.18034 15.0481 2.50802 15.1075 2.83748 15.1344C3.14962 15.1599 3.52858 15.1599 3.96786 15.1599H12.0321C12.4714 15.1599 12.8504 15.1599 13.1625 15.1344C13.492 15.1075 13.8197 15.0481 14.135 14.8874C14.6054 14.6477 14.9878 14.2653 15.2275 13.7949C15.3882 13.4796 15.4476 13.1519 15.4745 12.8224C15.5 12.5103 15.5 12.1313 15.5 11.6921V3.62778C15.5 3.18849 15.5 2.80953 15.4745 2.49739C15.4476 2.16794 15.3882 1.84025 15.2275 1.52494C14.9878 1.05453 14.6054 0.672081 14.135 0.432398C13.8197 0.271736 13.492 0.212306 13.1625 0.185389C12.8504 0.159886 12.4714 0.159899 12.0322 0.159913H3.96786ZM6.33333 6.82658C6.33333 6.36634 6.70643 5.99325 7.16667 5.99325H8C8.46024 5.99325 8.83333 6.36634 8.83333 6.82658V10.9932C8.83333 11.4535 8.46024 11.8266 8 11.8266C7.53976 11.8266 7.16667 11.4535 7.16667 10.9932V7.65991C6.70643 7.65991 6.33333 7.28682 6.33333 6.82658ZM8 3.49325C7.53976 3.49325 7.16667 3.86634 7.16667 4.32658C7.16667 4.78682 7.53976 5.15991 8 5.15991C8.46024 5.15991 8.83333 4.78682 8.83333 4.32658C8.83333 3.86634 8.46024 3.49325 8 3.49325Z', + fill: '#5E4200', + 'fill-opacity': '0.844', + }), + ], + ), + ], + }; + } + return { + securityStatus: EHostSecurityLevel.Unknown, + securityElement: [ + h( + 'span', + { + style: { + color: 'rgba(0, 0, 0, 0.88)', + fontWeight: '500', + fontSize: '11.2px', + }, + }, + 'Unknown', + ), + ], + }; + }, [securityInfo?.checkSources]); + return h(SecurityInfoRow, { + title: 'Risk Detection', + children: [ + h( + 'div', + { + style: { + display: 'flex', + alignItems: 'center', + gap: '3.2px', + }, + }, + [ + ...securityElement, + h( + 'svg', + { + width: '13', + height: '14', + viewBox: '0 0 13 14', + fill: 'none', + xmlns: 'http://www.w3.org/2000/svg', + }, + [ + h('path', { + 'fill-rule': 'evenodd', + 'clip-rule': 'evenodd', + d: 'M5.15621 4.48971C5.36449 4.28143 5.70218 4.28143 5.91046 4.48971L7.66667 6.24592C8.08323 6.66247 8.08323 7.33785 7.66667 7.75441L5.91046 9.51062C5.70218 9.7189 5.36449 9.7189 5.15621 9.51062C4.94793 9.30234 4.94793 8.96465 5.15621 8.75637L6.91242 7.00016L5.15621 5.24395C4.94793 5.03567 4.94793 4.69799 5.15621 4.48971Z', + fill: '#006B3B', + 'fill-opacity': '0.906', + }), + ], + ), + ], + ), + ], + }); +} + +function SecurityInfo({ + securityInfo, + onClose, +}: { + securityInfo: IHostSecurity; + onClose: () => void; +}) { + const viewRef = useRef(); + useOutsideClick(viewRef, onClose); + return h( + 'div', + { + ref: viewRef, + style: { + display: 'flex', + flexDirection: 'column', + width: '234px', + borderTopLeftRadius: '12px', + borderBottomLeftRadius: '12px', + paddingTop: '8px', + }, + }, + [ + h( + 'div', + { + style: { + display: 'flex', + flexDirection: 'column', + gap: '8px', + }, + }, + [ + h( + 'div', + { + style: { + padding: '0 8px', + display: 'flex', + alignItems: 'center', + flexDirection: 'row', + justifyContent: 'space-between', + }, + }, + [ + h( + 'div', + { + style: { + display: 'flex', + flexDirection: 'row', + alignItems: 'center', + gap: '8px', + color: 'rgba(0, 0, 0, 0.88)', + fontSize: '13px', + fontWeight: '500', + }, + }, + [ + securityInfo?.dapp.logo + ? h('img', { + src: securityInfo?.dapp.logo, + style: { + height: '24px', + width: '24px', + borderRadius: '4px', + }, + }) + : h( + 'svg', + { + width: '18', + height: '19', + viewBox: '0 0 18 19', + fill: 'none', + xmlns: 'http://www.w3.org/2000/svg', + style: { + width: '24px', + height: '24px', + }, + }, + [ + h('path', { + d: 'M6.6234 6.17768C6.6234 4.79769 7.73338 3.66333 9.1234 3.66333C10.5134 3.66333 11.6234 4.79769 11.6234 6.17768C11.6234 7.30559 10.8798 7.89399 10.4435 8.19056C10.3054 8.28442 10.2138 8.36716 10.1499 8.45311C10.092 8.53086 10.0368 8.63774 10.0107 8.81185C9.92866 9.35801 9.41941 9.73426 8.87325 9.65224C8.3271 9.57021 7.95084 9.06096 8.03287 8.5148C8.19122 7.4605 8.81104 6.8819 9.31912 6.53656C9.47624 6.42975 9.54878 6.36136 9.58594 6.31084C9.60107 6.29027 9.60813 6.27529 9.61242 6.26261C9.61657 6.25036 9.6234 6.22488 9.6234 6.17768C9.6234 5.88426 9.39093 5.66333 9.1234 5.66333C8.85586 5.66333 8.6234 5.88426 8.6234 6.17768C8.6234 6.72996 8.17568 7.17768 7.6234 7.17768C7.07111 7.17768 6.6234 6.72996 6.6234 6.17768Z', + fill: '#3C3C3C', + }), + h('path', { + d: 'M7.74976 11.5C7.74976 12.1904 8.3094 12.75 8.99976 12.75C9.69011 12.75 10.2498 12.1904 10.2498 11.5C10.2498 10.8096 9.69011 10.25 8.99976 10.25C8.3094 10.25 7.74976 10.8096 7.74976 11.5Z', + fill: '#3C3C3C', + }), + h('path', { + 'fill-rule': 'evenodd', + 'clip-rule': 'evenodd', + d: 'M3.00195 2.00272e-05L15.0019 0C16.6588 -2.7418e-06 18.002 1.34314 18.002 3V13.0358C18.002 14.6926 16.6588 16.0357 15.002 16.0358L12.3757 16.0358L8.99393 18.8375L5.65157 16.0358H3.00195C1.3451 16.0358 0.00195312 14.6926 0.00195312 13.0358V3.00002C0.00195312 1.34317 1.34509 2.2769e-05 3.00195 2.00272e-05ZM15.002 2L3.00195 2.00002C2.44967 2.00002 2.00195 2.44774 2.00195 3.00002V13.0358C2.00195 13.5881 2.44967 14.0358 3.00195 14.0358H5.65157C6.12143 14.0358 6.57629 14.2012 6.93638 14.503L9.00143 16.2341L11.0997 14.4957C11.4585 14.1984 11.9098 14.0358 12.3757 14.0358L15.002 14.0358C15.5542 14.0358 16.002 13.588 16.002 13.0358V3C16.002 2.44772 15.5542 2 15.002 2Z', + fill: '#3C3C3C', + }), + ], + ), + securityInfo?.dapp.name || securityInfo?.host, + ], + ), + h( + 'div', + { + width: '24', + height: '24', + cursor: 'pointer', + }, + h( + 'svg', + { + width: '24', + height: '24', + viewBox: '0 0 24 24', + fill: 'none', + xmlns: 'http://www.w3.org/2000/svg', + }, + [ + h('path', { + 'fill-rule': 'evenodd', + 'clip-rule': 'evenodd', + d: 'M7.29289 7.29289C7.68342 6.90237 8.31658 6.90237 8.70711 7.29289L12 10.5858L15.2929 7.29289C15.6834 6.90237 16.3166 6.90237 16.7071 7.29289C17.0976 7.68342 17.0976 8.31658 16.7071 8.70711L13.4142 12L16.7071 15.2929C17.0976 15.6834 17.0976 16.3166 16.7071 16.7071C16.3166 17.0976 15.6834 17.0976 15.2929 16.7071L12 13.4142L8.70711 16.7071C8.31658 17.0976 7.68342 17.0976 7.29289 16.7071C6.90237 16.3166 6.90237 15.6834 7.29289 15.2929L10.5858 12L7.29289 8.70711C6.90237 8.31658 6.90237 7.68342 7.29289 7.29289Z', + fill: '#BABABA', + }), + ], + ), + ), + ], + ), + h('div', { + style: { + background: 'rgba(0, 0, 0, 0.13)', + height: '0.33px', + width: '100%', + }, + }), + securityInfo?.dapp?.origins.length + ? h(SecurityInfoRow, { + title: 'Dapp listed by', + children: [ + h( + 'div', + { + style: { + display: 'flex', + alignItems: 'center', + gap: '2px', + }, + }, + securityInfo?.dapp?.origins.map((item) => + h('img', { + src: item.logo, + style: { + width: '16px', + height: '16px', + }, + }), + ), + ), + ], + }) + : null, + h(SecurityRiskDetectionRow, { + securityInfo, + }), + securityInfo?.dapp?.origins.length + ? h(SecurityInfoRow, { + title: 'Last Verified at', + children: [ + h( + 'span', + { + style: { + fontWeight: '500', + fontSize: '11.2px', + color: 'rgba(0, 0, 0, 0.88)', + }, + }, + securityInfo.updatedAt, + ), + ], + }) + : null, + ], + ), + h( + 'div', + { + style: { + marginTop: '8px', + textAlign: 'center', + padding: '8px 0', + background: 'rgba(249, 249, 249, 1)', + borderBottomLeftRadius: '12px', + }, + }, + [ + h( + 'span', + { + style: { + color: 'rgba(0, 0, 0, 0.61)', + fontWeight: '400', + fontSize: '11.2px', + }, + }, + 'Powered by', + ), + h('img', { + src: 'https://asset.onekey-asset.com/app-monorepo/bb7a4e71aba56b405faf9278776d57d73b829708/favicon.png', + style: { + width: '12.83px', + height: '12.83px', + marginLeft: '5.6px', + marginRight: '4.2px', + verticalAlign: 'middle', + }, + }), + h( + 'span', + { + style: { + color: 'rgba(0, 0, 0, 0.88)', + fontWeight: '600', + fontSize: '11.2px', + }, + }, + 'OneKey', + ), + ], + ), + ], + ); +} + +function App() { + const [isExpanded, setIsExpanded] = useState(false); + const [showSecurityInfo, setIsShowSecurityInfo] = useState(false); + const [securityInfo, setSecurityInfo] = useState(null); + + const handleClick = async () => { + setIsExpanded(!isExpanded); + setIsShowSecurityInfo(true); + if (!securityInfo) { + const result = await backgroundApiProxy.serviceDiscovery.checkUrlSecurity( + { + url: globalThis.location.origin, + from: 'app', + }, + ); + // const testData = { + // 'host': 'www.google.com', + // 'phishingSite': false, + // 'level': EHostSecurityLevel.Unknown, + // 'isWhiteList': false, + // 'isBlackList': false, + // 'createdAt': '2024-03-12', + // 'updatedAt': '2024-12-16', + // 'checkSources': [ + // { + // 'name': 'scam-sniffer', + // 'riskLevel': EHostSecurityLevel.Unknown, + // }, + // { + // 'name': 'goplus', + // 'riskLevel': EHostSecurityLevel.Unknown, + // }, + // { + // 'name': 'blockaid', + // 'riskLevel': EHostSecurityLevel.Unknown, + // }, + // ], + // 'alert': '未认证的网站,请自行甄别决定是否继续访问', + // 'detail': { + // 'title': '未认证的网站', + // 'content': + // '无法获取网站的信息。在批准该网站发起任何请求之前,请自行甄别安全风险,谨防钓鱼欺诈。', + // }, + // 'attackTypes': [], + // 'projectName': '', + // 'dapp': { + // name: '', + // logo: '', + // description: { text: '' }, + // tags: [], + // origins: [], + // }, + // }; + + const testData = { + 'host': 'app.uniswap.org', + 'projectName': 'Uniswap', + 'phishingSite': false, + 'level': 'security', + 'isWhiteList': false, + 'isBlackList': false, + 'createdAt': '2024-03-08', + 'updatedAt': '2024-12-16', + 'checkSources': [ + { + 'name': 'scam-sniffer', + 'riskLevel': 'unknown', + }, + { + 'name': 'goplus', + 'riskLevel': 'security', + }, + { + 'name': 'blockaid', + 'riskLevel': 'unknown', + }, + ], + 'alert': '已认证的网站', + 'detail': { + 'title': '已认证的网站', + 'content': '通过多个可信源认证的 Web3 网站,可以放心使用。', + }, + 'attackTypes': [], + 'dapp': { + 'name': 'Uniswap V1', + 'logo': 'https://dev.onekey-asset.com/discover/dapp/Uniswap%20V1.png', + 'categories': [ + { + 'name': { + 'text': 'exchanges', + 'lokaliseKey': '438062876', + 'deleted': false, + }, + 'recommendIndex': 0, + 'origin': 'dappradar', + 'categoryId': 'bf95c0de-fd9d-498b-8695-f9bca97fdc53', + }, + ], + 'tags': [ + { + 'name': { + 'text': ' 🔥 Hot', + 'lokaliseKey': '438074961', + 'deleted': false, + }, + 'tagId': '25be6bf0-6f93-4ef2-a0a6-500fcafca0e5', + 'type': 'critical', + }, + ], + 'origins': [ + { + 'name': 'okx', + 'logo': 'https://uni.onekey-asset.com/static/logo/dapp_okx.png', + }, + { + 'name': 'bitget', + 'logo': + 'https://uni.onekey-asset.com/static/logo/dapp_bitget.png', + }, + { + 'name': 'defillama', + 'logo': + 'https://uni.onekey-asset.com/static/logo/dapp_defillama.png', + }, + { + 'name': 'tp', + 'logo': 'https://uni.onekey-asset.com/static/logo/dapp_tp.png', + }, + { + 'name': 'dappradar', + 'logo': + 'https://uni.onekey-asset.com/static/logo/dapp_dappradar.png', + }, + ], + 'description': { + 'text': 'Decentralized protocol for automated liquidity', + 'lokaliseKey': '438065900', + 'deleted': false, + }, + }, + }; + setSecurityInfo(testData); + } + }; + + const borderStyle = useMemo( + () => + isExpanded + ? { + borderTopLeftRadius: '12px', + borderBottomLeftRadius: '12px', + borderTopRightRadius: '0px', + borderBottomRightRadius: '0px', + } + : { + boxShadow: '0px 8.57px 17.14px 0px rgba(0, 0, 0, 0.09)', + transition: 'transform 0.3s ease-in-out', + borderRadius: '100px', + }, + [isExpanded], + ); + + return h( + 'div', + { + id: containerId, + style: { + position: 'fixed', + zIndex: 999_999, + top: '20%', + right: '-146px', + background: 'rgba(255, 255, 255, 1)', + borderWidth: '0.33px', + borderColor: 'rgba(0, 0, 0, 0.13)', + borderStyle: 'solid', + boxShadow: '0px 8.57px 17.14px 0px rgba(0, 0, 0, 0.09)', + transition: 'transform 0.3s ease-in-out', + transform: isExpanded ? 'translateX(-146px)' : 'translateX(0)', + ...borderStyle, + }, + }, + showSecurityInfo && securityInfo + ? h(SecurityInfo, { + securityInfo, + onClose: () => { + setIsExpanded(false); + setIsShowSecurityInfo(false); + }, + }) + : h(IconButton, { + onClick: handleClick, + isExpanded, + dataLoaded: !!securityInfo, + }), + ); +} + +async function injectFloatingIcon() { + const isShowFloatingButton = + await backgroundApiProxy.serviceSetting.isShowFloatingButton(); + if (!isShowFloatingButton) { + return; + } + + if (isInjected) { + return; + } + + if (!document.body) { + return; + } + isInjected = true; + const div = document.createElement('div'); + document.body.appendChild(div); + render(h(App, {}), document.body, div); +} diff --git a/packages/providers/inpage-providers-hub/src/floatingButton/type.ts b/packages/providers/inpage-providers-hub/src/floatingButton/type.ts new file mode 100644 index 00000000..53606ab9 --- /dev/null +++ b/packages/providers/inpage-providers-hub/src/floatingButton/type.ts @@ -0,0 +1,52 @@ + +export enum EHostSecurityLevel { + High = 'high', + Medium = 'medium', + Security = 'security', + Unknown = 'unknown', +} +export interface IAttackType { + name: string; + description: string; +} + +export interface IHostSecurityCheckSources { + name: string; + riskLevel: EHostSecurityLevel; +} + +export interface IHostSecurity { + host: string; + level: EHostSecurityLevel; + attackTypes: IAttackType[]; + phishingSite: boolean; + checkSources: IHostSecurityCheckSources[]; + alert: string; + detail?: { + title: string; + content: string; + }; + projectName: string; + createdAt: string; + updatedAt?: string; + dapp: { + name: string; + logo: string; + description: { + text: string; + }; + tags: { + name: { + text: string; + lokaliseKey: string; + deleted: boolean; + }; + tagId: string; + type: 'success' | 'info' | 'critical' | 'warning' | 'default' | undefined; + }[]; + origins: { + name: string; + logo: string; + }[]; + }; +} \ No newline at end of file diff --git a/packages/providers/inpage-providers-hub/src/injectWeb3Provider.ts b/packages/providers/inpage-providers-hub/src/injectWeb3Provider.ts index 971fa1ea..cc3e99eb 100644 --- a/packages/providers/inpage-providers-hub/src/injectWeb3Provider.ts +++ b/packages/providers/inpage-providers-hub/src/injectWeb3Provider.ts @@ -70,7 +70,7 @@ export type IWindowOneKeyHub = { }; }; -function injectWeb3Provider(): unknown { +function injectWeb3Provider({ showFloatingButton = false }: { showFloatingButton?: boolean } = {}): unknown { if (!window?.$onekey?.jsBridge) { throw new Error('OneKey jsBridge not found.'); } @@ -305,6 +305,9 @@ function injectWeb3Provider(): unknown { registerPolkadot(polkadot, 'polkadot-js', '0.44.1'); } setTimeout(() => { + if (showFloatingButton) { + + } void detectWebsiteRiskLevel(); void hackAllConnectButtons(); void listenPageFocus(); From ef39f5be60c272f0a58e2c6e7f505a6c72a637ba Mon Sep 17 00:00:00 2001 From: huhuanming Date: Wed, 18 Dec 2024 00:13:52 +0800 Subject: [PATCH 02/32] refactor to jsx --- .../src/floatingButton/index.ts | 876 ------------------ .../src/floatingButton/index.tsx | 787 ++++++++++++++++ 2 files changed, 787 insertions(+), 876 deletions(-) delete mode 100644 packages/providers/inpage-providers-hub/src/floatingButton/index.ts create mode 100644 packages/providers/inpage-providers-hub/src/floatingButton/index.tsx diff --git a/packages/providers/inpage-providers-hub/src/floatingButton/index.ts b/packages/providers/inpage-providers-hub/src/floatingButton/index.ts deleted file mode 100644 index 4e76fb5c..00000000 --- a/packages/providers/inpage-providers-hub/src/floatingButton/index.ts +++ /dev/null @@ -1,876 +0,0 @@ -import { h, render } from 'preact'; -import { useEffect, useMemo, useRef, useState } from 'preact/hooks'; -import { - IHostSecurity, - EHostSecurityLevel, -} from './type' - -let isInjected = false; - -const logoStyle = { - width: '28px', - height: '28px', -}; - -const textStyle = { - color: 'rgba(0, 0, 0, 0.61)', - fontSize: '13px', - marginLeft: '8px', -}; - -const containerId = 'onekey-floating-widget'; - -const useOutsideClick = ( - ref: { current?: HTMLElement }, - callback: () => void, -) => { - useEffect(() => { - const handleClickOutside = (event: { target: unknown }) => { - if ( - ref.current && - !ref.current.contains(event.target as HTMLElement | null) - ) { - callback(); - } - }; - document.addEventListener('mousedown', handleClickOutside); - return () => { - document.removeEventListener('mousedown', handleClickOutside); - }; - }, [callback, ref]); -}; - -function CloseDialog({ onClose }: { onClose: () => void }) { - const dialogRef = useRef(); - useOutsideClick(dialogRef, onClose); - return h( - 'div', - { - style: { - background: 'rgba(255, 255, 255, 1)', - padding: '14px', - position: 'absolute', - right: '134px', - border: '1px rgba(0, 0, 0, 0.13) solid', - top: '60px', - width: '170px', - borderRadius: '15px', - }, - ref: dialogRef, - }, - [ - h( - 'div', - { - style: { - color: 'rgba(0, 0, 0, 1)', - fontSize: '12px', - fontWeight: '400', - }, - }, - 'Hide on this site', - ), - h( - 'div', - { - style: { - marginTop: '4px', - marginBottom: '8px', - color: 'rgba(0, 0, 0, 1)', - fontSize: '12px', - fontWeight: '400', - }, - }, - 'Disable', - ), - h( - 'div', - { - style: { - color: 'rgb(156, 156, 156)', - fontSize: '10px', - fontWeight: '400', - }, - }, - 'Can be re-enabled in settings.', - ), - ], - ); -} - -function IconButton({ - isExpanded, - onClick, - dataLoaded, -}: { - isExpanded: boolean; - onClick: () => void; - dataLoaded: boolean; -}) { - const [showCloseButton, setIsShowCloseButton] = useState(false); - const [showCloseDialog, setIsShowCloseDialog] = useState(false); - return [ - h( - 'div', - { - style: { - display: 'flex', - alignItems: 'center', - width: '184px', - position: 'relative', - cursor: 'pointer', - padding: '8px', - }, - onMouseEnter: () => { - if (isExpanded || showCloseDialog) { - return; - } - setIsShowCloseButton(true); - }, - onMouseLeave: () => setIsShowCloseButton(false), - onClick: () => { - if (showCloseDialog) { - return; - } - setIsShowCloseButton(false); - onClick(); - }, - }, - [ - h('img', { - src: 'https://asset.onekey-asset.com/app-monorepo/bb7a4e71aba56b405faf9278776d57d73b829708/favicon.png', - style: logoStyle, - }), - !dataLoaded - ? h( - 'span', - { - style: textStyle, - }, - isExpanded ? 'Fetching dApp info...' : '', - ) - : null, - h('div', { - style: { - position: 'absolute', - left: '0px', - bottom: '-10px', - opacity: showCloseButton ? 1 : 0, - }, - children: h( - 'svg', - { - width: '15', - height: '15', - viewBox: '0 0 15 15', - fill: 'none', - xmlns: 'http://www.w3.org/2000/svg', - }, - [ - h('path', { - 'fill-rule': 'evenodd', - 'clip-rule': 'evenodd', - d: 'M6.5 1.5C3.73858 1.5 1.5 3.73858 1.5 6.5C1.5 9.26142 3.73858 11.5 6.5 11.5C9.26142 11.5 11.5 9.26142 11.5 6.5C11.5 3.73858 9.26142 1.5 6.5 1.5ZM0.25 6.5C0.25 3.04822 3.04822 0.25 6.5 0.25C9.95178 0.25 12.75 3.04822 12.75 6.5C12.75 9.95178 9.95178 12.75 6.5 12.75C3.04822 12.75 0.25 9.95178 0.25 6.5ZM4.18306 4.18306C4.42714 3.93898 4.82286 3.93898 5.06694 4.18306L6.5 5.61612L7.93306 4.18306C8.17714 3.93898 8.57286 3.93898 8.81694 4.18306C9.06102 4.42714 9.06102 4.82286 8.81694 5.06694L7.38388 6.5L8.81694 7.93306C9.06102 8.17714 9.06102 8.57286 8.81694 8.81694C8.57286 9.06102 8.17714 9.06102 7.93306 8.81694L6.5 7.38388L5.06694 8.81694C4.82286 9.06102 4.42714 9.06102 4.18306 8.81694C3.93898 8.57286 3.93898 8.17714 4.18306 7.93306L5.61612 6.5L4.18306 5.06694C3.93898 4.82286 3.93898 4.42714 4.18306 4.18306Z', - fill: '#C8C8C8', - }), - ], - ), - onClick: (event: MouseEvent) => { - event.stopPropagation(); - setIsShowCloseButton(false); - setIsShowCloseDialog(true); - }, - }), - !isExpanded && showCloseDialog - ? h(CloseDialog, { - onClose: () => { - setIsShowCloseDialog(false); - }, - }) - : null, - ], - ), - ]; -} - -function SecurityInfoRow({ - title, - children, -}: { - title: string; - children: any; -}) { - return h( - 'div', - { - style: { - display: 'flex', - height: '16px', - flexDirection: 'row', - justifyContent: 'space-between', - alignItems: 'center', - padding: '0 8px', - }, - }, - [ - h( - 'span', - { - style: { - color: 'rgba(0, 0, 0, 0.61)', - fontWeight: '500', - fontSize: '11.2px', - }, - }, - title, - ), - children, - ], - ); -} - -function SecurityRiskDetectionRow({ - securityInfo, -}: { - securityInfo: IHostSecurity; -}) { - const { securityElement, securityStatus } = useMemo(() => { - const security = - securityInfo?.checkSources - .filter((item) => item.riskLevel === EHostSecurityLevel.Security) - .map((item) => item.name) - .join(' & ') || ''; - if (security) { - return { - securityStatus: EHostSecurityLevel.Security, - securityElement: [ - h( - 'span', - { - style: { - color: 'rgba(0, 0, 0, 0.88)', - fontWeight: '500', - fontSize: '11.2px', - }, - }, - 'Verified', - ), - h( - 'svg', - { - width: '13', - height: '14', - viewBox: '0 0 13 14', - fill: 'none', - xmlns: 'http://www.w3.org/2000/svg', - }, - [ - h('path', { - 'fill-rule': 'evenodd', - 'clip-rule': 'evenodd', - d: 'M5.7827 2.03938C6.21439 1.54254 6.98582 1.54254 7.41751 2.03938L8.14191 2.87311C8.14557 2.87733 8.15115 2.87935 8.15666 2.87848L9.2475 2.70544C9.89755 2.60232 10.4885 3.09819 10.4998 3.75627L10.5188 4.86059C10.5189 4.86617 10.5219 4.8713 10.5267 4.87418L11.4735 5.4428C12.0378 5.78165 12.1718 6.54136 11.7574 7.05277L11.0622 7.91094C11.0586 7.91528 11.0576 7.92112 11.0594 7.9264L11.4193 8.97061C11.6337 9.59289 11.248 10.261 10.6019 10.3864L9.51762 10.5969C9.51214 10.5979 9.5076 10.6018 9.5056 10.607L9.11004 11.6382C8.87432 12.2527 8.14941 12.5166 7.57382 12.1973L6.60796 11.6616C6.60307 11.6589 6.59714 11.6589 6.59226 11.6616L5.62639 12.1973C5.05081 12.5166 4.3259 12.2527 4.09017 11.6382L3.69462 10.607C3.69262 10.6018 3.68807 10.5979 3.68259 10.5969L2.59836 10.3864C1.95224 10.261 1.56652 9.59289 1.78095 8.97061L2.14079 7.9264C2.14261 7.92112 2.14158 7.91528 2.13806 7.91094L1.44279 7.05277C1.02846 6.54137 1.16241 5.78165 1.72667 5.4428L2.67353 4.87418C2.67831 4.8713 2.68128 4.86617 2.68137 4.86059L2.70038 3.75628C2.71171 3.09819 3.30266 2.60232 3.95272 2.70544L5.04355 2.87848C5.04907 2.87935 5.05464 2.87733 5.0583 2.87311L5.7827 2.03938ZM8.31057 6.5772C8.51885 6.36893 8.51885 6.03124 8.31057 5.82296C8.10229 5.61468 7.76461 5.61468 7.55633 5.82296L6.06678 7.3125L5.6439 6.88962C5.43562 6.68134 5.09794 6.68134 4.88966 6.88962C4.68138 7.0979 4.68138 7.43559 4.88966 7.64387L5.5011 8.25531C5.81352 8.56773 6.32005 8.56773 6.63247 8.25531L8.31057 6.5772Z', - fill: '#006B3B', - 'fill-opacity': '0.906', - }), - ], - ), - ], - }; - } - const highSecurity = - securityInfo?.checkSources - .filter((item) => item.riskLevel === EHostSecurityLevel.High) - .map((item) => item.name) - .join(' & ') || ''; - - if (highSecurity) { - return { - securityStatus: EHostSecurityLevel.High, - securityElement: [ - h( - 'span', - { - style: { - color: 'rgba(0, 0, 0, 0.88)', - fontWeight: '500', - fontSize: '11.2px', - }, - }, - 'Malicious site', - ), - h( - 'svg', - { - width: '18', - height: '16', - viewBox: '0 0 18 16', - fill: 'none', - xmlns: 'http://www.w3.org/2000/svg', - }, - [ - h('path', { - 'fill-rule': 'evenodd', - 'clip-rule': 'evenodd', - d: 'M6.83981 2.21151C7.8045 0.557753 10.194 0.557748 11.1587 2.21151L17.007 12.2371C17.9792 13.9038 16.777 15.9968 14.8475 15.9968H3.15098C1.22151 15.9968 0.0193263 13.9038 0.991535 12.2371L6.83981 2.21151ZM9.00008 5.99683C9.46032 5.99683 9.83342 6.36992 9.83342 6.83016V9.33016C9.83342 9.7904 9.46032 10.1635 9.00008 10.1635C8.53984 10.1635 8.16675 9.7904 8.16675 9.33016V6.83016C8.16675 6.36992 8.53984 5.99683 9.00008 5.99683ZM7.95842 11.8302C7.95842 11.2549 8.42478 10.7885 9.00008 10.7885C9.57538 10.7885 10.0417 11.2549 10.0417 11.8302C10.0417 12.4055 9.57538 12.8718 9.00008 12.8718C8.42478 12.8718 7.95842 12.4055 7.95842 11.8302Z', - fill: '#BB0007', - 'fill-opacity': '0.836', - }), - ], - ), - ], - }; - } - - const mediumSecurity = - securityInfo?.checkSources - .filter((item) => - [EHostSecurityLevel.Medium, EHostSecurityLevel.Low].includes( - item.riskLevel, - ), - ) - .map((item) => item.name) - .join(' & ') || ''; - if (mediumSecurity) { - return { - securityStatus: EHostSecurityLevel.High, - securityElement: [ - h( - 'span', - { - style: { - color: 'rgba(0, 0, 0, 0.88)', - fontWeight: '500', - fontSize: '11.2px', - }, - }, - 'Suspected malicious behavior', - ), - h( - 'svg', - { - width: '16', - height: '16', - viewBox: '0 0 16 16', - fill: 'none', - xmlns: 'http://www.w3.org/2000/svg', - }, - [ - h('path', { - 'fill-rule': 'evenodd', - 'clip-rule': 'evenodd', - d: 'M3.96786 0.159913C3.52858 0.159899 3.14962 0.159886 2.83748 0.185389C2.50802 0.212306 2.18034 0.271736 1.86503 0.432398C1.39462 0.672081 1.01217 1.05453 0.772486 1.52494C0.611824 1.84025 0.552394 2.16794 0.525477 2.49739C0.499974 2.80953 0.499986 3.18849 0.500001 3.62776V11.692C0.499986 12.1313 0.499974 12.5103 0.525477 12.8224C0.552394 13.1519 0.611824 13.4796 0.772486 13.7949C1.01217 14.2653 1.39462 14.6477 1.86503 14.8874C2.18034 15.0481 2.50802 15.1075 2.83748 15.1344C3.14962 15.1599 3.52858 15.1599 3.96786 15.1599H12.0321C12.4714 15.1599 12.8504 15.1599 13.1625 15.1344C13.492 15.1075 13.8197 15.0481 14.135 14.8874C14.6054 14.6477 14.9878 14.2653 15.2275 13.7949C15.3882 13.4796 15.4476 13.1519 15.4745 12.8224C15.5 12.5103 15.5 12.1313 15.5 11.6921V3.62778C15.5 3.18849 15.5 2.80953 15.4745 2.49739C15.4476 2.16794 15.3882 1.84025 15.2275 1.52494C14.9878 1.05453 14.6054 0.672081 14.135 0.432398C13.8197 0.271736 13.492 0.212306 13.1625 0.185389C12.8504 0.159886 12.4714 0.159899 12.0322 0.159913H3.96786ZM6.33333 6.82658C6.33333 6.36634 6.70643 5.99325 7.16667 5.99325H8C8.46024 5.99325 8.83333 6.36634 8.83333 6.82658V10.9932C8.83333 11.4535 8.46024 11.8266 8 11.8266C7.53976 11.8266 7.16667 11.4535 7.16667 10.9932V7.65991C6.70643 7.65991 6.33333 7.28682 6.33333 6.82658ZM8 3.49325C7.53976 3.49325 7.16667 3.86634 7.16667 4.32658C7.16667 4.78682 7.53976 5.15991 8 5.15991C8.46024 5.15991 8.83333 4.78682 8.83333 4.32658C8.83333 3.86634 8.46024 3.49325 8 3.49325Z', - fill: '#5E4200', - 'fill-opacity': '0.844', - }), - ], - ), - ], - }; - } - return { - securityStatus: EHostSecurityLevel.Unknown, - securityElement: [ - h( - 'span', - { - style: { - color: 'rgba(0, 0, 0, 0.88)', - fontWeight: '500', - fontSize: '11.2px', - }, - }, - 'Unknown', - ), - ], - }; - }, [securityInfo?.checkSources]); - return h(SecurityInfoRow, { - title: 'Risk Detection', - children: [ - h( - 'div', - { - style: { - display: 'flex', - alignItems: 'center', - gap: '3.2px', - }, - }, - [ - ...securityElement, - h( - 'svg', - { - width: '13', - height: '14', - viewBox: '0 0 13 14', - fill: 'none', - xmlns: 'http://www.w3.org/2000/svg', - }, - [ - h('path', { - 'fill-rule': 'evenodd', - 'clip-rule': 'evenodd', - d: 'M5.15621 4.48971C5.36449 4.28143 5.70218 4.28143 5.91046 4.48971L7.66667 6.24592C8.08323 6.66247 8.08323 7.33785 7.66667 7.75441L5.91046 9.51062C5.70218 9.7189 5.36449 9.7189 5.15621 9.51062C4.94793 9.30234 4.94793 8.96465 5.15621 8.75637L6.91242 7.00016L5.15621 5.24395C4.94793 5.03567 4.94793 4.69799 5.15621 4.48971Z', - fill: '#006B3B', - 'fill-opacity': '0.906', - }), - ], - ), - ], - ), - ], - }); -} - -function SecurityInfo({ - securityInfo, - onClose, -}: { - securityInfo: IHostSecurity; - onClose: () => void; -}) { - const viewRef = useRef(); - useOutsideClick(viewRef, onClose); - return h( - 'div', - { - ref: viewRef, - style: { - display: 'flex', - flexDirection: 'column', - width: '234px', - borderTopLeftRadius: '12px', - borderBottomLeftRadius: '12px', - paddingTop: '8px', - }, - }, - [ - h( - 'div', - { - style: { - display: 'flex', - flexDirection: 'column', - gap: '8px', - }, - }, - [ - h( - 'div', - { - style: { - padding: '0 8px', - display: 'flex', - alignItems: 'center', - flexDirection: 'row', - justifyContent: 'space-between', - }, - }, - [ - h( - 'div', - { - style: { - display: 'flex', - flexDirection: 'row', - alignItems: 'center', - gap: '8px', - color: 'rgba(0, 0, 0, 0.88)', - fontSize: '13px', - fontWeight: '500', - }, - }, - [ - securityInfo?.dapp.logo - ? h('img', { - src: securityInfo?.dapp.logo, - style: { - height: '24px', - width: '24px', - borderRadius: '4px', - }, - }) - : h( - 'svg', - { - width: '18', - height: '19', - viewBox: '0 0 18 19', - fill: 'none', - xmlns: 'http://www.w3.org/2000/svg', - style: { - width: '24px', - height: '24px', - }, - }, - [ - h('path', { - d: 'M6.6234 6.17768C6.6234 4.79769 7.73338 3.66333 9.1234 3.66333C10.5134 3.66333 11.6234 4.79769 11.6234 6.17768C11.6234 7.30559 10.8798 7.89399 10.4435 8.19056C10.3054 8.28442 10.2138 8.36716 10.1499 8.45311C10.092 8.53086 10.0368 8.63774 10.0107 8.81185C9.92866 9.35801 9.41941 9.73426 8.87325 9.65224C8.3271 9.57021 7.95084 9.06096 8.03287 8.5148C8.19122 7.4605 8.81104 6.8819 9.31912 6.53656C9.47624 6.42975 9.54878 6.36136 9.58594 6.31084C9.60107 6.29027 9.60813 6.27529 9.61242 6.26261C9.61657 6.25036 9.6234 6.22488 9.6234 6.17768C9.6234 5.88426 9.39093 5.66333 9.1234 5.66333C8.85586 5.66333 8.6234 5.88426 8.6234 6.17768C8.6234 6.72996 8.17568 7.17768 7.6234 7.17768C7.07111 7.17768 6.6234 6.72996 6.6234 6.17768Z', - fill: '#3C3C3C', - }), - h('path', { - d: 'M7.74976 11.5C7.74976 12.1904 8.3094 12.75 8.99976 12.75C9.69011 12.75 10.2498 12.1904 10.2498 11.5C10.2498 10.8096 9.69011 10.25 8.99976 10.25C8.3094 10.25 7.74976 10.8096 7.74976 11.5Z', - fill: '#3C3C3C', - }), - h('path', { - 'fill-rule': 'evenodd', - 'clip-rule': 'evenodd', - d: 'M3.00195 2.00272e-05L15.0019 0C16.6588 -2.7418e-06 18.002 1.34314 18.002 3V13.0358C18.002 14.6926 16.6588 16.0357 15.002 16.0358L12.3757 16.0358L8.99393 18.8375L5.65157 16.0358H3.00195C1.3451 16.0358 0.00195312 14.6926 0.00195312 13.0358V3.00002C0.00195312 1.34317 1.34509 2.2769e-05 3.00195 2.00272e-05ZM15.002 2L3.00195 2.00002C2.44967 2.00002 2.00195 2.44774 2.00195 3.00002V13.0358C2.00195 13.5881 2.44967 14.0358 3.00195 14.0358H5.65157C6.12143 14.0358 6.57629 14.2012 6.93638 14.503L9.00143 16.2341L11.0997 14.4957C11.4585 14.1984 11.9098 14.0358 12.3757 14.0358L15.002 14.0358C15.5542 14.0358 16.002 13.588 16.002 13.0358V3C16.002 2.44772 15.5542 2 15.002 2Z', - fill: '#3C3C3C', - }), - ], - ), - securityInfo?.dapp.name || securityInfo?.host, - ], - ), - h( - 'div', - { - width: '24', - height: '24', - cursor: 'pointer', - }, - h( - 'svg', - { - width: '24', - height: '24', - viewBox: '0 0 24 24', - fill: 'none', - xmlns: 'http://www.w3.org/2000/svg', - }, - [ - h('path', { - 'fill-rule': 'evenodd', - 'clip-rule': 'evenodd', - d: 'M7.29289 7.29289C7.68342 6.90237 8.31658 6.90237 8.70711 7.29289L12 10.5858L15.2929 7.29289C15.6834 6.90237 16.3166 6.90237 16.7071 7.29289C17.0976 7.68342 17.0976 8.31658 16.7071 8.70711L13.4142 12L16.7071 15.2929C17.0976 15.6834 17.0976 16.3166 16.7071 16.7071C16.3166 17.0976 15.6834 17.0976 15.2929 16.7071L12 13.4142L8.70711 16.7071C8.31658 17.0976 7.68342 17.0976 7.29289 16.7071C6.90237 16.3166 6.90237 15.6834 7.29289 15.2929L10.5858 12L7.29289 8.70711C6.90237 8.31658 6.90237 7.68342 7.29289 7.29289Z', - fill: '#BABABA', - }), - ], - ), - ), - ], - ), - h('div', { - style: { - background: 'rgba(0, 0, 0, 0.13)', - height: '0.33px', - width: '100%', - }, - }), - securityInfo?.dapp?.origins.length - ? h(SecurityInfoRow, { - title: 'Dapp listed by', - children: [ - h( - 'div', - { - style: { - display: 'flex', - alignItems: 'center', - gap: '2px', - }, - }, - securityInfo?.dapp?.origins.map((item) => - h('img', { - src: item.logo, - style: { - width: '16px', - height: '16px', - }, - }), - ), - ), - ], - }) - : null, - h(SecurityRiskDetectionRow, { - securityInfo, - }), - securityInfo?.dapp?.origins.length - ? h(SecurityInfoRow, { - title: 'Last Verified at', - children: [ - h( - 'span', - { - style: { - fontWeight: '500', - fontSize: '11.2px', - color: 'rgba(0, 0, 0, 0.88)', - }, - }, - securityInfo.updatedAt, - ), - ], - }) - : null, - ], - ), - h( - 'div', - { - style: { - marginTop: '8px', - textAlign: 'center', - padding: '8px 0', - background: 'rgba(249, 249, 249, 1)', - borderBottomLeftRadius: '12px', - }, - }, - [ - h( - 'span', - { - style: { - color: 'rgba(0, 0, 0, 0.61)', - fontWeight: '400', - fontSize: '11.2px', - }, - }, - 'Powered by', - ), - h('img', { - src: 'https://asset.onekey-asset.com/app-monorepo/bb7a4e71aba56b405faf9278776d57d73b829708/favicon.png', - style: { - width: '12.83px', - height: '12.83px', - marginLeft: '5.6px', - marginRight: '4.2px', - verticalAlign: 'middle', - }, - }), - h( - 'span', - { - style: { - color: 'rgba(0, 0, 0, 0.88)', - fontWeight: '600', - fontSize: '11.2px', - }, - }, - 'OneKey', - ), - ], - ), - ], - ); -} - -function App() { - const [isExpanded, setIsExpanded] = useState(false); - const [showSecurityInfo, setIsShowSecurityInfo] = useState(false); - const [securityInfo, setSecurityInfo] = useState(null); - - const handleClick = async () => { - setIsExpanded(!isExpanded); - setIsShowSecurityInfo(true); - if (!securityInfo) { - const result = await backgroundApiProxy.serviceDiscovery.checkUrlSecurity( - { - url: globalThis.location.origin, - from: 'app', - }, - ); - // const testData = { - // 'host': 'www.google.com', - // 'phishingSite': false, - // 'level': EHostSecurityLevel.Unknown, - // 'isWhiteList': false, - // 'isBlackList': false, - // 'createdAt': '2024-03-12', - // 'updatedAt': '2024-12-16', - // 'checkSources': [ - // { - // 'name': 'scam-sniffer', - // 'riskLevel': EHostSecurityLevel.Unknown, - // }, - // { - // 'name': 'goplus', - // 'riskLevel': EHostSecurityLevel.Unknown, - // }, - // { - // 'name': 'blockaid', - // 'riskLevel': EHostSecurityLevel.Unknown, - // }, - // ], - // 'alert': '未认证的网站,请自行甄别决定是否继续访问', - // 'detail': { - // 'title': '未认证的网站', - // 'content': - // '无法获取网站的信息。在批准该网站发起任何请求之前,请自行甄别安全风险,谨防钓鱼欺诈。', - // }, - // 'attackTypes': [], - // 'projectName': '', - // 'dapp': { - // name: '', - // logo: '', - // description: { text: '' }, - // tags: [], - // origins: [], - // }, - // }; - - const testData = { - 'host': 'app.uniswap.org', - 'projectName': 'Uniswap', - 'phishingSite': false, - 'level': 'security', - 'isWhiteList': false, - 'isBlackList': false, - 'createdAt': '2024-03-08', - 'updatedAt': '2024-12-16', - 'checkSources': [ - { - 'name': 'scam-sniffer', - 'riskLevel': 'unknown', - }, - { - 'name': 'goplus', - 'riskLevel': 'security', - }, - { - 'name': 'blockaid', - 'riskLevel': 'unknown', - }, - ], - 'alert': '已认证的网站', - 'detail': { - 'title': '已认证的网站', - 'content': '通过多个可信源认证的 Web3 网站,可以放心使用。', - }, - 'attackTypes': [], - 'dapp': { - 'name': 'Uniswap V1', - 'logo': 'https://dev.onekey-asset.com/discover/dapp/Uniswap%20V1.png', - 'categories': [ - { - 'name': { - 'text': 'exchanges', - 'lokaliseKey': '438062876', - 'deleted': false, - }, - 'recommendIndex': 0, - 'origin': 'dappradar', - 'categoryId': 'bf95c0de-fd9d-498b-8695-f9bca97fdc53', - }, - ], - 'tags': [ - { - 'name': { - 'text': ' 🔥 Hot', - 'lokaliseKey': '438074961', - 'deleted': false, - }, - 'tagId': '25be6bf0-6f93-4ef2-a0a6-500fcafca0e5', - 'type': 'critical', - }, - ], - 'origins': [ - { - 'name': 'okx', - 'logo': 'https://uni.onekey-asset.com/static/logo/dapp_okx.png', - }, - { - 'name': 'bitget', - 'logo': - 'https://uni.onekey-asset.com/static/logo/dapp_bitget.png', - }, - { - 'name': 'defillama', - 'logo': - 'https://uni.onekey-asset.com/static/logo/dapp_defillama.png', - }, - { - 'name': 'tp', - 'logo': 'https://uni.onekey-asset.com/static/logo/dapp_tp.png', - }, - { - 'name': 'dappradar', - 'logo': - 'https://uni.onekey-asset.com/static/logo/dapp_dappradar.png', - }, - ], - 'description': { - 'text': 'Decentralized protocol for automated liquidity', - 'lokaliseKey': '438065900', - 'deleted': false, - }, - }, - }; - setSecurityInfo(testData); - } - }; - - const borderStyle = useMemo( - () => - isExpanded - ? { - borderTopLeftRadius: '12px', - borderBottomLeftRadius: '12px', - borderTopRightRadius: '0px', - borderBottomRightRadius: '0px', - } - : { - boxShadow: '0px 8.57px 17.14px 0px rgba(0, 0, 0, 0.09)', - transition: 'transform 0.3s ease-in-out', - borderRadius: '100px', - }, - [isExpanded], - ); - - return h( - 'div', - { - id: containerId, - style: { - position: 'fixed', - zIndex: 999_999, - top: '20%', - right: '-146px', - background: 'rgba(255, 255, 255, 1)', - borderWidth: '0.33px', - borderColor: 'rgba(0, 0, 0, 0.13)', - borderStyle: 'solid', - boxShadow: '0px 8.57px 17.14px 0px rgba(0, 0, 0, 0.09)', - transition: 'transform 0.3s ease-in-out', - transform: isExpanded ? 'translateX(-146px)' : 'translateX(0)', - ...borderStyle, - }, - }, - showSecurityInfo && securityInfo - ? h(SecurityInfo, { - securityInfo, - onClose: () => { - setIsExpanded(false); - setIsShowSecurityInfo(false); - }, - }) - : h(IconButton, { - onClick: handleClick, - isExpanded, - dataLoaded: !!securityInfo, - }), - ); -} - -async function injectFloatingIcon() { - const isShowFloatingButton = - await backgroundApiProxy.serviceSetting.isShowFloatingButton(); - if (!isShowFloatingButton) { - return; - } - - if (isInjected) { - return; - } - - if (!document.body) { - return; - } - isInjected = true; - const div = document.createElement('div'); - document.body.appendChild(div); - render(h(App, {}), document.body, div); -} diff --git a/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx b/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx new file mode 100644 index 00000000..5fbbac92 --- /dev/null +++ b/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx @@ -0,0 +1,787 @@ +import { h, render } from 'preact'; +import { useEffect, useMemo, useRef, useState } from 'preact/hooks'; +import { + IHostSecurity, + EHostSecurityLevel, +} from './type' + +let isInjected = false; + +const logoStyle = { + width: '28px', + height: '28px', +}; + +const textStyle = { + color: 'rgba(0, 0, 0, 0.61)', + fontSize: '13px', + marginLeft: '8px', +}; + +const containerId = 'onekey-floating-widget'; + +const useOutsideClick = ( + ref: { current?: HTMLElement }, + callback: () => void, +) => { + useEffect(() => { + const handleClickOutside = (event: { target: unknown }) => { + if ( + ref.current && + !ref.current.contains(event.target as HTMLElement | null) + ) { + callback(); + } + }; + document.addEventListener('mousedown', handleClickOutside); + return () => { + document.removeEventListener('mousedown', handleClickOutside); + }; + }, [callback, ref]); +}; + +function CloseDialog({ onClose }: { onClose: () => void }) { + const dialogRef = useRef(); + useOutsideClick(dialogRef, onClose); + return ( +
+
+ Hide on this site +
+
+ Disable +
+
+ Can be re-enabled in settings. +
+
+ ); +} + +function IconButton({ + isExpanded, + onClick, + dataLoaded, +}: { + isExpanded: boolean; + onClick: () => void; + dataLoaded: boolean; +}) { + const [showCloseButton, setIsShowCloseButton] = useState(false); + const [showCloseDialog, setIsShowCloseDialog] = useState(false); + return ( +
{ + if (isExpanded || showCloseDialog) { + return; + } + setIsShowCloseButton(true); + }} + onMouseLeave={() => setIsShowCloseButton(false)} + onClick={() => { + if (showCloseDialog) { + return; + } + setIsShowCloseButton(false); + onClick(); + }} + > + + {!dataLoaded && ( + + {isExpanded ? 'Fetching dApp info...' : ''} + + )} +
{ + event.stopPropagation(); + setIsShowCloseButton(false); + setIsShowCloseDialog(true); + }} + > + + + +
+ {!isExpanded && showCloseDialog && ( + { + setIsShowCloseDialog(false); + }} + /> + )} +
+ ); +} + +function SecurityInfoRow({ + title, + children, +}: { + title: string; + children: any; +}) { + return ( +
+ + {title} + + {children} +
+ ); +} + +function SecurityRiskDetectionRow({ + securityInfo, +}: { + securityInfo: IHostSecurity; +}) { + const { securityElement, securityStatus } = useMemo(() => { + const security = + securityInfo?.checkSources + .filter((item) => item.riskLevel === EHostSecurityLevel.Security) + .map((item) => item.name) + .join(' & ') || ''; + if (security) { + return { + securityStatus: EHostSecurityLevel.Security, + securityElement: ( + <> + + Verified + + + + + + ), + }; + } + const highSecurity = + securityInfo?.checkSources + .filter((item) => item.riskLevel === EHostSecurityLevel.High) + .map((item) => item.name) + .join(' & ') || ''; + + if (highSecurity) { + return { + securityStatus: EHostSecurityLevel.High, + securityElement: ( + <> + + Malicious site + + + + + + ), + }; + } + + const mediumSecurity = + securityInfo?.checkSources + .filter((item) => + [EHostSecurityLevel.Medium, EHostSecurityLevel.Low].includes( + item.riskLevel, + ), + ) + .map((item) => item.name) + .join(' & ') || ''; + if (mediumSecurity) { + return { + securityStatus: EHostSecurityLevel.High, + securityElement: ( + <> + + Suspected malicious behavior + + + + + + ), + }; + } + return { + securityStatus: EHostSecurityLevel.Unknown, + securityElement: ( + + Unknown + + ), + }; + }, [securityInfo?.checkSources]); + return ( + +
+ {securityElement} + + + +
+
+ ); + +function SecurityInfo({ + securityInfo, + onClose, +}: { + securityInfo: IHostSecurity; + onClose: () => void; +}) { + const viewRef = useRef(); + useOutsideClick(viewRef, onClose); + return ( +
+
+
+
+ {securityInfo?.dapp.logo ? ( + + ) : ( + + + + + + )} + {securityInfo?.dapp.name || securityInfo?.host} +
+
+ + + +
+
+
+ {securityInfo?.dapp?.origins.length ? ( + +
+ {securityInfo?.dapp?.origins.map((item) => ( + + ))} +
+
+ ) : null} + + {securityInfo?.dapp?.origins.length ? ( + + + {securityInfo.updatedAt} + + + ) : null} +
+
+ + Powered by + + + + OneKey + +
+
+ ); + +function App() { + const [isExpanded, setIsExpanded] = useState(false); + const [showSecurityInfo, setIsShowSecurityInfo] = useState(false); + const [securityInfo, setSecurityInfo] = useState(null); + + const handleClick = async () => { + setIsExpanded(!isExpanded); + setIsShowSecurityInfo(true); + if (!securityInfo) { + const result = await backgroundApiProxy.serviceDiscovery.checkUrlSecurity( + { + url: globalThis.location.origin, + from: 'app', + }, + ); + // const testData = { + // 'host': 'www.google.com', + // 'phishingSite': false, + // 'level': EHostSecurityLevel.Unknown, + // 'isWhiteList': false, + // 'isBlackList': false, + // 'createdAt': '2024-03-12', + // 'updatedAt': '2024-12-16', + // 'checkSources': [ + // { + // 'name': 'scam-sniffer', + // 'riskLevel': EHostSecurityLevel.Unknown, + // }, + // { + // 'name': 'goplus', + // 'riskLevel': EHostSecurityLevel.Unknown, + // }, + // { + // 'name': 'blockaid', + // 'riskLevel': EHostSecurityLevel.Unknown, + // }, + // ], + // 'alert': '未认证的网站,请自行甄别决定是否继续访问', + // 'detail': { + // 'title': '未认证的网站', + // 'content': + // '无法获取网站的信息。在批准该网站发起任何请求之前,请自行甄别安全风险,谨防钓鱼欺诈。', + // }, + // 'attackTypes': [], + // 'projectName': '', + // 'dapp': { + // name: '', + // logo: '', + // description: { text: '' }, + // tags: [], + // origins: [], + // }, + // }; + + const testData = { + 'host': 'app.uniswap.org', + 'projectName': 'Uniswap', + 'phishingSite': false, + 'level': 'security', + 'isWhiteList': false, + 'isBlackList': false, + 'createdAt': '2024-03-08', + 'updatedAt': '2024-12-16', + 'checkSources': [ + { + 'name': 'scam-sniffer', + 'riskLevel': 'unknown', + }, + { + 'name': 'goplus', + 'riskLevel': 'security', + }, + { + 'name': 'blockaid', + 'riskLevel': 'unknown', + }, + ], + 'alert': '已认证的网站', + 'detail': { + 'title': '已认证的网站', + 'content': '通过多个可信源认证的 Web3 网站,可以放心使用。', + }, + 'attackTypes': [], + 'dapp': { + 'name': 'Uniswap V1', + 'logo': 'https://dev.onekey-asset.com/discover/dapp/Uniswap%20V1.png', + 'categories': [ + { + 'name': { + 'text': 'exchanges', + 'lokaliseKey': '438062876', + 'deleted': false, + }, + 'recommendIndex': 0, + 'origin': 'dappradar', + 'categoryId': 'bf95c0de-fd9d-498b-8695-f9bca97fdc53', + }, + ], + 'tags': [ + { + 'name': { + 'text': ' 🔥 Hot', + 'lokaliseKey': '438074961', + 'deleted': false, + }, + 'tagId': '25be6bf0-6f93-4ef2-a0a6-500fcafca0e5', + 'type': 'critical', + }, + ], + 'origins': [ + { + 'name': 'okx', + 'logo': 'https://uni.onekey-asset.com/static/logo/dapp_okx.png', + }, + { + 'name': 'bitget', + 'logo': + 'https://uni.onekey-asset.com/static/logo/dapp_bitget.png', + }, + { + 'name': 'defillama', + 'logo': + 'https://uni.onekey-asset.com/static/logo/dapp_defillama.png', + }, + { + 'name': 'tp', + 'logo': 'https://uni.onekey-asset.com/static/logo/dapp_tp.png', + }, + { + 'name': 'dappradar', + 'logo': + 'https://uni.onekey-asset.com/static/logo/dapp_dappradar.png', + }, + ], + 'description': { + 'text': 'Decentralized protocol for automated liquidity', + 'lokaliseKey': '438065900', + 'deleted': false, + }, + }, + }; + setSecurityInfo(testData); + } + }; + + const borderStyle = useMemo( + () => + isExpanded + ? { + borderTopLeftRadius: '12px', + borderBottomLeftRadius: '12px', + borderTopRightRadius: '0px', + borderBottomRightRadius: '0px', + } + : { + boxShadow: '0px 8.57px 17.14px 0px rgba(0, 0, 0, 0.09)', + transition: 'transform 0.3s ease-in-out', + borderRadius: '100px', + }, + [isExpanded], + ); + + return ( +
+ {showSecurityInfo && securityInfo ? ( + { + setIsExpanded(false); + setIsShowSecurityInfo(false); + }} + /> + ) : ( + + )} +
+ ); + +async function injectFloatingIcon() { + const isShowFloatingButton = + await backgroundApiProxy.serviceSetting.isShowFloatingButton(); + if (!isShowFloatingButton) { + return; + } + + if (isInjected) { + return; + } + + if (!document.body) { + return; + } + isInjected = true; + const div = document.createElement('div'); + document.body.appendChild(div); + render(, document.body, div); +} From 1c45294a35b7907dc2d34bcccb7a3bff45184074 Mon Sep 17 00:00:00 2001 From: huhuanming Date: Wed, 18 Dec 2024 00:38:35 +0800 Subject: [PATCH 03/32] Update injectWeb3Provider.ts --- .../providers/inpage-providers-hub/src/injectWeb3Provider.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/providers/inpage-providers-hub/src/injectWeb3Provider.ts b/packages/providers/inpage-providers-hub/src/injectWeb3Provider.ts index cc3e99eb..0c574627 100644 --- a/packages/providers/inpage-providers-hub/src/injectWeb3Provider.ts +++ b/packages/providers/inpage-providers-hub/src/injectWeb3Provider.ts @@ -30,6 +30,7 @@ import { ProviderBtc, ProviderBtcWallet } from '@onekeyfe/onekey-btc-provider'; import { ProviderAlgo } from '@onekeyfe/onekey-algo-provider'; import { hackAllConnectButtons } from './connectButtonHack'; import { detectWebsiteRiskLevel, listenPageFocus } from './detectRiskWebsite'; +import { injectFloatingIcon } from './floatingButton'; import { WALLET_CONNECT_INFO } from './connectButtonHack/consts'; export type IWindowOneKeyHub = { @@ -305,10 +306,8 @@ function injectWeb3Provider({ showFloatingButton = false }: { showFloatingButton registerPolkadot(polkadot, 'polkadot-js', '0.44.1'); } setTimeout(() => { - if (showFloatingButton) { - - } void detectWebsiteRiskLevel(); + void injectFloatingIcon(); void hackAllConnectButtons(); void listenPageFocus(); }, 1000); From 1059efa951995ff567282e354169d7d3c342dc5d Mon Sep 17 00:00:00 2001 From: huhuanming Date: Wed, 18 Dec 2024 00:38:38 +0800 Subject: [PATCH 04/32] Update index.tsx --- .../src/floatingButton/index.tsx | 208 +++++------------- 1 file changed, 57 insertions(+), 151 deletions(-) diff --git a/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx b/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx index 5fbbac92..4785a355 100644 --- a/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx +++ b/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx @@ -21,14 +21,14 @@ const textStyle = { const containerId = 'onekey-floating-widget'; const useOutsideClick = ( - ref: { current?: HTMLElement }, + ref: { current?: HTMLDivElement | null }, callback: () => void, ) => { useEffect(() => { - const handleClickOutside = (event: { target: unknown }) => { + const handleClickOutside = (event: MouseEvent) => { if ( ref.current && - !ref.current.contains(event.target as HTMLElement | null) + !ref.current.contains(event.target as HTMLElement) ) { callback(); } @@ -39,9 +39,8 @@ const useOutsideClick = ( }; }, [callback, ref]); }; - function CloseDialog({ onClose }: { onClose: () => void }) { - const dialogRef = useRef(); + const dialogRef = useRef(undefined); useOutsideClick(dialogRef, onClose); return (
{ + onClick={(event) => { event.stopPropagation(); setIsShowCloseButton(false); setIsShowCloseDialog(true); @@ -293,15 +292,13 @@ function SecurityRiskDetectionRow({ const mediumSecurity = securityInfo?.checkSources .filter((item) => - [EHostSecurityLevel.Medium, EHostSecurityLevel.Low].includes( - item.riskLevel, - ), + EHostSecurityLevel.Medium == item.riskLevel, ) .map((item) => item.name) .join(' & ') || ''; if (mediumSecurity) { return { - securityStatus: EHostSecurityLevel.High, + securityStatus: EHostSecurityLevel.Medium, securityElement: ( <> ); +} function SecurityInfo({ securityInfo, @@ -383,7 +381,7 @@ function SecurityInfo({ securityInfo: IHostSecurity; onClose: () => void; }) { - const viewRef = useRef(); + const viewRef = useRef(null); useOutsideClick(viewRef, onClose); return (
); +} function App() { const [isExpanded, setIsExpanded] = useState(false); @@ -577,139 +578,18 @@ function App() { setIsExpanded(!isExpanded); setIsShowSecurityInfo(true); if (!securityInfo) { - const result = await backgroundApiProxy.serviceDiscovery.checkUrlSecurity( - { - url: globalThis.location.origin, - from: 'app', - }, - ); - // const testData = { - // 'host': 'www.google.com', - // 'phishingSite': false, - // 'level': EHostSecurityLevel.Unknown, - // 'isWhiteList': false, - // 'isBlackList': false, - // 'createdAt': '2024-03-12', - // 'updatedAt': '2024-12-16', - // 'checkSources': [ - // { - // 'name': 'scam-sniffer', - // 'riskLevel': EHostSecurityLevel.Unknown, - // }, - // { - // 'name': 'goplus', - // 'riskLevel': EHostSecurityLevel.Unknown, - // }, - // { - // 'name': 'blockaid', - // 'riskLevel': EHostSecurityLevel.Unknown, - // }, - // ], - // 'alert': '未认证的网站,请自行甄别决定是否继续访问', - // 'detail': { - // 'title': '未认证的网站', - // 'content': - // '无法获取网站的信息。在批准该网站发起任何请求之前,请自行甄别安全风险,谨防钓鱼欺诈。', - // }, - // 'attackTypes': [], - // 'projectName': '', - // 'dapp': { - // name: '', - // logo: '', - // description: { text: '' }, - // tags: [], - // origins: [], - // }, - // }; - - const testData = { - 'host': 'app.uniswap.org', - 'projectName': 'Uniswap', - 'phishingSite': false, - 'level': 'security', - 'isWhiteList': false, - 'isBlackList': false, - 'createdAt': '2024-03-08', - 'updatedAt': '2024-12-16', - 'checkSources': [ - { - 'name': 'scam-sniffer', - 'riskLevel': 'unknown', - }, - { - 'name': 'goplus', - 'riskLevel': 'security', - }, - { - 'name': 'blockaid', - 'riskLevel': 'unknown', - }, - ], - 'alert': '已认证的网站', - 'detail': { - 'title': '已认证的网站', - 'content': '通过多个可信源认证的 Web3 网站,可以放心使用。', - }, - 'attackTypes': [], - 'dapp': { - 'name': 'Uniswap V1', - 'logo': 'https://dev.onekey-asset.com/discover/dapp/Uniswap%20V1.png', - 'categories': [ - { - 'name': { - 'text': 'exchanges', - 'lokaliseKey': '438062876', - 'deleted': false, - }, - 'recommendIndex': 0, - 'origin': 'dappradar', - 'categoryId': 'bf95c0de-fd9d-498b-8695-f9bca97fdc53', - }, - ], - 'tags': [ - { - 'name': { - 'text': ' 🔥 Hot', - 'lokaliseKey': '438074961', - 'deleted': false, - }, - 'tagId': '25be6bf0-6f93-4ef2-a0a6-500fcafca0e5', - 'type': 'critical', - }, - ], - 'origins': [ - { - 'name': 'okx', - 'logo': 'https://uni.onekey-asset.com/static/logo/dapp_okx.png', - }, - { - 'name': 'bitget', - 'logo': - 'https://uni.onekey-asset.com/static/logo/dapp_bitget.png', - }, - { - 'name': 'defillama', - 'logo': - 'https://uni.onekey-asset.com/static/logo/dapp_defillama.png', - }, - { - 'name': 'tp', - 'logo': 'https://uni.onekey-asset.com/static/logo/dapp_tp.png', - }, - { - 'name': 'dappradar', - 'logo': - 'https://uni.onekey-asset.com/static/logo/dapp_dappradar.png', - }, - ], - 'description': { - 'text': 'Decentralized protocol for automated liquidity', - 'lokaliseKey': '438065900', - 'deleted': false, - }, - }, - }; - setSecurityInfo(testData); + const result = await (window as unknown as { + $onekey: { + $private: { + request: (arg: { method: string; params: { url: string } }) => + Promise<{ securityInfo: IHostSecurity }> + } + } + }).$onekey.$private.request({ + method: 'wallet_detectRiskLevel', + params: { url: window.location.origin }, + }); + setSecurityInfo(result.securityInfo); } }; @@ -765,11 +645,37 @@ function App() { )}
); +} -async function injectFloatingIcon() { - const isShowFloatingButton = - await backgroundApiProxy.serviceSetting.isShowFloatingButton(); - if (!isShowFloatingButton) { +export async function injectFloatingIcon() { + const { isShow, i18n } = await (window as unknown as { + $onekey: { + $private: { + request: ( + arg: { method: string; } + ) => Promise<{ + isShow: boolean, + i18n: { + title: string; + description: string; + continueMessage: string; + continueLink: string; + addToWhiteListLink: string; + sourceMessage: string; + fetchingDAppInfo: string; + dappListedBy: string; + riskDetection: string; + maliciousDappWarningSourceMessage: string; + verifiedSite: string; + unknown: string; + } + }> + } + } + }).$onekey.$private.request({ + method: 'wallet_isShowFloatingButton', + }); + if (!isShow) { return; } From 6ee0809df8fd71d76c18df284a429c96917b920e Mon Sep 17 00:00:00 2001 From: huhuanming Date: Wed, 18 Dec 2024 00:38:41 +0800 Subject: [PATCH 05/32] Update tsconfig.cjs.json --- packages/providers/inpage-providers-hub/tsconfig.cjs.json | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/providers/inpage-providers-hub/tsconfig.cjs.json b/packages/providers/inpage-providers-hub/tsconfig.cjs.json index 89ae537e..c7dc78ed 100644 --- a/packages/providers/inpage-providers-hub/tsconfig.cjs.json +++ b/packages/providers/inpage-providers-hub/tsconfig.cjs.json @@ -3,6 +3,7 @@ "include": ["./src"], "exclude": ["./src/**/*.spec.ts", "./src/**/__tests__"], "compilerOptions": { + "jsx": "react-jsx", "outDir": "./dist/cjs" } } From 41072f3109342f6cdfbf342f98ecbea7166a7588 Mon Sep 17 00:00:00 2001 From: huhuanming Date: Wed, 18 Dec 2024 00:38:43 +0800 Subject: [PATCH 06/32] Update tsconfig.json --- packages/providers/inpage-providers-hub/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/providers/inpage-providers-hub/tsconfig.json b/packages/providers/inpage-providers-hub/tsconfig.json index 0df352ae..aa75ba52 100644 --- a/packages/providers/inpage-providers-hub/tsconfig.json +++ b/packages/providers/inpage-providers-hub/tsconfig.json @@ -3,6 +3,7 @@ "include": ["./src"], "exclude": ["./src/**/*.spec.ts", "./src/**/__tests__"], "compilerOptions": { + "jsx": "react-jsx", "outDir": "./dist" } } From bfccbaddaec0e60263357930b26846c490f1c158 Mon Sep 17 00:00:00 2001 From: huhuanming Date: Wed, 18 Dec 2024 00:41:56 +0800 Subject: [PATCH 07/32] Update index.tsx --- .../providers/inpage-providers-hub/src/floatingButton/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx b/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx index 4785a355..8ad8f2be 100644 --- a/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx +++ b/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx @@ -40,7 +40,7 @@ const useOutsideClick = ( }, [callback, ref]); }; function CloseDialog({ onClose }: { onClose: () => void }) { - const dialogRef = useRef(undefined); + const dialogRef = useRef(null); useOutsideClick(dialogRef, onClose); return (
Date: Wed, 18 Dec 2024 00:45:28 +0800 Subject: [PATCH 08/32] Update tsconfig.cjs.json --- packages/providers/inpage-providers-hub/tsconfig.cjs.json | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/providers/inpage-providers-hub/tsconfig.cjs.json b/packages/providers/inpage-providers-hub/tsconfig.cjs.json index c7dc78ed..c9cb74c7 100644 --- a/packages/providers/inpage-providers-hub/tsconfig.cjs.json +++ b/packages/providers/inpage-providers-hub/tsconfig.cjs.json @@ -4,6 +4,7 @@ "exclude": ["./src/**/*.spec.ts", "./src/**/__tests__"], "compilerOptions": { "jsx": "react-jsx", + "jsxImportSource": "preact", "outDir": "./dist/cjs" } } From 326a9d107759125eb8211e5012294620a7360c2a Mon Sep 17 00:00:00 2001 From: huhuanming Date: Wed, 18 Dec 2024 00:45:32 +0800 Subject: [PATCH 09/32] Update tsconfig.json --- packages/providers/inpage-providers-hub/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/providers/inpage-providers-hub/tsconfig.json b/packages/providers/inpage-providers-hub/tsconfig.json index aa75ba52..9a803681 100644 --- a/packages/providers/inpage-providers-hub/tsconfig.json +++ b/packages/providers/inpage-providers-hub/tsconfig.json @@ -4,6 +4,7 @@ "exclude": ["./src/**/*.spec.ts", "./src/**/__tests__"], "compilerOptions": { "jsx": "react-jsx", + "jsxImportSource": "preact", "outDir": "./dist" } } From 6fa343a136a3c4aae6f76884c1572e059bafc6d3 Mon Sep 17 00:00:00 2001 From: huhuanming Date: Wed, 18 Dec 2024 01:04:18 +0800 Subject: [PATCH 10/32] Update index.tsx --- .../inpage-providers-hub/src/floatingButton/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx b/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx index 8ad8f2be..f80ce806 100644 --- a/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx +++ b/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx @@ -581,7 +581,7 @@ function App() { const result = await (window as unknown as { $onekey: { $private: { - request: (arg: { method: string; params: { url: string } }) => + request: (arg: { method: string; params: { url: string } }) => Promise<{ securityInfo: IHostSecurity }> } } @@ -647,7 +647,7 @@ function App() { ); } -export async function injectFloatingIcon() { +export async function injectFloatingButton() { const { isShow, i18n } = await (window as unknown as { $onekey: { $private: { From 4cc92141fa11bd1b48d0687df572cc1f136ad903 Mon Sep 17 00:00:00 2001 From: huhuanming Date: Wed, 18 Dec 2024 01:50:40 +0800 Subject: [PATCH 11/32] Update index.tsx --- .../src/floatingButton/index.tsx | 46 +++++++++++-------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx b/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx index f80ce806..4f2b0d9a 100644 --- a/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx +++ b/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx @@ -6,6 +6,24 @@ import { } from './type' let isInjected = false; +interface i18nText { + title: string; + description: string; + continueMessage: string; + continueLink: string; + addToWhiteListLink: string; + sourceMessage: string; + fetchingDAppInfo: string; + dappListedBy: string; + riskDetection: string; + maliciousDappWarningSourceMessage: string; + verifiedSite: string; + unknown: string; + maliciousSiteWarning: string; + suspectedMaliciousBehavior: string; +} + +let i18n: i18nText = {} as i18nText const logoStyle = { width: '28px', @@ -228,7 +246,7 @@ function SecurityRiskDetectionRow({ fontSize: '11.2px', }} > - Verified + {i18n.verifiedSite} - Malicious site + {i18n.maliciousSiteWarning} - Suspected malicious behavior + {i18n.suspectedMaliciousBehavior} - Unknown + {i18n.unknown} ), }; @@ -492,7 +510,7 @@ function SecurityInfo({ }} /> {securityInfo?.dapp?.origins.length ? ( - +
Promise<{ isShow: boolean, - i18n: { - title: string; - description: string; - continueMessage: string; - continueLink: string; - addToWhiteListLink: string; - sourceMessage: string; - fetchingDAppInfo: string; - dappListedBy: string; - riskDetection: string; - maliciousDappWarningSourceMessage: string; - verifiedSite: string; - unknown: string; - } + i18n: i18nText }> } } }).$onekey.$private.request({ method: 'wallet_isShowFloatingButton', }); + i18n = i18nResponse if (!isShow) { return; } From 85a8329d708e0597cd6d81bfc27cfb8e4f563664 Mon Sep 17 00:00:00 2001 From: huhuanming Date: Wed, 18 Dec 2024 01:50:46 +0800 Subject: [PATCH 12/32] Update injectWeb3Provider.ts --- .../providers/inpage-providers-hub/src/injectWeb3Provider.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/providers/inpage-providers-hub/src/injectWeb3Provider.ts b/packages/providers/inpage-providers-hub/src/injectWeb3Provider.ts index 0c574627..835b2b11 100644 --- a/packages/providers/inpage-providers-hub/src/injectWeb3Provider.ts +++ b/packages/providers/inpage-providers-hub/src/injectWeb3Provider.ts @@ -30,7 +30,7 @@ import { ProviderBtc, ProviderBtcWallet } from '@onekeyfe/onekey-btc-provider'; import { ProviderAlgo } from '@onekeyfe/onekey-algo-provider'; import { hackAllConnectButtons } from './connectButtonHack'; import { detectWebsiteRiskLevel, listenPageFocus } from './detectRiskWebsite'; -import { injectFloatingIcon } from './floatingButton'; +import { injectFloatingButton } from './floatingButton'; import { WALLET_CONNECT_INFO } from './connectButtonHack/consts'; export type IWindowOneKeyHub = { @@ -307,7 +307,7 @@ function injectWeb3Provider({ showFloatingButton = false }: { showFloatingButton } setTimeout(() => { void detectWebsiteRiskLevel(); - void injectFloatingIcon(); + void injectFloatingButton(); void hackAllConnectButtons(); void listenPageFocus(); }, 1000); From 12588b44621d1937b47ce208f22b0c1a27e12e33 Mon Sep 17 00:00:00 2001 From: huhuanming Date: Wed, 18 Dec 2024 10:26:58 +0800 Subject: [PATCH 13/32] Update tsconfig.cjs.json --- packages/providers/inpage-providers-hub/tsconfig.cjs.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/providers/inpage-providers-hub/tsconfig.cjs.json b/packages/providers/inpage-providers-hub/tsconfig.cjs.json index c9cb74c7..d87448b3 100644 --- a/packages/providers/inpage-providers-hub/tsconfig.cjs.json +++ b/packages/providers/inpage-providers-hub/tsconfig.cjs.json @@ -4,7 +4,6 @@ "exclude": ["./src/**/*.spec.ts", "./src/**/__tests__"], "compilerOptions": { "jsx": "react-jsx", - "jsxImportSource": "preact", - "outDir": "./dist/cjs" + "jsxImportSource": "preact" } } From b75d02ae899d8ffc89e848d99a08e7e8c09543ad Mon Sep 17 00:00:00 2001 From: huhuanming Date: Wed, 18 Dec 2024 10:27:01 +0800 Subject: [PATCH 14/32] Update tsconfig.json --- packages/providers/inpage-providers-hub/tsconfig.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/providers/inpage-providers-hub/tsconfig.json b/packages/providers/inpage-providers-hub/tsconfig.json index 9a803681..7c837300 100644 --- a/packages/providers/inpage-providers-hub/tsconfig.json +++ b/packages/providers/inpage-providers-hub/tsconfig.json @@ -4,7 +4,6 @@ "exclude": ["./src/**/*.spec.ts", "./src/**/__tests__"], "compilerOptions": { "jsx": "react-jsx", - "jsxImportSource": "preact", - "outDir": "./dist" + "jsxImportSource": "preact" } } From 0c8aba6304b6c49fb3a3222cb289049b45f2b979 Mon Sep 17 00:00:00 2001 From: huhuanming Date: Wed, 18 Dec 2024 10:28:51 +0800 Subject: [PATCH 15/32] Update tsconfig.cjs.json --- packages/providers/inpage-providers-hub/tsconfig.cjs.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/providers/inpage-providers-hub/tsconfig.cjs.json b/packages/providers/inpage-providers-hub/tsconfig.cjs.json index d87448b3..c9cb74c7 100644 --- a/packages/providers/inpage-providers-hub/tsconfig.cjs.json +++ b/packages/providers/inpage-providers-hub/tsconfig.cjs.json @@ -4,6 +4,7 @@ "exclude": ["./src/**/*.spec.ts", "./src/**/__tests__"], "compilerOptions": { "jsx": "react-jsx", - "jsxImportSource": "preact" + "jsxImportSource": "preact", + "outDir": "./dist/cjs" } } From aeb949cf39094e72d663a08d069199cafdcfbb3d Mon Sep 17 00:00:00 2001 From: huhuanming Date: Wed, 18 Dec 2024 10:29:10 +0800 Subject: [PATCH 16/32] Update tsconfig.json --- packages/providers/inpage-providers-hub/tsconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/providers/inpage-providers-hub/tsconfig.json b/packages/providers/inpage-providers-hub/tsconfig.json index 7c837300..9a803681 100644 --- a/packages/providers/inpage-providers-hub/tsconfig.json +++ b/packages/providers/inpage-providers-hub/tsconfig.json @@ -4,6 +4,7 @@ "exclude": ["./src/**/*.spec.ts", "./src/**/__tests__"], "compilerOptions": { "jsx": "react-jsx", - "jsxImportSource": "preact" + "jsxImportSource": "preact", + "outDir": "./dist" } } From e51bc428674ce925ad1c96f37fe18c577c4654e7 Mon Sep 17 00:00:00 2001 From: huhuanming Date: Wed, 18 Dec 2024 11:13:16 +0800 Subject: [PATCH 17/32] dapp is optional --- .../inpage-providers-hub/src/floatingButton/index.tsx | 8 ++++---- .../inpage-providers-hub/src/floatingButton/type.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx b/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx index 4f2b0d9a..7b29ea60 100644 --- a/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx +++ b/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx @@ -1,4 +1,4 @@ -import { h, render } from 'preact'; +import { render } from 'preact'; import { useEffect, useMemo, useRef, useState } from 'preact/hooks'; import { IHostSecurity, @@ -440,9 +440,9 @@ function SecurityInfo({ fontWeight: '500', }} > - {securityInfo?.dapp.logo ? ( + {securityInfo?.dapp?.logo ? ( )} - {securityInfo?.dapp.name || securityInfo?.host} + {securityInfo?.dapp?.name || securityInfo?.host}
Date: Wed, 18 Dec 2024 11:13:32 +0800 Subject: [PATCH 18/32] Update yarn.lock --- packages/providers/inpage-providers-hub/yarn.lock | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/providers/inpage-providers-hub/yarn.lock b/packages/providers/inpage-providers-hub/yarn.lock index 22f1113e..ec8503b7 100644 --- a/packages/providers/inpage-providers-hub/yarn.lock +++ b/packages/providers/inpage-providers-hub/yarn.lock @@ -1897,6 +1897,11 @@ playwright@1.44.1, playwright@^1.43.1: optionalDependencies: fsevents "2.3.2" +preact@^10.25.1: + version "10.25.2" + resolved "https://registry.yarnpkg.com/preact/-/preact-10.25.2.tgz#e141e18a547ae0082dae48d044e0d8267e2547d2" + integrity sha512-GEts1EH3oMnqdOIeXhlbBSddZ9nrINd070WBOiPO2ous1orrKGUM4SMDbwyjSWD1iMS2dBvaDjAa5qUhz3TXqw== + prepend-http@^1.0.1: version "1.0.4" resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-1.0.4.tgz#d4f4562b0ce3696e41ac52d0e002e57a635dc6dc" From af0722ef30f8bc5bf30133d112e70ddd44d5901c Mon Sep 17 00:00:00 2001 From: huhuanming Date: Wed, 18 Dec 2024 11:27:27 +0800 Subject: [PATCH 19/32] Update index.tsx --- .../src/floatingButton/index.tsx | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx b/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx index 7b29ea60..d7acc13a 100644 --- a/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx +++ b/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx @@ -372,21 +372,6 @@ function SecurityRiskDetectionRow({ }} > {securityElement} - - -
); @@ -552,6 +537,9 @@ function SecurityInfo({ padding: '8px 0', background: 'rgba(249, 249, 249, 1)', borderBottomLeftRadius: '12px', + display: "flex", + alignItems: "center", + justifyContent: "center", }} > Date: Wed, 18 Dec 2024 11:43:10 +0800 Subject: [PATCH 20/32] Create images.tsx --- .../inpage-providers-hub/src/floatingButton/images.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 packages/providers/inpage-providers-hub/src/floatingButton/images.tsx diff --git a/packages/providers/inpage-providers-hub/src/floatingButton/images.tsx b/packages/providers/inpage-providers-hub/src/floatingButton/images.tsx new file mode 100644 index 00000000..67605942 --- /dev/null +++ b/packages/providers/inpage-providers-hub/src/floatingButton/images.tsx @@ -0,0 +1,9 @@ +/* eslint-disable @typescript-eslint/no-unsafe-assignment */ + +export const Logo = ({ style }: { style: any }) => ( + Logo +) From 21e59c0b1ee8a2bc8cb5b4a21efe00c2f2c58836 Mon Sep 17 00:00:00 2001 From: huhuanming Date: Wed, 18 Dec 2024 11:43:12 +0800 Subject: [PATCH 21/32] Update index.tsx --- .../inpage-providers-hub/src/floatingButton/index.tsx | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx b/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx index d7acc13a..52a7ad0c 100644 --- a/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx +++ b/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx @@ -4,6 +4,7 @@ import { IHostSecurity, EHostSecurityLevel, } from './type' +import { Logo } from './images'; let isInjected = false; interface i18nText { @@ -143,10 +144,7 @@ function IconButton({ onClick(); }} > - + {!dataLoaded && ( {isExpanded ? 'Fetching dApp info...' : ''} @@ -551,8 +549,7 @@ function SecurityInfo({ > Powered by - Date: Wed, 18 Dec 2024 12:20:37 +0800 Subject: [PATCH 22/32] Update index.tsx --- .../src/floatingButton/index.tsx | 39 ++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx b/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx index 52a7ad0c..555a1186 100644 --- a/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx +++ b/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx @@ -5,6 +5,7 @@ import { EHostSecurityLevel, } from './type' import { Logo } from './images'; +import { useCallback } from 'react'; let isInjected = false; interface i18nText { @@ -39,6 +40,10 @@ const textStyle = { const containerId = 'onekey-floating-widget'; +const removeApp = () => { + document.getElementById(containerId)?.remove(); +} + const useOutsideClick = ( ref: { current?: HTMLDivElement | null }, callback: () => void, @@ -61,6 +66,35 @@ const useOutsideClick = ( function CloseDialog({ onClose }: { onClose: () => void }) { const dialogRef = useRef(null); useOutsideClick(dialogRef, onClose); + const handleDisable = useCallback(() => { + void (globalThis as unknown as { + $onekey: { + $private: { + request: ( + arg: { method: string; } + ) => Promise + } + } + }).$onekey.$private.request({ + method: 'wallet_disableFloatingButton', + }); + removeApp(); + }, []) + const handleHideOnSite = useCallback(() => { + void (globalThis as unknown as { + $onekey: { + $private: { + request: ( + arg: { method: string; params: { url: string } } + ) => Promise + } + } + }).$onekey.$private.request({ + method: 'wallet_hideFloatingButtonOnSite', + params: { url: window.location.origin }, + }); + removeApp(); + }, []) return (
void }) { fontSize: '12px', fontWeight: '400', }} + onClick={handleHideOnSite} > Hide on this site
@@ -92,6 +127,7 @@ function CloseDialog({ onClose }: { onClose: () => void }) { fontSize: '12px', fontWeight: '400', }} + onClick={handleDisable} > Disable
@@ -655,7 +691,7 @@ export async function injectFloatingButton() { $onekey: { $private: { request: ( - arg: { method: string; } + arg: { method: string; params: { url: string } } ) => Promise<{ isShow: boolean, i18n: i18nText @@ -664,6 +700,7 @@ export async function injectFloatingButton() { } }).$onekey.$private.request({ method: 'wallet_isShowFloatingButton', + params: { url: window.location.origin }, }); i18n = i18nResponse if (!isShow) { From 34eb1b5f28dd2c57b0d4b883d6f1351d949527f7 Mon Sep 17 00:00:00 2001 From: huhuanming Date: Wed, 18 Dec 2024 12:27:43 +0800 Subject: [PATCH 23/32] Update index.tsx --- .../src/floatingButton/index.tsx | 40 ++++++++++++++----- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx b/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx index 555a1186..b76ab940 100644 --- a/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx +++ b/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx @@ -148,13 +148,16 @@ function IconButton({ isExpanded, onClick, dataLoaded, + isShowCloseDialog, + showCloseDialog, }: { isExpanded: boolean; + isShowCloseDialog: boolean; onClick: () => void; dataLoaded: boolean; + showCloseDialog: () => void; }) { const [showCloseButton, setIsShowCloseButton] = useState(false); - const [showCloseDialog, setIsShowCloseDialog] = useState(false); return (
{ - if (isExpanded || showCloseDialog) { + if (isExpanded || isShowCloseDialog) { return; } setIsShowCloseButton(true); }} onMouseLeave={() => setIsShowCloseButton(false)} onClick={() => { - if (showCloseDialog) { + if (isShowCloseDialog) { return; } setIsShowCloseButton(false); @@ -196,7 +199,7 @@ function IconButton({ onClick={(event) => { event.stopPropagation(); setIsShowCloseButton(false); - setIsShowCloseDialog(true); + showCloseDialog(); }} >
- {!isExpanded && showCloseDialog && ( - { - setIsShowCloseDialog(false); - }} - /> - )}
); } @@ -414,9 +410,12 @@ function SecurityRiskDetectionRow({ function SecurityInfo({ securityInfo, onClose, + showCloseDialog, + }: { securityInfo: IHostSecurity; onClose: () => void; + showCloseDialog: () => void; }) { const viewRef = useRef(null); useOutsideClick(viewRef, onClose); @@ -504,6 +503,10 @@ function SecurityInfo({ height: "24", cursor: "pointer" }} + onClick={() => { + onClose(); + showCloseDialog(); + }} > (null); + const [showCloseDialog, setIsShowCloseDialog] = useState(false); + + const handleShowCloseDialog = useCallback(() => { + setIsShowCloseDialog(true) + }, []) const handleClick = async () => { setIsExpanded(!isExpanded); @@ -670,6 +678,7 @@ function App() { {showSecurityInfo && securityInfo ? ( { setIsExpanded(false); setIsShowSecurityInfo(false); @@ -679,9 +688,18 @@ function App() { )} + {!isExpanded && showCloseDialog && ( + { + setIsShowCloseDialog(false); + }} + /> + )}
); } From a6629755fef73459ec4ec8cbd842d4e9855187c2 Mon Sep 17 00:00:00 2001 From: huhuanming Date: Wed, 18 Dec 2024 12:32:58 +0800 Subject: [PATCH 24/32] Update index.tsx --- .../inpage-providers-hub/src/floatingButton/index.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx b/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx index b76ab940..ac7c49b4 100644 --- a/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx +++ b/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx @@ -1,11 +1,10 @@ import { render } from 'preact'; -import { useEffect, useMemo, useRef, useState } from 'preact/hooks'; +import { useEffect, useMemo, useCallback, useRef, useState } from 'preact/hooks'; import { IHostSecurity, EHostSecurityLevel, } from './type' import { Logo } from './images'; -import { useCallback } from 'react'; let isInjected = false; interface i18nText { @@ -621,7 +620,7 @@ function App() { setIsShowCloseDialog(true) }, []) - const handleClick = async () => { + const handleClick = useCallback(async () => { setIsExpanded(!isExpanded); setIsShowSecurityInfo(true); if (!securityInfo) { @@ -638,7 +637,7 @@ function App() { }); setSecurityInfo(result.securityInfo); } - }; + }, [isExpanded, securityInfo]); const borderStyle = useMemo( () => From a19d86ebf9bd3d05788b9b6edf31c49cbe4a7603 Mon Sep 17 00:00:00 2001 From: huhuanming Date: Wed, 18 Dec 2024 12:39:02 +0800 Subject: [PATCH 25/32] Update index.tsx --- .../inpage-providers-hub/src/floatingButton/index.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx b/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx index ac7c49b4..e3e0db7c 100644 --- a/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx +++ b/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx @@ -113,6 +113,7 @@ function CloseDialog({ onClose }: { onClose: () => void }) { color: 'rgba(0, 0, 0, 1)', fontSize: '12px', fontWeight: '400', + cursor: 'pointer', }} onClick={handleHideOnSite} > @@ -125,6 +126,7 @@ function CloseDialog({ onClose }: { onClose: () => void }) { color: 'rgba(0, 0, 0, 1)', fontSize: '12px', fontWeight: '400', + cursor: 'pointer', }} onClick={handleDisable} > @@ -504,7 +506,9 @@ function SecurityInfo({ }} onClick={() => { onClose(); - showCloseDialog(); + setTimeout(() => { + showCloseDialog(); + }, 800) }} > Date: Wed, 18 Dec 2024 12:46:00 +0800 Subject: [PATCH 26/32] Update index.tsx --- .../providers/inpage-providers-hub/src/floatingButton/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx b/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx index e3e0db7c..21c17b8c 100644 --- a/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx +++ b/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx @@ -508,7 +508,7 @@ function SecurityInfo({ onClose(); setTimeout(() => { showCloseDialog(); - }, 800) + }, 200) }} > Date: Wed, 18 Dec 2024 12:56:45 +0800 Subject: [PATCH 27/32] Update index.tsx --- .../inpage-providers-hub/src/floatingButton/index.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx b/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx index 21c17b8c..2332a014 100644 --- a/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx +++ b/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx @@ -22,6 +22,7 @@ interface i18nText { unknown: string; maliciousSiteWarning: string; suspectedMaliciousBehavior: string; + lastVerifiedAt: string; } let i18n: i18nText = {} as i18nText @@ -187,7 +188,7 @@ function IconButton({ {!dataLoaded && ( - {isExpanded ? 'Fetching dApp info...' : ''} + {isExpanded ? i18n.fetchingDAppInfo : ''} )}
+
{securityInfo?.dapp?.origins.length ? ( - + Date: Wed, 18 Dec 2024 13:01:10 +0800 Subject: [PATCH 28/32] Update index.tsx --- .../inpage-providers-hub/src/floatingButton/index.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx b/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx index 2332a014..f804e776 100644 --- a/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx +++ b/packages/providers/inpage-providers-hub/src/floatingButton/index.tsx @@ -23,6 +23,9 @@ interface i18nText { maliciousSiteWarning: string; suspectedMaliciousBehavior: string; lastVerifiedAt: string; + disable: string; + hideOnThisSite: string; + canBeReEnabledInSettings: string; } let i18n: i18nText = {} as i18nText @@ -118,7 +121,7 @@ function CloseDialog({ onClose }: { onClose: () => void }) { }} onClick={handleHideOnSite} > - Hide on this site + {i18n.hideOnThisSite}
void }) { }} onClick={handleDisable} > - Disable + {i18n.disable}
void }) { fontWeight: '400', }} > - Can be re-enabled in settings. + {i18n.canBeReEnabledInSettings}
); From 5b193535abbc0dd0eb0ffa12f881f9b54596b9ff Mon Sep 17 00:00:00 2001 From: huhuanming Date: Wed, 18 Dec 2024 13:06:04 +0800 Subject: [PATCH 29/32] Update injectWeb3Provider.ts --- .../providers/inpage-providers-hub/src/injectWeb3Provider.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/providers/inpage-providers-hub/src/injectWeb3Provider.ts b/packages/providers/inpage-providers-hub/src/injectWeb3Provider.ts index 835b2b11..937330fe 100644 --- a/packages/providers/inpage-providers-hub/src/injectWeb3Provider.ts +++ b/packages/providers/inpage-providers-hub/src/injectWeb3Provider.ts @@ -307,7 +307,9 @@ function injectWeb3Provider({ showFloatingButton = false }: { showFloatingButton } setTimeout(() => { void detectWebsiteRiskLevel(); - void injectFloatingButton(); + if (showFloatingButton) { + void injectFloatingButton(); + } void hackAllConnectButtons(); void listenPageFocus(); }, 1000); From df703aa36770c009918eea3a19cb89404316137a Mon Sep 17 00:00:00 2001 From: huhuanming Date: Wed, 18 Dec 2024 13:07:16 +0800 Subject: [PATCH 30/32] Update images.tsx --- .../inpage-providers-hub/src/floatingButton/images.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/providers/inpage-providers-hub/src/floatingButton/images.tsx b/packages/providers/inpage-providers-hub/src/floatingButton/images.tsx index 67605942..1078b540 100644 --- a/packages/providers/inpage-providers-hub/src/floatingButton/images.tsx +++ b/packages/providers/inpage-providers-hub/src/floatingButton/images.tsx @@ -2,7 +2,7 @@ export const Logo = ({ style }: { style: any }) => ( Logo From 8fcb4adeb0d8b1040e6a2ca62c3d2c6096b68ed7 Mon Sep 17 00:00:00 2001 From: huhuanming Date: Wed, 18 Dec 2024 13:11:45 +0800 Subject: [PATCH 31/32] fix: fix version --- packages/core/package.json | 8 ++-- .../desktop-bridge-injected/package.json | 6 +-- packages/empty/package.json | 2 +- packages/errors/package.json | 2 +- packages/events/package.json | 2 +- packages/example/package.json | 24 +++++----- .../extension-bridge-hosted/package.json | 6 +-- .../extension-bridge-injected/package.json | 6 +-- packages/injected/package.json | 14 +++--- .../native-bridge-injected/package.json | 6 +-- .../inpage-providers-hub/package.json | 46 +++++++++---------- .../onekey-algo-provider/package.json | 10 ++-- .../onekey-alph-provider/package.json | 10 ++-- .../onekey-aptos-provider/package.json | 10 ++-- .../onekey-bfc-provider/package.json | 10 ++-- .../onekey-btc-provider/package.json | 10 ++-- .../onekey-cardano-provider/package.json | 10 ++-- .../onekey-conflux-provider/package.json | 10 ++-- .../onekey-cosmos-provider/package.json | 10 ++-- .../onekey-eth-provider/package.json | 10 ++-- .../onekey-near-provider/package.json | 10 ++-- .../onekey-nostr-provider/package.json | 10 ++-- .../onekey-polkadot-provider/package.json | 10 ++-- .../onekey-private-provider/package.json | 10 ++-- .../onekey-scdo-provider/package.json | 10 ++-- .../onekey-solana-provider/package.json | 10 ++-- .../onekey-sui-provider/package.json | 10 ++-- .../onekey-ton-provider/package.json | 10 ++-- .../onekey-tron-provider/package.json | 10 ++-- .../onekey-webln-provider/package.json | 10 ++-- packages/types/package.json | 2 +- packages/webview/package.json | 6 +-- 32 files changed, 160 insertions(+), 160 deletions(-) diff --git a/packages/core/package.json b/packages/core/package.json index 075cd100..b5b8c101 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/cross-inpage-provider-core", - "version": "2.1.23", + "version": "2.2.0", "keywords": [ "cross-inpage-provider" ], @@ -29,9 +29,9 @@ "build-version-info": "node ./scripts/buildVersionInfo.js" }, "dependencies": { - "@onekeyfe/cross-inpage-provider-errors": "2.1.23", - "@onekeyfe/cross-inpage-provider-events": "2.1.23", - "@onekeyfe/cross-inpage-provider-types": "2.1.23", + "@onekeyfe/cross-inpage-provider-errors": "2.2.0", + "@onekeyfe/cross-inpage-provider-events": "2.2.0", + "@onekeyfe/cross-inpage-provider-types": "2.2.0", "events": "^3.3.0", "lodash-es": "^4.17.21", "ms": "^2.1.3" diff --git a/packages/desktop/desktop-bridge-injected/package.json b/packages/desktop/desktop-bridge-injected/package.json index 1b04fa67..6ec9184f 100644 --- a/packages/desktop/desktop-bridge-injected/package.json +++ b/packages/desktop/desktop-bridge-injected/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/desktop-bridge-injected", - "version": "2.1.23", + "version": "2.2.0", "keywords": [ "cross-inpage-provider" ], @@ -34,7 +34,7 @@ "electron": "^17.2.0" }, "dependencies": { - "@onekeyfe/cross-inpage-provider-core": "2.1.23", - "@onekeyfe/cross-inpage-provider-types": "2.1.23" + "@onekeyfe/cross-inpage-provider-core": "2.2.0", + "@onekeyfe/cross-inpage-provider-types": "2.2.0" } } diff --git a/packages/empty/package.json b/packages/empty/package.json index 40c29da4..2ba970c7 100644 --- a/packages/empty/package.json +++ b/packages/empty/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/cross-inpage-provider-empty", - "version": "2.1.23", + "version": "2.2.0", "keywords": [ "cross-inpage-provider" ], diff --git a/packages/errors/package.json b/packages/errors/package.json index 31142f2f..c547028a 100644 --- a/packages/errors/package.json +++ b/packages/errors/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/cross-inpage-provider-errors", - "version": "2.1.23", + "version": "2.2.0", "keywords": [ "cross-inpage-provider" ], diff --git a/packages/events/package.json b/packages/events/package.json index 2785963d..e40f5e42 100644 --- a/packages/events/package.json +++ b/packages/events/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/cross-inpage-provider-events", - "version": "2.1.23", + "version": "2.2.0", "keywords": [ "cross-inpage-provider" ], diff --git a/packages/example/package.json b/packages/example/package.json index 23caf1c7..c121a4a7 100644 --- a/packages/example/package.json +++ b/packages/example/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/cross-inpage-provider-example", - "version": "2.1.23", + "version": "2.2.0", "private": true, "scripts": { "postinstall": "patch-package", @@ -28,17 +28,17 @@ "@metamask/onboarding": "^1.0.1", "@mizuwallet-sdk/core": "^1.4.0", "@mysten/dapp-kit": "0.13.2", - "@onekeyfe/cross-inpage-provider-core": "2.1.23", - "@onekeyfe/cross-inpage-provider-types": "2.1.23", - "@onekeyfe/onekey-aptos-provider": "2.1.23", - "@onekeyfe/onekey-cardano-provider": "2.1.23", - "@onekeyfe/onekey-conflux-provider": "2.1.23", - "@onekeyfe/onekey-cosmos-provider": "2.1.23", - "@onekeyfe/onekey-near-provider": "2.1.23", - "@onekeyfe/onekey-solana-provider": "2.1.23", - "@onekeyfe/onekey-sui-provider": "2.1.23", - "@onekeyfe/onekey-tron-provider": "2.1.23", - "@onekeyfe/onekey-webln-provider": "2.1.23", + "@onekeyfe/cross-inpage-provider-core": "2.2.0", + "@onekeyfe/cross-inpage-provider-types": "2.2.0", + "@onekeyfe/onekey-aptos-provider": "2.2.0", + "@onekeyfe/onekey-cardano-provider": "2.2.0", + "@onekeyfe/onekey-conflux-provider": "2.2.0", + "@onekeyfe/onekey-cosmos-provider": "2.2.0", + "@onekeyfe/onekey-near-provider": "2.2.0", + "@onekeyfe/onekey-solana-provider": "2.2.0", + "@onekeyfe/onekey-sui-provider": "2.2.0", + "@onekeyfe/onekey-tron-provider": "2.2.0", + "@onekeyfe/onekey-webln-provider": "2.2.0", "@polkadot/api": "^9.11.3", "@polkadot/extension-dapp": "^0.47.5", "@radix-ui/react-checkbox": "^1.1.2", diff --git a/packages/extension/extension-bridge-hosted/package.json b/packages/extension/extension-bridge-hosted/package.json index 69f7bd3a..ec650a70 100644 --- a/packages/extension/extension-bridge-hosted/package.json +++ b/packages/extension/extension-bridge-hosted/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/extension-bridge-hosted", - "version": "2.1.23", + "version": "2.2.0", "keywords": [ "cross-inpage-provider" ], @@ -28,8 +28,8 @@ "start": "tsc --watch" }, "dependencies": { - "@onekeyfe/cross-inpage-provider-core": "2.1.23", - "@onekeyfe/cross-inpage-provider-types": "2.1.23", + "@onekeyfe/cross-inpage-provider-core": "2.2.0", + "@onekeyfe/cross-inpage-provider-types": "2.2.0", "uuid": "^8.3.2" }, "devDependencies": { diff --git a/packages/extension/extension-bridge-injected/package.json b/packages/extension/extension-bridge-injected/package.json index a8ca9049..c2b10b77 100644 --- a/packages/extension/extension-bridge-injected/package.json +++ b/packages/extension/extension-bridge-injected/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/extension-bridge-injected", - "version": "2.1.23", + "version": "2.2.0", "keywords": [ "cross-inpage-provider" ], @@ -28,7 +28,7 @@ "start": "tsc --watch" }, "dependencies": { - "@onekeyfe/cross-inpage-provider-core": "2.1.23", - "@onekeyfe/cross-inpage-provider-types": "2.1.23" + "@onekeyfe/cross-inpage-provider-core": "2.2.0", + "@onekeyfe/cross-inpage-provider-types": "2.2.0" } } diff --git a/packages/injected/package.json b/packages/injected/package.json index fbdfc3a6..ed6e90f3 100644 --- a/packages/injected/package.json +++ b/packages/injected/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/cross-inpage-provider-injected", - "version": "2.1.23", + "version": "2.2.0", "keywords": [ "cross-inpage-provider" ], @@ -42,12 +42,12 @@ "electron": "*" }, "dependencies": { - "@onekeyfe/cross-inpage-provider-core": "2.1.23", - "@onekeyfe/cross-inpage-provider-types": "2.1.23", - "@onekeyfe/desktop-bridge-injected": "2.1.23", - "@onekeyfe/extension-bridge-injected": "2.1.23", - "@onekeyfe/inpage-providers-hub": "2.1.23", - "@onekeyfe/native-bridge-injected": "2.1.23", + "@onekeyfe/cross-inpage-provider-core": "2.2.0", + "@onekeyfe/cross-inpage-provider-types": "2.2.0", + "@onekeyfe/desktop-bridge-injected": "2.2.0", + "@onekeyfe/extension-bridge-injected": "2.2.0", + "@onekeyfe/inpage-providers-hub": "2.2.0", + "@onekeyfe/native-bridge-injected": "2.2.0", "buffer": "^6.0.3", "crypto-browserify": "^3.12.0" } diff --git a/packages/native/native-bridge-injected/package.json b/packages/native/native-bridge-injected/package.json index 7da54e95..f9f92eda 100644 --- a/packages/native/native-bridge-injected/package.json +++ b/packages/native/native-bridge-injected/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/native-bridge-injected", - "version": "2.1.23", + "version": "2.2.0", "keywords": [ "cross-inpage-provider" ], @@ -28,7 +28,7 @@ "start": "tsc --watch" }, "dependencies": { - "@onekeyfe/cross-inpage-provider-core": "2.1.23", - "@onekeyfe/cross-inpage-provider-types": "2.1.23" + "@onekeyfe/cross-inpage-provider-core": "2.2.0", + "@onekeyfe/cross-inpage-provider-types": "2.2.0" } } diff --git a/packages/providers/inpage-providers-hub/package.json b/packages/providers/inpage-providers-hub/package.json index fac5bd39..9713ee9a 100644 --- a/packages/providers/inpage-providers-hub/package.json +++ b/packages/providers/inpage-providers-hub/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/inpage-providers-hub", - "version": "2.1.23", + "version": "2.2.0", "keywords": [ "cross-inpage-provider" ], @@ -30,28 +30,28 @@ "start": "tsc --watch" }, "dependencies": { - "@onekeyfe/cross-inpage-provider-core": "2.1.23", - "@onekeyfe/cross-inpage-provider-types": "2.1.23", - "@onekeyfe/onekey-algo-provider": "2.1.23", - "@onekeyfe/onekey-alph-provider": "2.1.23", - "@onekeyfe/onekey-aptos-provider": "2.1.23", - "@onekeyfe/onekey-bfc-provider": "2.1.23", - "@onekeyfe/onekey-btc-provider": "2.1.23", - "@onekeyfe/onekey-cardano-provider": "2.1.23", - "@onekeyfe/onekey-conflux-provider": "2.1.23", - "@onekeyfe/onekey-cosmos-provider": "2.1.23", - "@onekeyfe/onekey-eth-provider": "2.1.23", - "@onekeyfe/onekey-nostr-provider": "2.1.23", - "@onekeyfe/onekey-polkadot-provider": "2.1.23", - "@onekeyfe/onekey-private-provider": "2.1.23", - "@onekeyfe/onekey-scdo-provider": "2.1.23", - "@onekeyfe/onekey-solana-provider": "2.1.23", - "@onekeyfe/onekey-sui-provider": "2.1.23", - "@onekeyfe/onekey-ton-provider": "2.1.23", - "@onekeyfe/onekey-tron-provider": "2.1.23", - "@onekeyfe/onekey-webln-provider": "2.1.23", - "web3": "^1.7.3", - "preact": "^10.25.1" + "@onekeyfe/cross-inpage-provider-core": "2.2.0", + "@onekeyfe/cross-inpage-provider-types": "2.2.0", + "@onekeyfe/onekey-algo-provider": "2.2.0", + "@onekeyfe/onekey-alph-provider": "2.2.0", + "@onekeyfe/onekey-aptos-provider": "2.2.0", + "@onekeyfe/onekey-bfc-provider": "2.2.0", + "@onekeyfe/onekey-btc-provider": "2.2.0", + "@onekeyfe/onekey-cardano-provider": "2.2.0", + "@onekeyfe/onekey-conflux-provider": "2.2.0", + "@onekeyfe/onekey-cosmos-provider": "2.2.0", + "@onekeyfe/onekey-eth-provider": "2.2.0", + "@onekeyfe/onekey-nostr-provider": "2.2.0", + "@onekeyfe/onekey-polkadot-provider": "2.2.0", + "@onekeyfe/onekey-private-provider": "2.2.0", + "@onekeyfe/onekey-scdo-provider": "2.2.0", + "@onekeyfe/onekey-solana-provider": "2.2.0", + "@onekeyfe/onekey-sui-provider": "2.2.0", + "@onekeyfe/onekey-ton-provider": "2.2.0", + "@onekeyfe/onekey-tron-provider": "2.2.0", + "@onekeyfe/onekey-webln-provider": "2.2.0", + "preact": "^10.25.1", + "web3": "^1.7.3" }, "devDependencies": { "@playwright/test": "^1.43.1", diff --git a/packages/providers/onekey-algo-provider/package.json b/packages/providers/onekey-algo-provider/package.json index 36658ca5..a98b2f7d 100644 --- a/packages/providers/onekey-algo-provider/package.json +++ b/packages/providers/onekey-algo-provider/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/onekey-algo-provider", - "version": "2.1.23", + "version": "2.2.0", "keywords": [ "cross-inpage-provider" ], @@ -28,9 +28,9 @@ "start": "tsc --watch" }, "dependencies": { - "@onekeyfe/cross-inpage-provider-core": "2.1.23", - "@onekeyfe/cross-inpage-provider-errors": "2.1.23", - "@onekeyfe/cross-inpage-provider-types": "2.1.23", - "@onekeyfe/extension-bridge-injected": "2.1.23" + "@onekeyfe/cross-inpage-provider-core": "2.2.0", + "@onekeyfe/cross-inpage-provider-errors": "2.2.0", + "@onekeyfe/cross-inpage-provider-types": "2.2.0", + "@onekeyfe/extension-bridge-injected": "2.2.0" } } diff --git a/packages/providers/onekey-alph-provider/package.json b/packages/providers/onekey-alph-provider/package.json index a0fc442c..f544cf18 100644 --- a/packages/providers/onekey-alph-provider/package.json +++ b/packages/providers/onekey-alph-provider/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/onekey-alph-provider", - "version": "2.1.23", + "version": "2.2.0", "keywords": [ "cross-inpage-provider" ], @@ -31,9 +31,9 @@ "@alephium/get-extension-wallet": "^1.5.2", "@alephium/walletconnect-provider": "^1.5.2", "@alephium/web3": "^1.5.2", - "@onekeyfe/cross-inpage-provider-core": "2.1.23", - "@onekeyfe/cross-inpage-provider-errors": "2.1.23", - "@onekeyfe/cross-inpage-provider-types": "2.1.23", - "@onekeyfe/extension-bridge-injected": "2.1.23" + "@onekeyfe/cross-inpage-provider-core": "2.2.0", + "@onekeyfe/cross-inpage-provider-errors": "2.2.0", + "@onekeyfe/cross-inpage-provider-types": "2.2.0", + "@onekeyfe/extension-bridge-injected": "2.2.0" } } diff --git a/packages/providers/onekey-aptos-provider/package.json b/packages/providers/onekey-aptos-provider/package.json index 4cddc46c..755417e5 100644 --- a/packages/providers/onekey-aptos-provider/package.json +++ b/packages/providers/onekey-aptos-provider/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/onekey-aptos-provider", - "version": "2.1.23", + "version": "2.2.0", "keywords": [ "cross-inpage-provider" ], @@ -29,10 +29,10 @@ }, "dependencies": { "@aptos-labs/wallet-standard": "^0.2.0", - "@onekeyfe/cross-inpage-provider-core": "2.1.23", - "@onekeyfe/cross-inpage-provider-errors": "2.1.23", - "@onekeyfe/cross-inpage-provider-types": "2.1.23", - "@onekeyfe/extension-bridge-injected": "2.1.23", + "@onekeyfe/cross-inpage-provider-core": "2.2.0", + "@onekeyfe/cross-inpage-provider-errors": "2.2.0", + "@onekeyfe/cross-inpage-provider-types": "2.2.0", + "@onekeyfe/extension-bridge-injected": "2.2.0", "@wallet-standard/core": "1.0.3", "eth-rpc-errors": "^4.0.3" }, diff --git a/packages/providers/onekey-bfc-provider/package.json b/packages/providers/onekey-bfc-provider/package.json index 95a98668..d7cc50cc 100644 --- a/packages/providers/onekey-bfc-provider/package.json +++ b/packages/providers/onekey-bfc-provider/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/onekey-bfc-provider", - "version": "2.1.23", + "version": "2.2.0", "keywords": [ "cross-inpage-provider" ], @@ -29,10 +29,10 @@ }, "dependencies": { "@benfen/bfc.js": "0.2.7", - "@onekeyfe/cross-inpage-provider-core": "2.1.23", - "@onekeyfe/cross-inpage-provider-errors": "2.1.23", - "@onekeyfe/cross-inpage-provider-types": "2.1.23", - "@onekeyfe/extension-bridge-injected": "2.1.23", + "@onekeyfe/cross-inpage-provider-core": "2.2.0", + "@onekeyfe/cross-inpage-provider-errors": "2.2.0", + "@onekeyfe/cross-inpage-provider-types": "2.2.0", + "@onekeyfe/extension-bridge-injected": "2.2.0", "eth-rpc-errors": "^4.0.3", "mitt": "^3.0.0" }, diff --git a/packages/providers/onekey-btc-provider/package.json b/packages/providers/onekey-btc-provider/package.json index 3f62b360..b6ddd84b 100644 --- a/packages/providers/onekey-btc-provider/package.json +++ b/packages/providers/onekey-btc-provider/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/onekey-btc-provider", - "version": "2.1.23", + "version": "2.2.0", "keywords": [ "cross-inpage-provider" ], @@ -28,9 +28,9 @@ "start": "tsc --watch" }, "dependencies": { - "@onekeyfe/cross-inpage-provider-core": "2.1.23", - "@onekeyfe/cross-inpage-provider-errors": "2.1.23", - "@onekeyfe/cross-inpage-provider-types": "2.1.23", - "@onekeyfe/extension-bridge-injected": "2.1.23" + "@onekeyfe/cross-inpage-provider-core": "2.2.0", + "@onekeyfe/cross-inpage-provider-errors": "2.2.0", + "@onekeyfe/cross-inpage-provider-types": "2.2.0", + "@onekeyfe/extension-bridge-injected": "2.2.0" } } diff --git a/packages/providers/onekey-cardano-provider/package.json b/packages/providers/onekey-cardano-provider/package.json index d0697fab..e33505e2 100644 --- a/packages/providers/onekey-cardano-provider/package.json +++ b/packages/providers/onekey-cardano-provider/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/onekey-cardano-provider", - "version": "2.1.23", + "version": "2.2.0", "keywords": [ "cross-inpage-provider", "cardano" @@ -29,9 +29,9 @@ "start": "tsc --watch" }, "dependencies": { - "@onekeyfe/cross-inpage-provider-core": "2.1.23", - "@onekeyfe/cross-inpage-provider-errors": "2.1.23", - "@onekeyfe/cross-inpage-provider-types": "2.1.23", - "@onekeyfe/extension-bridge-injected": "2.1.23" + "@onekeyfe/cross-inpage-provider-core": "2.2.0", + "@onekeyfe/cross-inpage-provider-errors": "2.2.0", + "@onekeyfe/cross-inpage-provider-types": "2.2.0", + "@onekeyfe/extension-bridge-injected": "2.2.0" } } diff --git a/packages/providers/onekey-conflux-provider/package.json b/packages/providers/onekey-conflux-provider/package.json index 1629a7e8..4073a1c5 100644 --- a/packages/providers/onekey-conflux-provider/package.json +++ b/packages/providers/onekey-conflux-provider/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/onekey-conflux-provider", - "version": "2.1.23", + "version": "2.2.0", "keywords": [ "cross-inpage-provider" ], @@ -28,9 +28,9 @@ "start": "tsc --watch" }, "dependencies": { - "@onekeyfe/cross-inpage-provider-core": "2.1.23", - "@onekeyfe/cross-inpage-provider-errors": "2.1.23", - "@onekeyfe/cross-inpage-provider-types": "2.1.23", - "@onekeyfe/extension-bridge-injected": "2.1.23" + "@onekeyfe/cross-inpage-provider-core": "2.2.0", + "@onekeyfe/cross-inpage-provider-errors": "2.2.0", + "@onekeyfe/cross-inpage-provider-types": "2.2.0", + "@onekeyfe/extension-bridge-injected": "2.2.0" } } diff --git a/packages/providers/onekey-cosmos-provider/package.json b/packages/providers/onekey-cosmos-provider/package.json index 478e942d..d7864db5 100644 --- a/packages/providers/onekey-cosmos-provider/package.json +++ b/packages/providers/onekey-cosmos-provider/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/onekey-cosmos-provider", - "version": "2.1.23", + "version": "2.2.0", "keywords": [ "cross-inpage-provider" ], @@ -29,10 +29,10 @@ }, "dependencies": { "@noble/hashes": "^1.3.0", - "@onekeyfe/cross-inpage-provider-core": "2.1.23", - "@onekeyfe/cross-inpage-provider-errors": "2.1.23", - "@onekeyfe/cross-inpage-provider-types": "2.1.23", - "@onekeyfe/extension-bridge-injected": "2.1.23", + "@onekeyfe/cross-inpage-provider-core": "2.2.0", + "@onekeyfe/cross-inpage-provider-errors": "2.2.0", + "@onekeyfe/cross-inpage-provider-types": "2.2.0", + "@onekeyfe/extension-bridge-injected": "2.2.0", "eth-rpc-errors": "^4.0.3", "long": "^5.2.1", "mitt": "^3.0.0" diff --git a/packages/providers/onekey-eth-provider/package.json b/packages/providers/onekey-eth-provider/package.json index 45e43447..91439ca0 100644 --- a/packages/providers/onekey-eth-provider/package.json +++ b/packages/providers/onekey-eth-provider/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/onekey-eth-provider", - "version": "2.1.23", + "version": "2.2.0", "keywords": [ "cross-inpage-provider" ], @@ -28,10 +28,10 @@ "start": "tsc --watch" }, "dependencies": { - "@onekeyfe/cross-inpage-provider-core": "2.1.23", - "@onekeyfe/cross-inpage-provider-errors": "2.1.23", - "@onekeyfe/cross-inpage-provider-types": "2.1.23", - "@onekeyfe/extension-bridge-injected": "2.1.23", + "@onekeyfe/cross-inpage-provider-core": "2.2.0", + "@onekeyfe/cross-inpage-provider-errors": "2.2.0", + "@onekeyfe/cross-inpage-provider-types": "2.2.0", + "@onekeyfe/extension-bridge-injected": "2.2.0", "eth-rpc-errors": "^4.0.3", "uuid": "^8.3.2" }, diff --git a/packages/providers/onekey-near-provider/package.json b/packages/providers/onekey-near-provider/package.json index 48b771bf..c2d44a9d 100644 --- a/packages/providers/onekey-near-provider/package.json +++ b/packages/providers/onekey-near-provider/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/onekey-near-provider", - "version": "2.1.23", + "version": "2.2.0", "keywords": [ "cross-inpage-provider" ], @@ -35,10 +35,10 @@ "near-api-js": "^0.44.2" }, "dependencies": { - "@onekeyfe/cross-inpage-provider-core": "2.1.23", - "@onekeyfe/cross-inpage-provider-errors": "2.1.23", - "@onekeyfe/cross-inpage-provider-types": "2.1.23", - "@onekeyfe/extension-bridge-injected": "2.1.23", + "@onekeyfe/cross-inpage-provider-core": "2.2.0", + "@onekeyfe/cross-inpage-provider-errors": "2.2.0", + "@onekeyfe/cross-inpage-provider-types": "2.2.0", + "@onekeyfe/extension-bridge-injected": "2.2.0", "borsh": "^0.6.0", "depd": "^2.0.0", "tweetnacl": "^1.0.3" diff --git a/packages/providers/onekey-nostr-provider/package.json b/packages/providers/onekey-nostr-provider/package.json index a86a2225..513a791b 100644 --- a/packages/providers/onekey-nostr-provider/package.json +++ b/packages/providers/onekey-nostr-provider/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/onekey-nostr-provider", - "version": "2.1.23", + "version": "2.2.0", "keywords": [ "cross-inpage-provider" ], @@ -28,9 +28,9 @@ "start": "tsc --watch" }, "dependencies": { - "@onekeyfe/cross-inpage-provider-core": "2.1.23", - "@onekeyfe/cross-inpage-provider-errors": "2.1.23", - "@onekeyfe/cross-inpage-provider-types": "2.1.23", - "@onekeyfe/extension-bridge-injected": "2.1.23" + "@onekeyfe/cross-inpage-provider-core": "2.2.0", + "@onekeyfe/cross-inpage-provider-errors": "2.2.0", + "@onekeyfe/cross-inpage-provider-types": "2.2.0", + "@onekeyfe/extension-bridge-injected": "2.2.0" } } diff --git a/packages/providers/onekey-polkadot-provider/package.json b/packages/providers/onekey-polkadot-provider/package.json index fc811c7c..735be1c6 100644 --- a/packages/providers/onekey-polkadot-provider/package.json +++ b/packages/providers/onekey-polkadot-provider/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/onekey-polkadot-provider", - "version": "2.1.23", + "version": "2.2.0", "keywords": [ "cross-inpage-provider" ], @@ -29,10 +29,10 @@ }, "dependencies": { "@noble/hashes": "^1.3.0", - "@onekeyfe/cross-inpage-provider-core": "2.1.23", - "@onekeyfe/cross-inpage-provider-errors": "2.1.23", - "@onekeyfe/cross-inpage-provider-types": "2.1.23", - "@onekeyfe/extension-bridge-injected": "2.1.23", + "@onekeyfe/cross-inpage-provider-core": "2.2.0", + "@onekeyfe/cross-inpage-provider-errors": "2.2.0", + "@onekeyfe/cross-inpage-provider-types": "2.2.0", + "@onekeyfe/extension-bridge-injected": "2.2.0", "@polkadot/extension-inject": "^0.46.3", "eth-rpc-errors": "^4.0.3", "long": "^5.2.1", diff --git a/packages/providers/onekey-private-provider/package.json b/packages/providers/onekey-private-provider/package.json index f79e4bb5..f5a9f099 100644 --- a/packages/providers/onekey-private-provider/package.json +++ b/packages/providers/onekey-private-provider/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/onekey-private-provider", - "version": "2.1.23", + "version": "2.2.0", "keywords": [ "cross-inpage-provider" ], @@ -28,9 +28,9 @@ "start": "tsc --watch" }, "dependencies": { - "@onekeyfe/cross-inpage-provider-core": "2.1.23", - "@onekeyfe/cross-inpage-provider-errors": "2.1.23", - "@onekeyfe/cross-inpage-provider-types": "2.1.23", - "@onekeyfe/extension-bridge-injected": "2.1.23" + "@onekeyfe/cross-inpage-provider-core": "2.2.0", + "@onekeyfe/cross-inpage-provider-errors": "2.2.0", + "@onekeyfe/cross-inpage-provider-types": "2.2.0", + "@onekeyfe/extension-bridge-injected": "2.2.0" } } diff --git a/packages/providers/onekey-scdo-provider/package.json b/packages/providers/onekey-scdo-provider/package.json index 85a407b6..2fa85429 100644 --- a/packages/providers/onekey-scdo-provider/package.json +++ b/packages/providers/onekey-scdo-provider/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/onekey-scdo-provider", - "version": "2.1.23", + "version": "2.2.0", "keywords": [ "cross-inpage-provider" ], @@ -28,9 +28,9 @@ "start": "tsc --watch" }, "dependencies": { - "@onekeyfe/cross-inpage-provider-core": "2.1.23", - "@onekeyfe/cross-inpage-provider-errors": "2.1.23", - "@onekeyfe/cross-inpage-provider-types": "2.1.23", - "@onekeyfe/extension-bridge-injected": "2.1.23" + "@onekeyfe/cross-inpage-provider-core": "2.2.0", + "@onekeyfe/cross-inpage-provider-errors": "2.2.0", + "@onekeyfe/cross-inpage-provider-types": "2.2.0", + "@onekeyfe/extension-bridge-injected": "2.2.0" } } diff --git a/packages/providers/onekey-solana-provider/package.json b/packages/providers/onekey-solana-provider/package.json index 406f7d23..43d89ac5 100644 --- a/packages/providers/onekey-solana-provider/package.json +++ b/packages/providers/onekey-solana-provider/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/onekey-solana-provider", - "version": "2.1.23", + "version": "2.2.0", "keywords": [ "cross-inpage-provider", "solona" @@ -29,10 +29,10 @@ "start": "tsc --watch" }, "dependencies": { - "@onekeyfe/cross-inpage-provider-core": "2.1.23", - "@onekeyfe/cross-inpage-provider-errors": "2.1.23", - "@onekeyfe/cross-inpage-provider-types": "2.1.23", - "@onekeyfe/extension-bridge-injected": "2.1.23", + "@onekeyfe/cross-inpage-provider-core": "2.2.0", + "@onekeyfe/cross-inpage-provider-errors": "2.2.0", + "@onekeyfe/cross-inpage-provider-types": "2.2.0", + "@onekeyfe/extension-bridge-injected": "2.2.0", "@solana/wallet-standard-features": "^1.1.0", "@solana/web3.js": "^1.41.3", "@wallet-standard/base": "^1.0.1", diff --git a/packages/providers/onekey-sui-provider/package.json b/packages/providers/onekey-sui-provider/package.json index cbd97d43..49103e16 100644 --- a/packages/providers/onekey-sui-provider/package.json +++ b/packages/providers/onekey-sui-provider/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/onekey-sui-provider", - "version": "2.1.23", + "version": "2.2.0", "keywords": [ "cross-inpage-provider" ], @@ -29,10 +29,10 @@ }, "dependencies": { "@mysten/wallet-standard": "^0.7.2", - "@onekeyfe/cross-inpage-provider-core": "2.1.23", - "@onekeyfe/cross-inpage-provider-errors": "2.1.23", - "@onekeyfe/cross-inpage-provider-types": "2.1.23", - "@onekeyfe/extension-bridge-injected": "2.1.23", + "@onekeyfe/cross-inpage-provider-core": "2.2.0", + "@onekeyfe/cross-inpage-provider-errors": "2.2.0", + "@onekeyfe/cross-inpage-provider-types": "2.2.0", + "@onekeyfe/extension-bridge-injected": "2.2.0", "eth-rpc-errors": "^4.0.3", "mitt": "^3.0.0" } diff --git a/packages/providers/onekey-ton-provider/package.json b/packages/providers/onekey-ton-provider/package.json index cabfb21a..b60a61c1 100644 --- a/packages/providers/onekey-ton-provider/package.json +++ b/packages/providers/onekey-ton-provider/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/onekey-ton-provider", - "version": "2.1.23", + "version": "2.2.0", "keywords": [ "cross-inpage-provider" ], @@ -28,10 +28,10 @@ "start": "tsc --watch" }, "dependencies": { - "@onekeyfe/cross-inpage-provider-core": "2.1.23", - "@onekeyfe/cross-inpage-provider-errors": "2.1.23", - "@onekeyfe/cross-inpage-provider-types": "2.1.23", - "@onekeyfe/extension-bridge-injected": "2.1.23", + "@onekeyfe/cross-inpage-provider-core": "2.2.0", + "@onekeyfe/cross-inpage-provider-errors": "2.2.0", + "@onekeyfe/cross-inpage-provider-types": "2.2.0", + "@onekeyfe/extension-bridge-injected": "2.2.0", "@tonconnect/protocol": "^2.2.6" } } diff --git a/packages/providers/onekey-tron-provider/package.json b/packages/providers/onekey-tron-provider/package.json index e3eecbf5..b8bb76df 100644 --- a/packages/providers/onekey-tron-provider/package.json +++ b/packages/providers/onekey-tron-provider/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/onekey-tron-provider", - "version": "2.1.23", + "version": "2.2.0", "keywords": [ "cross-inpage-provider" ], @@ -29,10 +29,10 @@ }, "dependencies": { "@noble/secp256k1": "1.7.1", - "@onekeyfe/cross-inpage-provider-core": "2.1.23", - "@onekeyfe/cross-inpage-provider-errors": "2.1.23", - "@onekeyfe/cross-inpage-provider-types": "2.1.23", - "@onekeyfe/extension-bridge-injected": "2.1.23", + "@onekeyfe/cross-inpage-provider-core": "2.2.0", + "@onekeyfe/cross-inpage-provider-errors": "2.2.0", + "@onekeyfe/cross-inpage-provider-types": "2.2.0", + "@onekeyfe/extension-bridge-injected": "2.2.0", "querystring": "^0.2.1", "sunweb": "^1.0.7", "tronweb": "^5.3.2" diff --git a/packages/providers/onekey-webln-provider/package.json b/packages/providers/onekey-webln-provider/package.json index d96e59cb..371e707d 100644 --- a/packages/providers/onekey-webln-provider/package.json +++ b/packages/providers/onekey-webln-provider/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/onekey-webln-provider", - "version": "2.1.23", + "version": "2.2.0", "keywords": [ "cross-inpage-provider" ], @@ -28,9 +28,9 @@ "start": "tsc --watch" }, "dependencies": { - "@onekeyfe/cross-inpage-provider-core": "2.1.23", - "@onekeyfe/cross-inpage-provider-errors": "2.1.23", - "@onekeyfe/cross-inpage-provider-types": "2.1.23", - "@onekeyfe/extension-bridge-injected": "2.1.23" + "@onekeyfe/cross-inpage-provider-core": "2.2.0", + "@onekeyfe/cross-inpage-provider-errors": "2.2.0", + "@onekeyfe/cross-inpage-provider-types": "2.2.0", + "@onekeyfe/extension-bridge-injected": "2.2.0" } } diff --git a/packages/types/package.json b/packages/types/package.json index d0ffbeae..5f1c93b5 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/cross-inpage-provider-types", - "version": "2.1.23", + "version": "2.2.0", "keywords": [ "cross-inpage-provider" ], diff --git a/packages/webview/package.json b/packages/webview/package.json index 8d391240..7bb3254b 100644 --- a/packages/webview/package.json +++ b/packages/webview/package.json @@ -1,6 +1,6 @@ { "name": "@onekeyfe/onekey-cross-webview", - "version": "2.1.23", + "version": "2.2.0", "keywords": [ "cross-inpage-provider" ], @@ -36,7 +36,7 @@ "react-native-webview": "^11.17.2" }, "dependencies": { - "@onekeyfe/cross-inpage-provider-core": "2.1.23", - "@onekeyfe/cross-inpage-provider-types": "2.1.23" + "@onekeyfe/cross-inpage-provider-core": "2.2.0", + "@onekeyfe/cross-inpage-provider-types": "2.2.0" } } From 3d7af025f1458b527933835f221e8dc2d0f1e528 Mon Sep 17 00:00:00 2001 From: huhuanming Date: Wed, 18 Dec 2024 13:11:50 +0800 Subject: [PATCH 32/32] Update versionInfo.ts --- packages/core/src/versionInfo.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/src/versionInfo.ts b/packages/core/src/versionInfo.ts index 7510fa27..0dc0673e 100644 --- a/packages/core/src/versionInfo.ts +++ b/packages/core/src/versionInfo.ts @@ -1,5 +1,5 @@ -const version = '2.1.21'; +const version = '2.2.0'; const versionBuild = '2020-0101-1'; export default {