diff --git a/packages/core/src/views/connect/Index.svelte b/packages/core/src/views/connect/Index.svelte index c99626d6b..e46d148ba 100644 --- a/packages/core/src/views/connect/Index.svelte +++ b/packages/core/src/views/connect/Index.svelte @@ -186,7 +186,7 @@ connectingErrorMessage = '' scrollToTop() - setTimeout(() => setStep('connectingWallet'), 1) + setStep('connectingWallet') } catch (error) { const { message } = error as { message: string } connectingErrorMessage = message @@ -496,7 +496,7 @@ // return; // } // } - setTimeout(() => connectWallet$.next({ inProgress: false }), 100) + connectWallet$.next({ inProgress: false }) } @@ -682,6 +682,12 @@ display: none; } } + + @media all and ( max-width: 768px) { + .content { + padding: 2rem 1rem 2rem 1rem; + } + } diff --git a/packages/core/src/views/connect/WalletButton.svelte b/packages/core/src/views/connect/WalletButton.svelte index a0285bca5..fe9229ff0 100644 --- a/packages/core/src/views/connect/WalletButton.svelte +++ b/packages/core/src/views/connect/WalletButton.svelte @@ -180,6 +180,12 @@ /* flex-direction: column;*/ /*}*/ } + @media screen and (max-width: 768px) { + button.wallet-button-styling { + min-width: 80px; + } + } + diff --git a/packages/demo/package.json b/packages/demo/package.json index 7f852b6a2..ca8a0405c 100644 --- a/packages/demo/package.json +++ b/packages/demo/package.json @@ -77,7 +77,8 @@ "usehooks-ts": "^2.15.1", "bignumber.js": "^9.1.2", "@types/bn.js": "^5.1.5", - "bn.js": "^4.11.9" + "bn.js": "^4.11.9", + "eventemitter3": "^4.0.7" }, "devDependencies": { "@types/jest": "^29.5.8", diff --git a/packages/demo/src/components/account/AccountBriefInfo.tsx b/packages/demo/src/components/account/AccountBriefInfo.tsx index 9e9f96303..25ad4be26 100644 --- a/packages/demo/src/components/account/AccountBriefInfo.tsx +++ b/packages/demo/src/components/account/AccountBriefInfo.tsx @@ -1,6 +1,6 @@ import { Typography } from '@subwallet/react-ui'; import SwAvatar from '@subwallet/react-ui/es/sw-avatar'; -import React, { useMemo } from 'react'; +import React, {useContext, useMemo} from 'react'; import styled from 'styled-components'; import type { ThemeProps } from '../../types'; @@ -49,6 +49,7 @@ const AccountBriefInfo = styled(Component)(({ theme: { token } }: Props) }, '.account-name': { + whiteSpace: 'nowrap', fontWeight: token.headingFontWeight, fontSize: token.fontSizeHeading5, lineHeight: token.lineHeightHeading5, @@ -56,10 +57,11 @@ const AccountBriefInfo = styled(Component)(({ theme: { token } }: Props) }, '.account-address': { + whiteSpace: 'nowrap', fontSize: token.fontSizeHeading6, lineHeight: token.lineHeightHeading6, color: token.colorTextDescription - } + }, }; }); diff --git a/packages/demo/src/components/icon/InfoIcon.tsx b/packages/demo/src/components/icon/InfoIcon.tsx index 1056523a8..1662236ef 100644 --- a/packages/demo/src/components/icon/InfoIcon.tsx +++ b/packages/demo/src/components/icon/InfoIcon.tsx @@ -11,7 +11,6 @@ const InfoIcon: React.FC = (props: Props) => { return ( ); diff --git a/packages/demo/src/components/layout/Layout.tsx b/packages/demo/src/components/layout/Layout.tsx index 111b0fe06..7b70516a6 100644 --- a/packages/demo/src/components/layout/Layout.tsx +++ b/packages/demo/src/components/layout/Layout.tsx @@ -111,11 +111,22 @@ const Layout = styled(Component)( ({ theme: { extendToken, token} }: Them }, + '@media(max-width : 1660px and min-width: 768px)' : { + '.__main-layout': { + padding: '0 16px' + } + + }, + '&.-isMobile':{ '.__main-content.-isConnected': { padding: `0 ${token.padding}px`, + }, - } + '.-upper': { + gap: 81, + marginTop: 0 + }, } } }) diff --git a/packages/demo/src/components/layout/WalletHeader.tsx b/packages/demo/src/components/layout/WalletHeader.tsx index 2f68af74e..97eb3b418 100644 --- a/packages/demo/src/components/layout/WalletHeader.tsx +++ b/packages/demo/src/components/layout/WalletHeader.tsx @@ -109,7 +109,7 @@ function Component ({ visible, className }: Props): React.ReactElement { size='xs' type='ghost' > - Help + {isWebUI && 'Help'} > } @@ -158,8 +158,8 @@ const WalletHeader = styled(Component)(({theme : {token}}) => { '.__header-title': { fontSize: 30, - color: token.colorTextLight1, - marginLeft: 85 + marginLeft: 30, + color: token.colorTextLight1 }, '.__header-action': { @@ -182,10 +182,6 @@ const WalletHeader = styled(Component)(({theme : {token}}) => { paddingRight: 3 } }, - - '.__header-title': { - marginLeft: 0 - } }, '&.-isMobile': { @@ -198,7 +194,19 @@ const WalletHeader = styled(Component)(({theme : {token}}) => { flexDirection: 'column', alignItems: 'flex-start', gap: token.paddingSM + }, + + '.__header-action': { + width: '100%' + }, + + '.__header-title': { + marginLeft: 0 } + }, + + '.__header-logo': { + padding: `0 ${token.padding}px` } }) }) diff --git a/packages/demo/src/components/logo/LogoWithSubIcon.tsx b/packages/demo/src/components/logo/LogoWithSubIcon.tsx index 14fb2ed56..8810d3666 100644 --- a/packages/demo/src/components/logo/LogoWithSubIcon.tsx +++ b/packages/demo/src/components/logo/LogoWithSubIcon.tsx @@ -25,13 +25,13 @@ const Component = ({className, icon, type} : Props) => { } -const LogoWithSubIcon = styled(Component)(({theme}) => { +const LogoWithSubIcon = styled(Component)(({theme: {token}}) => { return({ '&.__wallet-logo': { position: 'relative', + padding: `0 ${token.padding}`, width: 80, height: 80, - }, '.__wallet-logo-main': { diff --git a/packages/demo/src/components/modal/selectors/AccountSelector.tsx b/packages/demo/src/components/modal/selectors/AccountSelector.tsx index f11e823aa..b63f34959 100644 --- a/packages/demo/src/components/modal/selectors/AccountSelector.tsx +++ b/packages/demo/src/components/modal/selectors/AccountSelector.tsx @@ -11,6 +11,8 @@ import { GeneralEmptyList } from '../../empty'; import { BaseSelectModal } from '../BaseSelectModal'; import {useConnectWallet, useSetChain, useWallets} from "@subwallet-connect/react"; import type { Account, WalletState } from '@subwallet-connect/core/dist/types'; +import CN from "classnames"; +import {ScreenContext} from "../../../context/ScreenContext"; @@ -30,6 +32,7 @@ interface WalletMapByAccountInterface { function Component ({ className }: Props): React.ReactElement { const wallets = useWallets(); + const { isWebUI } = useContext(ScreenContext); const setPrimaryWallet = useConnectWallet()[5]; const [ accountMap, setAccountMap ] = useState([]); const [ walletMapByAccount, setWalletMapByAccount ] = useState({}); @@ -91,12 +94,11 @@ function Component ({ className }: Props): React.ReactElement { return ( (({ theme }) => { flexDirection: 'row', alignItems: 'center', gap: 8 - }, + } + }); }); diff --git a/packages/demo/src/components/modal/selectors/NetworkSelector.tsx b/packages/demo/src/components/modal/selectors/NetworkSelector.tsx index ef4e98221..a7f1022ae 100644 --- a/packages/demo/src/components/modal/selectors/NetworkSelector.tsx +++ b/packages/demo/src/components/modal/selectors/NetworkSelector.tsx @@ -26,9 +26,7 @@ function Component (props: Props): React.ReactElement { const isLedgerWallet = useMemo(()=> wallet?.label === 'Ledger' , []) const renderChainSelected = useCallback((item: NetworkItemType) => { return ( - <> - { isWebUI && {item.name} } - > + {item.name} ); }, []); diff --git a/packages/demo/src/components/transaction/TransactionModal.tsx b/packages/demo/src/components/transaction/TransactionModal.tsx index 40297cad7..5d4dc873a 100644 --- a/packages/demo/src/components/transaction/TransactionModal.tsx +++ b/packages/demo/src/components/transaction/TransactionModal.tsx @@ -238,7 +238,8 @@ function Component ({ className, senderAccount, evmProvider, substrateProvider } const amount = getOutputValuesFromString(value, chainInfo.decimal || 18); if(wallet?.type === "evm"){ - blockHash = await evmProvider?.sendTransaction(senderAccount.address, to, amount ) || '' + await evmProvider?.sendTransaction(senderAccount.address, to, amount ) + evmProvider?.transactionState.on('transaction-success', (blockHash: string) => blockHash !== '' && onCloseModal()) }else{ const getSigner = async ()=>{ @@ -252,7 +253,7 @@ function Component ({ className, senderAccount, evmProvider, substrateProvider } if(wallet.label === 'Polkadot Vault'){ wallet.signer = await substrateProvider?.getQrSigner(senderAccount.address, provider, chainId); } - return await substrateProvider?.sendTransaction( + return substrateProvider?.sendTransaction( senderAccount.address, to, wallet.signer, @@ -260,15 +261,21 @@ function Component ({ className, senderAccount, evmProvider, substrateProvider } ); } - await substrateProvider?.isReady() - blockHash = await getSigner() || ''; - + await substrateProvider?.isReady(); + await getSigner(); + substrateProvider?.transactionState.on('transaction-success', (blockHash: string) => blockHash !== '' && onCloseModal()) } setLoading(false) - blockHash !== '' && onCloseModal(); }catch (e) {} }, [wallet, chains, senderAccount, evmProvider, substrateProvider]); + useEffect(() => { + if(!(wallet && wallet.accounts && wallet.accounts.length > 0)){ + substrateProvider?.transactionState.removeAllListeners('transaction-success') + evmProvider?.transactionState.removeAllListeners('transaction-success') + } + }, [wallet, substrateProvider, evmProvider]); + const isValidInput = useCallback((input: string) => { return !(isNaN(parseFloat(input)) || !input.match(/^-?\d*(\.\d+)?$/)); }, []); diff --git a/packages/demo/src/pages/EvmWalletInfo.tsx b/packages/demo/src/pages/EvmWalletInfo.tsx index d1cb7d537..f1d17fc66 100644 --- a/packages/demo/src/pages/EvmWalletInfo.tsx +++ b/packages/demo/src/pages/EvmWalletInfo.tsx @@ -82,21 +82,25 @@ function Component ({className}: Props): React.ReactElement { {wallet?.accounts && wallet.accounts.length > 0 && } - - Permission - } - onClick={requestPermission} - block={true} - >Request Permissions - } - /> - + + {wallet?.label !== 'WalletConnect' && + <> + Permission + } + onClick={requestPermission} + block={true} + >Request Permissions + } + /> + > + } + diff --git a/packages/demo/src/pages/Welcome.tsx b/packages/demo/src/pages/Welcome.tsx index 648db409f..67f044568 100644 --- a/packages/demo/src/pages/Welcome.tsx +++ b/packages/demo/src/pages/Welcome.tsx @@ -121,7 +121,7 @@ const Welcome = styled(Component)(({theme: { token }}: ThemeProps) => { }, '.__welcome-content__sub-text.-isMobile': { - padding: `0 ${token.padding}` + padding: `0 ${token.padding}px` }, '.__welcome-content__btn': { diff --git a/packages/demo/src/utils/api/evmApi.ts b/packages/demo/src/utils/api/evmApi.ts index 441f08697..c0fa25bcf 100644 --- a/packages/demo/src/utils/api/evmApi.ts +++ b/packages/demo/src/utils/api/evmApi.ts @@ -6,14 +6,20 @@ import { RequestArguments } from "../../types"; import { METHOD_MAP, SIGN_METHODS } from "../methods"; import BigNumber from 'bignumber.js' import type { TxDetails } from "@subwallet-connect/core/src/types"; +import EventEmitter from 'eventemitter3'; export class evmApi { private readonly provider ?: Web3Provider; + private _transactionState = new EventEmitter(); constructor (provider: EIP1193Provider){ this.provider = new ethers.providers.Web3Provider(provider, 'any') } + get transactionState(): EventEmitter { + return this._transactionState; + } + public async getMaxTransfer (amount: string, senderAddress: string, recipientAddress: string) { if(!this.provider) return '0'; @@ -59,6 +65,7 @@ export class evmApi { } const sendTransaction = async (fn: (hash: string) => void) => { const tx = await signer.sendTransaction(txDetails); + this._transactionState.emit('transaction-success', tx.hash); fn(tx.hash); return tx.hash; } diff --git a/packages/demo/src/utils/api/substrateApi.ts b/packages/demo/src/utils/api/substrateApi.ts index e54f928d2..66b495ab3 100644 --- a/packages/demo/src/utils/api/substrateApi.ts +++ b/packages/demo/src/utils/api/substrateApi.ts @@ -8,8 +8,11 @@ import { LedgerSignature } from "@polkadot/hw-ledger/types"; import { blake2AsU8a } from '@polkadot/util-crypto'; import { BN_HUNDRED, BN_ZERO, isFunction, nextTick } from '@polkadot/util'; import BN from 'bn.js'; +import EventEmitter from 'eventemitter3'; +import status from "@subwallet-connect/injected-wallets/dist/icons/status"; export class substrateApi { private readonly api ?: ApiPromise; + private _transactionState = new EventEmitter(); constructor (chainEndpoint: string){ @@ -18,6 +21,10 @@ export class substrateApi { }); } + get transactionState(): EventEmitter { + return this._transactionState; + } + public async isReady(){ return this.api?.isReady } @@ -60,6 +67,7 @@ export class substrateApi { await transferExtrinsic.signAndSend(senderAddress, { signer }, ({ status, txHash }) => { if (status.isInBlock) { fn(txHash.toString()); + this._transactionState.emit('transaction-success', txHash.toString()); console.log(`Completed at block hash #${status.asInBlock.toString()}`); } else { console.log(`Current status: ${status.type}`); diff --git a/packages/injected/src/icons/talisman.ts b/packages/injected/src/icons/talisman.ts index 3670e2a0b..465a8f794 100644 --- a/packages/injected/src/icons/talisman.ts +++ b/packages/injected/src/icons/talisman.ts @@ -1,5 +1,5 @@ export default ` - + diff --git a/packages/ledgerPolkadot/src/icon.ts b/packages/ledgerPolkadot/src/icon.ts index 3b68e7002..e11a5e071 100644 --- a/packages/ledgerPolkadot/src/icon.ts +++ b/packages/ledgerPolkadot/src/icon.ts @@ -1,5 +1,5 @@ export default ` - + ` diff --git a/packages/polkadotVault/src/icon/closeCircle.ts b/packages/polkadotVault/src/icon/closeCircle.ts new file mode 100644 index 000000000..66ec82f65 --- /dev/null +++ b/packages/polkadotVault/src/icon/closeCircle.ts @@ -0,0 +1,6 @@ +export default ` + + + + +` diff --git a/packages/polkadotVault/src/icon/index.ts b/packages/polkadotVault/src/icon/index.ts index cde3dd038..2a70c7acf 100644 --- a/packages/polkadotVault/src/icon/index.ts +++ b/packages/polkadotVault/src/icon/index.ts @@ -4,3 +4,4 @@ export { default as logoWallet } from './logoWallet.js'; export { default as imageSquareIcon } from './imageSquare.js'; export { default as qrCodeIcon } from './qrCode.js'; export { default as errorIcon } from './error.js'; +export { default as closeCircleIcon } from './closeCircle.js' diff --git a/packages/polkadotVault/src/views/ScanQRCode.svelte b/packages/polkadotVault/src/views/ScanQRCode.svelte index 990351d3f..5953a5c1f 100644 --- a/packages/polkadotVault/src/views/ScanQRCode.svelte +++ b/packages/polkadotVault/src/views/ScanQRCode.svelte @@ -1,7 +1,7 @@