make compiler version part of state. update props

pull/5370/head
Joseph Izang 6 months ago
parent 66b8a00a21
commit a63d995cf5
  1. 3
      libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx
  2. 17
      libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx
  3. 4
      libs/remix-ui/run-tab/src/lib/components/instanceContainerUI.tsx
  4. 76
      libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx
  5. 21
      libs/remix-ui/run-tab/src/lib/run-tab.tsx
  6. 14
      libs/remix-ui/run-tab/src/lib/types/index.ts

@ -483,6 +483,9 @@ export function ContractDropdownUI(props: ContractDropdownProps) {
isValidProxyUpgrade={isValidProxyUpgrade}
modal={props.modal}
disabled={props.selectedAccount === ''}
solcVersion={props.solCompilerVersion}
setSolcVersion={props.setCompilerVersion}
getVersion={props.getCompilerVersion}
/>
<div className="d-flex py-1 align-items-center custom-control custom-checkbox">
<input

@ -32,6 +32,22 @@ export function ContractGUI(props: ContractGUIProps) {
const initializeFields = useRef<Array<HTMLInputElement | null>>([])
const basicInputRef = useRef<HTMLInputElement>()
const intl = useIntl()
// const [solcVersion, setSolcVersion] = useState({ version: '', canReceive: true })
// const getVersion = () => {
// let version = ''
// try {
// version = window.location.href.split('=')[5].split('+')[0].split('-')[1].slice(1)
// if (parseFloat(version) < 0.6) {
// setSolcVersion({ version: version, canReceive: false })
// }
// setSolcVersion({ version: version, canReceive: false })
// } catch (e) {
// version = window.location.href.split('=')[5].split('+')[0].split('-')[1].slice(1)
// console.log(e)
// }
// return version
// }
useEffect(() => {
if (props.deployOption && Array.isArray(props.deployOption)) {
@ -173,6 +189,7 @@ export function ContractGUI(props: ContractGUIProps) {
}
const handleActionClick = async () => {
props.getVersion()
if (deployState.deploy) {
const proxyInitializeString = getMultiValsString(initializeFields.current)
props.clickCallBack(props.initializerOptions.inputs.inputs, proxyInitializeString, ['Deploy with Proxy'])

@ -44,6 +44,8 @@ export function InstanceContainerUI(props: InstanceContainerProps) {
plugin={props.plugin}
exEnvironment={props.exEnvironment}
editInstance={props.editInstance}
solcVersion={props.solcVersion}
getVersion={props.getVersion}
/>
)
})}
@ -92,6 +94,8 @@ export function InstanceContainerUI(props: InstanceContainerProps) {
plugin={props.plugin}
exEnvironment={props.exEnvironment}
editInstance={props.editInstance}
solcVersion={props.solcVersion}
getVersion={props.getVersion}
/>
)
})}

@ -27,43 +27,22 @@ export function UniversalDappUI(props: UdappProps) {
const [calldataValue, setCalldataValue] = useState<string>('')
const [evmBC, setEvmBC] = useState(null)
const [instanceBalance, setInstanceBalance] = useState(0)
const UrlLink = () => {
const getVersion = () => {
let version = ''
try {
version = window.location.href.split('=')[5].split('+')[0].split('-')[1]
} catch {
version = window.location.href.split('=')[5].split('+')[0].split('-')[1]
}
return [version, parseFloat(version.slice(1))]
}
return (
<div className="d-flex flex-row justify-content-between mt-2">
<div className="py-2 border-top d-flex justify-content-start flex-grow-1">
<FormattedMessage id="udapp.lowLevelInteractions" />
</div>
<CustomTooltip
placement={'bottom-end'}
tooltipClasses="text-wrap"
tooltipId="receiveEthDocstoolTip"
tooltipText={<FormattedMessage id="udapp.tooltipText8" />}
>
{ // receive method added to solidity v0.6.x. use this as diff.
(getVersion()[1] as number) < 0.6 ? (
<a href={`https://solidity.readthedocs.io/en/${getVersion()[0]}/contracts.html`} target="_blank" rel="noreferrer">
<i aria-hidden="true" className="fas fa-info my-2 mr-1"></i>
</a>
) :<a href={`https://solidity.readthedocs.io/en/${getVersion()[0]}/contracts.html#receive-ether-function`} target="_blank" rel="noreferrer">
<i aria-hidden="true" className="fas fa-info my-2 mr-1"></i>
</a>
}
</CustomTooltip>
</div>
)
}
// const [solcVersion, setSolcVersion] = useState({ version: '', canReceive: true })
// const getVersion = () => {
// let version = ''
// try {
// version = window.location.href.split('=')[5].split('+')[0].split('-')[1].slice(1)
// if (parseFloat(version) < 0.6) {
// setSolcVersion({ version: version, canReceive: false })
// }
// setSolcVersion({ version: version, canReceive: false })
// } catch (e) {
// version = window.location.href.split('=')[5].split('+')[0].split('-')[1].slice(1)
// console.log(e)
// }
// return version
// }
useEffect(() => {
if (!props.instance.abi) {
const abi = txHelper.sortAbiFunction(props.instance.contractData.abi)
@ -469,6 +448,7 @@ export function UniversalDappUI(props: UdappProps) {
return (
<div key={index}>
<ContractGUI
getVersion={props.getVersion}
funcABI={funcABI}
clickCallBack={(valArray: {name: string; type: string}[], inputsValues: string) => {
runTransaction(lookupOnly, funcABI, valArray, inputsValues, index)
@ -499,7 +479,27 @@ export function UniversalDappUI(props: UdappProps) {
})}
</div>
<div className="d-flex flex-column">
<UrlLink />
<div className="d-flex flex-row justify-content-between mt-2">
<div className="py-2 border-top d-flex justify-content-start flex-grow-1">
<FormattedMessage id="udapp.lowLevelInteractions" />
</div>
<CustomTooltip
placement={'bottom-end'}
tooltipClasses="text-wrap"
tooltipId="receiveEthDocstoolTip"
tooltipText={<FormattedMessage id="udapp.tooltipText8" />}
>
{ // receive method added to solidity v0.6.x. use this as diff.
props.solcVersion.canReceive === false ? (
<a href={`https://solidity.readthedocs.io/en/v${props.solcVersion.version}/contracts.html`} target="_blank" rel="noreferrer">
<i aria-hidden="true" className="fas fa-info my-2 mr-1"></i>
</a>
) :<a href={`https://solidity.readthedocs.io/en/v${props.solcVersion.version}/contracts.html#receive-ether-function`} target="_blank" rel="noreferrer">
<i aria-hidden="true" className="fas fa-info my-2 mr-1"></i>
</a>
}
</CustomTooltip>
</div>
<div className="d-flex flex-column align-items-start">
<label className="">CALLDATA</label>
<div className="d-flex justify-content-end w-100 align-items-center">

@ -80,6 +80,22 @@ export function RunTabUI(props: RunTabProps) {
const [runTab, dispatch] = useReducer(runTabReducer, initialState)
const REACT_API = { runTab }
const currentfile = plugin.config.get('currentFile')
const [solcVersion, setSolcVersion] = useState<{version: string, canReceive: boolean}>({ version: '', canReceive: true })
const getVersion = () => {
let version = ''
try {
version = window.location.href.split('=')[5].split('+')[0].split('-')[1].slice(1)
if (parseFloat(version) < 0.6) {
setSolcVersion({ version: version, canReceive: false })
}
setSolcVersion({ version: version, canReceive: true })
} catch (e) {
version = window.location.href.split('=')[5].split('+')[0].split('-')[1].slice(1)
console.log(e)
}
return version
}
useEffect(() => {
if (!props.initialState) {
@ -306,6 +322,9 @@ export function RunTabUI(props: RunTabProps) {
isValidProxyAddress={isValidProxyAddress}
isValidProxyUpgrade={isValidProxyUpgrade}
proxy={runTab.proxy}
solCompilerVersion={solcVersion}
setCompilerVersion={setSolcVersion}
getCompilerVersion={getVersion}
/>
<RecorderUI
plugin={plugin}
@ -330,6 +349,8 @@ export function RunTabUI(props: RunTabProps) {
mainnetPrompt={mainnetPrompt}
runTransactions={executeTransactions}
sendValue={runTab.sendValue}
solcVersion={solcVersion}
getVersion={getVersion}
getFuncABIInputs={getFuncABIValues}
exEnvironment={runTab.selectExEnv}
editInstance={(instance) => {

@ -279,6 +279,11 @@ export interface ContractDropdownProps {
isValidProxyAddress?: (address: string) => Promise<boolean>,
isValidProxyUpgrade?: (proxyAddress: string, contractName: string, solcInput: SolcInput, solcOuput: SolcOutput, solcVersion: string) => Promise<LayoutCompatibilityReport | { ok: boolean, pass: boolean, warning: boolean }>,
proxy: { deployments: { address: string, date: string, contractName: string }[] }
solCompilerVersion: { version: string, canReceive: boolean }
setCompilerVersion: React.Dispatch<React.SetStateAction<{
version: string;
canReceive: boolean;}>>
getCompilerVersion: () => string
}
export interface RecorderProps {
@ -343,6 +348,8 @@ export interface InstanceContainerProps {
exEnvironment: string
editInstance: (instance) => void
plugin: RunTab
solcVersion: { version: string, canReceive: boolean }
getVersion: () => string
}
export interface Modal {
@ -397,6 +404,11 @@ export interface ContractGUIProps {
isValidProxyAddress?: (address: string) => Promise<boolean>,
isValidProxyUpgrade?: (proxyAddress: string) => Promise<LayoutCompatibilityReport | { ok: boolean, pass: boolean, warning: boolean }>,
modal?: (title: string, message: string | JSX.Element, okLabel: string, okFn: () => void, cancelLabel?: string, cancelFn?: () => void, okBtnClass?: string, cancelBtnClass?: string) => void
solcVersion?: { version: string, canReceive: boolean }
setSolcVersion?: React.Dispatch<React.SetStateAction<{
version: string;
canReceive: boolean;}>>
getVersion: () => string
}
export interface MainnetProps {
network: Network,
@ -452,6 +464,8 @@ export interface UdappProps {
exEnvironment: string
editInstance: (instance) => void
plugin: RunTab
solcVersion: { version: string, canReceive: boolean }
getVersion: () => string
}
export interface DeployButtonProps {

Loading…
Cancel
Save