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
5a22644c
Commit
5a22644c
authored
Aug 23, 2021
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix iframe plugin api
parent
f0c2b731
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
83 additions
and
183 deletions
+83
-183
compile-tab.js
apps/remix-ide/src/app/tabs/compile-tab.js
+0
-113
compiler-api.ts
apps/solidity-compiler/src/app/compiler-api.ts
+17
-5
compiler.ts
apps/solidity-compiler/src/app/compiler.ts
+20
-6
index.ts
libs/remix-ui/solidity-compiler/src/index.ts
+2
-2
compiler.ts
libs/remix-ui/solidity-compiler/src/lib/actions/compiler.ts
+5
-5
compiler-container.tsx
...remix-ui/solidity-compiler/src/lib/compiler-container.tsx
+1
-1
icompiler-api.ts
libs/remix-ui/solidity-compiler/src/lib/icompiler-api.ts
+0
-27
solidity-compiler.tsx
.../remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx
+3
-3
index.ts
libs/remix-ui/solidity-compiler/src/lib/types/index.ts
+35
-21
No files found.
apps/remix-ide/src/app/tabs/compile-tab.js
View file @
5a22644c
...
...
@@ -48,119 +48,6 @@ class CompileTab extends CompilerApiMixin(ViewPlugin) {
this
.
renderComponent
()
}
/************
* EVENTS
*/
listenToEvents
()
{
this
.
data
.
eventHandlers
.
onContentChanged
=
()
=>
{
this
.
emit
(
'statusChanged'
,
{
key
:
'edited'
,
title
:
'the content has changed, needs recompilation'
,
type
:
'info'
})
}
this
.
editor
.
event
.
register
(
'contentChanged'
,
this
.
data
.
eventHandlers
.
onContentChanged
)
this
.
data
.
eventHandlers
.
onLoadingCompiler
=
()
=>
{
this
.
data
.
loading
=
true
this
.
emit
(
'statusChanged'
,
{
key
:
'loading'
,
title
:
'loading compiler...'
,
type
:
'info'
})
}
this
.
compiler
.
event
.
register
(
'loadingCompiler'
,
this
.
data
.
eventHandlers
.
onLoadingCompiler
)
this
.
data
.
eventHandlers
.
onCompilerLoaded
=
()
=>
{
this
.
data
.
loading
=
false
this
.
emit
(
'statusChanged'
,
{
key
:
'none'
})
}
this
.
compiler
.
event
.
register
(
'compilerLoaded'
,
this
.
data
.
eventHandlers
.
onCompilerLoaded
)
this
.
data
.
eventHandlers
.
onStartingCompilation
=
()
=>
{
this
.
emit
(
'statusChanged'
,
{
key
:
'loading'
,
title
:
'compiling...'
,
type
:
'info'
})
}
this
.
data
.
eventHandlers
.
onRemoveAnnotations
=
()
=>
{
this
.
call
(
'editor'
,
'clearAnnotations'
)
}
const
resetView
=
(
isLocalhost
)
=>
{
this
.
compileTabLogic
.
isHardhatProject
().
then
((
result
)
=>
{
if
(
result
&&
isLocalhost
)
this
.
isHardHatProject
=
true
else
this
.
isHardHatProject
=
false
this
.
renderComponent
()
})
this
.
resetResults
()
}
this
.
on
(
'filePanel'
,
'setWorkspace'
,
(
workspace
)
=>
{
resetView
(
workspace
.
isLocalhost
)
})
this
.
on
(
'remixd'
,
'rootFolderChanged'
,
()
=>
{
resetView
(
true
)
})
this
.
compileTabLogic
.
event
.
on
(
'startingCompilation'
,
this
.
data
.
eventHandlers
.
onStartingCompilation
)
this
.
compileTabLogic
.
event
.
on
(
'removeAnnotations'
,
this
.
data
.
eventHandlers
.
onRemoveAnnotations
)
this
.
data
.
eventHandlers
.
onCurrentFileChanged
=
(
name
)
=>
{
this
.
currentFile
=
name
this
.
renderComponent
()
}
this
.
fileManager
.
events
.
on
(
'currentFileChanged'
,
this
.
data
.
eventHandlers
.
onCurrentFileChanged
)
this
.
data
.
eventHandlers
.
onNoFileSelected
=
()
=>
{
this
.
currentFile
=
''
this
.
renderComponent
()
}
this
.
fileManager
.
events
.
on
(
'noFileSelected'
,
this
.
data
.
eventHandlers
.
onNoFileSelected
)
this
.
data
.
eventHandlers
.
onCompilationFinished
=
(
success
,
data
,
source
)
=>
{
this
.
setCompileErrors
(
data
)
if
(
success
)
{
// forwarding the event to the appManager infra
this
.
emit
(
'compilationFinished'
,
source
.
target
,
source
,
'soljson'
,
data
)
if
(
data
.
errors
&&
data
.
errors
.
length
>
0
)
{
this
.
emit
(
'statusChanged'
,
{
key
:
data
.
errors
.
length
,
title
:
`compilation finished successful with warning
${
data
.
errors
.
length
>
1
?
's'
:
''
}
`
,
type
:
'warning'
})
}
else
this
.
emit
(
'statusChanged'
,
{
key
:
'succeed'
,
title
:
'compilation successful'
,
type
:
'success'
})
// Store the contracts
this
.
contractsDetails
=
{}
this
.
compiler
.
visitContracts
((
contract
)
=>
{
this
.
contractsDetails
[
contract
.
name
]
=
parseContracts
(
contract
.
name
,
contract
.
object
,
this
.
compiler
.
getSource
(
contract
.
file
)
)
})
}
else
{
const
count
=
(
data
.
errors
?
data
.
errors
.
filter
(
error
=>
error
.
severity
===
'error'
).
length
:
0
)
+
data
.
error
?
1
:
0
this
.
emit
(
'statusChanged'
,
{
key
:
count
,
title
:
`compilation failed with
${
count
}
error
${
count
.
length
>
1
?
's'
:
''
}
`
,
type
:
'error'
})
}
// Update contract Selection
this
.
contractMap
=
{}
if
(
success
)
this
.
compiler
.
visitContracts
((
contract
)
=>
{
this
.
contractMap
[
contract
.
name
]
=
contract
})
this
.
renderComponent
()
}
this
.
compiler
.
event
.
register
(
'compilationFinished'
,
this
.
data
.
eventHandlers
.
onCompilationFinished
)
this
.
data
.
eventHandlers
.
onThemeChanged
=
(
theme
)
=>
{
const
invert
=
theme
.
quality
===
'dark'
?
1
:
0
const
img
=
document
.
getElementById
(
'swarmLogo'
)
if
(
img
)
{
img
.
style
.
filter
=
`invert(
${
invert
}
)`
}
}
globalRegistry
.
get
(
'themeModule'
).
api
.
events
.
on
(
'themeChanged'
,
this
.
data
.
eventHandlers
.
onThemeChanged
)
// Run the compiler instead of trying to save the website
$
(
window
).
keydown
((
e
)
=>
{
// ctrl+s or command+s
if
((
e
.
metaKey
||
e
.
ctrlKey
)
&&
e
.
keyCode
===
83
)
{
e
.
preventDefault
()
this
.
compileTabLogic
.
runCompiler
(
this
.
hhCompilation
)
}
})
}
onResetResults
()
{
this
.
renderComponent
()
}
...
...
apps/solidity-compiler/src/app/compiler-api.ts
View file @
5a22644c
...
...
@@ -123,8 +123,7 @@ export const CompilerApiMixin = (Base) => class extends Base {
'currentFile'
:
()
=>
this
.
currentFile
,
'hideWarnings'
:
()
=>
false
,
'autoCompile'
:
()
=>
false
,
'includeNightlies'
:
()
=>
false
,
'optimise'
:
()
=>
false
'includeNightlies'
:
()
=>
false
}
return
conf
[
name
]()
}
...
...
@@ -186,7 +185,20 @@ export const CompilerApiMixin = (Base) => class extends Base {
this
.
on
(
'filePanel'
,
'setWorkspace'
,
(
workspace
)
=>
{
this
.
resetResults
()
if
(
this
.
onSetWorkspace
)
this
.
onSetWorkspace
(
workspace
)
if
(
this
.
onSetWorkspace
)
this
.
onSetWorkspace
(
workspace
.
isLocalhost
)
})
this
.
on
(
'remixd'
,
'rootFolderChanged'
,
()
=>
{
this
.
resetResults
()
if
(
this
.
onSetWorkspace
)
this
.
onSetWorkspace
(
true
)
})
this
.
on
(
'editor'
,
'sessionSwitched'
,
()
=>
{
if
(
this
.
onSessionSwitched
)
this
.
onSessionSwitched
()
})
this
.
on
(
'editor'
,
'contentChanged'
,
()
=>
{
if
(
this
.
onContentChanged
)
this
.
onContentChanged
()
})
this
.
compileTabLogic
.
event
.
on
(
'startingCompilation'
,
this
.
data
.
eventHandlers
.
onStartingCompilation
)
...
...
@@ -226,8 +238,8 @@ export const CompilerApiMixin = (Base) => class extends Base {
)
})
}
else
{
const
count
=
(
data
.
errors
?
data
.
errors
.
filter
(
error
=>
error
.
severity
===
'error'
).
length
:
0
+
data
.
error
?
1
:
0
)
this
.
emit
(
'statusChanged'
,
{
key
:
count
,
title
:
`compilation failed with
${
count
}
error
${
count
.
length
>
1
?
's'
:
''
}
`
,
type
:
'error'
})
const
count
=
(
data
.
errors
?
data
.
errors
.
filter
(
error
=>
error
.
severity
===
'error'
).
length
:
0
)
+
data
.
error
?
1
:
0
this
.
emit
(
'statusChanged'
,
{
key
:
count
,
title
:
`compilation failed with
${
count
}
error
${
count
>
1
?
's'
:
''
}
`
,
type
:
'error'
})
}
// Update contract Selection
this
.
contractMap
=
{}
...
...
apps/solidity-compiler/src/app/compiler.ts
View file @
5a22644c
...
...
@@ -24,26 +24,40 @@ export interface ConfigurationSettings {
}
export
class
CompilerClientApi
extends
CompilerApiMixin
(
PluginClient
)
{
// interface matches libs/remix-ui/solidity-compiler/types/index.ts : ICompilerApi
currentFile
:
string
contractMap
:
{
file
:
string
}
|
Record
<
string
,
any
>
compileErrors
:
any
compileTabLogic
:
any
contractsDetails
:
Record
<
string
,
any
>
contentImport
:
any
call
:
(...
args
)
=>
void
on
:
(...
args
)
=>
void
setSelectedVersion
:
(
value
:
string
)
=>
void
configurationSettings
:
ConfigurationSettings
setHardHatCompilation
:
(
value
:
boolean
)
=>
void
getParameters
:
()
=>
ConfigurationSettings
setParameters
:
(
params
:
Partial
<
ConfigurationSettings
>
)
=>
void
setCompilerConfig
:
(
settings
:
ConfigurationSettings
)
=>
void
getConfiguration
:
(
value
:
string
)
=>
string
setConfiguration
:
(
name
:
string
,
value
:
string
)
=>
void
currentFile
:
string
getFileManagerMode
:
()
=>
string
getCompilationResult
:
()
=>
any
onCurrentFileChanged
:
(
fileName
:
string
)
=>
void
onResetResults
:
()
=>
void
onSetWorkspace
:
(
workspace
:
any
)
=>
void
onSetWorkspace
:
(
isLocalhost
:
boolean
)
=>
void
onNoFileSelected
:
()
=>
void
onCompilationFinished
:
(
contractsDetails
:
any
,
contractMap
:
any
)
=>
void
onSessionSwitched
:
()
=>
void
onContentChanged
:
()
=>
void
fileExists
:
(
file
:
string
)
=>
Promise
<
boolean
>
writeFile
:
(
file
:
string
,
content
:
string
)
=>
Promise
<
void
>
readFile
:
(
file
:
string
)
=>
Promise
<
string
>
open
:
(
file
:
string
)
=>
void
constructor
()
{
super
()
...
...
libs/remix-ui/solidity-compiler/src/index.ts
View file @
5a22644c
export
*
from
'./lib/solidity-compiler'
export
*
from
'./lib/logic'
export
*
from
'./lib/icompiler-api'
export
*
from
'./lib/logic'
\ No newline at end of file
libs/remix-ui/solidity-compiler/src/lib/actions/compiler.ts
View file @
5a22644c
...
...
@@ -27,9 +27,9 @@ export const resetCompilerMode = () => (dispatch: React.Dispatch<any>) => {
}
export
const
listenToEvents
=
(
compileTabLogic
,
api
)
=>
(
dispatch
:
React
.
Dispatch
<
any
>
)
=>
{
api
.
on
(
'editor'
,
'sessionSwitched'
,
()
=>
{
api
.
on
SessionSwitched
=
()
=>
{
dispatch
(
setEditorMode
(
'sessionSwitched'
))
}
)
}
compileTabLogic
.
event
.
on
(
'startingCompilation'
,
()
=>
{
dispatch
(
setCompilerMode
(
'startingCompilation'
))
...
...
@@ -39,10 +39,10 @@ export const listenToEvents = (compileTabLogic, api) => (dispatch: React.Dispatc
dispatch
(
setCompilerMode
(
'compilationDuration'
,
speed
))
})
api
.
on
(
'editor'
,
'contentChanged'
,
()
=>
{
api
.
on
ContentChanged
=
()
=>
{
dispatch
(
setEditorMode
(
'contentChanged'
))
}
)
}
compileTabLogic
.
compiler
.
event
.
register
(
'loadingCompiler'
,
()
=>
{
dispatch
(
setCompilerMode
(
'loadingCompiler'
))
})
...
...
libs/remix-ui/solidity-compiler/src/lib/compiler-container.tsx
View file @
5a22644c
...
...
@@ -76,7 +76,7 @@ export const CompilerContainer = (props: CompilerContainerProps) => {
hideWarnings
:
api
.
getConfiguration
(
'hideWarnings'
)
||
false
,
autoCompile
:
typeof
autoCompile
===
'boolean'
?
autoCompile
:
api
.
getConfiguration
(
'autoCompile'
)
||
false
,
includeNightlies
:
api
.
getConfiguration
(
'includeNightlies'
)
||
false
,
optimi
se
:
typeof
optimize
===
'boolean'
?
optimize
:
api
.
getConfiguration
(
'optimise'
)
||
false
,
optimi
ze
:
(
optimize
!==
null
)
&&
(
optimize
!==
undefined
)
?
optimize
:
false
,
runs
:
(
runs
!==
null
)
&&
(
runs
!==
'null'
)
&&
(
runs
!==
undefined
)
&&
(
runs
!==
'undefined'
)
?
runs
:
200
,
evmVersion
:
(
evmVersion
!==
null
)
&&
(
evmVersion
!==
'null'
)
&&
(
evmVersion
!==
undefined
)
&&
(
evmVersion
!==
'undefined'
)
?
evmVersion
:
'default'
}
...
...
libs/remix-ui/solidity-compiler/src/lib/icompiler-api.ts
deleted
100644 → 0
View file @
f0c2b731
export
type
onCurrentFileChanged
=
(
fileName
:
string
)
=>
void
export
interface
ICompilerApi
{
contractMap
:
{
file
:
string
}
|
Record
<
string
,
any
>
compileErrors
:
any
currentFile
:
string
configurationSettings
:
any
setHardHatCompilation
(
value
:
boolean
):
void
setSelectedVersion
(
version
:
string
):
void
getCompilationResult
():
any
setCompilerConfig
:
(
settings
:
any
)
=>
void
getParameters
:
()
=>
any
setParameters
:
(
params
)
=>
void
getConfiguration
:
(
name
:
string
)
=>
string
setConfiguration
:
(
name
:
string
,
value
:
string
)
=>
void
fileProviderOf
:
(
file
:
string
)
=>
string
getFileManagerMode
:
()
=>
string
fileExists
:
(
file
:
string
)
=>
Promise
<
boolean
>
writeFile
:
(
file
:
string
,
content
:
string
)
=>
Promise
<
void
>
readFile
:
(
file
:
string
)
=>
Promise
<
string
>
open
:
(
file
:
string
)
=>
void
onCurrentFileChanged
:
(
listener
:
onCurrentFileChanged
)
=>
void
}
libs/remix-ui/solidity-compiler/src/lib/solidity-compiler.tsx
View file @
5a22644c
...
...
@@ -44,8 +44,8 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => {
})
}
plugin
.
onSetWorkspace
=
async
(
workspace
:
any
)
=>
{
const
isHardhat
=
workspace
.
isLocalhost
&&
await
compileTabLogic
.
isHardhatProject
()
plugin
.
onSetWorkspace
=
async
(
isLocalhost
:
boolean
)
=>
{
const
isHardhat
=
isLocalhost
&&
await
compileTabLogic
.
isHardhatProject
()
setState
(
prevState
=>
{
return
{
...
prevState
,
currentFile
,
isHardhatProject
:
isHardhat
}
})
...
...
@@ -71,7 +71,7 @@ export const SolidityCompiler = (props: SolidityCompilerProps) => {
const
updateCurrentVersion
=
(
value
)
=>
{
setCurrentVersion
(
value
)
plugin
.
set
SelectedVersion
(
value
)
plugin
.
set
Parameters
({
version
:
value
}
)
}
const
modal
=
async
(
title
:
string
,
message
:
string
|
JSX
.
Element
,
okLabel
:
string
,
okFn
:
()
=>
void
,
cancelLabel
?:
string
,
cancelFn
?:
()
=>
void
)
=>
{
...
...
libs/remix-ui/solidity-compiler/src/lib/types/index.ts
View file @
5a22644c
export
type
onCurrentFileChanged
=
(
fileName
:
string
)
=>
void
export
interface
SolidityCompilerProps
{
plugin
:
{
currentFile
:
string
contractMap
:
{
file
:
string
}
|
Record
<
string
,
any
>
compileErrors
:
any
,
compileTabLogic
:
any
,
contractsDetails
:
Record
<
string
,
any
>
,
contentImport
:
any
,
call
:
(...
args
)
=>
void
on
:
(...
args
)
=>
void
,
setSelectedVersion
:
(
value
:
string
)
=>
void
,
configurationSettings
:
ConfigurationSettings
,
getConfiguration
:
(
value
:
string
)
=>
string
,
setConfiguration
:
(
name
:
string
,
value
:
string
)
=>
void
,
onCurrentFileChanged
:
(
fileName
:
string
)
=>
void
,
onResetResults
:
()
=>
void
,
onSetWorkspace
:
(
workspace
:
any
)
=>
void
,
onNoFileSelected
:
()
=>
void
,
onCompilationFinished
:
(
contractsDetails
:
any
,
contractMap
:
any
)
=>
void
},
plugin
:
ICompilerApi
}
export
interface
ICompilerApi
{
currentFile
:
string
contractMap
:
{
file
:
string
}
|
Record
<
string
,
any
>
compileErrors
:
any
compileTabLogic
:
any
contractsDetails
:
Record
<
string
,
any
>
configurationSettings
:
ConfigurationSettings
setHardHatCompilation
:
(
value
:
boolean
)
=>
void
getParameters
:
()
=>
any
setParameters
:
(
params
)
=>
void
getConfiguration
:
(
value
:
string
)
=>
string
setConfiguration
:
(
name
:
string
,
value
:
string
)
=>
void
getFileManagerMode
:
()
=>
string
setCompilerConfig
:
(
settings
:
any
)
=>
void
getCompilationResult
:
()
=>
any
onCurrentFileChanged
:
(
fileName
:
string
)
=>
void
onResetResults
:
()
=>
void
,
onSetWorkspace
:
(
isLocalhost
:
boolean
)
=>
void
onNoFileSelected
:
()
=>
void
onCompilationFinished
:
(
contractsDetails
:
any
,
contractMap
:
any
)
=>
void
onSessionSwitched
:
()
=>
void
onContentChanged
:
()
=>
void
fileExists
:
(
file
:
string
)
=>
Promise
<
boolean
>
writeFile
:
(
file
:
string
,
content
:
string
)
=>
Promise
<
void
>
readFile
:
(
file
:
string
)
=>
Promise
<
string
>
open
:
(
file
:
string
)
=>
void
}
export
interface
CompilerContainerProps
{
...
...
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