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
a1d7198c
Unverified
Commit
a1d7198c
authored
Jan 23, 2020
by
yann300
Committed by
GitHub
Jan 23, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2544 from ethereum/fixIPFSUpload
fix ipfs upload
parents
1ff9e8ce
91c78bf9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
67 additions
and
10 deletions
+67
-10
compile-tab.js
src/app/tabs/compile-tab.js
+2
-2
publishOnIpfs.js
src/lib/publishOnIpfs.js
+14
-4
publishOnSwarm.js
src/lib/publishOnSwarm.js
+14
-4
publishContract.js
test-browser/tests/publishContract.js
+37
-0
No files found.
src/app/tabs/compile-tab.js
View file @
a1d7198c
...
...
@@ -239,11 +239,11 @@ class CompileTab extends ViewPlugin {
${
selectEl
}
</div>
<article class="px-2 mt-2 pb-0">
<button class="btn btn-secondary btn-block" title="Publish on Swarm" onclick="
${()
=>
{
this
.
publish
(
'swarm'
)
}}
">
<button
id="publishOnSwarm"
class="btn btn-secondary btn-block" title="Publish on Swarm" onclick="
${()
=>
{
this
.
publish
(
'swarm'
)
}}
">
<span>Publish on Swarm</span>
<img id="
swarmLogo
" class="
$
{
css
.
storageLogo
}
ml-2" src="
${
swarmImg
}
">
</button>
<button class="btn btn-secondary btn-block" title="Publish on Ipfs" onclick="
${()
=>
{
this
.
publish
(
'ipfs'
)
}}
">
<button
id="publishOnIpfs"
class="btn btn-secondary btn-block" title="Publish on Ipfs" onclick="
${()
=>
{
this
.
publish
(
'ipfs'
)
}}
">
<span>Publish on Ipfs</span>
<img id="
ipfsLogo
" class="
$
{
css
.
storageLogo
}
ml-2" src="
${
ipfsImg
}
">
</button>
...
...
src/lib/publishOnIpfs.js
View file @
a1d7198c
...
...
@@ -27,11 +27,21 @@ module.exports = (contract, fileManager, cb, ipfsVerifiedPublishCallBack) => {
async
.
eachSeries
(
Object
.
keys
(
metadata
.
sources
),
function
(
fileName
,
cb
)
{
// find hash
var
hash
let
hash
=
null
try
{
hash
=
metadata
.
sources
[
fileName
].
urls
[
1
].
match
(
'dweb:/ipfs/(.+)'
)[
1
]
// we try extract the hash defined in the metadata.json
// in order to check if the hash that we get after publishing is the same as the one located in metadata.json
// if it's not the same, we throw "hash mismatch between solidity bytecode and uploaded content"
// if we don't find the hash in the metadata.json, the check is not done.
//
// TODO: refactor this with publishOnSwarm
if
(
metadata
.
sources
[
fileName
].
urls
)
{
metadata
.
sources
[
fileName
].
urls
.
forEach
(
url
=>
{
if
(
url
.
includes
(
'ipfs'
))
hash
=
url
.
match
(
'dweb:/ipfs/(.+)'
)[
1
]
})
}
}
catch
(
e
)
{
return
cb
(
'
Metadata inconsistency
'
)
return
cb
(
'
Error while extracting the hash from metadata.json
'
)
}
fileManager
.
fileProviderOf
(
fileName
).
get
(
fileName
,
(
error
,
content
)
=>
{
...
...
@@ -94,7 +104,7 @@ module.exports = (contract, fileManager, cb, ipfsVerifiedPublishCallBack) => {
async
function
ipfsVerifiedPublish
(
content
,
expectedHash
,
cb
)
{
try
{
const
results
=
await
severalGatewaysPush
(
content
)
if
(
results
!==
expectedHash
)
{
if
(
expectedHash
&&
results
!==
expectedHash
)
{
cb
(
null
,
{
message
:
'hash mismatch between solidity bytecode and uploaded content.'
,
url
:
'dweb:/ipfs/'
+
results
,
hash
:
results
})
}
else
{
cb
(
null
,
{
message
:
'ok'
,
url
:
'dweb:/ipfs/'
+
results
,
hash
:
results
})
...
...
src/lib/publishOnSwarm.js
View file @
a1d7198c
...
...
@@ -20,11 +20,21 @@ module.exports = (contract, fileManager, cb, swarmVerifiedPublishCallBack) => {
async
.
eachSeries
(
Object
.
keys
(
metadata
.
sources
),
function
(
fileName
,
cb
)
{
// find hash
var
hash
let
hash
=
null
try
{
hash
=
metadata
.
sources
[
fileName
].
urls
[
0
].
match
(
'(bzzr|bzz-raw)://(.+)'
)[
1
]
// we try extract the hash defined in the metadata.json
// in order to check if the hash that we get after publishing is the same as the one located in metadata.json
// if it's not the same, we throw "hash mismatch between solidity bytecode and uploaded content"
// if we don't find the hash in the metadata.json, the check is not done.
//
// TODO: refactor this with publishOnIpfs
if
(
metadata
.
sources
[
fileName
].
urls
)
{
metadata
.
sources
[
fileName
].
urls
.
forEach
(
url
=>
{
if
(
url
.
includes
(
'bzz'
))
hash
=
url
.
match
(
'(bzzr|bzz-raw)://(.+)'
)[
1
]
})
}
}
catch
(
e
)
{
return
cb
(
'
Metadata inconsistency
'
)
return
cb
(
'
Error while extracting the hash from metadata.json
'
)
}
fileManager
.
fileProviderOf
(
fileName
).
get
(
fileName
,
(
error
,
content
)
=>
{
...
...
@@ -90,7 +100,7 @@ function swarmVerifiedPublish (content, expectedHash, cb) {
swarmgw
.
put
(
content
,
function
(
err
,
ret
)
{
if
(
err
)
{
cb
(
err
)
}
else
if
(
ret
!==
expectedHash
)
{
}
else
if
(
expectedHash
&&
ret
!==
expectedHash
)
{
cb
(
null
,
{
message
:
'hash mismatch between solidity bytecode and uploaded content.'
,
url
:
'bzz-raw://'
+
ret
,
hash
:
ret
})
}
else
{
cb
(
null
,
{
message
:
'ok'
,
url
:
'bzz-raw://'
+
ret
,
hash
:
ret
})
...
...
test-browser/tests/publishContract.js
0 → 100644
View file @
a1d7198c
'use strict'
var
init
=
require
(
'../helpers/init'
)
var
sauce
=
require
(
'./sauce'
)
module
.
exports
=
{
before
:
function
(
browser
,
done
)
{
init
(
browser
,
done
)
},
'@sources'
:
function
()
{
return
[]
},
'Publish on IPFS'
:
function
(
browser
)
{
browser
.
waitForElementVisible
(
'#icon-panel'
,
10000
)
.
clickLaunchIcon
(
'fileExplorers'
)
.
switchFile
(
'browser/3_Ballot.sol'
)
.
verifyContracts
([
'Ballot'
])
.
click
(
'#publishOnIpfs'
)
.
getModalBody
((
value
,
done
)
=>
{
if
(
value
.
indexOf
(
'Metadata published successfully.'
)
===
-
1
)
browser
.
assert
.
fail
(
'ipfs deploy failed'
,
''
,
''
)
if
(
value
.
indexOf
(
'dweb:/ipfs'
)
===
-
1
)
browser
.
assert
.
fail
(
'ipfs deploy failed'
,
''
,
''
)
done
()
})
.
modalFooterOKClick
()
},
'Publish on Swarm'
:
function
(
browser
)
{
browser
.
click
(
'#publishOnSwarm'
)
.
getModalBody
((
value
,
done
)
=>
{
if
(
value
.
indexOf
(
'Metadata published successfully.'
)
===
-
1
)
browser
.
assert
.
fail
(
'swarm deploy failed'
,
''
,
''
)
if
(
value
.
indexOf
(
'bzz'
)
===
-
1
)
browser
.
assert
.
fail
(
'swarm deploy failed'
,
''
,
''
)
done
()
})
.
end
()
},
tearDown
:
sauce
}
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