From bf756fddd2392f82814ee30f1ca7f55c1030d135 Mon Sep 17 00:00:00 2001 From: Thiendekaco Date: Wed, 13 Mar 2024 14:34:13 +0700 Subject: [PATCH] [Issue 22] SubConnect - Update content for SubConnect --- packages/core/src/chain.ts | 4 +-- packages/core/src/i18n/en.json | 20 ++++++------- packages/core/src/preflight-notifications.ts | 9 ++++++ .../core/src/views/connect/Agreement.svelte | 2 +- .../src/components/account/AccountList.tsx | 6 ++-- .../src/components/header/DisconnectModal.tsx | 5 ++-- .../sub_action/metadata/WalletMetadata.tsx | 8 ++--- packages/demo/src/pages/EvmWalletInfo.tsx | 6 ++-- packages/demo/src/pages/Welcome.tsx | 4 +-- packages/demo/src/web3-onboard.ts | 1 - .../hw-common/src/elements/TableHeader.svelte | 1 + .../hw-common/src/views/AccountSelect.svelte | 2 +- packages/ledgerPolkadot/src/index.ts | 30 ++++++++++++------- 13 files changed, 57 insertions(+), 41 deletions(-) diff --git a/packages/core/src/chain.ts b/packages/core/src/chain.ts index 8edf935be..fed35aa4a 100644 --- a/packages/core/src/chain.ts +++ b/packages/core/src/chain.ts @@ -108,7 +108,7 @@ async function setChain(options: { const { dismiss } = customNotification({ type: 'success', message: - `switch network succesfull`, + `Network switched successfully`, autoDismiss: 0 }) setTimeout(()=>{ @@ -119,7 +119,7 @@ async function setChain(options: { const { dismiss } = customNotification({ type: 'error', message: - `switch network failed ${(error as Error).message}`, + `Switch network failed`, autoDismiss: 0 }) diff --git a/packages/core/src/i18n/en.json b/packages/core/src/i18n/en.json index c5296da6e..ee4a055ab 100644 --- a/packages/core/src/i18n/en.json +++ b/packages/core/src/i18n/en.json @@ -5,15 +5,15 @@ "sidebar": { "heading": "", "subheading": "Connect your wallet", - "paragraph": "Connecting your wallet is like “logging in” to Web3. Select your wallet from the options to get started.", - "IDontHaveAWallet": "I don't have a wallet" + "paragraph": "Select your wallet from the provided options to get started", + "IDontHaveAWallet": "Don't see your wallet?" }, "recommendedWalletsPart1": "{app} only supports", "recommendedWalletsPart2": "on this platform. Please use or install one of the supported wallets to continue", "installWallet": "You do not have any wallets installed that {app} supports, please use a supported wallet", "agreement": { "agree": "I agree to the", - "terms": "Terms & Conditions", + "terms": "Terms of Use", "and": "and", "privacy": "Privacy Policy" }, @@ -65,8 +65,8 @@ }, "confirmDisconnectAll": { "heading": "Disconnect all Wallets", - "subHeading": "Do wan to disconnect all wallets?", - "description": "All connected wallets will be disconnected immediately. If you want to disconnect some accounts, please go to the corresponding \nwallet app to disable.", + "subHeading": "Disconnect all accounts?", + "description": "Once you press Disconnect, all connected accounts will be disconnected. If you only want to disconnect selected accounts, go to the wallet app.", "confirm": "Confirm", "cancel": "Cancel" }, @@ -92,7 +92,7 @@ }, "confirmConnectHDWallet": { "heading": "Connect your {wallet}", - "subHeading": "asdasdgasgduyasgdygaysgdyuagsydguyagd auysdgyausgdyagsydug", + "subHeading": "", "description": "All connected wallets will be disconnected immediately. If you want to disconnect some accounts, please go to the corresponding \nwallet app to disable.", "confirm": "Confirm" } @@ -116,13 +116,13 @@ }, "notify": { "transaction": { - "txRequest": "Your transaction is waiting for you to confirm", + "txRequest": "Processing…", "nsfFail": "You have insufficient funds for this transaction", "txUnderpriced": "The gas price for your transaction is too low, try a higher gas price", "txRepeat": "This could be a repeat transaction", "txAwaitingApproval": "You have a previous transaction waiting for you to confirm", - "txConfirmReminder": "Please confirm your transaction to continue", - "txSendFail": "You rejected the transaction", + "txConfirmReminder": "Confirm transaction on your wallet to continue", + "txSendFail": "Rejected by user", "txSent": "Your transaction has been sent to the network", "txStallPending": "Your transaction has stalled before it was sent, please try again", "txStuck": "Your transaction is stuck due to a nonce gap", @@ -131,7 +131,7 @@ "txSpeedUp": "Your transaction has been sped up", "txCancel": "Your transaction is being canceled", "txFailed": "Your transaction has failed", - "txConfirmed": "Your transaction has succeeded", + "txConfirmed": "Transaction successful", "txError": "Oops something went wrong, please try again", "txReplaceError": "There was an error replacing your transaction, please try again" }, diff --git a/packages/core/src/preflight-notifications.ts b/packages/core/src/preflight-notifications.ts index 9ef9b0be8..b2f9eb712 100644 --- a/packages/core/src/preflight-notifications.ts +++ b/packages/core/src/preflight-notifications.ts @@ -180,6 +180,8 @@ export function extractMessageFromError(error: { message: string stack: string }): { eventCode: string; errorMsg: string } { + + if (!error.stack || !error.message) { return { eventCode: 'txError', @@ -196,6 +198,13 @@ export function extractMessageFromError(error: { } } + if(message.includes('Rejected by user')){ + return { + eventCode: 'txSendFail', + errorMsg: 'Rejected by user' + } + } + if (message.includes('transaction underpriced')) { return { eventCode: 'txUnderpriced', diff --git a/packages/core/src/views/connect/Agreement.svelte b/packages/core/src/views/connect/Agreement.svelte index f5d1eeeef..b1c0e6ffa 100644 --- a/packages/core/src/views/connect/Agreement.svelte +++ b/packages/core/src/views/connect/Agreement.svelte @@ -73,7 +73,7 @@ {/if} {#if privacyUrl}{$_('connect.selectingWallet.agreement.privacy')}.{/if} + >{/if} diff --git a/packages/demo/src/components/account/AccountList.tsx b/packages/demo/src/components/account/AccountList.tsx index 7d4fe5a06..04fe9fdb3 100644 --- a/packages/demo/src/components/account/AccountList.tsx +++ b/packages/demo/src/components/account/AccountList.tsx @@ -54,7 +54,7 @@ function Component ({className, substrateProvider, evmProvider}: Props): React.R const { update, dismiss } = customNotification({ type: 'pending', message: - 'This is a custom DApp pending notification to use however you want', + 'Processing…', autoDismiss: 0 }); try { @@ -62,14 +62,14 @@ function Component ({className, substrateProvider, evmProvider}: Props): React.R : await substrateProvider?.signMessage(address, wallet.provider as SubstrateProvider, wallet.signer, wallet.chains[0].id); update({ eventCode: 'dbUpdateSuccess', - message: `success message is success`, + message: `Message signed successfully`, type: 'success', autoDismiss: 2000 }) }catch (e) { update({ eventCode: 'dbUpdateError', - message: `Failed, error ${(e as Error).message}`, + message: `${(e as Error).message}`, type: 'error', autoDismiss: 2000 }) diff --git a/packages/demo/src/components/header/DisconnectModal.tsx b/packages/demo/src/components/header/DisconnectModal.tsx index e9d4140d1..3448b4d4b 100644 --- a/packages/demo/src/components/header/DisconnectModal.tsx +++ b/packages/demo/src/components/header/DisconnectModal.tsx @@ -32,11 +32,10 @@ function Component ({className, onDisconnect}: Props) { >
- Do wan to disconnect all wallets? + Disconnect all accounts?
- All connected wallets will be disconnected immediately. If you want to disconnect some accounts, please go to the corresponding - wallet app to disable. + Once you press Disconnect, all connected accounts will be disconnected. If you only want to disconnect selected accounts, go to the wallet app.
); diff --git a/packages/demo/src/web3-onboard.ts b/packages/demo/src/web3-onboard.ts index 5f4139112..0bc02cbd6 100644 --- a/packages/demo/src/web3-onboard.ts +++ b/packages/demo/src/web3-onboard.ts @@ -220,7 +220,6 @@ export default init({ agreement: { version: '1.0.0', termsUrl: 'https://docs.subwallet.app/main/privacy-and-security/terms-of-use', - privacyUrl: 'https://docs.subwallet.app/main/privacy-and-security/security' } }, notify: { diff --git a/packages/hw-common/src/elements/TableHeader.svelte b/packages/hw-common/src/elements/TableHeader.svelte index 7fca04d6e..6004ee6f0 100644 --- a/packages/hw-common/src/elements/TableHeader.svelte +++ b/packages/hw-common/src/elements/TableHeader.svelte @@ -203,6 +203,7 @@ .table-controls { height: 3.5rem; + gap: 8px; justify-content: flex-end; } diff --git a/packages/hw-common/src/views/AccountSelect.svelte b/packages/hw-common/src/views/AccountSelect.svelte index 2a81ac503..1adc3a789 100644 --- a/packages/hw-common/src/views/AccountSelect.svelte +++ b/packages/hw-common/src/views/AccountSelect.svelte @@ -33,7 +33,7 @@ let showEmptyAddresses = true let loadingAccounts = false let errorFromScan = '' - let accountIdxStart = 0 + let accountIdxStart = -10 $: accountSelectedLength = accountSelected.length let scanAccountOptions: ScanAccountsOptions = { diff --git a/packages/ledgerPolkadot/src/index.ts b/packages/ledgerPolkadot/src/index.ts index 00bdef8e3..770c8021e 100644 --- a/packages/ledgerPolkadot/src/index.ts +++ b/packages/ledgerPolkadot/src/index.ts @@ -7,15 +7,14 @@ import { WalletInit, WalletInterfaceSubstrate } from '@subwallet-connect/common' -import { Ledger } from "@polkadot/hw-ledger"; -import type { BigNumber } from 'ethers' - -import type {Account, Asset, ScanAccountsOptions} from '@subwallet-connect/hw-common'; -import { supportedApps } from '@subwallet-connect/hw-common/src/utils'; -import { Subject} from 'rxjs'; -import { RequestArguments } from '@walletconnect/ethereum-provider/dist/types/types.js'; -import { isArray } from "@shapeshiftoss/hdwallet-core"; +import {Ledger} from "@polkadot/hw-ledger"; +import type {BigNumber} from 'ethers' +import type {Account, ScanAccountsOptions} from '@subwallet-connect/hw-common'; +import {supportedApps} from '@subwallet-connect/hw-common/src/utils'; +import {Subject} from 'rxjs'; +import {RequestArguments} from '@walletconnect/ethereum-provider/dist/types/types.js'; +import {isArray} from "@shapeshiftoss/hdwallet-core"; const DEFAULT_PATH_POLKADOT = "m/44'/354'/0'/0" @@ -333,11 +332,16 @@ function ledgerPolkadot({ return await this.signMessage(params[0] as string, params[1] as string); }catch (e) { + if((e as Error).message.includes('Transaction rejected')){ + throw new ProviderRpcError({ + code: ProviderRpcErrorCode.ACCOUNT_ACCESS_REJECTED, + message: 'Rejected by user' + }) + } throw new ProviderRpcError({ code: ProviderRpcErrorCode.UNSUPPORTED_METHOD, message: `The Provider does not support the requested method: ${method}` }) - return ; } } @@ -387,8 +391,12 @@ function ledgerPolkadot({ return await this.ledger.sign(transactionPayload as any, accountIdx, 0); } }catch (e) { - console.log(e); - return ; + console.log((e as Error).message) + + throw new ProviderRpcError({ + code: ProviderRpcErrorCode.ACCOUNT_ACCESS_REJECTED, + message: 'Rejected by user' + }) } }