diff --git a/README.md b/README.md index b8f700f796..a96b99c249 100644 --- a/README.md +++ b/README.md @@ -141,69 +141,129 @@ To run the Selenium tests via Nightwatch: for Firefox: `npm run nightwatch_local_firefox`, or for Google Chrome: `npm run nightwatch_local_chrome` - - Run a specific test case instead, use one of following commands: + - Run a specific test case instead, use a command like this: - npm run nightwatch_local_ballot - - - npm run nightwatch_local_usingWorker - - - npm run nightwatch_local_libraryDeployment - - - npm run nightwatch_local_solidityImport - - - npm run nightwatch_local_recorder - - npm run nightwatch_local_transactionExecution - - - npm run nightwatch_local_staticAnalysis - - - npm run nightwatch_local_signingMessage + The package.json file contains a list of all the tests you can run. + +**NOTE:** + +- **The `ballot` tests suite** requires to run `ganache-cli` locally. - - npm run nightwatch_local_specialFunctions +- **The `remixd` tests suite** requires to run `remixd` locally. + +- **The `gist` tests suite** requires specifying a github access token in **.env file**. +``` + gist_token = // token should have permission to create a gist +``` - - npm run nightwatch_local_solidityUnitTests +### Using 'select_test' for locally running specific tests - - npm run nightwatch_local_remixd # remixd needs to be run +There is a script to allow selecting the browser and a specific test to run: - - npm run nightwatch_local_terminal +``` +npm run select_test +``` - - npm run nightwatch_local_gist +You need to have - - npm run nightwatch_local_workspace +- selenium running - - npm run nightwatch_local_defaultLayout +- the IDE running - - npm run nightwatch_local_pluginManager +- optionally have remixd or ganache running - - npm run nightwatch_local_publishContract +### Splitting tests with groups - - npm run nightwatch_local_generalSettings +Groups can be used to group tests in a test file together. The advantage is you can avoid running long test files when you want to focus on a specific set of tests within a test file.x - - npm run nightwatch_local_fileExplorer +These groups only apply to the test file, not across all test files. So for example group1 in the ballot is not related to group1 in another test file. - - npm run nightwatch_local_debugger +Running a group only runs the tests marked as belonging to the group + all the tests in the test file that do not have a group tag. This way you can have tests that run for all groups, for example to peform common actions. - - npm run nightwatch_local_editor +There is no need to number the groups in a certain order. The number of the group is arbitrary. - - npm run nightwatch_local_compiler +A test can have multiple group tags, this means that this test will run in different groups. - - npm run nightwatch_local_txListener +You should write your tests so they can be executed in groups and not depend on other groups. - - npm run nightwatch_local_fileManager +To do this you need to: - - npm run nightwatch_local_runAndDeploy - - -**NOTE:** +- Add a group to tag to a test, they are formatted as #group followed by a number: so it becomes #group1, #group220, #group4. Any number will do. You don't have to do it in specific order. -- **The `ballot` tests suite** requires to run `ganache-cli` locally. +``` + 'Should generate test file #group1': function (browser: NightwatchBrowser) { + browser.waitForElementPresent('*[data-id="verticalIconsKindfilePanel"]') +``` -- **The `remixd` tests suite** requires to run `remixd` locally. +- add '@disable': true to the test file you want to split: -- **The `gist` tests suite** requires specifying a github access token in **.env file**. ``` - gist_token = // token should have permission to create a gist +module.exports = { + '@disabled': true, + before: function (browser: NightwatchBrowser, done: VoidFunction) { + init(browser, done) // , 'http://localhost:8080', false) + }, +``` +- change package json to locally run all group tests: + +``` + "nightwatch_local_debugger": "npm run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/debugger_*.spec.js --env=chrome", +``` + +- run the build script to build the test files if you want to run the locally + +``` +npm run build:e2e +``` + +### Locally testing group tests + +You can tag any test with a groupname, for example, #group10 and easily run the test locally. + +- make sure you have nx installed globally +- group tests are run like any other test, just specify the correct group number + +#### method 1 + +This script will give you an option menu, just select the test you want +``` +npm run select_test +``` +#### method 2 + +``` +npm run group_test --test=debugger --group=10 --env=chromeDesktop +``` +- specify chromeDesktop to see the browser action, use 'chrome' to run it headless + +### Run the same (flaky) test across all instances in CircleCI + +In CircleCI all tests are divided across instances to run in paralel. +You can also run 1 or more tests simultaneously across all instances. +This way the pipeline can easily be restarted to check if a test is flaky. + +For example: + ``` + 'Static Analysis run with remixd #group3 #flaky': function (browser) { +``` + +Now group3 of this test will be executed in firefox and chrome 80 times. +If you mark more groups in other tests they will also be executed. + +**CONFIGURATION** + +It's important to set a parameter in the .circleci/config.yml, set it to false then the normal tests will run. +Set it to true to run only tests marked with flaky. +``` +parameters: + run_flaky_tests: + type: boolean + default: true +``` + ## Important Links diff --git a/apps/remix-ide-e2e/src/tests/workspace.test.ts b/apps/remix-ide-e2e/src/tests/workspace.test.ts index 4b14321d6f..092d939302 100644 --- a/apps/remix-ide-e2e/src/tests/workspace.test.ts +++ b/apps/remix-ide-e2e/src/tests/workspace.test.ts @@ -50,11 +50,42 @@ module.exports = { .assert.elementPresent('*[data-id="treeViewLitreeViewItemcontracts/3_Ballot.sol"]') .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts"]') .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/deploy_with_web3.ts"]') + // check js and ts files are not transformed + .click('*[data-id="treeViewLitreeViewItemscripts/deploy_with_web3.ts"]') + + .getEditorValue((content) => { + browser.assert.ok(content.indexOf(`import { deploy } from './web3-lib'`) !== -1, + 'Incorrect content') + }) .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/deploy_with_ethers.ts"]') - .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/web3.ts"]') - .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/ethers.ts"]') + .click('*[data-id="treeViewLitreeViewItemscripts/deploy_with_ethers.ts"]') + .pause(100) + .getEditorValue((content) => { + browser.assert.ok(content.indexOf(`import { deploy } from './ethers-lib'`) !== -1, + 'Incorrect content') + }) + .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/web3-lib.ts"]') + .click('*[data-id="treeViewLitreeViewItemscripts/web3-lib.ts"]') + .pause(2000) + .getEditorValue((content) => { + browser.assert.ok(content.indexOf(`export const deploy = async (contractName: string, args: Array, from?: string, gas?: number): Promise => {`) !== -1, + 'Incorrect content') + }) + .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/ethers-lib.ts"]') + .click('*[data-id="treeViewLitreeViewItemscripts/ethers-lib.ts"]') + .pause(100) + .getEditorValue((content) => { + browser.assert.ok(content.indexOf(`export const deploy = async (contractName: string, args: Array, from?: string): Promise => { `) !== -1, + 'Incorrect content') + }) .assert.elementPresent('*[data-id="treeViewLitreeViewItemtests"]') .assert.elementPresent('*[data-id="treeViewLitreeViewItemtests/storage.test.js"]') + .click('*[data-id="treeViewLitreeViewItemtests/storage.test.js"]') + .pause(100) + .getEditorValue((content) => { + browser.assert.ok(content.indexOf(`const { expect } = require("chai");`) !== -1, + 'Incorrect content') + }) .assert.elementPresent('*[data-id="treeViewLitreeViewItemtests/Ballot_test.sol"]') .assert.elementPresent('*[data-id="treeViewLitreeViewItemREADME.txt"]') }, @@ -70,7 +101,7 @@ module.exports = { .click('select[id="wstemplate"] option[value=blank]') .waitForElementPresent('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') .execute(function () { (document.querySelector('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') as HTMLElement).click() }) - .pause(1000) + .pause(100) .assert.elementPresent('*[data-id="treeViewUltreeViewMenu"]') .execute(function () { const fileList = document.querySelector('*[data-id="treeViewUltreeViewMenu"]') @@ -89,21 +120,94 @@ module.exports = { // eslint-disable-next-line dot-notation .execute(function () { document.querySelector('*[data-id="modalDialogCustomPromptTextCreate"]')['value'] = 'workspace_erc20' }) .click('select[id="wstemplate"]') - .click('select[id="wstemplate"] option[value=erc20]') + .click('select[id="wstemplate"] option[value=ozerc20]') .waitForElementPresent('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') .execute(function () { (document.querySelector('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') as HTMLElement).click() }) - .pause(1000) + .pause(100) .assert.elementPresent('*[data-id="treeViewLitreeViewItemcontracts"]') .assert.elementPresent('*[data-id="treeViewLitreeViewItemcontracts/SampleERC20.sol"]') .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts"]') .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/deploy_with_web3.ts"]') + // check js and ts files are not transformed + .click('*[data-id="treeViewLitreeViewItemscripts/deploy_with_web3.ts"]') + + .getEditorValue((content) => { + browser.assert.ok(content.indexOf(`import { deploy } from './web3-lib'`) !== -1, + 'Incorrect content') + }) .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/deploy_with_ethers.ts"]') - .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/web3.ts"]') - .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/ethers.ts"]') + .click('*[data-id="treeViewLitreeViewItemscripts/deploy_with_ethers.ts"]') + .pause(100) + .getEditorValue((content) => { + browser.assert.ok(content.indexOf(`import { deploy } from './ethers-lib'`) !== -1, + 'Incorrect content') + }) + .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/web3-lib.ts"]') + .click('*[data-id="treeViewLitreeViewItemscripts/web3-lib.ts"]') + .pause(100) + .getEditorValue((content) => { + browser.assert.ok(content.indexOf(`export const deploy = async (contractName: string, args: Array, from?: string, gas?: number): Promise => {`) !== -1, + 'Incorrect content') + }) + .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/ethers-lib.ts"]') + .click('*[data-id="treeViewLitreeViewItemscripts/ethers-lib.ts"]') + .pause(100) + .getEditorValue((content) => { + browser.assert.ok(content.indexOf(`export const deploy = async (contractName: string, args: Array, from?: string): Promise => { `) !== -1, + 'Incorrect content') + }) .assert.elementPresent('*[data-id="treeViewLitreeViewItemtests"]') .assert.elementPresent('*[data-id="treeViewLitreeViewItemtests/SampleERC20_test.sol"]') }, + 'Should create ERC721 workspace with files': function (browser: NightwatchBrowser) { + browser + .click('*[data-id="workspaceCreate"]') + .waitForElementVisible('*[data-id="modalDialogCustomPromptTextCreate"]') + .waitForElementVisible('[data-id="fileSystemModalDialogModalFooter-react"] > span') + // eslint-disable-next-line dot-notation + .execute(function () { document.querySelector('*[data-id="modalDialogCustomPromptTextCreate"]')['value'] = 'workspace_erc721' }) + .click('select[id="wstemplate"]') + .click('select[id="wstemplate"] option[value=ozerc721]') + .waitForElementPresent('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') + .execute(function () { (document.querySelector('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') as HTMLElement).click() }) + .pause(100) + .assert.elementPresent('*[data-id="treeViewLitreeViewItemcontracts"]') + .assert.elementPresent('*[data-id="treeViewLitreeViewItemcontracts/SampleERC721.sol"]') + .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts"]') + .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/deploy_with_web3.ts"]') + // check js and ts files are not transformed + .click('*[data-id="treeViewLitreeViewItemscripts/deploy_with_web3.ts"]') + + .getEditorValue((content) => { + browser.assert.ok(content.indexOf(`import { deploy } from './web3-lib'`) !== -1, + 'Incorrect content') + }) + .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/deploy_with_ethers.ts"]') + .click('*[data-id="treeViewLitreeViewItemscripts/deploy_with_ethers.ts"]') + .pause(100) + .getEditorValue((content) => { + browser.assert.ok(content.indexOf(`import { deploy } from './ethers-lib'`) !== -1, + 'Incorrect content') + }) + .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/web3-lib.ts"]') + .click('*[data-id="treeViewLitreeViewItemscripts/web3-lib.ts"]') + .pause(100) + .getEditorValue((content) => { + browser.assert.ok(content.indexOf(`export const deploy = async (contractName: string, args: Array, from?: string, gas?: number): Promise => {`) !== -1, + 'Incorrect content') + }) + .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/ethers-lib.ts"]') + .click('*[data-id="treeViewLitreeViewItemscripts/ethers-lib.ts"]') + .pause(100) + .getEditorValue((content) => { + browser.assert.ok(content.indexOf(`export const deploy = async (contractName: string, args: Array, from?: string): Promise => { `) !== -1, + 'Incorrect content') + }) + .assert.elementPresent('*[data-id="treeViewLitreeViewItemtests"]') + .assert.elementPresent('*[data-id="treeViewLitreeViewItemtests/SampleERC721_test.sol"]') + }, + // WORKSPACE TEMPLATES E2E END 'Should create two workspace and switch to the first one': function (browser: NightwatchBrowser) { diff --git a/apps/remix-ide/src/app/editor/editor.js b/apps/remix-ide/src/app/editor/editor.js index 9fe194eeab..9bf7e3fec6 100644 --- a/apps/remix-ide/src/app/editor/editor.js +++ b/apps/remix-ide/src/app/editor/editor.js @@ -143,6 +143,7 @@ class Editor extends Plugin { this.on('fileManager', 'fileClosed', (name) => { if (name === this.currentFile) { this.currentFile = null + this.renderComponent() } }) this.on('theme', 'themeLoaded', (theme) => { diff --git a/apps/remix-ide/src/app/files/fileProvider.js b/apps/remix-ide/src/app/files/fileProvider.js index 61e751ee62..1a8639149f 100644 --- a/apps/remix-ide/src/app/files/fileProvider.js +++ b/apps/remix-ide/src/app/files/fileProvider.js @@ -135,16 +135,12 @@ class FileProvider { if (!await window.remixFileSystem.exists(currentCheck)) { try { await window.remixFileSystem.mkdir(currentCheck) + this.event.emit('folderAdded', this._normalizePath(currentCheck)) } catch (error) { console.log(error) } } } - currentCheck = '' - for (const value of paths) { - currentCheck = currentCheck + '/' + value - this.event.emit('folderAdded', this._normalizePath(currentCheck)) - } if (cb) cb() } diff --git a/apps/remix-ide/src/app/panels/tab-proxy.js b/apps/remix-ide/src/app/panels/tab-proxy.js index f9a11c2b93..ec8026c517 100644 --- a/apps/remix-ide/src/app/panels/tab-proxy.js +++ b/apps/remix-ide/src/app/panels/tab-proxy.js @@ -153,6 +153,10 @@ export class TabProxy extends Plugin { displayName, () => this.emit('switchApp', name), () => { + if (name === 'home' && this.loadedTabs.length === 1 && this.loadedTabs[0].id === "home") { + const files = Object.keys(this.editor.sessions) + files.forEach(filepath => this.editor.discard(filepath)) + } this.emit('closeApp', name) this.call('manager', 'deactivatePlugin', name) }, diff --git a/apps/remix-ide/src/app/tabs/compile-and-run.ts b/apps/remix-ide/src/app/tabs/compile-and-run.ts index 3c0bb23d9b..d5b298e966 100644 --- a/apps/remix-ide/src/app/tabs/compile-and-run.ts +++ b/apps/remix-ide/src/app/tabs/compile-and-run.ts @@ -34,11 +34,11 @@ export class CompileAndRun extends Plugin { e.preventDefault() this.targetFileName = file await this.call('solidity', 'compile', file) - _paq.push(['trackEvent', 'ScriptExecutor', 'compile_solidity']) + _paq.push(['trackEvent', 'ScriptExecutor', 'CompileAndRun', 'compile_solidity']) } else if (file.endsWith('.js') || file.endsWith('.ts')) { e.preventDefault() this.runScript(file, false) - _paq.push(['trackEvent', 'ScriptExecutor', 'run_script']) + _paq.push(['trackEvent', 'ScriptExecutor', 'CompileAndRun', 'run_script']) } } } @@ -47,7 +47,7 @@ export class CompileAndRun extends Plugin { runScriptAfterCompilation (fileName: string) { this.targetFileName = fileName - _paq.push(['trackEvent', 'ScriptExecutor', 'request_run_script']) + _paq.push(['trackEvent', 'ScriptExecutor', 'CompileAndRun', 'request_run_script']) } async runScript (fileName, clearAllInstances) { @@ -78,7 +78,7 @@ export class CompileAndRun extends Plugin { const file = contract.object.devdoc['custom:dev-run-script'] if (file) { this.runScript(file, true) - _paq.push(['trackEvent', 'ScriptExecutor', 'run_script_after_compile']) + _paq.push(['trackEvent', 'ScriptExecutor', 'CompileAndRun', 'run_script_after_compile']) } else { this.call('notification', 'toast', 'You have not set a script to run. Set it with @custom:dev-run-script NatSpec tag.') } diff --git a/libs/remix-ui/README.md b/libs/remix-ui/README.md index 7bb33ea706..8dd1b4b48d 100644 --- a/libs/remix-ui/README.md +++ b/libs/remix-ui/README.md @@ -3,7 +3,7 @@ This library was generated with [Nx](https://nx.dev). ## Pre-requisite -- Install **NxConsole** vscose extension +- Install **NxConsole** vscode extension ## Steps To Generate React App - Open **NxConsole** extension - Click generate option @@ -32,4 +32,4 @@ This library was generated with [Nx](https://nx.dev). - Select the name of the project/library that uses the component. (e.g TreeView library) - Set component directory if needed. - Click the run button in the top right corner of the generate page. -- Your react component should be created with the project/library name specified. \ No newline at end of file +- Your react component should be created with the project/library name specified. diff --git a/libs/remix-ui/editor/src/lib/remix-plugin-types.ts b/libs/remix-ui/editor/src/lib/remix-plugin-types.ts index 3c0a4d5e23..ef781936c0 100644 --- a/libs/remix-ui/editor/src/lib/remix-plugin-types.ts +++ b/libs/remix-ui/editor/src/lib/remix-plugin-types.ts @@ -1,5548 +1,935 @@ -export const types = ` -declare module 'dist/packages/api/lib/compiler/type/input' { - export interface CompilationInput { - /** Source code language */ - language: 'Solidity' | 'Vyper' | 'lll' | 'assembly' | 'yul'; - sources: SourcesInput; - settings?: CompilerSettings; - outputSelection?: CompilerOutputSelection; - } - export interface CondensedCompilationInput { - language: 'Solidity' | 'Vyper' | 'lll' | 'assembly' | 'yul'; - optimize: boolean; - /** e.g: 0.6.8+commit.0bbfe453 */ - version: string; - evmVersion?: 'istanbul' | 'petersburg' | 'constantinople' | 'byzantium' | 'spuriousDragon' | 'tangerineWhistle' | 'homestead'; - } - export interface SourceInputUrls { - /** Hash of the source file. It is used to verify the retrieved content imported via URLs */ - keccak256?: string; - /** - * URL(s) to the source file. - * URL(s) should be imported in this order and the result checked against the - * keccak256 hash (if available). If the hash doesn't match or none of the - * URL(s) result in success, an error should be raised. - */ - urls: string[]; - } - export interface SourceInputContent { - /** Hash of the source file. */ - keccak256?: string; - /** Literal contents of the source file */ - content: string; - } - export interface SourcesInput { - [contractName: string]: SourceInputContent | SourceInputUrls; - } - export interface CompilerSettings { - /** Sorted list of remappings */ - remappings?: string[]; - /** Optimizer settings */ - optimizer?: Partial; - /** Version of the EVM to compile for. Affects type checking and code generation */ - evmVersion: 'homestead' | 'tangerineWhistle' | 'spuriousDragon' | 'byzantium' | 'constantinople'; - /** Metadata settings */ - metadata?: CompilerMetadata; - /** Addresses of the libraries. If not all libraries are given here, it can result in unlinked objects whose output data is different. */ - libraries: CompilerLibraries; - } - export interface CompilerOptimizer { - /** disabled by default */ - enable: boolean; - /** - * Optimize for how many times you intend to run the code. - * Lower values will optimize more for initial deployment cost, higher values will optimize more for high-frequency usage. - */ - runs: number; - } - export interface CompilerMetadata { - /** Use only literal content and not URLs (false by default) */ - useLiteralContent: boolean; - } - /** - * The top level key is the the name of the source file where the library is used. - * If remappings are used, this source file should match the global path after remappings were applied. - * If this key is an empty string, that refers to a global level. - */ - export interface CompilerLibraries { - [contractName: string]: { - [libName: string]: string; - }; - } - export type OutputType = 'abi' | 'ast' | 'devdoc' | 'userdoc' | 'metadata' | 'ir' | 'evm.assembly' | 'evm.legacyAssembly' | 'evm.bytecode.object' | 'evm.bytecode.opcodes' | 'evm.bytecode.sourceMap' | 'evm.bytecode.linkReferences' | 'evm.deployedBytecode' | 'evm.methodIdentifiers' | 'evm.gasEstimates' | 'ewasm.wast' | 'ewasm.wasm'; - /** - * The following can be used to select desired outputs. - * If this field is omitted, then the compiler loads and does type checking, but will not generate any outputs apart from errors. - * The first level key is the file name and the second is the contract name, where empty contract name refers to the file itself, - * while the star refers to all of the contracts. - * Note that using a using evm, evm.bytecode, ewasm, etc. will select every - * target part of that output. Additionally, * can be used as a wildcard to request everything. - */ - export interface CompilerOutputSelection { - [file: string]: { - [contract: string]: OutputType[]; - }; - } - -} -declare module 'dist/packages/api/lib/compiler/type/output' { - export interface CompilationFileSources { - [fileName: string]: { - keccak256?: string; - content: string; - urls?: string[]; - }; - } - export interface SourceWithTarget { - sources?: CompilationFileSources; - target?: string | null | undefined; - } - export interface CompilationResult { - /** not present if no errors/warnings were encountered */ - errors?: CompilationError[]; - /** This contains the file-level outputs. In can be limited/filtered by the outputSelection settings */ - sources: { - [contractName: string]: CompilationSource; - }; - /** This contains the contract-level outputs. It can be limited/filtered by the outputSelection settings */ - contracts: { - /** If the language used has no contract names, this field should equal to an empty string. */ - [fileName: string]: { - [contract: string]: CompiledContract; - }; - }; - } - export interface lastCompilationResult { - data: CompilationResult | null; - source: SourceWithTarget | null | undefined; - } - export interface CompilationError { - /** Location within the source file */ - sourceLocation?: { - file: string; - start: number; - end: number; - }; - /** Error type */ - type: CompilationErrorType; - /** Component where the error originated, such as "general", "ewasm", etc. */ - component: 'general' | 'ewasm' | string; - severity: 'error' | 'warning'; - message: string; - /** the message formatted with source location */ - formattedMessage?: string; - } type CompilationErrorType = 'JSONError' | 'IOError' | 'ParserError' | 'DocstringParsingError' | 'SyntaxError' | 'DeclarationError' | 'TypeError' | 'UnimplementedFeatureError' | 'InternalCompilerError' | 'Exception' | 'CompilerError' | 'FatalError' | 'Warning'; - export interface CompilationSource { - /** Identifier of the source (used in source maps) */ - id: number; - /** The AST object */ - ast: AstNode; - /** The legacy AST object */ - legacyAST: AstNodeLegacy; - } - export interface AstNode { - absolutePath?: string; - exportedSymbols?: Object; - id: number; - nodeType: string; - nodes?: Array; - src: string; - literals?: Array; - file?: string; - scope?: number; - sourceUnit?: number; - symbolAliases?: Array; - [x: string]: any; - } - export interface AstNodeLegacy { - id: number; - name: string; - src: string; - children?: Array; - attributes?: AstNodeAtt; - } - export interface AstNodeAtt { - operator?: string; - string?: null; - type?: string; - value?: string; - constant?: boolean; - name?: string; - public?: boolean; - exportedSymbols?: Object; - argumentTypes?: null; - absolutePath?: string; - [x: string]: any; - } - export interface CompiledContract { - /** The Ethereum Contract ABI. If empty, it is represented as an empty array. */ - abi: ABIDescription[]; - metadata: string; - /** User documentation (natural specification) */ - userdoc: UserDocumentation; - /** Developer documentation (natural specification) */ - devdoc: DeveloperDocumentation; - /** Intermediate representation (string) */ - ir: string; - /** EVM-related outputs */ - evm: { - assembly: string; - legacyAssembly: {}; - /** Bytecode and related details. */ - bytecode: BytecodeObject; - deployedBytecode: BytecodeObject; - /** The list of function hashes */ - methodIdentifiers: { - [functionIdentifier: string]: string; - }; - gasEstimates: { - creation: { - codeDepositCost: string; - executionCost: 'infinite' | string; - totalCost: 'infinite' | string; - }; - external: { - [functionIdentifier: string]: string; - }; - internal: { - [functionIdentifier: string]: 'infinite' | string; - }; - }; - }; - /** eWASM related outputs */ - ewasm: { - /** S-expressions format */ - wast: string; - /** Binary format (hex string) */ - wasm: string; - }; - } - export type ABIDescription = FunctionDescription | EventDescription; - export interface FunctionDescription { - /** Type of the method. default is 'function' */ - type?: 'function' | 'constructor' | 'fallback'; - /** The name of the function. Constructor and fallback functions never have a name */ - name?: string; - /** List of parameters of the method. Fallback functions don’t have inputs. */ - inputs?: ABIParameter[]; - /** List of the output parameters for the method, if any */ - outputs?: ABIParameter[]; - /** State mutability of the method */ - stateMutability: 'pure' | 'view' | 'nonpayable' | 'payable'; - /** true if function accepts Ether, false otherwise. Default is false */ - payable?: boolean; - /** true if function is either pure or view, false otherwise. Default is false */ - constant?: boolean; - } - export interface EventDescription { - type: 'event'; - name: string; - inputs: ABIParameter & { - /** true if the field is part of the log’s topics, false if it one of the log’s data segment. */ - indexed: boolean; - }[]; - /** true if the event was declared as anonymous. */ - anonymous: boolean; - } - export interface ABIParameter { - /** The name of the parameter */ - name: string; - /** The canonical type of the parameter */ - type: ABITypeParameter; - /** Used for tuple types */ - components?: ABIParameter[]; - } - export type ABITypeParameter = 'uint' | 'uint[]' | 'int' | 'int[]' | 'address' | 'address[]' | 'bool' | 'bool[]' | 'fixed' | 'fixed[]' | 'ufixed' | 'ufixed[]' | 'bytes' | 'bytes[]' | 'function' | 'function[]' | 'tuple' | 'tuple[]' | string; - export interface UserDocumentation { - methods: UserMethodList; - notice: string; - } - export type UserMethodList = { - [functionIdentifier: string]: UserMethodDoc; - } & { - 'constructor'?: string; - }; - export interface UserMethodDoc { - notice: string; - } - export interface DeveloperDocumentation { - author: string; - title: string; - details: string; - methods: DevMethodList; - } - export interface DevMethodList { - [functionIdentifier: string]: DevMethodDoc; - } - export interface DevMethodDoc { - author: string; - details: string; - return: string; - returns: { - [param: string]: string; - }; - params: { - [param: string]: string; - }; - } - export interface BytecodeObject { - /** The bytecode as a hex string. */ - object: string; - /** Opcodes list */ - opcodes: string; - /** The source mapping as a string. See the source mapping definition. */ - sourceMap: string; - /** If given, this is an unlinked object. */ - linkReferences?: { - [contractName: string]: { - /** Byte offsets into the bytecode. */ - [library: string]: { - start: number; - length: number; - }[]; - }; - }; - } - export {}; - -} -declare module 'dist/packages/api/lib/compiler/type/index' { - export * from 'dist/packages/api/lib/compiler/type/input'; - export * from 'dist/packages/api/lib/compiler/type/output'; - -} -declare module 'packages/utils/src/lib/tools/event-name' { - /** Create the name of the event for a call */ - export function callEvent(name: string, key: string, id: number): string; - /** Create the name of the event for a listen */ - export function listenEvent(name: string, key: string): string; - -} -declare module 'packages/utils/src/lib/tools/method-path' { - /** Create a method path based on the method name and the path */ - export function getMethodPath(method: string, path?: string): string; - /** Get the root name of a path */ - export function getRootPath(path: string): string; - -} -declare module 'packages/utils/src/lib/types/service' { - export type IPluginService = any> = { - methods: string[]; - readonly path: string; - } & T; - export type GetPluginService> = S extends IPluginService ? S : IPluginService; - -} -declare module 'packages/utils/src/lib/types/status' { - export interface Status { - /** Display an icon or number */ - key: number | 'edited' | 'succeed' | 'loading' | 'failed' | 'none'; - /** Bootstrap css color */ - type?: 'success' | 'info' | 'warning' | 'error'; - /** Describe the status on mouseover */ - title?: string; - } - export type StatusEvents = { - statusChanged: (status: Status) => void; - }; - -} -declare module 'packages/utils/src/lib/types/api' { - import { StatusEvents } from 'packages/utils/src/lib/types/status'; - export interface Api { - events: { - [key: string]: (...args: any[]) => void; - } & StatusEvents; - methods: { - [key: string]: (...args: any[]) => void; - }; - } - export type EventKey = Extract; - export type EventParams> = T extends Api ? Parameters : any[]; - export type EventCallback> = T extends Api ? T['events'][K] : (...payload: any[]) => void; - export type MethodKey = Extract; - export type MethodParams> = T extends Api ? Parameters : any[]; - export interface EventApi { - on: >(name: event, cb: T['events'][event]) => void; - } - export type MethodApi = { - [m in Extract]: (...args: Parameters) => Promise>; - }; - export type CustomApi = EventApi & MethodApi; - /** A map of Api used to describe all the plugin's api in the project */ - export type ApiMap = Readonly>; - /** A map of plugin based on the ApiMap. It enforces the PluginEngine */ - export type PluginApi = { - [name in keyof T]: CustomApi; - }; - export type API = { - [M in keyof T['methods']]: T['methods'][M] | Promise; - }; - -} -declare module 'packages/utils/src/lib/types/plugin' { - import type { IPluginService } from 'packages/utils/src/lib/types/service'; - import { EventCallback, MethodParams, MethodKey, EventKey, Api, ApiMap, EventParams } from 'packages/utils/src/lib/types/api'; - export interface PluginBase { - methods: string[]; - activateService: Record Promise>; - /** Listen on an event from another plugin */ - on, Key extends EventKey>(name: Name, key: Key, cb: EventCallback): void; - /** Listen one time on an event from another plugin, then remove event listener */ - once, Key extends EventKey>(name: Name, key: Key, cb: EventCallback): void; - /** Stop listening on an event from another plugin */ - off, Key extends EventKey>(name: Name, key: Key): void; - /** Call a method of another plugin */ - call, Key extends MethodKey>(name: Name, key: Key, ...payload: MethodParams): Promise; - /** Clear calls in queue of a plugin called by plugin */ - cancel, Key extends MethodKey>(name: Name, key: Key): void; - /** Emit an event */ - emit>(key: Key, ...payload: EventParams): void; - } - -} -declare module 'packages/utils/src/lib/tools/service' { - import type { IPluginService, GetPluginService } from 'packages/utils/src/lib/types/service'; - import type { Api, ApiMap } from 'packages/utils/src/lib/types/api'; - import type { PluginBase } from 'packages/utils/src/lib/types/plugin'; - /** Check if the plugin is an instance of PluginService */ - export const isPluginService: (service: any) => service is PluginService; - /** - * Return the methods of a service, except "constructor" and methods starting with "_" - * @param instance The instance of a class to get the method from - */ - export function getMethods(service: IPluginService): any; - /** - * Create a plugin service - * @param path The path of the service separated by '.' (ex: 'box.profile') - * @param service The service template - * @note If the service doesn't provide a property "methods" then all methods are going to be exposed by default - */ - export function createService>(path: string, service: T): GetPluginService; - /** - * Connect the service to the plugin client - * @param client The main client of the plugin - * @param service A service to activate - */ - export function activateService(client: PluginBase, service: IPluginService): any; - /** - * A node that forward the call to the right path - */ - export abstract class PluginService implements IPluginService { - methods: string[]; - abstract readonly path: string; - protected abstract plugin: PluginBase; - emit(key: string, ...payload: any[]): void; - /** - * Create a subservice under this service - * @param name The name of the subservice inside this service - * @param service The subservice to add - */ - createService>(name: string, service: S): Promise>; - /** - * Prepare a service to be lazy loaded. - * Service can be activated by doing client.activateService(path) - * @param name The name of the subservice inside this service - * @param factory A function to create the service on demand - */ - prepareService>(name: string, factory: () => S): void; - } - -} -declare module 'packages/utils/src/lib/types/message' { - export interface PluginRequest { - /** The name of the plugin making the request */ - from: string; - /** @deprecated Will be remove in the next version */ - isFromNative?: boolean; - /** - * The path to access the request inside the plugin - * @example 'remixd.cmd.git' - */ - path?: string; - } type MessageActions = 'on' | 'off' | 'once' | 'call' | 'response' | 'emit' | 'cancel'; type OldMessageActions = 'notification' | 'request' | 'response' | 'listen'; - export interface Message { - id: number; - action: MessageActions | OldMessageActions; - name: string; - key: string; - payload: any; - requestInfo: PluginRequest; - error?: Error | string; - } - export {}; - -} -declare module 'packages/utils/src/lib/types/queue' { - import type { PluginRequest } from 'packages/utils/src/lib/types/message'; - export interface PluginQueueInterface { - setCurrentRequest(request: PluginRequest): void; - callMethod(method: string, args: any[]): void; - letContinue(): void; - cancel(): void; - } - -} -declare module 'packages/utils/src/lib/types/profile' { - import { MethodKey, Api, ApiMap, EventKey } from 'packages/utils/src/lib/types/api'; - /** Describe a plugin */ - export interface Profile { - name: string; - displayName?: string; - methods?: MethodKey[]; - events?: EventKey[]; - permission?: boolean; - hash?: string; - description?: string; - documentation?: string; - version?: string; - kind?: string; - canActivate?: string[]; - icon?: string; - } - export interface LocationProfile { - location: string; - } - export interface ExternalProfile { - url: string; - } - export interface HostProfile extends Profile { - methods: ('addView' | 'removeView' | 'focus' | string)[]; - } - export interface LibraryProfile extends Profile { - events?: EventKey[]; - notifications?: { - [name: string]: string[]; - }; - } - /** A map of profile */ - export type ProfileMap = Partial<{ - [name in keyof T]: Profile; - }>; - /** Extract the API of a profile */ - export type ApiFromProfile = T extends Profile ? I : never; - /** Create an ApiMap from a Profile Map */ - export type ApiMapFromProfileMap> = { - [name in keyof T]: ApiFromProfile; - }; - /** Transform an ApiMap into a profile map */ - export type ProfileMapFromApiMap = Readonly<{ - [name in keyof T]: Profile; - }>; - -} -declare module 'packages/utils/src/lib/tools/queue' { - import { PluginQueueInterface } from 'packages/utils/src/lib/types/queue'; - import type { PluginRequest } from 'packages/utils/src/lib/types/message'; - import { Profile } from 'packages/utils/src/lib/types/profile'; - import { Api } from 'packages/utils/src/lib/types/api'; - import { PluginOptions } from '@remixproject/plugin-utils'; - export class PluginQueueItem implements PluginQueueInterface { - private resolve; - private reject; - private timer; - private running; - private args; - method: Profile['methods'][number]; - timedout: boolean; - canceled: boolean; - finished: boolean; - request: PluginRequest; - private options; - constructor(resolve: (value: unknown) => void, reject: (reason: any) => void, request: PluginRequest, method: Profile['methods'][number], options: PluginOptions, args: any[]); - setCurrentRequest(request: PluginRequest): void; - callMethod(method: string, args: any[]): void; - letContinue(): void; - cancel(): void; - run(): Promise; - } - -} -declare module 'packages/utils/src/lib/types/options' { - export interface PluginOptions { - /** The time to wait for a call to be executed before going to next call in the queue */ - queueTimeout?: number; - } - -} -declare module 'packages/utils/src/index' { - export * from 'packages/utils/src/lib/tools/event-name'; - export * from 'packages/utils/src/lib/tools/method-path'; - export * from 'packages/utils/src/lib/tools/service'; - export * from 'packages/utils/src/lib/tools/queue'; - export * from 'packages/utils/src/lib/types/api'; - export * from 'packages/utils/src/lib/types/message'; - export * from 'packages/utils/src/lib/types/plugin'; - export * from 'packages/utils/src/lib/types/profile'; - export * from 'packages/utils/src/lib/types/service'; - export * from 'packages/utils/src/lib/types/status'; - export * from 'packages/utils/src/lib/types/queue'; - export * from 'packages/utils/src/lib/types/options'; - -} -declare module 'dist/packages/api/lib/compiler/api' { - import { CompilationResult, CompilationFileSources, lastCompilationResult, CondensedCompilationInput, SourcesInput } from 'dist/packages/api/lib/compiler/type'; - import { StatusEvents, Api } from '@remixproject/plugin-utils'; - export interface ICompiler extends Api { - events: { - compilationFinished: (fileName: string, source: CompilationFileSources, languageVersion: string, data: CompilationResult) => void; - } & StatusEvents; - methods: { - getCompilationResult(): lastCompilationResult; - compile(fileName: string): void; - setCompilerConfig(settings: CondensedCompilationInput): void; - compileWithParameters(targets: SourcesInput, settings: CondensedCompilationInput): lastCompilationResult; - }; - } - -} -declare module 'dist/packages/api/lib/compiler/profile' { - import { ICompiler } from 'dist/packages/api/lib/compiler/api'; - import { LibraryProfile } from '@remixproject/plugin-utils'; - export const compilerProfile: LibraryProfile; - -} -declare module 'dist/packages/api/lib/compiler/index' { - export * from 'dist/packages/api/lib/compiler/api'; - export * from 'dist/packages/api/lib/compiler/type'; - export * from 'dist/packages/api/lib/compiler/profile'; - -} -declare module 'dist/packages/api/lib/content-import/type' { - export interface ContentImport { - content: any; - cleanUrl: string; - type: 'github' | 'http' | 'https' | 'swarm' | 'ipfs'; - url: string; - } - -} -declare module 'dist/packages/api/lib/content-import/api' { - import { ContentImport } from 'dist/packages/api/lib/content-import/type'; - import { StatusEvents } from '@remixproject/plugin-utils'; - export interface IContentImport { - events: {} & StatusEvents; - methods: { - resolve(path: string): ContentImport; - resolveAndSave(url: string, targetPath: string): string; - }; - } - -} -declare module 'dist/packages/api/lib/content-import/profile' { - import { IContentImport } from 'dist/packages/api/lib/content-import/api'; - import { LibraryProfile } from '@remixproject/plugin-utils'; - export const contentImportProfile: LibraryProfile; - -} -declare module 'dist/packages/api/lib/content-import/index' { - export * from 'dist/packages/api/lib/content-import/api'; - export * from 'dist/packages/api/lib/content-import/type'; - export * from 'dist/packages/api/lib/content-import/profile'; - -} -declare module 'dist/packages/api/lib/editor/type' { - export interface HighlightPosition { - start: { - line: number; - column: number; - }; - end: { - line: number; - column: number; - }; - } - export interface Annotation { - row: number; - column: number; - text: string; - type: "error" | "warning" | "info"; - } - -} -declare module 'dist/packages/api/lib/editor/api' { - import { HighlightPosition, Annotation } from 'dist/packages/api/lib/editor/type'; - import { StatusEvents } from '@remixproject/plugin-utils'; - export interface IEditor { - events: {} & StatusEvents; - methods: { - highlight(position: HighlightPosition, filePath: string, hexColor: string): void; - discardHighlight(): void; - discardHighlightAt(line: number, filePath: string): void; - addAnnotation(annotation: Annotation): void; - clearAnnotations(): void; - }; - } - -} -declare module 'dist/packages/api/lib/editor/profile' { - import { IEditor } from 'dist/packages/api/lib/editor/api'; - import { LibraryProfile } from '@remixproject/plugin-utils'; - export const editorProfile: LibraryProfile; - -} -declare module 'dist/packages/api/lib/editor/index' { - export * from 'dist/packages/api/lib/editor/type'; - export * from 'dist/packages/api/lib/editor/api'; - export * from 'dist/packages/api/lib/editor/profile'; - -} -declare module 'dist/packages/api/lib/file-system/type' { - export interface Folder { - [path: string]: { - isDirectory: boolean; - }; - } - -} -declare module 'dist/packages/api/lib/file-system/api' { - import { Folder } from 'dist/packages/api/lib/file-system/type'; - import { StatusEvents } from '@remixproject/plugin-utils'; - export interface IFileSystem { - events: { - currentFileChanged: (file: string) => void; - fileSaved: (file: string) => void; - fileAdded: (file: string) => void; - fileRemoved: (file: string) => void; - fileClosed: (file: string) => void; - noFileSelected: () => void; - fileRenamed: (oldName: string, newName: string, isFolder: boolean) => void; - } & StatusEvents; - methods: { - /** Open the content of the file in the context (eg: Editor) */ - open(path: string): void; - /** Set the content of a specific file */ - writeFile(path: string, data: string): void; - /** Return the content of a specific file */ - readFile(path: string): string; - /** Change the path of a file */ - rename(oldPath: string, newPath: string): void; - /** Upsert a file with the content of the source file */ - copyFile(src: string, dest: string): void; - /** Create a directory */ - mkdir(path: string): void; - /** Get the list of files in the directory */ - readdir(path: string): string[]; - /** Removes a file or directory recursively */ - remove(path: string): void; - /** Get the name of the file currently focused if any */ - getCurrentFile(): string; - /** @deprecated Use readdir */ - getFolder(path: string): Folder; - /** @deprecated Use readFile */ - getFile(path: string): string; - /** @deprecated Use writeFile */ - setFile(path: string, content: string): void; - /** @deprecated Use open */ - switchFile(path: string): void; - }; - } - -} -declare module 'dist/packages/api/lib/file-system/profile' { - import { IFileSystem } from 'dist/packages/api/lib/file-system/api'; - import { LocationProfile, Profile } from '@remixproject/plugin-utils'; - export const filSystemProfile: Profile & LocationProfile; - -} -declare module 'dist/packages/api/lib/file-system/index' { - export * from 'dist/packages/api/lib/file-system/api'; - export * from 'dist/packages/api/lib/file-system/type'; - export * from 'dist/packages/api/lib/file-system/profile'; - -} -declare module 'dist/packages/api/lib/git/api' { - import { StatusEvents } from '@remixproject/plugin-utils'; - export interface IGitSystem { - events: {} & StatusEvents; - methods: { - clone(url: string): string; - checkout(cmd: string): string; - init(): string; - add(cmd: string): string; - commit(cmd: string): string; - fetch(cmd: string): string; - pull(cmd: string): string; - push(cmd: string): string; - reset(cmd: string): string; - status(cmd: string): string; - remote(cmd: string): string; - log(): string; - }; - } - -} -declare module 'dist/packages/api/lib/git/profile' { - import { IGitSystem } from 'dist/packages/api/lib/git/api'; - import { LibraryProfile } from '@remixproject/plugin-utils'; - export const gitProfile: LibraryProfile; - -} -declare module 'dist/packages/api/lib/git/index' { - export * from 'dist/packages/api/lib/git/api'; - export * from 'dist/packages/api/lib/git/profile'; - -} -declare module 'dist/packages/api/lib/network/type' { - /** @deprecated: current version in Remix IDE. To improve to match standard JSON RPC methods */ - export interface CustomNetwork { - id?: string; - name: string; - url: string; - } - /** @deprecated: current version in Remix IDE. To improve to match standard JSON RPC methods */ - export type NetworkProvider = 'vm' | 'injected' | 'web3'; - export type Network = { - id: '1'; - name: 'Main'; - } | { - id: '2'; - name: 'Morden (deprecated)'; - } | { - id: '3'; - name: 'Ropsten'; - } | { - id: '4'; - name: 'Rinkeby'; - } | { - id: '5'; - name: 'Goerli'; - } | { - id: '42'; - name: 'Kovan'; - }; - -} -declare module 'dist/packages/api/lib/network/api' { - import { StatusEvents } from '@remixproject/plugin-utils'; - import { NetworkProvider, Network, CustomNetwork } from 'dist/packages/api/lib/network/type'; - /** @deprecated: current version in Remix IDE. To improve to match standard JSON RPC methods */ - export interface INetwork { - events: { - providerChanged: (provider: NetworkProvider) => void; - } & StatusEvents; - methods: { - getNetworkProvider(): NetworkProvider; - detectNetwork(): Network | Partial; - getEndpoint(): string; - addNetwork(network: CustomNetwork): void; - removeNetwork(name: string): void; - }; - } - -} -declare module 'dist/packages/api/lib/network/profile' { - import { INetwork } from 'dist/packages/api/lib/network/api'; - import { LibraryProfile } from '@remixproject/plugin-utils'; - export const networkProfile: LibraryProfile; - -} -declare module 'dist/packages/api/lib/network/index' { - export * from 'dist/packages/api/lib/network/api'; - export * from 'dist/packages/api/lib/network/type'; - export * from 'dist/packages/api/lib/network/profile'; - -} -declare module 'dist/packages/api/lib/plugin-manager/api' { - import { StatusEvents, Profile } from '@remixproject/plugin-utils'; - export interface IPluginManager { - events: { - profileUpdated(profile: Profile): void; - profileAdded(profile: Profile): void; - pluginDeactivated(profile: Profile): void; - pluginActivated(profile: Profile): void; - } & StatusEvents; - methods: { - getProfile(name: string): Promise; - updateProfile(profile: Partial): any; - activatePlugin(name: string): any; - deactivatePlugin(name: string): any; - isActive(name: string): boolean; - canCall(from: string, to: string, method: string, message?: string): any; - }; - } - -} -declare module 'dist/packages/api/lib/plugin-manager/profile' { - import { IPluginManager } from 'dist/packages/api/lib/plugin-manager/api'; - import { LibraryProfile } from '@remixproject/plugin-utils'; - export const pluginManagerProfile: LibraryProfile & { - name: 'manager'; - }; - -} -declare module 'dist/packages/api/lib/plugin-manager/index' { - export * from 'dist/packages/api/lib/plugin-manager/api'; - export * from 'dist/packages/api/lib/plugin-manager/profile'; - -} -declare module 'dist/packages/api/lib/settings/api' { - import { StatusEvents } from '@remixproject/plugin-utils'; - export interface ISettings { - events: {} & StatusEvents; - methods: { - getGithubAccessToken(): string; - }; - } - -} -declare module 'dist/packages/api/lib/settings/profile' { - import { ISettings } from 'dist/packages/api/lib/settings/api'; - import { LibraryProfile } from '@remixproject/plugin-utils'; - export const settingsProfile: LibraryProfile; - -} -declare module 'dist/packages/api/lib/settings/index' { - export * from 'dist/packages/api/lib/settings/api'; - export * from 'dist/packages/api/lib/settings/profile'; - -} -declare module 'dist/packages/api/lib/theme/types' { - export interface Theme { - url?: string; - /** @deprecated Use brightness instead */ - quality?: 'dark' | 'light'; - brightness: 'dark' | 'light'; - colors: { - surface: string; - background: string; - foreground: string; - primary: string; - primaryContrast: string; - secondary?: string; - secondaryContrast?: string; - success?: string; - successContrast?: string; - warn: string; - warnContrast: string; - error: string; - errorContrast: string; - disabled: string; - }; - breakpoints: { - xs: number; - sm: number; - md: number; - lg: number; - xl: number; - }; - fontFamily: string; - /** A unit to multiply for margin & padding */ - space: number; - } - export interface ThemeUrls { - light: string; - dark: string; - } - -} -declare module 'dist/packages/api/lib/theme/api' { - import { StatusEvents } from '@remixproject/plugin-utils'; - import { Theme } from 'dist/packages/api/lib/theme/types'; - export interface ITheme { - events: { - themeChanged: (theme: Theme) => void; - } & StatusEvents; - methods: { - currentTheme(): Theme; - }; - } - -} -declare module 'dist/packages/api/lib/theme/profile' { - import { ITheme } from 'dist/packages/api/lib/theme/api'; - import { LibraryProfile } from '@remixproject/plugin-utils'; - export const themeProfile: LibraryProfile; - -} -declare module 'dist/packages/api/lib/theme/index' { - export * from 'dist/packages/api/lib/theme/api'; - export * from 'dist/packages/api/lib/theme/profile'; - export * from 'dist/packages/api/lib/theme/types'; - -} -declare module 'dist/packages/api/lib/udapp/type' { - export type RemixTxEvent = { - contractAddress: string; - data: string; - envMode: 'vm'; - executionCost: string; - from: string; - gas: string; - hash: string; - input: string; - logs: any[]; - returnValue: Uint8Array; - status: '0x01' | '0x00'; - transactionCost: string; - transactionHash: string; - value: string; - } | { - blockHash: string; - blockNumber: number; - envMod: 'injected' | 'web3'; - from: string; - gas: number; - gasPrice: { - c: number[]; - e: number; - s: number; - }; - hash: string; - input: string; - none: number; - r: string; - s: string; - v: string; - status: '0x01' | '0x00'; - to: string; - transactionCost: string; - transactionIndex: number; - value: { - c: number[]; - e: number; - s: number; - }; - }; - export interface RemixTx { - data: string; - from: string; - to?: string; - timestamp?: string; - gasLimit: string; - value: string; - useCall: boolean; - } - export interface RemixTxReceipt { - transactionHash: string; - status: 0 | 1; - gasUsed: string; - error: string; - return: string; - createdAddress?: string; - } - export interface VMAccount { - privateKey: string; - balance: string; - } - export interface UdappSettings { - selectedAccount: string; - selectedEnvMode: 'vm' | 'injected' | 'web3'; - networkEnvironment: string; - } - -} -declare module 'dist/packages/api/lib/udapp/api' { - import { RemixTx, RemixTxReceipt, RemixTxEvent, VMAccount, UdappSettings } from 'dist/packages/api/lib/udapp/type'; - import { StatusEvents } from '@remixproject/plugin-utils'; - export interface IUdapp { - events: { - newTransaction: (transaction: RemixTxEvent) => void; - } & StatusEvents; - methods: { - sendTransaction(tx: RemixTx): RemixTxReceipt; - getAccounts(): string[]; - createVMAccount(vmAccount: VMAccount): string; - getSettings(): UdappSettings; - setEnvironmentMode(env: 'vm' | 'injected' | 'web3'): void; - }; - } - -} -declare module 'dist/packages/api/lib/udapp/profile' { - import { IUdapp } from 'dist/packages/api/lib/udapp/api'; - import { LibraryProfile } from '@remixproject/plugin-utils'; - export const udappProfile: LibraryProfile; - -} -declare module 'dist/packages/api/lib/udapp/index' { - export * from 'dist/packages/api/lib/udapp/api'; - export * from 'dist/packages/api/lib/udapp/type'; - export * from 'dist/packages/api/lib/udapp/profile'; - -} -declare module 'dist/packages/api/lib/unit-testing/type' { - export interface UnitTestResult { - totalFailing: number; - totalPassing: number; - totalTime: number; - errors: UnitTestError[]; - } - export interface UnitTestError { - context: string; - value: string; - message: string; - } - -} -declare module 'dist/packages/api/lib/unit-testing/api' { - import { UnitTestResult } from 'dist/packages/api/lib/unit-testing/type'; - import { StatusEvents } from '@remixproject/plugin-utils'; - export interface IUnitTesting { - events: {} & StatusEvents; - methods: { - testFromPath(path: string): UnitTestResult; - testFromSource(sourceCode: string): UnitTestResult; - }; - } - -} -declare module 'dist/packages/api/lib/unit-testing/profile' { - import { IUnitTesting } from 'dist/packages/api/lib/unit-testing/api'; - import { LibraryProfile } from '@remixproject/plugin-utils'; - export const unitTestProfile: LibraryProfile; - -} -declare module 'dist/packages/api/lib/unit-testing/index' { - export * from 'dist/packages/api/lib/unit-testing/api'; - export * from 'dist/packages/api/lib/unit-testing/type'; - export * from 'dist/packages/api/lib/unit-testing/profile'; - -} -declare module 'dist/packages/api/lib/window/api' { - import { StatusEvents } from '@remixproject/plugin-utils'; - export interface IWindow { - events: {} & StatusEvents; - methods: { - /** Display an input window */ - prompt(message?: string): string; - /** Ask confirmation for an action */ - confirm(message: string): boolean; - /** Display a message with actions button. Returned the button clicked if any */ - alert(message: string, actions?: string[]): string | void; - }; - } - -} -declare module 'dist/packages/api/lib/window/profile' { - import { IWindow } from 'dist/packages/api/lib/window/api'; - import { LibraryProfile } from '@remixproject/plugin-utils'; - export const windowProfile: LibraryProfile; - -} -declare module 'dist/packages/api/lib/window/index' { - export * from 'dist/packages/api/lib/window/api'; - export * from 'dist/packages/api/lib/window/profile'; - -} -declare module 'dist/packages/api/lib/remix-profile' { - import { ProfileMap } from '@remixproject/plugin-utils'; - import { ICompiler } from 'dist/packages/api/lib/compiler'; - import { IFileSystem } from 'dist/packages/api/lib/file-system'; - import { IEditor } from 'dist/packages/api/lib/editor'; - import { INetwork } from 'dist/packages/api/lib/network'; - import { IUdapp } from 'dist/packages/api/lib/udapp'; - import { ITheme } from 'dist/packages/api/lib/theme'; - import { IUnitTesting } from 'dist/packages/api/lib/unit-testing'; - import { IContentImport } from 'dist/packages/api/lib/content-import'; - import { ISettings } from 'dist/packages/api/lib/settings'; - import { IPluginManager } from 'dist/packages/api/lib/plugin-manager'; - export interface IRemixApi { - manager: IPluginManager; - solidity: ICompiler; - fileManager: IFileSystem; - solidityUnitTesting: IUnitTesting; - editor: IEditor; - network: INetwork; - udapp: IUdapp; - contentImport: IContentImport; - settings: ISettings; - theme: ITheme; - } - export type RemixApi = Readonly; - /** @deprecated Use remixProfiles instead. Will be remove in next version */ - export const remixApi: ProfileMap; - /** Profiles of all the remix's Native Plugins */ - export const remixProfiles: ProfileMap; - -} -declare module 'dist/packages/api/lib/standard-profile' { - import { ProfileMap } from '@remixproject/plugin-utils'; - import { ICompiler } from 'dist/packages/api/lib/compiler'; - import { IFileSystem } from 'dist/packages/api/lib/file-system'; - import { IEditor } from 'dist/packages/api/lib/editor'; - import { INetwork } from 'dist/packages/api/lib/network'; - import { IUdapp } from 'dist/packages/api/lib/udapp'; - import { IPluginManager } from 'dist/packages/api/lib/plugin-manager'; - export interface IStandardApi { - manager: IPluginManager; - solidity: ICompiler; - fileManager: IFileSystem; - editor: IEditor; - network: INetwork; - udapp: IUdapp; - } - export type StandardApi = Readonly; - /** Profiles of all the standard's Native Plugins */ - export const standardProfiles: ProfileMap; - -} -declare module 'dist/packages/api/index' { - export * from 'dist/packages/api/lib/compiler'; - export * from 'dist/packages/api/lib/content-import'; - export * from 'dist/packages/api/lib/editor'; - export * from 'dist/packages/api/lib/file-system'; - export * from 'dist/packages/api/lib/git'; - export * from 'dist/packages/api/lib/network'; - export * from 'dist/packages/api/lib/plugin-manager'; - export * from 'dist/packages/api/lib/settings'; - export * from 'dist/packages/api/lib/theme'; - export * from 'dist/packages/api/lib/udapp'; - export * from 'dist/packages/api/lib/unit-testing'; - export * from 'dist/packages/api/lib/window'; - export * from 'dist/packages/api/lib/remix-profile'; - export * from 'dist/packages/api/lib/standard-profile'; - -} -declare module 'dist/packages/engine/core/lib/abstract' { - import type { Api, EventKey, EventParams, MethodKey, MethodParams, EventCallback, ApiMap, Profile, PluginRequest, PluginApi, PluginBase, IPluginService } from '@remixproject/plugin-utils'; - export interface RequestParams { - name: string; - key: string; - payload: any[]; - } - export interface PluginOptions { - /** The time to wait for a call to be executed before going to next call in the queue */ - queueTimeout?: number; - } - export class Plugin implements PluginBase { - profile: Profile; - activateService: Record Promise>; - protected requestQueue: Array<() => Promise>; - protected currentRequest: PluginRequest; - /** Give access to all the plugins registered by the engine */ - protected app: PluginApi; - protected options: PluginOptions; - onRegistration?(): void; - onActivation?(): void; - onDeactivation?(): void; - constructor(profile: Profile); - get name(): string; - get methods(): Extract[]; - set methods(methods: Extract[]); - activate(): any | Promise; - deactivate(): any | Promise; - setOptions(options?: Partial): void; - /** Call a method from this plugin */ - protected callPluginMethod(key: string, args: any[]): any; - /** Add a request to the list of current requests */ - protected addRequest(request: PluginRequest, method: Profile['methods'][number], args: any[]): Promise; - /** - * Ask the plugin manager if current request can call a specific method - * @param method The method to call - * @param message An optional message to show to the user - */ - askUserPermission(method: MethodKey, message?: string): Promise; - /** - * Called by the engine when a plugin try to activate it - * @param from the profile of the plugin activating this plugin - * @param method method used to activate this plugin if any - */ - canActivate(from: Profile, method?: string): Promise; - /** - * Called by the engine when a plugin try to deactivate it - * @param from the profile of the plugin deactivating this plugin - */ - canDeactivate(from: Profile): Promise; - /** - * Create a service under the client node - * @param name The name of the service - * @param service The service - */ - createService>(name: string, service: S): Promise>; - /** - * Prepare a service to be lazy loaded - * @param name The name of the subservice inside this service - * @param factory A function to create the service on demand - */ - prepareService>(name: string, factory: () => S): () => Promise>; - /** Listen on an event from another plugin */ - on, Key extends EventKey>(name: Name, key: Key, cb: EventCallback): void; - /** Listen once an event from another plugin then remove event listener */ - once, Key extends EventKey>(name: Name, key: Key, cb: EventCallback): void; - /** Stop listening on an event from another plugin */ - off, Key extends EventKey>(name: Name, key: Key): void; - /** Call a method of another plugin */ - call, Key extends MethodKey>(name: Name, key: Key, ...payload: MethodParams): Promise>; - /** Emit an event */ - emit>(key: Key, ...payload: EventParams): void; - } - -} -declare module 'dist/packages/engine/core/lib/connector' { - import type { ExternalProfile, Profile, Message } from '@remixproject/plugin-utils'; - import { Plugin, PluginOptions } from 'dist/packages/engine/core/lib/abstract'; - /** List of available gateways for decentralised storage */ - export const defaultGateways: { - 'ipfs://': (url: any, name: any) => string; - 'swarm://': (url: any, name: any) => string; - }; - /** Transform the URL to use a gateway if decentralised storage is specified */ - export function transformUrl({ url, name }: Profile & ExternalProfile): any; - export interface PluginConnectorOptions extends PluginOptions { - /** Usally used to reload the plugin on changes */ - devMode?: boolean; - transformUrl?: (profile: Profile & ExternalProfile) => string; - engine?: string; - } - export abstract class PluginConnector extends Plugin { - protected loaded: boolean; - protected id: number; - protected pendingRequest: Record void>; - protected options: PluginConnectorOptions; - profile: Profile & ExternalProfile; - constructor(profile: Profile & ExternalProfile); - /** - * Send a message to the external plugin - * @param message the message passed to the plugin - */ - protected abstract send(message: Partial): void; - /** - * Open connection with the plugin - * @param url The transformed url the plugin should connect to - */ - protected abstract connect(url: string): any | Promise; - /** Close connection with the plugin */ - protected abstract disconnect(): any | Promise; - activate(): Promise; - deactivate(): Promise; - /** Set options for an external plugin */ - setOptions(options?: Partial): void; - /** Call a method from this plugin */ - protected callPluginMethod(key: string, payload?: any[]): Promise; - /** Perform handshake with the client if not loaded yet */ - protected handshake(handshakeSpecificPayload?: string[]): Promise; - /** - * React when a message comes from client - * @param message The message sent by the client - */ - protected getMessage(message: Message): Promise; - } - -} -declare module 'dist/packages/engine/core/lib/engine' { - import type { Profile } from '@remixproject/plugin-utils'; - import { Plugin, PluginOptions } from 'dist/packages/engine/core/lib/abstract'; - export class Engine { - private plugins; - private events; - private listeners; - private eventMemory; - private manager; - onRegistration?(plugin: Plugin): void; - /** Update the options of the plugin when being registered */ - setPluginOption?(profile: Profile): PluginOptions; - /** - * Broadcast an event to the plugin listening - * @param emitter Plugin name that emits the event - * @param event The name of the event - * @param payload The content of the event - */ - private broadcast; - /** - * Start listening on an event from another plugin - * @param listener The name of the plugin that listen on the event - * @param emitter The name of the plugin that emit the event - * @param event The name of the event - * @param cb Callback function to trigger when the event is trigger - */ - private addListener; - /** - * Remove an event from the list of a listener's events - * @param listener The name of the plugin that was listening on the event - * @param emitter The name of the plugin that emitted the event - * @param event The name of the event - */ - private removeListener; - /** - * Create a listener that listen only once on an event - * @param listener The name of the plugin that listen on the event - * @param emitter The name of the plugin that emitted the event - * @param event The name of the event - * @param cb Callback function to trigger when event is triggered - */ - private listenOnce; - /** - * Call a method of a plugin from another - * @param caller The name of the plugin that calls the method - * @param path The path of the plugin that manages the method - * @param method The name of the method - * @param payload The argument to pass to the method - */ - private callMethod; - /** - * Create an object to easily access any registered plugin - * @param name Name of the caller plugin - * @note This method creates a snapshot at the time of activation - */ - private createApp; - /** - * Activate a plugin by making its method and event available - * @param name The name of the plugin - * @note This method is trigger by the plugin manager when a plugin has been activated - */ - private activatePlugin; - /** - * Deactivate a plugin by removing all its event listeners and making it inaccessible - * @param name The name of the plugin - * @note This method is trigger by the plugin manager when a plugin has been deactivated - */ - private deactivatePlugin; - /** - * Update error message when trying to call a method when not activated - * @param plugin The deactivated plugin to update the methods from - */ - private updateErrorHandler; - /** - * Register a plugin to the engine and update the manager - * @param plugin The plugin - */ - register(plugins: Plugin | Plugin[]): string | string[]; - /** Register the manager */ - private registerManager; - /** Remove plugin(s) from engine */ - remove(names: string | string[]): Promise | Promise; - /** - * Check is a name is already registered - * @param name Name of the plugin - */ - isRegistered(name: string): boolean; - } - -} -declare module 'dist/packages/engine/core/lib/library' { - import type { EventEmitter } from 'events'; - import type { Api, Profile, LibraryProfile, LocationProfile } from '@remixproject/plugin-utils'; - import { Plugin } from 'dist/packages/engine/core/lib/abstract'; - export type LibraryApi = { - [method in P['methods'][number]]: T['methods'][method]; - } & { - events?: EventEmitter; - } & { - render?(): Element; - }; type LibraryViewProfile = LocationProfile & LibraryProfile; - export function isViewLibrary(profile: any): profile is LibraryViewProfile; - export class LibraryPlugin extends Plugin { - protected library: LibraryApi; - profile: P; - private isView; - constructor(library: LibraryApi, profile: P); - activate(): Promise; - deactivate(): void; - /** Call a method from this plugin */ - protected callPluginMethod(key: string, payload: any[]): any; - } - export {}; - -} -declare module 'dist/packages/engine/core/lib/manager' { - import type { Profile } from '@remixproject/plugin-utils'; - import { Plugin } from 'dist/packages/engine/core/lib/abstract'; - export type BasePluginManager = { - getProfile(name: string): Promise; - updateProfile(profile: Partial): Promise; - activatePlugin(name: string): Promise; - deactivatePlugin(name: string): Promise; - isActive(name: string): Promise; - canCall(from: Profile, to: Profile, method: string): Promise; - toggleActive(name: string): any; - addProfile(profiles: Partial | Partial[]): any; - canActivatePlugin(from: Profile, to: Profile, method?: string): Promise; - canDeactivatePlugin(from: Profile, to: Profile): Promise; - } & Plugin; - interface ManagerProfile extends Profile { - name: 'manager'; - } - export class PluginManager extends Plugin implements BasePluginManager { - protected profiles: Record; - protected actives: string[]; - protected onPluginActivated?(profile: Profile): any; - protected onPluginDeactivated?(profile: Profile): any; - protected onProfileAdded?(profile: Profile): any; - constructor(profile?: ManagerProfile); - /** Return the name of the caller. If no request provided, this mean that the method has been called from the IDE so we use "manager" */ - get requestFrom(): string; - /** Run engine activation. Implemented by Engine */ - private engineActivatePlugin; - /** Run engine deactivation. Implemented by Engine */ - private engineDeactivatePlugin; - /** - * Get the profile if it's registered. - * @param name The name of the plugin - * @note This method can be overrided - */ - getProfile(name: string): Promise>; - /** Get all the profiles of the manager */ - getProfiles(): Profile[]; - /** Get all active profiles of the manager */ - getActiveProfiles(): Profile[]; - /** - * Update the profile of the plugin - * @param profile The Updated version of the plugin - * @note Only the caller plugin should be able to update its profile - */ - updateProfile(to: Partial): Promise; - /** - * Add a profile to the list of profile - * @param profile The profile to add - * @note This method should only be used by the engine - */ - addProfile(profiles: Profile | Profile[]): void | void[]; - /** - * Verify if a plugin is currently active - * @param name Name of the plugin - */ - isActive(name: string): Promise; - /** - * Check if caller can activate plugin and activate it if authorized - * @param name The name of the plugin to activate - */ - activatePlugin(names: string | string[]): Promise; - /** - * Check if caller can deactivate plugin and deactivate it if authorized - * @param name The name of the plugin to activate - */ - deactivatePlugin(names: string | string[]): Promise; - /** - * Activate or deactivate by bypassing permission - * @param name The name of the plugin to activate - * @note This method should ONLY be used by the IDE - */ - toggleActive(names: string | string[]): Promise; - /** - * Check if a plugin can activate another - * @param from Profile of the caller plugin - * @param to Profile of the target plugin - * @note This method should be overrided - */ - canActivatePlugin(from: Profile, to: Profile): Promise; - /** - * Check if a plugin can deactivate another - * @param from Profile of the caller plugin - * @param to Profile of the target plugin - * @note This method should be overrided - */ - canDeactivatePlugin(from: Profile, to: Profile): Promise; - /** - * Check if a plugin can call a method of another - * @param from Profile of the caller plugin - * @param to Profile of the target plugin - * @param method Method targetted by the caller - * @param message Method provided by the targetted method plugin - */ - canCall(from: Profile, to: Profile, method: string, message?: string): Promise; - /** - * Check if a plugin can update profile of another one - * @param from Profile of the caller plugin - * @param to Updates on the profile of the target plugin - * @note This method can be overrided - */ - canUpdateProfile(from: Profile, to: Partial): Promise; - } - export {}; - -} -declare module 'dist/packages/engine/core/index' { - export * from 'dist/packages/engine/core/lib/abstract'; - export * from 'dist/packages/engine/core/lib/connector'; - export * from 'dist/packages/engine/core/lib/engine'; - export * from 'dist/packages/engine/core/lib/library'; - export * from 'dist/packages/engine/core/lib/manager'; - -} -declare module 'packages/engine/core/src/lib/abstract' { - import type { Api, EventKey, EventParams, MethodKey, MethodParams, EventCallback, ApiMap, Profile, PluginRequest, PluginApi, PluginBase, IPluginService, PluginOptions } from '@remixproject/plugin-utils'; - import { PluginQueueItem } from '@remixproject/plugin-utils'; - export interface RequestParams { - name: string; - key: string; - payload: any[]; - } - export class Plugin implements PluginBase { - profile: Profile; - activateService: Record Promise>; - protected currentRequest: PluginRequest; - /** Give access to all the plugins registered by the engine */ - protected app: PluginApi; - protected options: PluginOptions; - protected queue: PluginQueueItem[]; - onRegistration?(): void; - onActivation?(): void; - onDeactivation?(): void; - constructor(profile: Profile); - get name(): string; - get methods(): Extract[]; - set methods(methods: Extract[]); - activate(): any | Promise; - deactivate(): any | Promise; - setOptions(options?: Partial): void; - /** Call a method on this plugin */ - protected callPluginMethod(key: string, args: any[]): any; - protected setCurrentRequest(request: PluginRequest): void; - protected letContinue(): void; - /** Add a request to the list of current requests */ - protected addRequest(request: PluginRequest, method: Profile['methods'][number], args: any[]): Promise; - protected cancelRequests(request: PluginRequest, method: Profile['methods'][number]): void; - /** - * Ask the plugin manager if current request can call a specific method - * @param method The method to call - * @param message An optional message to show to the user - */ - askUserPermission(method: MethodKey, message?: string): Promise; - /** - * Called by the engine when a plugin try to activate it - * @param from the profile of the plugin activating this plugin - * @param method method used to activate this plugin if any - */ - canActivate(from: Profile, method?: string): Promise; - /** - * Called by the engine when a plugin try to deactivate it - * @param from the profile of the plugin deactivating this plugin - */ - canDeactivate(from: Profile): Promise; - /** - * Create a service under the client node - * @param name The name of the service - * @param service The service - */ - createService>(name: string, service: S): Promise>; - /** - * Prepare a service to be lazy loaded - * @param name The name of the subservice inside this service - * @param factory A function to create the service on demand - */ - prepareService>(name: string, factory: () => S): () => Promise>; - /** Listen on an event from another plugin */ - on, Key extends EventKey>(name: Name, key: Key, cb: EventCallback): void; - /** Listen once an event from another plugin then remove event listener */ - once, Key extends EventKey>(name: Name, key: Key, cb: EventCallback): void; - /** Stop listening on an event from another plugin */ - off, Key extends EventKey>(name: Name, key: Key): void; - /** Call a method of another plugin */ - call, Key extends MethodKey>(name: Name, key: Key, ...payload: MethodParams): Promise>; - /** Cancel a method of another plugin */ - cancel, Key extends MethodKey>(name: Name, key: Key): Promise>; - /** Emit an event */ - emit>(key: Key, ...payload: EventParams): void; - } - -} -declare module 'packages/engine/core/src/lib/connector' { - import type { ExternalProfile, Profile, Message, PluginOptions } from '@remixproject/plugin-utils'; - import { Plugin } from 'packages/engine/core/src/lib/abstract'; - /** List of available gateways for decentralised storage */ - export const defaultGateways: { - 'ipfs://': (url: any, name: any) => string; - 'swarm://': (url: any, name: any) => string; - }; - /** Transform the URL to use a gateway if decentralised storage is specified */ - export function transformUrl({ url, name }: Profile & ExternalProfile): any; - export interface PluginConnectorOptions extends PluginOptions { - /** Usally used to reload the plugin on changes */ - devMode?: boolean; - transformUrl?: (profile: Profile & ExternalProfile) => string; - engine?: string; - } - export abstract class PluginConnector extends Plugin { - protected loaded: boolean; - protected id: number; - protected pendingRequest: Record void>; - protected options: PluginConnectorOptions; - profile: Profile & ExternalProfile; - constructor(profile: Profile & ExternalProfile); - /** - * Send a message to the external plugin - * @param message the message passed to the plugin - */ - protected abstract send(message: Partial): void; - /** - * Open connection with the plugin - * @param url The transformed url the plugin should connect to - */ - protected abstract connect(url: string): any | Promise; - /** Close connection with the plugin */ - protected abstract disconnect(): any | Promise; - activate(): Promise; - deactivate(): Promise; - /** Set options for an external plugin */ - setOptions(options?: Partial): void; - /** Call a method from this plugin */ - protected callPluginMethod(key: string, payload?: any[]): Promise; - /** Perform handshake with the client if not loaded yet */ - protected handshake(): Promise; - /** - * React when a message comes from client - * @param message The message sent by the client - */ - protected getMessage(message: Message): Promise; - } - -} -declare module 'packages/api/src/lib/compiler/type/input' { - export interface CompilationInput { - /** Source code language */ - language: 'Solidity' | 'Vyper' | 'lll' | 'assembly' | 'yul'; - sources: SourcesInput; - settings?: CompilerSettings; - outputSelection?: CompilerOutputSelection; - } - export interface CondensedCompilationInput { - language: 'Solidity' | 'Vyper' | 'lll' | 'assembly' | 'yul'; - optimize: boolean; - /** e.g: 0.6.8+commit.0bbfe453 */ - version: string; - evmVersion?: 'istanbul' | 'petersburg' | 'constantinople' | 'byzantium' | 'spuriousDragon' | 'tangerineWhistle' | 'homestead'; - } - export interface SourceInputUrls { - /** Hash of the source file. It is used to verify the retrieved content imported via URLs */ - keccak256?: string; - /** - * URL(s) to the source file. - * URL(s) should be imported in this order and the result checked against the - * keccak256 hash (if available). If the hash doesn't match or none of the - * URL(s) result in success, an error should be raised. - */ - urls: string[]; - } - export interface SourceInputContent { - /** Hash of the source file. */ - keccak256?: string; - /** Literal contents of the source file */ - content: string; - } - export interface SourcesInput { - [contractName: string]: SourceInputContent | SourceInputUrls; - } - export interface CompilerSettings { - /** Sorted list of remappings */ - remappings?: string[]; - /** Optimizer settings */ - optimizer?: Partial; - /** Version of the EVM to compile for. Affects type checking and code generation */ - evmVersion: 'homestead' | 'tangerineWhistle' | 'spuriousDragon' | 'byzantium' | 'constantinople'; - /** Metadata settings */ - metadata?: CompilerMetadata; - /** Addresses of the libraries. If not all libraries are given here, it can result in unlinked objects whose output data is different. */ - libraries: CompilerLibraries; - } - export interface CompilerOptimizer { - /** disabled by default */ - enable: boolean; - /** - * Optimize for how many times you intend to run the code. - * Lower values will optimize more for initial deployment cost, higher values will optimize more for high-frequency usage. - */ - runs: number; - } - export interface CompilerMetadata { - /** Use only literal content and not URLs (false by default) */ - useLiteralContent: boolean; - } - /** - * The top level key is the the name of the source file where the library is used. - * If remappings are used, this source file should match the global path after remappings were applied. - * If this key is an empty string, that refers to a global level. - */ - export interface CompilerLibraries { - [contractName: string]: { - [libName: string]: string; - }; - } - export type OutputType = 'abi' | 'ast' | 'devdoc' | 'userdoc' | 'metadata' | 'ir' | 'evm.assembly' | 'evm.legacyAssembly' | 'evm.bytecode.object' | 'evm.bytecode.opcodes' | 'evm.bytecode.sourceMap' | 'evm.bytecode.linkReferences' | 'evm.deployedBytecode' | 'evm.methodIdentifiers' | 'evm.gasEstimates' | 'ewasm.wast' | 'ewasm.wasm'; - /** - * The following can be used to select desired outputs. - * If this field is omitted, then the compiler loads and does type checking, but will not generate any outputs apart from errors. - * The first level key is the file name and the second is the contract name, where empty contract name refers to the file itself, - * while the star refers to all of the contracts. - * Note that using a using evm, evm.bytecode, ewasm, etc. will select every - * target part of that output. Additionally, * can be used as a wildcard to request everything. - */ - export interface CompilerOutputSelection { - [file: string]: { - [contract: string]: OutputType[]; - }; - } - -} -declare module 'packages/api/src/lib/compiler/type/output' { - export interface CompilationFileSources { - [fileName: string]: { - keccak256?: string; - content: string; - urls?: string[]; - }; - } - export interface SourceWithTarget { - sources?: CompilationFileSources; - target?: string | null | undefined; - } - export interface CompilationResult { - /** not present if no errors/warnings were encountered */ - errors?: CompilationError[]; - /** This contains the file-level outputs. In can be limited/filtered by the outputSelection settings */ - sources: { - [contractName: string]: CompilationSource; - }; - /** This contains the contract-level outputs. It can be limited/filtered by the outputSelection settings */ - contracts: { - /** If the language used has no contract names, this field should equal to an empty string. */ - [fileName: string]: { - [contract: string]: CompiledContract; - }; - }; - } - export interface lastCompilationResult { - data: CompilationResult | null; - source: SourceWithTarget | null | undefined; - } - export interface CompilationError { - /** Location within the source file */ - sourceLocation?: { - file: string; - start: number; - end: number; - }; - /** Error type */ - type: CompilationErrorType; - /** Component where the error originated, such as "general", "ewasm", etc. */ - component: 'general' | 'ewasm' | string; - severity: 'error' | 'warning'; - message: string; - /** the message formatted with source location */ - formattedMessage?: string; - } type CompilationErrorType = 'JSONError' | 'IOError' | 'ParserError' | 'DocstringParsingError' | 'SyntaxError' | 'DeclarationError' | 'TypeError' | 'UnimplementedFeatureError' | 'InternalCompilerError' | 'Exception' | 'CompilerError' | 'FatalError' | 'Warning'; - export interface CompilationSource { - /** Identifier of the source (used in source maps) */ - id: number; - /** The AST object */ - ast: AstNode; - /** The legacy AST object */ - legacyAST: AstNodeLegacy; - } - export interface AstNode { - absolutePath?: string; - exportedSymbols?: Object; - id: number; - nodeType: string; - nodes?: Array; - src: string; - literals?: Array; - file?: string; - scope?: number; - sourceUnit?: number; - symbolAliases?: Array; - [x: string]: any; - } - export interface AstNodeLegacy { - id: number; - name: string; - src: string; - children?: Array; - attributes?: AstNodeAtt; - } - export interface AstNodeAtt { - operator?: string; - string?: null; - type?: string; - value?: string; - constant?: boolean; - name?: string; - public?: boolean; - exportedSymbols?: Object; - argumentTypes?: null; - absolutePath?: string; - [x: string]: any; - } - export interface CompiledContract { - /** The Ethereum Contract ABI. If empty, it is represented as an empty array. */ - abi: ABIDescription[]; - metadata: string; - /** User documentation (natural specification) */ - userdoc: UserDocumentation; - /** Developer documentation (natural specification) */ - devdoc: DeveloperDocumentation; - /** Intermediate representation (string) */ - ir: string; - /** EVM-related outputs */ - evm: { - assembly: string; - legacyAssembly: {}; - /** Bytecode and related details. */ - bytecode: BytecodeObject; - deployedBytecode: BytecodeObject; - /** The list of function hashes */ - methodIdentifiers: { - [functionIdentifier: string]: string; - }; - gasEstimates: { - creation: { - codeDepositCost: string; - executionCost: 'infinite' | string; - totalCost: 'infinite' | string; - }; - external: { - [functionIdentifier: string]: string; - }; - internal: { - [functionIdentifier: string]: 'infinite' | string; - }; - }; - }; - /** eWASM related outputs */ - ewasm: { - /** S-expressions format */ - wast: string; - /** Binary format (hex string) */ - wasm: string; - }; - } - export type ABIDescription = FunctionDescription | EventDescription; - export interface FunctionDescription { - /** Type of the method. default is 'function' */ - type?: 'function' | 'constructor' | 'fallback'; - /** The name of the function. Constructor and fallback functions never have a name */ - name?: string; - /** List of parameters of the method. Fallback functions don’t have inputs. */ - inputs?: ABIParameter[]; - /** List of the output parameters for the method, if any */ - outputs?: ABIParameter[]; - /** State mutability of the method */ - stateMutability: 'pure' | 'view' | 'nonpayable' | 'payable'; - /** true if function accepts Ether, false otherwise. Default is false */ - payable?: boolean; - /** true if function is either pure or view, false otherwise. Default is false */ - constant?: boolean; - } - export interface EventDescription { - type: 'event'; - name: string; - inputs: ABIParameter & { - /** true if the field is part of the log’s topics, false if it one of the log’s data segment. */ - indexed: boolean; - }[]; - /** true if the event was declared as anonymous. */ - anonymous: boolean; - } - export interface ABIParameter { - /** The name of the parameter */ - name: string; - /** The canonical type of the parameter */ - type: ABITypeParameter; - /** Used for tuple types */ - components?: ABIParameter[]; - } - export type ABITypeParameter = 'uint' | 'uint[]' | 'int' | 'int[]' | 'address' | 'address[]' | 'bool' | 'bool[]' | 'fixed' | 'fixed[]' | 'ufixed' | 'ufixed[]' | 'bytes' | 'bytes[]' | 'function' | 'function[]' | 'tuple' | 'tuple[]' | string; - export interface UserDocumentation { - methods: UserMethodList; - notice: string; - } - export type UserMethodList = { - [functionIdentifier: string]: UserMethodDoc; - } & { - 'constructor'?: string; - }; - export interface UserMethodDoc { - notice: string; - } - export interface DeveloperDocumentation { - author: string; - title: string; - details: string; - methods: DevMethodList; - } - export interface DevMethodList { - [functionIdentifier: string]: DevMethodDoc; - } - export interface DevMethodDoc { - author: string; - details: string; - return: string; - returns: { - [param: string]: string; - }; - params: { - [param: string]: string; - }; - } - export interface BytecodeObject { - /** The bytecode as a hex string. */ - object: string; - /** Opcodes list */ - opcodes: string; - /** The source mapping as a string. See the source mapping definition. */ - sourceMap: string; - /** If given, this is an unlinked object. */ - linkReferences?: { - [contractName: string]: { - /** Byte offsets into the bytecode. */ - [library: string]: { - start: number; - length: number; - }[]; - }; - }; - } - export {}; - -} -declare module 'packages/api/src/lib/compiler/type/index' { - export * from 'packages/api/src/lib/compiler/type/input'; - export * from 'packages/api/src/lib/compiler/type/output'; - -} -declare module 'packages/api/src/lib/compiler/api' { - import { CompilationResult, CompilationFileSources, lastCompilationResult, CondensedCompilationInput, SourcesInput } from 'packages/api/src/lib/compiler/type'; - import { StatusEvents, Api } from '@remixproject/plugin-utils'; - export interface ICompiler extends Api { - events: { - compilationFinished: (fileName: string, source: CompilationFileSources, languageVersion: string, data: CompilationResult) => void; - } & StatusEvents; - methods: { - getCompilationResult(): lastCompilationResult; - compile(fileName: string): void; - setCompilerConfig(settings: CondensedCompilationInput): void; - compileWithParameters(targets: SourcesInput, settings: CondensedCompilationInput): lastCompilationResult; - }; - } - -} -declare module 'packages/api/src/lib/compiler/profile' { - import { ICompiler } from 'packages/api/src/lib/compiler/api'; - import { LibraryProfile } from '@remixproject/plugin-utils'; - export const compilerProfile: LibraryProfile; - -} -declare module 'packages/api/src/lib/compiler/index' { - export * from 'packages/api/src/lib/compiler/api'; - export * from 'packages/api/src/lib/compiler/type'; - export * from 'packages/api/src/lib/compiler/profile'; - -} -declare module 'packages/api/src/lib/content-import/type' { - export interface ContentImport { - content: any; - cleanUrl: string; - type: 'github' | 'http' | 'https' | 'swarm' | 'ipfs'; - url: string; - } - -} -declare module 'packages/api/src/lib/content-import/api' { - import { ContentImport } from 'packages/api/src/lib/content-import/type'; - import { StatusEvents } from '@remixproject/plugin-utils'; - export interface IContentImport { - events: {} & StatusEvents; - methods: { - resolve(path: string): ContentImport; - resolveAndSave(url: string, targetPath: string): string; - }; - } - -} -declare module 'packages/api/src/lib/content-import/profile' { - import { IContentImport } from 'packages/api/src/lib/content-import/api'; - import { LibraryProfile } from '@remixproject/plugin-utils'; - export const contentImportProfile: LibraryProfile; - -} -declare module 'packages/api/src/lib/content-import/index' { - export * from 'packages/api/src/lib/content-import/api'; - export * from 'packages/api/src/lib/content-import/type'; - export * from 'packages/api/src/lib/content-import/profile'; - -} -declare module 'packages/api/src/lib/editor/type' { - export interface HighlightPosition { - start: { - line: number; - column: number; - }; - end: { - line: number; - column: number; - }; - } - export interface HighLightOptions { - focus: boolean; - } - export interface Annotation { - row: number; - column: number; - text: string; - type: "error" | "warning" | "info"; - } - -} -declare module 'packages/api/src/lib/editor/api' { - import { HighlightPosition, Annotation } from 'packages/api/src/lib/editor/type'; - import { StatusEvents } from '@remixproject/plugin-utils'; - import { HighLightOptions } from '@remixproject/plugin-api'; - export interface IEditor { - events: StatusEvents; - methods: { - highlight(position: HighlightPosition, filePath: string, hexColor: string, opt?: HighLightOptions): void; - discardHighlight(): void; - discardHighlightAt(line: number, filePath: string): void; - addAnnotation(annotation: Annotation): void; - clearAnnotations(): void; - gotoLine(line: number, col: number): void; - }; - } - -} -declare module 'packages/api/src/lib/editor/profile' { - import { IEditor } from 'packages/api/src/lib/editor/api'; - import { LibraryProfile } from '@remixproject/plugin-utils'; - export const editorProfile: LibraryProfile; - -} -declare module 'packages/api/src/lib/editor/index' { - export * from 'packages/api/src/lib/editor/type'; - export * from 'packages/api/src/lib/editor/api'; - export * from 'packages/api/src/lib/editor/profile'; - -} -declare module 'packages/api/src/lib/file-system/file-manager/type' { - export interface Folder { - [path: string]: { - isDirectory: boolean; - }; - } - -} -declare module 'packages/api/src/lib/file-system/file-manager/api' { - import { Folder } from 'packages/api/src/lib/file-system/file-manager/type'; - import { StatusEvents } from '@remixproject/plugin-utils'; - export interface IFileSystem { - events: { - currentFileChanged: (file: string) => void; - fileSaved: (file: string) => void; - fileAdded: (file: string) => void; - folderAdded: (file: string) => void; - fileRemoved: (file: string) => void; - fileClosed: (file: string) => void; - noFileSelected: () => void; - fileRenamed: (oldName: string, newName: string, isFolder: boolean) => void; - } & StatusEvents; - methods: { - /** Open the content of the file in the context (eg: Editor) */ - open(path: string): void; - /** Set the content of a specific file */ - writeFile(path: string, data: string): void; - /** Return the content of a specific file */ - readFile(path: string): string; - /** Change the path of a file */ - rename(oldPath: string, newPath: string): void; - /** Upsert a file with the content of the source file */ - copyFile(src: string, dest: string): void; - /** Create a directory */ - mkdir(path: string): void; - /** Get the list of files in the directory */ - readdir(path: string): string[]; - /** Removes a file or directory recursively */ - remove(path: string): void; - /** Get the name of the file currently focused if any */ - getCurrentFile(): string; - /** close all files */ - closeAllFiles(): void; - /** close a file */ - closeFile(): void; - /** @deprecated Use readdir */ - getFolder(path: string): Folder; - /** @deprecated Use readFile */ - getFile(path: string): string; - /** @deprecated Use writeFile */ - setFile(path: string, content: string): void; - /** @deprecated Use open */ - switchFile(path: string): void; - }; - } - -} -declare module 'packages/api/src/lib/file-system/file-manager/profile' { - import { IFileSystem } from 'packages/api/src/lib/file-system/file-manager/api'; - import { LocationProfile, Profile } from '@remixproject/plugin-utils'; - export const filSystemProfile: Profile & LocationProfile; - -} -declare module 'packages/api/src/lib/file-system/file-manager/index' { - export * from 'packages/api/src/lib/file-system/file-manager/api'; - export * from 'packages/api/src/lib/file-system/file-manager/type'; - export * from 'packages/api/src/lib/file-system/file-manager/profile'; - -} -declare module 'packages/api/src/lib/file-system/file-panel/type' { - export interface customAction { - id: string; - name: string; - type: customActionType[]; - path: string[]; - extension: string[]; - pattern: string[]; - sticky?: boolean; - label?: string; - } - export type customActionType = 'file' | 'folder'; - -} -declare module 'packages/api/src/lib/file-system/file-panel/api' { - import { StatusEvents } from '@remixproject/plugin-utils'; - import { customAction } from 'packages/api/src/lib/file-system/file-panel/type'; - export interface IFilePanel { - events: { - setWorkspace: (workspace: any) => void; - workspaceRenamed: (workspace: any) => void; - workspaceDeleted: (workspace: any) => void; - workspaceCreated: (workspace: any) => void; - customAction: (cmd: customAction) => void; - } & StatusEvents; - methods: { - getCurrentWorkspace(): { - name: string; - isLocalhost: boolean; - absolutePath: string; - }; - getWorkspaces(): string[]; - deleteWorkspace(name: string): void; - createWorkspace(name: string, isEmpty: boolean): void; - renameWorkspace(oldName: string, newName: string): void; - registerContextMenuItem(cmd: customAction): void; - }; - } - -} -declare module 'packages/api/src/lib/file-system/file-panel/profile' { - import { IFilePanel as IFilePanel } from 'packages/api/src/lib/file-system/file-panel/api'; - import { LocationProfile, Profile } from '@remixproject/plugin-utils'; - export const filePanelProfile: Profile & LocationProfile; - -} -declare module 'packages/api/src/lib/file-system/file-panel/index' { - export * from 'packages/api/src/lib/file-system/file-panel/api'; - export * from 'packages/api/src/lib/file-system/file-panel/profile'; - export * from 'packages/api/src/lib/file-system/file-panel/type'; - -} -declare module 'packages/api/src/lib/dgit/api' { - import { StatusEvents } from '@remixproject/plugin-utils'; - export interface IDgitSystem { - events: StatusEvents; - methods: { - init(): void; - add(cmd: any): string; - commit(cmd: any): string; - status(cmd: any): any[]; - rm(cmd: any): string; - log(cmd: any): any[]; - lsfiles(cmd: any): any[]; - readblob(cmd: any): { - oid: string; - blob: Uint8Array; - }; - resolveref(cmd: any): string; - branch(cmd: any): void; - checkout(cmd: any): void; - branches(): string[]; - currentbranch(): string; - push(cmd: any): string; - pull(cmd: any): void; - setIpfsConfig(config: any): boolean; - zip(): void; - setItem(name: string, content: string): void; - getItem(name: string): string; - import(cmd: any): void; - export(cmd: any): void; - remotes(): any[]; - addremote(cmd: any): void; - delremote(cmd: any): void; - clone(cmd: any): void; - localStorageUsed(): any; - }; - } - -} -declare module 'packages/api/src/lib/dgit/profile' { - import { IDgitSystem } from 'packages/api/src/lib/dgit/api'; - import { LibraryProfile } from '@remixproject/plugin-utils'; - export const dGitProfile: LibraryProfile; - -} -declare module 'packages/api/src/lib/dgit/index' { - export * from 'packages/api/src/lib/dgit/api'; - export * from 'packages/api/src/lib/dgit/profile'; - -} -declare module 'packages/api/src/lib/git/api' { - import { StatusEvents } from '@remixproject/plugin-utils'; - export interface IGitSystem { - events: {} & StatusEvents; - methods: { - clone(url: string): string; - checkout(cmd: string): string; - init(): string; - add(cmd: string): string; - commit(cmd: string): string; - fetch(cmd: string): string; - pull(cmd: string): string; - push(cmd: string): string; - reset(cmd: string): string; - status(cmd: string): string; - remote(cmd: string): string; - log(): string; - }; - } - -} -declare module 'packages/api/src/lib/git/profile' { - import { IGitSystem } from 'packages/api/src/lib/git/api'; - import { LibraryProfile } from '@remixproject/plugin-utils'; - export const gitProfile: LibraryProfile; - -} -declare module 'packages/api/src/lib/git/index' { - export * from 'packages/api/src/lib/git/api'; - export * from 'packages/api/src/lib/git/profile'; - -} -declare module 'packages/api/src/lib/network/type' { - /** @deprecated: current version in Remix IDE. To improve to match standard JSON RPC methods */ - export interface CustomNetwork { - id?: string; - name: string; - url: string; - } - /** @deprecated: current version in Remix IDE. To improve to match standard JSON RPC methods */ - export type NetworkProvider = 'vm' | 'injected' | 'web3'; - export type Network = { - id: '1'; - name: 'Main'; - } | { - id: '2'; - name: 'Morden (deprecated)'; - } | { - id: '3'; - name: 'Ropsten'; - } | { - id: '4'; - name: 'Rinkeby'; - } | { - id: '5'; - name: 'Goerli'; - } | { - id: '42'; - name: 'Kovan'; - }; - -} -declare module 'packages/api/src/lib/network/api' { - import { StatusEvents } from '@remixproject/plugin-utils'; - import { NetworkProvider, Network, CustomNetwork } from 'packages/api/src/lib/network/type'; - /** @deprecated: current version in Remix IDE. To improve to match standard JSON RPC methods */ - export interface INetwork { - events: { - providerChanged: (provider: NetworkProvider) => void; - } & StatusEvents; - methods: { - getNetworkProvider(): NetworkProvider; - detectNetwork(): Network | Partial; - getEndpoint(): string; - addNetwork(network: CustomNetwork): void; - removeNetwork(name: string): void; - }; - } - -} -declare module 'packages/api/src/lib/network/profile' { - import { INetwork } from 'packages/api/src/lib/network/api'; - import { LibraryProfile } from '@remixproject/plugin-utils'; - export const networkProfile: LibraryProfile; - -} -declare module 'packages/api/src/lib/network/index' { - export * from 'packages/api/src/lib/network/api'; - export * from 'packages/api/src/lib/network/type'; - export * from 'packages/api/src/lib/network/profile'; - -} -declare module 'packages/api/src/lib/plugin-manager/api' { - import { StatusEvents, Profile } from '@remixproject/plugin-utils'; - export interface IPluginManager { - events: { - profileUpdated(profile: Profile): void; - profileAdded(profile: Profile): void; - pluginDeactivated(profile: Profile): void; - pluginActivated(profile: Profile): void; - } & StatusEvents; - methods: { - getProfile(name: string): Promise; - updateProfile(profile: Partial): any; - activatePlugin(name: string): any; - deactivatePlugin(name: string): any; - isActive(name: string): boolean; - canCall(from: string, to: string, method: string, message?: string): any; - }; - } - -} -declare module 'packages/api/src/lib/plugin-manager/profile' { - import { IPluginManager } from 'packages/api/src/lib/plugin-manager/api'; - import { LibraryProfile } from '@remixproject/plugin-utils'; - export const pluginManagerProfile: LibraryProfile & { - name: 'manager'; - }; - -} -declare module 'packages/api/src/lib/plugin-manager/index' { - export * from 'packages/api/src/lib/plugin-manager/api'; - export * from 'packages/api/src/lib/plugin-manager/profile'; - -} -declare module 'packages/api/src/lib/settings/api' { - import { StatusEvents } from '@remixproject/plugin-utils'; - export interface ISettings { - events: {} & StatusEvents; - methods: { - getGithubAccessToken(): string; - }; - } - -} -declare module 'packages/api/src/lib/settings/profile' { - import { ISettings } from 'packages/api/src/lib/settings/api'; - import { LibraryProfile } from '@remixproject/plugin-utils'; - export const settingsProfile: LibraryProfile; - -} -declare module 'packages/api/src/lib/settings/index' { - export * from 'packages/api/src/lib/settings/api'; - export * from 'packages/api/src/lib/settings/profile'; - -} -declare module 'packages/api/src/lib/theme/types' { - export interface Theme { - url?: string; - /** @deprecated Use brightness instead */ - quality?: 'dark' | 'light'; - brightness: 'dark' | 'light'; - colors: { - surface: string; - background: string; - foreground: string; - primary: string; - primaryContrast: string; - secondary?: string; - secondaryContrast?: string; - success?: string; - successContrast?: string; - warn: string; - warnContrast: string; - error: string; - errorContrast: string; - disabled: string; - }; - breakpoints: { - xs: number; - sm: number; - md: number; - lg: number; - xl: number; - }; - fontFamily: string; - /** A unit to multiply for margin & padding */ - space: number; - } - export interface ThemeUrls { - light: string; - dark: string; - } - -} -declare module 'packages/api/src/lib/theme/api' { - import { StatusEvents } from '@remixproject/plugin-utils'; - import { Theme } from 'packages/api/src/lib/theme/types'; - export interface ITheme { - events: { - themeChanged: (theme: Theme) => void; - } & StatusEvents; - methods: { - currentTheme(): Theme; - }; - } - -} -declare module 'packages/api/src/lib/theme/profile' { - import { ITheme } from 'packages/api/src/lib/theme/api'; - import { LibraryProfile } from '@remixproject/plugin-utils'; - export const themeProfile: LibraryProfile; - -} -declare module 'packages/api/src/lib/theme/index' { - export * from 'packages/api/src/lib/theme/api'; - export * from 'packages/api/src/lib/theme/profile'; - export * from 'packages/api/src/lib/theme/types'; - -} -declare module 'packages/api/src/lib/udapp/type' { - export type RemixTxEvent = { - contractAddress: string; - data: string; - envMode: 'vm'; - executionCost: string; - from: string; - gas: string; - hash: string; - input: string; - logs: any[]; - returnValue: Uint8Array; - status: '0x01' | '0x00'; - transactionCost: string; - transactionHash: string; - value: string; - } | { - blockHash: string; - blockNumber: number; - envMod: 'injected' | 'web3'; - from: string; - gas: number; - gasPrice: { - c: number[]; - e: number; - s: number; - }; - hash: string; - input: string; - none: number; - r: string; - s: string; - v: string; - status: '0x01' | '0x00'; - to: string; - transactionCost: string; - transactionIndex: number; - value: { - c: number[]; - e: number; - s: number; - }; - }; - export interface RemixTx { - data: string; - from: string; - to?: string; - timestamp?: string; - gasLimit: string; - value: string; - useCall: boolean; - } - export interface RemixTxReceipt { - transactionHash: string; - status: 0 | 1; - gasUsed: string; - error: string; - return: string; - createdAddress?: string; - } - export interface VMAccount { - privateKey: string; - balance: string; - } - export interface UdappSettings { - selectedAccount: string; - selectedEnvMode: 'vm' | 'injected' | 'web3'; - networkEnvironment: string; - } - -} -declare module 'packages/api/src/lib/udapp/api' { - import { RemixTx, RemixTxReceipt, RemixTxEvent, VMAccount, UdappSettings } from 'packages/api/src/lib/udapp/type'; - import { StatusEvents } from '@remixproject/plugin-utils'; - export interface IUdapp { - events: { - newTransaction: (transaction: RemixTxEvent) => void; - } & StatusEvents; - methods: { - sendTransaction(tx: RemixTx): RemixTxReceipt; - getAccounts(): string[]; - createVMAccount(vmAccount: VMAccount): string; - getSettings(): UdappSettings; - setEnvironmentMode(env: 'vm' | 'injected' | 'web3'): void; - }; - } - -} -declare module 'packages/api/src/lib/udapp/profile' { - import { IUdapp } from 'packages/api/src/lib/udapp/api'; - import { LibraryProfile } from '@remixproject/plugin-utils'; - export const udappProfile: LibraryProfile; - -} -declare module 'packages/api/src/lib/udapp/index' { - export * from 'packages/api/src/lib/udapp/api'; - export * from 'packages/api/src/lib/udapp/type'; - export * from 'packages/api/src/lib/udapp/profile'; - -} -declare module 'packages/api/src/lib/unit-testing/type' { - export interface UnitTestResult { - totalFailing: number; - totalPassing: number; - totalTime: number; - errors: UnitTestError[]; - } - export interface UnitTestError { - context: string; - value: string; - message: string; - } - -} -declare module 'packages/api/src/lib/unit-testing/api' { - import { UnitTestResult } from 'packages/api/src/lib/unit-testing/type'; - import { StatusEvents } from '@remixproject/plugin-utils'; - export interface IUnitTesting { - events: {} & StatusEvents; - methods: { - testFromPath(path: string): UnitTestResult; - testFromSource(sourceCode: string): UnitTestResult; - }; - } - -} -declare module 'packages/api/src/lib/unit-testing/profile' { - import { IUnitTesting } from 'packages/api/src/lib/unit-testing/api'; - import { LibraryProfile } from '@remixproject/plugin-utils'; - export const unitTestProfile: LibraryProfile; - -} -declare module 'packages/api/src/lib/unit-testing/index' { - export * from 'packages/api/src/lib/unit-testing/api'; - export * from 'packages/api/src/lib/unit-testing/type'; - export * from 'packages/api/src/lib/unit-testing/profile'; - -} -declare module 'packages/api/src/lib/window/api' { - import { StatusEvents } from '@remixproject/plugin-utils'; - export interface IWindow { - events: {} & StatusEvents; - methods: { - /** Display an input window */ - prompt(message?: string): string; - /** Ask confirmation for an action */ - confirm(message: string): boolean; - /** Display a message with actions button. Returned the button clicked if any */ - alert(message: string, actions?: string[]): string | void; - }; - } - -} -declare module 'packages/api/src/lib/window/profile' { - import { IWindow } from 'packages/api/src/lib/window/api'; - import { LibraryProfile } from '@remixproject/plugin-utils'; - export const windowProfile: LibraryProfile; - -} -declare module 'packages/api/src/lib/window/index' { - export * from 'packages/api/src/lib/window/api'; - export * from 'packages/api/src/lib/window/profile'; - -} -declare module 'packages/api/src/lib/vscextapi/api' { - import { StatusEvents } from '@remixproject/plugin-utils'; - export interface IVScodeExtAPI { - events: {} & StatusEvents; - methods: { - executeCommand(extension: string, command: string, payload?: any[]): any; - }; - } - -} -declare module 'packages/api/src/lib/vscextapi/profile' { - import { IVScodeExtAPI } from 'packages/api/src/lib/vscextapi/api'; - import { LibraryProfile } from '@remixproject/plugin-utils'; - export const vscodeExtProfile: LibraryProfile; - -} -declare module 'packages/api/src/lib/vscextapi/index' { - export * from 'packages/api/src/lib/vscextapi/api'; - export * from 'packages/api/src/lib/vscextapi/profile'; - -} -declare module 'packages/api/src/lib/terminal/type' { - export type TerminalMessage = { - value: any; - type: 'html' | 'log' | 'info' | 'warn' | 'error'; - }; - -} -declare module 'packages/api/src/lib/terminal/api' { - import { StatusEvents } from '@remixproject/plugin-utils'; - import { TerminalMessage } from 'packages/api/src/lib/terminal/type'; - export interface ITerminal { - events: {} & StatusEvents; - methods: { - log(message: TerminalMessage): void; - }; - } - -} -declare module 'packages/api/src/lib/terminal/profile' { - import { ITerminal } from 'packages/api/src/lib/terminal/api'; - import { LibraryProfile } from '@remixproject/plugin-utils'; - export const terminalProfile: LibraryProfile; - -} -declare module 'packages/api/src/lib/terminal/index' { - export * from 'packages/api/src/lib/terminal/api'; - export * from 'packages/api/src/lib/terminal/type'; - export * from 'packages/api/src/lib/terminal/profile'; - -} -declare module 'packages/api/src/lib/remix-profile' { - import { ProfileMap } from '@remixproject/plugin-utils'; - import { ICompiler } from 'packages/api/src/lib/compiler'; - import { IFileSystem } from 'packages/api/src/lib/file-system/file-manager'; - import { IEditor } from 'packages/api/src/lib/editor'; - import { INetwork } from 'packages/api/src/lib/network'; - import { IUdapp } from 'packages/api/src/lib/udapp'; - import { ITheme } from 'packages/api/src/lib/theme'; - import { IUnitTesting } from 'packages/api/src/lib/unit-testing'; - import { IContentImport } from 'packages/api/src/lib/content-import'; - import { ISettings } from 'packages/api/src/lib/settings'; - import { IVScodeExtAPI } from 'packages/api/src/lib/vscextapi'; - import { IPluginManager } from 'packages/api/src/lib/plugin-manager'; - import { IFilePanel } from 'packages/api/src/lib/file-system/file-panel'; - import { IDgitSystem } from 'packages/api/src/lib/dgit'; - import { ITerminal } from 'packages/api/src/lib/terminal'; - export interface IRemixApi { - manager: IPluginManager; - solidity: ICompiler; - fileManager: IFileSystem; - filePanel: IFilePanel; - dGitProvider: IDgitSystem; - solidityUnitTesting: IUnitTesting; - editor: IEditor; - network: INetwork; - udapp: IUdapp; - contentImport: IContentImport; - settings: ISettings; - theme: ITheme; - vscodeExtAPI: IVScodeExtAPI; - terminal: ITerminal; - } - export type RemixApi = Readonly; - /** @deprecated Use remixProfiles instead. Will be remove in next version */ - export const remixApi: ProfileMap; - /** Profiles of all the remix's Native Plugins */ - export const remixProfiles: ProfileMap; - -} -declare module 'packages/api/src/lib/standard-profile' { - import { ProfileMap } from '@remixproject/plugin-utils'; - import { ICompiler } from 'packages/api/src/lib/compiler'; - import { IFileSystem } from 'packages/api/src/lib/file-system/file-manager'; - import { IEditor } from 'packages/api/src/lib/editor'; - import { INetwork } from 'packages/api/src/lib/network'; - import { IUdapp } from 'packages/api/src/lib/udapp'; - import { IPluginManager } from 'packages/api/src/lib/plugin-manager'; - export interface IStandardApi { - manager: IPluginManager; - solidity: ICompiler; - fileManager: IFileSystem; - editor: IEditor; - network: INetwork; - udapp: IUdapp; - } - export type StandardApi = Readonly; - /** Profiles of all the standard's Native Plugins */ - export const standardProfiles: ProfileMap; - -} -declare module 'packages/api/src/index' { - export * from 'packages/api/src/lib/compiler'; - export * from 'packages/api/src/lib/content-import'; - export * from 'packages/api/src/lib/editor'; - export * from 'packages/api/src/lib/file-system/file-manager'; - export * from 'packages/api/src/lib/file-system/file-panel'; - export * from 'packages/api/src/lib/dgit'; - export * from 'packages/api/src/lib/git'; - export * from 'packages/api/src/lib/network'; - export * from 'packages/api/src/lib/plugin-manager'; - export * from 'packages/api/src/lib/settings'; - export * from 'packages/api/src/lib/theme'; - export * from 'packages/api/src/lib/udapp'; - export * from 'packages/api/src/lib/unit-testing'; - export * from 'packages/api/src/lib/window'; - export * from 'packages/api/src/lib/remix-profile'; - export * from 'packages/api/src/lib/standard-profile'; - -} -declare module 'packages/engine/core/src/lib/manager' { - import type { Profile } from '@remixproject/plugin-utils'; - import { Plugin } from 'packages/engine/core/src/lib/abstract'; - export type BasePluginManager = { - getProfile(name: string): Promise; - updateProfile(profile: Partial): Promise; - activatePlugin(name: string): Promise; - deactivatePlugin(name: string): Promise; - isActive(name: string): Promise; - canCall(from: Profile, to: Profile, method: string): Promise; - toggleActive(name: string): any; - addProfile(profiles: Partial | Partial[]): any; - canActivatePlugin(from: Profile, to: Profile, method?: string): Promise; - canDeactivatePlugin(from: Profile, to: Profile): Promise; - } & Plugin; - interface ManagerProfile extends Profile { - name: 'manager'; - } - export class PluginManager extends Plugin implements BasePluginManager { - protected profiles: Record; - protected actives: string[]; - protected onPluginActivated?(profile: Profile): any; - protected onPluginDeactivated?(profile: Profile): any; - protected onProfileAdded?(profile: Profile): any; - constructor(profile?: ManagerProfile); - /** Return the name of the caller. If no request provided, this mean that the method has been called from the IDE so we use "manager" */ - get requestFrom(): string; - /** Run engine activation. Implemented by Engine */ - private engineActivatePlugin; - /** Run engine deactivation. Implemented by Engine */ - private engineDeactivatePlugin; - /** - * Get the profile if it's registered. - * @param name The name of the plugin - * @note This method can be overrided - */ - getProfile(name: string): Promise>; - /** Get all the profiles of the manager */ - getProfiles(): Profile[]; - /** Get all active profiles of the manager */ - getActiveProfiles(): Profile[]; - /** - * Update the profile of the plugin - * @param profile The Updated version of the plugin - * @note Only the caller plugin should be able to update its profile - */ - updateProfile(to: Partial): Promise; - /** - * Add a profile to the list of profile - * @param profile The profile to add - * @note This method should only be used by the engine - */ - addProfile(profiles: Profile | Profile[]): void | void[]; - /** - * Verify if a plugin is currently active - * @param name Name of the plugin - */ - isActive(name: string): Promise; - /** - * Check if caller can activate plugin and activate it if authorized - * @param name The name of the plugin to activate - */ - activatePlugin(names: string | string[]): Promise; - /** - * Check if caller can deactivate plugin and deactivate it if authorized - * @param name The name of the plugin to activate - */ - deactivatePlugin(names: string | string[]): Promise; - /** - * Activate or deactivate by bypassing permission - * @param name The name of the plugin to activate - * @note This method should ONLY be used by the IDE - */ - toggleActive(names: string | string[]): Promise; - /** - * Check if a plugin can activate another - * @param from Profile of the caller plugin - * @param to Profile of the target plugin - * @note This method should be overrided - */ - canActivatePlugin(from: Profile, to: Profile): Promise; - /** - * Check if a plugin can deactivate another - * @param from Profile of the caller plugin - * @param to Profile of the target plugin - * @note This method should be overrided - */ - canDeactivatePlugin(from: Profile, to: Profile): Promise; - /** - * Check if a plugin can call a method of another - * @param from Profile of the caller plugin - * @param to Profile of the target plugin - * @param method Method targetted by the caller - * @param message Method provided by the targetted method plugin - */ - canCall(from: Profile, to: Profile, method: string, message?: string): Promise; - /** - * Check if a plugin can update profile of another one - * @param from Profile of the caller plugin - * @param to Updates on the profile of the target plugin - * @note This method can be overrided - */ - canUpdateProfile(from: Profile, to: Partial): Promise; - } - export {}; - -} -declare module 'packages/engine/core/src/lib/engine' { - import type { Profile, PluginOptions } from '@remixproject/plugin-utils'; - import { Plugin } from 'packages/engine/core/src/lib/abstract'; - export class Engine { - private plugins; - private events; - private listeners; - private eventMemory; - private manager; - onRegistration?(plugin: Plugin): void; - /** Update the options of the plugin when being registered */ - setPluginOption?(profile: Profile): PluginOptions; - /** - * Broadcast an event to the plugin listening - * @param emitter Plugin name that emits the event - * @param event The name of the event - * @param payload The content of the event - */ - private broadcast; - /** - * Start listening on an event from another plugin - * @param listener The name of the plugin that listen on the event - * @param emitter The name of the plugin that emit the event - * @param event The name of the event - * @param cb Callback function to trigger when the event is trigger - */ - private addListener; - /** - * Remove an event from the list of a listener's events - * @param listener The name of the plugin that was listening on the event - * @param emitter The name of the plugin that emitted the event - * @param event The name of the event - */ - private removeListener; - /** - * Create a listener that listen only once on an event - * @param listener The name of the plugin that listen on the event - * @param emitter The name of the plugin that emitted the event - * @param event The name of the event - * @param cb Callback function to trigger when event is triggered - */ - private listenOnce; - /** - * Call a method of a plugin from another - * @param caller The name of the plugin that calls the method - * @param path The path of the plugin that manages the method - * @param method The name of the method - * @param payload The argument to pass to the method - */ - private callMethod; - /** - * Cancels calls from a plugin to another - * @param caller The name of the plugin that calls the method - * @param path The path of the plugin that manages the method - * @param method The name of the method to be cancelled, if is empty cancels all calls from plugin - */ - private cancelMethod; - /** - * Create an object to easily access any registered plugin - * @param name Name of the caller plugin - * @note This method creates a snapshot at the time of activation - */ - private createApp; - /** - * Activate a plugin by making its method and event available - * @param name The name of the plugin - * @note This method is trigger by the plugin manager when a plugin has been activated - */ - private activatePlugin; - /** - * Deactivate a plugin by removing all its event listeners and making it inaccessible - * @param name The name of the plugin - * @note This method is trigger by the plugin manager when a plugin has been deactivated - */ - private deactivatePlugin; - /** - * Update error message when trying to call a method when not activated - * @param plugin The deactivated plugin to update the methods from - */ - private updateErrorHandler; - /** - * Register a plugin to the engine and update the manager - * @param plugin The plugin - */ - register(plugins: Plugin | Plugin[]): string | string[]; - /** Register the manager */ - private registerManager; - /** Remove plugin(s) from engine */ - remove(names: string | string[]): Promise | Promise; - /** - * Check is a name is already registered - * @param name Name of the plugin - */ - isRegistered(name: string): boolean; - } - -} -declare module 'packages/engine/core/src/lib/library' { - /// - import type { EventEmitter } from 'events'; - import type { Api, Profile, LibraryProfile, LocationProfile } from '@remixproject/plugin-utils'; - import { Plugin } from 'packages/engine/core/src/lib/abstract'; - export type LibraryApi = { - [method in P['methods'][number]]: T['methods'][method]; - } & { - events?: EventEmitter; - } & { - render?(): Element; - }; type LibraryViewProfile = LocationProfile & LibraryProfile; - export function isViewLibrary(profile: any): profile is LibraryViewProfile; - export class LibraryPlugin extends Plugin { - protected library: LibraryApi; - profile: P; - private isView; - constructor(library: LibraryApi, profile: P); - activate(): Promise; - deactivate(): void; - /** Call a method from this plugin */ - protected callPluginMethod(key: string, payload: any[]): any; - } - export {}; - -} -declare module 'packages/engine/core/src/index' { - export * from 'packages/engine/core/src/lib/abstract'; - export * from 'packages/engine/core/src/lib/connector'; - export * from 'packages/engine/core/src/lib/engine'; - export * from 'packages/engine/core/src/lib/library'; - export * from 'packages/engine/core/src/lib/manager'; - -} -declare module 'dist/packages/engine/node/lib/child-process' { - /// - import type { Message, Profile, ExternalProfile } from '@remixproject/plugin-utils'; - import { PluginConnector } from '@remixproject/engine'; - import { ChildProcess } from 'child_process'; - export class ChildProcessPlugin extends PluginConnector { - private readonly listener; - process: ChildProcess; - constructor(profile: Profile & ExternalProfile); - protected send(message: Partial): void; - protected connect(url: string): void; - protected disconnect(): void; - } - -} -declare module 'dist/packages/engine/node/index' { - export * from 'dist/packages/engine/node/lib/child-process'; - -} -declare module 'dist/packages/engine/theia/lib/engine-theia' { - export function engineTheia(): string; - -} -declare module 'dist/packages/engine/theia/index' { - export * from 'dist/packages/engine/theia/lib/engine-theia'; - -} -declare module 'dist/packages/engine/vscode/lib/command' { - import { Plugin, PluginOptions } from '@remixproject/engine'; - import { Profile } from '@remixproject/plugin-utils'; - import { Disposable } from 'vscode'; - export const transformCmd: (name: string, method: string) => string; - export interface CommandOptions extends PluginOptions { - transformCmd: (name: string, method: string) => string; - } - /** - * Connect methods of the plugins with a command depending on the transformCmd function pass as option - */ - export class CommandPlugin extends Plugin { - subscriptions: Disposable[]; - options: CommandOptions; - constructor(profile: Profile); - setOptions(options: Partial): void; - activate(): void; - deactivate(): void; - } - -} -declare module 'dist/packages/engine/vscode/lib/dynamic-list' { - import { Plugin, PluginOptions } from '@remixproject/engine'; - import { TreeDataProvider, EventEmitter, TreeView, TreeItem } from 'vscode'; type ID = string | number; - export class Item extends TreeItem { - private item; - constructor(label: string, pluginName: string, item: I); - } - export class List implements TreeDataProvider { - private name; - private list; - private options; - render: EventEmitter; - onDidChangeTreeData: import("vscode").Event; - constructor(name: string, initial?: I[]); - setOptions(options: Partial): void; - reset(list: I[]): void; - getParent(): any; - getTreeItem(element: I): Item; - getChildren(): I[]; - } - export interface ListOptions { - idKey: string; - labelKey: string; - } - export type ListPluginOptions = PluginOptions & ListOptions; - export class DynamicListPlugin = List> extends Plugin { - private listeners; - protected options: ListPluginOptions; - protected treeView: TreeView; - protected entities: Record; - protected selected: ID; - list: T; - constructor(name: string, options?: Partial); - setOptions(options: Partial): void; - activate(): void; - deactivate(): void; - getIds(): string[]; - getItem(id: ID): I; - getAll(): I[]; - /** Select on element of the list */ - select(idOrItem: ID | I): void; - /** Reset the entire list */ - reset(items: I[]): void; - /** Add a new item to the list */ - add(item: I): void; - /** Remove one item from the list */ - remove(id: ID): void; - /** Update one item in the list */ - update(id: ID, item: Partial): void; - } - export {}; - -} -declare module 'dist/packages/engine/vscode/lib/extension' { - import { PluginConnector } from '@remixproject/engine'; - import { Profile, ExternalProfile, Message } from '@remixproject/plugin-utils'; - export class ExtensionPlugin extends PluginConnector { - private extension; - private connector; - constructor(profile: Profile & ExternalProfile); - protected send(message: Partial): void; - protected connect(url: string): Promise; - protected disconnect(): void; - } - -} -declare module 'dist/packages/engine/vscode/lib/theme' { - import { Plugin, PluginOptions } from '@remixproject/engine'; - import { API } from '@remixproject/plugin-utils'; - import { ITheme, Theme, ThemeUrls } from '@remixproject/plugin-api'; - import { Disposable, ColorTheme } from 'vscode'; - export interface ThemeOptions extends PluginOptions { - urls?: Partial; - } - export function getVscodeTheme(color: ColorTheme, urls?: Partial): Theme; - export class ThemePlugin extends Plugin implements API { - protected getTheme: typeof getVscodeTheme; - protected options: ThemeOptions; - listener: Disposable; - constructor(options?: Partial); - setOptions(options: Partial): void; - onActivation(): void; - onDeactivation(): void; - currentTheme(): Theme; - } - -} -declare module 'dist/packages/engine/vscode/lib/webview' { - import { PluginConnector, PluginConnectorOptions } from '@remixproject/engine'; - import { Message, Profile, ExternalProfile } from '@remixproject/plugin-utils'; - import { ExtensionContext, ViewColumn, WebviewPanel } from 'vscode'; - interface WebviewOptions extends PluginConnectorOptions { - /** Extension Path */ - context: ExtensionContext; - relativeTo?: 'workspace' | 'extension'; - column?: ViewColumn; - devMode?: boolean; - } - export class WebviewPlugin extends PluginConnector { - private listeners; - panel?: WebviewPanel; - options: WebviewOptions; - constructor(profile: Profile & ExternalProfile, options: WebviewOptions); - setOptions(options: Partial): void; - protected send(message: Partial): void; - protected connect(url: string): Promise; - getMessage(message: Message): Promise; - protected disconnect(): void; - } - /** Create a webview */ - export function createWebview(profile: Profile, url: string, options: WebviewOptions): Promise; - export {}; - -} -declare module 'dist/packages/engine/vscode/lib/window' { - import { Plugin, PluginOptions } from '@remixproject/engine'; - import { Profile } from '@remixproject/plugin-utils'; - import { QuickPickOptions, InputBoxOptions } from 'vscode'; - export const windowProfile: Profile; - interface IWindowPlugin { - /** Display an input window */ - prompt(): Thenable; - /** Display a select window */ - select(options: string[]): Thenable; - /** Display a select window with local file system: can only select a file */ - selectFile(): Thenable; - /** Display a select window with local file system: can only select a folder */ - selectFolder(): Thenable; - /** Display a message with actions button. Returned the button clicked if any */ - alert(message: string, actions?: string[]): Thenable; - /** Display a warning message with actions button. Returned the button clicked if any */ - warning(message: string, actions?: string[]): Thenable; - /** Display an error message with actions button. Returned the button clicked if any */ - error(message: string, actions?: string[]): Thenable; - } - export class WindowPlugin extends Plugin implements IWindowPlugin { - constructor(options?: PluginOptions); - prompt(options?: InputBoxOptions): Thenable; - select(items: string[], options?: QuickPickOptions): Thenable; - selectFile(): Thenable; - selectFolder(): Thenable; - alert(message: string, actions?: string[]): Thenable; - error(message: string, actions?: string[]): Thenable; - warning(message: string, actions?: string[]): Thenable; - } - export {}; - -} -declare module 'dist/packages/engine/vscode/lib/filemanager' { - import { IFileSystem } from '@remixproject/plugin-api'; - import { MethodApi } from '@remixproject/plugin-utils'; - import { CommandPlugin } from 'dist/packages/engine/vscode/lib/command'; - export class FileManagerPlugin extends CommandPlugin implements MethodApi { - constructor(); - /** Open the content of the file in the context (eg: Editor) */ - open(path: string): Promise; - /** Set the content of a specific file */ - writeFile(path: string, data: string): Promise; - /** Return the content of a specific file */ - readFile(path: string): Promise; - /** Remove a file */ - remove(path: string): Promise; - /** Change the path of a file */ - rename(oldPath: string, newPath: string): Promise; - /** Upsert a file with the content of the source file */ - copyFile(src: string, dest: string): Promise; - /** Create a directory */ - mkdir(path: string): Promise; - /** Get the list of files in the directory */ - readdir(path: string): Promise; - getCurrentFile(): Promise; - getFile: (path: string) => Promise; - setFile: (path: string, data: string) => Promise; - switchFile: (path: string) => Promise; - /** @deprecated Use readdir instead */ - getFolder(path: string): Promise; - } - -} -declare module 'dist/packages/engine/vscode/lib/editor' { - import { IEditor, Annotation, HighlightPosition } from '@remixproject/plugin-api'; - import { MethodApi } from '@remixproject/plugin-utils'; - import { CommandPlugin, CommandOptions } from 'dist/packages/engine/vscode/lib/command'; - export interface EditorOptions extends CommandOptions { - language: string; - } - export class EditorPlugin extends CommandPlugin implements MethodApi { - private decoration; - private decorations; - private diagnosticCollection; - options: EditorOptions; - constructor(options: EditorOptions); - setOptions(options: EditorOptions): void; - onActivation(): void; - onDeactivation(): void; - highlight(position: HighlightPosition, filePath: string, themeColor: string): Promise; - discardDecorations(): Promise; - discardHighlight(): Promise; - /** - * Alisas of discardHighlight - * Required to match the standard interface of editor - */ - discardHighlightAt(): Promise; - addAnnotation(annotation: Annotation, filePath?: string): Promise; - clearAnnotations(): Promise; - } - -} -declare module 'dist/packages/engine/vscode/lib/terminal' { - import { Plugin } from '@remixproject/engine'; - export interface TerminalOptions { - name?: string; - open: boolean; - } - export class TerminalPlugin extends Plugin { - private terminals; - private outputs; - private activeOutput; - constructor(); - onDeactivation(): void; - private get active(); - private getTerminal; - private getOutput; - /** Open specific terminal (doesn't work with output) */ - open(name?: string): string; - /** Kill a terminal */ - kill(name?: string): void; - /** Write on the current terminal and execute command */ - exec(command: string, options?: Partial): void; - /** Write on the current output */ - write(text: string, options?: Partial): void; - } - -} -declare module 'dist/packages/engine/vscode/lib/contentimport' { - import { IContentImport } from '@remixproject/plugin-api'; - import { ContentImport } from '@remixproject/plugin-api'; - import { MethodApi } from '@remixproject/plugin-utils'; - import { CommandPlugin } from 'dist/packages/engine/vscode/lib/command'; - import { RemixURLResolver } from '@remix-project/remix-url-resolver'; - export class ContentImportPlugin extends CommandPlugin implements MethodApi { - urlResolver: RemixURLResolver; - constructor(); - resolve(path: string): Promise; - resolveAndSave(url: string, targetPath: string): Promise; - } - -} -declare module 'dist/packages/engine/vscode/lib/appmanager' { - import { PluginManager } from '@remixproject/engine'; - export class VscodeAppManager extends PluginManager { - pluginsDirectory: string; - target: string; - constructor(); - registeredPluginData(): Promise; - } - -} -declare module 'dist/packages/engine/vscode/index' { - export * from 'dist/packages/engine/vscode/lib/command'; - export * from 'dist/packages/engine/vscode/lib/dynamic-list'; - export * from 'dist/packages/engine/vscode/lib/extension'; - export * from 'dist/packages/engine/vscode/lib/theme'; - export * from 'dist/packages/engine/vscode/lib/webview'; - export * from 'dist/packages/engine/vscode/lib/window'; - export * from 'dist/packages/engine/vscode/lib/filemanager'; - export * from 'dist/packages/engine/vscode/lib/editor'; - export * from 'dist/packages/engine/vscode/lib/terminal'; - export * from 'dist/packages/engine/vscode/lib/contentimport'; - export * from 'dist/packages/engine/vscode/lib/appmanager'; - -} -declare module 'dist/packages/engine/vscode/util/editor' { - import { TextEditor } from 'vscode'; - export function getOpenedTextEditor(): TextEditor; - export function getTextEditorWithDocumentType(type: string): TextEditor; - -} -declare module 'dist/packages/engine/vscode/util/path' { - export function absolutePath(path: string): string; - export function relativePath(path: any): any; - -} -declare module 'dist/packages/engine/web/lib/iframe' { - import type { Message, Profile, ExternalProfile, LocationProfile } from '@remixproject/plugin-utils'; - import { PluginConnector } from '@remixproject/engine'; - export type IframeProfile = Profile & LocationProfile & ExternalProfile; - /** - * Connect an Iframe client to the engine. - * @dev This implements the ViewPlugin as it cannot extends two class. Maybe use a mixin at some point - */ - export class IframePlugin extends PluginConnector { - profile: IframeProfile; - private readonly listener; - private iframe; - private origin; - private source; - private url; - constructor(profile: IframeProfile); - /** Implement "activate" of the ViewPlugin */ - connect(url: string): Promise; - /** Implement "deactivate" of the ViewPlugin */ - disconnect(): Promise; - /** Get message from the iframe */ - private getEvent; - /** - * Post a message to the iframe of this plugin - * @param message The message to post - */ - protected send(message: Partial): void; - /** Create and return the iframe */ - render(): HTMLIFrameElement; - } - -} -declare module 'dist/packages/engine/web/lib/ws' { - import type { Message, Profile, ExternalProfile } from '@remixproject/plugin-utils'; - import { PluginConnector, PluginConnectorOptions } from '@remixproject/engine'; - export interface WebsocketOptions extends PluginConnectorOptions { - /** Time (in ms) to wait before reconnection after connection closed */ - reconnectDelay: number; - } - export class WebsocketPlugin extends PluginConnector { - private account; - private readonly listeners; - private url; - protected socket: WebSocket; - protected options: WebsocketOptions; - constructor(profile: Profile & ExternalProfile, options?: Partial); - private getEvent; - /** Try to reconnect to net websocket if closes */ - private onclose; - /** Open a connection with the server (also used for reconnection) */ - protected open(): void; - protected send(message: Partial): void; - protected connect(url: string): void; - protected disconnect(): void; - } - -} -declare module 'dist/packages/engine/web/lib/theme' { - import { Plugin } from '@remixproject/engine'; - import { MethodApi } from '@remixproject/plugin-utils'; - import { ITheme, Theme } from '@remixproject/plugin-api'; type DeepPartial = { - [P in keyof T]?: DeepPartial; - }; - /** - * Utils function to create a theme with default value - * Default values are taken from material design with colors - * - primary: indigo - * - secondary: pink - * - warn: orange - * - error: red - */ - export function createTheme(params?: DeepPartial): Theme; - export class ThemePlugin extends Plugin implements MethodApi { - protected getTheme: typeof createTheme; - protected theme: Theme; - constructor(); - /** Internal API to set the current theme */ - setTheme(theme: DeepPartial): void; - /** External API to get the current theme */ - currentTheme(): Promise; - } - export {}; - -} -declare module 'dist/packages/engine/web/lib/window' { - import { Plugin, PluginOptions } from '@remixproject/engine'; - import { IWindow } from '@remixproject/plugin-api'; - import { MethodApi } from '@remixproject/plugin-utils'; - export class WindowPlugin extends Plugin implements MethodApi { - constructor(options?: PluginOptions); - /** Display an input window */ - prompt(message?: string): Promise; - /** Ask confirmation for an action */ - confirm(message: string): Promise; - /** Display a message with actions button. Returned the button clicked if any */ - alert(message: string, actions?: string[]): Promise; - } - -} -declare module 'dist/packages/engine/web/lib/web-worker' { - import type { Message, Profile, ExternalProfile } from '@remixproject/plugin-utils'; - import { PluginConnector, PluginOptions } from '@remixproject/engine'; type WebworkerOptions = WorkerOptions & PluginOptions; - export class WebWorkerPlugin extends PluginConnector { - profile: Profile & ExternalProfile; - private worker; - protected options: WebworkerOptions; - constructor(profile: Profile & ExternalProfile, options?: WebworkerOptions); - setOptions(options: Partial): void; - connect(url: string): Promise; - disconnect(): void; - /** Get message from the iframe */ - private getEvent; - /** - * Post a message to the webview of this plugin - * @param message The message to post - */ - protected send(message: Partial): void; - } - export {}; - -} -declare module 'dist/packages/engine/web/lib/host' { - import type { Profile } from '@remixproject/plugin-utils'; - import { Plugin } from '@remixproject/engine'; - export abstract class HostPlugin extends Plugin { - constructor(profile: Profile); - /** Give the name of the current focus plugin */ - abstract currentFocus(): string; - /** Display the view inside the host */ - abstract focus(name: string): void; - /** Add the view of a plugin into the DOM */ - abstract addView(profile: Profile, view: Element): void; - /** Remove the plugin from the view from the DOM */ - abstract removeView(profile: Profile): void; - } - -} -declare module 'dist/packages/engine/web/lib/view' { - import type { Profile, LocationProfile } from '@remixproject/plugin-utils'; - import { Plugin } from '@remixproject/engine'; - export function isView

(profile: Profile): profile is (ViewProfile & P); - export type ViewProfile = Profile & LocationProfile; - export abstract class ViewPlugin extends Plugin { - profile: ViewProfile; - abstract render(): Element; - constructor(profile: ViewProfile); - activate(): Promise; - deactivate(): void; - } - -} -declare module 'dist/packages/engine/web/index' { - export * from 'dist/packages/engine/web/lib/iframe'; - export * from 'dist/packages/engine/web/lib/ws'; - export * from 'dist/packages/engine/web/lib/theme'; - export * from 'dist/packages/engine/web/lib/window'; - export * from 'dist/packages/engine/web/lib/web-worker'; - export * from 'dist/packages/engine/web/lib/host'; - export * from 'dist/packages/engine/web/lib/view'; - -} -declare module 'packages/plugin/core/src/lib/client' { - /// - import { EventEmitter } from 'events'; - import { RemixApi } from 'packages/api/src/lib/remix-profile'; - import { GetPluginService, Profile } from 'dist/packages/utils/lib/types/service'; - import type { Api, PluginRequest, ApiMap, EventKey, EventCallback, MethodParams, MethodKey, EventParams, ProfileMap, IPluginService, PluginBase } from 'dist/packages/utils/lib/types/plugin'; - export interface PluginDevMode { - /** Port for localhost */ - port: number | string; - origins: string | string[]; - } - /** Options of the plugin client */ - export interface PluginOptions { - customTheme: boolean; - /** define a set of custom apis to implements on the client */ - customApi: ProfileMap; - /** - * Allow a set of origins - * You can either a list of origin or a url with a link of origins - */ - allowOrigins: string | string[]; - /** - * options only available for dev mode - * @deprecated use allowOrigins instead if you want to limit the parent origin - */ - devMode: Partial; - } - export const defaultOptions: Partial>; - /** Throw an error if client try to send a message before connection */ - export function handleConnectionError(devMode?: Partial): void; - export class PluginClient implements PluginBase { - private id; - isLoaded: boolean; - events: EventEmitter; - currentRequest: PluginRequest; - options: PluginOptions; - name: string; - methods: string[]; - activateService: Record Promise>; - onActivation?(): void; - constructor(options?: Partial>); - onload(cb?: () => void): Promise; - /** - * Ask the plugin manager if current request can call a specific method - * @param method The method to call - * @param message An optional message to show to the user - */ - askUserPermission(method: MethodKey, message?: string): Promise; - /** - * Called before deactivating the plugin - * @param from profile of plugin asking to deactivate - * @note PluginManager will always be able to deactivate - */ - canDeactivate(from: Profile): boolean; - /** Make a call to another plugin */ - call, Key extends MethodKey>(name: Name, key: Key, ...payload: MethodParams): Promise>; - cancel, Key extends MethodKey>(name: Name, key?: Key | ''): void; - /** Listen on event from another plugin */ - on, Key extends EventKey>(name: Name, key: Key, cb: EventCallback): void; - /** Listen once on event from another plugin */ - once, Key extends EventKey>(name: Name, key: Key, cb: EventCallback): void; - /** Remove all listeners on an event from an external plugin */ - off, Key extends EventKey>(name: Name, key: Key): void; - /** Expose an event for the IDE */ - emit>(key: Key, ...payload: EventParams): void; - /** - * Create a service under the client node - * @param name The name of the service - * @param service The service - */ - createService, Service extends IPluginService>(name: string, service: Service): Promise>; - /** - * Prepare a service to be lazy loaded - * @param name The name of the subservice inside this service - * @param factory A function to create the service on demand - */ - prepareService>(name: string, factory: () => S): () => Promise>; - } - -} -declare module 'packages/plugin/core/src/lib/api' { - import type { Profile, Api, CustomApi, ProfileMap, ApiMapFromProfileMap, PluginApi, ApiMap } from '@remixproject/plugin-utils'; - import { PluginClient } from 'packages/plugin/core/src/lib/client'; - /** - * Create an Api - * @param profile The profile of the api - */ - export function createApi(client: PluginClient, profile: Profile): CustomApi; - /** - * Transform a list of profile into a map of API - * @deprecated Use applyApi from connector instead - */ - export function getApiMap, App extends ApiMap>(client: PluginClient, profiles: T): PluginApi>; - -} -declare module 'packages/plugin/core/src/lib/connector' { - import type { Message, Api, ApiMap, PluginApi } from '@remixproject/plugin-utils'; - import type { IRemixApi } from 'packages/api/src/lib/remix-profile'; - import { PluginClient } from 'packages/plugin/core/src/lib/client'; - export interface ClientConnector { - /** Send a message to the engine */ - send(message: Partial): void; - /** Get message from the engine */ - on(cb: (message: Partial) => void): void; - } - /** Check if a message is an handshake */ - export function isHandshake(message: Partial): boolean; - /** Check if an event.data is a plugin message is an handshake */ - export function isPluginMessage(message: any): message is Message; - /** - * Connect a plugin to the engine for a specific connector - * @param connector The connector for this plugin - * @param client The client instance of the plugin - * @example With a client - * typescript - * const client = new PluginClient() - * connectClient(new IframeConnector(client), client); - * - */ - export function connectClient(connector: ClientConnector, client?: PluginClient): PluginClient>; - export type Client

= PluginApi & PluginClient; - /** - * Add shortcut to the api requested by the client on it. - * @description - * Once applied, the client can do client.solidity.compile(x) instead of client.call('solidity', 'compile', x) - * @param client The client on which we apply the api - */ - export function applyApi(client: PluginClient): void; - /** - * Create & connect a client with a connector. - * @param connector A communication layer connector - * @param client The plugin client - */ - export const createConnectorClient:

> = Readonly>(connector: ClientConnector, client?: PluginClient) => Client; - -} -declare module 'packages/plugin/core/src/lib/node' { - import { PluginClient } from 'packages/plugin/core/src/lib/client'; - /** - * Access a service of an external plugin - */ - export class PluginNode { - private path; - private client; - /** - * @param path Path to external plugin - * @param client The main client used in this plugin - */ - constructor(path: string, client: PluginClient); - get(name: string): PluginNode; - /** Call a method of the node */ - call(method: string, ...payload: any[]): Promise; - /** - * Listen to an event from the plugin - * @note Event are trigger at the root level yet, not on a specific node - */ - on(method: string, cb: Function): void; - } - -} -declare module 'packages/plugin/core/src/lib/origin' { - import { PluginOptions } from 'packages/plugin/core/src/lib/client'; - export const remixOrgins = "https://gist.githubusercontent.com/EthereumRemix/091ccc57986452bbb33f57abfb13d173/raw/3367e019335746b73288e3710af2922d4c8ef5a3/origins.json"; - /** Fetch the default origins for remix */ - export function getOriginsFromUrl(url: string): Promise; - export function getDevmodeOrigins({ devMode }: Partial>): string[]; - /** - * Check if the sender has the right origin - * @param origin The origin of the incoming message - * @param options client plugin options - */ - export function checkOrigin(origin: string, options?: Partial>): Promise; - -} -declare module 'packages/plugin/core/src/index' { - export * from 'packages/plugin/core/src/lib/api'; - export * from 'packages/plugin/core/src/lib/client'; - export * from 'packages/plugin/core/src/lib/connector'; - export * from 'packages/plugin/core/src/lib/node'; - export * from 'packages/plugin/core/src/lib/origin'; - -} -declare module 'dist/packages/plugin/child-process/lib/connector' { - import { ClientConnector, Client, PluginClient } from '@remixproject/plugin'; - import type { Message, Api } from '@remixproject/plugin-utils'; - import { IRemixApi } from 'packages/api/src/lib/remix-profile'; - export interface WS { - send(data: string): void; - on(type: 'message', cb: (event: string) => any): this; - } - /** - * This Websocket connector works with the library ws - */ - export class WebsocketConnector implements ClientConnector { - private websocket; - constructor(websocket: WS); - /** Send a message to the engine */ - send(message: Partial): void; - /** Get messae from the engine */ - on(cb: (message: Partial) => void): void; - } - /** - * Connect a Websocket plugin client to a web engine - * @param client An optional websocket plugin client to connect to the engine. - * - * --------- - * @example - * typescript - * const wss = new WebSocket.Server({ port: 8080 }); - * wss.on('connection', (ws) => { - * const client = createClient(ws) - * }) - * - * --------- - * @example - * typescript - * class MyPlugin extends PluginClient { - * methods = ['hello'] - * hello() { - * console.log('Hello World') - * } - * } - * const wss = new WebSocket.Server({ port: 8080 }); - * wss.on('connection', (ws) => { - * const client = createClient(ws, new MyPlugin()) - * }) - * - */ - export const createClient:

> = Readonly>(websocket: WS, client?: PluginClient) => Client; - -} -declare module 'dist/packages/plugin/child-process/index' { - export * from 'dist/packages/plugin/child-process/lib/connector'; - -} -declare module 'dist/packages/plugin/core/lib/client' { - /// - import { EventEmitter } from 'events'; - import { RemixApi } from 'packages/api/src/lib/remix-profile'; - import { GetPluginService, Profile } from 'dist/packages/utils/lib/types/service'; - import type { Api, PluginRequest, ApiMap, EventKey, EventCallback, MethodParams, MethodKey, EventParams, ProfileMap, IPluginService, PluginBase } from 'dist/packages/utils/lib/types/plugin'; - export interface PluginDevMode { - /** Port for localhost */ - port: number | string; - origins: string | string[]; - } - /** Options of the plugin client */ - export interface PluginOptions { - customTheme: boolean; - /** define a set of custom apis to implements on the client */ - customApi: ProfileMap; - /** - * Allow a set of origins - * You can either a list of origin or a url with a link of origins - */ - allowOrigins: string | string[]; - /** - * options only available for dev mode - * @deprecated use allowOrigins instead if you want to limit the parent origin - */ - devMode: Partial; - } - export const defaultOptions: Partial>; - /** Throw an error if client try to send a message before connection */ - export function handleConnectionError(devMode?: Partial): void; - export class PluginClient implements PluginBase { - private id; - isLoaded: boolean; - events: EventEmitter; - currentRequest: PluginRequest; - options: PluginOptions; - name: string; - methods: string[]; - activateService: Record Promise>; - onActivation?(): void; - constructor(options?: Partial>); - onload(cb?: () => void): Promise; - /** - * Ask the plugin manager if current request can call a specific method - * @param method The method to call - * @param message An optional message to show to the user - */ - askUserPermission(method: MethodKey, message?: string): Promise; - /** - * Called before deactivating the plugin - * @param from profile of plugin asking to deactivate - * @note PluginManager will always be able to deactivate - */ - canDeactivate(from: Profile): boolean; - /** Make a call to another plugin */ - call, Key extends MethodKey>(name: Name, key: Key, ...payload: MethodParams): Promise>; - /** Listen on event from another plugin */ - on, Key extends EventKey>(name: Name, key: Key, cb: EventCallback): void; - /** Listen once on event from another plugin */ - once, Key extends EventKey>(name: Name, key: Key, cb: EventCallback): void; - /** Remove all listeners on an event from an external plugin */ - off, Key extends EventKey>(name: Name, key: Key): void; - /** Expose an event for the IDE */ - emit>(key: Key, ...payload: EventParams): void; - /** - * Create a service under the client node - * @param name The name of the service - * @param service The service - */ - createService, Service extends IPluginService>(name: string, service: Service): Promise>; - /** - * Prepare a service to be lazy loaded - * @param name The name of the subservice inside this service - * @param factory A function to create the service on demand - */ - prepareService>(name: string, factory: () => S): () => Promise>; - } - -} -declare module 'dist/packages/plugin/core/lib/api' { - import type { Profile, Api, CustomApi, ProfileMap, ApiMapFromProfileMap, PluginApi, ApiMap } from '@remixproject/plugin-utils'; - import { PluginClient } from 'dist/packages/plugin/core/lib/client'; - /** - * Create an Api - * @param profile The profile of the api - */ - export function createApi(client: PluginClient, profile: Profile): CustomApi; - /** - * Transform a list of profile into a map of API - * @deprecated Use applyApi from connector instead - */ - export function getApiMap, App extends ApiMap>(client: PluginClient, profiles: T): PluginApi>; - -} -declare module 'dist/packages/plugin/core/lib/connector' { - import type { Message, Api, ApiMap, PluginApi } from '@remixproject/plugin-utils'; - import type { IRemixApi } from '@remixproject/plugin-api'; - import { PluginClient } from 'dist/packages/plugin/core/lib/client'; - export interface ClientConnector { - /** Send a message to the engine */ - send(message: Partial): void; - /** Get message from the engine */ - on(cb: (message: Partial) => void): void; - } - /** Check if a message is an handshake */ - export function isHandshake(message: Partial): boolean; - /** Check if an event.data is a plugin message is an handshake */ - export function isPluginMessage(message: any): message is Message; - /** - * Connect a plugin to the engine for a specific connector - * @param connector The connector for this plugin - * @param client The client instance of the plugin - * @example With a client - * typescript - * const client = new PluginClient() - * connectClient(new IframeConnector(client), client); - * - */ - export function connectClient(connector: ClientConnector, client?: PluginClient): PluginClient>; - export type Client

= PluginApi & PluginClient; - /** - * Add shortcut to the api requested by the client on it. - * @description - * Once applied, the client can do client.solidity.compile(x) instead of client.call('solidity', 'compile', x) - * @param client The client on which we apply the api - */ - export function applyApi(client: PluginClient): void; - /** - * Create & connect a client with a connector. - * @param connector A communication layer connector - * @param client The plugin client - */ - export const createConnectorClient:

> = Readonly>(connector: ClientConnector, client?: PluginClient) => Client; - -} -declare module 'dist/packages/plugin/core/lib/node' { - import { PluginClient } from 'dist/packages/plugin/core/lib/client'; - /** - * Access a service of an external plugin - */ - export class PluginNode { - private path; - private client; - /** - * @param path Path to external plugin - * @param client The main client used in this plugin - */ - constructor(path: string, client: PluginClient); - get(name: string): PluginNode; - /** Call a method of the node */ - call(method: string, ...payload: any[]): Promise; - /** - * Listen to an event from the plugin - * @note Event are trigger at the root level yet, not on a specific node - */ - on(method: string, cb: Function): void; - } - -} -declare module 'dist/packages/plugin/core/lib/origin' { - import { PluginOptions } from 'dist/packages/plugin/core/lib/client'; - export const remixOrgins = "https://gist.githubusercontent.com/EthereumRemix/091ccc57986452bbb33f57abfb13d173/raw/3367e019335746b73288e3710af2922d4c8ef5a3/origins.json"; - /** Fetch the default origins for remix */ - export function getOriginsFromUrl(url: string): Promise; - export function getDevmodeOrigins({ devMode }: Partial>): string[]; - /** - * Check if the sender has the right origin - * @param origin The origin of the incoming message - * @param options client plugin options - */ - export function checkOrigin(origin: string, options?: Partial>): Promise; - -} -declare module 'dist/packages/plugin/core/index' { - export * from 'dist/packages/plugin/core/lib/api'; - export * from 'dist/packages/plugin/core/lib/client'; - export * from 'dist/packages/plugin/core/lib/connector'; - export * from 'dist/packages/plugin/core/lib/node'; - export * from 'dist/packages/plugin/core/lib/origin'; - -} -declare module 'dist/packages/plugin/iframe/lib/connector' { - import type { Message, Api } from '@remixproject/plugin-utils'; - import { IRemixApi } from 'packages/api/src/lib/remix-profile'; - import { ClientConnector, Client, PluginClient, PluginOptions } from '@remixproject/plugin'; - export class IframeConnector implements ClientConnector { - private options; - source: Window; - origin: string; - constructor(options: PluginOptions); - /** Send a message to the engine */ - send(message: Partial): void; - /** Get messae from the engine */ - on(cb: (message: Partial) => void): void; - } - /** - * Connect an Iframe client to a web engine - * @param client An optional iframe client to connect to the engine - * @example Let the function create a client - * typescript - * const client = createClient() - * - * @example With a custom client - * typescript - * class MyPlugin extends PluginClient { - * methods = ['hello'] - * hello() { - * console.log('Hello World') - * } - * } - * const client = createClient(new MyPlugin()) - * - */ - export const createClient:

> = Readonly>(client?: PluginClient) => Client; - -} -declare module 'dist/packages/plugin/iframe/lib/theme' { - import { PluginClient, PluginOptions } from '@remixproject/plugin'; - /** Start listening on theme changed */ - export function listenOnThemeChanged(client: PluginClient, options?: Partial>): Promise; - -} -declare module 'dist/packages/plugin/iframe/index' { - export * from 'dist/packages/plugin/iframe/lib/connector'; - export * from 'dist/packages/plugin/iframe/lib/theme'; - -} -declare module 'dist/packages/plugin/vscode/lib/webview' { - import type { Message, Api } from '@remixproject/plugin-utils'; - import { ClientConnector, Client, PluginClient, PluginOptions } from '@remixproject/plugin'; - /** - * This Webview connector - */ - export class WebviewConnector implements ClientConnector { - private options; - source: { - postMessage: (message: any, origin?: string) => void; - }; - origin: string; - isVscode: boolean; - constructor(options?: Partial>); - /** Send a message to the engine */ - send(message: Partial): void; - /** Get messae from the engine */ - on(cb: (message: Partial) => void): void; - } - /** - * Connect a Webview plugin client to a web engine - * @param client An optional websocket plugin client to connect to the engine. - */ - export const createClient:

>>(client?: PluginClient) => Client; - -} -declare module 'dist/packages/plugin/vscode/lib/extension' { - export {}; - -} -declare module 'dist/packages/plugin/vscode/index' { - export * from 'dist/packages/plugin/vscode/lib/webview'; - export * from 'dist/packages/plugin/vscode/lib/extension'; - -} -declare module 'dist/packages/plugin/webview/lib/connector' { - import type { Message, Api, PluginApi } from '@remixproject/plugin-utils'; - import { ClientConnector, PluginClient, PluginOptions } from '@remixproject/plugin'; - import { IRemixApi } from 'packages/api/src/lib/remix-profile'; global { - function acquireTheiaApi(): any; - } - /** - * This Webview connector - */ - export class WebviewConnector implements ClientConnector { - private options; - source: { - postMessage: (message: any, origin?: string) => void; - }; - origin: string; - isVscode: boolean; - constructor(options: PluginOptions); - /** Send a message to the engine */ - send(message: Partial): void; - /** Get messae from the engine */ - on(cb: (message: Partial) => void): void; - forwardEvents(): void; - } - /** - * Connect a Webview plugin client to a web engine - * @param client An optional websocket plugin client to connect to the engine. - */ - export const createClient:

> = Readonly, C extends PluginClient = any>(client: C) => C & PluginApi; - -} -declare module 'dist/packages/plugin/webview/index' { - export * from 'dist/packages/plugin/webview/lib/connector'; - -} -declare module 'dist/packages/plugin/webworker/lib/connector' { - /// - import { ClientConnector, Client, PluginClient } from '@remixproject/plugin'; - import type { Message, Api } from '@remixproject/plugin-utils'; - import { IRemixApi } from 'packages/api/src/lib/remix-profile'; - export class WebworkerConnector implements ClientConnector { - /** Send a message to the engine */ - send(message: Partial): void; - /** Get message from the engine */ - on(cb: (message: Partial) => void): void; - } - /** - * Connect a Websocket plugin client to a web engine - * @param client An optional websocket plugin client to connect to the engine. - */ - export const createClient:

> = Readonly>(client?: PluginClient) => Client; - -} -declare module 'dist/packages/plugin/webworker/index' { - export * from 'dist/packages/plugin/webworker/lib/connector'; - -} -declare module 'dist/packages/plugin/ws/lib/ws' { - import type { Message, Api } from '@remixproject/plugin-utils'; - import { PluginClient, ClientConnector, Client } from '@remixproject/plugin'; - import { IRemixApi } from 'packages/api/src/lib/remix-profile'; - export interface WS { - send(data: string): void; - on(type: 'message', cb: (event: string) => any): this; - } - /** - * This Websocket connector works with the library ws - */ - export class WebsocketConnector implements ClientConnector { - private websocket; - account: string; - constructor(websocket: WS); - /** Send a message to the engine */ - send(message: Partial): void; - /** Get message from the engine */ - on(cb: (message: Partial) => void): void; - } - /** - * Connect a Websocket plugin client to a web engine - * @param client An optional websocket plugin client to connect to the engine. - * - * --------- - * @example - * typescript - * const wss = new WebSocket.Server({ port: 8080 }); - * wss.on('connection', (ws) => { - * const client = createClient(ws) - * }) - * - * --------- - * @example - * typescript - * class MyPlugin extends PluginClient { - * methods = ['hello'] - * hello() { - * console.log('Hello World') - * } - * } - * const wss = new WebSocket.Server({ port: 8080 }); - * wss.on('connection', (ws) => { - * const client = createClient(ws, new MyPlugin()) - * }) - * - */ - export const createClient:

> = Readonly>(websocket: WS, client?: PluginClient) => Client; - -} -declare module 'dist/packages/plugin/ws/index' { - export * from 'dist/packages/plugin/ws/lib/ws'; - -} -declare module 'dist/packages/utils/lib/tools/event-name' { - /** Create the name of the event for a call */ - export function callEvent(name: string, key: string, id: number): string; - /** Create the name of the event for a listen */ - export function listenEvent(name: string, key: string): string; - -} -declare module 'dist/packages/utils/lib/tools/method-path' { - /** Create a method path based on the method name and the path */ - export function getMethodPath(method: string, path?: string): string; - /** Get the root name of a path */ - export function getRootPath(path: string): string; - -} -declare module 'dist/packages/utils/lib/types/service' { - export type IPluginService = any> = { - methods: string[]; - readonly path: string; - } & T; - export type GetPluginService> = S extends IPluginService ? S : IPluginService; - -} -declare module 'dist/packages/utils/lib/types/status' { - export interface Status { - /** Display an icon or number */ - key: number | 'edited' | 'succeed' | 'loading' | 'failed' | 'none'; - /** Bootstrap css color */ - type?: 'success' | 'info' | 'warning' | 'error'; - /** Describe the status on mouseover */ - title?: string; - } - export type StatusEvents = { - statusChanged: (status: Status) => void; - }; - -} -declare module 'dist/packages/utils/lib/types/api' { - import { StatusEvents } from 'dist/packages/utils/lib/types/status'; - export interface Api { - events: { - [key: string]: (...args: any[]) => void; - } & StatusEvents; - methods: { - [key: string]: (...args: any[]) => void; - }; - } - export type EventKey = Extract; - export type EventParams> = T extends Api ? Parameters : any[]; - export type EventCallback> = T extends Api ? T['events'][K] : (...payload: any[]) => void; - export type MethodKey = Extract; - export type MethodParams> = T extends Api ? Parameters : any[]; - export interface EventApi { - on: >(name: event, cb: T['events'][event]) => void; - } - export type MethodApi = { - [m in Extract]: (...args: Parameters) => Promise>; - }; - export type CustomApi = EventApi & MethodApi; - /** A map of Api used to describe all the plugin's api in the project */ - export type ApiMap = Readonly>; - /** A map of plugin based on the ApiMap. It enforces the PluginEngine */ - export type PluginApi = { - [name in keyof T]: CustomApi; - }; - export type API = { - [M in keyof T['methods']]: T['methods'][M] | Promise; - }; - -} -declare module 'dist/packages/utils/lib/types/plugin' { - import type { IPluginService } from 'dist/packages/utils/lib/types/service'; - import { EventCallback, MethodParams, MethodKey, EventKey, Api, ApiMap, EventParams } from 'dist/packages/utils/lib/types/api'; - export interface PluginBase { - methods: string[]; - activateService: Record Promise>; - /** Listen on an event from another plugin */ - on, Key extends EventKey>(name: Name, key: Key, cb: EventCallback): void; - /** Listen one time on an event from another plugin, then remove event listener */ - once, Key extends EventKey>(name: Name, key: Key, cb: EventCallback): void; - /** Stop listening on an event from another plugin */ - off, Key extends EventKey>(name: Name, key: Key): void; - /** Call a method of another plugin */ - call, Key extends MethodKey>(name: Name, key: Key, ...payload: MethodParams): Promise; - /** Emit an event */ - emit>(key: Key, ...payload: EventParams): void; - } - export { EventCallback, MethodParams, MethodKey, EventKey, Api, ApiMap, EventParams } -} -declare module 'dist/packages/utils/lib/tools/service' { - import type { IPluginService, GetPluginService } from 'dist/packages/utils/lib/types/service'; - import type { Api, ApiMap } from 'dist/packages/utils/lib/types/api'; - import type { PluginBase } from 'dist/packages/utils/lib/types/plugin'; - /** Check if the plugin is an instance of PluginService */ - export const isPluginService: (service: any) => service is PluginService; - /** - * Return the methods of a service, except "constructor" and methods starting with "_" - * @param instance The instance of a class to get the method from - */ - export function getMethods(service: IPluginService): any; - /** - * Create a plugin service - * @param path The path of the service separated by '.' (ex: 'box.profile') - * @param service The service template - * @note If the service doesn't provide a property "methods" then all methods are going to be exposed by default - */ - export function createService>(path: string, service: T): GetPluginService; - /** - * Connect the service to the plugin client - * @param client The main client of the plugin - * @param service A service to activate - */ - export function activateService(client: PluginBase, service: IPluginService): any; - /** - * A node that forward the call to the right path - */ - export abstract class PluginService implements IPluginService { - methods: string[]; - abstract readonly path: string; - protected abstract plugin: PluginBase; - emit(key: string, ...payload: any[]): void; - /** - * Create a subservice under this service - * @param name The name of the subservice inside this service - * @param service The subservice to add - */ - createService>(name: string, service: S): Promise>; - /** - * Prepare a service to be lazy loaded. - * Service can be activated by doing client.activateService(path) - * @param name The name of the subservice inside this service - * @param factory A function to create the service on demand - */ - prepareService>(name: string, factory: () => S): void; - } - -} -declare module 'dist/packages/utils/lib/types/message' { - export interface PluginRequest { - /** The name of the plugin making the request */ - from: string; - /** @deprecated Will be remove in the next version */ - isFromNative?: boolean; - /** - * The path to access the request inside the plugin - * @example 'remixd.cmd.git' - */ - path?: string; - } type MessageActions = 'on' | 'off' | 'once' | 'call' | 'response' | 'emit'; type OldMessageActions = 'notification' | 'request' | 'response' | 'listen'; - export interface Message { - id: number; - action: MessageActions | OldMessageActions; - name: string; - key: string; - payload: any; - requestInfo: PluginRequest; - error?: Error | string; - signature?: string; - verifier?: string; - } - export {}; - -} -declare module 'dist/packages/utils/lib/types/profile' { - import { MethodKey, Api, ApiMap, EventKey } from 'dist/packages/utils/lib/types/api'; - /** Describe a plugin */ - export interface Profile { - name: string; - displayName?: string; - methods?: MethodKey[]; - permission?: boolean; - hash?: string; - description?: string; - documentation?: string; - version?: string; - } - export interface LocationProfile { - location: string; - } - export interface ExternalProfile { - url: string; - } - export interface HostProfile extends Profile { - methods: ('addView' | 'removeView' | 'focus' | string)[]; - } - export interface LibraryProfile extends Profile { - events?: EventKey[]; - notifications?: { - [name: string]: string[]; - }; - } - /** A map of profile */ - export type ProfileMap = Partial<{ - [name in keyof T]: Profile; - }>; - /** Extract the API of a profile */ - export type ApiFromProfile = T extends Profile ? I : never; - /** Create an ApiMap from a Profile Map */ - export type ApiMapFromProfileMap> = { - [name in keyof T]: ApiFromProfile; - }; - /** Transform an ApiMap into a profile map */ - export type ProfileMapFromApiMap = Readonly<{ - [name in keyof T]: Profile; - }>; - -} -declare module 'dist/packages/utils/index' { - export * from 'dist/packages/utils/lib/tools/event-name'; - export * from 'dist/packages/utils/lib/tools/method-path'; - export * from 'dist/packages/utils/lib/tools/service'; - export * from 'dist/packages/utils/lib/types/api'; - export * from 'dist/packages/utils/lib/types/message'; - export * from 'dist/packages/utils/lib/types/plugin'; - export * from 'dist/packages/utils/lib/types/profile'; - export * from 'dist/packages/utils/lib/types/service'; - export * from 'dist/packages/utils/lib/types/status'; - -} -declare module 'examples/example/engine/web/src/app/engine' { - import { Engine as PluginEngine } from '@remixproject/engine'; - export class Engine extends PluginEngine { - constructor(); - } - -} -declare module 'examples/example/engine/web/src/app/plugins/manager' { - import { PluginManager } from '@remixproject/engine'; - import { Profile } from '@remixproject/plugin-utils'; - import { Engine } from 'examples/example/engine/web/src/app/engine'; - export class Manager extends PluginManager { - private activeProfiles; - private idleProfiles; - activeProfiles$: import("rxjs").Observable[]>; - idleProfiles$: import("rxjs").Observable[]>; - constructor(engine: Engine); - private updateProfiles; - onProfileAdded(): void; - onPluginActivated(profile: Profile): void; - onPluginDeactivated(): void; - canDeactivatePlugin(from: Profile, to: Profile): Promise; - } - -} -declare module 'examples/example/engine/web/src/app/plugins/theme' { - import { ThemePlugin } from '@remixproject/engine-web'; - import { Engine } from 'examples/example/engine/web/src/app/engine'; - export class Theme extends ThemePlugin { - private engine; - private themes; - constructor(engine: Engine); - selectTheme(brightness: 'dark' | 'light'): void; - onActivation(): void; - } - -} -declare module 'examples/example/engine/web/src/app/plugins/window' { - import { WindowPlugin } from '@remixproject/engine-web'; - import { Engine } from 'examples/example/engine/web/src/app/engine'; - import { Theme } from 'examples/example/engine/web/src/app/plugins/theme'; - export class Window extends WindowPlugin { - private engine; - private theme; - constructor(engine: Engine, theme: Theme); - onActivation(): Promise; - } - -} -declare module 'examples/example/engine/web/src/app/plugins/library' { - /// - import { LibraryPlugin } from '@remixproject/engine'; - import { EventEmitter } from 'events'; - import { Engine } from 'examples/example/engine/web/src/app/engine'; - interface Transaction { - id: string; - } class TransactionLibrary { - private transactions; - events: EventEmitter; - sendTransaction(tx: Transaction): void; - } - export class Library extends LibraryPlugin { - library: TransactionLibrary; - constructor(engine: Engine); - onActivation(): void; - } - export {}; - -} -declare module 'examples/example/engine/web/src/app/plugins/terminal' { - import { Plugin } from '@remixproject/engine'; - import { Engine } from 'examples/example/engine/web/src/app/engine'; - export class Terminal extends Plugin { - private engine; - constructor(engine: Engine); - onActivation(): void; - run(text: string): void; - } - -} -declare module 'examples/example/engine/web/src/app/plugins/index' { - export * from 'examples/example/engine/web/src/app/plugins/manager'; - export * from 'examples/example/engine/web/src/app/plugins/theme'; - export * from 'examples/example/engine/web/src/app/plugins/window'; - export * from 'examples/example/engine/web/src/app/plugins/library'; - export * from 'examples/example/engine/web/src/app/plugins/terminal'; - -} -declare module 'examples/example/engine/web/src/app/app.component' { - import { Theme, Manager, Window, Library } from 'examples/example/engine/web/src/app/plugins'; - import { Engine } from 'examples/example/engine/web/src/app/engine'; - export class AppComponent { - private engine; - private manager; - private window; - private theme; - private library; - actives$: import("rxjs").Observable[]>; - idles$: import("rxjs").Observable[]>; - constructor(engine: Engine, manager: Manager, window: Window, theme: Theme, library: Library); - ngAfterViewInit(): void; - deactivate(name: string): void; - activate(name: string): void; - } - -} -declare module 'examples/example/engine/web/src/app/host.directive' { - import { ElementRef, Renderer2 } from '@angular/core'; - import { Manager } from 'examples/example/engine/web/src/app/plugins'; - import { Engine } from 'examples/example/engine/web/src/app/engine'; - export class HostDirective { - private engine; - private manager; - private el; - private renderer; - private plugin; - host: string; - constructor(engine: Engine, manager: Manager, el: ElementRef, renderer: Renderer2); - get name(): string; - ngAfterViewInit(): void; - ngOnDestroy(): Promise; - } - -} -declare module 'examples/example/engine/web/src/app/terminal/terminal.component' { - import { FormControl } from '@angular/forms'; - import { Manager, Terminal } from 'examples/example/engine/web/src/app/plugins'; - export class TerminalComponent { - private manager; - private terminal; - form: FormControl; - constructor(manager: Manager, terminal: Terminal); - submit(): Promise; - } - -} -declare module 'examples/example/engine/web/src/app/app.module' { - export class AppModule { - } - -} -declare module 'examples/example/engine/web/src/environments/environment' { - export const environment: { - production: boolean; - }; - -} -declare module 'examples/example/engine/web/src/main' { - export {}; - -} -declare module 'examples/example/engine/web/src/polyfills' { - /** - * This file includes polyfills needed by Angular and is loaded before the app. - * You can add your own extra polyfills to this file. - * - * This file is divided into 2 sections: - * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. - * 2. Application imports. Files imported after ZoneJS that should be loaded before your main - * file. - * - * The current setup is for so-called "evergreen" browsers; the last versions of browsers that - * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), - * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. - * - * Learn more in https://angular.io/guide/browser-support - */ - /*************************************************************************************************** - * BROWSER POLYFILLS - */ - /** IE10 and IE11 requires the following for NgClass support on SVG elements */ - /** - * Web Animations @angular/platform-browser/animations - * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari. - * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0). - */ - /** - * By default, zone.js will patch all possible macroTask and DomEvents - * user can disable parts of macroTask/DomEvents patch by setting following flags - * because those flags need to be set before zone.js being loaded, and webpack - * will put import in the top of bundle, so user need to create a separate file - * in this directory (for example: zone-flags.ts), and put the following flags - * into that file, and then add the following code before importing zone.js. - * import './zone-flags'; - * - * The flags allowed in zone-flags.ts are listed here. - * - * The following flags will work for all browsers. - * - * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame - * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick - * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames - * - * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js - * with the following flag, it will bypass zone.js patch for IE/Edge - * - * (window as any).__Zone_enable_cross_context_check = true; - * - */ - /*************************************************************************************************** - * Zone JS is required by default for Angular itself. - */ - import 'zone.js/dist/zone'; - /*************************************************************************************************** - * APPLICATION IMPORTS - */ - -} -declare module 'examples/example/engine/web/src/test-setup' { - import 'jest-preset-angular'; - -} -declare module 'examples/example/engine/web/src/environments/environment.prod' { - export const environment: { - production: boolean; - }; - -} -declare module 'examples/example/engine/web-e2e/src/support/app.po' { - export const pluginList: () => any; - -} -declare module 'examples/example/engine/web-e2e/src/integration/app.spec' { - export {}; - -} -declare namespace Cypress { - interface Chainable { - login(email: string, password: string): void; +export const remixTypes = ` +/// + +import { EventEmitter } from 'events'; + +declare type ABIDescription = FunctionDescription | EventDescription + +declare interface ABIParameter { + /** The name of the parameter */ + name: string + /** The canonical type of the parameter */ + type: ABITypeParameter + /** Used for tuple types */ + components?: ABIParameter[] +} + +declare type ABITypeParameter = +| 'uint' +| 'uint[]' // TODO : add +| 'int' +| 'int[]' // TODO : add +| 'address' +| 'address[]' +| 'bool' +| 'bool[]' +| 'fixed' +| 'fixed[]' // TODO : add +| 'ufixed' +| 'ufixed[]' // TODO : add +| 'bytes' +| 'bytes[]' // TODO : add +| 'function' +| 'function[]' +| 'tuple' +| 'tuple[]' +| string + +declare interface Annotation { + row: number; + column: number; + text: string; + type: "error" | "warning" | "info"; +} + +declare interface Api { + events: { + [key: string]: (...args: any[]) => void + } & StatusEvents + methods: { + [key: string]: (...args: any[]) => void } } -declare module 'examples/example/engine/web-e2e/src/support/index' { - import 'examples/example/engine/web-e2e/src/support/commands'; - -} -declare module 'examples/example/plugin/webview/src/app/client' { - import { InjectionToken } from '@angular/core'; - import { PluginClient } from '@remixproject/plugin'; - export class Client extends PluginClient { - methods: string[]; - constructor(); - execute(value: string): void; - onActivation(): void; - } - export const CLIENT: InjectionToken; - -} -declare module 'examples/example/plugin/webview/src/app/app.component' { - import { Client } from 'examples/example/plugin/webview/src/app/client'; - export class AppComponent { - private client; - title: string; - constructor(client: Client); - } - -} -declare module 'examples/example/plugin/webview/src/app/app.module' { - export class AppModule { - } - -} -declare module 'examples/example/plugin/webview/src/environments/environment' { - export const environment: { - production: boolean; - }; - -} -declare module 'examples/example/plugin/webview/src/main' { - export {}; - -} -declare module 'examples/example/plugin/webview/src/polyfills' { - /** - * This file includes polyfills needed by Angular and is loaded before the app. - * You can add your own extra polyfills to this file. - * - * This file is divided into 2 sections: - * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. - * 2. Application imports. Files imported after ZoneJS that should be loaded before your main - * file. - * - * The current setup is for so-called "evergreen" browsers; the last versions of browsers that - * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), - * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. - * - * Learn more in https://angular.io/guide/browser-support - */ - /*************************************************************************************************** - * BROWSER POLYFILLS - */ - /** IE10 and IE11 requires the following for NgClass support on SVG elements */ - /** - * Web Animations @angular/platform-browser/animations - * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari. - * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0). - */ - /** - * By default, zone.js will patch all possible macroTask and DomEvents - * user can disable parts of macroTask/DomEvents patch by setting following flags - * because those flags need to be set before zone.js being loaded, and webpack - * will put import in the top of bundle, so user need to create a separate file - * in this directory (for example: zone-flags.ts), and put the following flags - * into that file, and then add the following code before importing zone.js. - * import './zone-flags'; - * - * The flags allowed in zone-flags.ts are listed here. - * - * The following flags will work for all browsers. - * - * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame - * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick - * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames - * - * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js - * with the following flag, it will bypass zone.js patch for IE/Edge - * - * (window as any).__Zone_enable_cross_context_check = true; - * - */ - /*************************************************************************************************** - * Zone JS is required by default for Angular itself. - */ - import 'zone.js/dist/zone'; - /*************************************************************************************************** - * APPLICATION IMPORTS - */ - -} -declare module 'examples/example/plugin/webview/src/test-setup' { - import 'jest-preset-angular'; - -} -declare module 'examples/example/plugin/webview/src/environments/environment.prod' { - export const environment: { - production: boolean; - }; - -} -declare module 'examples/example/plugin/webview-e2e/src/support/app.po' { - export const getGreeting: () => any; - -} -declare module 'examples/example/plugin/webview-e2e/src/integration/app.spec' { - export {}; -} -declare namespace Cypress { - interface Chainable { - login(email: string, password: string): void; +/** A map of Api used to describe all the plugin's api in the project */ +declare type ApiMap = Readonly> + +declare interface AstNode { + absolutePath?: string + exportedSymbols?: Object + id: number + nodeType: string + nodes?: Array + src: string + literals?: Array + file?: string + scope?: number + sourceUnit?: number + symbolAliases?: Array + [x: string]: any +} + +declare interface AstNodeAtt { + operator?: string + string?: null + type?: string + value?: string + constant?: boolean + name?: string + public?: boolean + exportedSymbols?: Object + argumentTypes?: null + absolutePath?: string + [x: string]: any +} + +declare interface AstNodeLegacy { + id: number + name: string + src: string + children?: Array + attributes?: AstNodeAtt +} + +declare interface BytecodeObject { + /** The bytecode as a hex string. */ + object: string + /** Opcodes list */ + opcodes: string + /** The source mapping as a string. See the source mapping definition. */ + sourceMap: string + /** If given, this is an unlinked object. */ + linkReferences?: { + [contractName: string]: { + /** Byte offsets into the bytecode. */ + [library: string]: { start: number; length: number }[] + } } } -declare module 'examples/example/plugin/webview-e2e/src/support/index' { - import 'examples/example/plugin/webview-e2e/src/support/commands'; - -} -declare module 'packages/engine/core/tests/abstract.spec' { - export {}; - -} -declare module 'packages/engine/core/tests/connector.spec' { - export {}; - -} -declare module 'packages/engine/core/tests/engine.spec' { - /// - import { Engine, Plugin, PluginManager } from 'packages/engine/core/src'; - export class MockEngine extends Engine { - onRegistration: jest.Mock; - setPluginOption: jest.Mock<{ - queueTimeout: number; - }, []>; - } - export class MockManager extends PluginManager { - activatePlugin: jest.Mock, [names: string | string[]]>; - deactivatePlugin: jest.Mock, [names: string | string[]]>; - onRegistration: jest.Mock; - onActivation: jest.Mock; - onDeactivation: jest.Mock; - onPluginActivated: jest.Mock; - onPluginDeactivated: jest.Mock; - onProfileAdded: jest.Mock; - canActivatePlugin: jest.Mock, []>; - canDeactivatePlugin: jest.Mock, [from: any]>; - canCall: jest.Mock, []>; - constructor(); - } - export class MockSolidity extends Plugin { - onActivation: jest.Mock; - onDeactivation: jest.Mock; - onRegistration: jest.Mock; - compile: jest.Mock; - slowMockMethod: jest.Mock, [num: number]>; - getCompilationResult: jest.Mock; - constructor(); - } - export class MockFileManager extends Plugin { - private files; - private active; - constructor(); - getCurrentFile: jest.Mock; - getFile: jest.Mock; - getFolder: jest.Mock<{}, []>; - setFile: jest.Mock; - switchFile: jest.Mock; - } - -} -declare module 'packages/engine/core/tests/manager.spec' { - export {}; - -} -declare module 'packages/engine/node/src/lib/child-process' { - /// - import type { Message, Profile, ExternalProfile } from '@remixproject/plugin-utils'; - import { PluginConnector } from '@remixproject/engine'; - import { ChildProcess } from 'child_process'; - export class ChildProcessPlugin extends PluginConnector { - private readonly listener; - process: ChildProcess; - constructor(profile: Profile & ExternalProfile); - protected send(message: Partial): void; - protected connect(url: string): void; - protected disconnect(): void; - } - -} -declare module 'packages/engine/node/src/index' { - export * from 'packages/engine/node/src/lib/child-process'; - -} -declare module 'packages/engine/node/tests/child-process.spec' { - export {}; - -} -declare module 'packages/engine/theia/src/lib/engine-theia' { - export function engineTheia(): string; - -} -declare module 'packages/engine/theia/src/index' { - export * from 'packages/engine/theia/src/lib/engine-theia'; - -} -declare module 'packages/engine/theia/src/lib/engine-theia.spec' { - export {}; - -} -declare module 'packages/engine/vscode/src/lib/command' { - import { Plugin } from '@remixproject/engine'; - import { Profile, PluginOptions } from '@remixproject/plugin-utils'; - import { Disposable } from 'vscode'; - export const transformCmd: (name: string, method: string) => string; - export interface CommandOptions extends PluginOptions { - transformCmd: (name: string, method: string) => string; - } - /** - * Connect methods of the plugins with a command depending on the transformCmd function pass as option - */ - export class CommandPlugin extends Plugin { - subscriptions: Disposable[]; - options: CommandOptions; - constructor(profile: Profile); - setOptions(options: Partial): void; - activate(): void; - deactivate(): void; - } - -} -declare module 'packages/engine/vscode/src/lib/dynamic-list' { - import { Plugin } from '@remixproject/engine'; - import { PluginOptions } from '@remixproject/plugin-utils'; - import { TreeDataProvider, EventEmitter, TreeView, TreeItem } from 'vscode'; type ID = string | number; - export class Item extends TreeItem { - private item; - constructor(label: string, pluginName: string, item: I); - } - export class List implements TreeDataProvider { - private name; - private list; - private options; - render: EventEmitter; - onDidChangeTreeData: import("vscode").Event; - constructor(name: string, initial?: I[]); - setOptions(options: Partial): void; - reset(list: I[]): void; - getParent(): any; - getTreeItem(element: I): Item; - getChildren(): I[]; - } - export interface ListOptions { - idKey: string; - labelKey: string; - } - export type ListPluginOptions = PluginOptions & ListOptions; - export class DynamicListPlugin = List> extends Plugin { - private listeners; - protected options: ListPluginOptions; - protected treeView: TreeView; - protected entities: Record; - protected selected: ID; - list: T; - constructor(name: string, options?: Partial); - setOptions(options: Partial): void; - activate(): void; - deactivate(): void; - getIds(): string[]; - getItem(id: ID): I; - getAll(): I[]; - /** Select on element of the list */ - select(idOrItem: ID | I): void; - /** Reset the entire list */ - reset(items: I[]): void; - /** Add a new item to the list */ - add(item: I): void; - /** Remove one item from the list */ - remove(id: ID): void; - /** Update one item in the list */ - update(id: ID, item: Partial): void; - } - export {}; - -} -declare module 'packages/engine/vscode/src/lib/extension' { - import { PluginConnector } from '@remixproject/engine'; - import { Profile, ExternalProfile, Message } from '@remixproject/plugin-utils'; - export class ExtensionPlugin extends PluginConnector { - private extension; - private connector; - constructor(profile: Profile & ExternalProfile); - protected send(message: Partial): void; - protected connect(url: string): Promise; - protected disconnect(): void; - } - -} -declare module 'packages/engine/vscode/src/lib/theme' { - import { Plugin } from '@remixproject/engine'; - import { API, PluginOptions } from '@remixproject/plugin-utils'; - import { ITheme, Theme, ThemeUrls } from '@remixproject/plugin-api'; - import { Disposable, ColorTheme } from 'vscode'; - export interface ThemeOptions extends PluginOptions { - urls?: Partial; - } - export function getVscodeTheme(color: ColorTheme, urls?: Partial): Theme; - export class ThemePlugin extends Plugin implements API { - protected getTheme: typeof getVscodeTheme; - protected options: ThemeOptions; - listener: Disposable; - constructor(options?: Partial); - setOptions(options: Partial): void; - onActivation(): void; - onDeactivation(): void; - currentTheme(): Theme; - } +declare interface CompilationError { + /** Location within the source file */ + sourceLocation?: { + file: string + start: number + end: number + } + /** Error type */ + type: CompilationErrorType + /** Component where the error originated, such as "general", "ewasm", etc. */ + component: 'general' | 'ewasm' | string + severity: 'error' | 'warning' + message: string + /** the message formatted with source location */ + formattedMessage?: string +} + +declare type CompilationErrorType = +| 'JSONError' +| 'IOError' +| 'ParserError' +| 'DocstringParsingError' +| 'SyntaxError' +| 'DeclarationError' +| 'TypeError' +| 'UnimplementedFeatureError' +| 'InternalCompilerError' +| 'Exception' +| 'CompilerError' +| 'FatalError' +| 'Warning' + +declare interface CompilationFileSources { + [fileName: string]: + { + // Optional: keccak256 hash of the source file + keccak256?: string, + // Required (unless "urls" is used): literal contents of the source file + content: string, + urls?: string[] + } } -declare module 'packages/engine/vscode/src/lib/webview' { - import { PluginConnector, PluginConnectorOptions } from '@remixproject/engine'; - import { Message, Profile, ExternalProfile } from '@remixproject/plugin-utils'; - import { ExtensionContext, ViewColumn, WebviewPanel } from 'vscode'; - interface WebviewOptions extends PluginConnectorOptions { - /** Extension Path */ - context: ExtensionContext; - relativeTo?: 'workspace' | 'extension'; - column?: ViewColumn; - devMode?: boolean; - } - export class WebviewPlugin extends PluginConnector { - private listeners; - panel?: WebviewPanel; - options: WebviewOptions; - constructor(profile: Profile & ExternalProfile, options: WebviewOptions); - setOptions(options: Partial): void; - protected send(message: Partial): void; - protected connect(url: string): Promise; - getMessage(message: Message): Promise; - protected disconnect(): void; - } - /** Create a webview */ - export function createWebview(profile: Profile, url: string, options: WebviewOptions): Promise; - export {}; +declare interface CompilationResult { + /** not present if no errors/warnings were encountered */ + errors?: CompilationError[] + /** This contains the file-level outputs. In can be limited/filtered by the outputSelection settings */ + sources: { + [contractName: string]: CompilationSource + } + /** This contains the contract-level outputs. It can be limited/filtered by the outputSelection settings */ + contracts: { + /** If the language used has no contract names, this field should equal to an empty string. */ + [fileName: string]: { + [contract: string]: CompiledContract + } + } } -declare module 'packages/engine/vscode/src/lib/window' { - import { Plugin } from '@remixproject/engine'; - import { Profile, PluginOptions } from '@remixproject/plugin-utils'; - import { QuickPickOptions, InputBoxOptions } from 'vscode'; - export const windowProfile: Profile; - interface IWindowPlugin { - /** Display an input window */ - prompt(): Thenable; - /** Display a select window */ - select(options: string[]): Thenable; - /** Display a select window with local file system: can only select a file */ - selectFile(): Thenable; - /** Display a select window with local file system: can only select a folder */ - selectFolder(): Thenable; - /** Display a message with actions button. Returned the button clicked if any */ - alert(message: string, actions?: string[]): Thenable; - /** Display a warning message with actions button. Returned the button clicked if any */ - warning(message: string, actions?: string[]): Thenable; - /** Display an error message with actions button. Returned the button clicked if any */ - error(message: string, actions?: string[]): Thenable; - } - export class WindowPlugin extends Plugin implements IWindowPlugin { - constructor(options?: PluginOptions); - prompt(options?: InputBoxOptions): Thenable; - select(items: string[], options?: QuickPickOptions): Thenable; - selectFile(): Thenable; - selectFolder(): Thenable; - alert(message: string, actions?: string[]): Thenable; - error(message: string, actions?: string[]): Thenable; - warning(message: string, actions?: string[]): Thenable; - } - export {}; +declare interface CompilationSource { + /** Identifier of the source (used in source maps) */ + id: number + /** The AST object */ + ast: AstNode + /** The legacy AST object */ + legacyAST: AstNodeLegacy +} + +declare interface CompiledContract { + /** The Ethereum Contract ABI. If empty, it is represented as an empty array. */ + abi: ABIDescription[] + // See the Metadata Output documentation (serialised JSON string) + metadata: string + /** User documentation (natural specification) */ + userdoc: UserDocumentation + /** Developer documentation (natural specification) */ + devdoc: DeveloperDocumentation + /** Intermediate representation (string) */ + ir: string + /** EVM-related outputs */ + evm: { + assembly: string + legacyAssembly: {} + /** Bytecode and related details. */ + bytecode: BytecodeObject + deployedBytecode: BytecodeObject + /** The list of function hashes */ + methodIdentifiers: { + [functionIdentifier: string]: string + } + // Function gas estimates + gasEstimates: { + creation: { + codeDepositCost: string + executionCost: 'infinite' | string + totalCost: 'infinite' | string + } + external: { + [functionIdentifier: string]: string + } + internal: { + [functionIdentifier: string]: 'infinite' | string + } + } + } + /** eWASM related outputs */ + ewasm: { + /** S-expressions format */ + wast: string + /** Binary format (hex string) */ + wasm: string + } } -declare module 'packages/engine/vscode/src/util/path' { - export function absolutePath(path: string): string; - export function relativePath(path: any): any; +declare interface CondensedCompilationInput { + language: 'Solidity' | 'Vyper' | 'lll' | 'assembly' | 'yul' + optimize: boolean + /** e.g: 0.6.8+commit.0bbfe453 */ + version: string + evmVersion?: 'istanbul' | 'petersburg' | 'constantinople' | 'byzantium' | 'spuriousDragon' | 'tangerineWhistle' | 'homestead' } -declare module 'packages/engine/vscode/src/util/editor' { - import { TextEditor } from 'vscode'; - export function getOpenedTextEditor(): TextEditor; - export function getTextEditorWithDocumentType(type: string): TextEditor; +declare interface ContentImport { + content: any + cleanUrl: string + type: 'github' | 'http' | 'https' | 'swarm' | 'ipfs' + url: string } -declare module 'packages/engine/vscode/src/lib/filemanager' { - import { IFileSystem } from '@remixproject/plugin-api'; - import { MethodApi } from '@remixproject/plugin-utils'; - import { CommandPlugin } from 'packages/engine/vscode/src/lib/command'; - export class FileManagerPlugin extends CommandPlugin implements MethodApi { - constructor(); - /** Open the content of the file in the context (eg: Editor) */ - open(path: string): Promise; - /** Set the content of a specific file */ - writeFile(path: string, data: string): Promise; - /** Return the content of a specific file */ - readFile(path: string): Promise; - /** Remove a file */ - remove(path: string): Promise; - /** Change the path of a file */ - rename(oldPath: string, newPath: string): Promise; - /** Upsert a file with the content of the source file */ - copyFile(src: string, dest: string): Promise; - /** Create a directory */ - mkdir(path: string): Promise; - /** Get the list of files in the directory */ - readdir(path: string): Promise; - getCurrentFile(): Promise; - closeFile(): Promise; - closeAllFiles(): Promise; - logMessage(message: any): void; - getFile: (path: string) => Promise; - setFile: (path: string, data: string) => Promise; - switchFile: (path: string) => Promise; - /** @deprecated Use readdir instead */ - getFolder(path: string): Promise; - } +declare interface customAction { + id: string, + name: string, + type: customActionType[], + path: string[], + extension: string[], + pattern: string[], + sticky?: boolean, + label?: string } -declare module 'packages/engine/vscode/src/lib/editor' { - import { IEditor, Annotation, HighlightPosition } from '@remixproject/plugin-api'; - import { MethodApi } from '@remixproject/plugin-utils'; - import { CommandPlugin, CommandOptions } from 'packages/engine/vscode/src/lib/command'; - export interface EditorOptions extends CommandOptions { - language: string; - } - export class EditorPlugin extends CommandPlugin implements MethodApi { - private decoration; - private decorations; - private diagnosticCollection; - options: EditorOptions; - constructor(options: EditorOptions); - setOptions(options: EditorOptions): void; - onActivation(): void; - onDeactivation(): void; - highlight(position: HighlightPosition, filePath: string, themeColor: string): Promise; - discardDecorations(): Promise; - discardHighlight(): Promise; - /** - * Alisas of discardHighlight - * Required to match the standard interface of editor - */ - discardHighlightAt(): Promise; - addAnnotation(annotation: Annotation, filePath?: string): Promise; - clearAnnotations(): Promise; - gotoLine(line: number, col: number): Promise; - } -} -declare module 'packages/engine/vscode/src/lib/terminal' { - import { Plugin } from '@remixproject/engine'; - export interface TerminalOptions { - name?: string; - open: boolean; - } - export class TerminalPlugin extends Plugin { - private terminals; - private outputs; - private activeOutput; - constructor(); - onDeactivation(): void; - private get active(); - private getTerminal; - private getOutput; - /** Open specific terminal (doesn't work with output) */ - open(name?: string): string; - /** Kill a terminal */ - kill(name?: string): void; - /** Write on the current terminal and execute command */ - exec(command: string, options?: Partial): void; - /** Write on the current output */ - write(text: string, options?: Partial): void; - } +declare type customActionType = 'file' | 'folder' +/** @deprecated: current version in Remix IDE. To improve to match standard JSON RPC methods */ +declare interface CustomNetwork { + id?: string + name: string + url: string } -declare module 'packages/engine/vscode/src/lib/contentimport' { - import { IContentImport } from '@remixproject/plugin-api'; - import { ContentImport } from '@remixproject/plugin-api'; - import { MethodApi } from '@remixproject/plugin-utils'; - import { CommandPlugin } from 'packages/engine/vscode/src/lib/command'; - import { RemixURLResolver } from '@remix-project/remix-url-resolver'; - export class ContentImportPlugin extends CommandPlugin implements MethodApi { - urlResolver: RemixURLResolver; - constructor(); - resolve(path: string): Promise; - resolveAndSave(url: string, targetPath: string): Promise; - } -} -declare module 'packages/engine/vscode/src/lib/appmanager' { - import { PluginManager } from '@remixproject/engine'; - export class VscodeAppManager extends PluginManager { - pluginsDirectory: string; - target: string; - constructor(); - registeredPluginData(): Promise; - } +export declare const defaultOptions: Partial>; +declare interface DeveloperDocumentation { + author: string + title: string + details: string + methods: DevMethodList } -declare module 'packages/engine/vscode/src/index' { - export * from 'packages/engine/vscode/src/lib/command'; - export * from 'packages/engine/vscode/src/lib/dynamic-list'; - export * from 'packages/engine/vscode/src/lib/extension'; - export * from 'packages/engine/vscode/src/lib/theme'; - export * from 'packages/engine/vscode/src/lib/webview'; - export * from 'packages/engine/vscode/src/lib/window'; - export * from 'packages/engine/vscode/src/lib/filemanager'; - export * from 'packages/engine/vscode/src/lib/editor'; - export * from 'packages/engine/vscode/src/lib/terminal'; - export * from 'packages/engine/vscode/src/lib/contentimport'; - export * from 'packages/engine/vscode/src/lib/appmanager'; +declare interface DevMethodDoc { + author: string + details: string + return: string + returns: { + [param: string]: string + } + params: { + [param: string]: string + } } -declare module 'packages/engine/web/src/lib/iframe' { - import type { Message, Profile, ExternalProfile, LocationProfile } from '@remixproject/plugin-utils'; - import { PluginConnector } from '@remixproject/engine'; - export type IframeProfile = Profile & LocationProfile & ExternalProfile; - /** - * Connect an Iframe client to the engine. - * @dev This implements the ViewPlugin as it cannot extends two class. Maybe use a mixin at some point - */ - export class IframePlugin extends PluginConnector { - profile: IframeProfile; - private readonly listener; - private iframe; - private origin; - private source; - private url; - constructor(profile: IframeProfile); - /** Implement "activate" of the ViewPlugin */ - connect(url: string): Promise; - /** Implement "deactivate" of the ViewPlugin */ - disconnect(): Promise; - /** Get message from the iframe */ - private getEvent; - /** - * Post a message to the iframe of this plugin - * @param message The message to post - */ - protected send(message: Partial): void; - /** Create and return the iframe */ - render(): HTMLIFrameElement; - } +declare interface DevMethodList { + [functionIdentifier: string]: DevMethodDoc } -declare module 'packages/engine/web/src/lib/ws' { - import type { Message, Profile, ExternalProfile } from '@remixproject/plugin-utils'; - import { PluginConnector, PluginConnectorOptions } from '@remixproject/engine'; - export interface WebsocketOptions extends PluginConnectorOptions { - /** Time (in ms) to wait before reconnection after connection closed */ - reconnectDelay: number; - } - export class WebsocketPlugin extends PluginConnector { - private readonly listeners; - private url; - protected socket: WebSocket; - protected options: WebsocketOptions; - constructor(profile: Profile & ExternalProfile, options?: Partial); - private getEvent; - /** Try to reconnect to net websocket if closes */ - private onclose; - /** Open a connection with the server (also used for reconnection) */ - protected open(): void; - protected send(message: Partial): void; - protected connect(url: string): void; - protected disconnect(): void; - } -} -declare module 'packages/engine/web/src/lib/theme' { - import { Plugin } from '@remixproject/engine'; - import { MethodApi } from '@remixproject/plugin-utils'; - import { ITheme, Theme } from '@remixproject/plugin-api'; type DeepPartial = { - [P in keyof T]?: DeepPartial; - }; - /** - * Utils function to create a theme with default value - * Default values are taken from material design with colors - * - primary: indigo - * - secondary: pink - * - warn: orange - * - error: red - */ - export function createTheme(params?: DeepPartial): Theme; - export class ThemePlugin extends Plugin implements MethodApi { - protected getTheme: typeof createTheme; - protected theme: Theme; - constructor(); - /** Internal API to set the current theme */ - setTheme(theme: DeepPartial): void; - /** External API to get the current theme */ - currentTheme(): Promise; - } - export {}; +declare type EventCallback> = T extends Api +? T['events'][K] +: (...payload: any[]) => void +declare interface EventDescription { + type: 'event' + name: string + inputs: ABIParameter & + { + /** true if the field is part of the log’s topics, false if it one of the log’s data segment. */ + indexed: boolean + }[] + /** true if the event was declared as anonymous. */ + anonymous: boolean } -declare module 'packages/engine/web/src/lib/window' { - import { Plugin } from '@remixproject/engine'; - import { IWindow } from '@remixproject/plugin-api'; - import { MethodApi, PluginOptions } from '@remixproject/plugin-utils'; - export class WindowPlugin extends Plugin implements MethodApi { - constructor(options?: PluginOptions); - /** Display an input window */ - prompt(message?: string): Promise; - /** Ask confirmation for an action */ - confirm(message: string): Promise; - /** Display a message with actions button. Returned the button clicked if any */ - alert(message: string, actions?: string[]): Promise; - } -} -declare module 'packages/engine/web/src/lib/web-worker' { - import type { Message, Profile, ExternalProfile, PluginOptions } from '@remixproject/plugin-utils'; - import { PluginConnector } from '@remixproject/engine'; type WebworkerOptions = WorkerOptions & PluginOptions; - export class WebWorkerPlugin extends PluginConnector { - profile: Profile & ExternalProfile; - private worker; - protected options: WebworkerOptions; - constructor(profile: Profile & ExternalProfile, options?: WebworkerOptions); - setOptions(options: Partial): void; - connect(url: string): Promise; - disconnect(): void; - /** Get message from the iframe */ - private getEvent; - /** - * Post a message to the webview of this plugin - * @param message The message to post - */ - protected send(message: Partial): void; - } - export {}; +declare type EventKey = Extract -} -declare module 'packages/engine/web/src/lib/host' { - import type { Profile } from '@remixproject/plugin-utils'; - import { Plugin } from '@remixproject/engine'; - export abstract class HostPlugin extends Plugin { - constructor(profile: Profile); - /** Give the name of the current focus plugin */ - abstract currentFocus(): string; - /** Display the view inside the host */ - abstract focus(name: string): void; - /** Add the view of a plugin into the DOM */ - abstract addView(profile: Profile, view: Element): void; - /** Remove the plugin from the view from the DOM */ - abstract removeView(profile: Profile): void; - } +declare type EventParams> = T extends Api +? Parameters +: any[] +declare interface Folder { + [path: string]: { + isDirectory: boolean + } } -declare module 'packages/engine/web/src/lib/view' { - import type { Profile, LocationProfile } from '@remixproject/plugin-utils'; - import { Plugin } from '@remixproject/engine'; - export function isView

(profile: Profile): profile is (ViewProfile & P); - export type ViewProfile = Profile & LocationProfile; - export abstract class ViewPlugin extends Plugin { - profile: ViewProfile; - abstract render(): Element; - constructor(profile: ViewProfile); - activate(): Promise; - deactivate(): void; - } +declare interface FunctionDescription { + /** Type of the method. default is 'function' */ + type?: 'function' | 'constructor' | 'fallback' + /** The name of the function. Constructor and fallback functions never have a name */ + name?: string + /** List of parameters of the method. Fallback functions don’t have inputs. */ + inputs?: ABIParameter[] + /** List of the output parameters for the method, if any */ + outputs?: ABIParameter[] + /** State mutability of the method */ + stateMutability: 'pure' | 'view' | 'nonpayable' | 'payable' + /** true if function accepts Ether, false otherwise. Default is false */ + payable?: boolean + /** true if function is either pure or view, false otherwise. Default is false */ + constant?: boolean } -declare module 'packages/engine/web/src/index' { - export * from 'packages/engine/web/src/lib/iframe'; - export * from 'packages/engine/web/src/lib/ws'; - export * from 'packages/engine/web/src/lib/theme'; - export * from 'packages/engine/web/src/lib/window'; - export * from 'packages/engine/web/src/lib/web-worker'; - export * from 'packages/engine/web/src/lib/host'; - export * from 'packages/engine/web/src/lib/view'; -} -declare module 'packages/engine/web/tests/iframe.spec' { - export {}; +declare type GetPluginService> = S extends IPluginService ? S : IPluginService -} -declare module 'packages/engine/web/tests/view.spec' { - /// - import { Engine } from 'packages/engine/core/src'; - export class MockEngine extends Engine { - onRegistration: jest.Mock; - } +/** Throw an error if client try to send a message before connection */ +export declare function handleConnectionError(devMode?: Partial): void; +declare interface HighLightOptions { + focus: boolean } -declare module 'packages/engine/web/tests/websocket.spec' { - export {}; +declare interface HighlightPosition { + start: { + line: number + column: number + } + end: { + line: number + column: number + } } -declare module 'packages/plugin/child-process/src/lib/connector' { - import { ClientConnector, Client, PluginClient } from '@remixproject/plugin'; - import type { Message, Api } from '@remixproject/plugin-utils'; - import { IRemixApi } from 'packages/api/src/lib/remix-profile'; - export interface WS { - send(data: string): void; - on(type: 'message', cb: (event: string) => any): this; - } - /** - * This Websocket connector works with the library ws - */ - export class WebsocketConnector implements ClientConnector { - private websocket; - constructor(websocket: WS); - /** Send a message to the engine */ - send(message: Partial): void; - /** Get messae from the engine */ - on(cb: (message: Partial) => void): void; - } - /** - * Connect a Websocket plugin client to a web engine - * @param client An optional websocket plugin client to connect to the engine. - * - * --------- - * @example - * typescript - * const wss = new WebSocket.Server({ port: 8080 }); - * wss.on('connection', (ws) => { - * const client = createClient(ws) - * }) - * - * --------- - * @example - * typescript - * class MyPlugin extends PluginClient { - * methods = ['hello'] - * hello() { - * console.log('Hello World') - * } - * } - * const wss = new WebSocket.Server({ port: 8080 }); - * wss.on('connection', (ws) => { - * const client = createClient(ws, new MyPlugin()) - * }) - * - */ - export const createClient:

> = Readonly>(websocket: WS, client?: PluginClient) => Client; +declare interface ICompiler extends Api { + events: { + compilationFinished: ( + fileName: string, + source: CompilationFileSources, + languageVersion: string, + data: CompilationResult + ) => void + } & StatusEvents + methods: { + getCompilationResult(): lastCompilationResult + compile(fileName: string): void + setCompilerConfig(settings: CondensedCompilationInput): void + compileWithParameters(targets: SourcesInput, settings: CondensedCompilationInput): lastCompilationResult + } } -declare module 'packages/plugin/child-process/src/index' { - export * from 'packages/plugin/child-process/src/lib/connector'; +declare interface IContentImport { + events: {} & StatusEvents + methods: { + resolve(path: string): ContentImport + resolveAndSave (url:string, targetPath: string): string + } } -declare module 'packages/plugin/core/tests/api.spec' { - export {}; -} -declare module 'packages/plugin/core/tests/client.spec' { - export {}; +declare interface IDgitSystem { + events: StatusEvents + methods: { + init(): void; + add(cmd: any): string; + commit(cmd: any): string; + status(cmd: any): any[]; + rm(cmd: any): string; + log(cmd: any): any[]; + lsfiles(cmd: any): any[]; + readblob(cmd: any): { oid: string, blob: Uint8Array } + resolveref(cmd: any): string + branch(cmd: any): void + checkout(cmd: any): void + branches(): string[] + currentbranch(): string + push(cmd: any): string + pull(cmd: any): void + setIpfsConfig(config:any): boolean + zip():void + setItem(name:string, content:string):void + getItem(name: string): string + import(cmd: any): void + export(cmd: any): void + remotes(): any[] + addremote(cmd: any): void + delremote(cmd: any): void + clone(cmd: any): void + localStorageUsed(): any + }; +} + +declare interface IEditor { + events: StatusEvents + methods: { + highlight( + position: HighlightPosition, + filePath: string, + hexColor: string, + opt?: HighLightOptions + ): void + discardHighlight(): void + discardHighlightAt(line: number, filePath: string): void + addAnnotation(annotation: Annotation): void + clearAnnotations(): void + gotoLine(line:number, col:number): void + } } -declare module 'packages/plugin/core/tests/node.spec' { - export {}; +declare interface IFilePanel { + events: { + setWorkspace: (workspace:any) => void + workspaceRenamed: (workspace:any) => void + workspaceDeleted: (workspace:any) => void + workspaceCreated: (workspace:any) => void + customAction: (cmd: customAction) => void + } & StatusEvents + methods: { + getCurrentWorkspace(): { name: string, isLocalhost: boolean, absolutePath: string } + getWorkspaces(): string[] + deleteWorkspace(name:string): void + createWorkspace(name:string, isEmpty:boolean): void + renameWorkspace(oldName:string, newName:string): void + registerContextMenuItem(cmd: customAction): void + } } -declare module 'packages/plugin/core/tests/origin.spec' { - export {}; +declare interface IFileSystem { + events: { + currentFileChanged: (file: string) => void + fileSaved: (file: string) => void + fileAdded: (file: string) => void + folderAdded: (file: string) => void + fileRemoved: (file: string) => void + fileClosed: (file: string) => void + noFileSelected: ()=> void + fileRenamed: (oldName: string, newName:string, isFolder: boolean) => void + } & StatusEvents + methods: { + /** Open the content of the file in the context (eg: Editor) */ + open(path: string): void + /** Set the content of a specific file */ + writeFile(path: string, data: string): void + /** Return the content of a specific file */ + readFile(path: string): string + /** Change the path of a file */ + rename(oldPath: string, newPath: string): void + /** Upsert a file with the content of the source file */ + copyFile(src: string, dest: string): void + /** Create a directory */ + mkdir(path: string): void + /** Get the list of files in the directory */ + readdir(path: string): string[] + /** Removes a file or directory recursively */ + remove(path: string): void + /** Get the name of the file currently focused if any */ + getCurrentFile(): string + /** close all files */ + closeAllFiles(): void + /** close a file */ + closeFile(): void + // Old API + /** @deprecated Use readdir */ + getFolder(path: string): Folder + /** @deprecated Use readFile */ + getFile(path: string): string + /** @deprecated Use writeFile */ + setFile(path: string, content: string): void + /** @deprecated Use open */ + switchFile(path: string): void + } } -declare module 'packages/plugin/core/tests/remix-api.spec' { - export {}; +/** @deprecated: current version in Remix IDE. To improve to match standard JSON RPC methods */ +declare interface INetwork { + events: { + providerChanged: (provider: NetworkProvider) => void + } & StatusEvents + methods: { + getNetworkProvider(): NetworkProvider + detectNetwork(): Network | Partial + getEndpoint(): string + addNetwork(network: CustomNetwork): void + removeNetwork(name: string): void + } } -declare module 'packages/plugin/core/tests/service.spec' { - export {}; +declare interface IPluginManager { + events: { + profileUpdated(profile: Profile): void + profileAdded(profile: Profile): void + pluginDeactivated(profile: Profile): void + pluginActivated(profile: Profile): void + } & StatusEvents + methods: { + getProfile(name: string): Promise + updateProfile(profile: Partial): any + activatePlugin(name: string): any + deactivatePlugin(name: string): any + isActive(name: string): boolean + canCall(from: string, to: string, method: string, message?: string): any + } } -declare module 'packages/plugin/iframe/src/lib/theme' { - import { PluginClient, PluginOptions } from '@remixproject/plugin'; - /** Start listening on theme changed */ - export function listenOnThemeChanged(client: PluginClient, options?: Partial>): Promise; +declare type IPluginService = any> = { + methods: string[] + readonly path: string +} & T + +declare interface IRemixApi { + manager: IPluginManager, + solidity: ICompiler + fileManager: IFileSystem + filePanel: IFilePanel + dGitProvider: IDgitSystem + solidityUnitTesting: IUnitTesting + editor: IEditor + network: INetwork + udapp: IUdapp + contentImport: IContentImport + settings: ISettings + theme: ITheme + vscodeExtAPI: IVScodeExtAPI + terminal: ITerminal +} + +declare interface ISettings { + events: {} & StatusEvents + methods: { + getGithubAccessToken(): string + } } -declare module 'packages/plugin/iframe/src/lib/connector' { - import type { Message, Api } from '@remixproject/plugin-utils'; - import { IRemixApi } from 'packages/api/src/lib/remix-profile'; - import { ClientConnector, Client, PluginClient, PluginOptions } from '@remixproject/plugin'; - export class IframeConnector implements ClientConnector { - private options; - source: Window; - origin: string; - constructor(options: PluginOptions); - /** Send a message to the engine */ - send(message: Partial): void; - /** Get messae from the engine */ - on(cb: (message: Partial) => void): void; - } - /** - * Connect an Iframe client to a web engine - * @param client An optional iframe client to connect to the engine - * @example Let the function create a client - * typescript - * const client = createClient() - * - * @example With a custom client - * typescript - * class MyPlugin extends PluginClient { - * methods = ['hello'] - * hello() { - * console.log('Hello World') - * } - * } - * const client = createClient(new MyPlugin()) - * - */ - export const createClient:

> = Readonly>(client?: PluginClient) => Client; +declare interface ITerminal { + events: { + } & StatusEvents + methods: { + log(message: TerminalMessage): void + } } -declare module 'packages/plugin/iframe/src/index' { - export * from 'packages/plugin/iframe/src/lib/connector'; - export * from 'packages/plugin/iframe/src/lib/theme'; +declare interface ITheme { + events: { + themeChanged: (theme: Theme) => void + } & StatusEvents + methods: { + currentTheme(): Theme + } } -declare module 'packages/plugin/iframe/tests/iframe.spec' { - export {}; +declare interface IUdapp { + events: { + newTransaction: (transaction: RemixTxEvent) => void + } & StatusEvents + methods: { + sendTransaction(tx: RemixTx): RemixTxReceipt + getAccounts(): string[] + createVMAccount(vmAccount: VMAccount): string + getSettings(): UdappSettings + setEnvironmentMode(env: 'vm' | 'injected' | 'web3'): void + } } -declare module 'packages/plugin/vscode/src/lib/webview' { - import type { Message, Api } from '@remixproject/plugin-utils'; - import { ClientConnector, Client, PluginClient, PluginOptions } from '@remixproject/plugin'; - /** - * This Webview connector - */ - export class WebviewConnector implements ClientConnector { - private options; - source: { - postMessage: (message: any, origin?: string) => void; - }; - origin: string; - isVscode: boolean; - constructor(options?: Partial>); - /** Send a message to the engine */ - send(message: Partial): void; - /** Get messae from the engine */ - on(cb: (message: Partial) => void): void; - } - /** - * Connect a Webview plugin client to a web engine - * @param client An optional websocket plugin client to connect to the engine. - */ - export const createClient:

>>(client?: PluginClient) => Client; +declare interface IUnitTesting { + events: {} & StatusEvents + methods: { + testFromPath(path: string): UnitTestResult + testFromSource(sourceCode: string): UnitTestResult + } } -declare module 'packages/plugin/vscode/src/lib/extension' { - export {}; +declare interface IVScodeExtAPI { + events: { + } & StatusEvents + methods: { + executeCommand(extension: string, command: string, payload?: any[]): any + } } -declare module 'packages/plugin/vscode/src/index' { - export * from 'packages/plugin/vscode/src/lib/webview'; - export * from 'packages/plugin/vscode/src/lib/extension'; +declare interface lastCompilationResult { + data: CompilationResult | null + source: SourceWithTarget | null | undefined +} + +declare type MethodKey = Extract + +declare type MethodParams> = T extends Api +? Parameters +: any[] + +declare type Network = +| { id: '1', name: 'Main' } +| { id: '2', name: 'Morden (deprecated)' } +| { id: '3', name: 'Ropsten' } +| { id: '4', name: 'Rinkeby' } +| { id: '5', name: 'Goerli' } +| { id: '42', name: 'Kovan' } + +/** @deprecated: current version in Remix IDE. To improve to match standard JSON RPC methods */ +declare type NetworkProvider = 'vm' | 'injected' | 'web3' + +declare interface PluginBase { + methods: string[], + activateService: Record Promise> + /** Listen on an event from another plugin */ + on, Key extends EventKey>( + name: Name, + key: Key, + cb: EventCallback, + ): void + + /** Listen one time on an event from another plugin, then remove event listener */ + once, Key extends EventKey>( + name: Name, + key: Key, + cb: EventCallback, + ): void + + /** Stop listening on an event from another plugin */ + off, Key extends EventKey>( + name: Name, + key: Key, + ): void + + /** Call a method of another plugin */ + call, Key extends MethodKey>( + name: Name, + key: Key, + ...payload: MethodParams + ): Promise + + /** Clear calls in queue of a plugin called by plugin */ + cancel, Key extends MethodKey>( + name: Name, + key: Key, + ): void + + /** Emit an event */ + emit>(key: Key, ...payload: EventParams): void +} + +export declare class PluginClient implements PluginBase { + private id; + isLoaded: boolean; + events: EventEmitter; + currentRequest: PluginRequest; + options: PluginOptions; + name: string; + methods: string[]; + activateService: Record Promise>; + onActivation?(): void; + constructor(options?: Partial>); + onload(cb?: () => void): Promise; + /** + * Ask the plugin manager if current request can call a specific method + * @param method The method to call + * @param message An optional message to show to the user + */ + askUserPermission(method: MethodKey, message?: string): Promise; + /** + * Called before deactivating the plugin + * @param from profile of plugin asking to deactivate + * @note PluginManager will always be able to deactivate + */ + canDeactivate(from: Profile): boolean; + /** Make a call to another plugin */ + call, Key extends MethodKey>(name: Name, key: Key, ...payload: MethodParams): Promise>; + /** Listen on event from another plugin */ + on, Key extends EventKey>(name: Name, key: Key, cb: EventCallback): void; + /** Listen once on event from another plugin */ + once, Key extends EventKey>(name: Name, key: Key, cb: EventCallback): void; + /** Remove all listeners on an event from an external plugin */ + off, Key extends EventKey>(name: Name, key: Key): void; + /** Expose an event for the IDE */ + emit>(key: Key, ...payload: EventParams): void; + /** + * Create a service under the client node + * @param name The name of the service + * @param service The service + */ + createService, Service extends IPluginService>(name: string, service: Service): Promise>; + /** + * Prepare a service to be lazy loaded + * @param name The name of the subservice inside this service + * @param factory A function to create the service on demand + */ + prepareService>(name: string, factory: () => S): () => Promise>; +} + +export declare interface PluginDevMode { + /** Port for localhost */ + port: number | string; + origins: string | string[]; +} + +/** Options of the plugin client */ +export declare interface PluginOptions { + customTheme: boolean; + /** define a set of custom apis to implements on the client */ + customApi: ProfileMap; + /** + * Allow a set of origins + * You can either a list of origin or a url with a link of origins + */ + allowOrigins: string | string[]; + /** + * options only available for dev mode + * @deprecated use allowOrigins instead if you want to limit the parent origin + */ + devMode: Partial; +} + +declare interface PluginRequest { + /** The name of the plugin making the request */ + from: string, + /** @deprecated Will be remove in the next version */ + isFromNative?: boolean, + /** + * The path to access the request inside the plugin + * @example 'remixd.cmd.git' + */ + path?: string +} + +/** Describe a plugin */ +declare interface Profile { + name: string + displayName?: string + methods?: MethodKey[] + events?: EventKey[] + permission?: boolean + hash?: string + description?: string + documentation?: string + version?: string + kind?: string, + canActivate?: string[], + icon?: string +} + +/** A map of profile */ +declare type ProfileMap = Partial<{ + [name in keyof T]: Profile +}> + +declare type RemixApi = Readonly + +declare interface RemixTx { + data: string + from: string + to?: string + timestamp?: string + gasLimit: string + value: string + useCall: boolean +} + +declare type RemixTxEvent = { + contractAddress: string + data: string + envMode: 'vm' + executionCost: string + from: string + gas: string + hash: string + input: string + logs: any[] + returnValue: Uint8Array + status: '0x01' | '0x00' + transactionCost: string + transactionHash: string + value: string +} | { + blockHash: string + blockNumber: number + envMod: 'injected' | 'web3' + from: string + gas: number + gasPrice: { c: number[], e: number, s: number } + hash: string + input: string + none: number + r: string + s: string + v: string + status: '0x01' | '0x00' + to: string + transactionCost: string + transactionIndex: number + value: { c: number[], e: number, s: number } +} + +declare interface RemixTxReceipt { + transactionHash: string + status: 0 | 1 + gasUsed: string + error: string + return: string + createdAddress?: string +} + +declare interface SourceInputContent { + /** Hash of the source file. */ + keccak256?: string + /** Literal contents of the source file */ + content: string +} + +declare interface SourceInputUrls { + /** Hash of the source file. It is used to verify the retrieved content imported via URLs */ + keccak256?: string + /** + * URL(s) to the source file. + * URL(s) should be imported in this order and the result checked against the + * keccak256 hash (if available). If the hash doesn't match or none of the + * URL(s) result in success, an error should be raised. + */ + urls: string[] +} + +declare interface SourcesInput { + [contractName: string]: SourceInputContent | SourceInputUrls +} + +declare interface SourceWithTarget { + sources?: CompilationFileSources, + target?: string | null | undefined +} + +declare interface Status { + /** Display an icon or number */ + key: number | 'edited' | 'succeed' | 'loading' | 'failed' | 'none' + /** Bootstrap css color */ + type?: 'success' | 'info' | 'warning' | 'error' + /** Describe the status on mouseover */ + title?: string +} + +declare type StatusEvents = { + statusChanged: (status: Status) => void +} + +declare type TerminalMessage = { + value: any, + type: 'html' | 'log' | 'info' | 'warn' | 'error' +} + +declare interface Theme { + url?: string + /** @deprecated Use brightness instead */ + quality?: 'dark' | 'light' + brightness: 'dark' | 'light' + colors: { + surface: string + background: string + foreground: string + primary: string + primaryContrast: string + secondary?: string + secondaryContrast?: string + success?: string + successContrast?: string + warn: string + warnContrast: string + error: string + errorContrast: string + disabled: string + } + breakpoints: { + xs: number + sm: number + md: number + lg: number + xl: number + } + fontFamily: string + /** A unit to multiply for margin & padding */ + space: number } -declare module 'packages/plugin/webview/src/lib/connector' { - import type { Message, Api, PluginApi } from '@remixproject/plugin-utils'; - import { ClientConnector, PluginClient, PluginOptions } from '@remixproject/plugin'; - import { IRemixApi } from 'packages/api/src/lib/remix-profile'; global { - function acquireTheiaApi(): any; - } - /** - * This Webview connector - */ - export class WebviewConnector implements ClientConnector { - private options; - source: { - postMessage: (message: any, origin?: string) => void; - }; - origin: string; - isVscode: boolean; - constructor(options: PluginOptions); - /** Send a message to the engine */ - send(message: Partial): void; - /** Get messae from the engine */ - on(cb: (message: Partial) => void): void; - pasteClipBoard(event: any): void; - insertAtCursor(element: any, value: any): void; - forwardEvents(): void; - } - /** - * Connect a Webview plugin client to a web engine - * @param client An optional websocket plugin client to connect to the engine. - */ - export const createClient:

> = Readonly, C extends PluginClient = any>(client: C) => C & PluginApi; +declare interface UdappSettings { + selectedAccount:string + selectedEnvMode: 'vm' | 'injected' | 'web3' + networkEnvironment: string } -declare module 'packages/plugin/webview/src/index' { - export * from 'packages/plugin/webview/src/lib/connector'; +declare interface UnitTestError { + context: string + value: string + message: string } -declare module 'packages/plugin/webworker/src/lib/connector' { - /// - import { ClientConnector, Client, PluginClient } from '@remixproject/plugin'; - import type { Message, Api } from '@remixproject/plugin-utils'; - import { IRemixApi } from 'packages/api/src/lib/remix-profile'; - export class WebworkerConnector implements ClientConnector { - /** Send a message to the engine */ - send(message: Partial): void; - /** Get message from the engine */ - on(cb: (message: Partial) => void): void; - } - /** - * Connect a Websocket plugin client to a web engine - * @param client An optional websocket plugin client to connect to the engine. - */ - export const createClient:

> = Readonly>(client?: PluginClient) => Client; +declare interface UnitTestResult { + totalFailing: number + totalPassing: number + totalTime: number + errors: UnitTestError[] } -declare module 'packages/plugin/webworker/src/index' { - export * from 'packages/plugin/webworker/src/lib/connector'; +declare interface UserDocumentation { + methods: UserMethodList + notice: string } -declare module 'packages/plugin/ws/src/lib/ws' { - import { Message, Api } from '@remixproject/plugin-utils'; - import { PluginClient, ClientConnector, Client } from '@remixproject/plugin'; - import { IRemixApi } from 'packages/api/src/lib/remix-profile'; - export interface WS { - send(data: string): void; - on(type: 'message', cb: (event: string) => any): this; - } - /** - * This Websocket connector works with the library ws - */ - export class WebsocketConnector implements ClientConnector { - private websocket; - private client; - constructor(websocket: WS); - setClient(client: PluginClient): void; - /** Send a message to the engine */ - send(message: Partial): void; - /** Get message from the engine */ - on(cb: (message: Partial) => void): void; - } - /** - * Connect a Websocket plugin client to a web engine - * @param client An optional websocket plugin client to connect to the engine. - * - * --------- - * @example - * typescript - * const wss = new WebSocket.Server({ port: 8080 }); - * wss.on('connection', (ws) => { - * const client = createClient(ws) - * }) - * - * --------- - * @example - * typescript - * class MyPlugin extends PluginClient { - * methods = ['hello'] - * hello() { - * console.log('Hello World') - * } - * } - * const wss = new WebSocket.Server({ port: 8080 }); - * wss.on('connection', (ws) => { - * const client = createClient(ws, new MyPlugin()) - * }) - * - */ - export const createClient:

> = Readonly>(websocket: WS, client?: PluginClient) => Client; +declare interface UserMethodDoc { + notice: string } -declare module 'packages/plugin/ws/src/index' { - export * from 'packages/plugin/ws/src/lib/ws'; +declare type UserMethodList = { + [functionIdentifier: string]: UserMethodDoc +} & { + 'constructor'?: string } -declare module 'packages/utils/tests/event-name.spec' { - export {}; +declare interface VMAccount { + privateKey: string + balance: string } -declare module 'packages/utils/tests/method-path.spec' { - export {}; -} -` +export { } +` \ No newline at end of file diff --git a/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx b/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx index 7bc0efe7b0..0c718a8865 100644 --- a/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx +++ b/libs/remix-ui/editor/src/lib/remix-ui-editor.tsx @@ -228,7 +228,7 @@ export const EditorUI = (props: EditorUIProps) => { useEffect(() => { - if (!editorRef.current) return + if (!editorRef.current || !props.currentFile) return currentFileRef.current = props.currentFile const file = editorModelsState[props.currentFile] editorRef.current.setModel(file.model) diff --git a/libs/remix-ui/editor/src/lib/web-types.ts b/libs/remix-ui/editor/src/lib/web-types.ts index a98c5c41c9..1c82788d30 100644 --- a/libs/remix-ui/editor/src/lib/web-types.ts +++ b/libs/remix-ui/editor/src/lib/web-types.ts @@ -1,132 +1,184 @@ +import { remixTypes } from './remix-plugin-types' + export const loadTypes = async (monaco) => { // ethers.js // @ts-ignore const ethersAbi = await import('raw-loader!@ethersproject/abi/lib/index.d.ts') - monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersAbi.default, `file:///node_modules/@types/@ethersproject/abi/index.d.ts`) + ethersAbi.default = ethersAbi.default.replace(/@ethersproject\//g, '@ethersproject_') + monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersAbi.default, `file:///node_modules/@types/@ethersproject_abi/index.d.ts`) // @ts-ignore const ethersAbstract = await import('raw-loader!@ethersproject/abstract-provider/lib/index.d.ts') - monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersAbstract.default, `file:///node_modules/@types/@ethersproject/abstract-provider/index.d.ts`) + ethersAbstract.default = ethersAbstract.default.replace(/@ethersproject\//g, '@ethersproject_') + monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersAbstract.default, `file:///node_modules/@types/@ethersproject_abstract-provider/index.d.ts`) // @ts-ignore const ethersSigner = await import('raw-loader!@ethersproject/abstract-signer/lib/index.d.ts') - monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersSigner.default, `file:///node_modules/@types/@ethersproject/abstract-signer/index.d.ts`) + ethersSigner.default = ethersSigner.default.replace(/@ethersproject\//g, '@ethersproject_') + monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersSigner.default, `file:///node_modules/@types/@ethersproject_abstract-signer/index.d.ts`) // @ts-ignore const ethersAddress = await import('raw-loader!@ethersproject/address/lib/index.d.ts') - monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersAddress.default, `file:///node_modules/@types/@ethersproject/address/index.d.ts`) + ethersAddress.default = ethersAddress.default.replace(/@ethersproject\//g, '@ethersproject_') + monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersAddress.default, `file:///node_modules/@types/@ethersproject_address/index.d.ts`) // @ts-ignore const ethersBase64 = await import('raw-loader!@ethersproject/base64/lib/index.d.ts') - monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersBase64.default, `file:///node_modules/@types/@ethersproject/base64/index.d.ts`) + ethersBase64.default = ethersBase64.default.replace(/@ethersproject\//g, '@ethersproject_') + monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersBase64.default, `file:///node_modules/@types/@ethersproject_base64/index.d.ts`) // @ts-ignore const ethersBasex = await import('raw-loader!@ethersproject/basex/lib/index.d.ts') - monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersBasex.default, `file:///node_modules/@types/@ethersproject/basex/index.d.ts`) + ethersBasex.default = ethersBasex.default.replace(/@ethersproject\//g, '@ethersproject_') + monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersBasex.default, `file:///node_modules/@types/@ethersproject_basex/index.d.ts`) // @ts-ignore const ethersBignumber = await import('raw-loader!@ethersproject/bignumber/lib/index.d.ts') - monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersBignumber.default, `file:///node_modules/@types/@ethersproject/bignumber/index.d.ts`) + ethersBignumber.default = ethersBignumber.default.replace(/@ethersproject\//g, '@ethersproject_') + monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersBignumber.default, `file:///node_modules/@types/@ethersproject_bignumber/index.d.ts`) // @ts-ignore const ethersBytes = await import('raw-loader!@ethersproject/bytes/lib/index.d.ts') - monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersBytes.default, `file:///node_modules/@types/@ethersproject/bytes/index.d.ts`) + ethersBytes.default = ethersBytes.default.replace(/@ethersproject\//g, '@ethersproject_') + monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersBytes.default, `file:///node_modules/@types/@ethersproject_bytes/index.d.ts`) // @ts-ignore const ethersConstants = await import('raw-loader!@ethersproject/constants/lib/index.d.ts') - monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersConstants.default, `file:///node_modules/@types/@ethersproject/constants/index.d.ts`) + ethersConstants.default = ethersConstants.default.replace(/@ethersproject\//g, '@ethersproject_') + monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersConstants.default, `file:///node_modules/@types/@ethersproject_constants/index.d.ts`) // @ts-ignore const ethersContracts = await import('raw-loader!@ethersproject/contracts/lib/index.d.ts') - monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersContracts.default, `file:///node_modules/@types/@ethersproject/contracts/index.d.ts`) + ethersContracts.default = ethersContracts.default.replace(/@ethersproject\//g, '@ethersproject_') + monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersContracts.default, `file:///node_modules/@types/@ethersproject_contracts/index.d.ts`) // @ts-ignore const ethersHash = await import('raw-loader!@ethersproject/hash/lib/index.d.ts') - monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersHash.default, `file:///node_modules/@types/@ethersproject/lib/index.d.ts`) + ethersHash.default = ethersHash.default.replace(/@ethersproject\//g, '@ethersproject_') + monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersHash.default, `file:///node_modules/@types/@ethersproject_hash/index.d.ts`) // @ts-ignore const ethersHdnode = await import('raw-loader!@ethersproject/hdnode/lib/index.d.ts') - monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersHdnode.default, `file:///node_modules/@types/@ethersproject/hdnode/index.d.ts`) + ethersHdnode.default = ethersHdnode.default.replace(/@ethersproject\//g, '@ethersproject_') + monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersHdnode.default, `file:///node_modules/@types/@ethersproject_hdnode/index.d.ts`) // @ts-ignore const ethersJsonWallets = await import('raw-loader!@ethersproject/json-wallets/lib/index.d.ts') - monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersJsonWallets.default, `file:///node_modules/@types/@ethersproject/json-wallets/index.d.ts`) + ethersJsonWallets.default = ethersJsonWallets.default.replace(/@ethersproject\//g, '@ethersproject_') + monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersJsonWallets.default, `file:///node_modules/@types/@ethersproject_json-wallets/index.d.ts`) // @ts-ignore const ethersKeccak256 = await import('raw-loader!@ethersproject/keccak256/lib/index.d.ts') - monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersKeccak256.default, `file:///node_modules/@types/@ethersproject/keccak256/index.d.ts`) + ethersKeccak256.default = ethersKeccak256.default.replace(/@ethersproject\//g, '@ethersproject_') + monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersKeccak256.default, `file:///node_modules/@types/@ethersproject_keccak256/index.d.ts`) // @ts-ignore const ethersLogger = await import('raw-loader!@ethersproject/logger/lib/index.d.ts') - monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersLogger.default, `file:///node_modules/@types/@ethersproject/logger/index.d.ts`) + ethersLogger.default = ethersLogger.default.replace(/@ethersproject\//g, '@ethersproject_') + monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersLogger.default, `file:///node_modules/@types/@ethersproject_logger/index.d.ts`) // @ts-ignore const ethersNetworks = await import('raw-loader!@ethersproject/networks/lib/index.d.ts') - monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersNetworks.default, `file:///node_modules/@types/@ethersproject/networks/index.d.ts`) + ethersNetworks.default = ethersNetworks.default.replace(/@ethersproject\//g, '@ethersproject_') + monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersNetworks.default, `file:///node_modules/@types/@ethersproject_networks/index.d.ts`) // @ts-ignore const ethersPbkdf2 = await import('raw-loader!@ethersproject/pbkdf2/lib/index.d.ts') - monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersPbkdf2.default, `file:///node_modules/@types/@ethersproject/pbkdf2/index.d.ts`) + ethersPbkdf2.default = ethersPbkdf2.default.replace(/@ethersproject\//g, '@ethersproject_') + monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersPbkdf2.default, `file:///node_modules/@types/@ethersproject_pbkdf2/index.d.ts`) // @ts-ignore const ethersProperties = await import('raw-loader!@ethersproject/properties/lib/index.d.ts') - monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersProperties.default, `file:///node_modules/@types/@ethersproject/properties/index.d.ts`) + ethersProperties.default = ethersProperties.default.replace(/@ethersproject\//g, '@ethersproject_') + monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersProperties.default, `file:///node_modules/@types/@ethersproject_properties/index.d.ts`) // @ts-ignore const ethersProviders = await import('raw-loader!@ethersproject/providers/lib/index.d.ts') - monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersProviders.default, `file:///node_modules/@types/@ethersproject/providers/index.d.ts`) + ethersProviders.default = ethersProviders.default.replace(/@ethersproject\//g, '@ethersproject_') + monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersProviders.default, `file:///node_modules/@types/@ethersproject_providers/index.d.ts`) // @ts-ignore const ethersRandom = await import('raw-loader!@ethersproject/random/lib/index.d.ts') - monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersRandom.default, `file:///node_modules/@types/@ethersproject/random/index.d.ts`) + ethersRandom.default = ethersRandom.default.replace(/@ethersproject\//g, '@ethersproject_') + monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersRandom.default, `file:///node_modules/@types/@ethersproject_random/index.d.ts`) // @ts-ignore const ethersRlp = await import('raw-loader!@ethersproject/rlp/lib/index.d.ts') - monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersRlp.default, `file:///node_modules/@types/@ethersproject/rlp/index.d.ts`) + ethersRlp.default = ethersRlp.default.replace(/@ethersproject\//g, '@ethersproject_') + monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersRlp.default, `file:///node_modules/@types/@ethersproject_rlp/index.d.ts`) // @ts-ignore const ethersSha2 = await import('raw-loader!@ethersproject/sha2/lib/index.d.ts') - monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersSha2.default, `file:///node_modules/@types/@ethersproject/sha2/index.d.ts`) + ethersSha2.default = ethersSha2.default.replace(/@ethersproject\//g, '@ethersproject_') + monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersSha2.default, `file:///node_modules/@types/@ethersproject_sha2/index.d.ts`) // @ts-ignore const ethersSingningkey = await import('raw-loader!@ethersproject/signing-key/lib/index.d.ts') - monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersSingningkey.default, `file:///node_modules/@types/@ethersproject/signing-key/index.d.ts`) + ethersSingningkey.default = ethersSingningkey.default.replace(/@ethersproject\//g, '@ethersproject_') + monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersSingningkey.default, `file:///node_modules/@types/@ethersproject_signing-key/index.d.ts`) // @ts-ignore const ethersSolidity = await import('raw-loader!@ethersproject/solidity/lib/index.d.ts') - monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersSolidity.default, `file:///node_modules/@types/@ethersproject/solidity/index.d.ts`) + ethersSolidity.default = ethersSolidity.default.replace(/@ethersproject\//g, '@ethersproject_') + monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersSolidity.default, `file:///node_modules/@types/@ethersproject_solidity/index.d.ts`) // @ts-ignore const ethersStrings = await import('raw-loader!@ethersproject/strings/lib/index.d.ts') - monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersStrings.default, `file:///node_modules/@types/@ethersproject/strings/index.d.ts`) + ethersStrings.default = ethersStrings.default.replace(/@ethersproject\//g, '@ethersproject_') + monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersStrings.default, `file:///node_modules/@types/@ethersproject_strings/index.d.ts`) // @ts-ignore const ethersTransactions = await import('raw-loader!@ethersproject/transactions/lib/index.d.ts') - monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersTransactions.default, `file:///node_modules/@types/@ethersproject/transactions/index.d.ts`) + ethersTransactions.default = ethersTransactions.default.replace(/@ethersproject\//g, '@ethersproject_') + monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersTransactions.default, `file:///node_modules/@types/@ethersproject_transactions/index.d.ts`) // @ts-ignore const ethersUnits = await import('raw-loader!@ethersproject/units/lib/index.d.ts') - monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersUnits.default, `file:///node_modules/@types/@ethersproject/units/index.d.ts`) + ethersUnits.default = ethersUnits.default.replace(/@ethersproject\//g, '@ethersproject_') + monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersUnits.default, `file:///node_modules/@types/@ethersproject_units/index.d.ts`) // @ts-ignore const ethersWallet = await import('raw-loader!@ethersproject/wallet/lib/index.d.ts') - monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersWallet.default, `file:///node_modules/@types/@ethersproject/wallet/index.d.ts`) + ethersWallet.default = ethersWallet.default.replace(/@ethersproject\//g, '@ethersproject_') + monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersWallet.default, `file:///node_modules/@types/@ethersproject_wallet/index.d.ts`) // @ts-ignore const ethersWeb = await import('raw-loader!@ethersproject/web/lib/index.d.ts') - monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersWeb.default, `file:///node_modules/@types/@ethersproject/web/index.d.ts`) + ethersWeb.default = ethersWeb.default.replace(/@ethersproject\//g, '@ethersproject_') + monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersWeb.default, `file:///node_modules/@types/@ethersproject_web/index.d.ts`) // @ts-ignore const ethersWordlists = await import('raw-loader!@ethersproject/wordlists/lib/index.d.ts') - monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersWordlists.default, `file:///node_modules/@types/@ethersproject/wordlists/index.d.ts`) + ethersWordlists.default = ethersWordlists.default.replace(/@ethersproject\//g, '@ethersproject_') + monaco.languages.typescript.typescriptDefaults.addExtraLib(ethersWordlists.default, `file:///node_modules/@types/@ethersproject_wordlists/index.d.ts`) + + // @ts-ignore + const versionEthers = await import('raw-loader!ethers/lib/_version.d.ts') + versionEthers.default = versionEthers.default.replace(/@ethersproject\//g, '@ethersproject_') + console.log(versionEthers.default) + monaco.languages.typescript.typescriptDefaults.addExtraLib(versionEthers.default, `file:///node_modules/@types/_version-ethers-lib/index.d.ts`) + + // @ts-ignore + const utilEthers = await import('raw-loader!ethers/lib/utils.d.ts') + utilEthers.default = utilEthers.default.replace(/@ethersproject\//g, '@ethersproject_') + console.log(utilEthers.default) + monaco.languages.typescript.typescriptDefaults.addExtraLib(utilEthers.default, `file:///node_modules/@types/utils-ethers-lib/index.d.ts`) // @ts-ignore const ethers = await import('raw-loader!ethers/lib/ethers.d.ts') - monaco.languages.typescript.typescriptDefaults.addExtraLib(ethers.default, `file:///node_modules/@types/ethers/ethers.d.ts`) + ethers.default = ethers.default.replace(/.\/utils/g, 'utils-ethers-lib') + ethers.default = ethers.default.replace(/.\/_version/g, '_version-ethers-lib') + ethers.default = ethers.default.replace(/.\/ethers/g, 'ethers-lib') + ethers.default = ethers.default.replace(/@ethersproject\//g, '@ethersproject_') + console.log(ethers.default) + monaco.languages.typescript.typescriptDefaults.addExtraLib(ethers.default, `file:///node_modules/@types/ethers-lib/index.d.ts`) // @ts-ignore const indexEthers = await import('raw-loader!ethers/lib/index.d.ts') + indexEthers.default = indexEthers.default.replace(/.\/ethers/g, 'ethers-lib') + indexEthers.default = indexEthers.default.replace(/@ethersproject\//g, '@ethersproject_') + console.log(indexEthers.default) monaco.languages.typescript.typescriptDefaults.addExtraLib(indexEthers.default, `file:///node_modules/@types/ethers/index.d.ts`) // Web3 @@ -162,20 +214,13 @@ export const loadTypes = async (monaco) => { // @ts-ignore const indexWeb3Util = await import('raw-loader!web3-utils/types/index.d.ts') monaco.languages.typescript.typescriptDefaults.addExtraLib(indexWeb3Util.default, `file:///node_modules/@types/web3-utils/index.d.ts`) - - - /* // remix - - // @ts-ignore - const indexRemixApi = await import('./remix-plugin-types') - monaco.languages.typescript.typescriptDefaults.addExtraLib(indexRemixApi.types) - */ - - monaco.languages.typescript.typescriptDefaults.addExtraLib(` - import { PluginClient } from 'packages/plugin/core/src/lib/client' - declare const remix: PluginClient - `) - + const indexRemixApi = remixTypes + `\n + declare global { + const remix: PluginClient; + const web3Provider; + } + ` + monaco.languages.typescript.typescriptDefaults.addExtraLib(indexRemixApi) console.log('loaded monaco types') } \ No newline at end of file diff --git a/libs/remix-ui/workspace/src/lib/actions/events.ts b/libs/remix-ui/workspace/src/lib/actions/events.ts index 188087d4fb..a8bde65fd5 100644 --- a/libs/remix-ui/workspace/src/lib/actions/events.ts +++ b/libs/remix-ui/workspace/src/lib/actions/events.ts @@ -49,6 +49,16 @@ export const listenOnPluginEvents = (filePanelPlugin) => { plugin.on('fileManager', 'fileClosed', async (file: string) => { dispatch(removeFocus(file)) }) + + plugin.on('fileManager', 'currentFileChanged', async (file: string) => { + const paths = file.split('/') + if (paths.length && paths[0] === '') paths.shift() + let currentCheck = '' + for (const value of paths) { + currentCheck = currentCheck + '/' + value + await folderAdded(currentCheck) + } + }) } export const listenOnProviderEvents = (provider) => (reducerDispatch: React.Dispatch) => { diff --git a/libs/remix-ui/workspace/src/lib/actions/workspace.ts b/libs/remix-ui/workspace/src/lib/actions/workspace.ts index 909b88d0c9..1b73f63cc0 100644 --- a/libs/remix-ui/workspace/src/lib/actions/workspace.ts +++ b/libs/remix-ui/workspace/src/lib/actions/workspace.ts @@ -12,6 +12,7 @@ import * as templateWithContent from '@remix-project/remix-ws-templates' const LOCALHOST = ' - connect to localhost - ' const NO_WORKSPACE = ' - none - ' const queryParams = new QueryParams() +const _paq = window._paq = window._paq || [] //eslint-disable-line let plugin, dispatch: React.Dispatch export const setPlugin = (filePanelPlugin, reducerDispatch) => { @@ -154,6 +155,7 @@ export const loadWorkspacePreset = async (template: WorkspaceTemplate = 'remixDe try { const templateList = Object.keys(templateWithContent) if (!templateList.includes(template)) break + _paq.push(['trackEvent', 'workspace', 'template', template]) // @ts-ignore const files = await templateWithContent[template]() for (const file in files) { diff --git a/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx b/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx index ea87e6779e..a0351ea3a1 100644 --- a/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx +++ b/libs/remix-ui/workspace/src/lib/components/file-explorer.tsx @@ -78,7 +78,6 @@ export const FileExplorer = (props: FileExplorerProps) => { targetDocument.addEventListener('keydown', keyPressHandler) targetDocument.addEventListener('keyup', keyUpHandler) - targetDocument.focus() return () => { targetDocument.removeEventListener('keydown', keyPressHandler) targetDocument.removeEventListener('keyup', keyUpHandler) diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index 4ab6fb3000..293b6d63cc 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -119,16 +119,22 @@ export function Workspace () { } } + const updateWsName = () => { + // @ts-ignore + workspaceCreateInput.current.value = `${workspaceCreateTemplateInput.current.value || 'remixDefault'}_${Date.now()}` + } + const createModalMessage = () => { return ( <> -
+
- - + + ) diff --git a/libs/remix-ui/workspace/src/lib/templates/blank.ts b/libs/remix-ui/workspace/src/lib/templates/blank.ts deleted file mode 100644 index 56004c9f9e..0000000000 --- a/libs/remix-ui/workspace/src/lib/templates/blank.ts +++ /dev/null @@ -1 +0,0 @@ -export default {} \ No newline at end of file diff --git a/libs/remix-ui/workspace/src/lib/templates/erc20.ts b/libs/remix-ui/workspace/src/lib/templates/erc20.ts deleted file mode 100644 index 348f9dbc73..0000000000 --- a/libs/remix-ui/workspace/src/lib/templates/erc20.ts +++ /dev/null @@ -1,125 +0,0 @@ -'use strict' - -const erc20 = `// SPDX-License-Identifier: GPL-3.0 - -pragma solidity >=0.7.0 <0.9.0; - -/** - * @title SampleERC20 - * @dev Create a sample ERC20 standard token - */ - -import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; - -contract SampleERC20 is ERC20 { - - constructor(string memory tokenName, string memory tokenSymbol) ERC20(tokenName, tokenSymbol) {} -}` - -const erc20_test = `// SPDX-License-Identifier: GPL-3.0 - -pragma solidity >=0.7.0 <0.9.0; -import "remix_tests.sol"; -import "../contracts/SampleERC20.sol"; - -contract SampleERC20Test { - - SampleERC20 s; - function beforeAll () public { - s = new SampleERC20("TestToken", "TST"); - } - - function testTokenNameAndSymbol () public { - Assert.equal(s.name(), "TestToken", "token name did not match"); - Assert.equal(s.symbol(), "TST", "token symbol did not match"); - } -} -` - -/* eslint-disable no-useless-escape */ -const deployWithWeb3 = `import { deploy } from './web3.ts' - -(async () => { - try { - const result = await deploy('SampleERC20', ['testToken', 'TST']) - console.log(\`address: \${result.address\}\`) - } catch (e) { - console.log(e.message) - } -})()` - -const deployWithEthers = `import { deploy } from './ethers.ts' - -(async () => { - try { - const result = await deploy('SampleERC20', ['testToken', 'TST']) - console.log(\`address: \${result.address\}\`) - } catch (e) { - console.log(e.message) - } - })()` - -const libWeb3 = ` -export const deploy = async (contractName: string, args: Array, from?: string, gas?: number) => { - - console.log(\`deploying \${contractName\}\`) - // Note that the script needs the ABI which is generated from the compilation artifact. - // Make sure contract is compiled and artifacts are generated - const artifactsPath = \`browser/contracts/artifacts/\${contractName\}.json\` - - const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath)) - - const accounts = await web3.eth.getAccounts() - - let contract = new web3.eth.Contract(metadata.abi) - - contract = contract.deploy({ - data: metadata.data.bytecode.object, - arguments: args - }) - - const newContractInstance = await contract.send({ - from: from || accounts[0], - gas: gas || 1500000 - }) - return newContractInstance.options -}: Promise` - -const libEthers = ` -export const deploy = async (contractName: string, args: Array, from?: string) => { - - console.log(\`deploying \${contractName\}\`) - // Note that the script needs the ABI which is generated from the compilation artifact. - // Make sure contract is compiled and artifacts are generated - const artifactsPath = \`browser/contracts/artifacts/\${contractName\}.json\` - - const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath)) - // 'web3Provider' is a remix global variable object - const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner() - - let factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer); - - let contract - if (from) { - contract = await factory.connect(from).deploy(...args); - } else { - contract = await factory.deploy(...args); - } - - // The contract is NOT deployed yet; we must wait until it is mined - await contract.deployed() - return contract -}: Promise` -/* eslint-enable no-useless-escape */ - - - - -export default { - erc20: { name: 'contracts/SampleERC20.sol', content: erc20 }, - erc20_test: { name: 'tests/SampleERC20_test.sol', content: erc20_test }, - deployWithWeb3: { name: 'scripts/deploy_with_web3.ts', content: deployWithWeb3 }, - deployWithEthers: { name: 'scripts/deploy_with_ethers.ts', content: deployWithEthers }, - web3: { name: 'scripts/web3.ts', content: libWeb3 }, - ethers: { name: 'scripts/ethers.ts', content: libEthers }, -} diff --git a/libs/remix-ui/workspace/src/lib/templates/index.ts b/libs/remix-ui/workspace/src/lib/templates/index.ts deleted file mode 100644 index 0fff14d78b..0000000000 --- a/libs/remix-ui/workspace/src/lib/templates/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { default as erc20 } from './erc20' -export { default as blank } from './blank' diff --git a/libs/remix-ws-templates/src/index.ts b/libs/remix-ws-templates/src/index.ts index 0b1893126b..011ddba170 100644 --- a/libs/remix-ws-templates/src/index.ts +++ b/libs/remix-ws-templates/src/index.ts @@ -1,3 +1,4 @@ export { default as remixDefault } from './templates/remixDefault' -export { default as erc20 } from './templates/erc20' -export { default as blank } from './templates/blank' \ No newline at end of file +export { default as blank } from './templates/blank' +export { default as ozerc20 } from './templates/ozerc20' +export { default as ozerc721 } from './templates/ozerc721' diff --git a/libs/remix-ws-templates/src/templates/erc20/contracts/SampleERC20.sol b/libs/remix-ws-templates/src/templates/ozerc20/contracts/SampleERC20.sol similarity index 99% rename from libs/remix-ws-templates/src/templates/erc20/contracts/SampleERC20.sol rename to libs/remix-ws-templates/src/templates/ozerc20/contracts/SampleERC20.sol index 23aa792466..56a7708413 100644 --- a/libs/remix-ws-templates/src/templates/erc20/contracts/SampleERC20.sol +++ b/libs/remix-ws-templates/src/templates/ozerc20/contracts/SampleERC20.sol @@ -2,13 +2,12 @@ pragma solidity >=0.7.0 <0.9.0; +import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; + /** * @title SampleERC20 * @dev Create a sample ERC20 standard token */ - -import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; - contract SampleERC20 is ERC20 { constructor(string memory tokenName, string memory tokenSymbol) ERC20(tokenName, tokenSymbol) {} diff --git a/libs/remix-ws-templates/src/templates/erc20/index.ts b/libs/remix-ws-templates/src/templates/ozerc20/index.ts similarity index 76% rename from libs/remix-ws-templates/src/templates/erc20/index.ts rename to libs/remix-ws-templates/src/templates/ozerc20/index.ts index cc1f087b55..48ffb45341 100644 --- a/libs/remix-ws-templates/src/templates/erc20/index.ts +++ b/libs/remix-ws-templates/src/templates/ozerc20/index.ts @@ -7,9 +7,9 @@ export default async () => { // @ts-ignore 'scripts/deploy_with_web3.ts': (await import('!!raw-loader!./scripts/deploy_with_web3.ts')).default, // @ts-ignore - 'scripts/ethers.ts': (await import('!!raw-loader!./scripts/ethers.ts')).default, + 'scripts/ethers-lib.ts': (await import('!!raw-loader!./scripts/ethers-lib.ts')).default, // @ts-ignore - 'scripts/web3.ts': (await import('!!raw-loader!./scripts/web3.ts')).default, + 'scripts/web3-lib.ts': (await import('!!raw-loader!./scripts/web3-lib.ts')).default, // @ts-ignore 'tests/SampleERC20_test.sol': (await import('raw-loader!./tests/SampleERC20_test.sol')).default } diff --git a/libs/remix-ws-templates/src/templates/erc20/scripts/deploy_with_ethers.ts b/libs/remix-ws-templates/src/templates/ozerc20/scripts/deploy_with_ethers.ts similarity index 82% rename from libs/remix-ws-templates/src/templates/erc20/scripts/deploy_with_ethers.ts rename to libs/remix-ws-templates/src/templates/ozerc20/scripts/deploy_with_ethers.ts index f863a6bcd5..c12ce0dfcd 100644 --- a/libs/remix-ws-templates/src/templates/erc20/scripts/deploy_with_ethers.ts +++ b/libs/remix-ws-templates/src/templates/ozerc20/scripts/deploy_with_ethers.ts @@ -1,4 +1,4 @@ -import { deploy } from './ethers' +import { deploy } from './ethers-lib' (async () => { try { diff --git a/libs/remix-ws-templates/src/templates/erc20/scripts/deploy_with_web3.ts b/libs/remix-ws-templates/src/templates/ozerc20/scripts/deploy_with_web3.ts similarity index 83% rename from libs/remix-ws-templates/src/templates/erc20/scripts/deploy_with_web3.ts rename to libs/remix-ws-templates/src/templates/ozerc20/scripts/deploy_with_web3.ts index 653b1f244e..3a19d6a068 100644 --- a/libs/remix-ws-templates/src/templates/erc20/scripts/deploy_with_web3.ts +++ b/libs/remix-ws-templates/src/templates/ozerc20/scripts/deploy_with_web3.ts @@ -1,4 +1,4 @@ -import { deploy } from './web3' +import { deploy } from './web3-lib' (async () => { try { diff --git a/libs/remix-ws-templates/src/templates/ozerc20/scripts/ethers-lib.ts b/libs/remix-ws-templates/src/templates/ozerc20/scripts/ethers-lib.ts new file mode 100644 index 0000000000..1c5f4c6548 --- /dev/null +++ b/libs/remix-ws-templates/src/templates/ozerc20/scripts/ethers-lib.ts @@ -0,0 +1,26 @@ +import { ethers } from 'ethers' + +export const deploy = async (contractName: string, args: Array, from?: string): Promise => { + + console.log(`deploying ${contractName}`) + // Note that the script needs the ABI which is generated from the compilation artifact. + // Make sure contract is compiled and artifacts are generated + const artifactsPath = `browser/contracts/artifacts/${contractName}.json` + + const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath)) + // 'web3Provider' is a remix global variable object + const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner() + + const factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer); + + let contract + if (from) { + contract = await factory.connect(from).deploy(...args); + } else { + contract = await factory.deploy(...args); + } + + // The contract is NOT deployed yet; we must wait until it is mined + await contract.deployed() + return contract +} \ No newline at end of file diff --git a/libs/remix-ws-templates/src/templates/ozerc20/scripts/web3-lib.ts b/libs/remix-ws-templates/src/templates/ozerc20/scripts/web3-lib.ts new file mode 100644 index 0000000000..37ff2be99b --- /dev/null +++ b/libs/remix-ws-templates/src/templates/ozerc20/scripts/web3-lib.ts @@ -0,0 +1,27 @@ +import Web3 from 'web3' + +export const deploy = async (contractName: string, args: Array, from?: string, gas?: number): Promise => { + + const web3 = new Web3(window.web3Provider) + console.log(`deploying ${contractName}`) + // Note that the script needs the ABI which is generated from the compilation artifact. + // Make sure contract is compiled and artifacts are generated + const artifactsPath = `browser/contracts/artifacts/${contractName}.json` + + const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath)) + + const accounts = await web3.eth.getAccounts() + + let contract = new web3.eth.Contract(metadata.abi) + + contract = contract.deploy({ + data: metadata.data.bytecode.object, + arguments: args + }) + + const newContractInstance = await contract.send({ + from: from || accounts[0], + gas: gas || 1500000 + }) + return newContractInstance.options +} \ No newline at end of file diff --git a/libs/remix-ws-templates/src/templates/erc20/tests/SampleERC20_test.sol b/libs/remix-ws-templates/src/templates/ozerc20/tests/SampleERC20_test.sol similarity index 100% rename from libs/remix-ws-templates/src/templates/erc20/tests/SampleERC20_test.sol rename to libs/remix-ws-templates/src/templates/ozerc20/tests/SampleERC20_test.sol diff --git a/libs/remix-ws-templates/src/templates/ozerc721/contracts/SampleERC721.sol b/libs/remix-ws-templates/src/templates/ozerc721/contracts/SampleERC721.sol new file mode 100644 index 0000000000..5a0d40c8e3 --- /dev/null +++ b/libs/remix-ws-templates/src/templates/ozerc721/contracts/SampleERC721.sol @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-3.0 + +pragma solidity >=0.7.0 <0.9.0; + +import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; + +/** + * @title SampleERC721 + * @dev Create a sample ERC721 standard token + */ +contract SampleERC721 is ERC721 { + + constructor(string memory tokenName, string memory tokenSymbol) ERC721(tokenName, tokenSymbol) {} +} \ No newline at end of file diff --git a/libs/remix-ws-templates/src/templates/ozerc721/index.ts b/libs/remix-ws-templates/src/templates/ozerc721/index.ts new file mode 100644 index 0000000000..53b6d132e7 --- /dev/null +++ b/libs/remix-ws-templates/src/templates/ozerc721/index.ts @@ -0,0 +1,16 @@ +export default async () => { + return { + // @ts-ignore + 'contracts/SampleERC721.sol': (await import('raw-loader!./contracts/SampleERC721.sol')).default, + // @ts-ignore + 'scripts/deploy_with_ethers.ts': (await import('!!raw-loader!./scripts/deploy_with_ethers.ts')).default, + // @ts-ignore + 'scripts/deploy_with_web3.ts': (await import('!!raw-loader!./scripts/deploy_with_web3.ts')).default, + // @ts-ignore + 'scripts/ethers-lib.ts': (await import('!!raw-loader!./scripts/ethers-lib.ts')).default, + // @ts-ignore + 'scripts/web3-lib.ts': (await import('!!raw-loader!./scripts/web3-lib.ts')).default, + // @ts-ignore + 'tests/SampleERC721_test.sol': (await import('raw-loader!./tests/SampleERC721_test.sol')).default + } +} \ No newline at end of file diff --git a/libs/remix-ws-templates/src/templates/ozerc721/scripts/deploy_with_ethers.ts b/libs/remix-ws-templates/src/templates/ozerc721/scripts/deploy_with_ethers.ts new file mode 100644 index 0000000000..185fd7a5fa --- /dev/null +++ b/libs/remix-ws-templates/src/templates/ozerc721/scripts/deploy_with_ethers.ts @@ -0,0 +1,10 @@ +import { deploy } from './ethers-lib' + +(async () => { + try { + const result = await deploy('SampleERC721', ['testNFT', 'TNFT']) + console.log(`address: ${result.address}`) + } catch (e) { + console.log(e.message) + } + })() \ No newline at end of file diff --git a/libs/remix-ws-templates/src/templates/ozerc721/scripts/deploy_with_web3.ts b/libs/remix-ws-templates/src/templates/ozerc721/scripts/deploy_with_web3.ts new file mode 100644 index 0000000000..2fec0c3b28 --- /dev/null +++ b/libs/remix-ws-templates/src/templates/ozerc721/scripts/deploy_with_web3.ts @@ -0,0 +1,10 @@ +import { deploy } from './web3-lib' + +(async () => { + try { + const result = await deploy('SampleERC721', ['testToken', 'TST']) + console.log(`address: ${result.address}`) + } catch (e) { + console.log(e.message) + } +})() \ No newline at end of file diff --git a/libs/remix-ws-templates/src/templates/erc20/scripts/ethers.ts b/libs/remix-ws-templates/src/templates/ozerc721/scripts/ethers-lib.ts similarity index 99% rename from libs/remix-ws-templates/src/templates/erc20/scripts/ethers.ts rename to libs/remix-ws-templates/src/templates/ozerc721/scripts/ethers-lib.ts index 04c363322a..0cb00c7e47 100644 --- a/libs/remix-ws-templates/src/templates/erc20/scripts/ethers.ts +++ b/libs/remix-ws-templates/src/templates/ozerc721/scripts/ethers-lib.ts @@ -1,6 +1,3 @@ - - - export const deploy = async (contractName: string, args: Array, from?: string): Promise => { console.log(`deploying ${contractName}`) diff --git a/libs/remix-ws-templates/src/templates/erc20/scripts/web3.ts b/libs/remix-ws-templates/src/templates/ozerc721/scripts/web3-lib.ts similarity index 100% rename from libs/remix-ws-templates/src/templates/erc20/scripts/web3.ts rename to libs/remix-ws-templates/src/templates/ozerc721/scripts/web3-lib.ts diff --git a/libs/remix-ws-templates/src/templates/ozerc721/tests/SampleERC721_test.sol b/libs/remix-ws-templates/src/templates/ozerc721/tests/SampleERC721_test.sol new file mode 100644 index 0000000000..27a4c46826 --- /dev/null +++ b/libs/remix-ws-templates/src/templates/ozerc721/tests/SampleERC721_test.sol @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: GPL-3.0 + +pragma solidity >=0.7.0 <0.9.0; +import "remix_tests.sol"; +import "../contracts/SampleERC721.sol"; + +contract SampleERC721Test { + + SampleERC721 s; + function beforeAll () public { + s = new SampleERC721("TestNFT", "TNFT"); + } + + function testTokenNameAndSymbol () public { + Assert.equal(s.name(), "TestNFT", "token name did not match"); + Assert.equal(s.symbol(), "TNFT", "token symbol did not match"); + } +} \ No newline at end of file diff --git a/libs/remix-ws-templates/src/templates/remixDefault/index.ts b/libs/remix-ws-templates/src/templates/remixDefault/index.ts index 683c616397..69bccc237d 100644 --- a/libs/remix-ws-templates/src/templates/remixDefault/index.ts +++ b/libs/remix-ws-templates/src/templates/remixDefault/index.ts @@ -11,9 +11,9 @@ export default async () => { // @ts-ignore 'scripts/deploy_with_web3.ts': (await import('!!raw-loader!./scripts/deploy_with_web3.ts')).default, // @ts-ignore - 'scripts/ethers.ts': (await import('!!raw-loader!./scripts/ethers.ts')).default, + 'scripts/ethers-lib.ts': (await import('!!raw-loader!./scripts/ethers-lib.ts')).default, // @ts-ignore - 'scripts/web3.ts': (await import('!!raw-loader!./scripts/web3.ts')).default, + 'scripts/web3-lib.ts': (await import('!!raw-loader!./scripts/web3-lib.ts')).default, // @ts-ignore 'tests/Ballot_test.sol': (await import('raw-loader!./tests/Ballot_test.sol')).default, // @ts-ignore diff --git a/libs/remix-ws-templates/src/templates/remixDefault/scripts/deploy_with_ethers.ts b/libs/remix-ws-templates/src/templates/remixDefault/scripts/deploy_with_ethers.ts index e5fbf05264..d7ec2105da 100644 --- a/libs/remix-ws-templates/src/templates/remixDefault/scripts/deploy_with_ethers.ts +++ b/libs/remix-ws-templates/src/templates/remixDefault/scripts/deploy_with_ethers.ts @@ -2,7 +2,7 @@ // Please make sure to compile "./contracts/1_Storage.sol" file before running this script. // And use Right click -> "Run" from context menu of the file to run the script. Shortcut: Ctrl+Shift+S -import { deploy } from './ethers' +import { deploy } from './ethers-lib' (async () => { try { diff --git a/libs/remix-ws-templates/src/templates/remixDefault/scripts/deploy_with_web3.ts b/libs/remix-ws-templates/src/templates/remixDefault/scripts/deploy_with_web3.ts index d2fe1ff4ff..57e1a73516 100644 --- a/libs/remix-ws-templates/src/templates/remixDefault/scripts/deploy_with_web3.ts +++ b/libs/remix-ws-templates/src/templates/remixDefault/scripts/deploy_with_web3.ts @@ -2,7 +2,7 @@ // Please make sure to compile "./contracts/1_Storage.sol" file before running this script. // And use Right click -> "Run" from context menu of the file to run the script. Shortcut: Ctrl+Shift+S -import { deploy } from './web3' +import { deploy } from './web3-lib' (async () => { try { diff --git a/libs/remix-ws-templates/src/templates/remixDefault/scripts/ethers.ts b/libs/remix-ws-templates/src/templates/remixDefault/scripts/ethers-lib.ts similarity index 96% rename from libs/remix-ws-templates/src/templates/remixDefault/scripts/ethers.ts rename to libs/remix-ws-templates/src/templates/remixDefault/scripts/ethers-lib.ts index 5f11f62e5f..40a478efbb 100644 --- a/libs/remix-ws-templates/src/templates/remixDefault/scripts/ethers.ts +++ b/libs/remix-ws-templates/src/templates/remixDefault/scripts/ethers-lib.ts @@ -1,3 +1,5 @@ +import { ethers } from 'ethers' + export const deploy = async (contractName: string, args: Array, from?: string): Promise => { console.log(`deploying ${contractName}`) diff --git a/libs/remix-ws-templates/src/templates/remixDefault/scripts/web3.ts b/libs/remix-ws-templates/src/templates/remixDefault/scripts/web3-lib.ts similarity index 92% rename from libs/remix-ws-templates/src/templates/remixDefault/scripts/web3.ts rename to libs/remix-ws-templates/src/templates/remixDefault/scripts/web3-lib.ts index 975a7176b4..9ec1a2d864 100644 --- a/libs/remix-ws-templates/src/templates/remixDefault/scripts/web3.ts +++ b/libs/remix-ws-templates/src/templates/remixDefault/scripts/web3-lib.ts @@ -1,5 +1,8 @@ +import Web3 from 'web3' + export const deploy = async (contractName: string, args: Array, from?: string, gas?: number): Promise => { + const web3 = new Web3(window.web3Provider) console.log(`deploying ${contractName}`) // Note that the script needs the ABI which is generated from the compilation artifact. // Make sure contract is compiled and artifacts are generated diff --git a/libs/remixd/src/bin/remixd.ts b/libs/remixd/src/bin/remixd.ts index d315b44b8e..a7ad050ba6 100644 --- a/libs/remixd/src/bin/remixd.ts +++ b/libs/remixd/src/bin/remixd.ts @@ -85,6 +85,8 @@ function errorHandler (error: any, service: string) { console.log('\x1b[33m%s\x1b[0m', '[WARN] You may now only use IDE at ' + program.remixIde + ' to connect to that instance') } + if (!program.sharedFolder) program.sharedFolder = process.cwd() // if no specified, use the current folder + if (program.sharedFolder && existsSync(absolutePath('./', program.sharedFolder))) { console.log('\x1b[33m%s\x1b[0m', '[WARN] Any application that runs on your computer can potentially read from and write to all files in the directory.') console.log('\x1b[33m%s\x1b[0m', '[WARN] Symbolic links are not forwarded to Remix IDE\n')