allow saving only for injected web3

pull/5370/head
aniket-engg 9 months ago committed by Aniket
parent abb1283938
commit c6457b0ca7
  1. 12
      libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx

@ -1,5 +1,5 @@
// eslint-disable-next-line no-use-before-define // eslint-disable-next-line no-use-before-define
import React, {useEffect, useState} from 'react' import React, {useEffect, useState, useRef} from 'react'
import {FormattedMessage, useIntl} from 'react-intl' import {FormattedMessage, useIntl} from 'react-intl'
import {UdappProps} from '../types' import {UdappProps} from '../types'
import {FuncABI} from '@remix-project/core-plugin' import {FuncABI} from '@remix-project/core-plugin'
@ -23,6 +23,7 @@ export function UniversalDappUI(props: UdappProps) {
const [calldataValue, setCalldataValue] = useState<string>('') const [calldataValue, setCalldataValue] = useState<string>('')
const [evmBC, setEvmBC] = useState(null) const [evmBC, setEvmBC] = useState(null)
const [instanceBalance, setInstanceBalance] = useState(0) const [instanceBalance, setInstanceBalance] = useState(0)
const env = useRef()
const getVersion = () => window.location.href.split('=')[5].split('+')[0].split('-')[1] const getVersion = () => window.location.href.split('=')[5].split('+')[0].split('-')[1]
@ -57,6 +58,13 @@ export function UniversalDappUI(props: UdappProps) {
} }
}, [props.instance.balance]) }, [props.instance.balance])
useEffect(() => {
const getEnv = async () => {
env.current = await props.plugin.call('blockchain', 'getProvider')
}
getEnv()
}, [])
const sendData = () => { const sendData = () => {
setLlIError('') setLlIError('')
const fallback = txHelper.getFallbackInterface(contractABI) const fallback = txHelper.getFallbackInterface(contractABI)
@ -267,7 +275,7 @@ export function UniversalDappUI(props: UdappProps) {
<div className="btn" style={{padding: '0.15rem'}}> <div className="btn" style={{padding: '0.15rem'}}>
<CopyToClipboard tip={intl.formatMessage({id: 'udapp.copy'})} content={address} direction={'top'} /> <CopyToClipboard tip={intl.formatMessage({id: 'udapp.copy'})} content={address} direction={'top'} />
</div> </div>
{ !props.isSavedContract ? ( <div className="btn" style={{padding: '0.15rem', marginLeft: '-0.5rem'}}> { !props.isSavedContract && env.current === 'injected' ? ( <div className="btn" style={{padding: '0.15rem', marginLeft: '-0.5rem'}}>
<CustomTooltip placement="top" tooltipClasses="text-nowrap" tooltipId="udapp_udappSaveTooltip" tooltipText={<FormattedMessage id="udapp.tooltipText14" />}> <CustomTooltip placement="top" tooltipClasses="text-nowrap" tooltipId="udapp_udappSaveTooltip" tooltipText={<FormattedMessage id="udapp.tooltipText14" />}>
<i className="far fa-save p-2" aria-hidden="true" data-id="universalDappUiUdappSave" onClick={saveContract}></i> <i className="far fa-save p-2" aria-hidden="true" data-id="universalDappUiUdappSave" onClick={saveContract}></i>
</CustomTooltip> </CustomTooltip>

Loading…
Cancel
Save