Files
kredits-web/app/models/contributor.js
T
bumi 32846194b6 Handle bignumber conversions
The kredits module always returns raw data from the contract. For uint
values these are bignumbers.
To handle those in the ember app we need to convert them to string or to
number.
2018-04-09 20:31:34 +02:00

33 lines
780 B
JavaScript

import computed from 'ember-computed';
import EmberObject from 'ember-object';
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,
balance: bignumber('balanceRaw', 'toNumber'),
isCore: false,
ipfsHash: null,
// IPFS
kind: null,
name: null,
url: null,
github_username: null,
github_uid: null,
wiki_username: null,
ipfsData: '',
// Deprecated
isCurrentUser: false,
avatarURL: computed('github_uid', function() {
let github_uid = this.get('github_uid');
if (github_uid) {
return `https://avatars2.githubusercontent.com/u/${github_uid}?v=3&s=128`;
}
}),
});