|
|
@ -1,12 +1,28 @@ |
|
|
|
// eslint-disable-next-line no-use-before-define
|
|
|
|
// eslint-disable-next-line no-use-before-define
|
|
|
|
import { CustomTooltip } from '@remix-ui/helper' |
|
|
|
import { CustomTooltip } from '@remix-ui/helper' |
|
|
|
import React from 'react' |
|
|
|
import React, {useState, useEffect, useRef} from 'react' |
|
|
|
import { FormattedMessage, useIntl } from 'react-intl' |
|
|
|
import { FormattedMessage, useIntl } from 'react-intl' |
|
|
|
import { InstanceContainerProps } from '../types' |
|
|
|
import { InstanceContainerProps } from '../types' |
|
|
|
import { UniversalDappUI } from './universalDappUI' |
|
|
|
import { UniversalDappUI } from './universalDappUI' |
|
|
|
|
|
|
|
|
|
|
|
export function InstanceContainerUI(props: InstanceContainerProps) { |
|
|
|
export function InstanceContainerUI(props: InstanceContainerProps) { |
|
|
|
const { instanceList } = props.instances |
|
|
|
const { instanceList } = props.instances |
|
|
|
|
|
|
|
let savedContractForCurrentEnv = useRef([]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
|
|
const fetchSavedContracts = async () => { |
|
|
|
|
|
|
|
let allSavedContracts = JSON.parse(localStorage.getItem('savedContracts')) |
|
|
|
|
|
|
|
const { network } = await props.plugin.call('blockchain', 'getCurrentNetworkStatus') |
|
|
|
|
|
|
|
network.id = network.id.trim() // For VM, id is ' - '
|
|
|
|
|
|
|
|
const env = await props.plugin.call('blockchain', 'getProvider') |
|
|
|
|
|
|
|
if (allSavedContracts && allSavedContracts[env] && allSavedContracts[env][network.id]) { |
|
|
|
|
|
|
|
savedContractForCurrentEnv.current = allSavedContracts[env][network.id] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fetchSavedContracts() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}, []) |
|
|
|
|
|
|
|
|
|
|
|
const clearInstance = () => { |
|
|
|
const clearInstance = () => { |
|
|
|
props.clearInstances() |
|
|
|
props.clearInstances() |
|
|
@ -23,6 +39,33 @@ export function InstanceContainerUI(props: InstanceContainerProps) { |
|
|
|
</label> |
|
|
|
</label> |
|
|
|
</CustomTooltip> |
|
|
|
</CustomTooltip> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
{savedContractForCurrentEnv.current.length > 0 ? ( |
|
|
|
|
|
|
|
<div> |
|
|
|
|
|
|
|
{' '} |
|
|
|
|
|
|
|
{savedContractForCurrentEnv.current.map((instance, index) => { |
|
|
|
|
|
|
|
return ( |
|
|
|
|
|
|
|
<UniversalDappUI |
|
|
|
|
|
|
|
key={index} |
|
|
|
|
|
|
|
instance={instance} |
|
|
|
|
|
|
|
context={props.getContext()} |
|
|
|
|
|
|
|
removeInstance={props.removeInstance} |
|
|
|
|
|
|
|
index={index} |
|
|
|
|
|
|
|
gasEstimationPrompt={props.gasEstimationPrompt} |
|
|
|
|
|
|
|
passphrasePrompt={props.passphrasePrompt} |
|
|
|
|
|
|
|
mainnetPrompt={props.mainnetPrompt} |
|
|
|
|
|
|
|
runTransactions={props.runTransactions} |
|
|
|
|
|
|
|
sendValue={props.sendValue} |
|
|
|
|
|
|
|
getFuncABIInputs={props.getFuncABIInputs} |
|
|
|
|
|
|
|
plugin={props.plugin} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
})} |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
) : ( |
|
|
|
|
|
|
|
<span className="mx-2 mt-3 alert alert-warning" data-id="NoSavedInstanceText" role="alert"> |
|
|
|
|
|
|
|
<FormattedMessage id="udapp.NoSavedInstanceText" /> |
|
|
|
|
|
|
|
</span> |
|
|
|
|
|
|
|
)} |
|
|
|
|
|
|
|
|
|
|
|
<div className="d-flex justify-content-between align-items-center pl-2 mb-2"> |
|
|
|
<div className="d-flex justify-content-between align-items-center pl-2 mb-2"> |
|
|
|
<CustomTooltip placement="top-start" tooltipClasses="text-nowrap" tooltipId="deployAndRunClearInstancesTooltip" tooltipText={<FormattedMessage id="udapp.tooltipText6" />}> |
|
|
|
<CustomTooltip placement="top-start" tooltipClasses="text-nowrap" tooltipId="deployAndRunClearInstancesTooltip" tooltipText={<FormattedMessage id="udapp.tooltipText6" />}> |
|
|
|