Merge branch 'master' into githubmodal

pull/5370/head
bunsenstraat 3 years ago committed by GitHub
commit 07e9f9b78b
  1. 10
      libs/remix-ui/publish-to-storage/src/lib/publishOnSwarm.tsx
  2. 10
      libs/remix-ui/publish-to-storage/src/lib/publishToIPFS.tsx

@ -26,6 +26,7 @@ export const publishToSwarm = async (contract, api) => {
} }
await Promise.all(Object.keys(metadata.sources).map(fileName => { await Promise.all(Object.keys(metadata.sources).map(fileName => {
return new Promise((resolve, reject) => {
// find hash // find hash
let hash = null let hash = null
try { try {
@ -41,7 +42,7 @@ export const publishToSwarm = async (contract, api) => {
}) })
} }
} catch (e) { } catch (e) {
throw new Error('Error while extracting the hash from metadata.json') return reject(new Error('Error while extracting the hash from metadata.json'))
} }
api.readFile(fileName).then((content) => { api.readFile(fileName).then((content) => {
@ -50,8 +51,15 @@ export const publishToSwarm = async (contract, api) => {
hash: hash, hash: hash,
filename: fileName filename: fileName
}) })
resolve({
content: content,
hash: hash,
filename: fileName
})
}).catch((error) => { }).catch((error) => {
console.log(error) console.log(error)
reject(error)
})
}) })
})) }))

@ -24,6 +24,7 @@ export const publishToIPFS = async (contract, api) => {
} }
await Promise.all(Object.keys(metadata.sources).map(fileName => { await Promise.all(Object.keys(metadata.sources).map(fileName => {
return new Promise((resolve, reject) => {
// find hash // find hash
let hash = null let hash = null
try { try {
@ -39,7 +40,7 @@ export const publishToIPFS = async (contract, api) => {
}) })
} }
} catch (e) { } catch (e) {
throw new Error('Error while extracting the hash from metadata.json') return reject(new Error('Error while extracting the hash from metadata.json'))
} }
api.readFile(fileName).then((content) => { api.readFile(fileName).then((content) => {
@ -48,8 +49,15 @@ export const publishToIPFS = async (contract, api) => {
hash: hash, hash: hash,
filename: fileName filename: fileName
}) })
resolve({
content: content,
hash: hash,
filename: fileName
})
}).catch((error) => { }).catch((error) => {
console.log(error) console.log(error)
reject(error)
})
}) })
})) }))
// publish the list of sources in order, fail if any failed // publish the list of sources in order, fail if any failed

Loading…
Cancel
Save