Skip to content

Commit

Permalink
[Issue 22] SubConnect - Update content for SubConnect
Browse files Browse the repository at this point in the history
  • Loading branch information
Thiendekaco committed Mar 13, 2024
1 parent 44ca66e commit bf756fd
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 41 deletions.
4 changes: 2 additions & 2 deletions packages/core/src/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ async function setChain(options: {
const { dismiss } = customNotification({
type: 'success',
message:
`switch network succesfull`,
`Network switched successfully`,
autoDismiss: 0
})
setTimeout(()=>{
Expand All @@ -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
})

Expand Down
20 changes: 10 additions & 10 deletions packages/core/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down Expand Up @@ -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"
},
Expand All @@ -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"
}
Expand All @@ -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",
Expand All @@ -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"
},
Expand Down
9 changes: 9 additions & 0 deletions packages/core/src/preflight-notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ export function extractMessageFromError(error: {
message: string
stack: string
}): { eventCode: string; errorMsg: string } {


if (!error.stack || !error.message) {
return {
eventCode: 'txError',
Expand All @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/views/connect/Agreement.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
{/if}
{#if privacyUrl}<a href={privacyUrl} target="_blank"
>{$_('connect.selectingWallet.agreement.privacy')}</a
>.{/if}
>{/if}
</span>
</label>
</div>
Expand Down
6 changes: 3 additions & 3 deletions packages/demo/src/components/account/AccountList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,22 @@ 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 {
wallet.type === 'evm' ? await evmProvider?.signMessage(address)
: 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
})
Expand Down
5 changes: 2 additions & 3 deletions packages/demo/src/components/header/DisconnectModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@ function Component ({className, onDisconnect}: Props) {
>
<div className={'__disconnect-modal-body'}>
<div className={'__disconnect-modal-sub-title'}>
Do wan to disconnect all wallets?
Disconnect all accounts?
</div>
<div className={'__disconnect-modal-content'}>
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.
</div>
<div className={'__disconnect-action-group'}>
<Button className={'__disconnect-action-reject'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,24 +62,24 @@ function Component({className}: Props): React.ReactElement {
const { update, dismiss } = customNotification({
type: 'pending',
message:
`Adding Metadata`,
`Processing…`,
autoDismiss: 0
});
(metadata as InjectedMetadata).provide(newMetaDef)
.then((rs) => {
update({
eventCode: 'dbUpdateSuccess',
message: `Add Metadata Successfully!`,
message: `Metadata updated successfully`,
type: 'success',
autoDismiss: 0
})
loadMetadata();
})
.catch((error) => {
console.error(error);

update({
eventCode: 'dbUpdateSuccess',
message: `Add Metadata Failed or Cancelled!`,
message: `${(error as Error).message.includes('Rejected') ? 'Rejected by user' : 'Add Metadata Failed or Cancelled!' }`,
type: 'error',
autoDismiss: 0
})
Expand Down
6 changes: 3 additions & 3 deletions packages/demo/src/pages/EvmWalletInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,22 @@ function Component ({className}: Props): React.ReactElement {
const { update, dismiss } = customNotification({
type: 'pending',
message:
`Request permission`,
`Processing…`,
autoDismiss: 0
});
try{
await evmProvider?.requestPermissions();

update({
eventCode: 'dbUpdateSuccess',
message: `Request permission success`,
message: `Permission requested successfully`,
type: 'success',
autoDismiss: 1500
})
}catch (e) {
update({
eventCode: 'dbUpdateError',
message: `${(e as Error).message}`,
message: `${(e as Error).message.includes('User Rejected Request')? 'Rejected by user': (e as Error).message}`,
type: 'error',
autoDismiss: 1500
})
Expand Down
4 changes: 2 additions & 2 deletions packages/demo/src/pages/Welcome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function Component ({ className }: Props): React.ReactElement {
<div className='__welcome-content__text'>Connect your wallet</div>
<div className={CN('__welcome-content__sub-text', {
'-isMobile': !isWebUI
})}>Connecting your wallet is like “logging in” to Web3. Select your wallet from the options to get started.</div>
})}>Select your wallet from the provided options to get started.</div>
<Button
className='__welcome-content__btn'
shape={'circle'}
Expand All @@ -78,7 +78,7 @@ function Component ({ className }: Props): React.ReactElement {
iconColor={token.colorPrimary}
customSize={'14px'}
/>
I don’t have a wallet
Don't see your wallet?
</a>
</div>
</div>);
Expand Down
1 change: 0 additions & 1 deletion packages/demo/src/web3-onboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
1 change: 1 addition & 0 deletions packages/hw-common/src/elements/TableHeader.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@
.table-controls {
height: 3.5rem;
gap: 8px;
justify-content: flex-end;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/hw-common/src/views/AccountSelect.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
let showEmptyAddresses = true
let loadingAccounts = false
let errorFromScan = ''
let accountIdxStart = 0
let accountIdxStart = -10
$: accountSelectedLength = accountSelected.length
let scanAccountOptions: ScanAccountsOptions = {
Expand Down
30 changes: 19 additions & 11 deletions packages/ledgerPolkadot/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 ;
}
}

Expand Down Expand Up @@ -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'
})
}
}

Expand Down

0 comments on commit bf756fd

Please sign in to comment.