Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
231895c0
Commit
231895c0
authored
May 21, 2021
by
aniket-engg
Committed by
Aniket
May 26, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
set execution context for hardhat provider
parent
e2898170
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
44 deletions
+46
-44
hardhat-provider.js
apps/remix-ide/src/app/tabs/hardhat-provider.js
+15
-34
settings.js
apps/remix-ide/src/app/tabs/runTab/settings.js
+30
-9
execution-context.js
apps/remix-ide/src/blockchain/execution-context.js
+1
-1
No files found.
apps/remix-ide/src/app/tabs/hardhat-provider.js
View file @
231895c0
import
*
as
packageJson
from
'../../../../../package.json'
import
*
as
packageJson
from
'../../../../../package.json'
import
{
Plugin
}
from
'@remixproject/engine'
import
{
Plugin
}
from
'@remixproject/engine'
const
yo
=
require
(
'yo-yo'
)
const
modalDialogCustom
=
require
(
'../ui/modal-dialog-custom'
)
import
Web3
from
'web3'
const
profile
=
{
const
profile
=
{
name
:
'hardhat-provider'
,
name
:
'hardhat-provider'
,
...
@@ -14,38 +11,23 @@ const profile = {
...
@@ -14,38 +11,23 @@ const profile = {
}
}
export
default
class
HardhatProvider
extends
Plugin
{
export
default
class
HardhatProvider
extends
Plugin
{
constructor
()
{
constructor
()
{
super
(
profile
)
super
(
profile
)
this
.
provider
=
null
this
.
provider
=
null
}
}
hardhatProviderDialogBody
()
{
sendAsync
(
data
)
{
return
yo
`
return
new
Promise
((
resolve
,
reject
)
=>
{
<div class="">
if
(
this
.
provider
)
{
Hardhat Provider Endpoint
this
.
provider
[
this
.
provider
.
sendAsync
?
'sendAsync'
:
'send'
](
data
,
(
error
,
message
)
=>
{
</div>
if
(
error
)
return
reject
(
error
)
`
resolve
(
message
)
}
sendAsync
(
data
)
{
console
.
log
(
'Inside sendAsync - modalDialogCustom'
,
modalDialogCustom
)
modalDialogCustom
.
prompt
(
'Hardhat node request'
,
this
.
hardhatProviderDialogBody
(),
'http://127.0.0.1:8545'
,
(
target
)
=>
{
console
.
log
(
'target--->'
,
target
)
this
.
provider
=
new
Web3
.
providers
.
HttpProvider
(
target
)
return
new
Promise
((
resolve
,
reject
)
=>
{
console
.
log
(
'inside sendAsync promise'
)
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
})
}
})
})
}
)
}
else
{
resolve
({
jsonrpc
:
'2.0'
,
result
:
[],
id
:
data
.
id
})
}
}
})
}
}
}
module
.
exports
=
HardhatProvider
module
.
exports
=
HardhatProvider
\ No newline at end of file
apps/remix-ide/src/app/tabs/runTab/settings.js
View file @
231895c0
...
@@ -244,16 +244,29 @@ class SettingsUI {
...
@@ -244,16 +244,29 @@ class SettingsUI {
}
}
setExecutionContext
(
context
)
{
setExecutionContext
(
context
)
{
this
.
blockchain
.
changeExecutionContext
(
context
,
()
=>
{
if
(
context
===
'Hardhat Provider'
)
{
modalDialogCustom
.
prompt
(
'External node request'
,
this
.
web3ProviderDialogBody
(),
'http://127.0.0.1:8545'
,
(
target
)
=>
{
this
.
blockchain
.
changeExecutionContext
(
context
,
()
=>
{
this
.
blockchain
.
setProviderFromEndpoint
(
target
,
context
,
(
alertMsg
)
=>
{
modalDialogCustom
.
prompt
(
'Hardhat node request'
,
this
.
hardhatProviderDialogBody
(),
'http://127.0.0.1:8545'
,
(
target
)
=>
{
if
(
alertMsg
)
addTooltip
(
alertMsg
)
this
.
blockchain
.
setProviderFromEndpoint
(
target
,
context
,
(
alertMsg
)
=>
{
this
.
setFinalContext
()
if
(
alertMsg
)
addTooltip
(
alertMsg
)
})
this
.
setFinalContext
()
})
},
this
.
setFinalContext
.
bind
(
this
))
},
(
alertMsg
)
=>
{
addTooltip
(
alertMsg
)
},
this
.
setFinalContext
.
bind
(
this
))
}
else
{
this
.
blockchain
.
changeExecutionContext
(
context
,
()
=>
{
modalDialogCustom
.
prompt
(
'External node request'
,
this
.
web3ProviderDialogBody
(),
'http://127.0.0.1:8545'
,
(
target
)
=>
{
this
.
blockchain
.
setProviderFromEndpoint
(
target
,
context
,
(
alertMsg
)
=>
{
if
(
alertMsg
)
addTooltip
(
alertMsg
)
this
.
setFinalContext
()
})
},
this
.
setFinalContext
.
bind
(
this
))
},
(
alertMsg
)
=>
{
addTooltip
(
alertMsg
)
},
this
.
setFinalContext
.
bind
(
this
))
},
this
.
setFinalContext
.
bind
(
this
))
},
(
alertMsg
)
=>
{
}
addTooltip
(
alertMsg
)
},
this
.
setFinalContext
.
bind
(
this
))
}
}
web3ProviderDialogBody
()
{
web3ProviderDialogBody
()
{
...
@@ -278,6 +291,14 @@ class SettingsUI {
...
@@ -278,6 +291,14 @@ class SettingsUI {
`
`
}
}
hardhatProviderDialogBody
()
{
return
yo
`
<div class="">
Hardhat Provider Endpoint
</div>
`
}
setFinalContext
()
{
setFinalContext
()
{
// set the final context. Cause it is possible that this is not the one we've originaly selected
// set the final context. Cause it is possible that this is not the one we've originaly selected
this
.
selectExEnv
.
value
=
this
.
blockchain
.
getProvider
()
this
.
selectExEnv
.
value
=
this
.
blockchain
.
getProvider
()
...
...
apps/remix-ide/src/blockchain/execution-context.js
View file @
231895c0
...
@@ -142,7 +142,7 @@ export class ExecutionContext {
...
@@ -142,7 +142,7 @@ export class ExecutionContext {
}
}
}
}
if
(
context
===
'web3'
)
{
if
(
context
===
'web3'
||
context
===
'Hardhat Provider'
)
{
confirmCb
(
cb
)
confirmCb
(
cb
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment