Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile details update #4167

Merged
merged 10 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions apps/remix-ide-e2e/src/commands/verifyContracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ function verifyContracts (browser: NightwatchBrowser, compiledContractNames: str
.click('*[data-id="compilation-details"]')
.waitForElementVisible('*[data-id="remixui_treeviewitem_metadata"]')
.pause(2000)
.click('*[data-id="remixui_treeviewitem_metadata"]')
.waitForElementVisible('*[data-id="treeViewDivtreeViewItemcompiler"]')
.pause(2000)
.click('*[data-id="treeViewDivtreeViewItemcompiler"]')
Expand All @@ -43,7 +42,6 @@ function verifyContracts (browser: NightwatchBrowser, compiledContractNames: str
.click('*[data-id="compilation-details"]')
.waitForElementVisible('*[data-id="remixui_treeviewitem_metadata"]')
.pause(2000)
.click('*[data-id="remixui_treeviewitem_metadata"]')
.assert.visible('*[data-id="treeViewDivtreeViewItemsettings"]')
.pause(2000)
.click('*[data-id="treeViewDivtreeViewItemsettings"]')
Expand Down
32 changes: 16 additions & 16 deletions apps/remix-ide-e2e/src/tests/transactionExecution.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ module.exports = {
.clickFunction('inputValue3 - transact (not payable)', { types: 'uint256[] _u', values: '["2.445e10", "13e1"]' })
.waitForElementContainsText('*[data-id="terminalJournal"]', '24450000000', 60000)
.waitForElementContainsText('*[data-id="terminalJournal"]', '130', 60000)
.click('*[data-id="deployAndRunClearInstances"]')
.click('*[data-id="deployAndRunClearInstances"]')
},

'Should Compile and Deploy a contract which define a custom error, the error should be logged in the terminal #group3': function (browser: NightwatchBrowser) {
Expand Down Expand Up @@ -240,7 +240,7 @@ module.exports = {
.waitForElementPresent({
locateStrategy: 'css selector',
selector: 'select[data-id="runTabSelectAccount"] option[value="0xdD870fA1b7C4700F2BD7f44238821C26f7392148"]',
timeout: 240000
timeout: 250000
}) // wait for the udapp to load the list of accounts
.selectContract('MyResolver')
.createContract('')
Expand Down Expand Up @@ -385,7 +385,7 @@ contract C {
content: `// SPDX-License-Identifier: GPL-3.0

pragma solidity ^0.8.7;

/// error description
/// @param a param1
/// @param b param2
Expand All @@ -397,7 +397,7 @@ contract C {
}
function g() public {
revert CustomError(2, 3, "error_string_2");
}
}
}`
}
},
Expand All @@ -406,7 +406,7 @@ contract C {
content: `// SPDX-License-Identifier: GPL-3.0

pragma solidity ^0.8.7;

library lib {
/// error description from library
/// @param a param1 from library
Expand All @@ -415,13 +415,13 @@ contract C {
error CustomError(uint a, uint b, string c);
function set() public {
revert CustomError(48, 46, "error_string_from_library");
}
}
}
}

contract D {
function h() public {
lib.set();
}
}
}`
}
},
Expand All @@ -439,10 +439,10 @@ contract C {
contract Owner {

address private owner;

// event for EVM logging
event OwnerSet(address indexed oldOwner, address indexed newOwner);

// modifier to check if caller is owner
modifier isOwner() {
// If the first argument of 'require' evaluates to 'false', execution terminates and all
Expand All @@ -453,7 +453,7 @@ contract C {
require(msg.sender == owner, "Caller is not owner");
_;
}

/**
* @dev Set contract deployer as owner
*/
Expand All @@ -472,7 +472,7 @@ contract C {
}

/**
* @dev Return owner address
* @dev Return owner address
* @return address of owner
*/
function getOwner() external view returns (address) {
Expand Down Expand Up @@ -507,7 +507,7 @@ contract C {
}

/**
* @dev Return value
* @dev Return value
* @return value of 'number'
*/
function retrieve() public view returns (uint256){
Expand Down Expand Up @@ -539,7 +539,7 @@ contract C {
return resolver.addr(node);
}
}
`
`
}
}, {
"scientific_notation.sol": {
Expand Down Expand Up @@ -571,7 +571,7 @@ contract C {
cake++;
}
}
`
`
}
}
]
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { CopyToClipboard } from '@remix-ui/clipboard'
import { CustomTooltip } from '@remix-ui/helper'
import { TreeView, TreeViewItem } from '@remix-ui/tree-view'
import { ContractPropertyName } from '@remix-ui/solidity-compiler'

import React from 'react'
import { useIntl } from 'react-intl'

Expand Down Expand Up @@ -32,7 +34,7 @@ export function RemixUiCompileDetails({ plugin, contractProperties, selectedCont
</div>
<div className="remixui_detailsJSON">
<TreeView>
{Object.keys(contractProperties).map((propertyName, index) => {
{Object.keys(contractProperties).map((propertyName: ContractPropertyName, index) => {
const copyDetails = (
<span className="remixui_copyDetails">
<CopyToClipboard tip={intl.formatMessage({id: 'solidity.copy'})} content={contractProperties[propertyName]} direction="top" />
Expand All @@ -59,6 +61,8 @@ export function RemixUiCompileDetails({ plugin, contractProperties, selectedCont
{propertyName} {copyDetails} {questionMark}
</div>
}
expand={propertyName === 'metadata' || propertyName === 'bytecode' ? true : false}
iconY='fas fa-caret-down'
>
{insertValue(contractProperties, propertyName)}
</TreeViewItem>
Expand Down
3 changes: 2 additions & 1 deletion libs/remix-ui/solidity-compiler/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './lib/solidity-compiler'
export * from './lib/logic'
export * from './lib/logic/flattenerUtilities'
export * from './lib/api/compiler-api'
export * from './lib/api/compiler-api'
export * from './lib/types'
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, {useState, useEffect} from 'react' // eslint-disable-line
import {FormattedMessage, useIntl} from 'react-intl'
import {ContractSelectionProps} from './types'
import {ContractPropertyName, ContractSelectionProps} from './types'
import {PublishToStorage} from '@remix-ui/publish-to-storage' // eslint-disable-line
import {TreeView, TreeViewItem} from '@remix-ui/tree-view' // eslint-disable-line
import {CopyToClipboard} from '@remix-ui/clipboard' // eslint-disable-line
Expand Down Expand Up @@ -122,7 +122,7 @@ export const ContractSelection = (props: ContractSelectionProps) => {
return ret
}

const insertValue = (details, propertyName) => {
const insertValue = (details, propertyName: ContractPropertyName) => {
let node
if (propertyName === 'web3Deploy' || propertyName === 'name' || propertyName === 'Assembly') {
node = <pre>{details[propertyName]}</pre>
Expand Down Expand Up @@ -197,7 +197,7 @@ export const ContractSelection = (props: ContractSelectionProps) => {
const log = (
<div className="remixui_detailsJSON">
<TreeView>
{Object.keys(contractProperties).map((propertyName, index) => {
{Object.keys(contractProperties).map((propertyName: ContractPropertyName, index) => {
const copyDetails = (
<span className="remixui_copyDetails">
<CopyToClipboard tip={intl.formatMessage({id: 'solidity.copy'})} content={contractProperties[propertyName]} direction="top" />
Expand Down
4 changes: 4 additions & 0 deletions libs/remix-ui/solidity-compiler/src/lib/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,7 @@ export interface CompilationDetails {
export interface ContractsFile {
[currentFile: string]: CompilationDetails
}

export type ContractPropertyName = 'compilerInput' | 'name' | 'metadata' | 'bytecode' | 'abi' | 'storageLayout'
| 'web3Deploy' | 'metadataHash' | 'functionHashes' | 'gasEstimates' | 'devdoc' | 'userdoc' | 'Runtime Bytecode'
| 'Assembly'
Loading