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
d79bdab5
Commit
d79bdab5
authored
May 11, 2021
by
aniket-engg
Committed by
Aniket
May 18, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hardhat websocket plugin
parent
6dfd7d91
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
87 additions
and
16 deletions
+87
-16
hardhat-handle.js
apps/remix-ide/src/app/files/hardhat-handle.js
+18
-0
remixDProvider.js
apps/remix-ide/src/app/files/remixDProvider.js
+0
-5
remixd-handle.js
apps/remix-ide/src/app/files/remixd-handle.js
+1
-1
compileTab.js
apps/remix-ide/src/app/tabs/compileTab/compileTab.js
+1
-1
remixd.ts
libs/remixd/src/bin/remixd.ts
+7
-1
index.ts
libs/remixd/src/index.ts
+3
-1
serviceList.ts
libs/remixd/src/serviceList.ts
+1
-0
hardhatClient.ts
libs/remixd/src/services/hardhatClient.ts
+55
-0
remixdClient.ts
libs/remixd/src/services/remixdClient.ts
+1
-7
No files found.
apps/remix-ide/src/app/files/hardhat-handle.js
0 → 100644
View file @
d79bdab5
import
{
WebsocketPlugin
}
from
'@remixproject/engine-web'
import
*
as
packageJson
from
'../../../../../package.json'
const
profile
=
{
name
:
'hardhat'
,
displayName
:
'Hardhat'
,
url
:
'ws://127.0.0.1:65522'
,
methods
:
[
'compile'
],
description
:
'Using Remixd daemon, allow to access hardhat API'
,
kind
:
'other'
,
version
:
packageJson
.
version
}
export
class
hardhatHandle
extends
WebsocketPlugin
{
constructor
()
{
super
(
profile
)
}
}
apps/remix-ide/src/app/files/remixDProvider.js
View file @
d79bdab5
...
@@ -50,11 +50,6 @@ module.exports = class RemixDProvider extends FileProvider {
...
@@ -50,11 +50,6 @@ module.exports = class RemixDProvider extends FileProvider {
return
this
.
_isReady
return
this
.
_isReady
}
}
async
compileWithHardhat
()
{
console
.
log
(
'Inside compileWithHardhat, calling hardhatCompile using _appManager'
)
return
await
this
.
_appManager
.
call
(
'remixd'
,
'hardhatCompile'
,
{})
}
close
(
cb
)
{
close
(
cb
)
{
this
.
_isReady
=
false
this
.
_isReady
=
false
cb
()
cb
()
...
...
apps/remix-ide/src/app/files/remixd-handle.js
View file @
d79bdab5
...
@@ -22,7 +22,7 @@ const profile = {
...
@@ -22,7 +22,7 @@ const profile = {
name
:
'remixd'
,
name
:
'remixd'
,
displayName
:
'RemixD'
,
displayName
:
'RemixD'
,
url
:
'ws://127.0.0.1:65520'
,
url
:
'ws://127.0.0.1:65520'
,
methods
:
[
'folderIsReadOnly'
,
'
hardhatCompile'
,
'
resolveDirectory'
,
'get'
,
'exists'
,
'isFile'
,
'set'
,
'rename'
,
'remove'
,
'isDirectory'
,
'list'
,
'createDir'
],
methods
:
[
'folderIsReadOnly'
,
'resolveDirectory'
,
'get'
,
'exists'
,
'isFile'
,
'set'
,
'rename'
,
'remove'
,
'isDirectory'
,
'list'
,
'createDir'
],
events
:
[],
events
:
[],
description
:
'Using Remixd daemon, allow to access file system'
,
description
:
'Using Remixd daemon, allow to access file system'
,
kind
:
'other'
,
kind
:
'other'
,
...
...
apps/remix-ide/src/app/tabs/compileTab/compileTab.js
View file @
d79bdab5
...
@@ -83,7 +83,7 @@ class CompileTab {
...
@@ -83,7 +83,7 @@ class CompileTab {
console
.
log
(
'mode is - '
,
this
.
fileManager
.
mode
)
console
.
log
(
'mode is - '
,
this
.
fileManager
.
mode
)
if
(
this
.
fileManager
.
mode
===
'localhost'
)
{
if
(
this
.
fileManager
.
mode
===
'localhost'
)
{
console
.
log
(
'calling compilehardhat'
)
console
.
log
(
'calling compilehardhat'
)
this
.
fileProvider
.
compileWithHardhat
().
then
(
console
.
log
)
//
this.fileProvider.compileWithHardhat().then(console.log)
}
}
this
.
fileManager
.
saveCurrentFile
()
this
.
fileManager
.
saveCurrentFile
()
this
.
miscApi
.
clearAnnotations
()
this
.
miscApi
.
clearAnnotations
()
...
...
libs/remixd/src/bin/remixd.ts
View file @
d79bdab5
...
@@ -24,16 +24,18 @@ async function warnLatestVersion () {
...
@@ -24,16 +24,18 @@ async function warnLatestVersion () {
const
services
=
{
const
services
=
{
git
:
(
readOnly
:
boolean
)
=>
new
servicesList
.
GitClient
(
readOnly
),
git
:
(
readOnly
:
boolean
)
=>
new
servicesList
.
GitClient
(
readOnly
),
hardhat
:
(
readOnly
:
boolean
)
=>
new
servicesList
.
HardhatClient
(
readOnly
),
folder
:
(
readOnly
:
boolean
)
=>
new
servicesList
.
Sharedfolder
(
readOnly
)
folder
:
(
readOnly
:
boolean
)
=>
new
servicesList
.
Sharedfolder
(
readOnly
)
}
}
const
ports
=
{
const
ports
=
{
git
:
65521
,
git
:
65521
,
hardhat
:
65522
,
folder
:
65520
folder
:
65520
}
}
const
killCallBack
:
Array
<
Function
>
=
[]
const
killCallBack
:
Array
<
Function
>
=
[]
function
startService
<
S
extends
'git'
|
'folder'
>
(
service
:
S
,
callback
:
(
ws
:
WS
,
sharedFolderClient
:
servicesList
.
Sharedfolder
)
=>
void
)
{
function
startService
<
S
extends
'git'
|
'
hardhat'
|
'
folder'
>
(
service
:
S
,
callback
:
(
ws
:
WS
,
sharedFolderClient
:
servicesList
.
Sharedfolder
)
=>
void
)
{
const
socket
=
new
WebSocket
(
ports
[
service
],
{
remixIdeUrl
:
program
.
remixIde
},
()
=>
services
[
service
](
program
.
readOnly
||
false
))
const
socket
=
new
WebSocket
(
ports
[
service
],
{
remixIdeUrl
:
program
.
remixIde
},
()
=>
services
[
service
](
program
.
readOnly
||
false
))
socket
.
start
(
callback
)
socket
.
start
(
callback
)
killCallBack
.
push
(
socket
.
close
.
bind
(
socket
))
killCallBack
.
push
(
socket
.
close
.
bind
(
socket
))
...
@@ -78,6 +80,10 @@ function startService<S extends 'git' | 'folder'> (service: S, callback: (ws: WS
...
@@ -78,6 +80,10 @@ function startService<S extends 'git' | 'folder'> (service: S, callback: (ws: WS
sharedFolderClient
.
setupNotifications
(
program
.
sharedFolder
)
sharedFolderClient
.
setupNotifications
(
program
.
sharedFolder
)
sharedFolderClient
.
sharedFolder
(
program
.
sharedFolder
)
sharedFolderClient
.
sharedFolder
(
program
.
sharedFolder
)
})
})
startService
(
'hardhat'
,
(
ws
:
WS
,
sharedFolderClient
:
servicesList
.
Sharedfolder
)
=>
{
sharedFolderClient
.
setWebSocket
(
ws
)
sharedFolderClient
.
sharedFolder
(
program
.
sharedFolder
)
})
/*
/*
startService('git', (ws: WS, sharedFolderClient: servicesList.Sharedfolder) => {
startService('git', (ws: WS, sharedFolderClient: servicesList.Sharedfolder) => {
sharedFolderClient.setWebSocket(ws)
sharedFolderClient.setWebSocket(ws)
...
...
libs/remixd/src/index.ts
View file @
d79bdab5
'use strict'
'use strict'
import
{
RemixdClient
as
sharedFolder
}
from
'./services/remixdClient'
import
{
RemixdClient
as
sharedFolder
}
from
'./services/remixdClient'
import
{
GitClient
}
from
'./services/gitClient'
import
{
GitClient
}
from
'./services/gitClient'
import
{
HardhatClient
}
from
'./services/hardhatClient'
import
Websocket
from
'./websocket'
import
Websocket
from
'./websocket'
import
*
as
utils
from
'./utils'
import
*
as
utils
from
'./utils'
...
@@ -9,6 +10,7 @@ module.exports = {
...
@@ -9,6 +10,7 @@ module.exports = {
utils
,
utils
,
services
:
{
services
:
{
sharedFolder
,
sharedFolder
,
GitClient
GitClient
,
HardhatClient
}
}
}
}
libs/remixd/src/serviceList.ts
View file @
d79bdab5
export
{
RemixdClient
as
Sharedfolder
}
from
'./services/remixdClient'
export
{
RemixdClient
as
Sharedfolder
}
from
'./services/remixdClient'
export
{
GitClient
}
from
'./services/gitClient'
export
{
GitClient
}
from
'./services/gitClient'
export
{
HardhatClient
}
from
'./services/hardhatClient'
libs/remixd/src/services/hardhatClient.ts
0 → 100644
View file @
d79bdab5
import
*
as
WS
from
'ws'
// eslint-disable-line
import
{
PluginClient
}
from
'@remixproject/plugin'
const
{
spawn
}
=
require
(
'child_process'
)
export
class
HardhatClient
extends
PluginClient
{
methods
:
Array
<
string
>
websocket
:
WS
currentSharedFolder
:
string
constructor
(
private
readOnly
=
false
)
{
super
()
console
.
log
(
'this is HardhatClient constructor'
)
this
.
methods
=
[
'compile'
]
}
setWebSocket
(
websocket
:
WS
):
void
{
this
.
websocket
=
websocket
}
sharedFolder
(
currentSharedFolder
:
string
):
void
{
this
.
currentSharedFolder
=
currentSharedFolder
}
compile
(
cmd
:
string
)
{
// assertCommand(cmd)
const
options
=
{
cwd
:
this
.
currentSharedFolder
,
shell
:
true
}
const
child
=
spawn
(
cmd
,
options
)
let
result
=
''
let
error
=
''
return
new
Promise
((
resolve
,
reject
)
=>
{
child
.
stdout
.
on
(
'data'
,
(
data
)
=>
{
console
.
log
(
'data in compile in HardhatClient'
,
data
)
result
+=
data
.
toString
()
})
child
.
stderr
.
on
(
'data'
,
(
err
)
=>
{
error
+=
err
.
toString
()
})
child
.
on
(
'close'
,
()
=>
{
if
(
error
)
reject
(
error
)
else
resolve
(
result
)
})
})
}
}
/**
* Validate that command can be run by service
* @param cmd
*/
function
assertCommand
(
cmd
)
{
const
regex
=
'^hardhat
\\
s[^&|;]*$'
if
(
!
RegExp
(
regex
).
test
(
cmd
))
{
// git then space and then everything else
throw
new
Error
(
'Invalid command for service!'
)
}
}
libs/remixd/src/services/remixdClient.ts
View file @
d79bdab5
...
@@ -15,7 +15,7 @@ export class RemixdClient extends PluginClient {
...
@@ -15,7 +15,7 @@ export class RemixdClient extends PluginClient {
constructor
(
private
readOnly
=
false
)
{
constructor
(
private
readOnly
=
false
)
{
super
()
super
()
this
.
methods
=
[
'folderIsReadOnly'
,
'
hardhatCompile'
,
'
resolveDirectory'
,
'get'
,
'exists'
,
'isFile'
,
'set'
,
'rename'
,
'remove'
,
'isDirectory'
,
'list'
,
'createDir'
,
'canDeactivate'
]
this
.
methods
=
[
'folderIsReadOnly'
,
'resolveDirectory'
,
'get'
,
'exists'
,
'isFile'
,
'set'
,
'rename'
,
'remove'
,
'isDirectory'
,
'list'
,
'createDir'
,
'canDeactivate'
]
}
}
setWebSocket
(
websocket
:
WS
):
void
{
setWebSocket
(
websocket
:
WS
):
void
{
...
@@ -27,12 +27,6 @@ export class RemixdClient extends PluginClient {
...
@@ -27,12 +27,6 @@ export class RemixdClient extends PluginClient {
if
(
this
.
isLoaded
)
this
.
emit
(
'rootFolderChanged'
)
if
(
this
.
isLoaded
)
this
.
emit
(
'rootFolderChanged'
)
}
}
async
hardhatCompile
()
{
console
.
log
(
'inside hardhatCompile'
)
console
.
log
(
'here is hre-->'
,
hre
.
tasks
)
// await hre.tasks.accounts.action();
}
list
():
Filelist
{
list
():
Filelist
{
try
{
try
{
return
utils
.
walkSync
(
this
.
currentSharedFolder
,
{},
this
.
currentSharedFolder
)
return
utils
.
walkSync
(
this
.
currentSharedFolder
,
{},
this
.
currentSharedFolder
)
...
...
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