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