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
pull/5370/head
filip mertens 3 years ago
parent dadc3309a9
commit 22bb7c365b
  1. 18
      apps/remix-ide/src/app.js
  2. 46
      apps/remix-ide/src/app/compiler/compiler-abstract.js
  3. 21
      apps/remix-ide/src/app/compiler/compiler-input.js
  4. 2
      apps/remix-ide/src/app/files/compiler-metadata.js
  5. 4
      apps/remix-ide/src/app/files/fileProvider.js
  6. 2
      apps/remix-ide/src/app/tabs/compile-tab.js
  7. 2
      apps/remix-ide/src/app/tabs/compileTab/compilerContainer.js
  8. 2
      apps/remix-ide/src/app/tabs/runTab/model/dropdownlogic.js
  9. 3
      apps/remix-ide/src/app/tabs/test-tab.js
  10. 4
      apps/remix-ide/src/app/ui/landing-page/landing-page.js
  11. 4
      apps/remix-ide/src/lib/cmdInterpreterAPI.js
  12. 1
      libs/remix-core-plugin/compiler-artefacts/.eslintrc
  13. 3
      libs/remix-core-plugin/compiler-artefacts/README.md
  14. 11
      libs/remix-core-plugin/compiler-artefacts/package.json
  15. 1
      libs/remix-core-plugin/compiler-artefacts/src/index.ts
  16. 11
      libs/remix-core-plugin/compiler-artefacts/src/lib/compiler-artefacts.ts
  17. 10
      libs/remix-core-plugin/compiler-artefacts/tsconfig.json
  18. 12
      libs/remix-core-plugin/compiler-artefacts/tsconfig.lib.json
  19. 1
      libs/remix-core-plugin/compiler-content-imports/.eslintrc
  20. 3
      libs/remix-core-plugin/compiler-content-imports/README.md
  21. 11
      libs/remix-core-plugin/compiler-content-imports/package.json
  22. 1
      libs/remix-core-plugin/compiler-content-imports/src/index.ts
  23. 39
      libs/remix-core-plugin/compiler-content-imports/src/lib/compiler-content-imports.ts
  24. 10
      libs/remix-core-plugin/compiler-content-imports/tsconfig.json
  25. 12
      libs/remix-core-plugin/compiler-content-imports/tsconfig.lib.json
  26. 1
      libs/remix-core-plugin/compiler-fetch-and-compile/.eslintrc
  27. 3
      libs/remix-core-plugin/compiler-fetch-and-compile/README.md
  28. 11
      libs/remix-core-plugin/compiler-fetch-and-compile/package.json
  29. 1
      libs/remix-core-plugin/compiler-fetch-and-compile/src/index.ts
  30. 28
      libs/remix-core-plugin/compiler-fetch-and-compile/src/lib/compiler-fetch-and-compile.ts
  31. 10
      libs/remix-core-plugin/compiler-fetch-and-compile/tsconfig.json
  32. 12
      libs/remix-core-plugin/compiler-fetch-and-compile/tsconfig.lib.json
  33. 1
      libs/remix-core-plugin/offset-line-to-column-converter/.eslintrc
  34. 3
      libs/remix-core-plugin/offset-line-to-column-converter/README.md
  35. 11
      libs/remix-core-plugin/offset-line-to-column-converter/package.json
  36. 1
      libs/remix-core-plugin/offset-line-to-column-converter/src/index.ts
  37. 77
      libs/remix-core-plugin/offset-line-to-column-converter/src/lib/offset-line-to-column-converter.ts
  38. 10
      libs/remix-core-plugin/offset-line-to-column-converter/tsconfig.json
  39. 12
      libs/remix-core-plugin/offset-line-to-column-converter/tsconfig.lib.json
  40. 2
      libs/remix-debug/src/eventManager.ts
  41. 2
      libs/remix-lib/src/eventManager.ts
  42. 48
      libs/remix-solidity/src/compiler/compiler-abstract.ts
  43. 4
      libs/remix-solidity/src/compiler/compiler-helpers.ts
  44. 0
      libs/remix-solidity/src/compiler/compiler-utils.ts
  45. 3
      libs/remix-solidity/src/index.ts
  46. 2
      libs/remix-solidity/src/lib/eventManager.ts
  47. 13
      nx.json
  48. 6
      package-lock.json
  49. 14
      tsconfig.json
  50. 121
      workspace.json

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

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

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

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

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

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

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

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

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

@ -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`
<div class="p-2">

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

@ -0,0 +1 @@
{ "extends": "../../../.eslintrc", "rules": {}, "ignorePatterns": ["!**/*"] }

@ -0,0 +1,3 @@
# compiler-artefacts
This library was generated with [Nx](https://nx.dev).

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

@ -0,0 +1 @@
export * from './lib/compiler-artefacts'

@ -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 = {}

@ -0,0 +1,10 @@
{
"extends": "../../../tsconfig.json",
"files": [],
"include": [],
"references": [
{
"path": "./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"]
}

@ -0,0 +1 @@
{ "extends": "../../../.eslintrc", "rules": {}, "ignorePatterns": ["!**/*"] }

@ -0,0 +1,3 @@
# compiler-content-imports
This library was generated with [Nx](https://nx.dev).

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

@ -0,0 +1 @@
export * from './lib/compiler-content-imports'

@ -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) => {

@ -0,0 +1,10 @@
{
"extends": "../../../tsconfig.json",
"files": [],
"include": [],
"references": [
{
"path": "./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"]
}

@ -0,0 +1 @@
{ "extends": "../../../.eslintrc", "rules": {}, "ignorePatterns": ["!**/*"] }

@ -0,0 +1,3 @@
# compiler-fetch-and-compile
This library was generated with [Nx](https://nx.dev).

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

@ -0,0 +1 @@
export * from './lib/compiler-fetch-and-compile'

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

@ -0,0 +1,10 @@
{
"extends": "../../../tsconfig.json",
"files": [],
"include": [],
"references": [
{
"path": "./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"]
}

@ -0,0 +1 @@
{ "extends": "../../../.eslintrc", "rules": {}, "ignorePatterns": ["!**/*"] }

@ -0,0 +1,3 @@
# offset-line-to-column-converter
This library was generated with [Nx](https://nx.dev).

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

@ -0,0 +1 @@
export * from './lib/offset-line-to-column-converter'

@ -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.<string, {content}>} sources - Map of content sources
* @param {Object.<string, {ast, id}>} 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()
})
}
}

@ -0,0 +1,10 @@
{
"extends": "../../../tsconfig.json",
"files": [],
"include": [],
"references": [
{
"path": "./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"]
}

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

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

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

@ -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 (() => {

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

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

@ -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": []
}
}
}

6
package-lock.json generated

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

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

@ -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": {

Loading…
Cancel
Save