Skip to content
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
4 changes: 2 additions & 2 deletions apps/remix-ide-e2e/src/tests/generalSettings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ module.exports = {
.click('*[data-id="compilerContainerCompileBtn"]')
.pause(3000)
.click('*[data-id="verticalIconsKindfilePanel"]')
.openFile('contracts/artifacts/Ballot.json')
.openFile('contracts/artifacts/Ballot_metadata.json')
.openFile('artifacts/Ballot.json')
.openFile('artifacts/Ballot_metadata.json')
.getEditorValue((content) => {
const metadata = JSON.parse(content)
browser.assert.equal(metadata.language, 'Solidity')
Expand Down
4 changes: 2 additions & 2 deletions apps/remix-ide-e2e/src/tests/migrateFileSystem.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ module.exports = {
},
'Should have an artifacts file with JSON test data #group1 #group3 #group5 #group7': function (browser: NightwatchBrowser) {
browser.waitForElementVisible('*[data-id="remixIdeSidePanel"]', 5000)
.click('*[data-id="treeViewLitreeViewItemtest_contracts/artifacts"]')
.openFile('test_contracts/artifacts/Storage_metadata.json')
.click('*[data-id="treeViewLitreeViewItemartifacts"]')
.openFile('artifacts/Storage_metadata.json')
.waitForElementVisible('*[id="editorView"]', 10000)
.getEditorValue((content) => {
const metadata = JSON.parse(content)
Expand Down
2 changes: 1 addition & 1 deletion apps/remix-ide-e2e/src/tests/script-runner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ const deploy = async (contractName: string, args: Array<any>, accountIndex?: num
console.log(\`deploying \${contractName}\`)
// Note that the script needs the ABI which is generated from the compilation artifact.
// Make sure contract is compiled and artifacts are generated
const artifactsPath = \`contracts/artifacts/\${contractName}.json\` // Change this for different path
const artifactsPath = \`artifacts/\${contractName}.json\` // Change this for different path

const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath))
// 'web3Provider' is a remix global variable object
Expand Down
4 changes: 2 additions & 2 deletions apps/remix-ide-e2e/src/tests/search.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ module.exports = {
.clearValue('*[id="search_include"]').pause(2000)
.setValue('*[id="search_include"]', '**').sendKeys('*[id="search_include"]', browser.Keys.ENTER).pause(4000)
.elements('css selector', '.search_plugin_search_line', (res) => {
Array.isArray(res.value) && browser.assert.equal(res.value.length, 63)
Array.isArray(res.value) && browser.assert.equal(res.value.length, 61)
})
.setValue('*[id="search_exclude"]', ',contracts/**').sendKeys('*[id="search_exclude"]', browser.Keys.ENTER).pause(4000)
.elements('css selector', '.search_plugin_search_line', (res) => {
Array.isArray(res.value) && browser.assert.equal(res.value.length, 56)
Array.isArray(res.value) && browser.assert.equal(res.value.length, 54)
})
.clearValue('*[id="search_include"]').setValue('*[id="search_include"]', '*.sol, *.js, *.txt')
.clearValue('*[id="search_exclude"]').setValue('*[id="search_exclude"]', '.*/**/*')
Expand Down
16 changes: 8 additions & 8 deletions apps/remix-ide-e2e/src/tests/terminal.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ const deployWithEthersJs = `

// Note that the script needs the ABI which is generated from the compilation artifact.
// Make sure contract is compiled and artifacts are generated
const artifactsPath = 'contracts/artifacts/Owner.json' // Change this for different path
const artifactsPath = 'artifacts/Owner.json' // Change this for different path

const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath))
// 'web3Provider' is a remix global variable object
Expand Down Expand Up @@ -555,7 +555,7 @@ const { expect } = require("chai");
describe("Storage with lib", function () {
it("test initial value", async function () {
// Make sure contract is compiled and artifacts are generated
const metadata = JSON.parse(await remix.call('fileManager', 'getFile', 'contracts/artifacts/Storage.json'))
const metadata = JSON.parse(await remix.call('fileManager', 'getFile', 'artifacts/Storage.json'))
const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner()
let Storage = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer)
let storage = await Storage.deploy();
Expand All @@ -565,7 +565,7 @@ describe("Storage with lib", function () {
});

it("test updating and retrieving updated value", async function () {
const metadata = JSON.parse(await remix.call('fileManager', 'getFile', 'contracts/artifacts/Storage.json'))
const metadata = JSON.parse(await remix.call('fileManager', 'getFile', 'artifacts/Storage.json'))
const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner()
let Storage = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer)
let storage = await Storage.deploy();
Expand All @@ -576,7 +576,7 @@ describe("Storage with lib", function () {
});

it("fail test updating and retrieving updated value", async function () {
const metadata = JSON.parse(await remix.call('fileManager', 'getFile', 'contracts/artifacts/Storage.json'))
const metadata = JSON.parse(await remix.call('fileManager', 'getFile', 'artifacts/Storage.json'))
const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner()
let Storage = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer)
let storage = await Storage.deploy();
Expand Down Expand Up @@ -633,7 +633,7 @@ const { ethers } = require("hardhat");

describe("Storage", function () {
it("test library integration by calling a lib method", async function () {
const metadataLib = JSON.parse(await remix.call('fileManager', 'readFile', 'contracts/artifacts/Lib.json'))
const metadataLib = JSON.parse(await remix.call('fileManager', 'readFile', 'artifacts/Lib.json'))
console.log('deploying lib:')
const artifactLib = {
contractName: 'Lib',
Expand All @@ -650,7 +650,7 @@ describe("Storage", function () {
const lib = await factoryLib.deploy();
await lib.deployed()

const metadata = JSON.parse(await remix.call('fileManager', 'readFile', 'contracts/artifacts/StorageWithLib.json'))
const metadata = JSON.parse(await remix.call('fileManager', 'readFile', 'artifacts/StorageWithLib.json'))
const artifact = {
contractName: 'StorageWithLib',
sourceName: 'contracts/StorageWithLib.sol',
Expand Down Expand Up @@ -786,7 +786,7 @@ const scriptAutoExec = {

// function getContractFactoryFromArtifact(artifact: Artifact, factoryOptions: FactoryOptions): Promise<ethers.ContractFactory>;

const metadataLib = JSON.parse(await remix.call('fileManager', 'readFile', 'contracts/artifacts/lib.json'))
const metadataLib = JSON.parse(await remix.call('fileManager', 'readFile', 'artifacts/lib.json'))
console.log('deploying lib:')

const artifactLib = {
Expand All @@ -808,7 +808,7 @@ const scriptAutoExec = {

console.log('lib deployed', lib.address)

const metadata = JSON.parse(await remix.call('fileManager', 'readFile', 'contracts/artifacts/Storage.json'))
const metadata = JSON.parse(await remix.call('fileManager', 'readFile', 'artifacts/Storage.json'))
const artifact = {
contractName: 'Storage',
sourceName: 'contracts/1_Storage.sol',
Expand Down
13 changes: 13 additions & 0 deletions apps/remix-ide-e2e/src/tests/transactionExecution.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import { NightwatchBrowser } from 'nightwatch'
import init from '../helpers/init'
import { JsonRpcProvider } from 'ethers'

const branch = process.env.CIRCLE_BRANCH;
const isMasterBranch = branch === 'master';
const runMasterTests: boolean = (branch ? (isMasterBranch ? true : false) : true)

module.exports = {
'@disabled': true,
before: function (browser: NightwatchBrowser, done: VoidFunction) {
Expand Down Expand Up @@ -239,6 +243,9 @@ module.exports = {
},

'Should switch to the mainnet VM fork and execute a tx to query ENS #group5': function (browser: NightwatchBrowser) {
if (!runMasterTests) {
return
}
let addressRef
browser
.addFile('mainnet_ens.sol', sources[7]['mainnet_ens.sol'])
Expand Down Expand Up @@ -267,6 +274,9 @@ module.exports = {
},

'Should stay connected in the mainnet VM fork and execute state changing operations and non state changing operations #group5': function (browser: NightwatchBrowser) {
if (!runMasterTests) {
return
}
let addressRef
browser
.click('*[data-id="deployAndRunClearInstances"]') // clear udapp instances
Expand Down Expand Up @@ -312,6 +322,9 @@ module.exports = {
},

'Should stay connected to mainnet VM fork and: check the block number is advancing and is not low #group5': function (browser: NightwatchBrowser) {
if (!runMasterTests) {
return
}
/*
Should stay connected in the mainnet VM fork and:
- check the block number has been set to the current mainnet block number.
Expand Down
31 changes: 13 additions & 18 deletions apps/remix-ide-e2e/src/tests/url.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,8 @@ module.exports = {
.refreshPage()
.pause(2000)
.currentWorkspaceIs('code-sample')
.waitForElementVisible('*[data-id=treeViewLitreeViewItemmainnet]')
.waitForElementVisible('*[data-id="treeViewLitreeViewItemmainnet/0xdac17f958d2ee523a2206206994597c13d831ec7"]')
.waitForElementVisible('*[data-id="treeViewLitreeViewItemmainnet/0xdac17f958d2ee523a2206206994597c13d831ec7/TetherToken.sol"]')
.click('*[data-id="treeViewLitreeViewItemmainnet/0xdac17f958d2ee523a2206206994597c13d831ec7/TetherToken.sol"]')
.waitForElementVisible('*[data-id="treeViewLitreeViewItemTetherToken.sol"]')
.click('*[data-id="treeViewLitreeViewItemTetherToken.sol"]')
.getEditorValue((content) => {
browser.assert.ok(content && content.indexOf(
'contract TetherToken is Pausable, StandardToken, BlackList {') !== -1)
Expand All @@ -114,8 +112,7 @@ module.exports = {
.refreshPage()
.pause(7000)
.currentWorkspaceIs('code-sample')
.assert.elementPresent('*[data-id="treeViewLitreeViewItemeth.blockscout.com"]')
.assert.elementPresent('*[data-id="treeViewLitreeViewItemeth.blockscout.com/0xdAC17F958D2ee523a2206206994597C13D831ec7"]')
.assert.elementPresent('*[data-id="treeViewLitreeViewItemTetherToken.sol"]')
.getEditorValue((content) => {
browser.assert.ok(content && content.indexOf(
'contract TetherToken is Pausable, StandardToken, BlackList {') !== -1)
Expand All @@ -129,18 +126,16 @@ module.exports = {
.refreshPage()
.pause(7000)
.currentWorkspaceIs('code-sample')
.assert.elementPresent('*[data-id="treeViewLitreeViewItemeth.blockscout.com"]')
.assert.elementPresent('*[data-id="treeViewLitreeViewItemeth.blockscout.com/0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9"]')
.assert.elementPresent('*[data-id="treeViewLitreeViewItemeth.blockscout.com/0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9/contracts"]')
.assert.elementPresent('*[data-id="treeViewLitreeViewItemeth.blockscout.com/0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9/contracts/open-zeppelin"]')
.assert.elementPresent('*[data-id="treeViewLitreeViewItemeth.blockscout.com/0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9/contracts/open-zeppelin/Address.sol"]')
.assert.elementPresent('*[data-id="treeViewLitreeViewItemeth.blockscout.com/0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9/contracts/open-zeppelin/BaseAdminUpgradeabilityProxy.sol"]')
.assert.elementPresent('*[data-id="treeViewLitreeViewItemeth.blockscout.com/0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9/contracts/open-zeppelin/BaseUpgradeabilityProxy.sol"]')
.assert.elementPresent('*[data-id="treeViewLitreeViewItemeth.blockscout.com/0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9/contracts/open-zeppelin/InitializableAdminUpgradeabilityProxy.sol"]')
.assert.elementPresent('*[data-id="treeViewLitreeViewItemeth.blockscout.com/0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9/contracts/open-zeppelin/InitializableUpgradeabilityProxy.sol"]')
.assert.elementPresent('*[data-id="treeViewLitreeViewItemeth.blockscout.com/0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9/contracts/open-zeppelin/Proxy.sol"]')
.assert.elementPresent('*[data-id="treeViewLitreeViewItemeth.blockscout.com/0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9/contracts/open-zeppelin/UpgradeabilityProxy.sol"]')
.openFile('eth.blockscout.com/0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9/contracts/open-zeppelin/InitializableAdminUpgradeabilityProxy.sol')
.assert.elementPresent('*[data-id="treeViewLitreeViewItemcontracts"]')
.assert.elementPresent('*[data-id="treeViewLitreeViewItemcontracts/open-zeppelin"]')
.assert.elementPresent('*[data-id="treeViewLitreeViewItemcontracts/open-zeppelin/Address.sol"]')
.assert.elementPresent('*[data-id="treeViewLitreeViewItemcontracts/open-zeppelin/BaseAdminUpgradeabilityProxy.sol"]')
.assert.elementPresent('*[data-id="treeViewLitreeViewItemcontracts/open-zeppelin/BaseUpgradeabilityProxy.sol"]')
.assert.elementPresent('*[data-id="treeViewLitreeViewItemcontracts/open-zeppelin/InitializableAdminUpgradeabilityProxy.sol"]')
.assert.elementPresent('*[data-id="treeViewLitreeViewItemcontracts/open-zeppelin/InitializableUpgradeabilityProxy.sol"]')
.assert.elementPresent('*[data-id="treeViewLitreeViewItemcontracts/open-zeppelin/Proxy.sol"]')
.assert.elementPresent('*[data-id="treeViewLitreeViewItemcontracts/open-zeppelin/UpgradeabilityProxy.sol"]')
.openFile('open-zeppelin/InitializableAdminUpgradeabilityProxy.sol')
.getEditorValue((content) => {
browser.assert.ok(content && content.indexOf(
'contract InitializableAdminUpgradeabilityProxy is BaseAdminUpgradeabilityProxy, InitializableUpgradeabilityProxy {') !== -1)
Expand Down
4 changes: 2 additions & 2 deletions apps/remix-ide/src/app/files/filesystems/fileSystemUtility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,9 @@ export const migrationTestData = {
'.workspaces/workspace_test/test_contracts/1_Storage.sol': {
content: 'testing'
},
'.workspaces/workspace_test/test_contracts/artifacts': {
'.workspaces/workspace_test/artifacts': {
children: {
'.workspaces/workspace_test/test_contracts/artifacts/Storage_metadata.json': {
'.workspaces/workspace_test/artifacts/Storage_metadata.json': {
content: '{ "test": "data" }'
}
}
Expand Down
15 changes: 15 additions & 0 deletions libs/remix-core-plugin/src/lib/compiler-fetch-and-compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,21 @@ export class FetchAndCompile extends Plugin {
}
}
const { config, compilationTargets, version } = data
/*
* If the remappings are defined in the config, we need to update them to point to the targetPath
* it's beeing disabled for the moment.
*/
/*if (config && config.settings && config.settings.remappings) {
console.log(config.settings.remappings)
config.settings.remappings = config.settings.remappings.map((remapping) => {
let [virtual, path] = remapping.split('=')
if (virtual.includes(':')) {
let [scope, path] = virtual.split(':')
virtual = `${targetPath}/${scope}:${path}`
}
return `${virtual}=${targetPath}/${path}`
})
}*/

try {
setTimeout(_ => this.emit('compiling', config.settings), 0)
Expand Down
8 changes: 4 additions & 4 deletions libs/remix-core-plugin/src/lib/compiler-metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ export class CompilerMetadata extends Plugin {
}

_JSONFileName (path, contractName) {
return this.joinPath(path, this.innerPath, contractName + '.json')
return this.joinPath(this.innerPath, contractName + '.json')
}

_MetadataFileName (path, contractName) {
return this.joinPath(path, this.innerPath, contractName + '_metadata.json')
return this.joinPath(this.innerPath, contractName + '_metadata.json')
}

onActivation () {
Expand All @@ -53,7 +53,7 @@ export class CompilerMetadata extends Plugin {
// Access each file in build-info, check the input sources
// If they are all same as in current compiled file and sources includes the path of compiled file, remove old build file
async removeStoredBuildInfo (currentInput, path, filePath) {
const buildDir = this.joinPath(path, this.innerPath, 'build-info/')
const buildDir = this.joinPath(this.innerPath, 'build-info/')
if (await this.call('fileManager', 'exists', buildDir)) {
const allBuildFiles = await this.call('fileManager', 'fileList', buildDir)
const currentInputFileNames = Object.keys(currentInput.sources)
Expand All @@ -79,7 +79,7 @@ export class CompilerMetadata extends Plugin {
input
})
const id = createHash('md5').update(Buffer.from(json)).digest().toString('hex')
const buildFilename = this.joinPath(path, this.innerPath, 'build-info/' + id + '.json')
const buildFilename = this.joinPath(this.innerPath, 'build-info/' + id + '.json')
// If there are no file in buildInfoNames,it means compilation is running first time after loading Remix
if (!this.buildInfoNames[filePath]) {
// Check the existing build-info and delete all the previous build files for compiled file
Expand Down
6 changes: 5 additions & 1 deletion libs/remix-core-plugin/src/lib/helpers/fetch-blockscout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ export const fetchContractFromBlockscout = async (plugin, endpoint, contractAddr
return null
}

if (data.result[0].FileName === '') {
if (data.result[0].FileName === '.sol' && data.result[0].ContractName) {
Copy link
Collaborator

@ioedeveloper ioedeveloper Jun 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this an error data.result[0].FileName === '.sol'? or do you meant data.result[0].FileName.endsWith('.sol')

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intended, this API isn't really consistent and in my test case the filename returned by the API ia .sol

const fileName = `${targetPath}/${data.result[0].ContractName}.sol`
if (shouldSetFile) await plugin.call('fileManager', 'setFile', fileName, data.result[0].SourceCode)
compilationTargets[fileName] = { content: data.result[0].SourceCode }
} else if (data.result[0].FileName === '') {
const fileName = `${targetPath}/${data.result[0].ContractName}.sol`
if (shouldSetFile) await plugin.call('fileManager', 'setFile', fileName, data.result[0].SourceCode)
compilationTargets[fileName] = { content: data.result[0].SourceCode }
Expand Down
14 changes: 11 additions & 3 deletions libs/remix-core-plugin/src/lib/helpers/fetch-etherscan.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
export const fetchContractFromEtherscan = async (plugin, network, contractAddress, targetPath, shouldSetFile = true, etherscanKey?) => {

export type Network = {
id: number
name: string
}

export const fetchContractFromEtherscan = async (plugin, endpoint: string | Network, contractAddress, targetPath, shouldSetFile = true, etherscanKey?) => {
let data
const compilationTargets = {}
if (!etherscanKey) etherscanKey = await plugin.call('config', 'getAppParameter', 'etherscan-access-token')
if (!etherscanKey) etherscanKey = '2HKUX5ZVASZIKWJM8MIQVCRUVZ6JAWT531'

if (etherscanKey) {
const endpoint = network.id == 1 ? 'api.etherscan.io' : 'api-' + network.name + '.etherscan.io'
if (typeof endpoint === 'object' && endpoint !== null && 'id' in endpoint && 'name' in endpoint) {
endpoint = endpoint.id == 1 ? 'api.etherscan.io' : 'api-' + endpoint.name + '.etherscan.io'
}
try {
data = await fetch('https://' + endpoint + '/api?module=contract&action=getsourcecode&address=' + contractAddress + '&apikey=' + etherscanKey)
data = await data.json()
// etherscan api doc https://docs.etherscan.io/api-endpoints/contracts
if (data.message === 'OK' && data.status === "1") {
if (data.result.length) {
if (data.result[0].SourceCode === '') throw new Error(`contract not verified on Etherscan ${network.name} network`)
if (data.result[0].SourceCode === '') throw new Error(`contract not verified on Etherscan ${endpoint}`)
if (data.result[0].SourceCode.startsWith('{')) {
data.result[0].SourceCode = JSON.parse(data.result[0].SourceCode.replace(/(?:\r\n|\r|\n)/g, '').replace(/^{{/, '{').replace(/}}$/, '}'))
}
Expand Down
Loading