parent
aad2dfbce8
commit
66f5deb7ad
@ -0,0 +1,63 @@ |
||||
# See http://help.github.com/ignore-files/ for more about ignoring files. |
||||
|
||||
build |
||||
dist |
||||
node_modules |
||||
lint.xml |
||||
reports/* |
||||
babelify-src |
||||
docs/_build |
||||
.DS_Store |
||||
.tern-port |
||||
TODO |
||||
soljson.js |
||||
*~ |
||||
*_group*.*.ts |
||||
*_group*.ts |
||||
stats.json |
||||
|
||||
|
||||
# compiled output |
||||
/dist |
||||
/tmp |
||||
/out-tsc |
||||
|
||||
# dependencies |
||||
/node_modules |
||||
|
||||
# IDEs and editors |
||||
/.idea |
||||
.project |
||||
.classpath |
||||
.c9/ |
||||
*.launch |
||||
.settings/ |
||||
*.sublime-workspace |
||||
.vscode/ |
||||
|
||||
# IDE - VSCode |
||||
.vscode/* |
||||
!.vscode/settings.json |
||||
!.vscode/tasks.json |
||||
!.vscode/launch.json |
||||
!.vscode/extensions.json |
||||
|
||||
# misc |
||||
/.sass-cache |
||||
/connect.lock |
||||
/coverage |
||||
/libpeerconnection.log |
||||
npm-debug.log |
||||
lerna-debug.log |
||||
yarn-error.log |
||||
testem.log |
||||
/typings |
||||
|
||||
# System Files |
||||
.DS_Store |
||||
.vscode/settings.json |
||||
.vscode/launch.json |
||||
libs/remix-node/ |
||||
libs/remix-niks/ |
||||
|
||||
apps/remix-react |
@ -0,0 +1,289 @@ |
||||
<p align="center"> |
||||
<img src="./apps/remix-ide/src/assets/img/icon.png" alt="Remix Logo" width="200"/> |
||||
</p> |
||||
<h3 align="center">Remix Project</h3> |
||||
|
||||
<div align="center"> |
||||
|
||||
|
||||
[](https://circleci.com/gh/ethereum/remix-project) |
||||
[](https://remix-ide.readthedocs.io/en/latest/index.html) |
||||
[](https://github.com/ethereum/remix-project/blob/master/CONTRIBUTING.md) |
||||
[](https://github.com/ethereum/remix-project/blob/master/CONTRIBUTING.md) |
||||
[](https://github.com/ethereum/awesome-remix) |
||||
 |
||||
[](https://gitter.im/ethereum/remix) |
||||
[](https://twitter.com/ethereumremix) |
||||
|
||||
</div> |
||||
|
||||
## Remix Project |
||||
|
||||
**Remix Project** is a rich toolset including Remix IDE, a comprehensive smart contract development tool. The Remix Project also includes Remix Plugin Engine and Remix Libraries which are low-level tools for wider use. |
||||
|
||||
## Remix IDE |
||||
**Remix IDE** is used for the entire journey of contract development by users of any knowledge level. It fosters a fast development cycle and has a rich set of plugins with intuitive GUIs. The IDE comes in 2 flavors and a VSCode extension: |
||||
|
||||
**Remix Online IDE**, see: [https://remix.ethereum.org](https://remix.ethereum.org) |
||||
|
||||
:point_right: Supported browsers: Firefox v100.0.1 & Chrome v101.0.4951.64. No support for Remix's use on tablets or smartphones or telephones. |
||||
|
||||
**Remix Desktop IDE**, see releases: [https://github.com/ethereum/remix-desktop/releases](https://github.com/ethereum/remix-desktop/releases) |
||||
|
||||
 |
||||
|
||||
**VSCode extension**, see: [Ethereum-Remix](https://marketplace.visualstudio.com/items?itemName=RemixProject.ethereum-remix) |
||||
|
||||
## Remix libraries |
||||
Remix libraries are essential for Remix IDE's native plugins. Read more about libraries [here](libs/README.md) |
||||
|
||||
## Offline Usage |
||||
|
||||
The `gh-pages` branch of [remix-live](https://github.com/ethereum/remix-live) always has the latest stable build of Remix. It contains a ZIP file with the entire build. Download it to use offline. |
||||
|
||||
Note: It contains the latest supported version of Solidity available at the time of the packaging. Other compiler versions can be used online only. |
||||
|
||||
|
||||
## Setup |
||||
|
||||
* Install **Yarn** and **Node.js**. See [Guide for NodeJs](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) and [Yarn install](https://classic.yarnpkg.com/lang/en/docs/install)<br/> |
||||
*Supported versions:* |
||||
```bash |
||||
"engines": { |
||||
"node": "^14.17.6", |
||||
"npm": "^6.14.15" |
||||
} |
||||
``` |
||||
* Install [Nx CLI](https://nx.dev/using-nx/nx-cli) globally to enable running **nx executable commands**. |
||||
```bash |
||||
yarn global add nx |
||||
``` |
||||
* Clone the GitHub repository (`wget` need to be installed first): |
||||
|
||||
```bash |
||||
git clone https://github.com/ethereum/remix-project.git |
||||
``` |
||||
* Build `remix-project`: |
||||
```bash |
||||
cd remix-project |
||||
yarn install |
||||
yarn run build:libs // Build remix libs |
||||
nx build |
||||
nx serve |
||||
``` |
||||
|
||||
Open `http://127.0.0.1:8080` in your browser to load Remix IDE locally. |
||||
|
||||
Go to your `text editor` and start developing. The browser will automatically refresh when files are saved. |
||||
|
||||
## Production Build |
||||
To generate react production builds for remix-project. |
||||
```bash |
||||
yarn run build:production |
||||
``` |
||||
Build can be found in `remix-project/dist/apps/remix-ide` directory. |
||||
|
||||
```bash |
||||
yarn run serve:production |
||||
``` |
||||
Production build will be served by default to `http://localhost:8080/` or `http://127.0.0.1:8080/` |
||||
|
||||
## Docker: |
||||
|
||||
Prerequisites: |
||||
* Docker (https://docs.docker.com/desktop/) |
||||
* Docker Compose (https://docs.docker.com/compose/install/) |
||||
|
||||
### Run with docker |
||||
|
||||
If you want to run the latest changes that are merged into the master branch then run: |
||||
|
||||
``` |
||||
docker pull remixproject/remix-ide:latest |
||||
docker run -p 8080:80 remixproject/remix-ide:latest |
||||
``` |
||||
|
||||
If you want to run the latest remix-live release run. |
||||
``` |
||||
docker pull remixproject/remix-ide:remix_live |
||||
docker run -p 8080:80 remixproject/remix-ide:remix_live |
||||
``` |
||||
|
||||
### Run with docker-compose: |
||||
|
||||
To run locally without building you only need docker-compose.yaml file and you can run: |
||||
|
||||
``` |
||||
docker-compose pull |
||||
docker-compose up -d |
||||
``` |
||||
|
||||
Then go to http://localhost:8080 and you can use your Remix instance. |
||||
|
||||
To fetch the docker-compose file without cloning this repo run: |
||||
``` |
||||
curl https://raw.githubusercontent.com/ethereum/remix-project/master/docker-compose.yaml > docker-compose.yaml |
||||
``` |
||||
|
||||
### Troubleshooting |
||||
|
||||
If you have trouble building the project, make sure that you have the correct version of `node`, `npm` and `nvm`. Also, ensure [Nx CLI](https://nx.dev/using-nx/nx-cli) is installed globally. |
||||
|
||||
Run: |
||||
|
||||
```bash |
||||
node --version |
||||
npm --version |
||||
nvm --version |
||||
``` |
||||
|
||||
In Debian-based OS such as Ubuntu 14.04LTS, you may need to run `apt-get install build-essential`. After installing `build-essential`, run `npm rebuild`. |
||||
|
||||
## Unit Testing |
||||
|
||||
Run the unit tests using library name like: `nx test <project-name>` |
||||
|
||||
For example, to run unit tests of `remix-analyzer`, use `nx test remix-analyzer` |
||||
|
||||
## Browser Testing |
||||
|
||||
To run the Selenium tests via Nightwatch: |
||||
|
||||
- Install Selenium for the first time: `yarn run selenium-install` |
||||
- Run a selenium server: `yarn run selenium` |
||||
- Build & Serve Remix: `nx serve` |
||||
- Run all the end-to-end tests: |
||||
|
||||
for Firefox: `yarn run nightwatch_local_firefox`, or |
||||
|
||||
for Google Chrome: `yarn run nightwatch_local_chrome` |
||||
- Run a specific test case instead, use a command like this: |
||||
|
||||
- yarn run nightwatch_local_ballot |
||||
|
||||
The package.json file contains a list of all the tests you can run. |
||||
|
||||
**NOTE:** |
||||
|
||||
- **The `ballot` tests suite** requires running `ganache-cli` locally. |
||||
|
||||
- **The `remixd` tests suite** requires running `remixd` locally. |
||||
|
||||
- **The `gist` tests suite** requires specifying a GitHub access token in **.env file**. |
||||
``` |
||||
gist_token = <token> // token should have permission to create a gist |
||||
``` |
||||
|
||||
### Using 'select_test' for locally running specific tests |
||||
|
||||
There is a script to allow selecting the browser and a specific test to run: |
||||
|
||||
``` |
||||
yarn run select_test |
||||
``` |
||||
|
||||
You need to have |
||||
|
||||
- selenium running |
||||
|
||||
- the IDE running |
||||
|
||||
- optionally have remixd or ganache running |
||||
|
||||
### Splitting tests with groups |
||||
|
||||
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 |
||||
|
||||
These groups only apply to the test file, not across all test files. So for example group1 in the ballot is not related to a group1 in another test file. |
||||
|
||||
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 perform common actions. |
||||
|
||||
There is no need to number the groups in a certain order. The number of the group is arbitrary. |
||||
|
||||
A test can have multiple group tags, this means that this test will run in different groups. |
||||
|
||||
You should write your tests so they can be executed in groups and not depend on other groups. |
||||
|
||||
To do this you need to: |
||||
|
||||
- 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 a specific order. |
||||
|
||||
``` |
||||
'Should generate test file #group1': function (browser: NightwatchBrowser) { |
||||
browser.waitForElementPresent('*[data-id="verticalIconsKindfilePanel"]') |
||||
``` |
||||
|
||||
- add '@disabled': true to the test file you want to split: |
||||
|
||||
``` |
||||
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": "yarn 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 |
||||
|
||||
``` |
||||
yarn run build:e2e |
||||
``` |
||||
|
||||
### Locally testing group tests |
||||
|
||||
You can tag any test with a group name, 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 options menu, just select the test you want |
||||
``` |
||||
yarn run select_test |
||||
``` |
||||
#### method 2 |
||||
|
||||
``` |
||||
yarn 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 parallel. |
||||
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, the 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 |
||||
|
||||
- Official documentation: https://remix-ide.readthedocs.io/en/latest/ |
||||
- Curated list of Remix resources, tutorials etc.: https://github.com/ethereum/awesome-remix |
||||
- Medium: https://medium.com/remix-ide |
||||
- Twitter: https://twitter.com/ethereumremix |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,365 @@ |
||||
{ |
||||
"name": "remix-project", |
||||
"version": "0.31.0-dev", |
||||
"license": "MIT", |
||||
"description": "Ethereum Remix Monorepo", |
||||
"keywords": [ |
||||
"ethereum", |
||||
"solidity", |
||||
"compiler" |
||||
], |
||||
"repository": { |
||||
"type": "git", |
||||
"url": "git+https://github.com/ethereum/remix-project.git" |
||||
}, |
||||
"author": "@yann300", |
||||
"bugs": { |
||||
"url": "https://github.com/ethereum/remix-project/issues" |
||||
}, |
||||
"homepage": "https://github.com/ethereum/remix-project#readme", |
||||
"bin": { |
||||
"remix-ide": "./apps/remix-ide/bin/remix-ide" |
||||
}, |
||||
"engines": { |
||||
"node": "^14.17.6", |
||||
"npm": "^6.14.15" |
||||
}, |
||||
"scripts": { |
||||
"nx": "nx", |
||||
"start": "nx start", |
||||
"serve": "nx serve remix-ide --configuration=development", |
||||
"build": "nx build", |
||||
"test": "nx test", |
||||
"lint": "nx lint", |
||||
"affected:apps": "nx affected:apps", |
||||
"affected:libs": "nx affected:libs", |
||||
"affected:build": "nx affected:build", |
||||
"affected:test": "nx affected:test", |
||||
"affected:lint": "nx affected:lint", |
||||
"affected:dep-graph": "nx affected:dep-graph", |
||||
"affected": "nx affected", |
||||
"format": "nx format:write", |
||||
"format:write": "nx format:write", |
||||
"format:check": "nx format:check", |
||||
"update": "nx migrate latest", |
||||
"workspace-schematic": "nx workspace-schematic", |
||||
"dep-graph": "nx dep-graph", |
||||
"help": "nx help", |
||||
"lint:libs": "nx run-many --target=lint --projects=remix-analyzer,remix-astwalker,remix-debug,remix-lib,remix-simulator,remix-solidity,remix-tests,remix-url-resolver,remix-ws-templates,remixd,remix-ui-tree-view,remix-ui-modal-dialog,remix-ui-toaster,remix-ui-helper,remix-ui-debugger-ui,remix-ui-workspace,remix-ui-static-analyser,remix-ui-checkbox,remix-ui-settings,remix-core-plugin,remix-ui-renderer,remix-ui-publish-to-storage,remix-ui-solidity-compiler,solidity-unit-testing,remix-ui-plugin-manager,remix-ui-terminal,remix-ui-editor,remix-ui-app,remix-ui-tabs,remix-ui-panel,remix-ui-run-tab,remix-ui-permission-handler,remix-ui-search,remix-ui-file-decorators,remix-ui-tooltip-popup,ghaction-helper", |
||||
"build:libs": "nx run-many --target=build --parallel=false --with-deps=true --projects=remix-analyzer,remix-astwalker,remix-debug,remix-lib,remix-simulator,remix-solidity,remix-tests,remix-url-resolver,remix-ws-templates,remixd,ghaction-helper", |
||||
"test:libs": "nx run-many --target=test --projects=remix-analyzer,remix-astwalker,remix-debug,remix-lib,remix-simulator,remix-tests,remix-url-resolver,remixd", |
||||
"publish:libs": "yarn run build:libs && lerna publish --skip-git && yarn run bumpVersion:libs", |
||||
"publishDev:libs": "yarn run build:libs && lerna publish --npm-tag alpha --skip-git && yarn run bumpVersion:libs", |
||||
"build:e2e": "node apps/remix-ide-e2e/src/buildGroupTests.js && tsc -p apps/remix-ide-e2e/tsconfig.e2e.json", |
||||
"babel": "babel", |
||||
"watch:e2e": "nodemon", |
||||
"bumpVersion:libs": "gulp & gulp syncLibVersions;", |
||||
"browsertest": "sleep 5 && yarn run nightwatch_local", |
||||
"csslint": "csslint --ignore=order-alphabetical --errors='errors,duplicate-properties,empty-rules' --exclude-list='apps/remix-ide/src/assets/css/font-awesome.min.css' apps/remix-ide/src/assets/css/", |
||||
"downloadsolc_assets_e2e": "node ./apps/remix-ide/ci/download_e2e_assets.js", |
||||
"downloadsolc_assets": "wget --no-check-certificate https://binaries.soliditylang.org/wasm/soljson-v0.8.18+commit.87f61d96.js -O ./apps/remix-ide/src/assets/js/soljson.js && wget --no-check-certificate https://binaries.soliditylang.org/wasm/soljson-v0.8.18+commit.87f61d96.js -O ./apps/solidity-compiler/src/assets/js/soljson.js", |
||||
"downloadsolc_assets_dist": "wget --no-check-certificate https://binaries.soliditylang.org/wasm/soljson-v0.8.18+commit.87f61d96.js -O ./dist/apps/remix-ide/assets/js/soljson.js && wget --no-check-certificate https://binaries.soliditylang.org/wasm/soljson-v0.8.18+commit.87f61d96.js -O ./dist/apps/solidity-compiler/assets/js/soljson.js", |
||||
"make-mock-compiler": "node apps/remix-ide/ci/makeMockCompiler.js", |
||||
"minify": "uglifyjs --in-source-map inline --source-map-inline -c warnings=false", |
||||
"build:production": "NODE_ENV=production nx build remix-ide --configuration=production --skip-nx-cache", |
||||
"serve:production": "npx http-server ./dist/apps/remix-ide", |
||||
"select_test": "bash apps/remix-ide-e2e/src/select_tests.sh", |
||||
"group_test": "yarn run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/${npm_config_test}_group${npm_config_group}.test.js --env=${npm_config_env}", |
||||
"nightwatch_parallel": "yarn run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js --env=chrome,firefox", |
||||
"nightwatch_local_firefox": "yarn run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js --env=firefox", |
||||
"nightwatch_local_chrome": "yarn run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js --env=chrome", |
||||
"nightwatch_local_ballot": "yarn run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/ballot.test.js --env=chrome", |
||||
"nightwatch_local_ballot_0_4_14": "yarn run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/ballot_0_4_14.test.js --env=chrome", |
||||
"nightwatch_local_usingWorker": "yarn run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/usingWebWorker.test.js --env=chrome", |
||||
"nightwatch_local_libraryDeployment": "yarn run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/libraryDeployment.test.js --env=chrome", |
||||
"nightwatch_local_solidityImport": "yarn run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/solidityImport_*.test.js --env=chrome", |
||||
"nightwatch_local_recorder": "yarn run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/recorder.test.js --env=chrome", |
||||
"nightwatch_local_transactionExecution": "yarn run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/transactionExecution_*.test.js --env=chrome", |
||||
"nightwatch_local_staticAnalysis": "yarn run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/staticAnalysis.test.js --env=chrome", |
||||
"nightwatch_local_signingMessage": "yarn run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/signingMessage.test.js --env=chrome", |
||||
"nightwatch_local_specialFunctions": "yarn run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/specialFunctions_*.test.js --env=chrome", |
||||
"nightwatch_local_solidityUnitTests": "yarn run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/solidityUnittests_*.test.js --env=chrome", |
||||
"nightwatch_local_remixd": "yarn run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/remixd.test.js --env=chrome", |
||||
"nightwatch_local_terminal": "yarn run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/terminal_*.test.js --env=chrome", |
||||
"nightwatch_local_gist": "yarn run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/gist.test.js --env=chrome", |
||||
"nightwatch_local_workspace": "yarn run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/workspace.test.js --env=chrome", |
||||
"nightwatch_local_defaultLayout": "yarn run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/defaultLayout.test.js --env=chrome", |
||||
"nightwatch_local_pluginManager": "yarn run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/pluginManager.test.js --env=chrome", |
||||
"nightwatch_local_publishContract": "yarn run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/publishContract.test.js --env=chrome", |
||||
"nightwatch_local_generalSettings": "yarn run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/generalSettings.test.js --env=chrome", |
||||
"nightwatch_local_fileExplorer": "yarn run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/fileExplorer.test.js --env=chrome", |
||||
"nightwatch_local_debugger": "yarn run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/debugger_*.test.js --env=chrome", |
||||
"nightwatch_local_editor": "yarn run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/editor.test.js --env=chrome", |
||||
"nightwatch_local_importFromGithub": "yarn run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/importFromGithub.test.js --env=chrome", |
||||
"nightwatch_local_compiler": "yarn run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/compiler_api.test.js --env=chrome", |
||||
"nightwatch_local_txListener": "yarn run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/txListener.test.js --env=chrome", |
||||
"nightwatch_local_fileManager": "yarn run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/fileManager_api.test.js --env=chrome", |
||||
"nightwatch_local_runAndDeploy": "yarn run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/runAndDeploy.js --env=chrome-runAndDeploy", |
||||
"nightwatch_local_url": "yarn run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/url.test.js --env=chrome", |
||||
"nightwatch_local_verticalIconscontextmenu": "yarn run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/verticalIconsPanel.test.js --env=chrome", |
||||
"nightwatch_local_pluginApi": "yarn run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/plugin_api_*.js --env=chrome", |
||||
"nightwatch_local_migrate_filesystem": "yarn run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/migrateFileSystem.test.js --env=chrome", |
||||
"nightwatch_local_proxy": "yarn run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/proxy.test.js --env=chrome", |
||||
"nightwatch_local_stress_editor": "yarn run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/stressEditor.test.js --env=chromeDesktop", |
||||
"nightwatch_local_search": "yarn run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/search.test.js --env=chromeDesktop", |
||||
"nightwatch_local_providers": "yarn run build:e2e && nightwatch --config dist/apps/remix-ide-e2e/nightwatch.js dist/apps/remix-ide-e2e/src/tests/providers.test.js --env=chromeDesktop", |
||||
"onchange": "onchange apps/remix-ide/build/app.js -- npm-run-all lint", |
||||
"remixd": "nx build remixd && chmod +x dist/libs/remixd/src/bin/remixd.js && dist/libs/remixd/src/bin/remixd.js --remix-ide http://127.0.0.1:8080", |
||||
"simulator": "nx build remix-simulator && chmod +x dist/libs/remix-simulator/bin/ethsim && dist/libs/remix-simulator/bin/ethsim start --rpc", |
||||
"selenium": "selenium-standalone start", |
||||
"selenium-install": "selenium-standalone install", |
||||
"sourcemap": "exorcist --root ../ apps/remix-ide/build/app.js.map > apps/remix-ide/build/app.js", |
||||
"test-browser": "npm-run-all -lpr selenium make-mock-compiler serve browsertest", |
||||
"watch": "watchify apps/remix-ide/src/index.js -dv -p browserify-reload -o apps/remix-ide/build/app.js --exclude solc", |
||||
"reinstall": "rm ./node-modules/ -rf && rm yarn.lock && rm ./build/ -rf && yarn install & yarn run build", |
||||
"ganache-cli": "npx ganache-cli", |
||||
"build-contracts": "find ./node_modules/@openzeppelin/contracts | grep -i '.sol' > libs/remix-ui/editor/src/lib/providers/completion/contracts/contracts.txt && find ./node_modules/@uniswap/v3-core/contracts | grep -i '.sol' >> libs/remix-ui/editor/src/lib/providers/completion/contracts/contracts.txt" |
||||
}, |
||||
"dependencies": { |
||||
"@babel/plugin-proposal-class-properties": "^7.16.0", |
||||
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6", |
||||
"@erebos/bzz-node": "^0.13.0", |
||||
"@ethereumjs/block": "^4.1.0", |
||||
"@ethereumjs/common": "^3.0.2", |
||||
"@ethereumjs/evm": "^1.2.3", |
||||
"@ethereumjs/statemanager": "^1.0.2", |
||||
"@ethereumjs/tx": "^4.0.2", |
||||
"@ethereumjs/util": "^8.0.3", |
||||
"@ethereumjs/vm": "^6.3.0", |
||||
"@ethersphere/bee-js": "^3.2.0", |
||||
"@isomorphic-git/lightning-fs": "^4.4.1", |
||||
"@monaco-editor/react": "4.4.5", |
||||
"@openzeppelin/contracts": "^4.7.3", |
||||
"@openzeppelin/upgrades-core": "^1.22.0", |
||||
"@openzeppelin/wizard": "^0.1.1", |
||||
"@remixproject/engine": "^0.3.31", |
||||
"@remixproject/engine-web": "^0.3.31", |
||||
"@remixproject/plugin": "^0.3.31", |
||||
"@remixproject/plugin-api": "^0.3.31", |
||||
"@remixproject/plugin-utils": "^0.3.31", |
||||
"@remixproject/plugin-webview": "^0.3.31", |
||||
"@remixproject/plugin-ws": "^0.3.31", |
||||
"@types/nightwatch": "^2.3.1", |
||||
"ansi-gray": "^0.1.1", |
||||
"async": "^2.6.2", |
||||
"axios": "1.1.2", |
||||
"bn.js": "^5.1.2", |
||||
"bootstrap": "^5.2.2", |
||||
"brace": "^0.8.0", |
||||
"change-case": "^4.1.1", |
||||
"chokidar": "^2.1.8", |
||||
"color-support": "^1.1.3", |
||||
"commander": "^9.4.1", |
||||
"core-js": "^3.6.5", |
||||
"deep-equal": "^1.0.1", |
||||
"document-register-element": "1.13.1", |
||||
"dom-to-pdf": "^0.3.1", |
||||
"eslint-config-prettier": "^8.5.0", |
||||
"ethers": "^5.4.2", |
||||
"ethjs-util": "^0.1.6", |
||||
"express": "^4.18.2", |
||||
"express-ws": "^5.0.2", |
||||
"file-path-filter": "^3.0.2", |
||||
"file-saver": "^2.0.5", |
||||
"form-data": "^4.0.0", |
||||
"formik": "^2.2.9", |
||||
"fs-extra": "^3.0.1", |
||||
"html-react-parser": "^3.0.4", |
||||
"http-server": "^14.1.1", |
||||
"intro.js": "^4.1.0", |
||||
"isbinaryfile": "^3.0.2", |
||||
"isomorphic-git": "^1.8.2", |
||||
"jquery": "^3.3.1", |
||||
"js-yaml": "^4.1.0", |
||||
"jszip": "^3.6.0", |
||||
"latest-version": "^5.1.0", |
||||
"merge": "^2.1.1", |
||||
"monaco-editor": "^0.30.1", |
||||
"npm-install-version": "^6.0.2", |
||||
"path-browserify": "^1.0.1", |
||||
"prettier": "^2.7.1", |
||||
"prettier-plugin-solidity": "^1.0.0-beta.24", |
||||
"raw-loader": "^4.0.2", |
||||
"react": "^17.0.2", |
||||
"react-beautiful-dnd": "^13.1.0", |
||||
"react-bootstrap": "^1.6.4", |
||||
"react-dom": "^17.0.2", |
||||
"react-draggable": "^4.4.4", |
||||
"react-intl": "^6.0.4", |
||||
"react-json-view": "^1.21.3", |
||||
"react-multi-carousel": "^2.8.2", |
||||
"react-router-dom": "^6.3.0", |
||||
"react-tabs": "^3.2.2", |
||||
"react-zoom-pan-pinch": "^2.2.0", |
||||
"regenerator-runtime": "0.13.7", |
||||
"rss-parser": "^3.12.0", |
||||
"signale": "^1.4.0", |
||||
"sol2uml": "^2.4.3", |
||||
"string-similarity": "^4.0.4", |
||||
"swarmgw": "^0.3.1", |
||||
"time-stamp": "^2.2.0", |
||||
"toml": "^3.0.0", |
||||
"tree-kill": "^1.2.2", |
||||
"ts-loader": "^9.2.6", |
||||
"tslib": "^2.3.0", |
||||
"web3": "^1.8.0", |
||||
"winston": "^3.3.3", |
||||
"ws": "^7.3.0" |
||||
}, |
||||
"devDependencies": { |
||||
"@babel/cli": "^7.19.3", |
||||
"@babel/core": "^7.19.6", |
||||
"@babel/plugin-transform-modules-amd": "^7.10.4", |
||||
"@babel/plugin-transform-modules-commonjs": "^7.19.6", |
||||
"@babel/plugin-transform-object-assign": "^7.2.0", |
||||
"@babel/plugin-transform-reserved-words": "^7.18.6", |
||||
"@babel/plugin-transform-runtime": "^7.10.4", |
||||
"@babel/polyfill": "^7.4.4", |
||||
"@babel/preset-env": "^7.19.4", |
||||
"@babel/preset-es2015": "^7.0.0-beta.53", |
||||
"@babel/preset-es2017": "latest", |
||||
"@babel/preset-react": "^7.18.6", |
||||
"@babel/preset-stage-0": "^7.0.0", |
||||
"@babel/preset-typescript": "^7.18.6", |
||||
"@babel/register": "^7.4.4", |
||||
"@fortawesome/fontawesome-free": "^5.8.1", |
||||
"@nrwl/cli": "^15.6.3", |
||||
"@nrwl/eslint-plugin-nx": "^15.6.3", |
||||
"@nrwl/jest": "15.6.3", |
||||
"@nrwl/js": "15.6.3", |
||||
"@nrwl/linter": "15.6.3", |
||||
"@nrwl/node": "15.6.3", |
||||
"@nrwl/react": "15.6.3", |
||||
"@nrwl/tao": "^15.6.3", |
||||
"@nrwl/web": "15.6.3", |
||||
"@nrwl/webpack": "15.6.3", |
||||
"@nrwl/workspace": "^15.6.3", |
||||
"@openzeppelin/contracts-upgradeable": "^4.8.1", |
||||
"@svgr/webpack": "^6.5.1", |
||||
"@testing-library/react": "13.4.0", |
||||
"@types/axios": "^0.14.0", |
||||
"@types/chai": "^4.3.3", |
||||
"@types/express-ws": "^3.0.1", |
||||
"@types/fs-extra": "^9.0.1", |
||||
"@types/isomorphic-git__lightning-fs": "^4.4.2", |
||||
"@types/jest": "28.1.1", |
||||
"@types/lodash": "^4.14.172", |
||||
"@types/mocha": "^9.1.1", |
||||
"@types/node": "18.7.18", |
||||
"@types/react": "^17.0.24", |
||||
"@types/react-beautiful-dnd": "^13.1.2", |
||||
"@types/react-dom": "^17.0.9", |
||||
"@types/react-router-dom": "^5.3.0", |
||||
"@types/request": "^2.48.7", |
||||
"@types/semver": "^7.3.10", |
||||
"@types/tape": "^4.13.0", |
||||
"@types/ws": "^7.2.4", |
||||
"@typescript-eslint/eslint-plugin": "^5.40.1", |
||||
"@typescript-eslint/parser": "^5.40.1", |
||||
"@uniswap/v2-core": "^1.0.1", |
||||
"@uniswap/v3-core": "^1.0.1", |
||||
"ace-mode-lexon": "^1.*.*", |
||||
"ace-mode-move": "0.0.1", |
||||
"ace-mode-solidity": "^0.1.0", |
||||
"ace-mode-zokrates": "^1.0.4", |
||||
"babel-eslint": "^10.0.0", |
||||
"babel-jest": "25.1.0", |
||||
"babel-plugin-add-module-exports": "^1.0.2", |
||||
"babel-plugin-fast-async": "^6.1.2", |
||||
"babel-plugin-module-resolver": "^4.0.0", |
||||
"babel-plugin-replace-ts-export-assignment": "^0.0.2", |
||||
"babel-plugin-transform-object-rest-spread": "^6.26.0", |
||||
"babel-preset-env": "^1.7.0", |
||||
"babel-preset-typescript": "^7.0.0-alpha.19", |
||||
"babelify": "^10.0.0", |
||||
"browserify": "^17.0.0", |
||||
"browserify-reload": "^1.0.3", |
||||
"browserify-zlib": "^0.2.0", |
||||
"buffer": "^6.0.3", |
||||
"chai": "^4.3.7", |
||||
"child_process": "^1.0.2", |
||||
"colors": "^1.4.0", |
||||
"colors-browserify": "^0.1.1", |
||||
"component-type": "^1.2.1", |
||||
"constants-browserify": "^1.0.0", |
||||
"copy-to-clipboard": "^3.3.1", |
||||
"copy-webpack-plugin": "^11.0.0", |
||||
"crypto-browserify": "^3.12.0", |
||||
"csjs-inject": "^1.0.1", |
||||
"css-loader": "^6.7.1", |
||||
"css-minimizer-webpack-plugin": "^4.2.2", |
||||
"csslint": "^1.0.2", |
||||
"dotenv": "^8.2.0", |
||||
"eslint": "^8.26.0", |
||||
"eslint-config-standard": "^14.1.1", |
||||
"eslint-plugin-import": "2.26.0", |
||||
"eslint-plugin-jsx-a11y": "6.6.1", |
||||
"eslint-plugin-node": "11.1.0", |
||||
"eslint-plugin-promise": "4.2.1", |
||||
"eslint-plugin-react": "7.31.8", |
||||
"eslint-plugin-react-hooks": "4.6.0", |
||||
"eslint-plugin-standard": "4.0.1", |
||||
"events": "^3.0.0", |
||||
"execr": "^1.0.1", |
||||
"exorcist": "^0.4.0", |
||||
"exports-loader": "^1.1.0", |
||||
"fast-async": "^7.0.6", |
||||
"fast-levenshtein": "^2.0.6", |
||||
"ganache-cli": "^6.8.1", |
||||
"gists": "^1.0.1", |
||||
"gulp": "^4.0.2", |
||||
"hardhat": "^2.12.7", |
||||
"https-browserify": "^1.0.0", |
||||
"ipfs-http-client": "^47.0.1", |
||||
"ipfs-mini": "^1.1.5", |
||||
"is-electron": "^2.2.0", |
||||
"javascript-serialize": "^1.6.1", |
||||
"jest": "^29.3.1", |
||||
"jest-environment-jsdom": "28.1.1", |
||||
"js-base64": "^2.1.9", |
||||
"js-beautify": "1.6.14", |
||||
"lerna": "^3.22.1", |
||||
"minixhr": "^4.0.0", |
||||
"mkdirp": "^0.5.1", |
||||
"mocha": "^8.0.1", |
||||
"nanohtml": "^1.6.3", |
||||
"nightwatch": "^2.3", |
||||
"nodemon": "^2.0.4", |
||||
"notify-error": "^1.2.0", |
||||
"npm-link-local": "^1.1.0", |
||||
"npm-merge-driver": "^2.3.5", |
||||
"npm-run-all": "^4.0.2", |
||||
"nx": "15.6.3", |
||||
"nyc": "^13.3.0", |
||||
"onchange": "^3.2.1", |
||||
"os-browserify": "^0.3.0", |
||||
"process": "^0.11.10", |
||||
"react-test-renderer": "^17.0.2", |
||||
"request": "^2.83.0", |
||||
"rimraf": "^2.6.1", |
||||
"selenium-standalone": "^8.2.3", |
||||
"semver": "^6.3.0", |
||||
"solc": "0.7.4", |
||||
"stream-browserify": "^3.0.0", |
||||
"stream-http": "^3.2.0", |
||||
"style-loader": "^3.3.1", |
||||
"tap-spec": "^5.0.0", |
||||
"tape": "^4.13.3", |
||||
"terser-webpack-plugin": "^5.3.6", |
||||
"timers-browserify": "^2.0.12", |
||||
"ts-jest": "^29.0.3", |
||||
"ts-node": "10.9.1", |
||||
"tslint": "~6.0.0", |
||||
"typescript": "^4.8.4", |
||||
"uglify-js": "^2.8.16", |
||||
"url": "^0.11.0", |
||||
"vm-browserify": "^1.1.2", |
||||
"watchify": "^3.9.0", |
||||
"webpack": "^5.75.0", |
||||
"webpack-bundle-analyzer": "^4.7.0", |
||||
"webpack-cli": "^4.10.0" |
||||
}, |
||||
"resolutions": { |
||||
"@types/react": "^17.0.24" |
||||
} |
||||
} |
After Width: | Height: | Size: 108 KiB |
@ -0,0 +1,42 @@ |
||||
<!DOCTYPE html> |
||||
<html lang="en"> |
||||
<head> |
||||
<meta charset="utf-8" /> |
||||
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" /> |
||||
<meta name="viewport" content="width=device-width, initial-scale=1" /> |
||||
<meta |
||||
name="description" |
||||
content="Remix" |
||||
/> |
||||
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo.png" /> |
||||
<!-- |
||||
manifest.json provides metadata used when your web app is installed on a |
||||
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/ |
||||
--> |
||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" /> |
||||
<!-- |
||||
Notice the use of %PUBLIC_URL% in the tags above. |
||||
It will be replaced with the URL of the `public` folder during the build. |
||||
Only files inside the `public` folder can be referenced from the HTML. |
||||
|
||||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will |
||||
work correctly both with client-side routing and a non-root public URL. |
||||
Learn how to configure a non-root public URL by running `npm run build`. |
||||
--> |
||||
<title>Remix</title> |
||||
</head> |
||||
<body> |
||||
<noscript>You need to enable JavaScript to run this app.</noscript> |
||||
<div id="root"></div> |
||||
<!-- |
||||
This HTML file is a template. |
||||
If you open it directly in the browser, you will see an empty page. |
||||
|
||||
You can add webfonts, meta tags, or analytics to this file. |
||||
The build step will place the bundled scripts into the <body> tag. |
||||
|
||||
To begin the development, run `npm start` or `yarn start`. |
||||
To create a production bundle, use `npm run build` or `yarn build`. |
||||
--> |
||||
</body> |
||||
</html> |
After Width: | Height: | Size: 9.1 KiB |
@ -0,0 +1,20 @@ |
||||
{ |
||||
"short_name": "React App", |
||||
"name": "Create React App Sample", |
||||
"icons": [ |
||||
{ |
||||
"src": "favicon.ico", |
||||
"sizes": "64x64 32x32 24x24 16x16", |
||||
"type": "image/x-icon" |
||||
}, |
||||
{ |
||||
"src": "logo.png", |
||||
"type": "image/png", |
||||
"sizes": "420x400" |
||||
} |
||||
], |
||||
"start_url": ".", |
||||
"display": "standalone", |
||||
"theme_color": "#000000", |
||||
"background_color": "#ffffff" |
||||
} |
@ -0,0 +1,3 @@ |
||||
# https://www.robotstxt.org/robotstxt.html |
||||
User-agent: * |
||||
Disallow: |
@ -0,0 +1,42 @@ |
||||
.App { |
||||
text-align: center; |
||||
} |
||||
|
||||
.App-logo { |
||||
height: 40vmin; |
||||
pointer-events: none; |
||||
} |
||||
|
||||
@media (prefers-reduced-motion: no-preference) { |
||||
.App-logo { |
||||
animation: App-logo-spin infinite 20s linear; |
||||
} |
||||
} |
||||
|
||||
.App-header { |
||||
background-color: #282c34; |
||||
min-height: 100vh; |
||||
display: flex; |
||||
flex-direction: column; |
||||
align-items: center; |
||||
justify-content: center; |
||||
font-size: calc(10px + 2vmin); |
||||
color: white; |
||||
} |
||||
|
||||
.App-link { |
||||
color: #61dafb; |
||||
} |
||||
|
||||
@keyframes App-logo-spin { |
||||
from { |
||||
transform: rotate(0deg); |
||||
} |
||||
to { |
||||
transform: rotate(360deg); |
||||
} |
||||
} |
||||
|
||||
#disconnectbtn, #accounts-container { |
||||
display: none; |
||||
} |
@ -0,0 +1,56 @@ |
||||
import React from 'react'; |
||||
import './App.css'; |
||||
import '@fortawesome/fontawesome-free/css/all.css' |
||||
import { RemixClient, INFURA_ID_KEY } from './RemixClient' |
||||
const p = new RemixClient() |
||||
function App() { |
||||
|
||||
const openModal = () => { |
||||
p.onConnect() |
||||
} |
||||
|
||||
const disconnect = () => { |
||||
p.onDisconnect() |
||||
} |
||||
|
||||
const showButtons = (connected = true) =>{ |
||||
document.getElementById("disconnectbtn").style.display = document.getElementById("accounts-container").style.display = connected? 'block':'none'; |
||||
document.getElementById("connectbtn").style.display = connected? 'none':'block'; |
||||
} |
||||
|
||||
p.internalEvents.on('accountsChanged', (accounts) => { |
||||
document.getElementById('accounts').innerHTML = "" |
||||
for(const account of accounts){ |
||||
document.getElementById('accounts').innerHTML += `<li className="list-group-item">${account}</li>` |
||||
} |
||||
}) |
||||
|
||||
p.internalEvents.on('chainChanged', (chain) => { |
||||
document.getElementById('chain').innerHTML = chain |
||||
showButtons(true) |
||||
}) |
||||
|
||||
p.internalEvents.on('disconnect', (chain) => { |
||||
document.getElementById('accounts').innerHTML = '' |
||||
document.getElementById('chain').innerHTML = '' |
||||
showButtons(false) |
||||
}) |
||||
return ( |
||||
<div className="App"> |
||||
<div className="btn-group-vertical mt-5 w-25" role="group"> |
||||
<div class="text-center w-100"> |
||||
<i class="fas fa-info-circle mr-2 bg-light" title="Wallet connect reuire an infura id in order to make request to the network."/><a target="_blank" href="https://infura.io/dashboard/ethereum">infura settings</a> |
||||
<input onChange={(e) => { localStorage.setItem(INFURA_ID_KEY, e.target.value)}} id="input-infura-id" placeholder="Infura Id" className="mt-2 mb-2 ml-2"></input> |
||||
</div> |
||||
<button id="connectbtn" type="button" onClick={openModal} className="btn btn-primary">Connect to a wallet</button> |
||||
<button id="disconnectbtn" type="button" onClick={disconnect} className="btn btn-primary mt-2">Disconnect</button> |
||||
</div> |
||||
<div id='accounts-container'> |
||||
<div><label><b>Accounts: </b></label><br></br><ul className="list-group list-group-flush" id="accounts"></ul></div> |
||||
<div><label><b>Network: </b></label><label className="ml-1" id="chain"> - </label></div> |
||||
</div> |
||||
</div> |
||||
); |
||||
} |
||||
|
||||
export default App; |
@ -0,0 +1,9 @@ |
||||
import React from 'react'; |
||||
import { render } from '@testing-library/react'; |
||||
import App from './App'; |
||||
|
||||
test('renders learn react link', () => { |
||||
const { getByText } = render(<App />); |
||||
const linkElement = getByText(/learn react/i); |
||||
expect(linkElement).toBeInTheDocument(); |
||||
}); |
@ -0,0 +1,183 @@ |
||||
import { |
||||
PluginClient |
||||
} from '@remixproject/plugin'; |
||||
import { |
||||
createClient |
||||
} from '@remixproject/plugin-webview'; |
||||
import WalletConnectProvider from "@walletconnect/web3-provider"; |
||||
import Torus from "@toruslabs/torus-embed"; |
||||
import Authereum from "authereum"; |
||||
import Web3Modal, { local } from "web3modal"; |
||||
import BurnerConnectProvider from "@burner-wallet/burner-connect-provider"; |
||||
import MewConnect from "@myetherwallet/mewconnect-web-client"; |
||||
import EventManager from "events" |
||||
|
||||
export const INFURA_ID_KEY = 'walletconnect-infura-id' |
||||
|
||||
export class RemixClient extends PluginClient { |
||||
provider |
||||
constructor() { |
||||
super(); |
||||
createClient(this); |
||||
this.methods = ["sendAsync"]; |
||||
this.internalEvents = new EventManager() |
||||
this.onload() |
||||
} |
||||
|
||||
/** |
||||
* Connect wallet button pressed. |
||||
*/ |
||||
async onConnect() { |
||||
|
||||
try { |
||||
this.web3Modal = new Web3Modal({ |
||||
providerOptions: this.getProviderOptions() // required
|
||||
}) |
||||
this.provider = await this.web3Modal.connect(); |
||||
} catch (e) { |
||||
console.error("Could not get a wallet connection", e); |
||||
return; |
||||
} |
||||
|
||||
this.internalEvents.emit('accountsChanged', this.provider.accounts || []) |
||||
this.internalEvents.emit('chainChanged', await this.detectNetwork(this.provider.chainId)) |
||||
|
||||
// Subscribe to accounts change
|
||||
this.provider.on("accountsChanged", (accounts) => { |
||||
this.internalEvents.emit('accountsChanged', accounts || []) |
||||
}); |
||||
|
||||
// Subscribe to chainId change
|
||||
this.provider.on("chainChanged", async (chainId) => { |
||||
this.internalEvents.emit('chainChanged', await this.detectNetwork(chainId)) |
||||
}); |
||||
|
||||
// Subscribe to networkId change
|
||||
this.provider.on("networkChanged", (networkId) => { |
||||
this.internalEvents.emit('networkChanged', networkId) |
||||
}); |
||||
|
||||
// Subscribe to networkId change
|
||||
this.provider.on("disconnect", () => { |
||||
this.internalEvents.emit('disconnect') |
||||
}); |
||||
} |
||||
|
||||
async detectNetwork(id) { |
||||
|
||||
let networkName = null; |
||||
id = parseInt(id) |
||||
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md
|
||||
if (id === 1) networkName = "Main"; |
||||
else if (id === 2) networkName = "Morden (deprecated)"; |
||||
else if (id === 3) networkName = "Ropsten"; |
||||
else if (id === 4) networkName = "Rinkeby"; |
||||
else if (id === 5) networkName = "Goerli"; |
||||
else if (id === 42) networkName = "Kovan"; |
||||
else networkName = "Custom"; |
||||
return networkName |
||||
} |
||||
|
||||
getInfuraId () { |
||||
return localStorage.getItem(INFURA_ID_KEY) |
||||
} |
||||
|
||||
/** |
||||
* Disconnect wallet button pressed. |
||||
*/ |
||||
async onDisconnect() { |
||||
this.web3Modal = null |
||||
// TODO: Which providers have close method?
|
||||
if (this.provider && this.provider.close) { |
||||
await this.provider.close(); |
||||
|
||||
// If the cached provider is not cleared,
|
||||
// WalletConnect will default to the existing session
|
||||
// and does not allow to re-scan the QR code with a new wallet.
|
||||
// Depending on your use case you may want or want not his behavir.
|
||||
await this.web3Modal.clearCachedProvider(); |
||||
this.provider = null; |
||||
} else { |
||||
this.internalEvents.emit('disconnect') |
||||
} |
||||
} |
||||
|
||||
getProviderOptions() { |
||||
const providerOptions = { |
||||
walletconnect: { |
||||
package: WalletConnectProvider, |
||||
options: { |
||||
infuraId: this.getInfuraId(), |
||||
bridge: 'https://wallet-connect-bridge.dyn.plugin.remixproject.org:8080/' |
||||
} |
||||
}, |
||||
torus: { |
||||
package: Torus, // required
|
||||
options: {} |
||||
}, |
||||
authereum: { |
||||
package: Authereum |
||||
}, |
||||
burnerconnect: { |
||||
package: BurnerConnectProvider, // required
|
||||
options: { |
||||
defaultNetwork: "100" |
||||
} |
||||
}, |
||||
mewconnect: { |
||||
package: MewConnect, // required
|
||||
options: { |
||||
infuraId: this.getInfuraId() // required
|
||||
} |
||||
} |
||||
/*, |
||||
fortmatic: { |
||||
package: Fortmatic, |
||||
options: { |
||||
key: process.env.REACT_APP_FORTMATIC_KEY |
||||
} |
||||
}, |
||||
authereum: { |
||||
package: Authereum |
||||
}, |
||||
portis: { |
||||
package: Portis, // required
|
||||
options: { |
||||
id: "PORTIS_ID" // required
|
||||
} |
||||
}, |
||||
squarelink: { |
||||
package: Squarelink, // required
|
||||
options: { |
||||
id: "SQUARELINK_ID" // required
|
||||
} |
||||
}, |
||||
arkane: { |
||||
package: Arkane, // required
|
||||
options: { |
||||
clientId: "ARKANE_CLIENT_ID" // required
|
||||
} |
||||
}, |
||||
dcentwallet: { |
||||
package: DcentProvider, // required
|
||||
options: { |
||||
rpcUrl: "INSERT_RPC_URL" // required
|
||||
} |
||||
}*/ |
||||
}; |
||||
return providerOptions; |
||||
}; |
||||
|
||||
sendAsync = (data) => { |
||||
return new Promise((resolve, reject) => { |
||||
if (this.provider) { |
||||
this.provider.sendAsync(data, (error, message) => { |
||||
if (error) return reject(error) |
||||
resolve(message) |
||||
}) |
||||
} else { |
||||
resolve({"jsonrpc": "2.0", "result": [], "id": data.id}) |
||||
} |
||||
}) |
||||
} |
||||
} |
@ -0,0 +1,13 @@ |
||||
body { |
||||
margin: 0; |
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', |
||||
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', |
||||
sans-serif; |
||||
-webkit-font-smoothing: antialiased; |
||||
-moz-osx-font-smoothing: grayscale; |
||||
} |
||||
|
||||
code { |
||||
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', |
||||
monospace; |
||||
} |
@ -0,0 +1,17 @@ |
||||
import React from 'react'; |
||||
import ReactDOM from 'react-dom'; |
||||
import './index.css'; |
||||
import App from './App'; |
||||
import * as serviceWorker from './serviceWorker'; |
||||
|
||||
ReactDOM.render( |
||||
<React.StrictMode> |
||||
<App /> |
||||
</React.StrictMode>, |
||||
document.getElementById('root') |
||||
); |
||||
|
||||
// If you want your app to work offline and load faster, you can change
|
||||
// unregister() to register() below. Note this comes with some pitfalls.
|
||||
// Learn more about service workers: https://bit.ly/CRA-PWA
|
||||
serviceWorker.unregister(); |
After Width: | Height: | Size: 1.7 KiB |
@ -0,0 +1,141 @@ |
||||
// This optional code is used to register a service worker.
|
||||
// register() is not called by default.
|
||||
|
||||
// This lets the app load faster on subsequent visits in production, and gives
|
||||
// it offline capabilities. However, it also means that developers (and users)
|
||||
// will only see deployed updates on subsequent visits to a page, after all the
|
||||
// existing tabs open on the page have been closed, since previously cached
|
||||
// resources are updated in the background.
|
||||
|
||||
// To learn more about the benefits of this model and instructions on how to
|
||||
// opt-in, read https://bit.ly/CRA-PWA
|
||||
|
||||
const isLocalhost = Boolean( |
||||
window.location.hostname === 'localhost' || |
||||
// [::1] is the IPv6 localhost address.
|
||||
window.location.hostname === '[::1]' || |
||||
// 127.0.0.0/8 are considered localhost for IPv4.
|
||||
window.location.hostname.match( |
||||
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ |
||||
) |
||||
); |
||||
|
||||
export function register(config) { |
||||
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { |
||||
// The URL constructor is available in all browsers that support SW.
|
||||
const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href); |
||||
if (publicUrl.origin !== window.location.origin) { |
||||
// Our service worker won't work if PUBLIC_URL is on a different origin
|
||||
// from what our page is served on. This might happen if a CDN is used to
|
||||
// serve assets; see https://github.com/facebook/create-react-app/issues/2374
|
||||
return; |
||||
} |
||||
|
||||
window.addEventListener('load', () => { |
||||
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; |
||||
|
||||
if (isLocalhost) { |
||||
// This is running on localhost. Let's check if a service worker still exists or not.
|
||||
checkValidServiceWorker(swUrl, config); |
||||
|
||||
// Add some additional logging to localhost, pointing developers to the
|
||||
// service worker/PWA documentation.
|
||||
navigator.serviceWorker.ready.then(() => { |
||||
console.log( |
||||
'This web app is being served cache-first by a service ' + |
||||
'worker. To learn more, visit https://bit.ly/CRA-PWA' |
||||
); |
||||
}); |
||||
} else { |
||||
// Is not localhost. Just register service worker
|
||||
registerValidSW(swUrl, config); |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
|
||||
function registerValidSW(swUrl, config) { |
||||
navigator.serviceWorker |
||||
.register(swUrl) |
||||
.then(registration => { |
||||
registration.onupdatefound = () => { |
||||
const installingWorker = registration.installing; |
||||
if (installingWorker == null) { |
||||
return; |
||||
} |
||||
installingWorker.onstatechange = () => { |
||||
if (installingWorker.state === 'installed') { |
||||
if (navigator.serviceWorker.controller) { |
||||
// At this point, the updated precached content has been fetched,
|
||||
// but the previous service worker will still serve the older
|
||||
// content until all client tabs are closed.
|
||||
console.log( |
||||
'New content is available and will be used when all ' + |
||||
'tabs for this page are closed. See https://bit.ly/CRA-PWA.' |
||||
); |
||||
|
||||
// Execute callback
|
||||
if (config && config.onUpdate) { |
||||
config.onUpdate(registration); |
||||
} |
||||
} else { |
||||
// At this point, everything has been precached.
|
||||
// It's the perfect time to display a
|
||||
// "Content is cached for offline use." message.
|
||||
console.log('Content is cached for offline use.'); |
||||
|
||||
// Execute callback
|
||||
if (config && config.onSuccess) { |
||||
config.onSuccess(registration); |
||||
} |
||||
} |
||||
} |
||||
}; |
||||
}; |
||||
}) |
||||
.catch(error => { |
||||
console.error('Error during service worker registration:', error); |
||||
}); |
||||
} |
||||
|
||||
function checkValidServiceWorker(swUrl, config) { |
||||
// Check if the service worker can be found. If it can't reload the page.
|
||||
fetch(swUrl, { |
||||
headers: { 'Service-Worker': 'script' }, |
||||
}) |
||||
.then(response => { |
||||
// Ensure service worker exists, and that we really are getting a JS file.
|
||||
const contentType = response.headers.get('content-type'); |
||||
if ( |
||||
response.status === 404 || |
||||
(contentType != null && contentType.indexOf('javascript') === -1) |
||||
) { |
||||
// No service worker found. Probably a different app. Reload the page.
|
||||
navigator.serviceWorker.ready.then(registration => { |
||||
registration.unregister().then(() => { |
||||
window.location.reload(); |
||||
}); |
||||
}); |
||||
} else { |
||||
// Service worker found. Proceed as normal.
|
||||
registerValidSW(swUrl, config); |
||||
} |
||||
}) |
||||
.catch(() => { |
||||
console.log( |
||||
'No internet connection found. App is running in offline mode.' |
||||
); |
||||
}); |
||||
} |
||||
|
||||
export function unregister() { |
||||
if ('serviceWorker' in navigator) { |
||||
navigator.serviceWorker.ready |
||||
.then(registration => { |
||||
registration.unregister(); |
||||
}) |
||||
.catch(error => { |
||||
console.error(error.message); |
||||
}); |
||||
} |
||||
} |
@ -0,0 +1,5 @@ |
||||
// jest-dom adds custom jest matchers for asserting on DOM nodes.
|
||||
// allows you to do things like:
|
||||
// expect(element).toHaveTextContent(/react/i)
|
||||
// learn more: https://github.com/testing-library/jest-dom
|
||||
import '@testing-library/jest-dom/extend-expect'; |
Loading…
Reference in new issue