Merge branch 'master' into ppmm

pull/2826/head
Aniket 2 years ago committed by GitHub
commit 1a232614a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 45
      apps/remix-ide-e2e/src/tests/erc721.test.ts
  2. 4
      libs/remix-lib/src/execution/txListener.ts
  3. 25
      libs/remix-lib/src/util.ts
  4. 1
      libs/remix-lib/test/data/ERC721.ts
  5. 1
      libs/remix-lib/test/data/sampleERC721.ts
  6. 24
      libs/remix-lib/test/util.ts
  7. 2
      libs/remix-ui/debugger-ui/src/lib/debugger-ui.css
  8. 4
      libs/remix-ui/debugger-ui/src/lib/vm-debugger/styles/dropdown-panel.css
  9. 17
      libs/remix-ui/debugger-ui/src/lib/vm-debugger/vm-debugger.tsx

@ -0,0 +1,45 @@
'use strict'
import { NightwatchBrowser } from 'nightwatch'
import init from '../helpers/init'
const sources = []
module.exports = {
before: function (browser: NightwatchBrowser, done: VoidFunction) {
init(browser, done)
},
'@sources': function () {
return sources
},
'Deploy SampleERC721 whose bytecode is very similar to ERC721': function (browser: NightwatchBrowser) {
browser.clickLaunchIcon('filePanel')
.click('*[data-id="workspaceCreate"]')
// create contract
.waitForElementVisible('*[data-id="modalDialogCustomPromptTextCreate"]')
.waitForElementVisible('[data-id="fileSystemModalDialogModalFooter-react"] > button')
// eslint-disable-next-line dot-notation
.execute(function () { document.querySelector('*[data-id="modalDialogCustomPromptTextCreate"]')['value'] = 'workspace_erc721' })
.click('select[id="wstemplate"]')
.click('select[id="wstemplate"] option[value=ozerc721]')
.waitForElementPresent('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok')
.execute(function () { (document.querySelector('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') as HTMLElement).click() })
.pause(100)
.waitForElementVisible('*[data-id="treeViewLitreeViewItemcontracts"]')
.waitForElementVisible('*[data-id="treeViewLitreeViewItemcontracts/SampleERC721.sol"]')
.openFile('contracts/SampleERC721.sol')
.verifyContracts(['SampleERC721'])
// deploy contract
.clickLaunchIcon('udapp')
.selectContract('SampleERC721')
.createContract('E,E')
.testFunction('last',
{
status: 'true Transaction mined and execution succeed',
'decoded input': {
'string tokenName': 'E',
'string tokenSymbol': 'E'
}
}).end()
}
}

@ -2,7 +2,7 @@
import { ethers } from 'ethers'
import { toBuffer, addHexPrefix } from 'ethereumjs-util'
import { EventManager } from '../eventManager'
import { compareByteCode } from '../util'
import { compareByteCode, getinputParameters } from '../util'
import { decodeResponse } from './txFormat'
import { getFunction, getReceiveInterface, getConstructorInterface, visitContracts, makeFullTypeDefinition } from './txHelper'
@ -352,7 +352,7 @@ export class TxListener {
const bytecode = contract.object.evm.bytecode.object
let params = null
if (bytecode && bytecode.length) {
params = this._decodeInputParams(inputData.substring(bytecode.length), getConstructorInterface(abi))
params = this._decodeInputParams(getinputParameters(inputData), getConstructorInterface(abi))
}
this._resolvedTransactions[tx.hash] = {
contractName: contract.name,

@ -184,6 +184,15 @@ export function cborEncodedValueExtraction () {
return /64697066735822([0-9a-f]{68})64736f6c6343([0-9a-f]{6})0033$/
}
/**
* return a regex which extract the input parameters from the bytecode
*
* @return {RegEx}
*/
export function inputParametersExtraction () {
return /64697066735822[0-9a-f]{68}64736f6c6343[0-9a-f]{6}0033(.*)$/
}
export function extractcborMetadata (value) {
return value.replace(cborEncodedValueExtraction(), '')
}
@ -195,6 +204,18 @@ export function extractSwarmHash (value) {
return value
}
export function extractinputParameters (value) {
return value.replace(inputParametersExtraction(), '')
}
export function getinputParameters (value) {
const regex = value.match(inputParametersExtraction())
if (regex && regex[1]) {
return regex[1]
} else
return ''
}
/**
* Compare bytecode. return true if the code is equal (handle swarm hash and library references)
* @param {String} code1 - the bytecode that is actually deployed (contains resolved library reference and a potentially different swarmhash)
@ -218,14 +239,16 @@ export function compareByteCode (code1, code2) {
code2 = replaceLibReference(code2, pos)
code1 = replaceLibReference(code1, pos)
}
code1 = extractinputParameters(code1)
code1 = extractSwarmHash(code1)
code1 = extractcborMetadata(code1)
code2 = extractinputParameters(code2)
code2 = extractSwarmHash(code2)
code2 = extractcborMetadata(code2)
if (code1 && code2) {
const compare = stringSimilarity.compareTwoStrings(code1, code2)
return compare > 0.93
return compare == 1
}
return false

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -18,6 +18,6 @@
overflow-wrap: break-word;
}
.debuggerPanels {
overflow-y: scroll;
overflow-y: auto;
height: fit-content;
}

@ -4,10 +4,14 @@
}
.name {
font-weight: bold;
overflow: hidden;
text-overflow: ellipsis;
}
.nameDetail {
font-weight: bold;
margin-left: 3px;
overflow: hidden;
text-overflow: ellipsis;
}
.icon {
margin-right: 5%;

@ -53,7 +53,14 @@ export const VmDebugger = ({ vmDebugger: { registerEvent }, currentBlock, curren
return (
<div id='vmdebugger' className="d-flex">
<div className='d-flex flex-column px-2 pr-2' style={{ flex: 1 }}>
<div
className='d-flex flex-column px-2 pr-2'
style={{
flex: 1,
overflow: "hidden",
textOverflow: "ellipsis"
}}
>
<CallstackPanel className="pb-1" calldata={callStackPanel} />
<StackPanel className="pb-1" calldata={stackPanel} />
<MemoryPanel className="pb-1" calldata={memoryPanel} />
@ -61,7 +68,13 @@ export const VmDebugger = ({ vmDebugger: { registerEvent }, currentBlock, curren
<ReturnValuesPanel className="pb-1" dropdownName='Return Value' calldata={returnValuesPanel || {}} />
<GlobalVariables className="pb-1" block={currentBlock} receipt={currentReceipt} tx={currentTransaction} />
</div>
<div className='d-flex flex-column px-2 pl-2' style={{ flex: 1 }}>
<div className='d-flex flex-column px-2 pl-2'
style={{
flex: 1,
overflow: "hidden",
textOverflow: "ellipsis"
}}
>
<FullStoragesChangesPanel className="pb-1" calldata={fullStoragesChangesPanel} />
<CalldataPanel className="pb-1" calldata={calldataPanel} />
</div>

Loading…
Cancel
Save