|
|
@ -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
|
|
|
|