add provider from run ad deploy plugin

pull/2265/head^2
yann300 3 years ago
parent 34f5f14605
commit c2f2468de1
  1. 31
      apps/remix-ide/src/app/udapp/run-tab.js
  2. 2
      apps/remix-ide/src/blockchain/blockchain.js
  3. 3
      apps/remix-ide/src/remixAppManager.js
  4. 27
      libs/remix-ui/run-tab/src/lib/actions/index.ts

@ -97,9 +97,36 @@ export class RunTab extends ViewPlugin {
}
async onInitDone () {
await this.call('manager', 'activatePlugin', 'hardhat-provider')
await this.call('manager', 'activatePlugin', 'ganache-provider')
const udapp = this
await this.call('blockchain', 'addProvider', {
name: 'Hardhat Provider',
provider: {
async sendAsync (payload, callback) {
try {
const result = await udapp.call('hardhat-provider', 'sendAsync', payload)
callback(null, result)
} catch (e) {
callback(e)
}
}
}
})
await this.call('blockchain', 'addProvider', {
name: 'Ganache Provider',
provider: {
async sendAsync (payload, callback) {
try {
const result = await udapp.call('ganache-provider', 'sendAsync', payload)
callback(null, result)
} catch (e) {
callback(e)
}
}
}
})
await this.call('blockchain', 'addProvider', {
name: 'Wallet Connect',
provider: {

@ -22,7 +22,7 @@ const profile = {
name: 'blockchain',
displayName: 'Blockchain',
description: 'Blockchain - Logic',
methods: ['getCode', 'getTransactionReceipt'],
methods: ['getCode', 'getTransactionReceipt', 'addProvider', 'removeProvider'],
version: packageJson.version
}

@ -13,7 +13,7 @@ const requiredModules = [ // services + layout views + system views
const dependentModules = ['git', 'hardhat', 'truffle', 'slither'] // module which shouldn't be manually activated (e.g git is activated by remixd)
export function isNative (name) {
const nativePlugins = ['vyper', 'workshops', 'debugger', 'remixd', 'menuicons', 'solidity', 'hardhat-provider', 'solidityStaticAnalysis', 'solidityUnitTesting', 'layout', 'notification']
const nativePlugins = ['vyper', 'workshops', 'debugger', 'remixd', 'menuicons', 'solidity', 'hardhat-provider', 'solidityStaticAnalysis', 'solidityUnitTesting', 'layout', 'notification', 'hardhat-provider', 'ganache-provider']
return nativePlugins.includes(name) || requiredModules.includes(name)
}
@ -133,7 +133,6 @@ export class RemixAppManager extends PluginManager {
}
}
return plugins.map(plugin => {
if (plugin.name === 'walletconnect') plugin.url = 'http://127.0.0.1:8081'
return new IframePlugin(plugin)
// return new IframeReactPlugin(plugin)
})

@ -64,10 +64,6 @@ const setupEvents = () => {
plugin.blockchain.event.register('removeProvider', name => removeExternalProvider(name))
plugin.on('manager', 'pluginActivated', addPluginProvider.bind(plugin))
plugin.on('manager', 'pluginDeactivated', removePluginProvider.bind(plugin))
plugin.on('solidity', 'compilationFinished', (file, source, languageVersion, data, input, version) => broadcastCompilationResult(file, source, languageVersion, data, input))
plugin.on('vyper', 'compilationFinished', (file, source, languageVersion, data) => broadcastCompilationResult(file, source, languageVersion, data))
@ -186,29 +182,6 @@ export const setGasFee = (value: number) => {
dispatch(setGasLimit(value))
}
const addPluginProvider = (profile) => {
if (profile.kind === 'provider') {
console.log(profile);
((profile, app) => {
const web3Provider = {
async sendAsync (payload, callback) {
try {
const result = await app.call(profile.name, 'sendAsync', payload)
callback(null, result)
} catch (e) {
callback(e)
}
}
}
app.blockchain.addProvider({ name: profile.displayName, provider: web3Provider })
})(profile, plugin)
}
}
const removePluginProvider = (profile) => {
if (profile.kind === 'provider') plugin.blockchain.removeProvider(profile.displayName)
}
const setFinalContext = () => {
// set the final context. Cause it is possible that this is not the one we've originaly selected
const value = _getProviderDropdownValue()

Loading…
Cancel
Save