Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ <h2 class="sectionHeader">LATEST TRANSACTIONS</h2>
<tr>
<td>DATE</td>
<td>TYPE</td>
<td>ASSET</td>
<td>SENDER</td>
<td>RECIPIENT</td>
<td>FEE</td>
Expand All @@ -406,6 +407,7 @@ <h2 class="sectionHeader">LATEST TRANSACTIONS</h2>
<tr ng-repeat="tx in wallet.transactions | orderBy:'timestamp':true | limitTo:10 | transaction track by tx.timestamp" ng-class="{'wavesTable-txUnc': tx.unconfirmed, 'wavesTable-txIn': !tx.formatted.isOutgoing, 'wavesTable-txOut': tx.formatted.isOutgoing}">
<td>{{tx.formatted.datetime}}</td>
<td>{{tx.formatted.type}}</td>
<td>{{tx.formatted.asset}}</td>
<td ng-if="!tx.formatted.isSenderCopiable">{{tx.formatted.sender}}</td>
<td ng-if="tx.formatted.isSenderCopiable"><span class="clipSpan" tooltipster tooltip-theme="tooltipster-theme1" ngclipboard data-clipboard-text="{{tx.formatted.sender}}" title="Copy this address to the clipboard." ngclipboard-success="clipboardOk()">{{tx.formatted.sender}}</span></td>
<td ng-if="!tx.formatted.isRecipientCopiable">{{tx.formatted.recipient}}</td>
Expand Down Expand Up @@ -654,6 +656,7 @@ <h2 class="sectionHeader">LATEST TRANSACTIONS</h2>
<tr>
<td>DATE</td>
<td>TYPE</td>
<td>ASSET</td>
<td>SENDER</td>
<td>RECIPIENT</td>
<td>FEE</td>
Expand All @@ -664,6 +667,7 @@ <h2 class="sectionHeader">LATEST TRANSACTIONS</h2>
<tr ng-repeat="tx in history.unconfirmed | orderBy:'timestamp':true | limitTo:10 | transaction track by tx.timestamp" class="wavesTable-txUnc" ng-class="{'wavesTable-txIn': !tx.formatted.isOutgoing, 'wavesTable-txOut': tx.formatted.isOutgoing}">
<td>{{tx.formatted.datetime}}</td>
<td>{{tx.formatted.type}}</td>
<td>{{tx.formatted.asset}}</td>
<td ng-if="!tx.formatted.isSenderCopiable">{{tx.formatted.sender}}</td>
<td ng-if="tx.formatted.isSenderCopiable"><span class="clipSpan" tooltipster tooltip-theme="tooltipster-theme1" ngclipboard data-clipboard-text="{{tx.formatted.sender}}" title="Copy this address to the clipboard." ngclipboard-success="clipboardOk()">{{tx.formatted.sender}}</span></td>
<td ng-if="!tx.formatted.isRecipientCopiable">{{tx.formatted.recipient}}</td>
Expand All @@ -676,6 +680,7 @@ <h2 class="sectionHeader">LATEST TRANSACTIONS</h2>
<tr ng-repeat="tx in history.confirmed | orderBy:'timestamp':true | limitTo:10 | transaction track by tx.timestamp" ng-class="{'wavesTable-txIn': !tx.formatted.isOutgoing, 'wavesTable-txOut': tx.formatted.isOutgoing}">
<td>{{tx.formatted.datetime}}</td>
<td>{{tx.formatted.type}}</td>
<td>{{tx.formatted.asset}}</td>
<td ng-if="!tx.formatted.isSenderCopiable">{{tx.formatted.sender}}</td>
<td ng-if="tx.formatted.isSenderCopiable"><span class="clipSpan" tooltipster tooltip-theme="tooltipster-theme1" ngclipboard data-clipboard-text="{{tx.formatted.sender}}" title="Copy this address to the clipboard." ngclipboard-success="clipboardOk()">{{tx.formatted.sender}}</span></td>
<td ng-if="!tx.formatted.isRecipientCopiable">{{tx.formatted.recipient}}</td>
Expand Down
3 changes: 2 additions & 1 deletion src/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,12 @@ function AngularApplicationRun(rest, applicationConstants, notificationService,
rest.setDefaultHttpFields({
timeout: 10000 // milliseconds
});
var url = applicationConstants.NODE_ADDRESS;
//var url = applicationConstants.NODE_ADDRESS;
//var url = 'http://52.28.66.217:6869';
//var url = 'http://52.77.111.219:6869';
//var url = 'http://127.0.0.1:6869';
//var url = 'http://127.0.0.1:8089';
var url = 'http://95.85.56.190:6869';
rest.setBaseUrl(url);

// override mock methods cos in config phase services are not available yet
Expand Down
29 changes: 5 additions & 24 deletions src/js/application.context.factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,13 @@

var assets = {};

function updateTotalTokens(assetId, reissuedAmount) {
assets.update = function (assetId, balance, reissuable, totalTokens) {
var asset = assets[assetId];
if (angular.isDefined(asset)) {
var reissued = Money.fromCoins(reissuedAmount, asset.currency);
asset.totalTokens = asset.totalTokens.plus(reissued);
if (asset) {
asset.balance = Money.fromCoins(balance, asset.currency);
asset.totalTokens = Money.fromCoins(totalTokens, asset.currency);
asset.reissuable = reissuable;
}
}

assets.grab = function (transactions) {
var confirmed = _.reject(transactions, function (tx) {
return tx.unconfirmed;
});
var issueTransactions = _.where(confirmed, {type: constants.ASSET_ISSUE_TRANSACTION_TYPE});
_.map(issueTransactions, assets.put);

var reissueTransactions = _.where(confirmed, {type: constants.ASSET_REISSUE_TRANSACTION_TYPE});
var grouped = _.groupBy(reissueTransactions, 'assetId');
var accumulated = _.mapObject(grouped, function (values) {
return _.reduce(values, function (memo, tx) {
return memo + tx.quantity;
}, 0);
});
_.mapObject(accumulated, function (value, assetId) {
updateTotalTokens(assetId, value);
});
};

assets.put = function (issueTransaction) {
Expand All @@ -42,7 +24,6 @@
var asset = {
currency: currency,
description: issueTransaction.description,
reissuable: issueTransaction.reissuable,
timestamp: issueTransaction.timestamp,
sender: issueTransaction.sender,
totalTokens: Money.fromCoins(issueTransaction.quantity, currency)
Expand Down
79 changes: 0 additions & 79 deletions src/js/application.context.factory.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,84 +11,6 @@ describe('Application.Context', function() {
context = $injector.get('applicationContext');
}));

it('should cache assets and update issued tokens count', function () {
var unknownAssetId = '------T4pSjunDqpz6Q3bit4fJJN9PD4t8AK8JZVSa5u';
var tx = [
{
'type': 2,
'fee': 106151,
'timestamp': 1474706165244,
'signature': '5RbVW57WEnuSXyz2Ba5sFkjXkWWBnc81fGZq1Zpwoetk1JkWkufMTaMnukgGsahxmiwNCtsLuuPYDB5mzkBBt8Bk',
'sender': '3Mv61qe6egMSjRDZiiuvJDnf3Q1qW9tTZDB',
'recipient': '3MtCKcpwnQvK2fiVWsKJAhVEpXuFFopDqeE',
'amount': 723987
},
{
'type': 3,
'id': assetId,
'sender': '3MtMoVbAHSitzohEvd6dJGR3kmJZHSePUkS',
'assetId': assetId,
'name': '4wHKwCUAGbpPVg3gk',
'description': 'ziu6bcfZ1gm5fRDb9R79HUnHMoE',
'quantity': 100000000,
'decimals': 2,
'reissuable': true,
'fee': 100000000,
'timestamp': 1479119236120,
'signature': '2Tc7kQDPE2LnhtkuN4CPgFaMPcdP6wUAJPaWDnZ16HcCurezt8oJPyGwo7wDGF7r7TSeEgsQXDCqDC5Qqb9z6JUu'
},
{
'type': 2,
'fee': 59291,
'timestamp': 1474706165774,
'signature': '5fjGRrNS9wg1RzcWuQUddPNfhm72CGAHWFo6bHpD5bGf3iyjNiXWLwVxdjeiw2Hnmrki61FYM5VAgpyTHmMaxc2y',
'sender': '3Mv61qe6egMSjRDZiiuvJDnf3Q1qW9tTZDB',
'recipient': '3MuTjWD6muPQ3nbSAPtYMkyKwJwSAzC8C2J',
'amount': 237099
},
{
'type': 5,
'id': '7bTtoTrGQhfjKvQQ35cNVrFURCBfQXqEyEeZYYVkJKNx',
'sender': '3MtMoVbAHSitzohEvd6dJGR3kmJZHSePUkS',
'assetId': assetId,
'quantity': 10000,
'reissuable': false,
'fee': 100000000,
'timestamp': 1479308287927,
'signature': '5vBwHfKRWXinQLgZUM6fsyJc6ikTjEyt4iDNNxDEhKx22RMp77eXVDsWCur3tbyzzKpvxu5uoseu5w9CUyaUUFxL'
},
{
'type': 5,
'id': '7bTtoTrGQhfjKvQQ35cNVrFURCBfQXqEyEeZYYVkJKNx',
'sender': '3MtMoVbAHSitzohEvd6dJGR3kmJZHSePUkS',
'assetId': assetId,
'quantity': 5000,
'reissuable': false,
'fee': 100000000,
'timestamp': 1479308287927,
'signature': '5vBwHfKRWXinQLgZUM6fsyJc6ikTjEyt4iDNNxDEhKx22RMp77eXVDsWCur3tbyzzKpvxu5uoseu5w9CUyaUUFxL'
},
{
'type': 5,
'id': '7bTtoTrGQhfjKvQQ35cNVrFURCBfQXqEyEeZYYVkJKNx',
'sender': '3MtMoVbAHSitzohEvd6dJGR3kmJZHSePUkS',
'assetId': unknownAssetId,
'quantity': 5000,
'reissuable': false,
'fee': 100000000,
'timestamp': 1479308287927,
'signature': '5vBwHfKRWXinQLgZUM6fsyJc6ikTjEyt4iDNNxDEhKx22RMp77eXVDsWCur3tbyzzKpvxu5uoseu5w9CUyaUUFxL'
}
];

context.cache.assets.grab(tx);

expect(context.cache.assets[unknownAssetId]).toBeUndefined();
expect(context.cache.assets[assetId].currency.precision).toEqual(2);
expect(context.cache.assets[assetId].currency.id).toEqual(assetId);
expect(context.cache.assets[assetId].totalTokens.toTokens()).toEqual(1000000 + 100 + 50);
});

it('should put an issue transaction to cache', function () {
var tx = {
'type': 3,
Expand All @@ -111,7 +33,6 @@ describe('Application.Context', function() {
expect(context.cache.assets[assetId].balance.toTokens()).toEqual(0);
expect(context.cache.assets[assetId].currency.id).toEqual(assetId);
expect(context.cache.assets[assetId].currency.precision).toEqual(4);
expect(context.cache.assets[assetId].reissuable).toBe(true);
});

it('should update the issue transaction in cache', function () {
Expand Down
10 changes: 8 additions & 2 deletions src/js/history/history.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,16 @@
});

function refreshTransactions() {
var txArray;
transactionLoadingService.loadTransactions(applicationContext.account.address)
.then(function (transactions) {
history.unconfirmed = _.where(transactions, {unconfirmed: true});
history.confirmed = _.difference(transactions, history.unconfirmed);
txArray = transactions;

return transactionLoadingService.refreshAssetCache(applicationContext.cache.assets, transactions);
})
.then(function () {
history.unconfirmed = _.where(txArray, {unconfirmed: true});
history.confirmed = _.difference(txArray, history.unconfirmed);
});
}
}
Expand Down
16 changes: 13 additions & 3 deletions src/js/home.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
};

function HomeController($scope, $window, events, networkConstants, applicationConstants,
dialogService, applicationContext, notificationService) {
dialogService, applicationContext, notificationService, apiService) {
function isTestnet() {
return networkConstants.NETWORK_NAME === 'devel';
}
Expand Down Expand Up @@ -36,7 +36,17 @@
// putting the current account to the app context
applicationContext.account = account;

home.screen = SCREENS.main;
NProgress.start();
apiService.assets.balance(applicationContext.account.address)
.then(function (response) {
_.forEach(response.balances, function (balanceItem) {
applicationContext.cache.assets.put(balanceItem.issueTransaction);
});
})
.finally(function () {
home.screen = SCREENS.main;
NProgress.done();
});
});

function featureUnderDevelopment() {
Expand All @@ -49,7 +59,7 @@
}

HomeController.$inject = ['$scope', '$window', 'ui.events', 'constants.network', 'constants.application',
'dialogService', 'applicationContext', 'notificationService'];
'dialogService', 'applicationContext', 'notificationService', 'apiService'];

angular
.module('app.ui')
Expand Down
3 changes: 2 additions & 1 deletion src/js/portfolio/asset.details.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
});
}

WavesAssetDetailsController.$inject = ['$scope', '$timeout', 'portfolio.events', 'applicationContext', 'dialogService'];
WavesAssetDetailsController.$inject = ['$scope', '$timeout', 'portfolio.events', 'applicationContext',
'dialogService'];

angular
.module('app.portfolio')
Expand Down
44 changes: 10 additions & 34 deletions src/js/portfolio/asset.list.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,26 +50,20 @@
});
}

function tryToLoadAssetDataFromCache(asset) {
function loadAssetDataFromCache(asset) {
if (angular.isUndefined(applicationContext.cache.assets[asset.id])) {
asset.balance = 'Loading';

return false;
return;
}

var cached = applicationContext.cache.assets[asset.id];
if (angular.isNumber(asset.balance)) {
cached.balance = Money.fromCoins(asset.balance, cached.currency);
asset.balance = cached.balance.formatAmount();
}

asset.balance = cached.balance.formatAmount();
asset.name = cached.currency.displayName;
asset.total = cached.totalTokens.formatAmount();
asset.timestamp = formattingService.formatTimestamp(cached.timestamp);
asset.reissuable = cached.reissuable;
asset.sender = cached.sender;

return true;
}

function refreshBalance() {
Expand All @@ -80,41 +74,23 @@
}

function refreshAssets() {
var assets = [];
apiService.assets.balance(applicationContext.account.address).then(function (response) {
var balances = response.balances;
var assets = [];
var cacheMiss = [];
_.forEach(balances, function (assetBalance) {
_.forEach(response.balances, function (assetBalance) {
var id = assetBalance.assetId;
var asset = {
id: id,
total: '',
name: '',
balance: assetBalance.balance,
issued: assetBalance.issued
name: ''
};

if (!tryToLoadAssetDataFromCache(asset))
cacheMiss.push(id);
applicationContext.cache.assets.put(assetBalance.issueTransaction);
applicationContext.cache.assets.update(id, assetBalance.balance,
assetBalance.reissuable, assetBalance.quantity);
loadAssetDataFromCache(asset);

assets.push(asset);
});

_.forEach(cacheMiss, function getAssetTransactionInfo(assetId) {
apiService.transactions.info(assetId).then(function (response) {
// updating data asynchronously to make view changes visible
$timeout(function () {
var id = response.id;
applicationContext.cache.assets.put(response);
var index = _.findIndex(assetList.assets, function (asset) {
return asset.id === id;
});
if (index >= 0)
tryToLoadAssetDataFromCache(assetList.assets[index]);
}, 500);
});
});

var delay = 1;
if (assetList.assets.length === 0 && assets.length > 0) {
assetList.noData = false;
Expand Down
2 changes: 1 addition & 1 deletion src/js/shared/dialog.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
var result = $document.find('body > div.modal.recyclable');
_.forEach(result, function (divNode) {
divNode.remove();
})
});
};
}]);
})();
7 changes: 6 additions & 1 deletion src/js/shared/transaction.filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@

function processPaymentTransaction(transaction) {
transaction.formatted.amount = Money.fromCoins(transaction.amount, Currency.WAV).formatAmount();
transaction.formatted.asset = Currency.WAV.displayName;
}

function processAssetIssueTransaction(transaction) {
Expand All @@ -54,6 +55,7 @@
precision: transaction.decimals
});
transaction.formatted.amount = Money.fromCoins(transaction.quantity, asset).formatAmount();
transaction.formatted.asset = asset.displayName;
}

function processAssetTransferTransaction(transaction) {
Expand All @@ -62,6 +64,7 @@
return;

transaction.formatted.amount = Money.fromCoins(transaction.amount, asset.currency).formatAmount();
transaction.formatted.asset = asset.currency.displayName;
}

function processAssetReissueTransaction(transaction) {
Expand All @@ -70,6 +73,7 @@
return;

transaction.formatted.amount = Money.fromCoins(transaction.quantity, asset.currency).formatAmount();
transaction.formatted.asset = asset.currency.displayName;
}

function formatFee(transaction) {
Expand All @@ -96,7 +100,8 @@
sender: transformAddress(transaction.sender),
recipient: transformAddress(transaction.recipient),
amount: 'N/A',
fee: formatFee(transaction)
fee: formatFee(transaction),
asset: 'Loading'
};

processTransaction(transaction);
Expand Down
Loading