From cfd9dc778eb52f5d35437a659fe9401851556f5a Mon Sep 17 00:00:00 2001 From: yann300 Date: Sat, 19 Mar 2022 01:17:21 +0100 Subject: [PATCH] add ganache provider --- apps/remix-ide/src/app.js | 3 ++ .../src/app/tabs/ganache-provider.tsx | 33 +++++++++++++++++++ apps/remix-ide/src/app/udapp/run-tab.js | 5 +-- 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 apps/remix-ide/src/app/tabs/ganache-provider.tsx diff --git a/apps/remix-ide/src/app.js b/apps/remix-ide/src/app.js index 1a295fb793..8b9197f5d5 100644 --- a/apps/remix-ide/src/app.js +++ b/apps/remix-ide/src/app.js @@ -26,6 +26,7 @@ import { Layout } from './app/panels/layout' import { NotificationPlugin } from './app/plugins/notification' import { Blockchain } from './blockchain/blockchain.js' import { HardhatProvider } from './app/tabs/hardhat-provider' +import { GanacheProvider } from './app/tabs/ganache-provider' const isElectron = require('is-electron') @@ -174,6 +175,7 @@ class AppComponent { // ----------------- represent the current selected web3 provider ---- const web3Provider = new Web3ProviderModule(blockchain) const hardhatProvider = new HardhatProvider(blockchain) + const ganacheProvider = new GanacheProvider(blockchain) // ----------------- convert offset to line/column service ----------- const offsetToLineColumnConverter = new OffsetToLineColumnConverter() Registry.getInstance().put({ @@ -229,6 +231,7 @@ class AppComponent { dGitProvider, storagePlugin, hardhatProvider, + ganacheProvider, this.walkthroughService, ]) diff --git a/apps/remix-ide/src/app/tabs/ganache-provider.tsx b/apps/remix-ide/src/app/tabs/ganache-provider.tsx new file mode 100644 index 0000000000..85b018bf1c --- /dev/null +++ b/apps/remix-ide/src/app/tabs/ganache-provider.tsx @@ -0,0 +1,33 @@ +import * as packageJson from '../../../../../package.json' +import { Plugin } from '@remixproject/engine' +import { AppModal, AlertModal, ModalTypes } from '@remix-ui/app' +import React from 'react' // eslint-disable-line +import { Blockchain } from '../../blockchain/blockchain' +import { ethers } from 'ethers' +import { AbstractProvider } from './abstract-provider' + +const profile = { + name: 'ganache-provider', + displayName: 'Ganache', + kind: 'provider', + description: 'Ganache', + methods: ['sendAsync'], + version: packageJson.version +} + +export class GanacheProvider extends AbstractProvider { + constructor (blockchain) { + super(profile, blockchain, 'http://127.0.0.1:8545') + } + + body (): JSX.Element { + return ( +
Note: To run Ganache on your system, run +
npm install -g ganache
+
ganache
+ For more info, visit: Ganache Documentation +
Ganache JSON-RPC Endpoint:
+
+ ) + } +} \ No newline at end of file diff --git a/apps/remix-ide/src/app/udapp/run-tab.js b/apps/remix-ide/src/app/udapp/run-tab.js index 4868ff2ade..5573ea345d 100644 --- a/apps/remix-ide/src/app/udapp/run-tab.js +++ b/apps/remix-ide/src/app/udapp/run-tab.js @@ -96,8 +96,9 @@ export class RunTab extends ViewPlugin { this.REACT_API = api } - onInitDone () { - this.call('manager', 'activatePlugin', 'hardhat-provider') + async onInitDone () { + await this.call('manager', 'activatePlugin', 'hardhat-provider') + await this.call('manager', 'activatePlugin', 'ganache-provider') } writeFile (fileName, content) {