diff --git a/apps/remix-ide-e2e/src/tests/signingMessage.test.ts b/apps/remix-ide-e2e/src/tests/signingMessage.test.ts index 517a19191e..913851fa38 100644 --- a/apps/remix-ide-e2e/src/tests/signingMessage.test.ts +++ b/apps/remix-ide-e2e/src/tests/signingMessage.test.ts @@ -23,6 +23,8 @@ module.exports = { console.log('signature', signature) browser.assert.ok(typeof hash.value === 'string', 'type of hash.value must be String') browser.assert.ok(typeof signature.value === 'string', 'type of signature.value must be String') + // we check here that the input is strictly "test message" + browser.assert.equal(signature.value, '0xaa8873317ebf3f34fbcc0eab3e9808d851352674c28a3d6b88dc84db6e10fc183a45bcec983a105964a13b54f18e43eceae29d982bf379826fb7ecfe0d42c6ba1b', 'signature should be tied to the input "test message"') }) .addFile('signMassage.sol', sources[0]['signMassage.sol']) .openFile('signMassage.sol') diff --git a/apps/remix-ide/src/app/components/vertical-icons.tsx b/apps/remix-ide/src/app/components/vertical-icons.tsx index 2e8deaa182..eea114b637 100644 --- a/apps/remix-ide/src/app/components/vertical-icons.tsx +++ b/apps/remix-ide/src/app/components/vertical-icons.tsx @@ -1,13 +1,11 @@ // eslint-disable-next-line no-use-before-define import React from 'react' import ReactDOM from 'react-dom' -import Registry from '../state/registry' import packageJson from '../../../../../package.json' import { Plugin } from '@remixproject/engine' import { EventEmitter } from 'events' import { IconRecord, RemixUiVerticalIconsPanel } from '@remix-ui/vertical-icons-panel' import { Profile } from '@remixproject/plugin-utils' -import { timeStamp } from 'console' const profile = { name: 'menuicons', @@ -95,7 +93,6 @@ export class VerticalIcons extends Plugin { */ select (name: string) { // TODO: Only keep `this.emit` (issue#2210) - console.log(name, this) this.emit('showContent', name) this.events.emit('showContent', name) } diff --git a/apps/remix-ide/src/blockchain/blockchain.js b/apps/remix-ide/src/blockchain/blockchain.js index a747ba0f31..d3bc4e60ce 100644 --- a/apps/remix-ide/src/blockchain/blockchain.js +++ b/apps/remix-ide/src/blockchain/blockchain.js @@ -226,6 +226,10 @@ export class Blockchain extends Plugin { return this.executionContext.getProvider() } + getInjectedWeb3Address () { + return this.executionContext.getSelectedAddress() + } + /** * return the fork name applied to the current envionment * @return {String} - fork name diff --git a/apps/remix-ide/src/blockchain/execution-context.js b/apps/remix-ide/src/blockchain/execution-context.js index 67a3f1f28c..54e738b245 100644 --- a/apps/remix-ide/src/blockchain/execution-context.js +++ b/apps/remix-ide/src/blockchain/execution-context.js @@ -50,6 +50,10 @@ export class ExecutionContext { return this.executionContext } + getSelectedAddress () { + return injectedProvider ? injectedProvider.selectedAddress : null + } + getCurrentFork () { return this.currentFork } 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..95ef6f8a76 100644 --- a/libs/remix-ui/run-tab/src/lib/actions/index.ts +++ b/libs/remix-ui/run-tab/src/lib/actions/index.ts @@ -145,6 +145,13 @@ const fillAccountsList = async () => { }) }) })) + const provider = plugin.blockchain.getProvider() + + if (provider === 'injected') { + const selectedAddress = plugin.blockchain.getInjectedWeb3Address() + + if (!(Object.keys(loadedAccounts).includes(selectedAddress))) setAccount(null) + } dispatch(fetchAccountsListSuccess(loadedAccounts)) }).catch((e) => { dispatch(fetchAccountsListFailed(e.message)) @@ -552,25 +559,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() diff --git a/libs/remix-ui/run-tab/src/lib/components/account.tsx b/libs/remix-ui/run-tab/src/lib/components/account.tsx index 9d34294026..f8a74a1a34 100644 --- a/libs/remix-ui/run-tab/src/lib/components/account.tsx +++ b/libs/remix-ui/run-tab/src/lib/components/account.tsx @@ -1,5 +1,5 @@ // eslint-disable-next-line no-use-before-define -import React, { useEffect, useState } from 'react' +import React, { useEffect, useState, useRef } from 'react' import { CopyToClipboard } from '@remix-ui/clipboard' import { AccountProps } from '../types' import { PassphrasePrompt } from './passphrase' @@ -11,7 +11,7 @@ export function AccountUI (props: AccountProps) { classList: '', title: '' }) - const [message, setMessage] = useState('') + const messageRef = useRef('') useEffect(() => { if (!selectedAccount && accounts.length > 0) props.setAccount(accounts[0]) @@ -79,7 +79,7 @@ export function AccountUI (props: AccountProps) { setPassphrase={props.setPassphrase} />, 'OK', () => { props.modal('Sign a message', signMessagePrompt(), 'OK', () => { - props.signMessageWithAddress(selectedAccount, message, signedMessagePrompt, props.passphrase) + props.signMessageWithAddress(selectedAccount, messageRef.current, signedMessagePrompt, props.passphrase) props.setPassphrase('') }, 'Cancel', null) }, 'Cancel', () => { @@ -88,7 +88,7 @@ export function AccountUI (props: AccountProps) { } props.modal('Sign a message', signMessagePrompt(), 'OK', () => { - props.signMessageWithAddress(selectedAccount, message, signedMessagePrompt) + props.signMessageWithAddress(selectedAccount, messageRef.current, signedMessagePrompt) }, 'Cancel', null) } @@ -101,7 +101,7 @@ export function AccountUI (props: AccountProps) { } const handleMessageInput = (e) => { - setMessage(e.target.value) + messageRef.current = e.target.value } const passphraseCreationPrompt = () => { @@ -128,7 +128,7 @@ export function AccountUI (props: AccountProps) { rows={4} cols={50} onInput={handleMessageInput} - defaultValue={message} + defaultValue={messageRef.current} > diff --git a/libs/remix-ui/run-tab/src/lib/types/blockchain.d.ts b/libs/remix-ui/run-tab/src/lib/types/blockchain.d.ts index 406459b1a0..1b2f7d442d 100644 --- a/libs/remix-ui/run-tab/src/lib/types/blockchain.d.ts +++ b/libs/remix-ui/run-tab/src/lib/types/blockchain.d.ts @@ -37,6 +37,7 @@ export class Blockchain extends Plugin { setProviderFromEndpoint(target: any, context: any, cb: any): void; detectNetwork(cb: any): void; getProvider(): any; + getInjectedWeb3Address(): any; /** * return the fork name applied to the current envionment * @return {String} - fork name diff --git a/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx b/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx index 15e19bd358..36cd05b73c 100644 --- a/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx +++ b/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx @@ -72,6 +72,7 @@ export const SolidityUnitTesting = (props: Record) => { // eslint-d const isDebugging = useRef(false) const allTests = useRef([]) const selectedTests = useRef([]) + const currentTestFiles:any = useRef([]) // stores files for which tests have been run const currentErrors:any = useRef([]) // eslint-disable-line @typescript-eslint/no-explicit-any const defaultPath = 'tests' @@ -104,7 +105,7 @@ export const SolidityUnitTesting = (props: Record) => { // eslint-d } // if current file is changed while debugging and one of the files imported in test file are opened // do not clear the test results in SUT plugin - if (isDebugging.current && testTab.allFilesInvolved.includes(file)) return + if ((isDebugging.current && testTab.allFilesInvolved.includes(file)) || currentTestFiles.current.includes(file)) return allTests.current = [] updateTestFileList() clearResults() @@ -394,6 +395,7 @@ export const SolidityUnitTesting = (props: Record) => { // eslint-d const showTestsResult = () => { const filenames = Object.keys(testsResultByFilename) + currentTestFiles.current = filenames for (const filename of filenames) { const fileTestsResult = testsResultByFilename[filename] const contracts = Object.keys(fileTestsResult) diff --git a/libs/remix-ui/terminal/src/lib/components/RenderCall.tsx b/libs/remix-ui/terminal/src/lib/components/RenderCall.tsx index 92feb90b65..4cb3b96473 100644 --- a/libs/remix-ui/terminal/src/lib/components/RenderCall.tsx +++ b/libs/remix-ui/terminal/src/lib/components/RenderCall.tsx @@ -27,7 +27,7 @@ const RenderCall = ({ tx, resolvedData, logs, index, plugin, showTableHash, txDe
txDetails(event, tx)}> - [call] + [call]
from: {from}
to: {to}
data: {input}
@@ -35,7 +35,7 @@ const RenderCall = ({ tx, resolvedData, logs, index, plugin, showTableHash, txDe
debug(event, tx)}>Debug
- +
{showTableHash.includes(tx.hash) ? showTable({ hash: tx.hash, diff --git a/libs/remix-ui/workspace/src/lib/reducers/workspace.ts b/libs/remix-ui/workspace/src/lib/reducers/workspace.ts index a41365224b..cf3e3a1cbf 100644 --- a/libs/remix-ui/workspace/src/lib/reducers/workspace.ts +++ b/libs/remix-ui/workspace/src/lib/reducers/workspace.ts @@ -608,12 +608,12 @@ const fileAdded = (state: BrowserState, path: string): { [x: string]: Record