Adjust for latest naming conventions #56

Merged
bumi merged 2 commits from naming-conventions into master 2018-04-17 11:29:09 +00:00
8 changed files with 23 additions and 27 deletions
+4 -4
View File
@@ -9,7 +9,7 @@ export default Component.extend({
// Default attributes used by reset
attributes: {
address: null,
account: null,
name: null,
kind: 'person',
url: null,
@@ -24,9 +24,9 @@ export default Component.extend({
this.reset();
},
isValidAddress: computed('kredits.ethProvider', 'address', function() {
isValidAccount: computed('kredits.ethProvider', 'account', function() {
// TODO: add proper address validation
return this.address !== '';
return this.account !== '';
}),
isValidName: notEmpty('name'),
isValidURL: notEmpty('url'),
@@ -34,7 +34,7 @@ export default Component.extend({
isValidGithubUsername: notEmpty('github_username'),
isValidWikiUsername: notEmpty('wiki_username'),
isValid: and(
'isValidAddress',
'isValidAccount',
'isValidName',
'isValidGithubUID'
),
+3 -3
View File
@@ -9,11 +9,11 @@
</label>
</p>
<p>
{{input name="address"
{{input name="account"
type="text"
placeholder="0xF18E631Ea191aE4ebE70046Fcb01a436554421BA4"
value=address
class=(if isValidAddress 'valid' '')}}
value=account
class=(if isValidAccount 'valid' '')}}
</p>
<p>
<select required onchange={{action (mut kind) value="target.value"}}>
+1 -1
View File
@@ -13,7 +13,7 @@
<tr class="metadata {{if contributor.isCurrentUser 'current-user'}} {{if contributor.showMetadata 'visible'}}">
<td colspan="2">
<ul>
<li><a href="https://testnet.etherscan.io/address/{{contributor.address}}">Inspect Ethereum transactions</a></li>
<li><a href="https://testnet.etherscan.io/address/{{contributor.account}}">Inspect Ethereum transactions</a></li>
{{#if contributor.ipfsHash}}
<li><a href="https://ipfs.io/ipfs/{{contributor.ipfsHash}}">Inspect IPFS profile</a></li>
{{/if}}
+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);
}
+1 -2
View File
@@ -5,8 +5,7 @@ import bignumber from 'kredits-web/utils/cps/bignumber';
export default EmberObject.extend({
// Contract
id: bignumber('idRaw', 'toString'),
// TODO: Should we rename it to account like in the contract?
address: null,
account: null,
balance: bignumber('balanceRaw', 'toNumber'),
isCore: false,
ipfsHash: null,
+1 -1
View File
@@ -5,7 +5,7 @@
{{#if kredits.currentUserIsCore }}
(core)
{{/if}}
Account: {{kredits.currentUser.address}}
Account: {{kredits.currentUser.account}}
{{/if}}
</section>
{{/if}}