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
1de5dd72
Unverified
Commit
1de5dd72
authored
May 22, 2019
by
yann300
Committed by
GitHub
May 22, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2008 from ethereum/fixToaster
Fix Swarm integration
parents
0aabc474
fbeebd11
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
61 additions
and
29 deletions
+61
-29
publishOnSwarm.js
src/app/contract/publishOnSwarm.js
+13
-2
basicReadOnlyExplorer.js
src/app/files/basicReadOnlyExplorer.js
+3
-3
file-explorer.js
src/app/files/file-explorer.js
+2
-1
file-explorer-styles.js
src/app/files/styles/file-explorer-styles.js
+7
-1
compile-tab.js
src/app/tabs/compile-tab.js
+1
-1
cmdInterpreterAPI.js
src/lib/cmdInterpreterAPI.js
+35
-21
No files found.
src/app/contract/publishOnSwarm.js
View file @
1de5dd72
...
@@ -47,6 +47,11 @@ module.exports = (contract, fileManager, cb, swarmVerifiedPublishCallBack) => {
...
@@ -47,6 +47,11 @@ module.exports = (contract, fileManager, cb, swarmVerifiedPublishCallBack) => {
var
uploaded
=
[]
var
uploaded
=
[]
async
.
eachSeries
(
sources
,
function
(
item
,
cb
)
{
async
.
eachSeries
(
sources
,
function
(
item
,
cb
)
{
swarmVerifiedPublish
(
item
.
content
,
item
.
hash
,
(
error
,
result
)
=>
{
swarmVerifiedPublish
(
item
.
content
,
item
.
hash
,
(
error
,
result
)
=>
{
try
{
item
.
hash
=
result
.
url
.
match
(
'bzz-raw://(.+)'
)[
1
]
}
catch
(
e
)
{
item
.
hash
=
'<Metadata inconsistency> - '
+
item
.
fileName
}
if
(
!
error
&&
swarmVerifiedPublishCallBack
)
swarmVerifiedPublishCallBack
(
item
)
if
(
!
error
&&
swarmVerifiedPublishCallBack
)
swarmVerifiedPublishCallBack
(
item
)
item
.
output
=
result
item
.
output
=
result
uploaded
.
push
(
item
)
uploaded
.
push
(
item
)
...
@@ -55,10 +60,16 @@ module.exports = (contract, fileManager, cb, swarmVerifiedPublishCallBack) => {
...
@@ -55,10 +60,16 @@ module.exports = (contract, fileManager, cb, swarmVerifiedPublishCallBack) => {
cb
(
error
)
cb
(
error
)
})
})
},
()
=>
{
},
()
=>
{
swarmVerifiedPublish
(
JSON
.
stringify
(
metadata
),
''
,
(
error
,
result
)
=>
{
const
metadataContent
=
JSON
.
stringify
(
metadata
)
swarmVerifiedPublish
(
metadataContent
,
''
,
(
error
,
result
)
=>
{
try
{
contract
.
metadataHash
=
result
.
url
.
match
(
'bzz-raw://(.+)'
)[
1
]
}
catch
(
e
)
{
contract
.
metadataHash
=
'<Metadata inconsistency> - metadata.json'
}
if
(
!
error
&&
swarmVerifiedPublishCallBack
)
{
if
(
!
error
&&
swarmVerifiedPublishCallBack
)
{
swarmVerifiedPublishCallBack
({
swarmVerifiedPublishCallBack
({
content
:
contract
.
metadata
,
content
:
metadataContent
,
hash
:
contract
.
metadataHash
hash
:
contract
.
metadataHash
})
})
}
}
...
...
src/app/files/basicReadOnlyExplorer.js
View file @
1de5dd72
...
@@ -41,13 +41,13 @@ class BasicReadOnlyExplorer {
...
@@ -41,13 +41,13 @@ class BasicReadOnlyExplorer {
}
}
set
(
path
,
content
,
cb
)
{
set
(
path
,
content
,
cb
)
{
var
unprefixedPath
=
this
.
removePrefix
(
path
)
this
.
addReadOnly
(
path
,
content
)
this
.
addReadOnly
(
unprefixedPath
,
content
)
if
(
cb
)
cb
()
if
(
cb
)
cb
()
return
true
return
true
}
}
addReadOnly
(
path
,
content
,
rawPath
)
{
addReadOnly
(
path
,
content
,
rawPath
)
{
path
=
this
.
removePrefix
(
path
)
try
{
// lazy try to format JSON
try
{
// lazy try to format JSON
content
=
JSON
.
stringify
(
JSON
.
parse
(
content
),
null
,
'
\
t'
)
content
=
JSON
.
stringify
(
JSON
.
parse
(
content
),
null
,
'
\
t'
)
}
catch
(
e
)
{}
}
catch
(
e
)
{}
...
@@ -67,7 +67,7 @@ class BasicReadOnlyExplorer {
...
@@ -67,7 +67,7 @@ class BasicReadOnlyExplorer {
this
.
paths
[
this
.
type
][
split
]
=
{
isDirectory
:
folder
}
this
.
paths
[
this
.
type
][
split
]
=
{
isDirectory
:
folder
}
this
.
files
[
path
]
=
content
this
.
files
[
path
]
=
content
this
.
normalizedNames
[
rawPath
]
=
path
this
.
normalizedNames
[
rawPath
]
=
path
this
.
event
.
trigger
(
'fileAdded'
,
[
path
,
true
])
this
.
event
.
trigger
(
'fileAdded'
,
[
this
.
type
+
'/'
+
path
,
true
])
return
true
return
true
}
}
...
...
src/app/files/file-explorer.js
View file @
1de5dd72
...
@@ -158,7 +158,8 @@ function fileExplorer (localRegistry, files, menuItems) {
...
@@ -158,7 +158,8 @@ function fileExplorer (localRegistry, files, menuItems) {
return
yo
`
return
yo
`
<div class="
${
css
.
items
}
">
<div class="
${
css
.
items
}
">
<label
<label
class=
${
css
.
label
}
title="
${
data
.
path
}
"
class="
${
css
.
label
}
${
!
isRoot
?
css
.
leaf
:
''
}
"
data-path="
${
data
.
path
}
"
data-path="
${
data
.
path
}
"
style="
${
isRoot
?
'font-weight:bold;'
:
''
}
"
style="
${
isRoot
?
'font-weight:bold;'
:
''
}
"
onkeydown=
${
editModeOff
}
onkeydown=
${
editModeOff
}
...
...
src/app/files/styles/file-explorer-styles.js
View file @
1de5dd72
...
@@ -2,7 +2,13 @@ var csjs = require('csjs-inject')
...
@@ -2,7 +2,13 @@ var csjs = require('csjs-inject')
var
css
=
csjs
`
var
css
=
csjs
`
.label {
.label {
margin-top : 4px
margin-top : 4px;
}
.leaf {
overflow : hidden;
text-overflow : ellipsis;
width : 90%;
margin-bottom : 0px;
}
}
.fileexplorer {
.fileexplorer {
box-sizing : border-box;
box-sizing : border-box;
...
...
src/app/tabs/compile-tab.js
View file @
1de5dd72
...
@@ -259,7 +259,7 @@ class CompileTab extends CompilerApi {
...
@@ -259,7 +259,7 @@ class CompileTab extends CompilerApi {
modalDialogCustom
.
alert
(
yo
`<span>Metadata published successfully.<br> <pre>
${
result
}
</pre> </span>`
)
modalDialogCustom
.
alert
(
yo
`<span>Metadata published successfully.<br> <pre>
${
result
}
</pre> </span>`
)
}
}
},
(
item
)
=>
{
// triggered each time there's a new verified publish (means hash correspond)
},
(
item
)
=>
{
// triggered each time there's a new verified publish (means hash correspond)
this
.
swarmfileProvider
.
addReadOnly
(
item
.
hash
,
item
.
content
)
this
.
swarmfileProvider
.
addReadOnly
(
'swarm/'
+
item
.
hash
,
item
.
content
)
})
})
}
}
}
}
...
...
src/lib/cmdInterpreterAPI.js
View file @
1de5dd72
...
@@ -4,6 +4,7 @@ var async = require('async')
...
@@ -4,6 +4,7 @@ var async = require('async')
var
remixLib
=
require
(
'remix-lib'
)
var
remixLib
=
require
(
'remix-lib'
)
var
EventManager
=
require
(
'../lib/events'
)
var
EventManager
=
require
(
'../lib/events'
)
var
CompilerImport
=
require
(
'../app/compiler/compiler-imports'
)
var
executionContext
=
require
(
'../execution-context'
)
var
executionContext
=
require
(
'../execution-context'
)
var
toolTip
=
require
(
'../app/ui/tooltip'
)
var
toolTip
=
require
(
'../app/ui/tooltip'
)
var
globalRegistry
=
require
(
'../global/registry'
)
var
globalRegistry
=
require
(
'../global/registry'
)
...
@@ -20,6 +21,7 @@ class CmdInterpreterAPI {
...
@@ -20,6 +21,7 @@ class CmdInterpreterAPI {
self
.
_components
.
registry
=
localRegistry
||
globalRegistry
self
.
_components
.
registry
=
localRegistry
||
globalRegistry
self
.
_components
.
terminal
=
terminal
self
.
_components
.
terminal
=
terminal
self
.
_components
.
sourceHighlighter
=
new
SourceHighlighter
()
self
.
_components
.
sourceHighlighter
=
new
SourceHighlighter
()
self
.
_components
.
fileImport
=
new
CompilerImport
()
self
.
_deps
=
{
self
.
_deps
=
{
app
:
self
.
_components
.
registry
.
get
(
'app'
).
api
,
app
:
self
.
_components
.
registry
.
get
(
'app'
).
api
,
fileManager
:
self
.
_components
.
registry
.
get
(
'filemanager'
).
api
,
fileManager
:
self
.
_components
.
registry
.
get
(
'filemanager'
).
api
,
...
@@ -141,28 +143,40 @@ class CmdInterpreterAPI {
...
@@ -141,28 +143,40 @@ class CmdInterpreterAPI {
}
}
loadurl
(
url
,
cb
)
{
loadurl
(
url
,
cb
)
{
const
self
=
this
const
self
=
this
self
.
_deps
.
app
.
importExternal
(
url
,
(
err
,
content
)
=>
{
self
.
_components
.
fileImport
.
import
(
url
,
if
(
err
)
{
(
loadingMsg
)
=>
{
toolTip
(
loadingMsg
)
},
toolTip
(
`Unable to load
${
url
}
:
${
err
}
`
)
(
err
,
content
,
cleanUrl
,
type
,
url
)
=>
{
if
(
cb
)
cb
(
err
)
if
(
err
)
{
}
else
{
toolTip
(
`Unable to load
${
url
}
:
${
err
}
`
)
try
{
if
(
cb
)
cb
(
err
)
content
=
JSON
.
parse
(
content
)
}
else
{
async
.
eachOfSeries
(
content
.
sources
,
(
value
,
file
,
callbackSource
)
=>
{
self
.
_deps
.
fileManager
.
setFile
(
type
+
'/'
+
cleanUrl
,
content
)
var
url
=
value
.
urls
[
0
]
// @TODO retrieve all other contents ?
try
{
self
.
_deps
.
app
.
importExternal
(
url
,
(
error
,
content
)
=>
{
content
=
JSON
.
parse
(
content
)
if
(
error
)
{
async
.
eachOfSeries
(
content
.
sources
,
(
value
,
file
,
callbackSource
)
=>
{
toolTip
(
`Cannot retrieve the content of
${
url
}
:
${
error
}
`
)
var
url
=
value
.
urls
[
0
]
// @TODO retrieve all other contents ?
}
self
.
_components
.
fileImport
.
import
(
url
,
callbackSource
()
(
loadingMsg
)
=>
{
toolTip
(
loadingMsg
)
},
async
(
error
,
content
,
cleanUrl
,
type
,
url
)
=>
{
if
(
error
)
{
toolTip
(
`Cannot retrieve the content of
${
url
}
:
${
error
}
`
)
return
callbackSource
(
`Cannot retrieve the content of
${
url
}
:
${
error
}
`
)
}
else
{
try
{
await
self
.
_deps
.
fileManager
.
setFile
(
type
+
'/'
+
cleanUrl
,
content
)
callbackSource
()
}
catch
(
e
)
{
callbackSource
(
e
.
message
)
}
}
})
},
(
error
)
=>
{
if
(
cb
)
cb
(
error
)
})
})
},
(
error
)
=>
{
}
catch
(
e
)
{}
if
(
cb
)
cb
(
error
)
if
(
cb
)
cb
()
})
}
}
catch
(
e
)
{}
})
if
(
cb
)
cb
()
}
})
}
}
setproviderurl
(
url
,
cb
)
{
setproviderurl
(
url
,
cb
)
{
executionContext
.
setProviderFromEndpoint
(
url
,
'web3'
,
(
error
)
=>
{
executionContext
.
setProviderFromEndpoint
(
url
,
'web3'
,
(
error
)
=>
{
...
...
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