Validate proposed contributions
This commit is contained in:
@@ -25,12 +25,16 @@ class Proposal extends Base {
|
||||
});
|
||||
}
|
||||
|
||||
addProposal(proposalAttr, callOptions = {}) {
|
||||
let json = ContributionSerializer.serialize(proposalAttr);
|
||||
// TODO: validate against schema
|
||||
async addProposal(proposalAttr, callOptions = {}) {
|
||||
const contribution = new ContributionSerializer(proposalAttr);
|
||||
|
||||
try { await contribution.validate(); }
|
||||
catch (error) { return Promise.reject(error); }
|
||||
|
||||
const jsonStr = contribution.serialize();
|
||||
|
||||
return this.ipfs
|
||||
.add(json)
|
||||
.add(jsonStr)
|
||||
.then((ipfsHashAttr) => {
|
||||
let proposal = [
|
||||
proposalAttr.contributorId,
|
||||
|
||||
Reference in New Issue
Block a user