diff --git a/package-lock.json b/package-lock.json index f7fab18..df881a4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "wallet-bridge", - "version": "0.1.60", + "version": "0.1.61-beta.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "wallet-bridge", - "version": "0.1.60", + "version": "0.1.61-beta.3", "dependencies": { "@headlessui/react": "^1.7.15", "@lingui/detect-locale": "^4.5.0", diff --git a/package.json b/package.json index 500851c..10164e4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "wallet-bridge", "private": false, - "version": "0.1.60", + "version": "0.1.61-beta.3", "main": "./dist/wallet-bridge.umd.js", "module": "./dist/wallet-bridge.es.js", "types": "./dist/index.d.ts", diff --git a/src/lib/components/Icons/index.tsx b/src/lib/components/Icons/index.tsx index 5c92a68..d826bb6 100644 --- a/src/lib/components/Icons/index.tsx +++ b/src/lib/components/Icons/index.tsx @@ -559,3 +559,29 @@ export function QRCodeIcon(props: React.SVGProps) { ) } + +export function TorusIcon(props: React.SVGProps) { + const { className, ...rest } = props + return ( + + + + + ) +} diff --git a/src/lib/ui/LoggedIn/LoggedIn.tsx b/src/lib/ui/LoggedIn/LoggedIn.tsx index 4bc2765..b1c132f 100644 --- a/src/lib/ui/LoggedIn/LoggedIn.tsx +++ b/src/lib/ui/LoggedIn/LoggedIn.tsx @@ -1,7 +1,16 @@ -import { CopyIcon, DeviceIcon, DisconnectIcon, Header, QRCodeIcon, SwapChildProps, SwitchIcon } from '../../components' +import { + CopyIcon, + DeviceIcon, + DisconnectIcon, + Header, + QRCodeIcon, + SwapChildProps, + SwitchIcon, + TorusIcon, +} from '../../components' import { CoinType, WalletProtocol } from '../../constant' import { backupDeviceData, getAuthorizeInfo, getDotbitAlias, getMastersAddress, useWalletState } from '../../store' -import { ReactNode, useContext, useEffect, useState } from 'react' +import { ReactNode, useContext, useEffect, useMemo, useState } from 'react' import { collapseString, copyText } from '../../utils' import { WalletSDKContext } from '../ConnectWallet' import { useSimpleRouter } from '../../components/SimpleRouter' @@ -87,6 +96,14 @@ export const LoggedIn = ({ transitionRef, transitionStyle }: SwapChildProps) => }) } + const openTorus = () => { + walletSDK?.context?.torusWallet?.showWallet?.('home') + } + + const showOpenTorusButton = useMemo(() => { + return !!walletSDK?.context?.torusWallet?.isLoggedIn + }, [walletSDK?.context?.torusWallet?.isLoggedIn]) + useEffect(() => { void getMastersAddress() void getAuthorizeInfo().then(() => { @@ -191,6 +208,15 @@ export const LoggedIn = ({ transitionRef, transitionStyle }: SwapChildProps) => > {t`QR Code`} + {showOpenTorusButton && ( + } + onClick={openTorus} + > + {t`Open Torus`} + + )} } diff --git a/src/lib/ui/Login/ChainList.tsx b/src/lib/ui/Login/ChainList.tsx index 67023a9..f77b83b 100644 --- a/src/lib/ui/Login/ChainList.tsx +++ b/src/lib/ui/Login/ChainList.tsx @@ -129,7 +129,6 @@ export const ChainList = ({ transitionStyle, transitionRef }: SwapChildProps) => await walletSDK.connect() onClose() } catch (error: any) { - console.error(error) const handleErrorRes = handleError(error) if (handleErrorRes.isHandle) { if (handleErrorRes.title && handleErrorRes.message) { @@ -139,6 +138,7 @@ export const ChainList = ({ transitionStyle, transitionRef }: SwapChildProps) => }) } } else { + console.error(error) createTips({ title: t`Tips`, // eslint-disable-next-line @typescript-eslint/restrict-template-expressions diff --git a/src/lib/ui/Login/Connect.tsx b/src/lib/ui/Login/Connect.tsx index c99dddd..a13619b 100644 --- a/src/lib/ui/Login/Connect.tsx +++ b/src/lib/ui/Login/Connect.tsx @@ -122,7 +122,6 @@ export const Connect = ({ transitionStyle, transitionRef }: SwapChildProps) => { onClose() } } catch (error: any) { - console.error(error) const handleErrorRes = handleError(error) if (handleErrorRes.isHandle) { if (handleErrorRes.title && handleErrorRes.message) { @@ -132,6 +131,7 @@ export const Connect = ({ transitionStyle, transitionRef }: SwapChildProps) => { }) } } else { + console.error(error) createTips({ title: t`Tips`, // eslint-disable-next-line @typescript-eslint/restrict-template-expressions diff --git a/src/lib/ui/Login/WalletList.tsx b/src/lib/ui/Login/WalletList.tsx index 5d3d039..c439066 100644 --- a/src/lib/ui/Login/WalletList.tsx +++ b/src/lib/ui/Login/WalletList.tsx @@ -119,7 +119,6 @@ export const WalletList = ({ transitionRef, transitionStyle }: SwapChildProps) = onClose?.() setLoginCacheState({ walletConnectDisplayUri: '', walletName: '' }) } catch (error: any) { - console.error(error) const handleErrorRes = handleError(error) if (handleErrorRes.isHandle) { if (handleErrorRes.title && handleErrorRes.message) { @@ -129,6 +128,7 @@ export const WalletList = ({ transitionRef, transitionStyle }: SwapChildProps) = }) } } else { + console.error(error) createTips({ title: t`Tips`, // eslint-disable-next-line @typescript-eslint/restrict-template-expressions diff --git a/src/lib/ui/Wallet/wallet.stories.tsx b/src/lib/ui/Wallet/wallet.stories.tsx index 85fff9f..c4afa31 100644 --- a/src/lib/ui/Wallet/wallet.stories.tsx +++ b/src/lib/ui/Wallet/wallet.stories.tsx @@ -62,7 +62,7 @@ const wagmiConfig = createConfig({ }) const wallet = new Wallet({ - isTestNet: false, + isTestNet: true, wagmiConfig, }) @@ -125,6 +125,15 @@ const TemplateConnectWallet = () => { console.log(res) } + const onSignData712 = async () => { + const mmJson = + '{"types":{"EIP712Domain":[{"name":"chainId","type":"uint256"},{"name":"name","type":"string"},{"name":"verifyingContract","type":"address"},{"name":"version","type":"string"}],"Action":[{"name":"action","type":"string"},{"name":"params","type":"string"}],"Cell":[{"name":"capacity","type":"string"},{"name":"lock","type":"string"},{"name":"type","type":"string"},{"name":"data","type":"string"},{"name":"extraData","type":"string"}],"Transaction":[{"name":"DAS_MESSAGE","type":"string"},{"name":"inputsCapacity","type":"string"},{"name":"outputsCapacity","type":"string"},{"name":"fee","type":"string"},{"name":"action","type":"Action"},{"name":"inputs","type":"Cell[]"},{"name":"outputs","type":"Cell[]"},{"name":"digest","type":"bytes32"}]},"primaryType":"Transaction","domain":{"chainId":1,"name":"da.systems","verifyingContract":"0x0000000000000000000000000000000020210722","version":"1"},"message":{"DAS_MESSAGE":"TRANSFER FROM 0x54366bcd1e73baf55449377bd23123274803236e(906.74221046 CKB) TO ckt1qyqvsej8jggu4hmr45g4h8d9pfkpd0fayfksz44t9q(764.13228446 CKB), 0x54366bcd1e73baf55449377bd23123274803236e(142.609826 CKB)","inputsCapacity":"906.74221046 CKB","outputsCapacity":"906.74211046 CKB","fee":"0.0001 CKB","digest":"0x29cd28dbeb470adb17548563ceb4988953fec7b499e716c16381e5ae4b04021f","action":{"action":"transfer","params":"0x00"},"inputs":[],"outputs":[]}}' + const signature = await wallet.walletSDK.signData(JSON.parse(mmJson), { + isEIP712: true, + }) + console.log(signature) + } + const onSendTransaction = async () => { const signature = await wallet.sendTransaction({ to: '0x7df93d9F500fD5A9537FEE086322a988D4fDCC38', @@ -167,6 +176,8 @@ const TemplateConnectWallet = () => {

+ +