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

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

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

15
package-lock.json generated

@ -41619,15 +41619,6 @@
"which": "^2.0.1" "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": { "decompress-response": {
"version": "6.0.0", "version": "6.0.0",
"resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz",
@ -41699,9 +41690,9 @@
} }
}, },
"keyv": { "keyv": {
"version": "4.0.3", "version": "4.0.4",
"resolved": "https://registry.npmjs.org/keyv/-/keyv-4.0.3.tgz", "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.0.4.tgz",
"integrity": "sha512-zdGa2TOpSZPq5mU6iowDARnMBZgtCqJ11dJROFi6tg6kTn4nuUdU09lFyLFSaHrWqpIJ+EBq4E8/Dc0Vx5vLdA==", "integrity": "sha512-vqNHbAc8BBsxk+7QBYLW0Y219rWcClspR6WSeoHYKG5mnsSoOH+BL1pWq02DDCVdvvuUny5rkBlzMRzoqc+GIg==",
"dev": true, "dev": true,
"requires": { "requires": {
"json-buffer": "3.0.1" "json-buffer": "3.0.1"

Loading…
Cancel
Save