Merge branch 'master' into bump-master

bump-master
David Disu 3 years ago committed by GitHub
commit b55c9612fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      apps/remix-ide-e2e/src/tests/signingMessage.test.ts
  2. 3
      apps/remix-ide/src/app/components/vertical-icons.tsx
  3. 4
      apps/remix-ide/src/blockchain/blockchain.js
  4. 4
      apps/remix-ide/src/blockchain/execution-context.js
  5. 43
      libs/remix-ui/run-tab/src/lib/actions/index.ts
  6. 12
      libs/remix-ui/run-tab/src/lib/components/account.tsx
  7. 1
      libs/remix-ui/run-tab/src/lib/types/blockchain.d.ts
  8. 4
      libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx
  9. 4
      libs/remix-ui/terminal/src/lib/components/RenderCall.tsx
  10. 12
      libs/remix-ui/workspace/src/lib/reducers/workspace.ts

@ -23,6 +23,8 @@ module.exports = {
console.log('signature', signature) console.log('signature', signature)
browser.assert.ok(typeof hash.value === 'string', 'type of hash.value must be String') 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') 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']) .addFile('signMassage.sol', sources[0]['signMassage.sol'])
.openFile('signMassage.sol') .openFile('signMassage.sol')

@ -1,13 +1,11 @@
// eslint-disable-next-line no-use-before-define // eslint-disable-next-line no-use-before-define
import React from 'react' import React from 'react'
import ReactDOM from 'react-dom' import ReactDOM from 'react-dom'
import Registry from '../state/registry'
import packageJson from '../../../../../package.json' import packageJson from '../../../../../package.json'
import { Plugin } from '@remixproject/engine' import { Plugin } from '@remixproject/engine'
import { EventEmitter } from 'events' import { EventEmitter } from 'events'
import { IconRecord, RemixUiVerticalIconsPanel } from '@remix-ui/vertical-icons-panel' import { IconRecord, RemixUiVerticalIconsPanel } from '@remix-ui/vertical-icons-panel'
import { Profile } from '@remixproject/plugin-utils' import { Profile } from '@remixproject/plugin-utils'
import { timeStamp } from 'console'
const profile = { const profile = {
name: 'menuicons', name: 'menuicons',
@ -95,7 +93,6 @@ export class VerticalIcons extends Plugin {
*/ */
select (name: string) { select (name: string) {
// TODO: Only keep `this.emit` (issue#2210) // TODO: Only keep `this.emit` (issue#2210)
console.log(name, this)
this.emit('showContent', name) this.emit('showContent', name)
this.events.emit('showContent', name) this.events.emit('showContent', name)
} }

@ -226,6 +226,10 @@ export class Blockchain extends Plugin {
return this.executionContext.getProvider() return this.executionContext.getProvider()
} }
getInjectedWeb3Address () {
return this.executionContext.getSelectedAddress()
}
/** /**
* return the fork name applied to the current envionment * return the fork name applied to the current envionment
* @return {String} - fork name * @return {String} - fork name

@ -50,6 +50,10 @@ export class ExecutionContext {
return this.executionContext return this.executionContext
} }
getSelectedAddress () {
return injectedProvider ? injectedProvider.selectedAddress : null
}
getCurrentFork () { getCurrentFork () {
return this.currentFork return this.currentFork
} }

@ -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)) dispatch(fetchAccountsListSuccess(loadedAccounts))
}).catch((e) => { }).catch((e) => {
dispatch(fetchAccountsListFailed(e.message)) dispatch(fetchAccountsListFailed(e.message))
@ -552,25 +559,25 @@ export const clearInstances = () => {
} }
export const loadAddress = (contract: ContractData, address: string) => { export const loadAddress = (contract: ContractData, address: string) => {
if (!contract) return dispatch(displayPopUp('No compiled contracts found.'))
loadContractFromAddress(address, loadContractFromAddress(address,
(cb) => { (cb) => {
dispatch(displayNotification('At Address', `Do you really want to interact with ${address} using the current ABI definition?`, 'OK', 'Cancel', cb, null)) dispatch(displayNotification('At Address', `Do you really want to interact with ${address} using the current ABI definition?`, 'OK', 'Cancel', cb, null))
}, },
(error, loadType, abi) => { (error, loadType, abi) => {
if (error) { if (error) {
return dispatch(displayNotification('Alert', error, 'OK', null)) return dispatch(displayNotification('Alert', error, 'OK', null))
} }
const compiler = plugin.REACT_API.contracts.contractList.find(item => item.alias === contract.name) if (loadType === 'abi') {
const contractData = getSelectedContract(contract.name, compiler.name) return addInstance({ abi, address, name: '<at address>' })
} else if (loadType === 'instance') {
if (loadType === 'abi') { if (!contract) return dispatch(displayPopUp('No compiled contracts found.'))
return addInstance({ contractData, address, name: '<at address>' }) const compiler = plugin.REACT_API.contracts.contractList.find(item => item.alias === contract.name)
} const contractData = getSelectedContract(contract.name, compiler.name)
addInstance({ contractData, address, name: contract.name }) return addInstance({ contractData, address, name: contract.name })
} }
) }
} )
}
export const getContext = () => { export const getContext = () => {
return plugin.blockchain.context() return plugin.blockchain.context()

@ -1,5 +1,5 @@
// eslint-disable-next-line no-use-before-define // 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 { CopyToClipboard } from '@remix-ui/clipboard'
import { AccountProps } from '../types' import { AccountProps } from '../types'
import { PassphrasePrompt } from './passphrase' import { PassphrasePrompt } from './passphrase'
@ -11,7 +11,7 @@ export function AccountUI (props: AccountProps) {
classList: '', classList: '',
title: '' title: ''
}) })
const [message, setMessage] = useState('') const messageRef = useRef('')
useEffect(() => { useEffect(() => {
if (!selectedAccount && accounts.length > 0) props.setAccount(accounts[0]) if (!selectedAccount && accounts.length > 0) props.setAccount(accounts[0])
@ -79,7 +79,7 @@ export function AccountUI (props: AccountProps) {
setPassphrase={props.setPassphrase} setPassphrase={props.setPassphrase}
/>, 'OK', () => { />, 'OK', () => {
props.modal('Sign a message', signMessagePrompt(), '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('') props.setPassphrase('')
}, 'Cancel', null) }, 'Cancel', null)
}, 'Cancel', () => { }, 'Cancel', () => {
@ -88,7 +88,7 @@ export function AccountUI (props: AccountProps) {
} }
props.modal('Sign a message', signMessagePrompt(), 'OK', () => { props.modal('Sign a message', signMessagePrompt(), 'OK', () => {
props.signMessageWithAddress(selectedAccount, message, signedMessagePrompt) props.signMessageWithAddress(selectedAccount, messageRef.current, signedMessagePrompt)
}, 'Cancel', null) }, 'Cancel', null)
} }
@ -101,7 +101,7 @@ export function AccountUI (props: AccountProps) {
} }
const handleMessageInput = (e) => { const handleMessageInput = (e) => {
setMessage(e.target.value) messageRef.current = e.target.value
} }
const passphraseCreationPrompt = () => { const passphraseCreationPrompt = () => {
@ -128,7 +128,7 @@ export function AccountUI (props: AccountProps) {
rows={4} rows={4}
cols={50} cols={50}
onInput={handleMessageInput} onInput={handleMessageInput}
defaultValue={message} defaultValue={messageRef.current}
></textarea> ></textarea>
</div> </div>
</div> </div>

@ -37,6 +37,7 @@ export class Blockchain extends Plugin<any, any> {
setProviderFromEndpoint(target: any, context: any, cb: any): void; setProviderFromEndpoint(target: any, context: any, cb: any): void;
detectNetwork(cb: any): void; detectNetwork(cb: any): void;
getProvider(): any; getProvider(): any;
getInjectedWeb3Address(): any;
/** /**
* return the fork name applied to the current envionment * return the fork name applied to the current envionment
* @return {String} - fork name * @return {String} - fork name

@ -72,6 +72,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d
const isDebugging = useRef<boolean>(false) const isDebugging = useRef<boolean>(false)
const allTests = useRef<string[]>([]) const allTests = useRef<string[]>([])
const selectedTests = useRef<string[]>([]) const selectedTests = useRef<string[]>([])
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 currentErrors:any = useRef([]) // eslint-disable-line @typescript-eslint/no-explicit-any
const defaultPath = 'tests' const defaultPath = 'tests'
@ -104,7 +105,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d
} }
// if current file is changed while debugging and one of the files imported in test file are opened // 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 // 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 = [] allTests.current = []
updateTestFileList() updateTestFileList()
clearResults() clearResults()
@ -394,6 +395,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d
const showTestsResult = () => { const showTestsResult = () => {
const filenames = Object.keys(testsResultByFilename) const filenames = Object.keys(testsResultByFilename)
currentTestFiles.current = filenames
for (const filename of filenames) { for (const filename of filenames) {
const fileTestsResult = testsResultByFilename[filename] const fileTestsResult = testsResultByFilename[filename]
const contracts = Object.keys(fileTestsResult) const contracts = Object.keys(fileTestsResult)

@ -27,7 +27,7 @@ const RenderCall = ({ tx, resolvedData, logs, index, plugin, showTableHash, txDe
<div className="remix_ui_terminal_log" onClick={(event) => txDetails(event, tx)}> <div className="remix_ui_terminal_log" onClick={(event) => txDetails(event, tx)}>
<CheckTxStatus tx={tx} type={txType} /> <CheckTxStatus tx={tx} type={txType} />
<span> <span>
<span className="tx">[call]</span> <span className="remix_ui_terminal_tx">[call]</span>
<div className='remix_ui_terminal_txItem'><span className='remix_ui_terminal_txItemTitle'>from:</span> {from}</div> <div className='remix_ui_terminal_txItem'><span className='remix_ui_terminal_txItemTitle'>from:</span> {from}</div>
<div className='remix_ui_terminal_txItem'><span className='remix_ui_terminal_txItemTitle'>to:</span> {to}</div> <div className='remix_ui_terminal_txItem'><span className='remix_ui_terminal_txItemTitle'>to:</span> {to}</div>
<div className='remix_ui_terminal_txItem'><span className='remix_ui_terminal_txItemTitle'>data:</span> {input}</div> <div className='remix_ui_terminal_txItem'><span className='remix_ui_terminal_txItemTitle'>data:</span> {input}</div>
@ -35,7 +35,7 @@ const RenderCall = ({ tx, resolvedData, logs, index, plugin, showTableHash, txDe
<div className='remix_ui_terminal_buttons'> <div className='remix_ui_terminal_buttons'>
<div className="remix_ui_terminal_debug btn btn-primary btn-sm" onClick={(event) => debug(event, tx)}>Debug</div> <div className="remix_ui_terminal_debug btn btn-primary btn-sm" onClick={(event) => debug(event, tx)}>Debug</div>
</div> </div>
<i className="remix_ui_terminal_terminal_arrow fas fa-angle-down"></i> <i className="remix_ui_terminal_arrow fas fa-angle-down"></i>
</div> </div>
{showTableHash.includes(tx.hash) ? showTable({ {showTableHash.includes(tx.hash) ? showTable({
hash: tx.hash, hash: tx.hash,

@ -608,12 +608,12 @@ const fileAdded = (state: BrowserState, path: string): { [x: string]: Record<str
let files = state.mode === 'browser' ? state.browser.files : state.localhost.files let files = state.mode === 'browser' ? state.browser.files : state.localhost.files
const _path = splitPath(state, path) const _path = splitPath(state, path)
files = _.set(files, _path, { files = _.setWith(files, _path, {
path: path, path: path,
name: extractNameFromKey(path), name: extractNameFromKey(path),
isDirectory: false, isDirectory: false,
type: 'file' type: 'file'
}) }, Object)
return files return files
} }
@ -638,13 +638,13 @@ const removeInputField = (state: BrowserState, path: string): { [x: string]: Rec
if (prevFiles) { if (prevFiles) {
prevFiles.child && prevFiles.child[path + '/' + 'blank'] && delete prevFiles.child[path + '/' + 'blank'] prevFiles.child && prevFiles.child[path + '/' + 'blank'] && delete prevFiles.child[path + '/' + 'blank']
files = _.set(files, _path, { files = _.setWith(files, _path, {
isDirectory: true, isDirectory: true,
path, path,
name: extractNameFromKey(path).indexOf('gist-') === 0 ? extractNameFromKey(path).split('-')[1] : extractNameFromKey(path), name: extractNameFromKey(path).indexOf('gist-') === 0 ? extractNameFromKey(path).split('-')[1] : extractNameFromKey(path),
type: extractNameFromKey(path).indexOf('gist-') === 0 ? 'gist' : 'folder', type: extractNameFromKey(path).indexOf('gist-') === 0 ? 'gist' : 'folder',
child: prevFiles ? prevFiles.child : {} child: prevFiles ? prevFiles.child : {}
}) }, Object)
} }
return files return files
@ -674,7 +674,7 @@ const fetchDirectoryContent = (state: BrowserState, payload: { fileTree, path: s
delete prevFiles.child[deletePath] delete prevFiles.child[deletePath]
} }
} }
files = _.set(files, _path, prevFiles) files = _.setWith(files, _path, prevFiles, Object)
} else if (payload.fileTree && payload.path) { } else if (payload.fileTree && payload.path) {
files = { [payload.path]: normalize(payload.fileTree, payload.path, payload.type) } files = { [payload.path]: normalize(payload.fileTree, payload.path, payload.type) }
} }
@ -703,7 +703,7 @@ const fetchDirectoryContent = (state: BrowserState, payload: { fileTree, path: s
delete prevFiles.child[deletePath] delete prevFiles.child[deletePath]
} }
} }
files = _.set(files, _path, prevFiles) files = _.setWith(files, _path, prevFiles, Object)
} else { } else {
files = { [payload.path]: normalize(payload.fileTree, payload.path, payload.type) } files = { [payload.path]: normalize(payload.fileTree, payload.path, payload.type) }
} }

Loading…
Cancel
Save