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
d4c60aed
Commit
d4c60aed
authored
Jun 28, 2021
by
filip mertens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
plugin compilerMetadata
parent
340d7800
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
137 additions
and
65 deletions
+137
-65
app.js
apps/remix-ide/src/app.js
+3
-2
settings-tab.js
apps/remix-ide/src/app/tabs/settings-tab.js
+3
-3
compiler-content-imports.ts
...piler-content-imports/src/lib/compiler-content-imports.ts
+1
-1
.eslintrc
libs/remix-core-plugin/compiler-metadata/.eslintrc
+1
-0
README.md
libs/remix-core-plugin/compiler-metadata/README.md
+3
-0
package.json
libs/remix-core-plugin/compiler-metadata/package.json
+11
-0
index.ts
libs/remix-core-plugin/compiler-metadata/src/index.ts
+1
-0
compiler-metadata.ts
...ore-plugin/compiler-metadata/src/lib/compiler-metadata.ts
+56
-58
tsconfig.json
libs/remix-core-plugin/compiler-metadata/tsconfig.json
+10
-0
tsconfig.lib.json
libs/remix-core-plugin/compiler-metadata/tsconfig.lib.json
+12
-0
nx.json
nx.json
+3
-0
tsconfig.json
tsconfig.json
+3
-0
workspace.json
workspace.json
+30
-1
No files found.
apps/remix-ide/src/app.js
View file @
d4c60aed
...
@@ -21,6 +21,7 @@ import { CompilerArtefacts } from '@remix-core-plugin/compiler-artefacts'
...
@@ -21,6 +21,7 @@ import { CompilerArtefacts } from '@remix-core-plugin/compiler-artefacts'
import
{
CompilerImports
}
from
'@remix-core-plugin/compiler-content-imports'
import
{
CompilerImports
}
from
'@remix-core-plugin/compiler-content-imports'
import
{
FetchAndCompile
}
from
'@remix-core-plugin/compiler-fetch-and-compile'
import
{
FetchAndCompile
}
from
'@remix-core-plugin/compiler-fetch-and-compile'
import
{
OffsetToLineColumnConverter
}
from
'@remix-core-plugin/offset-line-to-column-converter'
import
{
OffsetToLineColumnConverter
}
from
'@remix-core-plugin/offset-line-to-column-converter'
import
{
CompilerMetadata
}
from
'@remix-core-plugin/compiler-metadata'
import
migrateFileSystem
from
'./migrateFileSystem'
import
migrateFileSystem
from
'./migrateFileSystem'
...
@@ -42,7 +43,7 @@ const FileProvider = require('./app/files/fileProvider')
...
@@ -42,7 +43,7 @@ const FileProvider = require('./app/files/fileProvider')
const
DGitProvider
=
require
(
'./app/files/dgitProvider'
)
const
DGitProvider
=
require
(
'./app/files/dgitProvider'
)
const
WorkspaceFileProvider
=
require
(
'./app/files/workspaceFileProvider'
)
const
WorkspaceFileProvider
=
require
(
'./app/files/workspaceFileProvider'
)
const
toolTip
=
require
(
'./app/ui/tooltip'
)
const
toolTip
=
require
(
'./app/ui/tooltip'
)
const
CompilerMetadata
=
require
(
'./app/files/compiler-metadata'
)
const
Blockchain
=
require
(
'./blockchain/blockchain.js'
)
const
Blockchain
=
require
(
'./blockchain/blockchain.js'
)
...
@@ -269,7 +270,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
...
@@ -269,7 +270,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
const
blockchain
=
new
Blockchain
(
registry
.
get
(
'config'
).
api
)
const
blockchain
=
new
Blockchain
(
registry
.
get
(
'config'
).
api
)
// ----------------- compilation metadata generation service ---------
// ----------------- compilation metadata generation service ---------
const
compilerMetadataGenerator
=
new
CompilerMetadata
(
blockchain
,
fileManager
,
registry
.
get
(
'config'
).
api
)
const
compilerMetadataGenerator
=
new
CompilerMetadata
()
// ----------------- compilation result service (can keep track of compilation results) ----------------------------
// ----------------- compilation result service (can keep track of compilation results) ----------------------------
const
compilersArtefacts
=
new
CompilerArtefacts
()
// store all the compilation results (key represent a compiler name)
const
compilersArtefacts
=
new
CompilerArtefacts
()
// store all the compilation results (key represent a compiler name)
registry
.
put
({
api
:
compilersArtefacts
,
name
:
'compilersartefacts'
})
registry
.
put
({
api
:
compilersArtefacts
,
name
:
'compilersartefacts'
})
...
...
apps/remix-ide/src/app/tabs/settings-tab.js
View file @
d4c60aed
...
@@ -11,7 +11,7 @@ const _paq = window._paq = window._paq || []
...
@@ -11,7 +11,7 @@ const _paq = window._paq = window._paq || []
const
profile
=
{
const
profile
=
{
name
:
'settings'
,
name
:
'settings'
,
displayName
:
'Settings'
,
displayName
:
'Settings'
,
methods
:
[
'get
GithubAccessToken
'
],
methods
:
[
'get'
],
events
:
[],
events
:
[],
icon
:
'assets/img/settings.webp'
,
icon
:
'assets/img/settings.webp'
,
description
:
'Remix-IDE settings'
,
description
:
'Remix-IDE settings'
,
...
@@ -257,8 +257,8 @@ module.exports = class SettingsTab extends ViewPlugin {
...
@@ -257,8 +257,8 @@ module.exports = class SettingsTab extends ViewPlugin {
return
this
.
_view
.
el
return
this
.
_view
.
el
}
}
get
GithubAccessToken
(
)
{
get
(
key
)
{
return
this
.
config
.
get
(
'settings/gist-access-token'
)
return
this
.
config
.
get
(
key
)
}
}
updateMatomoAnalyticsChoice
(
isChecked
)
{
updateMatomoAnalyticsChoice
(
isChecked
)
{
...
...
libs/remix-core-plugin/compiler-content-imports/src/lib/compiler-content-imports.ts
View file @
d4c60aed
...
@@ -24,7 +24,7 @@ export class CompilerImports extends Plugin {
...
@@ -24,7 +24,7 @@ export class CompilerImports extends Plugin {
async
setToken
()
{
async
setToken
()
{
const
protocol
=
typeof
window
!==
'undefined'
&&
window
.
location
.
protocol
const
protocol
=
typeof
window
!==
'undefined'
&&
window
.
location
.
protocol
const
token
=
await
this
.
call
(
'settings'
,
'get
GithubAccessT
oken'
)
const
token
=
await
this
.
call
(
'settings'
,
'get
'
,
'settings/gist-access-t
oken'
)
this
.
urlResolver
.
setGistToken
(
token
,
protocol
)
this
.
urlResolver
.
setGistToken
(
token
,
protocol
)
}
}
...
...
libs/remix-core-plugin/compiler-metadata/.eslintrc
0 → 100644
View file @
d4c60aed
{ "extends": "../../../.eslintrc", "rules": {}, "ignorePatterns": ["!**/*"] }
libs/remix-core-plugin/compiler-metadata/README.md
0 → 100644
View file @
d4c60aed
# remix-core-plugin-compiler-metadata
This library was generated with
[
Nx
](
https://nx.dev
)
.
libs/remix-core-plugin/compiler-metadata/package.json
0 → 100644
View file @
d4c60aed
{
"name"
:
"@remix-core-plugin/compiler-metadata"
,
"version"
:
"0.0.1"
,
"description"
:
"This library was generated with [Nx](https://nx.dev)."
,
"main"
:
"index.js"
,
"scripts"
:
{
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
},
"author"
:
"Remix Team"
,
"license"
:
"ISC"
}
libs/remix-core-plugin/compiler-metadata/src/index.ts
0 → 100644
View file @
d4c60aed
export
*
from
'./lib/compiler-metadata'
apps/remix-ide/src/app/files/compiler-metadata.j
s
→
libs/remix-core-plugin/compiler-metadata/src/lib/compiler-metadata.t
s
View file @
d4c60aed
'use strict'
'use strict'
import
{
Plugin
}
from
'@remixproject/engine'
import
{
Plugin
}
from
'@remixproject/engine'
import
*
as
packageJson
from
'../../../../../package.json'
import
{
joinPath
}
from
'../../lib/helper'
import
{
CompilerAbstract
}
from
'@remix-project/remix-solidity'
import
{
CompilerAbstract
}
from
'@remix-project/remix-solidity'
const
profile
=
{
const
profile
=
{
name
:
'compilerMetadata'
,
name
:
'compilerMetadata'
,
methods
:
[
'deployMetadataOf'
],
methods
:
[
'deployMetadataOf'
],
events
:
[],
events
:
[],
version
:
packageJson
.
version
version
:
'0.0.1'
}
}
class
CompilerMetadata
extends
Plugin
{
export
class
CompilerMetadata
extends
Plugin
{
constructor
(
blockchain
,
fileManager
,
config
)
{
networks
:
string
[]
innerPath
:
string
constructor
()
{
super
(
profile
)
super
(
profile
)
this
.
blockchain
=
blockchain
this
.
fileManager
=
fileManager
this
.
config
=
config
this
.
networks
=
[
'VM:-'
,
'main:1'
,
'ropsten:3'
,
'rinkeby:4'
,
'kovan:42'
,
'görli:5'
,
'Custom'
]
this
.
networks
=
[
'VM:-'
,
'main:1'
,
'ropsten:3'
,
'rinkeby:4'
,
'kovan:42'
,
'görli:5'
,
'Custom'
]
this
.
innerPath
=
'artifacts'
this
.
innerPath
=
'artifacts'
}
}
_JSONFileName
(
path
,
contractName
)
{
_JSONFileName
(
path
,
contractName
)
{
return
joinPath
(
path
,
this
.
innerPath
,
contractName
+
'.json'
)
return
this
.
joinPath
(
path
,
this
.
innerPath
,
contractName
+
'.json'
)
}
}
_MetadataFileName
(
path
,
contractName
)
{
_MetadataFileName
(
path
,
contractName
)
{
return
joinPath
(
path
,
this
.
innerPath
,
contractName
+
'_metadata.json'
)
return
this
.
joinPath
(
path
,
this
.
innerPath
,
contractName
+
'_metadata.json'
)
}
}
onActivation
()
{
onActivation
()
{
var
self
=
this
var
self
=
this
this
.
on
(
'solidity'
,
'compilationFinished'
,
(
file
,
source
,
languageVersion
,
data
)
=>
{
this
.
on
(
'solidity'
,
'compilationFinished'
,
async
(
file
,
source
,
languageVersion
,
data
)
=>
{
if
(
!
self
.
config
.
get
(
'settings/generate-contract-metadata'
))
return
if
(
!
await
this
.
call
(
'settings'
,
'get'
,
'settings/generate-contract-metadata'
))
return
const
compiler
=
new
CompilerAbstract
(
languageVersion
,
data
,
source
)
const
compiler
=
new
CompilerAbstract
(
languageVersion
,
data
,
source
)
var
provider
=
self
.
fileManager
.
fileProviderOf
(
source
.
target
)
var
path
=
self
.
_extractPathOf
(
source
.
target
)
var
path
=
self
.
fileManager
.
extractPathOf
(
source
.
target
)
if
(
provider
)
{
compiler
.
visitContracts
((
contract
)
=>
{
compiler
.
visitContracts
((
contract
)
=>
{
if
(
contract
.
file
!==
source
.
target
)
return
if
(
contract
.
file
!==
source
.
target
)
return
(
async
()
=>
{
const
fileName
=
self
.
_JSONFileName
(
path
,
contract
.
name
)
const
content
=
await
this
.
call
(
'fileManager'
,
'exists'
,
fileName
)
?
await
this
.
call
(
'fileManager'
,
'readFile'
,
fileName
)
:
null
await
this
.
_setArtefacts
(
content
,
contract
,
path
)
})()
})
})
}
var
fileName
=
self
.
_JSONFileName
(
path
,
contract
.
name
)
_extractPathOf
(
file
)
{
var
metadataFileName
=
self
.
_MetadataFileName
(
path
,
contract
.
name
)
var
reg
=
/
(
.*
)(\/)
.*/
provider
.
get
(
fileName
,
(
error
,
content
)
=>
{
var
path
=
reg
.
exec
(
file
)
if
(
!
error
)
{
return
path
?
path
[
1
]
:
'/'
}
async
_setArtefacts
(
content
,
contract
,
path
)
{
content
=
content
||
'{}'
content
=
content
||
'{}'
var
metadata
var
metadata
try
{
try
{
...
@@ -51,10 +57,12 @@ class CompilerMetadata extends Plugin {
...
@@ -51,10 +57,12 @@ class CompilerMetadata extends Plugin {
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
log
(
e
)
console
.
log
(
e
)
}
}
var
fileName
=
this
.
_JSONFileName
(
path
,
contract
.
name
)
var
metadataFileName
=
this
.
_MetadataFileName
(
path
,
contract
.
name
)
var
deploy
=
metadata
.
deploy
||
{}
var
deploy
=
metadata
.
deploy
||
{}
self
.
networks
.
forEach
((
network
)
=>
{
this
.
networks
.
forEach
((
network
)
=>
{
deploy
[
network
]
=
self
.
_syncContext
(
contract
,
deploy
[
network
]
||
{})
deploy
[
network
]
=
this
.
_syncContext
(
contract
,
deploy
[
network
]
||
{})
})
})
let
parsedMetadata
let
parsedMetadata
...
@@ -63,7 +71,7 @@ class CompilerMetadata extends Plugin {
...
@@ -63,7 +71,7 @@ class CompilerMetadata extends Plugin {
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
log
(
e
)
console
.
log
(
e
)
}
}
if
(
parsedMetadata
)
provider
.
set
(
metadataFileName
,
JSON
.
stringify
(
parsedMetadata
,
null
,
'
\
t'
))
if
(
parsedMetadata
)
await
this
.
call
(
'fileManager'
,
'writeFile'
,
metadataFileName
,
JSON
.
stringify
(
parsedMetadata
,
null
,
'
\
t'
))
var
data
=
{
var
data
=
{
deploy
,
deploy
,
...
@@ -75,13 +83,7 @@ class CompilerMetadata extends Plugin {
...
@@ -75,13 +83,7 @@ class CompilerMetadata extends Plugin {
},
},
abi
:
contract
.
object
.
abi
abi
:
contract
.
object
.
abi
}
}
await
this
.
call
(
'fileManager'
,
'writeFile'
,
fileName
,
JSON
.
stringify
(
data
,
null
,
'
\
t'
))
provider
.
set
(
fileName
,
JSON
.
stringify
(
data
,
null
,
'
\
t'
))
}
})
})
}
})
}
}
_syncContext
(
contract
,
metadata
)
{
_syncContext
(
contract
,
metadata
)
{
...
@@ -103,46 +105,42 @@ class CompilerMetadata extends Plugin {
...
@@ -103,46 +105,42 @@ class CompilerMetadata extends Plugin {
return
metadata
return
metadata
}
}
// TODO: is only called by dropdownLogic and can be moved there
async
deployMetadataOf
(
contractName
,
fileLocation
)
{
deployMetadataOf
(
contractName
,
fileLocation
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
var
provider
let
path
let
path
if
(
fileLocation
)
{
if
(
fileLocation
)
{
provider
=
this
.
fileManager
.
fileProviderOf
(
fileLocation
)
path
=
fileLocation
.
split
(
'/'
)
path
=
fileLocation
.
split
(
'/'
)
path
.
pop
()
path
.
pop
()
path
=
path
.
join
(
'/'
)
path
=
path
.
join
(
'/'
)
}
else
{
}
else
{
provider
=
this
.
fileManager
.
currentFileProvider
()
try
{
path
=
this
.
fileManager
.
currentPath
()
path
=
this
.
_extractPathOf
(
await
this
.
call
(
'fileManager'
,
'getCurrentFile'
))
}
}
catch
(
err
)
{
if
(
provider
)
{
this
.
blockchain
.
detectNetwork
((
err
,
{
id
,
name
}
=
{})
=>
{
if
(
err
)
{
console
.
log
(
err
)
console
.
log
(
err
)
reject
(
err
)
throw
new
Error
(
err
)
}
else
{
}
var
fileName
=
this
.
_JSONFileName
(
path
,
contractName
)
}
provider
.
get
(
fileName
,
(
error
,
content
)
=>
{
try
{
if
(
error
)
return
reject
(
error
)
const
{
id
,
name
}
=
await
this
.
call
(
'network'
,
'detectNetwork'
)
if
(
!
content
)
return
resolve
(
)
const
fileName
=
this
.
_JSONFileName
(
path
,
contractName
)
try
{
try
{
var
metadata
=
JSON
.
parse
(
content
)
const
content
=
await
this
.
call
(
'fileManager'
,
'readFile'
,
fileName
)
if
(
!
content
)
return
null
let
metadata
=
JSON
.
parse
(
content
)
metadata
=
metadata
.
deploy
||
{}
metadata
=
metadata
.
deploy
||
{}
return
resolve
(
metadata
[
name
+
':'
+
id
]
||
metadata
[
name
]
||
metadata
[
id
]
||
metadata
[
name
.
toLowerCase
()
+
':'
+
id
]
||
metadata
[
name
.
toLowerCase
()])
return
metadata
[
name
+
':'
+
id
]
||
metadata
[
name
]
||
metadata
[
id
]
||
metadata
[
name
.
toLowerCase
()
+
':'
+
id
]
||
metadata
[
name
.
toLowerCase
()]
}
catch
(
e
)
{
}
catch
(
err
)
{
reject
(
e
.
message
)
console
.
log
(
err
)
throw
new
Error
(
err
)
}
}
})
}
catch
(
err
)
{
console
.
log
(
err
)
throw
new
Error
(
err
)
}
}
})
}
else
{
reject
(
new
Error
(
`Please select the folder in the file explorer where the metadata of
${
contractName
}
can be found`
))
}
}
})
joinPath
(...
paths
)
{
paths
=
paths
.
filter
((
value
)
=>
value
!==
''
).
map
((
path
)
=>
path
.
replace
(
/^
\/
|
\/
$/g
,
''
))
// remove first and last slash)
if
(
paths
.
length
===
1
)
return
paths
[
0
]
return
paths
.
join
(
'/'
)
}
}
}
}
module
.
exports
=
CompilerMetadata
libs/remix-core-plugin/compiler-metadata/tsconfig.json
0 → 100644
View file @
d4c60aed
{
"extends"
:
"../../../tsconfig.json"
,
"files"
:
[],
"include"
:
[],
"references"
:
[
{
"path"
:
"./tsconfig.lib.json"
}
]
}
libs/remix-core-plugin/compiler-metadata/tsconfig.lib.json
0 → 100644
View file @
d4c60aed
{
"extends"
:
"./tsconfig.json"
,
"compilerOptions"
:
{
"module"
:
"commonjs"
,
"outDir"
:
"../../../dist/out-tsc"
,
"declaration"
:
true
,
"rootDir"
:
"./src"
,
"types"
:
[
"node"
]
},
"exclude"
:
[
"**/*.spec.ts"
],
"include"
:
[
"**/*.ts"
]
}
nx.json
View file @
d4c60aed
...
@@ -114,6 +114,9 @@
...
@@ -114,6 +114,9 @@
},
},
"offset-line-to-column-converter"
:
{
"offset-line-to-column-converter"
:
{
"tags"
:
[]
"tags"
:
[]
},
"compiler-metadata"
:
{
"tags"
:
[]
}
}
}
}
}
}
tsconfig.json
View file @
d4c60aed
...
@@ -52,6 +52,9 @@
...
@@ -52,6 +52,9 @@
],
],
"@remix-core-plugin/offset-line-to-column-converter"
:
[
"@remix-core-plugin/offset-line-to-column-converter"
:
[
"libs/remix-core-plugin/offset-line-to-column-converter/src/index.ts"
"libs/remix-core-plugin/offset-line-to-column-converter/src/index.ts"
],
"@remix-core-plugin/compiler-metadata"
:
[
"libs/remix-core-plugin/compiler-metadata/src/index.ts"
]
]
}
}
},
},
...
...
workspace.json
View file @
d4c60aed
...
@@ -840,7 +840,6 @@
...
@@ -840,7 +840,6 @@
]
]
}
}
},
},
"build"
:
{
"build"
:
{
"builder"
:
"@nrwl/node:package"
,
"builder"
:
"@nrwl/node:package"
,
"options"
:
{
"options"
:
{
...
@@ -881,6 +880,36 @@
...
@@ -881,6 +880,36 @@
}
}
}
}
}
}
},
"compiler-metadata"
:
{
"root"
:
"libs/remix-core-plugin/compiler-metadata"
,
"sourceRoot"
:
"libs/remix-core-plugin/compiler-metadata/src"
,
"projectType"
:
"library"
,
"schematics"
:
{},
"architect"
:
{
"lint"
:
{
"builder"
:
"@nrwl/linter:lint"
,
"options"
:
{
"linter"
:
"eslint"
,
"tsConfig"
:
[
"libs/remix-core-plugin/compiler-metadata/tsconfig.lib.json"
],
"exclude"
:
[
"**/node_modules/**"
,
"!libs/remix-core-plugin/compiler-metadata/**/*"
]
}
},
"build"
:
{
"builder"
:
"@nrwl/node:package"
,
"options"
:
{
"outputPath"
:
"dist/libs/core-plugin/compiler-metadata"
,
"tsConfig"
:
"libs/remix-core-plugin/compiler-metadata/tsconfig.lib.json"
,
"packageJson"
:
"libs/remix-core-plugin/compiler-metadata/package.json"
,
"main"
:
"libs/remix-core-plugin/compiler-metadata/src/index.ts"
}
}
}
}
}
},
},
"cli"
:
{
"cli"
:
{
...
...
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