hardhat provider plugin

pull/1222/head
aniket-engg 4 years ago committed by Aniket
parent fe1689976c
commit 4ce7228874
  1. 5
      apps/remix-ide/src/app.js
  2. 34
      apps/remix-ide/src/app/tabs/hardhat-provider.js

@ -29,6 +29,7 @@ const { OffsetToLineColumnConverter } = require('./lib/offsetToLineColumnConvert
const QueryParams = require('./lib/query-params')
const Storage = remixLib.Storage
const RemixDProvider = require('./app/files/remixDProvider')
const HardhatProvider = require('./app/tabs/hardhat-provider')
const Config = require('./config')
const modalDialogCustom = require('./app/ui/modal-dialog-custom')
const modalDialog = require('./app/ui/modaldialog')
@ -296,6 +297,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
makeUdapp(blockchain, compilersArtefacts, (domEl) => terminal.logHtml(domEl))
const contextualListener = new ContextualListener({ editor })
const hardhatProvider = new HardhatProvider()
engine.register([
contentImport,
@ -309,7 +311,8 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
contextualListener,
terminal,
web3Provider,
fetchAndCompile
fetchAndCompile,
hardhatProvider
])
// LAYOUT & SYSTEM VIEWS

@ -0,0 +1,34 @@
import * as packageJson from '../../../../../package.json'
import { Plugin } from '@remixproject/engine'
import Web3 from 'web3'
const profile = {
name: 'hardhat-provider',
displayName: 'Hardhat Provider',
kind: 'provider',
description: 'Hardhat provider',
methods: ['sendAsync'],
version: packageJson.version
}
export default class HardhatProvider extends Plugin {
constructor () {
super(profile)
this.provider = new Web3.providers.HttpProvider('http://127.0.0.1:8545')
}
sendAsync (data) {
return new Promise((resolve, reject) => {
if (this.provider) {
this.provider[this.provider.sendAsync ? 'sendAsync' : 'send'](data, (error, message) => {
if (error) return reject(error)
resolve(message)
})
} else {
resolve({"jsonrpc": "2.0", "result": [], "id": data.id})
}
})
}
}
module.exports = HardhatProvider
Loading…
Cancel
Save