Adjust for latest naming conventions

expept the renaming of ipfsHash to hashDigest all are already reflected
in the contracts
This commit is contained in:
2018-04-17 11:43:44 +02:00
parent 539f32911d
commit f0f82a96fb
8 changed files with 23 additions and 27 deletions
+3 -6
View File
@@ -26,11 +26,8 @@ export default class Contributor extends Base {
return this.functions.getContributorById(id)
.then((data) => {
// TODO: remove as soon as the contract provides the id
data.id = id;
// TODO: rename address to account
data.address = data.account;
// TODO: remove when naming updated on the contract
data.hashDigest = data.ipfsHash;
return data;
})
// Fetch IPFS data if available
@@ -48,7 +45,7 @@ export default class Contributor extends Base {
.then((ipfsHashAttr) => {
let contributor = [
contributorAttr.address,
ipfsHashAttr.ipfsHash,
ipfsHashAttr.hashDigest,
ipfsHashAttr.hashFunction,
ipfsHashAttr.hashSize,
contributorAttr.isCore,
+4 -7
View File
@@ -24,13 +24,10 @@ export default class Operator extends Base {
getById(id) {
id = ethers.utils.bigNumberify(id);
return this.functions.proposals(id)
return this.functions.getProposal(id)
.then((data) => {
// TODO: remove as soon as the contract provides the id
data.id = id;
// TODO: rename creatorAddress to creator
data.creatorAddress = data.creator;
// TODO: remove when naming updated on the contract
data.hashDigest = data.ipfsHash;
return data;
})
// Fetch IPFS data if available
@@ -49,7 +46,7 @@ export default class Operator extends Base {
let proposal = [
proposalAttr.contributorId,
proposalAttr.amount,
ipfsHashAttr.ipfsHash,
ipfsHashAttr.hashDigest,
ipfsHashAttr.hashFunction,
ipfsHashAttr.hashSize,
];
+6 -3
View File
@@ -13,6 +13,9 @@ export default class IPFS {
if (!data.hashSize || data.hashSize === 0) {
return data;
}
// merge ipfsHash (encoded from hashDigest, hashSize, hashFunction)
data.ipfsHash = this.encodeHash(data);
return this.cat(data)
.then(deserialize)
.then((attributes) => {
@@ -39,15 +42,15 @@ export default class IPFS {
decodeHash(ipfsHash) {
let multihash = multihashes.decode(multihashes.fromB58String(ipfsHash));
return {
ipfsHash: '0x' + multihashes.toHexString(multihash.digest),
hashDigest: '0x' + multihashes.toHexString(multihash.digest),
hashSize: multihash.length,
hashFunction: multihash.code,
sourceHash: ipfsHash
ipfsHash: ipfsHash
};
}
encodeHash(hashData) {
let digest = this._ipfsAPI.Buffer.from(hashData.ipfsHash.slice(2), 'hex');
let digest = this._ipfsAPI.Buffer.from(hashData.hashDigest.slice(2), 'hex');
return multihashes.encode(digest, hashData.hashFunction, hashData.hashSize);
}