retrieve function inputs

yann300-patch-36
David Disu 3 years ago committed by yann300
parent 296c70f2e3
commit c2e9c13bec
  1. 4
      libs/remix-ui/run-tab/src/lib/actions/index.ts
  2. 13
      libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx
  3. 1
      libs/remix-ui/run-tab/src/lib/components/instanceContainerUI.tsx
  4. 3
      libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx
  5. 4
      libs/remix-ui/run-tab/src/lib/run-tab.tsx
  6. 6
      libs/remix-ui/run-tab/src/lib/types/index.ts
  7. 2
      workspace.json

@ -717,3 +717,7 @@ export const runCurrentScenario = (gasEstimationPrompt: (msg: string) => JSX.Ele
export const updateScenarioPath = (path: string) => {
dispatch(setPathToScenario(path))
}
export const getFuncABIInputs = (funcABI: FuncABI) => {
return plugin.blockchain.getInputs(funcABI)
}

@ -1,6 +1,6 @@
// eslint-disable-next-line no-use-before-define
import React, { useEffect, useState } from 'react'
import { ContractData, ContractDropdownProps } from '../types'
import { ContractData, ContractDropdownProps, FuncABI } from '../types'
import * as ethJSUtil from 'ethereumjs-util'
import { ContractGUI } from './contractGUI'
@ -25,6 +25,8 @@ export function ContractDropdownUI (props: ContractDropdownProps) {
const [selectedContract, setSelectedContract] = useState<string>('')
const [compFails, setCompFails] = useState<'none' | 'block'>('none')
const [loadedContractData, setLoadedContractData] = useState<ContractData>(null)
const [constructorInterface, setConstructorInterface] = useState<FuncABI>(null)
const [constructorInputs, setConstructorInputs] = useState(null)
const { contractList, loadType, currentFile } = props.contracts
useEffect(() => {
@ -79,8 +81,13 @@ export function ContractDropdownUI (props: ContractDropdownProps) {
useEffect(() => {
if (selectedContract) {
const contract = contractList.find(contract => contract.alias === selectedContract)
const loadedContractData = props.getSelectedContract(selectedContract, contract.name)
setLoadedContractData(props.getSelectedContract(selectedContract, contract.name))
if (loadedContractData) {
setLoadedContractData(loadedContractData)
setConstructorInterface(loadedContractData.getConstructorInterface())
setConstructorInputs(loadedContractData.getConstructorInputs())
}
}
}, [selectedContract])
@ -193,7 +200,7 @@ export function ContractDropdownUI (props: ContractDropdownProps) {
<div className="udapp_deployDropdown">
{ contractList.length <= 0 ? 'No compiled contracts'
: loadedContractData ? <div>
<ContractGUI title='Deploy' funcABI={loadedContractData.getConstructorInterface()} clickCallBack={clickCallback} inputs={loadedContractData.getConstructorInputs()} widthClass='w-50' evmBC={loadedContractData.bytecodeObject} lookupOnly={false} />
<ContractGUI title='Deploy' funcABI={constructorInterface} clickCallBack={clickCallback} inputs={constructorInputs} widthClass='w-50' evmBC={loadedContractData.bytecodeObject} lookupOnly={false} />
<div className="d-flex py-1 align-items-center custom-control custom-checkbox">
<input
id="deployAndRunPublishToIPFS"

@ -35,6 +35,7 @@ export function InstanceContainerUI (props: InstanceContainerProps) {
mainnetPrompt={props.mainnetPrompt}
runTransactions={props.runTransactions}
sendValue={props.sendValue}
getFuncABIInputs={props.getFuncABIInputs}
/>
}) }
</div>

@ -18,7 +18,6 @@ export function UniversalDappUI (props: UdappProps) {
const [expandPath, setExpandPath] = useState<string[]>([])
const [llIError, setLlIError] = useState<string>('')
const [calldataValue, setCalldataValue] = useState<string>('')
const [inputs, setInputs] = useState<string>(null)
const [evmBC, setEvmBC] = useState(null)
useEffect(() => {
@ -43,7 +42,6 @@ export function UniversalDappUI (props: UdappProps) {
useEffect(() => {
if (props.instance.contractData) {
setInputs(props.instance.contractData.getConstructorInputs())
setEvmBC(props.instance.contractData.bytecodeObject)
}
}, [props.instance.contractData])
@ -235,6 +233,7 @@ export function UniversalDappUI (props: UdappProps) {
if (funcABI.type !== 'function') return null
const isConstant = funcABI.constant !== undefined ? funcABI.constant : false
const lookupOnly = funcABI.stateMutability === 'view' || funcABI.stateMutability === 'pure' || isConstant
const inputs = props.getFuncABIInputs(funcABI)
return <ContractGUI
funcABI={funcABI}

@ -24,7 +24,8 @@ import {
removeInstance, getContext,
runTransactions, loadAddress,
storeScenario, runCurrentScenario,
updateScenarioPath, initWebDialogs
updateScenarioPath, initWebDialogs,
getFuncABIInputs
} from './actions'
import './css/run-tab.css'
import { PublishToStorage } from '@remix-ui/publish-to-storage'
@ -275,6 +276,7 @@ export function RunTabUI (props: RunTabProps) {
mainnetPrompt={mainnetPrompt}
runTransactions={runTransactions}
sendValue={runTab.sendValue}
getFuncABIInputs={getFuncABIInputs}
/>
</div>
</div>

@ -225,7 +225,8 @@ export interface InstanceContainerProps {
logBuilder: (msg: string) => JSX.Element,
passphrasePrompt: (message: string) => JSX.Element,
mainnetPrompt: (tx: Tx, network: Network, amount: string, gasEstimation: string, gasFees: (maxFee: string, cb: (txFeeText: string, priceStatus: boolean) => void) => void, determineGasPrice: (cb: (txFeeText: string, gasPriceValue: string, gasPriceStatus: boolean) => void) => void) => JSX.Element,
sendValue: string
sendValue: string,
getFuncABIInputs: (funcABI: FuncABI) => string
}
export interface Modal {
@ -295,5 +296,6 @@ export interface UdappProps {
mainnetPrompt: MainnetPrompt,
gasEstimationPrompt: (msg: string) => JSX.Element,
passphrasePrompt: (msg: string) => JSX.Element) => void,
sendValue: string
sendValue: string,
getFuncABIInputs: (funcABI: FuncABI) => string
}

@ -1166,7 +1166,7 @@
"options": {
"linter": "eslint",
"tsConfig": ["libs/remix-ui/run-tab/tsconfig.lib.json"],
"exclude": ["**/node_modules/**", "!libs/remix-ui/run-tab/**/*"]
"exclude": ["**/node_modules/**", "libs/remix-ui/run-tab/**/*.d.ts", "!libs/remix-ui/run-tab/**/*"]
}
}
}

Loading…
Cancel
Save