From aa4f78fb44bbd18ad381cb5539f166f853bc0429 Mon Sep 17 00:00:00 2001 From: David Disu Date: Thu, 30 Dec 2021 17:10:41 +0100 Subject: [PATCH] Fixed selected contract initialization and deploy constructor error --- .../src/lib/components/contractDropdownUI.tsx | 22 +++++++++++++------ .../src/lib/components/contractGUI.tsx | 2 +- .../run-tab/src/lib/reducers/runTab.ts | 7 +++++- package-lock.json | 15 +++---------- 4 files changed, 25 insertions(+), 21 deletions(-) diff --git a/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx b/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx index 595f8ae22b..8d49e0e78f 100644 --- a/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/contractDropdownUI.tsx @@ -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) => { diff --git a/libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx b/libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx index 33e4f3c2df..292c2eeaee 100644 --- a/libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/contractGUI.tsx @@ -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) diff --git a/libs/remix-ui/run-tab/src/lib/reducers/runTab.ts b/libs/remix-ui/run-tab/src/lib/reducers/runTab.ts index f91240e2c5..78d8fd5387 100644 --- a/libs/remix-ui/run-tab/src/lib/reducers/runTab.ts +++ b/libs/remix-ui/run-tab/src/lib/reducers/runTab.ts @@ -256,7 +256,12 @@ export const runTabReducer = (state: RunTabState = runTabInitialState, action: A return { ...state, - selectExEnv: payload + selectExEnv: payload, + accounts: { + ...state.accounts, + selectedAccount: '', + loadedAccounts: {} + } } } diff --git a/package-lock.json b/package-lock.json index a05d1a99a7..bab7da51d1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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"