From ef0b8f8e4437cc2c8c50f76987199069b0677d5e Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 3 Feb 2022 13:49:12 +0100 Subject: [PATCH] fix using load from abi --- .../remix-ui/run-tab/src/lib/actions/index.ts | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/libs/remix-ui/run-tab/src/lib/actions/index.ts b/libs/remix-ui/run-tab/src/lib/actions/index.ts index 25bbb89d93..848ea4ce0d 100644 --- a/libs/remix-ui/run-tab/src/lib/actions/index.ts +++ b/libs/remix-ui/run-tab/src/lib/actions/index.ts @@ -552,25 +552,25 @@ export const clearInstances = () => { } export const loadAddress = (contract: ContractData, address: string) => { - if (!contract) return dispatch(displayPopUp('No compiled contracts found.')) loadContractFromAddress(address, - (cb) => { - dispatch(displayNotification('At Address', `Do you really want to interact with ${address} using the current ABI definition?`, 'OK', 'Cancel', cb, null)) - }, - (error, loadType, abi) => { - if (error) { - return dispatch(displayNotification('Alert', error, 'OK', null)) - } - const compiler = plugin.REACT_API.contracts.contractList.find(item => item.alias === contract.name) - const contractData = getSelectedContract(contract.name, compiler.name) - - if (loadType === 'abi') { - return addInstance({ contractData, address, name: '' }) - } - addInstance({ contractData, address, name: contract.name }) - } - ) -} + (cb) => { + dispatch(displayNotification('At Address', `Do you really want to interact with ${address} using the current ABI definition?`, 'OK', 'Cancel', cb, null)) + }, + (error, loadType, abi) => { + if (error) { + return dispatch(displayNotification('Alert', error, 'OK', null)) + } + if (loadType === 'abi') { + return addInstance({ abi, address, name: '' }) + } else if (loadType === 'instance') { + if (!contract) return dispatch(displayPopUp('No compiled contracts found.')) + const compiler = plugin.REACT_API.contracts.contractList.find(item => item.alias === contract.name) + const contractData = getSelectedContract(contract.name, compiler.name) + return addInstance({ contractData, address, name: contract.name }) + } + } + ) + } export const getContext = () => { return plugin.blockchain.context()