Fixed selected contract initialization and deploy constructor error

yann300-patch-36
David Disu 3 years ago committed by yann300
parent 5f0239390c
commit aa4f78fb44
  1. 22
      libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx
  2. 2
      libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx
  3. 7
      libs/remix-ui/run-tab/src/lib/reducers/runTab.ts
  4. 15
      package-lock.json

@ -71,11 +71,7 @@ export function ContractDropdownUI (props: ContractDropdownProps) {
enableContractNames(false)
setCompFails('block')
}
if (contractList.length > 0) {
const contract = contractList.find(contract => contract.alias === selectedContract)
if (!selectedContract || !contract) setSelectedContract(contractList[0].alias)
}
initSelectedContract()
}, [loadType, currentFile])
useEffect(() => {
@ -91,6 +87,18 @@ export function ContractDropdownUI (props: ContractDropdownProps) {
}
}, [selectedContract])
useEffect(() => {
initSelectedContract()
}, [contractList])
const initSelectedContract = () => {
if (contractList.length > 0) {
const contract = contractList.find(contract => contract.alias === selectedContract)
if (!selectedContract || !contract) setSelectedContract(contractList[0].alias)
}
}
const enableAtAddress = (enable: boolean) => {
if (enable) {
setAtAddressOptions({
@ -119,8 +127,8 @@ export function ContractDropdownUI (props: ContractDropdownProps) {
}
}
const clickCallback = (inputsValues) => {
createInstance(loadedContractData, inputsValues)
const clickCallback = (inputs, value) => {
createInstance(loadedContractData, value)
}
const createInstance = (selectedContract, args) => {

@ -73,7 +73,7 @@ export function ContractGUI (props: ContractGUIProps) {
dataId: title + ' - transact (not payable)'
})
}
}, [props.lookupOnly, props.funcABI])
}, [props.lookupOnly, props.funcABI, title])
const switchMethodViewOn = () => {
setToggleContainer(true)

@ -256,7 +256,12 @@ export const runTabReducer = (state: RunTabState = runTabInitialState, action: A
return {
...state,
selectExEnv: payload
selectExEnv: payload,
accounts: {
...state.accounts,
selectedAccount: '',
loadedAccounts: {}
}
}
}

15
package-lock.json generated

@ -41619,15 +41619,6 @@
"which": "^2.0.1"
}
},
"debug": {
"version": "4.3.2",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.2.tgz",
"integrity": "sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==",
"dev": true,
"requires": {
"ms": "2.1.2"
}
},
"decompress-response": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz",
@ -41699,9 +41690,9 @@
}
},
"keyv": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/keyv/-/keyv-4.0.3.tgz",
"integrity": "sha512-zdGa2TOpSZPq5mU6iowDARnMBZgtCqJ11dJROFi6tg6kTn4nuUdU09lFyLFSaHrWqpIJ+EBq4E8/Dc0Vx5vLdA==",
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/keyv/-/keyv-4.0.4.tgz",
"integrity": "sha512-vqNHbAc8BBsxk+7QBYLW0Y219rWcClspR6WSeoHYKG5mnsSoOH+BL1pWq02DDCVdvvuUny5rkBlzMRzoqc+GIg==",
"dev": true,
"requires": {
"json-buffer": "3.0.1"

Loading…
Cancel
Save