diff --git a/src/components/account/AssetOverview.tsx b/src/components/account/AssetOverview.tsx index 7021dd8b..23e53419 100644 --- a/src/components/account/AssetOverview.tsx +++ b/src/components/account/AssetOverview.tsx @@ -57,7 +57,7 @@ export function AssetOverview({ asset, refresh }: AssetOverviewProps) { }} onFail={() => setIsVisible(false)} onCancel={() => setIsVisible(false)} - initialValues={{ from: account, to: accounts[0].address, amount: 0 }} + initialValues={{ from: account, to: accounts[0]?.address, amount: 0 }} extrinsic={(values) => { const { to, amount } = values; const moduleName = isRing(asset.token?.symbol) ? 'balances' : 'kton'; diff --git a/src/components/toolbox/withdraw.tsx b/src/components/toolbox/withdraw.tsx index 6c267ef8..73021d52 100644 --- a/src/components/toolbox/withdraw.tsx +++ b/src/components/toolbox/withdraw.tsx @@ -79,7 +79,7 @@ export function Withdraw() { if (status === 'success' && accountHex !== EMPTY_ADDRESS) { getSendTransactionObs({ - from: accounts[0].address, + from: accounts[0]?.address, to: DVM_WITHDRAW_ADDRESS, data: accountHex, value: web3.utils.toWei(amount, 'ether'), diff --git a/src/utils/network/connection.tsx b/src/utils/network/connection.tsx index 8a6fd3b9..cc47ae21 100644 --- a/src/utils/network/connection.tsx +++ b/src/utils/network/connection.tsx @@ -45,8 +45,8 @@ export const LOCAL = 'local'; export const getPolkadotConnection: (network: ChainConfig) => Observable = (network) => from(web3Enable('polkadot-js/apps')).pipe( - concatMap((extensions) => - combineLatest([from(web3Accounts()), accountsObs.subject.asObservable()], (injected, data) => { + concatMap((extensions) => { + const result = combineLatest([from(web3Accounts()), accountsObs.subject.asObservable()], (injected, data) => { const keys = Object.keys(data); const injectedAddress = injected.map((item) => item.address); const source = keys.filter((key) => !injectedAddress.includes(key)); @@ -71,8 +71,15 @@ export const getPolkadotConnection: (network: ChainConfig) => Observable) ) - ) - ), + ); + + if (!extensions.length) { + showWarning('Polkadot', 'https://polkadot.js.org/extension/'); + return EMPTY; + } + + return result; + }), switchMap((envelop: Exclude) => { const subject = new BehaviorSubject(envelop); const url = network.provider.rpc;