From c68525285856c3584e6704f63767d98e180cce93 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Tue, 22 Jun 2021 17:08:02 +0200 Subject: [PATCH 01/17] rm registry from compiler files add core plugins mv content imports and compiler artefacts mv utils mv compiler helpers mv compiler abstract rm compiler input mv all to solidity mv fetch and compile fixed imports mv offset line converter url resolver fix await calls packages package location versions func can be undefined window can be undefined settings dependency for contentimport undefined window --- apps/remix-ide/src/app.js | 18 +-- .../src/app/compiler/compiler-abstract.js | 46 ------- .../src/app/compiler/compiler-input.js | 21 --- .../src/app/files/compiler-metadata.js | 2 +- apps/remix-ide/src/app/files/fileProvider.js | 4 +- apps/remix-ide/src/app/tabs/compile-tab.js | 2 +- .../app/tabs/compileTab/compilerContainer.js | 2 +- .../app/tabs/runTab/model/dropdownlogic.js | 2 +- apps/remix-ide/src/app/tabs/test-tab.js | 3 +- .../src/app/ui/landing-page/landing-page.js | 4 +- apps/remix-ide/src/lib/cmdInterpreterAPI.js | 4 +- .../compiler-artefacts/.eslintrc | 1 + .../compiler-artefacts/README.md | 3 + .../compiler-artefacts/package.json | 11 ++ .../compiler-artefacts/src/index.ts | 1 + .../src/lib/compiler-artefacts.ts | 11 +- .../compiler-artefacts/tsconfig.json | 10 ++ .../compiler-artefacts/tsconfig.lib.json | 12 ++ .../compiler-content-imports/.eslintrc | 1 + .../compiler-content-imports/README.md | 3 + .../compiler-content-imports/package.json | 11 ++ .../compiler-content-imports/src/index.ts | 1 + .../src/lib/compiler-content-imports.ts | 39 +++--- .../compiler-content-imports/tsconfig.json | 10 ++ .../tsconfig.lib.json | 12 ++ .../compiler-fetch-and-compile/.eslintrc | 1 + .../compiler-fetch-and-compile/README.md | 3 + .../compiler-fetch-and-compile/package.json | 11 ++ .../compiler-fetch-and-compile/src/index.ts | 1 + .../src/lib/compiler-fetch-and-compile.ts | 28 ++-- .../compiler-fetch-and-compile/tsconfig.json | 10 ++ .../tsconfig.lib.json | 12 ++ .../offset-line-to-column-converter/.eslintrc | 1 + .../offset-line-to-column-converter/README.md | 3 + .../package.json | 11 ++ .../src/index.ts | 1 + .../lib/offset-line-to-column-converter.ts | 77 +++++++++++ .../tsconfig.json | 10 ++ .../tsconfig.lib.json | 12 ++ libs/remix-debug/src/eventManager.ts | 2 +- libs/remix-lib/src/eventManager.ts | 2 +- .../src/compiler/compiler-abstract.ts | 48 +++++++ .../src/compiler/compiler-helpers.ts | 4 +- .../src/compiler/compiler-utils.ts | 0 libs/remix-solidity/src/index.ts | 3 + libs/remix-solidity/src/lib/eventManager.ts | 2 +- nx.json | 13 ++ package-lock.json | 6 + tsconfig.json | 14 +- workspace.json | 121 ++++++++++++++++++ 50 files changed, 501 insertions(+), 129 deletions(-) delete mode 100644 apps/remix-ide/src/app/compiler/compiler-abstract.js delete mode 100644 apps/remix-ide/src/app/compiler/compiler-input.js create mode 100644 libs/remix-core-plugin/compiler-artefacts/.eslintrc create mode 100644 libs/remix-core-plugin/compiler-artefacts/README.md create mode 100644 libs/remix-core-plugin/compiler-artefacts/package.json create mode 100644 libs/remix-core-plugin/compiler-artefacts/src/index.ts rename apps/remix-ide/src/app/compiler/compiler-artefacts.js => libs/remix-core-plugin/compiler-artefacts/src/lib/compiler-artefacts.ts (92%) create mode 100644 libs/remix-core-plugin/compiler-artefacts/tsconfig.json create mode 100644 libs/remix-core-plugin/compiler-artefacts/tsconfig.lib.json create mode 100644 libs/remix-core-plugin/compiler-content-imports/.eslintrc create mode 100644 libs/remix-core-plugin/compiler-content-imports/README.md create mode 100644 libs/remix-core-plugin/compiler-content-imports/package.json create mode 100644 libs/remix-core-plugin/compiler-content-imports/src/index.ts rename apps/remix-ide/src/app/compiler/compiler-imports.js => libs/remix-core-plugin/compiler-content-imports/src/lib/compiler-content-imports.ts (84%) create mode 100644 libs/remix-core-plugin/compiler-content-imports/tsconfig.json create mode 100644 libs/remix-core-plugin/compiler-content-imports/tsconfig.lib.json create mode 100644 libs/remix-core-plugin/compiler-fetch-and-compile/.eslintrc create mode 100644 libs/remix-core-plugin/compiler-fetch-and-compile/README.md create mode 100644 libs/remix-core-plugin/compiler-fetch-and-compile/package.json create mode 100644 libs/remix-core-plugin/compiler-fetch-and-compile/src/index.ts rename apps/remix-ide/src/app/compiler/compiler-sourceVerifier-fetchAndCompile.js => libs/remix-core-plugin/compiler-fetch-and-compile/src/lib/compiler-fetch-and-compile.ts (80%) create mode 100644 libs/remix-core-plugin/compiler-fetch-and-compile/tsconfig.json create mode 100644 libs/remix-core-plugin/compiler-fetch-and-compile/tsconfig.lib.json create mode 100644 libs/remix-core-plugin/offset-line-to-column-converter/.eslintrc create mode 100644 libs/remix-core-plugin/offset-line-to-column-converter/README.md create mode 100644 libs/remix-core-plugin/offset-line-to-column-converter/package.json create mode 100644 libs/remix-core-plugin/offset-line-to-column-converter/src/index.ts create mode 100644 libs/remix-core-plugin/offset-line-to-column-converter/src/lib/offset-line-to-column-converter.ts create mode 100644 libs/remix-core-plugin/offset-line-to-column-converter/tsconfig.json create mode 100644 libs/remix-core-plugin/offset-line-to-column-converter/tsconfig.lib.json create mode 100644 libs/remix-solidity/src/compiler/compiler-abstract.ts rename apps/remix-ide/src/app/compiler/compiler-helpers.js => libs/remix-solidity/src/compiler/compiler-helpers.ts (89%) rename apps/remix-ide/src/app/compiler/compiler-utils.js => libs/remix-solidity/src/compiler/compiler-utils.ts (100%) diff --git a/apps/remix-ide/src/app.js b/apps/remix-ide/src/app.js index 8beeae8849..323ec0ba86 100644 --- a/apps/remix-ide/src/app.js +++ b/apps/remix-ide/src/app.js @@ -16,7 +16,11 @@ import { HiddenPanel } from './app/components/hidden-panel' import { VerticalIcons } from './app/components/vertical-icons' import { LandingPage } from './app/ui/landing-page/landing-page' import { MainPanel } from './app/components/main-panel' -import FetchAndCompile from './app/compiler/compiler-sourceVerifier-fetchAndCompile' + +import { CompilerArtefacts } from '@remix-core-plugin/compiler-artefacts' +import { CompilerImports } from '@remix-core-plugin/compiler-content-imports' +import { FetchAndCompile } from '@remix-core-plugin/compiler-fetch-and-compile' +import { OffsetToLineColumnConverter } from '@remix-core-plugin/offset-line-to-column-converter' import migrateFileSystem from './migrateFileSystem' @@ -25,7 +29,7 @@ const csjs = require('csjs-inject') const yo = require('yo-yo') const remixLib = require('@remix-project/remix-lib') const registry = require('./global/registry') -const { OffsetToLineColumnConverter } = require('./lib/offsetToLineColumnConverter') + const QueryParams = require('./lib/query-params') const Storage = remixLib.Storage const RemixDProvider = require('./app/files/remixDProvider') @@ -39,12 +43,10 @@ const DGitProvider = require('./app/files/dgitProvider') const WorkspaceFileProvider = require('./app/files/workspaceFileProvider') const toolTip = require('./app/ui/tooltip') const CompilerMetadata = require('./app/files/compiler-metadata') -const CompilerImport = require('./app/compiler/compiler-imports') const Blockchain = require('./blockchain/blockchain.js') const PluginManagerComponent = require('./app/components/plugin-manager-component') -const CompilersArtefacts = require('./app/compiler/compiler-artefacts') const CompileTab = require('./app/tabs/compile-tab') const SettingsTab = require('./app/tabs/settings-tab') @@ -262,14 +264,14 @@ Please make a backup of your contracts and start using http://remix.ethereum.org const dGitProvider = new DGitProvider() // ----------------- import content service ------------------------ - const contentImport = new CompilerImport(fileManager) + const contentImport = new CompilerImports(fileManager) const blockchain = new Blockchain(registry.get('config').api) // ----------------- compilation metadata generation service --------- const compilerMetadataGenerator = new CompilerMetadata(blockchain, fileManager, registry.get('config').api) // ----------------- compilation result service (can keep track of compilation results) ---------------------------- - const compilersArtefacts = new CompilersArtefacts() // store all the compilation results (key represent a compiler name) + const compilersArtefacts = new CompilerArtefacts() // store all the compilation results (key represent a compiler name) registry.put({ api: compilersArtefacts, name: 'compilersartefacts' }) // service which fetch contract artifacts from sourve-verify, put artifacts in remix and compile it @@ -458,11 +460,11 @@ Please make a backup of your contracts and start using http://remix.ethereum.org console.log('couldn\'t register iframe plugins', e.message) } - await appManager.activatePlugin(['contentImport', 'theme', 'editor', 'fileManager', 'compilerMetadata', 'compilerArtefacts', 'network', 'web3Provider', 'offsetToLineColumnConverter']) + await appManager.activatePlugin(['settings', 'contentImport', 'theme', 'editor', 'fileManager', 'compilerMetadata', 'compilerArtefacts', 'network', 'web3Provider', 'offsetToLineColumnConverter']) await appManager.activatePlugin(['mainPanel', 'menuicons', 'tabs']) await appManager.activatePlugin(['sidePanel']) // activating host plugin separately await appManager.activatePlugin(['home']) - await appManager.activatePlugin(['hiddenPanel', 'pluginManager', 'filePanel', 'settings', 'contextualListener', 'terminal', 'fetchAndCompile']) + await appManager.activatePlugin(['hiddenPanel', 'pluginManager', 'filePanel', 'contextualListener', 'terminal', 'fetchAndCompile']) const queryParams = new QueryParams() const params = queryParams.get() diff --git a/apps/remix-ide/src/app/compiler/compiler-abstract.js b/apps/remix-ide/src/app/compiler/compiler-abstract.js deleted file mode 100644 index fcfb32a827..0000000000 --- a/apps/remix-ide/src/app/compiler/compiler-abstract.js +++ /dev/null @@ -1,46 +0,0 @@ -'use strict' -var remixLib = require('@remix-project/remix-lib') -var txHelper = remixLib.execution.txHelper - -module.exports = class CompilerAbstract { - constructor (languageversion, data, source) { - this.languageversion = languageversion - this.data = data - this.source = source // source code - } - - getContracts () { - return this.data.contracts - } - - getContract (name) { - return txHelper.getContract(name, this.data.contracts) - } - - visitContracts (calllback) { - return txHelper.visitContracts(this.data.contracts, calllback) - } - - getData () { - return this.data - } - - getAsts () { - return this.data.sources // ast - } - - getSourceName (fileIndex) { - if (this.data && this.data.sources) { - return Object.keys(this.data.sources)[fileIndex] - } else if (Object.keys(this.source.sources).length === 1) { - // if we don't have ast, we return the only one filename present. - const sourcesArray = Object.keys(this.source.sources) - return sourcesArray[0] - } - return null - } - - getSourceCode () { - return this.source - } -} diff --git a/apps/remix-ide/src/app/compiler/compiler-input.js b/apps/remix-ide/src/app/compiler/compiler-input.js deleted file mode 100644 index a0be3c499d..0000000000 --- a/apps/remix-ide/src/app/compiler/compiler-input.js +++ /dev/null @@ -1,21 +0,0 @@ -'use strict' - -module.exports = (sources, opts) => { - return JSON.stringify({ - language: 'Solidity', - sources: sources, - settings: { - optimizer: { - enabled: opts.optimize === true || opts.optimize === 1, - runs: 200 - }, - libraries: opts.libraries, - outputSelection: { - '*': { - '': ['ast'], - '*': ['abi', 'metadata', 'devdoc', 'userdoc', 'evm.legacyAssembly', 'evm.bytecode', 'evm.deployedBytecode', 'evm.methodIdentifiers', 'evm.gasEstimates'] - } - } - } - }) -} diff --git a/apps/remix-ide/src/app/files/compiler-metadata.js b/apps/remix-ide/src/app/files/compiler-metadata.js index fe4dfc3c43..5c10ad1c7e 100644 --- a/apps/remix-ide/src/app/files/compiler-metadata.js +++ b/apps/remix-ide/src/app/files/compiler-metadata.js @@ -2,7 +2,7 @@ import { Plugin } from '@remixproject/engine' import * as packageJson from '../../../../../package.json' import { joinPath } from '../../lib/helper' -var CompilerAbstract = require('../compiler/compiler-abstract') +import { CompilerAbstract } from '@remix-project/remix-solidity' const profile = { name: 'compilerMetadata', diff --git a/apps/remix-ide/src/app/files/fileProvider.js b/apps/remix-ide/src/app/files/fileProvider.js index 5d152ec74b..288eabe518 100644 --- a/apps/remix-ide/src/app/files/fileProvider.js +++ b/apps/remix-ide/src/app/files/fileProvider.js @@ -1,6 +1,6 @@ 'use strict' -const CompilerImport = require('../compiler/compiler-imports') +import { CompilerImports } from '@remix-core-plugin/compiler-content-imports' const EventManager = require('events') const modalDialogCustom = require('../ui/modal-dialog-custom') const tooltip = require('../ui/tooltip') @@ -44,7 +44,7 @@ class FileProvider { discardChanges (path) { this.remove(path) - const compilerImport = new CompilerImport() + const compilerImport = new CompilerImports() this.providerExternalsStorage.keys().map(value => { if (value.indexOf(path) === 0) { compilerImport.import( diff --git a/apps/remix-ide/src/app/tabs/compile-tab.js b/apps/remix-ide/src/app/tabs/compile-tab.js index cb0773b2b0..767f35de64 100644 --- a/apps/remix-ide/src/app/tabs/compile-tab.js +++ b/apps/remix-ide/src/app/tabs/compile-tab.js @@ -2,7 +2,7 @@ import { ViewPlugin } from '@remixproject/engine-web' import * as packageJson from '../../../../../package.json' import publishToStorage from '../../publishToStorage' -import { compile } from '../compiler/compiler-helpers' +import { compile } from '@remix-project/remix-solidity' const EventEmitter = require('events') const $ = require('jquery') diff --git a/apps/remix-ide/src/app/tabs/compileTab/compilerContainer.js b/apps/remix-ide/src/app/tabs/compileTab/compilerContainer.js index dfb0cfc5a4..7ecc3298b1 100644 --- a/apps/remix-ide/src/app/tabs/compileTab/compilerContainer.js +++ b/apps/remix-ide/src/app/tabs/compileTab/compilerContainer.js @@ -1,6 +1,6 @@ import toaster from '../../ui/tooltip' -import { canUseWorker, baseURLBin, baseURLWasm, urlFromVersion, pathToURL, promisedMiniXhr } from '../../compiler/compiler-utils' +import { canUseWorker, baseURLBin, baseURLWasm, urlFromVersion, pathToURL, promisedMiniXhr } from '@remix-project/remix-solidity' const yo = require('yo-yo') const helper = require('../../../lib/helper') const addTooltip = require('../../ui/tooltip') diff --git a/apps/remix-ide/src/app/tabs/runTab/model/dropdownlogic.js b/apps/remix-ide/src/app/tabs/runTab/model/dropdownlogic.js index 2ee225fef3..386f654775 100644 --- a/apps/remix-ide/src/app/tabs/runTab/model/dropdownlogic.js +++ b/apps/remix-ide/src/app/tabs/runTab/model/dropdownlogic.js @@ -1,6 +1,6 @@ +import { CompilerAbstract } from '@remix-project/remix-solidity' const remixLib = require('@remix-project/remix-lib') const txHelper = remixLib.execution.txHelper -const CompilerAbstract = require('../../../compiler/compiler-abstract') const EventManager = remixLib.EventManager const _paq = window._paq = window._paq || [] diff --git a/apps/remix-ide/src/app/tabs/test-tab.js b/apps/remix-ide/src/app/tabs/test-tab.js index b4527f1151..b5c2c2fafd 100644 --- a/apps/remix-ide/src/app/tabs/test-tab.js +++ b/apps/remix-ide/src/app/tabs/test-tab.js @@ -1,7 +1,6 @@ import { ViewPlugin } from '@remixproject/engine-web' -import { canUseWorker, urlFromVersion } from '../compiler/compiler-utils' import { removeMultipleSlashes, removeTrailingSlashes } from '../../lib/helper' - +import { canUseWorker, urlFromVersion } from '@remix-project/remix-solidity' var yo = require('yo-yo') var async = require('async') var tooltip = require('../ui/tooltip') diff --git a/apps/remix-ide/src/app/ui/landing-page/landing-page.js b/apps/remix-ide/src/app/ui/landing-page/landing-page.js index 9719d0985c..e72d37db9c 100644 --- a/apps/remix-ide/src/app/ui/landing-page/landing-page.js +++ b/apps/remix-ide/src/app/ui/landing-page/landing-page.js @@ -1,12 +1,12 @@ import * as packageJson from '../../../../../../package.json' import { ViewPlugin } from '@remixproject/engine-web' import { migrateToWorkspace } from '../../../migrateFileSystem' +import { CompilerImports } from '@remix-core-plugin/compiler-content-imports' import JSZip from 'jszip' const yo = require('yo-yo') const csjs = require('csjs-inject') const globalRegistry = require('../../../global/registry') -const CompilerImport = require('../../compiler/compiler-imports') const modalDialogCustom = require('../modal-dialog-custom') const modalDialog = require('../modaldialog') const tooltip = require('../tooltip') @@ -240,7 +240,7 @@ export class LandingPage extends ViewPlugin { render () { const load = (service, item, examples, info) => { - const compilerImport = new CompilerImport() + const compilerImport = new CompilerImports() const fileProviders = globalRegistry.get('fileproviders').api const msg = yo`
diff --git a/apps/remix-ide/src/lib/cmdInterpreterAPI.js b/apps/remix-ide/src/lib/cmdInterpreterAPI.js index d132f13107..e8bb3e000e 100644 --- a/apps/remix-ide/src/lib/cmdInterpreterAPI.js +++ b/apps/remix-ide/src/lib/cmdInterpreterAPI.js @@ -1,9 +1,9 @@ 'use strict' +import { CompilerImports } from '@remix-core-plugin/compiler-content-imports' var yo = require('yo-yo') var async = require('async') var EventManager = require('../lib/events') -var CompilerImport = require('../app/compiler/compiler-imports') var toolTip = require('../app/ui/tooltip') var globalRegistry = require('../global/registry') var SourceHighlighter = require('../app/editor/sourceHighlighter') @@ -18,7 +18,7 @@ class CmdInterpreterAPI { self._components.registry = localRegistry || globalRegistry self._components.terminal = terminal self._components.sourceHighlighter = new SourceHighlighter() - self._components.fileImport = new CompilerImport() + self._components.fileImport = new CompilerImports() self._components.gistHandler = new GistHandler() self._deps = { fileManager: self._components.registry.get('filemanager').api, diff --git a/libs/remix-core-plugin/compiler-artefacts/.eslintrc b/libs/remix-core-plugin/compiler-artefacts/.eslintrc new file mode 100644 index 0000000000..1655d72922 --- /dev/null +++ b/libs/remix-core-plugin/compiler-artefacts/.eslintrc @@ -0,0 +1 @@ +{ "extends": "../../../.eslintrc", "rules": {}, "ignorePatterns": ["!**/*"] } diff --git a/libs/remix-core-plugin/compiler-artefacts/README.md b/libs/remix-core-plugin/compiler-artefacts/README.md new file mode 100644 index 0000000000..b3c08632bc --- /dev/null +++ b/libs/remix-core-plugin/compiler-artefacts/README.md @@ -0,0 +1,3 @@ +# compiler-artefacts + +This library was generated with [Nx](https://nx.dev). diff --git a/libs/remix-core-plugin/compiler-artefacts/package.json b/libs/remix-core-plugin/compiler-artefacts/package.json new file mode 100644 index 0000000000..046a760da7 --- /dev/null +++ b/libs/remix-core-plugin/compiler-artefacts/package.json @@ -0,0 +1,11 @@ +{ + "name": "@remix-core-plugin/compiler-artefacts", + "version": "0.0.1", + "description": "This library was generated with [Nx](https://nx.dev).", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "Remix Team", + "license": "ISC" +} diff --git a/libs/remix-core-plugin/compiler-artefacts/src/index.ts b/libs/remix-core-plugin/compiler-artefacts/src/index.ts new file mode 100644 index 0000000000..c11c162acb --- /dev/null +++ b/libs/remix-core-plugin/compiler-artefacts/src/index.ts @@ -0,0 +1 @@ +export * from './lib/compiler-artefacts' diff --git a/apps/remix-ide/src/app/compiler/compiler-artefacts.js b/libs/remix-core-plugin/compiler-artefacts/src/lib/compiler-artefacts.ts similarity index 92% rename from apps/remix-ide/src/app/compiler/compiler-artefacts.js rename to libs/remix-core-plugin/compiler-artefacts/src/lib/compiler-artefacts.ts index 68b1cad9bd..47eb1d519b 100644 --- a/apps/remix-ide/src/app/compiler/compiler-artefacts.js +++ b/libs/remix-core-plugin/compiler-artefacts/src/lib/compiler-artefacts.ts @@ -1,16 +1,17 @@ 'use strict' import { Plugin } from '@remixproject/engine' -import * as packageJson from '../../../../../package.json' -import CompilerAbstract from './compiler-abstract' +import { CompilerAbstract } from '@remix-project/remix-solidity' const profile = { name: 'compilerArtefacts', - methods: [], + methods: ['get', 'addResolvedContract'], events: [], - version: packageJson.version + version: '0.0.1' } -module.exports = class CompilerArtefacts extends Plugin { +export class CompilerArtefacts extends Plugin { + compilersArtefactsPerFile: any + compilersArtefacts: any constructor () { super(profile) this.compilersArtefacts = {} diff --git a/libs/remix-core-plugin/compiler-artefacts/tsconfig.json b/libs/remix-core-plugin/compiler-artefacts/tsconfig.json new file mode 100644 index 0000000000..42882af48a --- /dev/null +++ b/libs/remix-core-plugin/compiler-artefacts/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../../../tsconfig.json", + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + } + ] +} diff --git a/libs/remix-core-plugin/compiler-artefacts/tsconfig.lib.json b/libs/remix-core-plugin/compiler-artefacts/tsconfig.lib.json new file mode 100644 index 0000000000..9c463b51e2 --- /dev/null +++ b/libs/remix-core-plugin/compiler-artefacts/tsconfig.lib.json @@ -0,0 +1,12 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "commonjs", + "outDir": "../../../dist/out-tsc", + "declaration": true, + "rootDir": "./src", + "types": ["node"] + }, + "exclude": ["**/*.spec.ts"], + "include": ["**/*.ts"] +} diff --git a/libs/remix-core-plugin/compiler-content-imports/.eslintrc b/libs/remix-core-plugin/compiler-content-imports/.eslintrc new file mode 100644 index 0000000000..1655d72922 --- /dev/null +++ b/libs/remix-core-plugin/compiler-content-imports/.eslintrc @@ -0,0 +1 @@ +{ "extends": "../../../.eslintrc", "rules": {}, "ignorePatterns": ["!**/*"] } diff --git a/libs/remix-core-plugin/compiler-content-imports/README.md b/libs/remix-core-plugin/compiler-content-imports/README.md new file mode 100644 index 0000000000..38165da82b --- /dev/null +++ b/libs/remix-core-plugin/compiler-content-imports/README.md @@ -0,0 +1,3 @@ +# compiler-content-imports + +This library was generated with [Nx](https://nx.dev). diff --git a/libs/remix-core-plugin/compiler-content-imports/package.json b/libs/remix-core-plugin/compiler-content-imports/package.json new file mode 100644 index 0000000000..95af3c807c --- /dev/null +++ b/libs/remix-core-plugin/compiler-content-imports/package.json @@ -0,0 +1,11 @@ +{ + "name": "@remix-core-plugin/compiler-content-imports", + "version": "0.0.1", + "description": "This library was generated with [Nx](https://nx.dev).", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "Remix Team", + "license": "ISC" +} diff --git a/libs/remix-core-plugin/compiler-content-imports/src/index.ts b/libs/remix-core-plugin/compiler-content-imports/src/index.ts new file mode 100644 index 0000000000..f6219a88b3 --- /dev/null +++ b/libs/remix-core-plugin/compiler-content-imports/src/index.ts @@ -0,0 +1 @@ +export * from './lib/compiler-content-imports' diff --git a/apps/remix-ide/src/app/compiler/compiler-imports.js b/libs/remix-core-plugin/compiler-content-imports/src/lib/compiler-content-imports.ts similarity index 84% rename from apps/remix-ide/src/app/compiler/compiler-imports.js rename to libs/remix-core-plugin/compiler-content-imports/src/lib/compiler-content-imports.ts index 0e72bb425d..d860dc4729 100644 --- a/apps/remix-ide/src/app/compiler/compiler-imports.js +++ b/libs/remix-core-plugin/compiler-content-imports/src/lib/compiler-content-imports.ts @@ -1,30 +1,33 @@ 'use strict' import { Plugin } from '@remixproject/engine' -import * as packageJson from '../../../../../package.json' import { RemixURLResolver } from '@remix-project/remix-url-resolver' const remixTests = require('@remix-project/remix-tests') -const globalRegistry = require('../../global/registry') -const addTooltip = require('../ui/tooltip') const async = require('async') const profile = { name: 'contentImport', displayName: 'content import', - version: packageJson.version, + version: '0.0.1', methods: ['resolve', 'resolveAndSave', 'isExternalUrl'] } -module.exports = class CompilerImports extends Plugin { +export class CompilerImports extends Plugin { + previouslyHandled: {} + fileManager: any + urlResolver: any constructor (fileManager) { super(profile) this.fileManager = fileManager - // const token = await this.call('settings', 'getGithubAccessToken') - const token = globalRegistry.get('config').api.get('settings/gist-access-token') // TODO replace with the plugin call above https://github.com/ethereum/remix-ide/issues/2288 - const protocol = window.location.protocol - this.urlResolver = new RemixURLResolver(token, protocol) + this.urlResolver = new RemixURLResolver() this.previouslyHandled = {} // cache import so we don't make the request at each compilation. } + async onActivation () { + const protocol = typeof window !== 'undefined' && window.location.protocol + const token = await this.call('settings', 'getGithubAccessToken') + this.urlResolver = new RemixURLResolver(token, protocol) + } + isRelativeImport (url) { return /^([^/]+)/.exec(url) } @@ -45,7 +48,7 @@ module.exports = class CompilerImports extends Plugin { this.import(url, null, (error, content, cleanUrl, type, url) => { if (error) return reject(error) resolve({ content, cleanUrl, type, url }) - }) + }, null) }) } @@ -83,8 +86,8 @@ module.exports = class CompilerImports extends Plugin { importExternal (url, targetPath, cb) { this.import(url, - // TODO: move to an event that is generated, the UI shouldn't be here - (loadingMsg) => { addTooltip(loadingMsg) }, + // TODO: handle this event + (loadingMsg) => { this.emit('message', loadingMsg) }, (error, content, cleanUrl, type, url) => { if (error) return cb(error) if (this.fileManager) { @@ -93,7 +96,7 @@ module.exports = class CompilerImports extends Plugin { if (provider) provider.addExternal('.deps/' + path, content, url) } cb(null, content) - }) + }, null) } /** @@ -141,10 +144,12 @@ module.exports = class CompilerImports extends Plugin { if (localhostProvider.isConnected()) { var splitted = /([^/]+)\/(.*)$/g.exec(url) return async.tryEach([ - (cb) => { this.resolveAndSave('localhost/installed_contracts/' + url).then((result) => cb(null, result)).catch((error) => cb(error.message)) }, - (cb) => { if (!splitted) { cb('URL not parseable: ' + url) } else { this.resolveAndSave('localhost/installed_contracts/' + splitted[1] + '/contracts/' + splitted[2]).then((result) => cb(null, result)).catch((error) => cb(error.message)) } }, - (cb) => { this.resolveAndSave('localhost/node_modules/' + url).then((result) => cb(null, result)).catch((error) => cb(error.message)) }, - (cb) => { if (!splitted) { cb('URL not parseable: ' + url) } else { this.resolveAndSave('localhost/node_modules/' + splitted[1] + '/contracts/' + splitted[2]).then((result) => cb(null, result)).catch((error) => cb(error.message)) } }], + (cb) => { this.resolveAndSave('localhost/installed_contracts/' + url, null).then((result) => cb(null, result)).catch((error) => cb(error.message)) }, + // eslint-disable-next-line standard/no-callback-literal + (cb) => { if (!splitted) { cb('URL not parseable: ' + url) } else { this.resolveAndSave('localhost/installed_contracts/' + splitted[1] + '/contracts/' + splitted[2], null).then((result) => cb(null, result)).catch((error) => cb(error.message)) } }, + (cb) => { this.resolveAndSave('localhost/node_modules/' + url, null).then((result) => cb(null, result)).catch((error) => cb(error.message)) }, + // eslint-disable-next-line standard/no-callback-literal + (cb) => { if (!splitted) { cb('URL not parseable: ' + url) } else { this.resolveAndSave('localhost/node_modules/' + splitted[1] + '/contracts/' + splitted[2], null).then((result) => cb(null, result)).catch((error) => cb(error.message)) } }], (error, result) => { if (error) { return this.importExternal(url, targetPath, (error, content) => { diff --git a/libs/remix-core-plugin/compiler-content-imports/tsconfig.json b/libs/remix-core-plugin/compiler-content-imports/tsconfig.json new file mode 100644 index 0000000000..42882af48a --- /dev/null +++ b/libs/remix-core-plugin/compiler-content-imports/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../../../tsconfig.json", + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + } + ] +} diff --git a/libs/remix-core-plugin/compiler-content-imports/tsconfig.lib.json b/libs/remix-core-plugin/compiler-content-imports/tsconfig.lib.json new file mode 100644 index 0000000000..9c463b51e2 --- /dev/null +++ b/libs/remix-core-plugin/compiler-content-imports/tsconfig.lib.json @@ -0,0 +1,12 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "commonjs", + "outDir": "../../../dist/out-tsc", + "declaration": true, + "rootDir": "./src", + "types": ["node"] + }, + "exclude": ["**/*.spec.ts"], + "include": ["**/*.ts"] +} diff --git a/libs/remix-core-plugin/compiler-fetch-and-compile/.eslintrc b/libs/remix-core-plugin/compiler-fetch-and-compile/.eslintrc new file mode 100644 index 0000000000..1655d72922 --- /dev/null +++ b/libs/remix-core-plugin/compiler-fetch-and-compile/.eslintrc @@ -0,0 +1 @@ +{ "extends": "../../../.eslintrc", "rules": {}, "ignorePatterns": ["!**/*"] } diff --git a/libs/remix-core-plugin/compiler-fetch-and-compile/README.md b/libs/remix-core-plugin/compiler-fetch-and-compile/README.md new file mode 100644 index 0000000000..5c2aca3ead --- /dev/null +++ b/libs/remix-core-plugin/compiler-fetch-and-compile/README.md @@ -0,0 +1,3 @@ +# compiler-fetch-and-compile + +This library was generated with [Nx](https://nx.dev). diff --git a/libs/remix-core-plugin/compiler-fetch-and-compile/package.json b/libs/remix-core-plugin/compiler-fetch-and-compile/package.json new file mode 100644 index 0000000000..05dfdb3372 --- /dev/null +++ b/libs/remix-core-plugin/compiler-fetch-and-compile/package.json @@ -0,0 +1,11 @@ +{ + "name": "@remix-core-plugin/compiler-fetch-and-compile", + "version": "0.0.1", + "description": "This library was generated with [Nx](https://nx.dev).", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "Remix Team", + "license": "ISC" +} diff --git a/libs/remix-core-plugin/compiler-fetch-and-compile/src/index.ts b/libs/remix-core-plugin/compiler-fetch-and-compile/src/index.ts new file mode 100644 index 0000000000..2d387c7552 --- /dev/null +++ b/libs/remix-core-plugin/compiler-fetch-and-compile/src/index.ts @@ -0,0 +1 @@ +export * from './lib/compiler-fetch-and-compile' diff --git a/apps/remix-ide/src/app/compiler/compiler-sourceVerifier-fetchAndCompile.js b/libs/remix-core-plugin/compiler-fetch-and-compile/src/lib/compiler-fetch-and-compile.ts similarity index 80% rename from apps/remix-ide/src/app/compiler/compiler-sourceVerifier-fetchAndCompile.js rename to libs/remix-core-plugin/compiler-fetch-and-compile/src/lib/compiler-fetch-and-compile.ts index 4a513e2129..e7769b7b04 100644 --- a/apps/remix-ide/src/app/compiler/compiler-sourceVerifier-fetchAndCompile.js +++ b/libs/remix-core-plugin/compiler-fetch-and-compile/src/lib/compiler-fetch-and-compile.ts @@ -1,18 +1,19 @@ -import * as packageJson from '../../../../../package.json' + import { Plugin } from '@remixproject/engine' -import { compile } from './compiler-helpers' -import globalRegistry from '../../global/registry' +import { compile } from '@remix-project/remix-solidity' +import { util } from '@remix-project/remix-lib' -import remixLib from '@remix-project/remix-lib' const ethutil = require('ethereumjs-util') const profile = { name: 'fetchAndCompile', methods: ['resolve'], - version: packageJson.version + version: '0.0.1' } -export default class FetchAndCompile extends Plugin { +export class FetchAndCompile extends Plugin { + unresolvedAddresses: any[] + sourceVerifierNetWork: string[] constructor () { super(profile) this.unresolvedAddresses = [] @@ -32,11 +33,10 @@ export default class FetchAndCompile extends Plugin { */ async resolve (contractAddress, codeAtAddress, targetPath) { contractAddress = ethutil.toChecksumAddress(contractAddress) - const compilersartefacts = globalRegistry.get('compilersartefacts').api - const localCompilation = () => compilersartefacts.get(contractAddress) ? compilersartefacts.get(contractAddress) : compilersartefacts.get('__last') ? compilersartefacts.get('__last') : null + const localCompilation = async () => await this.call('compilerArtefacts', 'get', contractAddress) ? await this.call('compilerArtefacts', 'get', contractAddress) : await this.call('compilerArtefacts', 'get', '__last') ? await this.call('compilerArtefacts', 'get', '__last') : null - const resolved = compilersartefacts.get(contractAddress) + const resolved = await this.call('compilerArtefacts', 'get', contractAddress) if (resolved) return resolved if (this.unresolvedAddresses.includes(contractAddress)) return localCompilation() @@ -53,15 +53,15 @@ export default class FetchAndCompile extends Plugin { if (!this.sourceVerifierNetWork.includes(network.name)) return localCompilation() // check if the contract if part of the local compilation result - const compilation = localCompilation() + const compilation = await localCompilation() if (compilation) { let found = false compilation.visitContracts((contract) => { - found = remixLib.util.compareByteCode('0x' + contract.object.evm.deployedBytecode.object, codeAtAddress) + found = util.compareByteCode('0x' + contract.object.evm.deployedBytecode.object, codeAtAddress) return found }) if (found) { - compilersartefacts.addResolvedContract(contractAddress, compilation) + await this.call('compilerArtefacts', 'addResolvedContract', contractAddress, compilation) setTimeout(_ => this.emit('usingLocalCompilation', contractAddress), 0) return compilation } @@ -118,8 +118,8 @@ export default class FetchAndCompile extends Plugin { const compData = await compile( compilationTargets, settings, - (url, cb) => this.call('contentImport', 'resolveAndSave', url).then((result) => cb(null, result)).catch((error) => cb(error.message))) - compilersartefacts.addResolvedContract(contractAddress, compData) + async (url, cb) => await this.call('contentImport', 'resolveAndSave', url).then((result) => cb(null, result)).catch((error) => cb(error.message))) + await this.call('compilerArtefacts', 'addResolvedContract', contractAddress, compData) return compData } catch (e) { this.unresolvedAddresses.push(contractAddress) diff --git a/libs/remix-core-plugin/compiler-fetch-and-compile/tsconfig.json b/libs/remix-core-plugin/compiler-fetch-and-compile/tsconfig.json new file mode 100644 index 0000000000..42882af48a --- /dev/null +++ b/libs/remix-core-plugin/compiler-fetch-and-compile/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../../../tsconfig.json", + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + } + ] +} diff --git a/libs/remix-core-plugin/compiler-fetch-and-compile/tsconfig.lib.json b/libs/remix-core-plugin/compiler-fetch-and-compile/tsconfig.lib.json new file mode 100644 index 0000000000..9c463b51e2 --- /dev/null +++ b/libs/remix-core-plugin/compiler-fetch-and-compile/tsconfig.lib.json @@ -0,0 +1,12 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "commonjs", + "outDir": "../../../dist/out-tsc", + "declaration": true, + "rootDir": "./src", + "types": ["node"] + }, + "exclude": ["**/*.spec.ts"], + "include": ["**/*.ts"] +} diff --git a/libs/remix-core-plugin/offset-line-to-column-converter/.eslintrc b/libs/remix-core-plugin/offset-line-to-column-converter/.eslintrc new file mode 100644 index 0000000000..1655d72922 --- /dev/null +++ b/libs/remix-core-plugin/offset-line-to-column-converter/.eslintrc @@ -0,0 +1 @@ +{ "extends": "../../../.eslintrc", "rules": {}, "ignorePatterns": ["!**/*"] } diff --git a/libs/remix-core-plugin/offset-line-to-column-converter/README.md b/libs/remix-core-plugin/offset-line-to-column-converter/README.md new file mode 100644 index 0000000000..17a2dea5c3 --- /dev/null +++ b/libs/remix-core-plugin/offset-line-to-column-converter/README.md @@ -0,0 +1,3 @@ +# offset-line-to-column-converter + +This library was generated with [Nx](https://nx.dev). diff --git a/libs/remix-core-plugin/offset-line-to-column-converter/package.json b/libs/remix-core-plugin/offset-line-to-column-converter/package.json new file mode 100644 index 0000000000..761b79682e --- /dev/null +++ b/libs/remix-core-plugin/offset-line-to-column-converter/package.json @@ -0,0 +1,11 @@ +{ + "name": "@remix-core-plugin/offset-line-to-column-converter", + "version": "0.0.1", + "description": "This library was generated with [Nx](https://nx.dev).", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "Remix Team", + "license": "ISC" +} diff --git a/libs/remix-core-plugin/offset-line-to-column-converter/src/index.ts b/libs/remix-core-plugin/offset-line-to-column-converter/src/index.ts new file mode 100644 index 0000000000..d2699060ec --- /dev/null +++ b/libs/remix-core-plugin/offset-line-to-column-converter/src/index.ts @@ -0,0 +1 @@ +export * from './lib/offset-line-to-column-converter' diff --git a/libs/remix-core-plugin/offset-line-to-column-converter/src/lib/offset-line-to-column-converter.ts b/libs/remix-core-plugin/offset-line-to-column-converter/src/lib/offset-line-to-column-converter.ts new file mode 100644 index 0000000000..57c3f3ed2e --- /dev/null +++ b/libs/remix-core-plugin/offset-line-to-column-converter/src/lib/offset-line-to-column-converter.ts @@ -0,0 +1,77 @@ +'use strict' +import { Plugin } from '@remixproject/engine' + +import { sourceMappingDecoder } from '@remix-project/remix-debug' + +const profile = { + name: 'offsetToLineColumnConverter', + methods: ['offsetToLineColumn'], + events: [], + version: '0.0.1' +} + +export class OffsetToLineColumnConverter extends Plugin { + lineBreakPositionsByContent: {} + sourceMappingDecoder: any + constructor () { + super(profile) + this.lineBreakPositionsByContent = {} + this.sourceMappingDecoder = sourceMappingDecoder + } + + /** + * Convert offset representation with line/column representation. + * This is also used to resolve the content: + * @arg file is the index of the file in the content sources array and content sources array does have filename as key and not index. + * So we use the asts (which references both index and filename) to look up the actual content targeted by the @arg file index. + * @param {{start, length}} rawLocation - offset location + * @param {number} file - The index where to find the source in the sources parameters + * @param {Object.} sources - Map of content sources + * @param {Object.} asts - Map of content sources + */ + offsetToLineColumn (rawLocation, file, sources, asts) { + if (!this.lineBreakPositionsByContent[file]) { + const sourcesArray = Object.keys(sources) + if (!asts || (file === 0 && sourcesArray.length === 1)) { + // if we don't have ast, we process the only one available content (applicable also for compiler older than 0.4.12) + this.lineBreakPositionsByContent[file] = this.sourceMappingDecoder.getLinebreakPositions(sources[sourcesArray[0]].content) + } else { + for (var filename in asts) { + const source = asts[filename] + if (source.id === file) { + this.lineBreakPositionsByContent[file] = this.sourceMappingDecoder.getLinebreakPositions(sources[filename].content) + break + } + } + } + } + return this.sourceMappingDecoder.convertOffsetToLineColumn(rawLocation, this.lineBreakPositionsByContent[file]) + } + + /** + * Convert offset representation with line/column representation. + * @param {{start, length}} rawLocation - offset location + * @param {number} file - The index where to find the source in the sources parameters + * @param {string} content - source + */ + offsetToLineColumnWithContent (rawLocation, file, content) { + this.lineBreakPositionsByContent[file] = this.sourceMappingDecoder.getLinebreakPositions(content) + return this.sourceMappingDecoder.convertOffsetToLineColumn(rawLocation, this.lineBreakPositionsByContent[file]) + } + + /** + * Clear the cache + */ + clear () { + this.lineBreakPositionsByContent = {} + } + + /** + * called by plugin API + */ + activate () { + this.on('solidity', 'compilationFinished', () => { + this.clear() + }) + } +} diff --git a/libs/remix-core-plugin/offset-line-to-column-converter/tsconfig.json b/libs/remix-core-plugin/offset-line-to-column-converter/tsconfig.json new file mode 100644 index 0000000000..42882af48a --- /dev/null +++ b/libs/remix-core-plugin/offset-line-to-column-converter/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../../../tsconfig.json", + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + } + ] +} diff --git a/libs/remix-core-plugin/offset-line-to-column-converter/tsconfig.lib.json b/libs/remix-core-plugin/offset-line-to-column-converter/tsconfig.lib.json new file mode 100644 index 0000000000..9c463b51e2 --- /dev/null +++ b/libs/remix-core-plugin/offset-line-to-column-converter/tsconfig.lib.json @@ -0,0 +1,12 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "commonjs", + "outDir": "../../../dist/out-tsc", + "declaration": true, + "rootDir": "./src", + "types": ["node"] + }, + "exclude": ["**/*.spec.ts"], + "include": ["**/*.ts"] +} diff --git a/libs/remix-debug/src/eventManager.ts b/libs/remix-debug/src/eventManager.ts index 60e83b0a78..f878395ed3 100644 --- a/libs/remix-debug/src/eventManager.ts +++ b/libs/remix-debug/src/eventManager.ts @@ -67,7 +67,7 @@ export class EventManager { } for (const listener in this.registered[eventName]) { const l = this.registered[eventName][listener] - l.func.apply(l.obj === this.anonymous ? {} : l.obj, args) + if (l.func) l.func.apply(l.obj === this.anonymous ? {} : l.obj, args) } } } diff --git a/libs/remix-lib/src/eventManager.ts b/libs/remix-lib/src/eventManager.ts index 80280e8b27..a67548f899 100644 --- a/libs/remix-lib/src/eventManager.ts +++ b/libs/remix-lib/src/eventManager.ts @@ -64,7 +64,7 @@ export class EventManager { } for (const listener in this.registered[eventName]) { const l = this.registered[eventName][listener] - l.func.apply(l.obj === this.anonymous ? {} : l.obj, args) + if (l.func) l.func.apply(l.obj === this.anonymous ? {} : l.obj, args) } } } diff --git a/libs/remix-solidity/src/compiler/compiler-abstract.ts b/libs/remix-solidity/src/compiler/compiler-abstract.ts new file mode 100644 index 0000000000..81cd33db28 --- /dev/null +++ b/libs/remix-solidity/src/compiler/compiler-abstract.ts @@ -0,0 +1,48 @@ +'use strict' +import txHelper from './txHelper' + +export class CompilerAbstract { + languageversion: any + data: any + source: any + constructor (languageversion, data, source) { + this.languageversion = languageversion + this.data = data + this.source = source // source code + } + + getContracts () { + return this.data.contracts + } + + getContract (name) { + return txHelper.getContract(name, this.data.contracts) + } + + visitContracts (calllback) { + return txHelper.visitContracts(this.data.contracts, calllback) + } + + getData () { + return this.data + } + + getAsts () { + return this.data.sources // ast + } + + getSourceName (fileIndex) { + if (this.data && this.data.sources) { + return Object.keys(this.data.sources)[fileIndex] + } else if (Object.keys(this.source.sources).length === 1) { + // if we don't have ast, we return the only one filename present. + const sourcesArray = Object.keys(this.source.sources) + return sourcesArray[0] + } + return null + } + + getSourceCode () { + return this.source + } +} diff --git a/apps/remix-ide/src/app/compiler/compiler-helpers.js b/libs/remix-solidity/src/compiler/compiler-helpers.ts similarity index 89% rename from apps/remix-ide/src/app/compiler/compiler-helpers.js rename to libs/remix-solidity/src/compiler/compiler-helpers.ts index db7d5988f3..8a70e6be4f 100644 --- a/apps/remix-ide/src/app/compiler/compiler-helpers.js +++ b/libs/remix-solidity/src/compiler/compiler-helpers.ts @@ -1,7 +1,7 @@ 'use strict' import { canUseWorker, urlFromVersion } from './compiler-utils' -import { Compiler } from '@remix-project/remix-solidity' -import CompilerAbstract from './compiler-abstract' +import { CompilerAbstract } from './compiler-abstract' +import { Compiler } from './compiler' export const compile = async (compilationTargets, settings, contentResolverCallback) => { const res = await (() => { diff --git a/apps/remix-ide/src/app/compiler/compiler-utils.js b/libs/remix-solidity/src/compiler/compiler-utils.ts similarity index 100% rename from apps/remix-ide/src/app/compiler/compiler-utils.js rename to libs/remix-solidity/src/compiler/compiler-utils.ts diff --git a/libs/remix-solidity/src/index.ts b/libs/remix-solidity/src/index.ts index cb204a8af6..db63062910 100644 --- a/libs/remix-solidity/src/index.ts +++ b/libs/remix-solidity/src/index.ts @@ -1,3 +1,6 @@ export { Compiler } from './compiler/compiler' +export { compile } from './compiler/compiler-helpers' export { default as CompilerInput } from './compiler/compiler-input' +export { CompilerAbstract } from './compiler/compiler-abstract' export * from './compiler/types' +export * from './compiler/compiler-utils' diff --git a/libs/remix-solidity/src/lib/eventManager.ts b/libs/remix-solidity/src/lib/eventManager.ts index 289b2ec4eb..8282e09b6c 100644 --- a/libs/remix-solidity/src/lib/eventManager.ts +++ b/libs/remix-solidity/src/lib/eventManager.ts @@ -62,7 +62,7 @@ export default class EventManager { } for (const listener in this.registered[eventName]) { const l = this.registered[eventName][listener] - l.func.apply(l.obj === this.anonymous ? {} : l.obj, args) + if (l.func) l.func.apply(l.obj === this.anonymous ? {} : l.obj, args) } } } diff --git a/nx.json b/nx.json index a63c015d64..dcfee1205d 100644 --- a/nx.json +++ b/nx.json @@ -101,6 +101,19 @@ }, "remix-ui-checkbox": { "tags": [] + }, + "compiler-artefacts": { + "tags": [], + "implicitDependencies": ["remix-lib"] + }, + "compiler-fetch-and-compile": { + "tags": [] + }, + "compiler-content-imports": { + "tags": [] + }, + "offset-line-to-column-converter": { + "tags": [] } } } diff --git a/package-lock.json b/package-lock.json index aac4527317..8f326fe235 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21926,6 +21926,12 @@ "which": "^2.0.2" }, "dependencies": { + "fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "optional": true + }, "has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", diff --git a/tsconfig.json b/tsconfig.json index 75db5bc6ff..88cef54a3f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -40,7 +40,19 @@ "@remix-ui/file-explorer": ["libs/remix-ui/file-explorer/src/index.ts"], "@remix-ui/workspace": ["libs/remix-ui/workspace/src/index.ts"], "@remix-ui/static-analyser": ["libs/remix-ui/static-analyser/src/index.ts"], - "@remix-ui/checkbox": ["libs/remix-ui/checkbox/src/index.ts"] + "@remix-ui/checkbox": ["libs/remix-ui/checkbox/src/index.ts"], + "@remix-core-plugin/compiler-artefacts": [ + "libs/remix-core-plugin/compiler-artefacts/src/index.ts" + ], + "@remix-core-plugin/compiler-fetch-and-compile": [ + "libs/remix-core-plugin/compiler-fetch-and-compile/src/index.ts" + ], + "@remix-core-plugin/compiler-content-imports": [ + "libs/remix-core-plugin/compiler-content-imports/src/index.ts" + ], + "@remix-core-plugin/offset-line-to-column-converter": [ + "libs/remix-core-plugin/offset-line-to-column-converter/src/index.ts" + ] } }, "exclude": ["node_modules", "tmp"] diff --git a/workspace.json b/workspace.json index 5d2bf912c0..0f6a4698fe 100644 --- a/workspace.json +++ b/workspace.json @@ -760,6 +760,127 @@ } } } + }, + "compiler-artefacts": { + "root": "libs/remix-core-plugin/compiler-artefacts", + "sourceRoot": "libs/remix-core-plugin/compiler-artefacts/src", + "projectType": "library", + "schematics": {}, + "architect": { + "lint": { + "builder": "@nrwl/linter:lint", + "options": { + "linter": "eslint", + "tsConfig": [ + "libs/remix-core-plugin/compiler-artefacts/tsconfig.lib.json" + ], + "exclude": [ + "**/node_modules/**", + "!libs/remix-core-plugin/compiler-artefacts/**/*" + ] + } + }, + "build": { + "builder": "@nrwl/node:package", + "options": { + "outputPath": "dist/libs/core-plugin/compiler-artefacts", + "tsConfig": "libs/remix-core-plugin/compiler-artefacts/tsconfig.lib.json", + "packageJson": "libs/remix-core-plugin/compiler-artefacts/package.json", + "main": "libs/remix-core-plugin/compiler-artefacts/src/index.ts" + } + } + } + }, + "compiler-fetch-and-compile": { + "root": "libs/remix-core-plugin/compiler-fetch-and-compile", + "sourceRoot": "libs/remix-core-plugin/compiler-fetch-and-compile/src", + "projectType": "library", + "schematics": {}, + "architect": { + "lint": { + "builder": "@nrwl/linter:lint", + "options": { + "linter": "eslint", + "tsConfig": [ + "libs/remix-core-plugin/compiler-fetch-and-compile/tsconfig.lib.json" + ], + "exclude": [ + "**/node_modules/**", + "!libs/remix-core-plugin/compiler-fetch-and-compile/**/*" + ] + } + }, + "build": { + "builder": "@nrwl/node:package", + "options": { + "outputPath": "dist/libs/core-plugin/compiler-fetch-and-compile", + "tsConfig": "libs/remix-core-plugin/compiler-fetch-and-compile/tsconfig.lib.json", + "packageJson": "libs/remix-core-plugin/compiler-fetch-and-compile/package.json", + "main": "libs/remix-core-plugin/compiler-fetch-and-compile/src/index.ts" + } + } + } + }, + "compiler-content-imports": { + "root": "libs/remix-core-plugin/compiler-content-imports", + "sourceRoot": "libs/remix-core-plugin/compiler-content-imports/src", + "projectType": "library", + "schematics": {}, + "architect": { + "lint": { + "builder": "@nrwl/linter:lint", + "options": { + "linter": "eslint", + "tsConfig": [ + "libs/remix-core-plugin/compiler-content-imports/tsconfig.lib.json" + ], + "exclude": [ + "**/node_modules/**", + "!libs/remix-core-plugin/compiler-content-imports/**/*" + ] + } + }, + + "build": { + "builder": "@nrwl/node:package", + "options": { + "outputPath": "dist/libs/core-plugin/compiler-content-imports", + "tsConfig": "libs/remix-core-plugin/compiler-content-imports/tsconfig.lib.json", + "packageJson": "libs/remix-core-plugin/compiler-content-imports/package.json", + "main": "libs/remix-core-plugin/compiler-content-imports/src/index.ts" + } + } + } + }, + "offset-line-to-column-converter": { + "root": "libs/remix-core-plugin/offset-line-to-column-converter", + "sourceRoot": "libs/remix-core-plugin/offset-line-to-column-converter/src", + "projectType": "library", + "schematics": {}, + "architect": { + "lint": { + "builder": "@nrwl/linter:lint", + "options": { + "linter": "eslint", + "tsConfig": [ + "libs/remix-core-plugin/offset-line-to-column-converter/tsconfig.lib.json" + ], + "exclude": [ + "**/node_modules/**", + "!libs/remix-core-plugin/offset-line-to-column-converter/**/*" + ] + } + }, + "build": { + "builder": "@nrwl/node:package", + "options": { + "outputPath": "dist/libs/core-plugin/offset-line-to-column-converter", + "tsConfig": "libs/remix-core-plugin/offset-line-to-column-converter/tsconfig.lib.json", + "packageJson": "libs/remix-core-plugin/offset-line-to-column-converter/package.json", + "main": "libs/remix-core-plugin/coffset-line-to-column-converter/src/index.ts" + } + } + } } }, "cli": { From 340d78000d141572654bb7a69699238c1084402a Mon Sep 17 00:00:00 2001 From: filip mertens Date: Mon, 28 Jun 2021 10:45:47 +0200 Subject: [PATCH 02/17] get token when using import --- apps/remix-ide/src/app.js | 4 ++-- .../src/lib/compiler-content-imports.ts | 5 +++-- libs/remix-url-resolver/src/resolve.ts | 4 ++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/apps/remix-ide/src/app.js b/apps/remix-ide/src/app.js index 323ec0ba86..3f855b5f02 100644 --- a/apps/remix-ide/src/app.js +++ b/apps/remix-ide/src/app.js @@ -460,11 +460,11 @@ Please make a backup of your contracts and start using http://remix.ethereum.org console.log('couldn\'t register iframe plugins', e.message) } - await appManager.activatePlugin(['settings', 'contentImport', 'theme', 'editor', 'fileManager', 'compilerMetadata', 'compilerArtefacts', 'network', 'web3Provider', 'offsetToLineColumnConverter']) + await appManager.activatePlugin(['theme', 'editor', 'fileManager', 'compilerMetadata', 'compilerArtefacts', 'network', 'web3Provider', 'offsetToLineColumnConverter']) await appManager.activatePlugin(['mainPanel', 'menuicons', 'tabs']) await appManager.activatePlugin(['sidePanel']) // activating host plugin separately await appManager.activatePlugin(['home']) - await appManager.activatePlugin(['hiddenPanel', 'pluginManager', 'filePanel', 'contextualListener', 'terminal', 'fetchAndCompile']) + await appManager.activatePlugin(['hiddenPanel', 'pluginManager', 'filePanel', 'settings', 'contextualListener', 'terminal', 'fetchAndCompile', 'contentImport']) const queryParams = new QueryParams() const params = queryParams.get() diff --git a/libs/remix-core-plugin/compiler-content-imports/src/lib/compiler-content-imports.ts b/libs/remix-core-plugin/compiler-content-imports/src/lib/compiler-content-imports.ts index d860dc4729..85450a04d9 100644 --- a/libs/remix-core-plugin/compiler-content-imports/src/lib/compiler-content-imports.ts +++ b/libs/remix-core-plugin/compiler-content-imports/src/lib/compiler-content-imports.ts @@ -22,10 +22,10 @@ export class CompilerImports extends Plugin { this.previouslyHandled = {} // cache import so we don't make the request at each compilation. } - async onActivation () { + async setToken () { const protocol = typeof window !== 'undefined' && window.location.protocol const token = await this.call('settings', 'getGithubAccessToken') - this.urlResolver = new RemixURLResolver(token, protocol) + this.urlResolver.setGistToken(token, protocol) } isRelativeImport (url) { @@ -71,6 +71,7 @@ export class CompilerImports extends Plugin { let resolved try { + await this.setToken() resolved = await this.urlResolver.resolve(url) const { content, cleanUrl, type } = resolved self.previouslyHandled[url] = { diff --git a/libs/remix-url-resolver/src/resolve.ts b/libs/remix-url-resolver/src/resolve.ts index 13029cefbd..adfc05d862 100644 --- a/libs/remix-url-resolver/src/resolve.ts +++ b/libs/remix-url-resolver/src/resolve.ts @@ -30,6 +30,10 @@ export class RemixURLResolver { constructor (gistToken?: string, protocol = 'http:') { this.previouslyHandled = {} + this.setGistToken(gistToken, protocol) + } + + async setGistToken (gistToken?: string, protocol = 'http:') { this.gistAccessToken = gistToken || '' this.protocol = protocol } From d4c60aed81afefbafa42b6a9fa0f1d8ea13cb29b Mon Sep 17 00:00:00 2001 From: filip mertens Date: Mon, 28 Jun 2021 17:02:23 +0200 Subject: [PATCH 03/17] plugin compilerMetadata --- apps/remix-ide/src/app.js | 5 +- .../src/app/files/compiler-metadata.js | 148 ------------------ apps/remix-ide/src/app/tabs/settings-tab.js | 6 +- .../src/lib/compiler-content-imports.ts | 2 +- .../compiler-metadata/.eslintrc | 1 + .../compiler-metadata/README.md | 3 + .../compiler-metadata/package.json | 11 ++ .../compiler-metadata/src/index.ts | 1 + .../src/lib/compiler-metadata.ts | 146 +++++++++++++++++ .../compiler-metadata/tsconfig.json | 10 ++ .../compiler-metadata/tsconfig.lib.json | 12 ++ nx.json | 3 + tsconfig.json | 3 + workspace.json | 31 +++- 14 files changed, 227 insertions(+), 155 deletions(-) delete mode 100644 apps/remix-ide/src/app/files/compiler-metadata.js create mode 100644 libs/remix-core-plugin/compiler-metadata/.eslintrc create mode 100644 libs/remix-core-plugin/compiler-metadata/README.md create mode 100644 libs/remix-core-plugin/compiler-metadata/package.json create mode 100644 libs/remix-core-plugin/compiler-metadata/src/index.ts create mode 100644 libs/remix-core-plugin/compiler-metadata/src/lib/compiler-metadata.ts create mode 100644 libs/remix-core-plugin/compiler-metadata/tsconfig.json create mode 100644 libs/remix-core-plugin/compiler-metadata/tsconfig.lib.json diff --git a/apps/remix-ide/src/app.js b/apps/remix-ide/src/app.js index 3f855b5f02..039d0a9c15 100644 --- a/apps/remix-ide/src/app.js +++ b/apps/remix-ide/src/app.js @@ -21,6 +21,7 @@ import { CompilerArtefacts } from '@remix-core-plugin/compiler-artefacts' import { CompilerImports } from '@remix-core-plugin/compiler-content-imports' import { FetchAndCompile } from '@remix-core-plugin/compiler-fetch-and-compile' import { OffsetToLineColumnConverter } from '@remix-core-plugin/offset-line-to-column-converter' +import { CompilerMetadata } from '@remix-core-plugin/compiler-metadata' import migrateFileSystem from './migrateFileSystem' @@ -42,7 +43,7 @@ const FileProvider = require('./app/files/fileProvider') const DGitProvider = require('./app/files/dgitProvider') const WorkspaceFileProvider = require('./app/files/workspaceFileProvider') const toolTip = require('./app/ui/tooltip') -const CompilerMetadata = require('./app/files/compiler-metadata') + const Blockchain = require('./blockchain/blockchain.js') @@ -269,7 +270,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org const blockchain = new Blockchain(registry.get('config').api) // ----------------- compilation metadata generation service --------- - const compilerMetadataGenerator = new CompilerMetadata(blockchain, fileManager, registry.get('config').api) + const compilerMetadataGenerator = new CompilerMetadata() // ----------------- compilation result service (can keep track of compilation results) ---------------------------- const compilersArtefacts = new CompilerArtefacts() // store all the compilation results (key represent a compiler name) registry.put({ api: compilersArtefacts, name: 'compilersartefacts' }) diff --git a/apps/remix-ide/src/app/files/compiler-metadata.js b/apps/remix-ide/src/app/files/compiler-metadata.js deleted file mode 100644 index 5c10ad1c7e..0000000000 --- a/apps/remix-ide/src/app/files/compiler-metadata.js +++ /dev/null @@ -1,148 +0,0 @@ -'use strict' -import { Plugin } from '@remixproject/engine' -import * as packageJson from '../../../../../package.json' -import { joinPath } from '../../lib/helper' -import { CompilerAbstract } from '@remix-project/remix-solidity' - -const profile = { - name: 'compilerMetadata', - methods: ['deployMetadataOf'], - events: [], - version: packageJson.version -} - -class CompilerMetadata extends Plugin { - constructor (blockchain, fileManager, config) { - super(profile) - this.blockchain = blockchain - this.fileManager = fileManager - this.config = config - this.networks = ['VM:-', 'main:1', 'ropsten:3', 'rinkeby:4', 'kovan:42', 'görli:5', 'Custom'] - this.innerPath = 'artifacts' - } - - _JSONFileName (path, contractName) { - return joinPath(path, this.innerPath, contractName + '.json') - } - - _MetadataFileName (path, contractName) { - return joinPath(path, this.innerPath, contractName + '_metadata.json') - } - - onActivation () { - var self = this - this.on('solidity', 'compilationFinished', (file, source, languageVersion, data) => { - if (!self.config.get('settings/generate-contract-metadata')) return - const compiler = new CompilerAbstract(languageVersion, data, source) - var provider = self.fileManager.fileProviderOf(source.target) - var path = self.fileManager.extractPathOf(source.target) - if (provider) { - compiler.visitContracts((contract) => { - if (contract.file !== source.target) return - - var fileName = self._JSONFileName(path, contract.name) - var metadataFileName = self._MetadataFileName(path, contract.name) - provider.get(fileName, (error, content) => { - if (!error) { - content = content || '{}' - var metadata - try { - metadata = JSON.parse(content) - } catch (e) { - console.log(e) - } - - var deploy = metadata.deploy || {} - self.networks.forEach((network) => { - deploy[network] = self._syncContext(contract, deploy[network] || {}) - }) - - let parsedMetadata - try { - parsedMetadata = JSON.parse(contract.object.metadata) - } catch (e) { - console.log(e) - } - if (parsedMetadata) provider.set(metadataFileName, JSON.stringify(parsedMetadata, null, '\t')) - - var data = { - deploy, - data: { - bytecode: contract.object.evm.bytecode, - deployedBytecode: contract.object.evm.deployedBytecode, - gasEstimates: contract.object.evm.gasEstimates, - methodIdentifiers: contract.object.evm.methodIdentifiers - }, - abi: contract.object.abi - } - - provider.set(fileName, JSON.stringify(data, null, '\t')) - } - }) - }) - } - }) - } - - _syncContext (contract, metadata) { - var linkReferences = metadata.linkReferences - var autoDeployLib = metadata.autoDeployLib - if (!linkReferences) linkReferences = {} - if (autoDeployLib === undefined) autoDeployLib = true - - for (var libFile in contract.object.evm.bytecode.linkReferences) { - if (!linkReferences[libFile]) linkReferences[libFile] = {} - for (var lib in contract.object.evm.bytecode.linkReferences[libFile]) { - if (!linkReferences[libFile][lib]) { - linkReferences[libFile][lib] = '
' - } - } - } - metadata.linkReferences = linkReferences - metadata.autoDeployLib = autoDeployLib - return metadata - } - - // TODO: is only called by dropdownLogic and can be moved there - deployMetadataOf (contractName, fileLocation) { - return new Promise((resolve, reject) => { - var provider - let path - if (fileLocation) { - provider = this.fileManager.fileProviderOf(fileLocation) - path = fileLocation.split('/') - path.pop() - path = path.join('/') - } else { - provider = this.fileManager.currentFileProvider() - path = this.fileManager.currentPath() - } - - if (provider) { - this.blockchain.detectNetwork((err, { id, name } = {}) => { - if (err) { - console.log(err) - reject(err) - } else { - var fileName = this._JSONFileName(path, contractName) - provider.get(fileName, (error, content) => { - if (error) return reject(error) - if (!content) return resolve() - try { - var metadata = JSON.parse(content) - metadata = metadata.deploy || {} - return resolve(metadata[name + ':' + id] || metadata[name] || metadata[id] || metadata[name.toLowerCase() + ':' + id] || metadata[name.toLowerCase()]) - } catch (e) { - reject(e.message) - } - }) - } - }) - } else { - reject(new Error(`Please select the folder in the file explorer where the metadata of ${contractName} can be found`)) - } - }) - } -} - -module.exports = CompilerMetadata diff --git a/apps/remix-ide/src/app/tabs/settings-tab.js b/apps/remix-ide/src/app/tabs/settings-tab.js index b692fb2611..3d8da2b8a2 100644 --- a/apps/remix-ide/src/app/tabs/settings-tab.js +++ b/apps/remix-ide/src/app/tabs/settings-tab.js @@ -11,7 +11,7 @@ const _paq = window._paq = window._paq || [] const profile = { name: 'settings', displayName: 'Settings', - methods: ['getGithubAccessToken'], + methods: ['get'], events: [], icon: 'assets/img/settings.webp', description: 'Remix-IDE settings', @@ -257,8 +257,8 @@ module.exports = class SettingsTab extends ViewPlugin { return this._view.el } - getGithubAccessToken () { - return this.config.get('settings/gist-access-token') + get (key) { + return this.config.get(key) } updateMatomoAnalyticsChoice (isChecked) { diff --git a/libs/remix-core-plugin/compiler-content-imports/src/lib/compiler-content-imports.ts b/libs/remix-core-plugin/compiler-content-imports/src/lib/compiler-content-imports.ts index 85450a04d9..0e9e4ab8e0 100644 --- a/libs/remix-core-plugin/compiler-content-imports/src/lib/compiler-content-imports.ts +++ b/libs/remix-core-plugin/compiler-content-imports/src/lib/compiler-content-imports.ts @@ -24,7 +24,7 @@ export class CompilerImports extends Plugin { async setToken () { const protocol = typeof window !== 'undefined' && window.location.protocol - const token = await this.call('settings', 'getGithubAccessToken') + const token = await this.call('settings', 'get', 'settings/gist-access-token') this.urlResolver.setGistToken(token, protocol) } diff --git a/libs/remix-core-plugin/compiler-metadata/.eslintrc b/libs/remix-core-plugin/compiler-metadata/.eslintrc new file mode 100644 index 0000000000..1655d72922 --- /dev/null +++ b/libs/remix-core-plugin/compiler-metadata/.eslintrc @@ -0,0 +1 @@ +{ "extends": "../../../.eslintrc", "rules": {}, "ignorePatterns": ["!**/*"] } diff --git a/libs/remix-core-plugin/compiler-metadata/README.md b/libs/remix-core-plugin/compiler-metadata/README.md new file mode 100644 index 0000000000..96888a605b --- /dev/null +++ b/libs/remix-core-plugin/compiler-metadata/README.md @@ -0,0 +1,3 @@ +# remix-core-plugin-compiler-metadata + +This library was generated with [Nx](https://nx.dev). diff --git a/libs/remix-core-plugin/compiler-metadata/package.json b/libs/remix-core-plugin/compiler-metadata/package.json new file mode 100644 index 0000000000..f8a22f5ab6 --- /dev/null +++ b/libs/remix-core-plugin/compiler-metadata/package.json @@ -0,0 +1,11 @@ +{ + "name": "@remix-core-plugin/compiler-metadata", + "version": "0.0.1", + "description": "This library was generated with [Nx](https://nx.dev).", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "Remix Team", + "license": "ISC" +} diff --git a/libs/remix-core-plugin/compiler-metadata/src/index.ts b/libs/remix-core-plugin/compiler-metadata/src/index.ts new file mode 100644 index 0000000000..2b81c60e16 --- /dev/null +++ b/libs/remix-core-plugin/compiler-metadata/src/index.ts @@ -0,0 +1 @@ +export * from './lib/compiler-metadata' diff --git a/libs/remix-core-plugin/compiler-metadata/src/lib/compiler-metadata.ts b/libs/remix-core-plugin/compiler-metadata/src/lib/compiler-metadata.ts new file mode 100644 index 0000000000..1991cfd2ae --- /dev/null +++ b/libs/remix-core-plugin/compiler-metadata/src/lib/compiler-metadata.ts @@ -0,0 +1,146 @@ +'use strict' +import { Plugin } from '@remixproject/engine' +import { CompilerAbstract } from '@remix-project/remix-solidity' + +const profile = { + name: 'compilerMetadata', + methods: ['deployMetadataOf'], + events: [], + version: '0.0.1' +} + +export class CompilerMetadata extends Plugin { + networks: string[] + innerPath: string + constructor () { + super(profile) + this.networks = ['VM:-', 'main:1', 'ropsten:3', 'rinkeby:4', 'kovan:42', 'görli:5', 'Custom'] + this.innerPath = 'artifacts' + } + + _JSONFileName (path, contractName) { + return this.joinPath(path, this.innerPath, contractName + '.json') + } + + _MetadataFileName (path, contractName) { + return this.joinPath(path, this.innerPath, contractName + '_metadata.json') + } + + onActivation () { + var self = this + this.on('solidity', 'compilationFinished', async (file, source, languageVersion, data) => { + if (!await this.call('settings', 'get', 'settings/generate-contract-metadata')) return + const compiler = new CompilerAbstract(languageVersion, data, source) + var path = self._extractPathOf(source.target) + compiler.visitContracts((contract) => { + if (contract.file !== source.target) return + (async () => { + const fileName = self._JSONFileName(path, contract.name) + const content = await this.call('fileManager', 'exists', fileName) ? await this.call('fileManager', 'readFile', fileName) : null + await this._setArtefacts(content, contract, path) + })() + }) + }) + } + + _extractPathOf (file) { + var reg = /(.*)(\/).*/ + var path = reg.exec(file) + return path ? path[1] : '/' + } + + async _setArtefacts (content, contract, path) { + content = content || '{}' + var metadata + try { + metadata = JSON.parse(content) + } catch (e) { + console.log(e) + } + var fileName = this._JSONFileName(path, contract.name) + var metadataFileName = this._MetadataFileName(path, contract.name) + + var deploy = metadata.deploy || {} + this.networks.forEach((network) => { + deploy[network] = this._syncContext(contract, deploy[network] || {}) + }) + + let parsedMetadata + try { + parsedMetadata = JSON.parse(contract.object.metadata) + } catch (e) { + console.log(e) + } + if (parsedMetadata) await this.call('fileManager', 'writeFile', metadataFileName, JSON.stringify(parsedMetadata, null, '\t')) + + var data = { + deploy, + data: { + bytecode: contract.object.evm.bytecode, + deployedBytecode: contract.object.evm.deployedBytecode, + gasEstimates: contract.object.evm.gasEstimates, + methodIdentifiers: contract.object.evm.methodIdentifiers + }, + abi: contract.object.abi + } + await this.call('fileManager', 'writeFile', fileName, JSON.stringify(data, null, '\t')) + } + + _syncContext (contract, metadata) { + var linkReferences = metadata.linkReferences + var autoDeployLib = metadata.autoDeployLib + if (!linkReferences) linkReferences = {} + if (autoDeployLib === undefined) autoDeployLib = true + + for (var libFile in contract.object.evm.bytecode.linkReferences) { + if (!linkReferences[libFile]) linkReferences[libFile] = {} + for (var lib in contract.object.evm.bytecode.linkReferences[libFile]) { + if (!linkReferences[libFile][lib]) { + linkReferences[libFile][lib] = '
' + } + } + } + metadata.linkReferences = linkReferences + metadata.autoDeployLib = autoDeployLib + return metadata + } + + async deployMetadataOf (contractName, fileLocation) { + let path + if (fileLocation) { + path = fileLocation.split('/') + path.pop() + path = path.join('/') + } else { + try { + path = this._extractPathOf(await this.call('fileManager', 'getCurrentFile')) + } catch (err) { + console.log(err) + throw new Error(err) + } + } + try { + const { id, name } = await this.call('network', 'detectNetwork') + const fileName = this._JSONFileName(path, contractName) + try { + const content = await this.call('fileManager', 'readFile', fileName) + if (!content) return null + let metadata = JSON.parse(content) + metadata = metadata.deploy || {} + return metadata[name + ':' + id] || metadata[name] || metadata[id] || metadata[name.toLowerCase() + ':' + id] || metadata[name.toLowerCase()] + } catch (err) { + console.log(err) + throw new Error(err) + } + } catch (err) { + console.log(err) + throw new Error(err) + } + } + + joinPath (...paths) { + paths = paths.filter((value) => value !== '').map((path) => path.replace(/^\/|\/$/g, '')) // remove first and last slash) + if (paths.length === 1) return paths[0] + return paths.join('/') + } +} diff --git a/libs/remix-core-plugin/compiler-metadata/tsconfig.json b/libs/remix-core-plugin/compiler-metadata/tsconfig.json new file mode 100644 index 0000000000..42882af48a --- /dev/null +++ b/libs/remix-core-plugin/compiler-metadata/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../../../tsconfig.json", + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + } + ] +} diff --git a/libs/remix-core-plugin/compiler-metadata/tsconfig.lib.json b/libs/remix-core-plugin/compiler-metadata/tsconfig.lib.json new file mode 100644 index 0000000000..9c463b51e2 --- /dev/null +++ b/libs/remix-core-plugin/compiler-metadata/tsconfig.lib.json @@ -0,0 +1,12 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "commonjs", + "outDir": "../../../dist/out-tsc", + "declaration": true, + "rootDir": "./src", + "types": ["node"] + }, + "exclude": ["**/*.spec.ts"], + "include": ["**/*.ts"] +} diff --git a/nx.json b/nx.json index dcfee1205d..3549933180 100644 --- a/nx.json +++ b/nx.json @@ -114,6 +114,9 @@ }, "offset-line-to-column-converter": { "tags": [] + }, + "compiler-metadata": { + "tags": [] } } } diff --git a/tsconfig.json b/tsconfig.json index 88cef54a3f..bf1134b50c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -52,6 +52,9 @@ ], "@remix-core-plugin/offset-line-to-column-converter": [ "libs/remix-core-plugin/offset-line-to-column-converter/src/index.ts" + ], + "@remix-core-plugin/compiler-metadata": [ + "libs/remix-core-plugin/compiler-metadata/src/index.ts" ] } }, diff --git a/workspace.json b/workspace.json index 0f6a4698fe..c01f8cd138 100644 --- a/workspace.json +++ b/workspace.json @@ -840,7 +840,6 @@ ] } }, - "build": { "builder": "@nrwl/node:package", "options": { @@ -881,6 +880,36 @@ } } } + }, + "compiler-metadata": { + "root": "libs/remix-core-plugin/compiler-metadata", + "sourceRoot": "libs/remix-core-plugin/compiler-metadata/src", + "projectType": "library", + "schematics": {}, + "architect": { + "lint": { + "builder": "@nrwl/linter:lint", + "options": { + "linter": "eslint", + "tsConfig": [ + "libs/remix-core-plugin/compiler-metadata/tsconfig.lib.json" + ], + "exclude": [ + "**/node_modules/**", + "!libs/remix-core-plugin/compiler-metadata/**/*" + ] + } + }, + "build": { + "builder": "@nrwl/node:package", + "options": { + "outputPath": "dist/libs/core-plugin/compiler-metadata", + "tsConfig": "libs/remix-core-plugin/compiler-metadata/tsconfig.lib.json", + "packageJson": "libs/remix-core-plugin/compiler-metadata/package.json", + "main": "libs/remix-core-plugin/compiler-metadata/src/index.ts" + } + } + } } }, "cli": { From 138589a88a100de323c3aa7c0a5f99eef4e80e98 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Mon, 28 Jun 2021 17:31:28 +0200 Subject: [PATCH 04/17] lint --- apps/remix-ide/src/app.js | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/remix-ide/src/app.js b/apps/remix-ide/src/app.js index 039d0a9c15..520f32d31a 100644 --- a/apps/remix-ide/src/app.js +++ b/apps/remix-ide/src/app.js @@ -44,7 +44,6 @@ const DGitProvider = require('./app/files/dgitProvider') const WorkspaceFileProvider = require('./app/files/workspaceFileProvider') const toolTip = require('./app/ui/tooltip') - const Blockchain = require('./blockchain/blockchain.js') const PluginManagerComponent = require('./app/components/plugin-manager-component') From 641c58e3d518c3cdd157070bd935161737426d1b Mon Sep 17 00:00:00 2001 From: filip mertens Date: Mon, 28 Jun 2021 18:41:57 +0200 Subject: [PATCH 05/17] return null --- .../compiler-metadata/src/lib/compiler-metadata.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libs/remix-core-plugin/compiler-metadata/src/lib/compiler-metadata.ts b/libs/remix-core-plugin/compiler-metadata/src/lib/compiler-metadata.ts index 1991cfd2ae..d194c0281d 100644 --- a/libs/remix-core-plugin/compiler-metadata/src/lib/compiler-metadata.ts +++ b/libs/remix-core-plugin/compiler-metadata/src/lib/compiler-metadata.ts @@ -129,8 +129,7 @@ export class CompilerMetadata extends Plugin { metadata = metadata.deploy || {} return metadata[name + ':' + id] || metadata[name] || metadata[id] || metadata[name.toLowerCase() + ':' + id] || metadata[name.toLowerCase()] } catch (err) { - console.log(err) - throw new Error(err) + return null } } catch (err) { console.log(err) From 0ce42c1cb7d7aaf830e1b7f055fb47684219e1e0 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Wed, 30 Jun 2021 08:44:29 +0200 Subject: [PATCH 06/17] core-plugin -> @remix-project --- apps/remix-ide/src/app.js | 10 +++++----- apps/remix-ide/src/app/files/fileProvider.js | 2 +- apps/remix-ide/src/app/ui/landing-page/landing-page.js | 2 +- apps/remix-ide/src/lib/cmdInterpreterAPI.js | 2 +- libs/remix-core-plugin/compiler-artefacts/package.json | 2 +- .../compiler-content-imports/package.json | 2 +- .../compiler-fetch-and-compile/package.json | 2 +- libs/remix-core-plugin/compiler-metadata/package.json | 2 +- .../offset-line-to-column-converter/package.json | 2 +- nx.json | 2 +- package-lock.json | 6 ------ tsconfig.json | 10 +++++----- 12 files changed, 19 insertions(+), 25 deletions(-) diff --git a/apps/remix-ide/src/app.js b/apps/remix-ide/src/app.js index 520f32d31a..ed7f86fc1b 100644 --- a/apps/remix-ide/src/app.js +++ b/apps/remix-ide/src/app.js @@ -17,11 +17,11 @@ import { VerticalIcons } from './app/components/vertical-icons' import { LandingPage } from './app/ui/landing-page/landing-page' import { MainPanel } from './app/components/main-panel' -import { CompilerArtefacts } from '@remix-core-plugin/compiler-artefacts' -import { CompilerImports } from '@remix-core-plugin/compiler-content-imports' -import { FetchAndCompile } from '@remix-core-plugin/compiler-fetch-and-compile' -import { OffsetToLineColumnConverter } from '@remix-core-plugin/offset-line-to-column-converter' -import { CompilerMetadata } from '@remix-core-plugin/compiler-metadata' +import { CompilerArtefacts } from '@remix-project/compiler-artefacts' +import { CompilerImports } from '@remix-project/compiler-content-imports' +import { FetchAndCompile } from '@remix-project/compiler-fetch-and-compile' +import { OffsetToLineColumnConverter } from '@remix-project/offset-line-to-column-converter' +import { CompilerMetadata } from '@remix-project/compiler-metadata' import migrateFileSystem from './migrateFileSystem' diff --git a/apps/remix-ide/src/app/files/fileProvider.js b/apps/remix-ide/src/app/files/fileProvider.js index 288eabe518..ef8f9f8a93 100644 --- a/apps/remix-ide/src/app/files/fileProvider.js +++ b/apps/remix-ide/src/app/files/fileProvider.js @@ -1,6 +1,6 @@ 'use strict' -import { CompilerImports } from '@remix-core-plugin/compiler-content-imports' +import { CompilerImports } from '@remix-project/compiler-content-imports' const EventManager = require('events') const modalDialogCustom = require('../ui/modal-dialog-custom') const tooltip = require('../ui/tooltip') diff --git a/apps/remix-ide/src/app/ui/landing-page/landing-page.js b/apps/remix-ide/src/app/ui/landing-page/landing-page.js index 7f02892809..039c47fb92 100644 --- a/apps/remix-ide/src/app/ui/landing-page/landing-page.js +++ b/apps/remix-ide/src/app/ui/landing-page/landing-page.js @@ -1,7 +1,7 @@ import * as packageJson from '../../../../../../package.json' import { ViewPlugin } from '@remixproject/engine-web' import { migrateToWorkspace } from '../../../migrateFileSystem' -import { CompilerImports } from '@remix-core-plugin/compiler-content-imports' +import { CompilerImports } from '@remix-project/compiler-content-imports' import JSZip from 'jszip' const yo = require('yo-yo') diff --git a/apps/remix-ide/src/lib/cmdInterpreterAPI.js b/apps/remix-ide/src/lib/cmdInterpreterAPI.js index e8bb3e000e..7717e4b7d4 100644 --- a/apps/remix-ide/src/lib/cmdInterpreterAPI.js +++ b/apps/remix-ide/src/lib/cmdInterpreterAPI.js @@ -1,5 +1,5 @@ 'use strict' -import { CompilerImports } from '@remix-core-plugin/compiler-content-imports' +import { CompilerImports } from '@remix-project/compiler-content-imports' var yo = require('yo-yo') var async = require('async') var EventManager = require('../lib/events') diff --git a/libs/remix-core-plugin/compiler-artefacts/package.json b/libs/remix-core-plugin/compiler-artefacts/package.json index 046a760da7..55606a6759 100644 --- a/libs/remix-core-plugin/compiler-artefacts/package.json +++ b/libs/remix-core-plugin/compiler-artefacts/package.json @@ -1,5 +1,5 @@ { - "name": "@remix-core-plugin/compiler-artefacts", + "name": "@remix-project/compiler-artefacts", "version": "0.0.1", "description": "This library was generated with [Nx](https://nx.dev).", "main": "index.js", diff --git a/libs/remix-core-plugin/compiler-content-imports/package.json b/libs/remix-core-plugin/compiler-content-imports/package.json index 95af3c807c..3124552151 100644 --- a/libs/remix-core-plugin/compiler-content-imports/package.json +++ b/libs/remix-core-plugin/compiler-content-imports/package.json @@ -1,5 +1,5 @@ { - "name": "@remix-core-plugin/compiler-content-imports", + "name": "@remix-project/compiler-content-imports", "version": "0.0.1", "description": "This library was generated with [Nx](https://nx.dev).", "main": "index.js", diff --git a/libs/remix-core-plugin/compiler-fetch-and-compile/package.json b/libs/remix-core-plugin/compiler-fetch-and-compile/package.json index 05dfdb3372..0e41b098a3 100644 --- a/libs/remix-core-plugin/compiler-fetch-and-compile/package.json +++ b/libs/remix-core-plugin/compiler-fetch-and-compile/package.json @@ -1,5 +1,5 @@ { - "name": "@remix-core-plugin/compiler-fetch-and-compile", + "name": "@remix-project/compiler-fetch-and-compile", "version": "0.0.1", "description": "This library was generated with [Nx](https://nx.dev).", "main": "index.js", diff --git a/libs/remix-core-plugin/compiler-metadata/package.json b/libs/remix-core-plugin/compiler-metadata/package.json index f8a22f5ab6..1b0c0ef678 100644 --- a/libs/remix-core-plugin/compiler-metadata/package.json +++ b/libs/remix-core-plugin/compiler-metadata/package.json @@ -1,5 +1,5 @@ { - "name": "@remix-core-plugin/compiler-metadata", + "name": "@remix-project/compiler-metadata", "version": "0.0.1", "description": "This library was generated with [Nx](https://nx.dev).", "main": "index.js", diff --git a/libs/remix-core-plugin/offset-line-to-column-converter/package.json b/libs/remix-core-plugin/offset-line-to-column-converter/package.json index 761b79682e..4554680180 100644 --- a/libs/remix-core-plugin/offset-line-to-column-converter/package.json +++ b/libs/remix-core-plugin/offset-line-to-column-converter/package.json @@ -1,5 +1,5 @@ { - "name": "@remix-core-plugin/offset-line-to-column-converter", + "name": "@remix-project/offset-line-to-column-converter", "version": "0.0.1", "description": "This library was generated with [Nx](https://nx.dev).", "main": "index.js", diff --git a/nx.json b/nx.json index 3549933180..0c247fcf7c 100644 --- a/nx.json +++ b/nx.json @@ -104,7 +104,7 @@ }, "compiler-artefacts": { "tags": [], - "implicitDependencies": ["remix-lib"] + "implicitDependencies": ["remix-lib", "remix-solidity"] }, "compiler-fetch-and-compile": { "tags": [] diff --git a/package-lock.json b/package-lock.json index fb58209d79..c2707a9707 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17553,12 +17553,6 @@ "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" }, - "fsevents": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", - "optional": true - }, "fstream": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.11.tgz", diff --git a/tsconfig.json b/tsconfig.json index bf1134b50c..5f0dc24d8f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -41,19 +41,19 @@ "@remix-ui/workspace": ["libs/remix-ui/workspace/src/index.ts"], "@remix-ui/static-analyser": ["libs/remix-ui/static-analyser/src/index.ts"], "@remix-ui/checkbox": ["libs/remix-ui/checkbox/src/index.ts"], - "@remix-core-plugin/compiler-artefacts": [ + "@remix-project/compiler-artefacts": [ "libs/remix-core-plugin/compiler-artefacts/src/index.ts" ], - "@remix-core-plugin/compiler-fetch-and-compile": [ + "@remix-project/compiler-fetch-and-compile": [ "libs/remix-core-plugin/compiler-fetch-and-compile/src/index.ts" ], - "@remix-core-plugin/compiler-content-imports": [ + "@remix-project/compiler-content-imports": [ "libs/remix-core-plugin/compiler-content-imports/src/index.ts" ], - "@remix-core-plugin/offset-line-to-column-converter": [ + "@remix-project/offset-line-to-column-converter": [ "libs/remix-core-plugin/offset-line-to-column-converter/src/index.ts" ], - "@remix-core-plugin/compiler-metadata": [ + "@remix-project/compiler-metadata": [ "libs/remix-core-plugin/compiler-metadata/src/index.ts" ] } From 0f654603639bc77408919669550131c28d034744 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Wed, 30 Jun 2021 10:47:52 +0200 Subject: [PATCH 07/17] mv to core-plugin package --- apps/remix-ide/src/app.js | 6 +- apps/remix-ide/src/app/files/fileProvider.js | 2 +- .../src/app/ui/landing-page/landing-page.js | 2 +- apps/remix-ide/src/lib/cmdInterpreterAPI.js | 2 +- libs/remix-core-plugin/.eslintrc | 1 + .../{compiler-content-imports => }/README.md | 2 +- .../compiler-artefacts/.eslintrc | 1 - .../compiler-artefacts/README.md | 3 - .../compiler-artefacts/package.json | 11 -- .../compiler-artefacts/src/index.ts | 1 - .../compiler-artefacts/tsconfig.lib.json | 12 -- .../compiler-content-imports/.eslintrc | 1 - .../compiler-content-imports/package.json | 11 -- .../compiler-content-imports/src/index.ts | 1 - .../compiler-content-imports/tsconfig.json | 10 -- .../compiler-fetch-and-compile/.eslintrc | 1 - .../compiler-fetch-and-compile/README.md | 3 - .../compiler-fetch-and-compile/package.json | 11 -- .../compiler-fetch-and-compile/src/index.ts | 1 - .../compiler-fetch-and-compile/tsconfig.json | 10 -- .../tsconfig.lib.json | 12 -- .../compiler-metadata/.eslintrc | 1 - .../compiler-metadata/README.md | 3 - .../compiler-metadata/package.json | 11 -- .../compiler-metadata/src/index.ts | 1 - .../compiler-metadata/tsconfig.json | 10 -- .../compiler-metadata/tsconfig.lib.json | 12 -- .../offset-line-to-column-converter/.eslintrc | 1 - .../offset-line-to-column-converter/README.md | 3 - .../package.json | 11 -- .../src/index.ts | 1 - .../tsconfig.json | 10 -- .../tsconfig.lib.json | 12 -- libs/remix-core-plugin/package.json | 12 ++ libs/remix-core-plugin/src/index.ts | 4 + .../src/lib/compiler-artefacts.ts | 0 .../src/lib/compiler-content-imports.ts | 0 .../src/lib/compiler-fetch-and-compile.ts | 0 .../src/lib/compiler-metadata.ts | 0 .../lib/offset-line-to-column-converter.ts | 0 .../{compiler-artefacts => }/tsconfig.json | 2 +- .../tsconfig.lib.json | 2 +- nx.json | 15 +- tsconfig.json | 20 +-- workspace.json | 138 ++---------------- 45 files changed, 39 insertions(+), 334 deletions(-) create mode 100644 libs/remix-core-plugin/.eslintrc rename libs/remix-core-plugin/{compiler-content-imports => }/README.md (63%) delete mode 100644 libs/remix-core-plugin/compiler-artefacts/.eslintrc delete mode 100644 libs/remix-core-plugin/compiler-artefacts/README.md delete mode 100644 libs/remix-core-plugin/compiler-artefacts/package.json delete mode 100644 libs/remix-core-plugin/compiler-artefacts/src/index.ts delete mode 100644 libs/remix-core-plugin/compiler-artefacts/tsconfig.lib.json delete mode 100644 libs/remix-core-plugin/compiler-content-imports/.eslintrc delete mode 100644 libs/remix-core-plugin/compiler-content-imports/package.json delete mode 100644 libs/remix-core-plugin/compiler-content-imports/src/index.ts delete mode 100644 libs/remix-core-plugin/compiler-content-imports/tsconfig.json delete mode 100644 libs/remix-core-plugin/compiler-fetch-and-compile/.eslintrc delete mode 100644 libs/remix-core-plugin/compiler-fetch-and-compile/README.md delete mode 100644 libs/remix-core-plugin/compiler-fetch-and-compile/package.json delete mode 100644 libs/remix-core-plugin/compiler-fetch-and-compile/src/index.ts delete mode 100644 libs/remix-core-plugin/compiler-fetch-and-compile/tsconfig.json delete mode 100644 libs/remix-core-plugin/compiler-fetch-and-compile/tsconfig.lib.json delete mode 100644 libs/remix-core-plugin/compiler-metadata/.eslintrc delete mode 100644 libs/remix-core-plugin/compiler-metadata/README.md delete mode 100644 libs/remix-core-plugin/compiler-metadata/package.json delete mode 100644 libs/remix-core-plugin/compiler-metadata/src/index.ts delete mode 100644 libs/remix-core-plugin/compiler-metadata/tsconfig.json delete mode 100644 libs/remix-core-plugin/compiler-metadata/tsconfig.lib.json delete mode 100644 libs/remix-core-plugin/offset-line-to-column-converter/.eslintrc delete mode 100644 libs/remix-core-plugin/offset-line-to-column-converter/README.md delete mode 100644 libs/remix-core-plugin/offset-line-to-column-converter/package.json delete mode 100644 libs/remix-core-plugin/offset-line-to-column-converter/src/index.ts delete mode 100644 libs/remix-core-plugin/offset-line-to-column-converter/tsconfig.json delete mode 100644 libs/remix-core-plugin/offset-line-to-column-converter/tsconfig.lib.json create mode 100644 libs/remix-core-plugin/package.json create mode 100644 libs/remix-core-plugin/src/index.ts rename libs/remix-core-plugin/{compiler-artefacts => }/src/lib/compiler-artefacts.ts (100%) rename libs/remix-core-plugin/{compiler-content-imports => }/src/lib/compiler-content-imports.ts (100%) rename libs/remix-core-plugin/{compiler-fetch-and-compile => }/src/lib/compiler-fetch-and-compile.ts (100%) rename libs/remix-core-plugin/{compiler-metadata => }/src/lib/compiler-metadata.ts (100%) rename libs/remix-core-plugin/{offset-line-to-column-converter => }/src/lib/offset-line-to-column-converter.ts (100%) rename libs/remix-core-plugin/{compiler-artefacts => }/tsconfig.json (73%) rename libs/remix-core-plugin/{compiler-content-imports => }/tsconfig.lib.json (84%) diff --git a/apps/remix-ide/src/app.js b/apps/remix-ide/src/app.js index ed7f86fc1b..5bcc3db57b 100644 --- a/apps/remix-ide/src/app.js +++ b/apps/remix-ide/src/app.js @@ -17,11 +17,7 @@ import { VerticalIcons } from './app/components/vertical-icons' import { LandingPage } from './app/ui/landing-page/landing-page' import { MainPanel } from './app/components/main-panel' -import { CompilerArtefacts } from '@remix-project/compiler-artefacts' -import { CompilerImports } from '@remix-project/compiler-content-imports' -import { FetchAndCompile } from '@remix-project/compiler-fetch-and-compile' -import { OffsetToLineColumnConverter } from '@remix-project/offset-line-to-column-converter' -import { CompilerMetadata } from '@remix-project/compiler-metadata' +import { OffsetToLineColumnConverter, CompilerMetadata, CompilerArtefacts, FetchAndCompile, CompilerImports } from '@remix-project/core-plugin' import migrateFileSystem from './migrateFileSystem' diff --git a/apps/remix-ide/src/app/files/fileProvider.js b/apps/remix-ide/src/app/files/fileProvider.js index ef8f9f8a93..c789635160 100644 --- a/apps/remix-ide/src/app/files/fileProvider.js +++ b/apps/remix-ide/src/app/files/fileProvider.js @@ -1,6 +1,6 @@ 'use strict' -import { CompilerImports } from '@remix-project/compiler-content-imports' +import { CompilerImports } from '@remix-project/core-plugin' const EventManager = require('events') const modalDialogCustom = require('../ui/modal-dialog-custom') const tooltip = require('../ui/tooltip') diff --git a/apps/remix-ide/src/app/ui/landing-page/landing-page.js b/apps/remix-ide/src/app/ui/landing-page/landing-page.js index 039c47fb92..8652017b2a 100644 --- a/apps/remix-ide/src/app/ui/landing-page/landing-page.js +++ b/apps/remix-ide/src/app/ui/landing-page/landing-page.js @@ -1,7 +1,7 @@ import * as packageJson from '../../../../../../package.json' import { ViewPlugin } from '@remixproject/engine-web' import { migrateToWorkspace } from '../../../migrateFileSystem' -import { CompilerImports } from '@remix-project/compiler-content-imports' +import { CompilerImports } from '@remix-project/core-plugin' import JSZip from 'jszip' const yo = require('yo-yo') diff --git a/apps/remix-ide/src/lib/cmdInterpreterAPI.js b/apps/remix-ide/src/lib/cmdInterpreterAPI.js index 7717e4b7d4..9c79cae25b 100644 --- a/apps/remix-ide/src/lib/cmdInterpreterAPI.js +++ b/apps/remix-ide/src/lib/cmdInterpreterAPI.js @@ -1,5 +1,5 @@ 'use strict' -import { CompilerImports } from '@remix-project/compiler-content-imports' +import { CompilerImports } from '@remix-project/core-plugin' var yo = require('yo-yo') var async = require('async') var EventManager = require('../lib/events') diff --git a/libs/remix-core-plugin/.eslintrc b/libs/remix-core-plugin/.eslintrc new file mode 100644 index 0000000000..ab8f38339c --- /dev/null +++ b/libs/remix-core-plugin/.eslintrc @@ -0,0 +1 @@ +{ "extends": "../../.eslintrc", "rules": {}, "ignorePatterns": ["!**/*"] } diff --git a/libs/remix-core-plugin/compiler-content-imports/README.md b/libs/remix-core-plugin/README.md similarity index 63% rename from libs/remix-core-plugin/compiler-content-imports/README.md rename to libs/remix-core-plugin/README.md index 38165da82b..fc60297f57 100644 --- a/libs/remix-core-plugin/compiler-content-imports/README.md +++ b/libs/remix-core-plugin/README.md @@ -1,3 +1,3 @@ -# compiler-content-imports +# remix-core-plugin-core-plugin This library was generated with [Nx](https://nx.dev). diff --git a/libs/remix-core-plugin/compiler-artefacts/.eslintrc b/libs/remix-core-plugin/compiler-artefacts/.eslintrc deleted file mode 100644 index 1655d72922..0000000000 --- a/libs/remix-core-plugin/compiler-artefacts/.eslintrc +++ /dev/null @@ -1 +0,0 @@ -{ "extends": "../../../.eslintrc", "rules": {}, "ignorePatterns": ["!**/*"] } diff --git a/libs/remix-core-plugin/compiler-artefacts/README.md b/libs/remix-core-plugin/compiler-artefacts/README.md deleted file mode 100644 index b3c08632bc..0000000000 --- a/libs/remix-core-plugin/compiler-artefacts/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# compiler-artefacts - -This library was generated with [Nx](https://nx.dev). diff --git a/libs/remix-core-plugin/compiler-artefacts/package.json b/libs/remix-core-plugin/compiler-artefacts/package.json deleted file mode 100644 index 55606a6759..0000000000 --- a/libs/remix-core-plugin/compiler-artefacts/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "@remix-project/compiler-artefacts", - "version": "0.0.1", - "description": "This library was generated with [Nx](https://nx.dev).", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "Remix Team", - "license": "ISC" -} diff --git a/libs/remix-core-plugin/compiler-artefacts/src/index.ts b/libs/remix-core-plugin/compiler-artefacts/src/index.ts deleted file mode 100644 index c11c162acb..0000000000 --- a/libs/remix-core-plugin/compiler-artefacts/src/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './lib/compiler-artefacts' diff --git a/libs/remix-core-plugin/compiler-artefacts/tsconfig.lib.json b/libs/remix-core-plugin/compiler-artefacts/tsconfig.lib.json deleted file mode 100644 index 9c463b51e2..0000000000 --- a/libs/remix-core-plugin/compiler-artefacts/tsconfig.lib.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "module": "commonjs", - "outDir": "../../../dist/out-tsc", - "declaration": true, - "rootDir": "./src", - "types": ["node"] - }, - "exclude": ["**/*.spec.ts"], - "include": ["**/*.ts"] -} diff --git a/libs/remix-core-plugin/compiler-content-imports/.eslintrc b/libs/remix-core-plugin/compiler-content-imports/.eslintrc deleted file mode 100644 index 1655d72922..0000000000 --- a/libs/remix-core-plugin/compiler-content-imports/.eslintrc +++ /dev/null @@ -1 +0,0 @@ -{ "extends": "../../../.eslintrc", "rules": {}, "ignorePatterns": ["!**/*"] } diff --git a/libs/remix-core-plugin/compiler-content-imports/package.json b/libs/remix-core-plugin/compiler-content-imports/package.json deleted file mode 100644 index 3124552151..0000000000 --- a/libs/remix-core-plugin/compiler-content-imports/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "@remix-project/compiler-content-imports", - "version": "0.0.1", - "description": "This library was generated with [Nx](https://nx.dev).", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "Remix Team", - "license": "ISC" -} diff --git a/libs/remix-core-plugin/compiler-content-imports/src/index.ts b/libs/remix-core-plugin/compiler-content-imports/src/index.ts deleted file mode 100644 index f6219a88b3..0000000000 --- a/libs/remix-core-plugin/compiler-content-imports/src/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './lib/compiler-content-imports' diff --git a/libs/remix-core-plugin/compiler-content-imports/tsconfig.json b/libs/remix-core-plugin/compiler-content-imports/tsconfig.json deleted file mode 100644 index 42882af48a..0000000000 --- a/libs/remix-core-plugin/compiler-content-imports/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "../../../tsconfig.json", - "files": [], - "include": [], - "references": [ - { - "path": "./tsconfig.lib.json" - } - ] -} diff --git a/libs/remix-core-plugin/compiler-fetch-and-compile/.eslintrc b/libs/remix-core-plugin/compiler-fetch-and-compile/.eslintrc deleted file mode 100644 index 1655d72922..0000000000 --- a/libs/remix-core-plugin/compiler-fetch-and-compile/.eslintrc +++ /dev/null @@ -1 +0,0 @@ -{ "extends": "../../../.eslintrc", "rules": {}, "ignorePatterns": ["!**/*"] } diff --git a/libs/remix-core-plugin/compiler-fetch-and-compile/README.md b/libs/remix-core-plugin/compiler-fetch-and-compile/README.md deleted file mode 100644 index 5c2aca3ead..0000000000 --- a/libs/remix-core-plugin/compiler-fetch-and-compile/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# compiler-fetch-and-compile - -This library was generated with [Nx](https://nx.dev). diff --git a/libs/remix-core-plugin/compiler-fetch-and-compile/package.json b/libs/remix-core-plugin/compiler-fetch-and-compile/package.json deleted file mode 100644 index 0e41b098a3..0000000000 --- a/libs/remix-core-plugin/compiler-fetch-and-compile/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "@remix-project/compiler-fetch-and-compile", - "version": "0.0.1", - "description": "This library was generated with [Nx](https://nx.dev).", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "Remix Team", - "license": "ISC" -} diff --git a/libs/remix-core-plugin/compiler-fetch-and-compile/src/index.ts b/libs/remix-core-plugin/compiler-fetch-and-compile/src/index.ts deleted file mode 100644 index 2d387c7552..0000000000 --- a/libs/remix-core-plugin/compiler-fetch-and-compile/src/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './lib/compiler-fetch-and-compile' diff --git a/libs/remix-core-plugin/compiler-fetch-and-compile/tsconfig.json b/libs/remix-core-plugin/compiler-fetch-and-compile/tsconfig.json deleted file mode 100644 index 42882af48a..0000000000 --- a/libs/remix-core-plugin/compiler-fetch-and-compile/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "../../../tsconfig.json", - "files": [], - "include": [], - "references": [ - { - "path": "./tsconfig.lib.json" - } - ] -} diff --git a/libs/remix-core-plugin/compiler-fetch-and-compile/tsconfig.lib.json b/libs/remix-core-plugin/compiler-fetch-and-compile/tsconfig.lib.json deleted file mode 100644 index 9c463b51e2..0000000000 --- a/libs/remix-core-plugin/compiler-fetch-and-compile/tsconfig.lib.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "module": "commonjs", - "outDir": "../../../dist/out-tsc", - "declaration": true, - "rootDir": "./src", - "types": ["node"] - }, - "exclude": ["**/*.spec.ts"], - "include": ["**/*.ts"] -} diff --git a/libs/remix-core-plugin/compiler-metadata/.eslintrc b/libs/remix-core-plugin/compiler-metadata/.eslintrc deleted file mode 100644 index 1655d72922..0000000000 --- a/libs/remix-core-plugin/compiler-metadata/.eslintrc +++ /dev/null @@ -1 +0,0 @@ -{ "extends": "../../../.eslintrc", "rules": {}, "ignorePatterns": ["!**/*"] } diff --git a/libs/remix-core-plugin/compiler-metadata/README.md b/libs/remix-core-plugin/compiler-metadata/README.md deleted file mode 100644 index 96888a605b..0000000000 --- a/libs/remix-core-plugin/compiler-metadata/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# remix-core-plugin-compiler-metadata - -This library was generated with [Nx](https://nx.dev). diff --git a/libs/remix-core-plugin/compiler-metadata/package.json b/libs/remix-core-plugin/compiler-metadata/package.json deleted file mode 100644 index 1b0c0ef678..0000000000 --- a/libs/remix-core-plugin/compiler-metadata/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "@remix-project/compiler-metadata", - "version": "0.0.1", - "description": "This library was generated with [Nx](https://nx.dev).", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "Remix Team", - "license": "ISC" -} diff --git a/libs/remix-core-plugin/compiler-metadata/src/index.ts b/libs/remix-core-plugin/compiler-metadata/src/index.ts deleted file mode 100644 index 2b81c60e16..0000000000 --- a/libs/remix-core-plugin/compiler-metadata/src/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './lib/compiler-metadata' diff --git a/libs/remix-core-plugin/compiler-metadata/tsconfig.json b/libs/remix-core-plugin/compiler-metadata/tsconfig.json deleted file mode 100644 index 42882af48a..0000000000 --- a/libs/remix-core-plugin/compiler-metadata/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "../../../tsconfig.json", - "files": [], - "include": [], - "references": [ - { - "path": "./tsconfig.lib.json" - } - ] -} diff --git a/libs/remix-core-plugin/compiler-metadata/tsconfig.lib.json b/libs/remix-core-plugin/compiler-metadata/tsconfig.lib.json deleted file mode 100644 index 9c463b51e2..0000000000 --- a/libs/remix-core-plugin/compiler-metadata/tsconfig.lib.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "module": "commonjs", - "outDir": "../../../dist/out-tsc", - "declaration": true, - "rootDir": "./src", - "types": ["node"] - }, - "exclude": ["**/*.spec.ts"], - "include": ["**/*.ts"] -} diff --git a/libs/remix-core-plugin/offset-line-to-column-converter/.eslintrc b/libs/remix-core-plugin/offset-line-to-column-converter/.eslintrc deleted file mode 100644 index 1655d72922..0000000000 --- a/libs/remix-core-plugin/offset-line-to-column-converter/.eslintrc +++ /dev/null @@ -1 +0,0 @@ -{ "extends": "../../../.eslintrc", "rules": {}, "ignorePatterns": ["!**/*"] } diff --git a/libs/remix-core-plugin/offset-line-to-column-converter/README.md b/libs/remix-core-plugin/offset-line-to-column-converter/README.md deleted file mode 100644 index 17a2dea5c3..0000000000 --- a/libs/remix-core-plugin/offset-line-to-column-converter/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# offset-line-to-column-converter - -This library was generated with [Nx](https://nx.dev). diff --git a/libs/remix-core-plugin/offset-line-to-column-converter/package.json b/libs/remix-core-plugin/offset-line-to-column-converter/package.json deleted file mode 100644 index 4554680180..0000000000 --- a/libs/remix-core-plugin/offset-line-to-column-converter/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "@remix-project/offset-line-to-column-converter", - "version": "0.0.1", - "description": "This library was generated with [Nx](https://nx.dev).", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "Remix Team", - "license": "ISC" -} diff --git a/libs/remix-core-plugin/offset-line-to-column-converter/src/index.ts b/libs/remix-core-plugin/offset-line-to-column-converter/src/index.ts deleted file mode 100644 index d2699060ec..0000000000 --- a/libs/remix-core-plugin/offset-line-to-column-converter/src/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './lib/offset-line-to-column-converter' diff --git a/libs/remix-core-plugin/offset-line-to-column-converter/tsconfig.json b/libs/remix-core-plugin/offset-line-to-column-converter/tsconfig.json deleted file mode 100644 index 42882af48a..0000000000 --- a/libs/remix-core-plugin/offset-line-to-column-converter/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "../../../tsconfig.json", - "files": [], - "include": [], - "references": [ - { - "path": "./tsconfig.lib.json" - } - ] -} diff --git a/libs/remix-core-plugin/offset-line-to-column-converter/tsconfig.lib.json b/libs/remix-core-plugin/offset-line-to-column-converter/tsconfig.lib.json deleted file mode 100644 index 9c463b51e2..0000000000 --- a/libs/remix-core-plugin/offset-line-to-column-converter/tsconfig.lib.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "module": "commonjs", - "outDir": "../../../dist/out-tsc", - "declaration": true, - "rootDir": "./src", - "types": ["node"] - }, - "exclude": ["**/*.spec.ts"], - "include": ["**/*.ts"] -} diff --git a/libs/remix-core-plugin/package.json b/libs/remix-core-plugin/package.json new file mode 100644 index 0000000000..dcdc862128 --- /dev/null +++ b/libs/remix-core-plugin/package.json @@ -0,0 +1,12 @@ +{ + "name": "@remix-project/core-plugin", + "version": "0.0.1", + "description": "This library was generated with [Nx](https://nx.dev).", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "Remix Team", + "license": "ISC" + } + \ No newline at end of file diff --git a/libs/remix-core-plugin/src/index.ts b/libs/remix-core-plugin/src/index.ts new file mode 100644 index 0000000000..863c411740 --- /dev/null +++ b/libs/remix-core-plugin/src/index.ts @@ -0,0 +1,4 @@ +export * from './lib/offset-line-to-column-converter' +export * from './lib/compiler-metadata' +export * from './lib/compiler-fetch-and-compile' +export * from './lib/offset-line-to-column-converter' diff --git a/libs/remix-core-plugin/compiler-artefacts/src/lib/compiler-artefacts.ts b/libs/remix-core-plugin/src/lib/compiler-artefacts.ts similarity index 100% rename from libs/remix-core-plugin/compiler-artefacts/src/lib/compiler-artefacts.ts rename to libs/remix-core-plugin/src/lib/compiler-artefacts.ts diff --git a/libs/remix-core-plugin/compiler-content-imports/src/lib/compiler-content-imports.ts b/libs/remix-core-plugin/src/lib/compiler-content-imports.ts similarity index 100% rename from libs/remix-core-plugin/compiler-content-imports/src/lib/compiler-content-imports.ts rename to libs/remix-core-plugin/src/lib/compiler-content-imports.ts diff --git a/libs/remix-core-plugin/compiler-fetch-and-compile/src/lib/compiler-fetch-and-compile.ts b/libs/remix-core-plugin/src/lib/compiler-fetch-and-compile.ts similarity index 100% rename from libs/remix-core-plugin/compiler-fetch-and-compile/src/lib/compiler-fetch-and-compile.ts rename to libs/remix-core-plugin/src/lib/compiler-fetch-and-compile.ts diff --git a/libs/remix-core-plugin/compiler-metadata/src/lib/compiler-metadata.ts b/libs/remix-core-plugin/src/lib/compiler-metadata.ts similarity index 100% rename from libs/remix-core-plugin/compiler-metadata/src/lib/compiler-metadata.ts rename to libs/remix-core-plugin/src/lib/compiler-metadata.ts diff --git a/libs/remix-core-plugin/offset-line-to-column-converter/src/lib/offset-line-to-column-converter.ts b/libs/remix-core-plugin/src/lib/offset-line-to-column-converter.ts similarity index 100% rename from libs/remix-core-plugin/offset-line-to-column-converter/src/lib/offset-line-to-column-converter.ts rename to libs/remix-core-plugin/src/lib/offset-line-to-column-converter.ts diff --git a/libs/remix-core-plugin/compiler-artefacts/tsconfig.json b/libs/remix-core-plugin/tsconfig.json similarity index 73% rename from libs/remix-core-plugin/compiler-artefacts/tsconfig.json rename to libs/remix-core-plugin/tsconfig.json index 42882af48a..f14da61cdf 100644 --- a/libs/remix-core-plugin/compiler-artefacts/tsconfig.json +++ b/libs/remix-core-plugin/tsconfig.json @@ -1,5 +1,5 @@ { - "extends": "../../../tsconfig.json", + "extends": "../../tsconfig.json", "files": [], "include": [], "references": [ diff --git a/libs/remix-core-plugin/compiler-content-imports/tsconfig.lib.json b/libs/remix-core-plugin/tsconfig.lib.json similarity index 84% rename from libs/remix-core-plugin/compiler-content-imports/tsconfig.lib.json rename to libs/remix-core-plugin/tsconfig.lib.json index 9c463b51e2..7e93feb2f8 100644 --- a/libs/remix-core-plugin/compiler-content-imports/tsconfig.lib.json +++ b/libs/remix-core-plugin/tsconfig.lib.json @@ -2,7 +2,7 @@ "extends": "./tsconfig.json", "compilerOptions": { "module": "commonjs", - "outDir": "../../../dist/out-tsc", + "outDir": "../../dist/out-tsc", "declaration": true, "rootDir": "./src", "types": ["node"] diff --git a/nx.json b/nx.json index 0c247fcf7c..5265d5274b 100644 --- a/nx.json +++ b/nx.json @@ -102,20 +102,7 @@ "remix-ui-checkbox": { "tags": [] }, - "compiler-artefacts": { - "tags": [], - "implicitDependencies": ["remix-lib", "remix-solidity"] - }, - "compiler-fetch-and-compile": { - "tags": [] - }, - "compiler-content-imports": { - "tags": [] - }, - "offset-line-to-column-converter": { - "tags": [] - }, - "compiler-metadata": { + "remix-core-plugin": { "tags": [] } } diff --git a/tsconfig.json b/tsconfig.json index 5f0dc24d8f..242856c0f9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -39,22 +39,12 @@ "@remix-ui/toaster": ["libs/remix-ui/toaster/src/index.ts"], "@remix-ui/file-explorer": ["libs/remix-ui/file-explorer/src/index.ts"], "@remix-ui/workspace": ["libs/remix-ui/workspace/src/index.ts"], - "@remix-ui/static-analyser": ["libs/remix-ui/static-analyser/src/index.ts"], - "@remix-ui/checkbox": ["libs/remix-ui/checkbox/src/index.ts"], - "@remix-project/compiler-artefacts": [ - "libs/remix-core-plugin/compiler-artefacts/src/index.ts" - ], - "@remix-project/compiler-fetch-and-compile": [ - "libs/remix-core-plugin/compiler-fetch-and-compile/src/index.ts" - ], - "@remix-project/compiler-content-imports": [ - "libs/remix-core-plugin/compiler-content-imports/src/index.ts" + "@remix-ui/static-analyser": [ + "libs/remix-ui/static-analyser/src/index.ts" ], - "@remix-project/offset-line-to-column-converter": [ - "libs/remix-core-plugin/offset-line-to-column-converter/src/index.ts" - ], - "@remix-project/compiler-metadata": [ - "libs/remix-core-plugin/compiler-metadata/src/index.ts" + "@remix-ui/checkbox": ["libs/remix-ui/checkbox/src/index.ts"], + "@remix-project/core-plugin": [ + "libs/remix-core-plugin/src/index.ts" ] } }, diff --git a/workspace.json b/workspace.json index c01f8cd138..1ec24e8e75 100644 --- a/workspace.json +++ b/workspace.json @@ -761,9 +761,9 @@ } } }, - "compiler-artefacts": { - "root": "libs/remix-core-plugin/compiler-artefacts", - "sourceRoot": "libs/remix-core-plugin/compiler-artefacts/src", + "remix-core-plugin": { + "root": "libs/remix-core-plugin", + "sourceRoot": "libs/remix-core-plugin/src", "projectType": "library", "schematics": {}, "architect": { @@ -772,141 +772,21 @@ "options": { "linter": "eslint", "tsConfig": [ - "libs/remix-core-plugin/compiler-artefacts/tsconfig.lib.json" + "libs/remix-core-plugin/tsconfig.lib.json" ], "exclude": [ "**/node_modules/**", - "!libs/remix-core-plugin/compiler-artefacts/**/*" + "!libs/remix-core-plugin/**/*" ] } }, "build": { "builder": "@nrwl/node:package", "options": { - "outputPath": "dist/libs/core-plugin/compiler-artefacts", - "tsConfig": "libs/remix-core-plugin/compiler-artefacts/tsconfig.lib.json", - "packageJson": "libs/remix-core-plugin/compiler-artefacts/package.json", - "main": "libs/remix-core-plugin/compiler-artefacts/src/index.ts" - } - } - } - }, - "compiler-fetch-and-compile": { - "root": "libs/remix-core-plugin/compiler-fetch-and-compile", - "sourceRoot": "libs/remix-core-plugin/compiler-fetch-and-compile/src", - "projectType": "library", - "schematics": {}, - "architect": { - "lint": { - "builder": "@nrwl/linter:lint", - "options": { - "linter": "eslint", - "tsConfig": [ - "libs/remix-core-plugin/compiler-fetch-and-compile/tsconfig.lib.json" - ], - "exclude": [ - "**/node_modules/**", - "!libs/remix-core-plugin/compiler-fetch-and-compile/**/*" - ] - } - }, - "build": { - "builder": "@nrwl/node:package", - "options": { - "outputPath": "dist/libs/core-plugin/compiler-fetch-and-compile", - "tsConfig": "libs/remix-core-plugin/compiler-fetch-and-compile/tsconfig.lib.json", - "packageJson": "libs/remix-core-plugin/compiler-fetch-and-compile/package.json", - "main": "libs/remix-core-plugin/compiler-fetch-and-compile/src/index.ts" - } - } - } - }, - "compiler-content-imports": { - "root": "libs/remix-core-plugin/compiler-content-imports", - "sourceRoot": "libs/remix-core-plugin/compiler-content-imports/src", - "projectType": "library", - "schematics": {}, - "architect": { - "lint": { - "builder": "@nrwl/linter:lint", - "options": { - "linter": "eslint", - "tsConfig": [ - "libs/remix-core-plugin/compiler-content-imports/tsconfig.lib.json" - ], - "exclude": [ - "**/node_modules/**", - "!libs/remix-core-plugin/compiler-content-imports/**/*" - ] - } - }, - "build": { - "builder": "@nrwl/node:package", - "options": { - "outputPath": "dist/libs/core-plugin/compiler-content-imports", - "tsConfig": "libs/remix-core-plugin/compiler-content-imports/tsconfig.lib.json", - "packageJson": "libs/remix-core-plugin/compiler-content-imports/package.json", - "main": "libs/remix-core-plugin/compiler-content-imports/src/index.ts" - } - } - } - }, - "offset-line-to-column-converter": { - "root": "libs/remix-core-plugin/offset-line-to-column-converter", - "sourceRoot": "libs/remix-core-plugin/offset-line-to-column-converter/src", - "projectType": "library", - "schematics": {}, - "architect": { - "lint": { - "builder": "@nrwl/linter:lint", - "options": { - "linter": "eslint", - "tsConfig": [ - "libs/remix-core-plugin/offset-line-to-column-converter/tsconfig.lib.json" - ], - "exclude": [ - "**/node_modules/**", - "!libs/remix-core-plugin/offset-line-to-column-converter/**/*" - ] - } - }, - "build": { - "builder": "@nrwl/node:package", - "options": { - "outputPath": "dist/libs/core-plugin/offset-line-to-column-converter", - "tsConfig": "libs/remix-core-plugin/offset-line-to-column-converter/tsconfig.lib.json", - "packageJson": "libs/remix-core-plugin/offset-line-to-column-converter/package.json", - "main": "libs/remix-core-plugin/coffset-line-to-column-converter/src/index.ts" - } - } - } - }, - "compiler-metadata": { - "root": "libs/remix-core-plugin/compiler-metadata", - "sourceRoot": "libs/remix-core-plugin/compiler-metadata/src", - "projectType": "library", - "schematics": {}, - "architect": { - "lint": { - "builder": "@nrwl/linter:lint", - "options": { - "linter": "eslint", - "tsConfig": [ - "libs/remix-core-plugin/compiler-metadata/tsconfig.lib.json" - ], - "exclude": [ - "**/node_modules/**", - "!libs/remix-core-plugin/compiler-metadata/**/*" - ] - } - }, - "build": { - "builder": "@nrwl/node:package", - "options": { - "outputPath": "dist/libs/core-plugin/compiler-metadata", - "tsConfig": "libs/remix-core-plugin/compiler-metadata/tsconfig.lib.json", - "packageJson": "libs/remix-core-plugin/compiler-metadata/package.json", - "main": "libs/remix-core-plugin/compiler-metadata/src/index.ts" + "outputPath": "dist/libs/core-plugin", + "tsConfig": "libs/remix-core-plugin/tsconfig.lib.json", + "packageJson": "libs/remix-core-plugin/package.json", + "main": "libs/remix-core-plugin/src/index.ts" } } } From 5b3cb4ea9c26b35c393bae07e54c42bdedd25326 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Wed, 30 Jun 2021 11:03:29 +0200 Subject: [PATCH 08/17] update index --- libs/remix-core-plugin/src/index.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libs/remix-core-plugin/src/index.ts b/libs/remix-core-plugin/src/index.ts index 863c411740..33f3e2ce83 100644 --- a/libs/remix-core-plugin/src/index.ts +++ b/libs/remix-core-plugin/src/index.ts @@ -1,4 +1,5 @@ -export * from './lib/offset-line-to-column-converter' -export * from './lib/compiler-metadata' -export * from './lib/compiler-fetch-and-compile' -export * from './lib/offset-line-to-column-converter' +export { OffsetToLineColumnConverter } from './lib/offset-line-to-column-converter' +export { CompilerMetadata } from './lib/compiler-metadata' +export { FetchAndCompile } from './lib/compiler-fetch-and-compile' +export { CompilerImports } from './lib/compiler-content-imports' +export { CompilerArtefacts } from './lib/compiler-artefacts' \ No newline at end of file From 20913eca2cec87dce368f3d487fdbc5086df996f Mon Sep 17 00:00:00 2001 From: filip mertens Date: Wed, 30 Jun 2021 11:09:37 +0200 Subject: [PATCH 09/17] update lint/build command --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 07ab9d39e1..ed37d6414e 100644 --- a/package.json +++ b/package.json @@ -41,8 +41,8 @@ "workspace-schematic": "nx workspace-schematic", "dep-graph": "nx dep-graph", "help": "nx help", - "lint:libs": "nx run-many --target=lint --projects=remix-analyzer,remix-astwalker,remix-debug,remix-lib,remix-simulator,remix-solidity,remix-tests,remix-url-resolver,remixd,remix-ui-tree-view,remix-ui-modal-dialog,remix-ui-toaster,remix-ui-file-explorer,remix-ui-debugger-ui,remix-ui-workspace,remix-ui-static-analyser,remix-ui-checkbox", - "build:libs": "nx run-many --target=build --parallel=false --with-deps=true --projects=remix-analyzer,remix-astwalker,remix-debug,remix-lib,remix-simulator,remix-solidity,remix-tests,remix-url-resolver,remixd", + "lint:libs": "nx run-many --target=lint --projects=remix-analyzer,remix-astwalker,remix-debug,remix-lib,remix-simulator,remix-solidity,remix-tests,remix-url-resolver,remixd,remix-ui-tree-view,remix-ui-modal-dialog,remix-ui-toaster,remix-ui-file-explorer,remix-ui-debugger-ui,remix-ui-workspace,remix-ui-static-analyser,remix-ui-checkbox,remix-core-plugin", + "build:libs": "nx run-many --target=build --parallel=false --with-deps=true --projects=remix-analyzer,remix-astwalker,remix-debug,remix-lib,remix-simulator,remix-solidity,remix-tests,remix-url-resolver,remixd,remix-core-plugin", "test:libs": "nx run-many --target=test --projects=remix-analyzer,remix-astwalker,remix-debug,remix-lib,remix-simulator,remix-solidity,remix-tests,remix-url-resolver,remixd", "publish:libs": "npm run build:libs && lerna publish --skip-git && npm run bumpVersion:libs", "build:e2e": "tsc -p apps/remix-ide-e2e/tsconfig.e2e.json", From 35878ca731ed6be894c8c74726924ae97871e393 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Wed, 30 Jun 2021 11:42:06 +0200 Subject: [PATCH 10/17] tsconfig --- tsconfig.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index 97ce348921..275dcae946 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -39,12 +39,12 @@ "@remix-ui/toaster": ["libs/remix-ui/toaster/src/index.ts"], "@remix-ui/file-explorer": ["libs/remix-ui/file-explorer/src/index.ts"], "@remix-ui/workspace": ["libs/remix-ui/workspace/src/index.ts"], - "@remix-project/core-plugin": [ - "libs/remix-core-plugin/src/index.ts" - ], "@remix-ui/static-analyser": ["libs/remix-ui/static-analyser/src/index.ts"], "@remix-ui/checkbox": ["libs/remix-ui/checkbox/src/index.ts"], - "@remix-ui/settings": ["libs/remix-ui/settings/src/index.ts"] + "@remix-ui/settings": ["libs/remix-ui/settings/src/index.ts"], + "@remix-project/core-plugin": [ + "libs/remix-core-plugin/src/index.ts" + ] } }, "exclude": ["node_modules", "tmp"] From 02c2d242a92610a61755f44ffa1fbd49d7778073 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Wed, 30 Jun 2021 11:50:45 +0200 Subject: [PATCH 11/17] lint --- libs/remix-core-plugin/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-core-plugin/src/index.ts b/libs/remix-core-plugin/src/index.ts index 33f3e2ce83..73c98a6181 100644 --- a/libs/remix-core-plugin/src/index.ts +++ b/libs/remix-core-plugin/src/index.ts @@ -2,4 +2,4 @@ export { OffsetToLineColumnConverter } from './lib/offset-line-to-column-convert export { CompilerMetadata } from './lib/compiler-metadata' export { FetchAndCompile } from './lib/compiler-fetch-and-compile' export { CompilerImports } from './lib/compiler-content-imports' -export { CompilerArtefacts } from './lib/compiler-artefacts' \ No newline at end of file +export { CompilerArtefacts } from './lib/compiler-artefacts' From fd03ce63b00967047a7bbf3cd12e0d6f0248c447 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Wed, 30 Jun 2021 12:45:58 +0200 Subject: [PATCH 12/17] version update --- libs/remix-lib/package.json | 2 +- libs/remix-solidity/package.json | 2 +- libs/remix-url-resolver/package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/remix-lib/package.json b/libs/remix-lib/package.json index fa032c739c..052de7f712 100644 --- a/libs/remix-lib/package.json +++ b/libs/remix-lib/package.json @@ -1,6 +1,6 @@ { "name": "@remix-project/remix-lib", - "version": "0.5.2", + "version": "0.5.3", "description": "Library to various Remix tools", "contributors": [ { diff --git a/libs/remix-solidity/package.json b/libs/remix-solidity/package.json index f6aee88583..def46c43cb 100644 --- a/libs/remix-solidity/package.json +++ b/libs/remix-solidity/package.json @@ -1,6 +1,6 @@ { "name": "@remix-project/remix-solidity", - "version": "0.4.2", + "version": "0.4.3", "description": "Tool to load and run Solidity compiler", "main": "index.js", "types": "./index.d.ts", diff --git a/libs/remix-url-resolver/package.json b/libs/remix-url-resolver/package.json index e5d8376d62..9d9b25e3b1 100644 --- a/libs/remix-url-resolver/package.json +++ b/libs/remix-url-resolver/package.json @@ -1,6 +1,6 @@ { "name": "@remix-project/remix-url-resolver", - "version": "0.0.23", + "version": "0.0.24", "description": "Solidity import url resolver engine", "main": "index.js", "types": "./index.d.ts", From 334575fd64c59049906bbb31783f2607408a99b2 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Wed, 30 Jun 2021 15:10:17 +0200 Subject: [PATCH 13/17] remove filemanager deps and calls to get providers --- apps/remix-ide/src/app.js | 2 +- apps/remix-ide/src/app/files/fileManager.js | 28 ++++- .../src/lib/compiler-content-imports.ts | 111 +++++++++--------- 3 files changed, 84 insertions(+), 57 deletions(-) diff --git a/apps/remix-ide/src/app.js b/apps/remix-ide/src/app.js index 5bcc3db57b..4cb32e75e7 100644 --- a/apps/remix-ide/src/app.js +++ b/apps/remix-ide/src/app.js @@ -260,7 +260,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org const dGitProvider = new DGitProvider() // ----------------- import content service ------------------------ - const contentImport = new CompilerImports(fileManager) + const contentImport = new CompilerImports() const blockchain = new Blockchain(registry.get('config').api) diff --git a/apps/remix-ide/src/app/files/fileManager.js b/apps/remix-ide/src/app/files/fileManager.js index c789991a9a..9b618a9fe9 100644 --- a/apps/remix-ide/src/app/files/fileManager.js +++ b/apps/remix-ide/src/app/files/fileManager.js @@ -22,7 +22,7 @@ const profile = { icon: 'assets/img/fileManager.webp', permission: true, version: packageJson.version, - methods: ['file', 'exists', 'open', 'writeFile', 'readFile', 'copyFile', 'copyDir', 'rename', 'mkdir', 'readdir', 'remove', 'getCurrentFile', 'getFile', 'getFolder', 'setFile', 'switchFile', 'refresh'], + methods: ['file', 'exists', 'open', 'writeFile', 'readFile', 'copyFile', 'copyDir', 'rename', 'mkdir', 'readdir', 'remove', 'getCurrentFile', 'getFile', 'getFolder', 'setFile', 'switchFile', 'refresh', 'getProviderOf', 'getProviderByName'], kind: 'file-system' } const errorMsg = { @@ -597,6 +597,32 @@ class FileManager extends Plugin { } } + /** + * Async API method getProviderOf + * @param {string} file + * + */ + + async getProviderOf (file) { + const cancall = await this.askUserPermission('getProviderByName') + if (cancall) { + return file ? this.fileProviderOf(file) : this.currentFileProvider() + } + } + + /** + * Async API method getProviderByName + * @param {string} name + * + */ + + async getProviderByName (name) { + const cancall = await this.askUserPermission('getProviderByName') + if (cancall) { + return this.getProvider(name) + } + } + getProvider (name) { return this._deps.filesProviders[name] } diff --git a/libs/remix-core-plugin/src/lib/compiler-content-imports.ts b/libs/remix-core-plugin/src/lib/compiler-content-imports.ts index 0e9e4ab8e0..a83d2ddbc9 100644 --- a/libs/remix-core-plugin/src/lib/compiler-content-imports.ts +++ b/libs/remix-core-plugin/src/lib/compiler-content-imports.ts @@ -13,11 +13,9 @@ const profile = { export class CompilerImports extends Plugin { previouslyHandled: {} - fileManager: any urlResolver: any - constructor (fileManager) { + constructor () { super(profile) - this.fileManager = fileManager this.urlResolver = new RemixURLResolver() this.previouslyHandled = {} // cache import so we don't make the request at each compilation. } @@ -89,12 +87,14 @@ export class CompilerImports extends Plugin { this.import(url, // TODO: handle this event (loadingMsg) => { this.emit('message', loadingMsg) }, - (error, content, cleanUrl, type, url) => { + async (error, content, cleanUrl, type, url) => { if (error) return cb(error) - if (this.fileManager) { - const provider = this.fileManager.currentFileProvider() + try { + const provider = await this.call('fileManager', 'getProviderOf', null) const path = targetPath || type + '/' + cleanUrl if (provider) provider.addExternal('.deps/' + path, content, url) + } catch (err) { + } cb(null, content) }, null) @@ -113,63 +113,64 @@ export class CompilerImports extends Plugin { resolveAndSave (url, targetPath) { return new Promise((resolve, reject) => { if (url.indexOf('remix_tests.sol') !== -1) resolve(remixTests.assertLibCode) - if (!this.fileManager) { - // fallback to just resolving the file, it won't be saved in file manager - return this.importExternal(url, targetPath, (error, content) => { - if (error) return reject(error) - resolve(content) - }) - } - var provider = this.fileManager.fileProviderOf(url) - if (provider) { - if (provider.type === 'localhost' && !provider.isConnected()) { - return reject(new Error(`file provider ${provider.type} not available while trying to resolve ${url}`)) - } - provider.exists(url).then(exist => { - /* - if the path is absolute and the file does not exist, we can stop here - Doesn't make sense to try to resolve "localhost/node_modules/localhost/node_modules/" and we'll end in an infinite loop. - */ - if (!exist && url.startsWith('browser/')) return reject(new Error(`not found ${url}`)) - if (!exist && url.startsWith('localhost/')) return reject(new Error(`not found ${url}`)) - - if (exist) { - return provider.get(url, (error, content) => { - if (error) return reject(error) - resolve(content) - }) + this.call('fileManager', 'getProviderOf', url).then((provider) => { + if (provider) { + if (provider.type === 'localhost' && !provider.isConnected()) { + return reject(new Error(`file provider ${provider.type} not available while trying to resolve ${url}`)) } + provider.exists(url).then(exist => { + /* + if the path is absolute and the file does not exist, we can stop here + Doesn't make sense to try to resolve "localhost/node_modules/localhost/node_modules/" and we'll end in an infinite loop. + */ + if (!exist && url.startsWith('browser/')) return reject(new Error(`not found ${url}`)) + if (!exist && url.startsWith('localhost/')) return reject(new Error(`not found ${url}`)) - // try to resolve localhost modules (aka truffle imports) - e.g from the node_modules folder - const localhostProvider = this.fileManager.getProvider('localhost') - if (localhostProvider.isConnected()) { - var splitted = /([^/]+)\/(.*)$/g.exec(url) - return async.tryEach([ - (cb) => { this.resolveAndSave('localhost/installed_contracts/' + url, null).then((result) => cb(null, result)).catch((error) => cb(error.message)) }, - // eslint-disable-next-line standard/no-callback-literal - (cb) => { if (!splitted) { cb('URL not parseable: ' + url) } else { this.resolveAndSave('localhost/installed_contracts/' + splitted[1] + '/contracts/' + splitted[2], null).then((result) => cb(null, result)).catch((error) => cb(error.message)) } }, - (cb) => { this.resolveAndSave('localhost/node_modules/' + url, null).then((result) => cb(null, result)).catch((error) => cb(error.message)) }, - // eslint-disable-next-line standard/no-callback-literal - (cb) => { if (!splitted) { cb('URL not parseable: ' + url) } else { this.resolveAndSave('localhost/node_modules/' + splitted[1] + '/contracts/' + splitted[2], null).then((result) => cb(null, result)).catch((error) => cb(error.message)) } }], - (error, result) => { - if (error) { - return this.importExternal(url, targetPath, (error, content) => { - if (error) return reject(error) - resolve(content) + if (exist) { + return provider.get(url, (error, content) => { + if (error) return reject(error) + resolve(content) + }) + } + + // try to resolve localhost modules (aka truffle imports) - e.g from the node_modules folder + this.call('fileManager', 'getProviderByName', 'localhost').then((localhostProvider) => { + if (localhostProvider.isConnected()) { + var splitted = /([^/]+)\/(.*)$/g.exec(url) + return async.tryEach([ + (cb) => { this.resolveAndSave('localhost/installed_contracts/' + url, null).then((result) => cb(null, result)).catch((error) => cb(error.message)) }, + // eslint-disable-next-line standard/no-callback-literal + (cb) => { if (!splitted) { cb('URL not parseable: ' + url) } else { this.resolveAndSave('localhost/installed_contracts/' + splitted[1] + '/contracts/' + splitted[2], null).then((result) => cb(null, result)).catch((error) => cb(error.message)) } }, + (cb) => { this.resolveAndSave('localhost/node_modules/' + url, null).then((result) => cb(null, result)).catch((error) => cb(error.message)) }, + // eslint-disable-next-line standard/no-callback-literal + (cb) => { if (!splitted) { cb('URL not parseable: ' + url) } else { this.resolveAndSave('localhost/node_modules/' + splitted[1] + '/contracts/' + splitted[2], null).then((result) => cb(null, result)).catch((error) => cb(error.message)) } }], + (error, result) => { + if (error) { + return this.importExternal(url, targetPath, (error, content) => { + if (error) return reject(error) + resolve(content) + }) + } + resolve(result) }) } - resolve(result) }) - } - this.importExternal(url, targetPath, (error, content) => { - if (error) return reject(error) - resolve(content) + this.importExternal(url, targetPath, (error, content) => { + if (error) return reject(error) + resolve(content) + }) + }).catch(error => { + return reject(error) }) - }).catch(error => { - return reject(error) + } + }).catch(() => { + // fallback to just resolving the file, it won't be saved in file manager + return this.importExternal(url, targetPath, (error, content) => { + if (error) return reject(error) + resolve(content) }) - } + }) }) } } From c07188c654df90e61ac27c86eec3c0abd3ff24d2 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Thu, 1 Jul 2021 11:59:03 +0200 Subject: [PATCH 14/17] fix for external import --- .../src/lib/compiler-content-imports.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libs/remix-core-plugin/src/lib/compiler-content-imports.ts b/libs/remix-core-plugin/src/lib/compiler-content-imports.ts index a83d2ddbc9..ea4eae6958 100644 --- a/libs/remix-core-plugin/src/lib/compiler-content-imports.ts +++ b/libs/remix-core-plugin/src/lib/compiler-content-imports.ts @@ -154,11 +154,10 @@ export class CompilerImports extends Plugin { resolve(result) }) } - }) - - this.importExternal(url, targetPath, (error, content) => { - if (error) return reject(error) - resolve(content) + this.importExternal(url, targetPath, (error, content) => { + if (error) return reject(error) + resolve(content) + }) }) }).catch(error => { return reject(error) From ea7a127af6d83623c5f89553e5353e84408878db Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 12 Jul 2021 11:56:22 +0200 Subject: [PATCH 15/17] should not be 0x prefixed --- libs/remix-debug/src/solidity-decoder/types/util.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-debug/src/solidity-decoder/types/util.ts b/libs/remix-debug/src/solidity-decoder/types/util.ts index 30748c9aca..cd83d1cd32 100644 --- a/libs/remix-debug/src/solidity-decoder/types/util.ts +++ b/libs/remix-debug/src/solidity-decoder/types/util.ts @@ -48,7 +48,7 @@ export async function extractHexValue (location, storageResolver, byteLength) { try { slotvalue = await readFromStorage(location.slot, storageResolver) } catch (e) { - return '0x' + return '' } return extractHexByteSlice(slotvalue, byteLength, location.offset) } From 133a88e7f5aaef09a7793930935be9f210d232c8 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 12 Jul 2021 11:56:04 +0200 Subject: [PATCH 16/17] ensure 0x prefixed --- libs/remix-debug/src/trace/traceManager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/remix-debug/src/trace/traceManager.ts b/libs/remix-debug/src/trace/traceManager.ts index 848b3c57aa..f4bf488392 100644 --- a/libs/remix-debug/src/trace/traceManager.ts +++ b/libs/remix-debug/src/trace/traceManager.ts @@ -151,7 +151,7 @@ export class TraceManager { if (this.trace[stepIndex] && this.trace[stepIndex].stack) { // there's always a stack const stack = this.trace[stepIndex].stack.slice(0) stack.reverse() - return stack + return stack.map(el => el.startsWith('0x') ? el : '0x' + el) } else { throw new Error('no stack found') } From 6aad3b74ce3b1ca594a7479e0b58f63b638e37a6 Mon Sep 17 00:00:00 2001 From: yann300 Date: Wed, 14 Jul 2021 10:23:27 +0200 Subject: [PATCH 17/17] change ipfs endpoint --- apps/remix-ide/ci/publishIpfs | 4 ++-- apps/remix-ide/src/app/files/dgitProvider.js | 4 ++-- apps/remix-ide/src/lib/publishOnIpfs.js | 2 +- libs/remix-lib/src/init.ts | 17 ----------------- libs/remix-url-resolver/src/resolve.ts | 2 +- libs/remixd/src/origins.json | 3 ++- 6 files changed, 8 insertions(+), 24 deletions(-) diff --git a/apps/remix-ide/ci/publishIpfs b/apps/remix-ide/ci/publishIpfs index c56a5f37bf..98a5d56729 100755 --- a/apps/remix-ide/ci/publishIpfs +++ b/apps/remix-ide/ci/publishIpfs @@ -6,13 +6,13 @@ console.log('current folder', process.cwd()) const folder = process.cwd() + '/temp_publish_docker'; (async () => { - const host = 'ipfs.komputing.org' // ethdev berlin ipfs node + const host = 'ipfs.remixproject.org' const ipfs = IpfsHttpClient({ host, port: 443, protocol: 'https' }) try { let result = await ipfs.add(globSource(folder, { recursive: true}), { pin: false }) const hash = result.cid.toString() console.log('ipfs://' + hash) - console.log('https://ipfsgw.komputing.org/ipfs/' + hash) + console.log('https://ipfs.remixproject.org/ipfs/' + hash) console.log('https://gateway.ipfs.io/ipfs/' + hash) } catch (e) { console.log(e) diff --git a/apps/remix-ide/src/app/files/dgitProvider.js b/apps/remix-ide/src/app/files/dgitProvider.js index ed7d4edb8e..5a2bc6a366 100644 --- a/apps/remix-ide/src/app/files/dgitProvider.js +++ b/apps/remix-ide/src/app/files/dgitProvider.js @@ -27,10 +27,10 @@ class DGitProvider extends Plugin { constructor () { super(profile) this.ipfsconfig = { - host: 'ipfs.komputing.org', + host: 'ipfs.remixproject.org', port: 443, protocol: 'https', - ipfsurl: 'https://ipfsgw.komputing.org/ipfs/' + ipfsurl: 'https://ipfs.remixproject.org/ipfs/' } this.globalIPFSConfig = { host: 'ipfs.io', diff --git a/apps/remix-ide/src/lib/publishOnIpfs.js b/apps/remix-ide/src/lib/publishOnIpfs.js index 52a55a02e7..07f8256540 100644 --- a/apps/remix-ide/src/lib/publishOnIpfs.js +++ b/apps/remix-ide/src/lib/publishOnIpfs.js @@ -4,7 +4,7 @@ const async = require('async') const IpfsClient = require('ipfs-mini') const ipfsNodes = [ - new IpfsClient({ host: 'ipfs.komputing.org', port: 443, protocol: 'https' }), + new IpfsClient({ host: 'ipfs.remixproject.org', port: 443, protocol: 'https' }), new IpfsClient({ host: 'ipfs.infura.io', port: 5001, protocol: 'https' }), new IpfsClient({ host: '127.0.0.1', port: 5001, protocol: 'http' }) ] diff --git a/libs/remix-lib/src/init.ts b/libs/remix-lib/src/init.ts index 7e3d371715..43c68ee58f 100644 --- a/libs/remix-lib/src/init.ts +++ b/libs/remix-lib/src/init.ts @@ -12,23 +12,6 @@ export function extendWeb3 (web3) { this.extend(web3) } -export function setProvider (web3, url) { - web3.setProvider(new web3.providers.HttpProvider(url)) -} - -export function web3DebugNode (network) { - const web3DebugNodes = { - Main: 'https://gethmainnet.komputing.org', - Rinkeby: 'https://remix-rinkeby.ethdevops.io', - Ropsten: 'https://remix-ropsten.ethdevops.io', - Goerli: 'https://remix-goerli.ethdevops.io' - } - if (web3DebugNodes[network]) { - return this.loadWeb3(web3DebugNodes[network]) - } - return null -} - export function extend (web3) { if (!web3.extend) { return diff --git a/libs/remix-url-resolver/src/resolve.ts b/libs/remix-url-resolver/src/resolve.ts index adfc05d862..38076686a2 100644 --- a/libs/remix-url-resolver/src/resolve.ts +++ b/libs/remix-url-resolver/src/resolve.ts @@ -113,7 +113,7 @@ export class RemixURLResolver { url = url.replace(/^ipfs:\/\/?/, 'ipfs/') // eslint-disable-next-line no-useless-catch try { - const req = 'https://ipfsgw.komputing.org/' + url + const req = 'https://ipfs.remixproject.org/' + url // If you don't find greeter.sol on ipfs gateway use local // const req = 'http://localhost:8080/' + url const response: AxiosResponse = await axios.get(req) diff --git a/libs/remixd/src/origins.json b/libs/remixd/src/origins.json index d91e2f8a61..5a3331f3c7 100644 --- a/libs/remixd/src/origins.json +++ b/libs/remixd/src/origins.json @@ -6,6 +6,7 @@ "https://remix.ethereum.org", "package://a7df6d3c223593f3550b35e90d7b0b1f.mod", "package://6fd22d6fe5549ad4c4d8fd3ca0b7816b.mod", - "https://ipfsgw.komputing.org" + "https://ipfsgw.komputing.org", + "https://ipfs.remixproject.org" ] } \ No newline at end of file