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)
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')

@ -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)
}

@ -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

@ -50,6 +50,10 @@ export class ExecutionContext {
return this.executionContext
}
getSelectedAddress () {
return injectedProvider ? injectedProvider.selectedAddress : null
}
getCurrentFork () {
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))
}).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: '<at address>' })
}
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: '<at address>' })
} 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()

@ -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}
></textarea>
</div>
</div>

@ -37,6 +37,7 @@ export class Blockchain extends Plugin<any, any> {
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

@ -72,6 +72,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => { // eslint-d
const isDebugging = useRef<boolean>(false)
const allTests = 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 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
// 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<string, any>) => { // 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)

@ -27,7 +27,7 @@ const RenderCall = ({ tx, resolvedData, logs, index, plugin, showTableHash, txDe
<div className="remix_ui_terminal_log" onClick={(event) => txDetails(event, tx)}>
<CheckTxStatus tx={tx} type={txType} />
<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'>to:</span> {to}</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_debug btn btn-primary btn-sm" onClick={(event) => debug(event, tx)}>Debug</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>
{showTableHash.includes(tx.hash) ? showTable({
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
const _path = splitPath(state, path)
files = _.set(files, _path, {
files = _.setWith(files, _path, {
path: path,
name: extractNameFromKey(path),
isDirectory: false,
type: 'file'
})
}, Object)
return files
}
@ -638,13 +638,13 @@ const removeInputField = (state: BrowserState, path: string): { [x: string]: Rec
if (prevFiles) {
prevFiles.child && prevFiles.child[path + '/' + 'blank'] && delete prevFiles.child[path + '/' + 'blank']
files = _.set(files, _path, {
files = _.setWith(files, _path, {
isDirectory: true,
path,
name: extractNameFromKey(path).indexOf('gist-') === 0 ? extractNameFromKey(path).split('-')[1] : extractNameFromKey(path),
type: extractNameFromKey(path).indexOf('gist-') === 0 ? 'gist' : 'folder',
child: prevFiles ? prevFiles.child : {}
})
}, Object)
}
return files
@ -674,7 +674,7 @@ const fetchDirectoryContent = (state: BrowserState, payload: { fileTree, path: s
delete prevFiles.child[deletePath]
}
}
files = _.set(files, _path, prevFiles)
files = _.setWith(files, _path, prevFiles, Object)
} else if (payload.fileTree && payload.path) {
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]
}
}
files = _.set(files, _path, prevFiles)
files = _.setWith(files, _path, prevFiles, Object)
} else {
files = { [payload.path]: normalize(payload.fileTree, payload.path, payload.type) }
}

Loading…
Cancel
Save