Merge branch 'master' into editorcontext

editorcontextDummy
bunsenstraat 3 years ago committed by GitHub
commit a26bb20e0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 120
      README.md
  2. 10
      apps/remix-ide-e2e/src/tests/workspace.test.ts
  3. 1
      apps/remix-ide/src/app/editor/editor.js
  4. 6
      apps/remix-ide/src/app/files/fileProvider.js
  5. 4
      apps/remix-ide/src/app/panels/tab-proxy.js
  6. 8
      apps/remix-ide/src/app/tabs/compile-and-run.ts
  7. 6177
      libs/remix-ui/editor/src/lib/remix-plugin-types.ts
  8. 2
      libs/remix-ui/editor/src/lib/remix-ui-editor.tsx
  9. 135
      libs/remix-ui/editor/src/lib/web-types.ts
  10. 10
      libs/remix-ui/workspace/src/lib/actions/events.ts
  11. 2
      libs/remix-ui/workspace/src/lib/actions/workspace.ts
  12. 1
      libs/remix-ui/workspace/src/lib/components/file-explorer.tsx
  13. 11
      libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx
  14. 1
      libs/remix-ui/workspace/src/lib/templates/blank.ts
  15. 125
      libs/remix-ui/workspace/src/lib/templates/erc20.ts
  16. 2
      libs/remix-ui/workspace/src/lib/templates/index.ts
  17. 2
      libs/remix-ws-templates/src/index.ts
  18. 16
      libs/remix-ws-templates/src/templates/erc20/index.ts
  19. 5
      libs/remix-ws-templates/src/templates/ozerc20/contracts/SampleERC20.sol
  20. 16
      libs/remix-ws-templates/src/templates/ozerc20/index.ts
  21. 2
      libs/remix-ws-templates/src/templates/ozerc20/scripts/deploy_with_ethers.ts
  22. 2
      libs/remix-ws-templates/src/templates/ozerc20/scripts/deploy_with_web3.ts
  23. 3
      libs/remix-ws-templates/src/templates/ozerc20/scripts/ethers-lib.ts
  24. 3
      libs/remix-ws-templates/src/templates/ozerc20/scripts/web3-lib.ts
  25. 0
      libs/remix-ws-templates/src/templates/ozerc20/tests/SampleERC20_test.sol
  26. 10
      libs/remix-ws-templates/src/templates/remixDefault/index.ts
  27. 2
      libs/remix-ws-templates/src/templates/remixDefault/scripts/deploy_with_ethers.ts
  28. 2
      libs/remix-ws-templates/src/templates/remixDefault/scripts/deploy_with_web3.ts
  29. 2
      libs/remix-ws-templates/src/templates/remixDefault/scripts/ethers-lib.ts
  30. 3
      libs/remix-ws-templates/src/templates/remixDefault/scripts/web3-lib.ts
  31. 2
      libs/remixd/src/bin/remixd.ts

@ -141,69 +141,129 @@ To run the Selenium tests via Nightwatch:
for Firefox: `npm run nightwatch_local_firefox`, or for Firefox: `npm run nightwatch_local_firefox`, or
for Google Chrome: `npm run nightwatch_local_chrome` 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_ballot
- npm run nightwatch_local_usingWorker The package.json file contains a list of all the tests you can run.
- npm run nightwatch_local_libraryDeployment **NOTE:**
- npm run nightwatch_local_solidityImport - **The `ballot` tests suite** requires to run `ganache-cli` locally.
- npm run nightwatch_local_recorder - **The `remixd` tests suite** requires to run `remixd` locally.
- npm run nightwatch_local_transactionExecution - **The `gist` tests suite** requires specifying a github access token in **.env file**.
```
gist_token = <token> // token should have permission to create a gist
```
- npm run nightwatch_local_staticAnalysis ### Using 'select_test' for locally running specific tests
- npm run nightwatch_local_signingMessage There is a script to allow selecting the browser and a specific test to run:
- npm run nightwatch_local_specialFunctions ```
npm run select_test
```
- npm run nightwatch_local_solidityUnitTests You need to have
- npm run nightwatch_local_remixd # remixd needs to be run - selenium running
- npm run nightwatch_local_terminal - the IDE running
- npm run nightwatch_local_gist - optionally have remixd or ganache running
- npm run nightwatch_local_workspace ### Splitting tests with groups
- npm run nightwatch_local_defaultLayout 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_pluginManager 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_publishContract 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_generalSettings There is no need to number the groups in a certain order. The number of the group is arbitrary.
- npm run nightwatch_local_fileExplorer A test can have multiple group tags, this means that this test will run in different groups.
- npm run nightwatch_local_debugger You should write your tests so they can be executed in groups and not depend on other groups.
- npm run nightwatch_local_editor To do this you need to:
- npm run nightwatch_local_compiler - 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.
- npm run nightwatch_local_txListener ```
'Should generate test file #group1': function (browser: NightwatchBrowser) {
browser.waitForElementPresent('*[data-id="verticalIconsKindfilePanel"]')
```
- npm run nightwatch_local_fileManager - add '@disable': true to the test file you want to split:
- npm run nightwatch_local_runAndDeploy ```
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",
```
**NOTE:** - run the build script to build the test files if you want to run the locally
- **The `ballot` tests suite** requires to run `ganache-cli` locally. ```
npm run build:e2e
```
- **The `remixd` tests suite** requires to run `remixd` locally. ### Locally testing group tests
- **The `gist` tests suite** requires specifying a github access token in **.env file**. 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
``` ```
gist_token = <token> // token should have permission to create a gist 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 ## Important Links

@ -51,8 +51,8 @@ module.exports = {
.assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts"]') .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts"]')
.assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/deploy_with_web3.ts"]') .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/deploy_with_web3.ts"]')
.assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/deploy_with_ethers.ts"]') .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/deploy_with_ethers.ts"]')
.assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/web3.ts"]') .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/web3-lib.ts"]')
.assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/ethers.ts"]') .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/ethers-lib.ts"]')
.assert.elementPresent('*[data-id="treeViewLitreeViewItemtests"]') .assert.elementPresent('*[data-id="treeViewLitreeViewItemtests"]')
.assert.elementPresent('*[data-id="treeViewLitreeViewItemtests/storage.test.js"]') .assert.elementPresent('*[data-id="treeViewLitreeViewItemtests/storage.test.js"]')
.assert.elementPresent('*[data-id="treeViewLitreeViewItemtests/Ballot_test.sol"]') .assert.elementPresent('*[data-id="treeViewLitreeViewItemtests/Ballot_test.sol"]')
@ -89,7 +89,7 @@ module.exports = {
// eslint-disable-next-line dot-notation // eslint-disable-next-line dot-notation
.execute(function () { document.querySelector('*[data-id="modalDialogCustomPromptTextCreate"]')['value'] = 'workspace_erc20' }) .execute(function () { document.querySelector('*[data-id="modalDialogCustomPromptTextCreate"]')['value'] = 'workspace_erc20' })
.click('select[id="wstemplate"]') .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') .waitForElementPresent('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok')
.execute(function () { (document.querySelector('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') as HTMLElement).click() }) .execute(function () { (document.querySelector('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') as HTMLElement).click() })
.pause(1000) .pause(1000)
@ -98,8 +98,8 @@ module.exports = {
.assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts"]') .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts"]')
.assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/deploy_with_web3.ts"]') .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/deploy_with_web3.ts"]')
.assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/deploy_with_ethers.ts"]') .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/deploy_with_ethers.ts"]')
.assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/web3.ts"]') .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/web3-lib.ts"]')
.assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/ethers.ts"]') .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/ethers-lib.ts"]')
.assert.elementPresent('*[data-id="treeViewLitreeViewItemtests"]') .assert.elementPresent('*[data-id="treeViewLitreeViewItemtests"]')
.assert.elementPresent('*[data-id="treeViewLitreeViewItemtests/SampleERC20_test.sol"]') .assert.elementPresent('*[data-id="treeViewLitreeViewItemtests/SampleERC20_test.sol"]')
}, },

@ -143,6 +143,7 @@ class Editor extends Plugin {
this.on('fileManager', 'fileClosed', (name) => { this.on('fileManager', 'fileClosed', (name) => {
if (name === this.currentFile) { if (name === this.currentFile) {
this.currentFile = null this.currentFile = null
this.renderComponent()
} }
}) })
this.on('theme', 'themeLoaded', (theme) => { this.on('theme', 'themeLoaded', (theme) => {

@ -135,16 +135,12 @@ class FileProvider {
if (!await window.remixFileSystem.exists(currentCheck)) { if (!await window.remixFileSystem.exists(currentCheck)) {
try { try {
await window.remixFileSystem.mkdir(currentCheck) await window.remixFileSystem.mkdir(currentCheck)
this.event.emit('folderAdded', this._normalizePath(currentCheck))
} catch (error) { } catch (error) {
console.log(error) console.log(error)
} }
} }
} }
currentCheck = ''
for (const value of paths) {
currentCheck = currentCheck + '/' + value
this.event.emit('folderAdded', this._normalizePath(currentCheck))
}
if (cb) cb() if (cb) cb()
} }

@ -153,6 +153,10 @@ export class TabProxy extends Plugin {
displayName, displayName,
() => this.emit('switchApp', name), () => 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.emit('closeApp', name)
this.call('manager', 'deactivatePlugin', name) this.call('manager', 'deactivatePlugin', name)
}, },

@ -34,11 +34,11 @@ export class CompileAndRun extends Plugin {
e.preventDefault() e.preventDefault()
this.targetFileName = file this.targetFileName = file
await this.call('solidity', 'compile', 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')) { } else if (file.endsWith('.js') || file.endsWith('.ts')) {
e.preventDefault() e.preventDefault()
this.runScript(file, false) 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) { runScriptAfterCompilation (fileName: string) {
this.targetFileName = fileName this.targetFileName = fileName
_paq.push(['trackEvent', 'ScriptExecutor', 'request_run_script']) _paq.push(['trackEvent', 'ScriptExecutor', 'CompileAndRun', 'request_run_script'])
} }
async runScript (fileName, clearAllInstances) { async runScript (fileName, clearAllInstances) {
@ -78,7 +78,7 @@ export class CompileAndRun extends Plugin {
const file = contract.object.devdoc['custom:dev-run-script'] const file = contract.object.devdoc['custom:dev-run-script']
if (file) { if (file) {
this.runScript(file, true) this.runScript(file, true)
_paq.push(['trackEvent', 'ScriptExecutor', 'run_script_after_compile']) _paq.push(['trackEvent', 'ScriptExecutor', 'CompileAndRun', 'run_script_after_compile'])
} else { } else {
this.call('notification', 'toast', 'You have not set a script to run. Set it with @custom:dev-run-script NatSpec tag.') this.call('notification', 'toast', 'You have not set a script to run. Set it with @custom:dev-run-script NatSpec tag.')
} }

File diff suppressed because it is too large Load Diff

@ -236,7 +236,7 @@ export const EditorUI = (props: EditorUIProps) => {
useEffect(() => { useEffect(() => {
if (!editorRef.current) return if (!editorRef.current || !props.currentFile) return
currentFileRef.current = props.currentFile currentFileRef.current = props.currentFile
const file = editorModelsState[props.currentFile] const file = editorModelsState[props.currentFile]
editorRef.current.setModel(file.model) editorRef.current.setModel(file.model)

@ -1,132 +1,184 @@
import { remixTypes } from './remix-plugin-types'
export const loadTypes = async (monaco) => { export const loadTypes = async (monaco) => {
// ethers.js // ethers.js
// @ts-ignore // @ts-ignore
const ethersAbi = await import('raw-loader!@ethersproject/abi/lib/index.d.ts') 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 // @ts-ignore
const ethersAbstract = await import('raw-loader!@ethersproject/abstract-provider/lib/index.d.ts') 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 // @ts-ignore
const ethersSigner = await import('raw-loader!@ethersproject/abstract-signer/lib/index.d.ts') 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 // @ts-ignore
const ethersAddress = await import('raw-loader!@ethersproject/address/lib/index.d.ts') 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 // @ts-ignore
const ethersBase64 = await import('raw-loader!@ethersproject/base64/lib/index.d.ts') 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 // @ts-ignore
const ethersBasex = await import('raw-loader!@ethersproject/basex/lib/index.d.ts') 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 // @ts-ignore
const ethersBignumber = await import('raw-loader!@ethersproject/bignumber/lib/index.d.ts') 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 // @ts-ignore
const ethersBytes = await import('raw-loader!@ethersproject/bytes/lib/index.d.ts') 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 // @ts-ignore
const ethersConstants = await import('raw-loader!@ethersproject/constants/lib/index.d.ts') 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 // @ts-ignore
const ethersContracts = await import('raw-loader!@ethersproject/contracts/lib/index.d.ts') 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 // @ts-ignore
const ethersHash = await import('raw-loader!@ethersproject/hash/lib/index.d.ts') 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 // @ts-ignore
const ethersHdnode = await import('raw-loader!@ethersproject/hdnode/lib/index.d.ts') 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 // @ts-ignore
const ethersJsonWallets = await import('raw-loader!@ethersproject/json-wallets/lib/index.d.ts') 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 // @ts-ignore
const ethersKeccak256 = await import('raw-loader!@ethersproject/keccak256/lib/index.d.ts') 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 // @ts-ignore
const ethersLogger = await import('raw-loader!@ethersproject/logger/lib/index.d.ts') 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 // @ts-ignore
const ethersNetworks = await import('raw-loader!@ethersproject/networks/lib/index.d.ts') 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 // @ts-ignore
const ethersPbkdf2 = await import('raw-loader!@ethersproject/pbkdf2/lib/index.d.ts') 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 // @ts-ignore
const ethersProperties = await import('raw-loader!@ethersproject/properties/lib/index.d.ts') 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 // @ts-ignore
const ethersProviders = await import('raw-loader!@ethersproject/providers/lib/index.d.ts') 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 // @ts-ignore
const ethersRandom = await import('raw-loader!@ethersproject/random/lib/index.d.ts') 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 // @ts-ignore
const ethersRlp = await import('raw-loader!@ethersproject/rlp/lib/index.d.ts') 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 // @ts-ignore
const ethersSha2 = await import('raw-loader!@ethersproject/sha2/lib/index.d.ts') 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 // @ts-ignore
const ethersSingningkey = await import('raw-loader!@ethersproject/signing-key/lib/index.d.ts') 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 // @ts-ignore
const ethersSolidity = await import('raw-loader!@ethersproject/solidity/lib/index.d.ts') 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 // @ts-ignore
const ethersStrings = await import('raw-loader!@ethersproject/strings/lib/index.d.ts') 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 // @ts-ignore
const ethersTransactions = await import('raw-loader!@ethersproject/transactions/lib/index.d.ts') 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 // @ts-ignore
const ethersUnits = await import('raw-loader!@ethersproject/units/lib/index.d.ts') 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 // @ts-ignore
const ethersWallet = await import('raw-loader!@ethersproject/wallet/lib/index.d.ts') 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 // @ts-ignore
const ethersWeb = await import('raw-loader!@ethersproject/web/lib/index.d.ts') 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 // @ts-ignore
const ethersWordlists = await import('raw-loader!@ethersproject/wordlists/lib/index.d.ts') 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 // @ts-ignore
const ethers = await import('raw-loader!ethers/lib/ethers.d.ts') 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 // @ts-ignore
const indexEthers = await import('raw-loader!ethers/lib/index.d.ts') 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`) monaco.languages.typescript.typescriptDefaults.addExtraLib(indexEthers.default, `file:///node_modules/@types/ethers/index.d.ts`)
// Web3 // Web3
@ -162,20 +214,13 @@ export const loadTypes = async (monaco) => {
// @ts-ignore // @ts-ignore
const indexWeb3Util = await import('raw-loader!web3-utils/types/index.d.ts') 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`) monaco.languages.typescript.typescriptDefaults.addExtraLib(indexWeb3Util.default, `file:///node_modules/@types/web3-utils/index.d.ts`)
/*
// remix // remix
const indexRemixApi = remixTypes + `\n
// @ts-ignore declare global {
const indexRemixApi = await import('./remix-plugin-types') const remix: PluginClient;
monaco.languages.typescript.typescriptDefaults.addExtraLib(indexRemixApi.types) const web3Provider;
*/ }
`
monaco.languages.typescript.typescriptDefaults.addExtraLib(` monaco.languages.typescript.typescriptDefaults.addExtraLib(indexRemixApi)
import { PluginClient } from 'packages/plugin/core/src/lib/client'
declare const remix: PluginClient
`)
console.log('loaded monaco types') console.log('loaded monaco types')
} }

@ -49,6 +49,16 @@ export const listenOnPluginEvents = (filePanelPlugin) => {
plugin.on('fileManager', 'fileClosed', async (file: string) => { plugin.on('fileManager', 'fileClosed', async (file: string) => {
dispatch(removeFocus(file)) 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<any>) => { export const listenOnProviderEvents = (provider) => (reducerDispatch: React.Dispatch<any>) => {

@ -12,6 +12,7 @@ import * as templateWithContent from '@remix-project/remix-ws-templates'
const LOCALHOST = ' - connect to localhost - ' const LOCALHOST = ' - connect to localhost - '
const NO_WORKSPACE = ' - none - ' const NO_WORKSPACE = ' - none - '
const queryParams = new QueryParams() const queryParams = new QueryParams()
const _paq = window._paq = window._paq || [] //eslint-disable-line
let plugin, dispatch: React.Dispatch<any> let plugin, dispatch: React.Dispatch<any>
export const setPlugin = (filePanelPlugin, reducerDispatch) => { export const setPlugin = (filePanelPlugin, reducerDispatch) => {
@ -154,6 +155,7 @@ export const loadWorkspacePreset = async (template: WorkspaceTemplate = 'remixDe
try { try {
const templateList = Object.keys(templateWithContent) const templateList = Object.keys(templateWithContent)
if (!templateList.includes(template)) break if (!templateList.includes(template)) break
_paq.push(['trackEvent', 'workspace', 'template', template])
// @ts-ignore // @ts-ignore
const files = await templateWithContent[template]() const files = await templateWithContent[template]()
for (const file in files) { for (const file in files) {

@ -78,7 +78,6 @@ export const FileExplorer = (props: FileExplorerProps) => {
targetDocument.addEventListener('keydown', keyPressHandler) targetDocument.addEventListener('keydown', keyPressHandler)
targetDocument.addEventListener('keyup', keyUpHandler) targetDocument.addEventListener('keyup', keyUpHandler)
targetDocument.focus()
return () => { return () => {
targetDocument.removeEventListener('keydown', keyPressHandler) targetDocument.removeEventListener('keydown', keyPressHandler)
targetDocument.removeEventListener('keyup', keyUpHandler) targetDocument.removeEventListener('keyup', keyUpHandler)

@ -119,16 +119,21 @@ export function Workspace () {
} }
} }
const updateWsName = () => {
// @ts-ignore
workspaceCreateInput.current.value = `${workspaceCreateTemplateInput.current.value || 'remixDefault'}_${Date.now()}`
}
const createModalMessage = () => { const createModalMessage = () => {
return ( return (
<> <>
<label id="wsName" className="form-check-label">Workspace name</label> <label id="wsName" className="form-check-label">Workspace name</label>
<input type="text" data-id="modalDialogCustomPromptTextCreate" defaultValue={`workspace_${Date.now()}`} ref={workspaceCreateInput} className="form-control" /><br/> <input type="text" data-id="modalDialogCustomPromptTextCreate" defaultValue={`remixDefault_${Date.now()}`} ref={workspaceCreateInput} className="form-control" /><br/>
<label id="selectWsTemplate" className="form-check-label">Choose a template</label> <label id="selectWsTemplate" className="form-check-label">Choose a template</label>
<select name="wstemplate" className="form-control custom-select" id="wstemplate" defaultValue='remixDefault' ref={workspaceCreateTemplateInput}> <select name="wstemplate" className="form-control custom-select" id="wstemplate" defaultValue='remixDefault' ref={workspaceCreateTemplateInput} onChange={updateWsName}>
<option value='remixDefault'>Default</option> <option value='remixDefault'>Default</option>
<option value='blank'>Blank</option> <option value='blank'>Blank</option>
<option value='erc20'>ERC20</option> <option value='ozerc20'>OpenZeppelin ERC20</option>
</select> </select>
</> </>
) )

@ -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<any>, 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<any>`
const libEthers = `
export const deploy = async (contractName: string, args: Array<any>, 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<any>`
/* 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 },
}

@ -1,2 +0,0 @@
export { default as erc20 } from './erc20'
export { default as blank } from './blank'

@ -1,3 +1,3 @@
export { default as remixDefault } from './templates/remixDefault' export { default as remixDefault } from './templates/remixDefault'
export { default as erc20 } from './templates/erc20' export { default as ozerc20 } from './templates/ozerc20'
export { default as blank } from './templates/blank' export { default as blank } from './templates/blank'

@ -1,16 +0,0 @@
export default async () => {
return {
// @ts-ignore
'contracts/SampleERC20.sol': (await import('raw-loader!./contracts/SampleERC20.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.ts': (await import('!!raw-loader!./scripts/ethers.ts')).default,
// @ts-ignore
'scripts/web3.ts': (await import('!!raw-loader!./scripts/web3.ts')).default,
// @ts-ignore
'tests/SampleERC20_test.sol': (await import('raw-loader!./tests/SampleERC20_test.sol')).default
}
}

@ -2,13 +2,12 @@
pragma solidity >=0.7.0 <0.9.0; pragma solidity >=0.7.0 <0.9.0;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
/** /**
* @title SampleERC20 * @title SampleERC20
* @dev Create a sample ERC20 standard token * @dev Create a sample ERC20 standard token
*/ */
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract SampleERC20 is ERC20 { contract SampleERC20 is ERC20 {
constructor(string memory tokenName, string memory tokenSymbol) ERC20(tokenName, tokenSymbol) {} constructor(string memory tokenName, string memory tokenSymbol) ERC20(tokenName, tokenSymbol) {}

@ -0,0 +1,16 @@
export default async () => {
return {
// @ts-ignore
'contracts/SampleERC20.sol': (await import('raw-loader!./contracts/SampleERC20.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/SampleERC20_test.sol': (await import('raw-loader!./tests/SampleERC20_test.sol')).default
}
}

@ -1,4 +1,4 @@
import { deploy } from './ethers' import { deploy } from './ethers-lib'
(async () => { (async () => {
try { try {

@ -1,4 +1,4 @@
import { deploy } from './web3' import { deploy } from './web3-lib'
(async () => { (async () => {
try { try {

@ -1,5 +1,4 @@
import { ethers } from 'ethers-lib'
export const deploy = async (contractName: string, args: Array<any>, from?: string): Promise<any> => { export const deploy = async (contractName: string, args: Array<any>, from?: string): Promise<any> => {

@ -1,5 +1,8 @@
import Web3 from 'web3-lib'
export const deploy = async (contractName: string, args: Array<any>, from?: string, gas?: number): Promise<any> => { export const deploy = async (contractName: string, args: Array<any>, from?: string, gas?: number): Promise<any> => {
const web3 = new Web3(window.web3Provider)
console.log(`deploying ${contractName}`) console.log(`deploying ${contractName}`)
// Note that the script needs the ABI which is generated from the compilation artifact. // Note that the script needs the ABI which is generated from the compilation artifact.
// Make sure contract is compiled and artifacts are generated // Make sure contract is compiled and artifacts are generated

@ -7,17 +7,17 @@ export default async () => {
// @ts-ignore // @ts-ignore
'contracts/3_Ballot.sol': (await import('raw-loader!./contracts/3_Ballot.sol')).default, 'contracts/3_Ballot.sol': (await import('raw-loader!./contracts/3_Ballot.sol')).default,
// @ts-ignore // @ts-ignore
'scripts/deploy_with_ethers.ts': (await import('!!raw-loader!./scripts/deploy_with_ethers.ts')).default, 'scripts/deploy_with_ethers.ts': (await import('raw-loader!./scripts/deploy_with_ethers.ts')).default,
// @ts-ignore // @ts-ignore
'scripts/deploy_with_web3.ts': (await import('!!raw-loader!./scripts/deploy_with_web3.ts')).default, 'scripts/deploy_with_web3.ts': (await import('raw-loader!./scripts/deploy_with_web3.ts')).default,
// @ts-ignore // @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 // @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 // @ts-ignore
'tests/Ballot_test.sol': (await import('raw-loader!./tests/Ballot_test.sol')).default, 'tests/Ballot_test.sol': (await import('raw-loader!./tests/Ballot_test.sol')).default,
// @ts-ignore // @ts-ignore
'tests/storage.test.js': (await import('!!raw-loader!./tests/storage.test.js')).default, 'tests/storage.test.js': (await import('raw-loader!./tests/storage.test.js')).default,
// @ts-ignore // @ts-ignore
'README.txt': (await import('raw-loader!./README.txt')).default, 'README.txt': (await import('raw-loader!./README.txt')).default,
} }

@ -2,7 +2,7 @@
// Please make sure to compile "./contracts/1_Storage.sol" file before running this script. // 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 // 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 () => { (async () => {
try { try {

@ -2,7 +2,7 @@
// Please make sure to compile "./contracts/1_Storage.sol" file before running this script. // 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 // 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 () => { (async () => {
try { try {

@ -1,3 +1,5 @@
import { ethers } from 'ethers'
export const deploy = async (contractName: string, args: Array<any>, from?: string): Promise<any> => { export const deploy = async (contractName: string, args: Array<any>, from?: string): Promise<any> => {
console.log(`deploying ${contractName}`) console.log(`deploying ${contractName}`)

@ -1,5 +1,8 @@
import Web3 from 'web3'
export const deploy = async (contractName: string, args: Array<any>, from?: string, gas?: number): Promise<any> => { export const deploy = async (contractName: string, args: Array<any>, from?: string, gas?: number): Promise<any> => {
const web3 = new Web3(window.web3Provider)
console.log(`deploying ${contractName}`) console.log(`deploying ${contractName}`)
// Note that the script needs the ABI which is generated from the compilation artifact. // Note that the script needs the ABI which is generated from the compilation artifact.
// Make sure contract is compiled and artifacts are generated // Make sure contract is compiled and artifacts are generated

@ -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') 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))) { 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] 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') console.log('\x1b[33m%s\x1b[0m', '[WARN] Symbolic links are not forwarded to Remix IDE\n')

Loading…
Cancel
Save