Integrate the new model

This commit is contained in:
Yemel Jardi 2014-08-29 10:50:52 -03:00
parent 16091bd330
commit 862dfa72c9
5 changed files with 17 additions and 15 deletions

View File

@ -100,14 +100,14 @@ Insight.prototype.getSocket = function(url, opts) {
/** @private */
Insight.prototype.request = function(path, cb) {
preconditions.checkArgument(url).shouldBeFunction(cb);
preconditions.checkArgument(path).shouldBeFunction(cb);
request(this.url + path, cb);
}
/** @private */
Insight.prototype.requestPost = function(path, data, cb) {
preconditions.checkArgument(url).checkArgument(data).shouldBeFunction(cb);
request.post(this.url, cb).form(data);
preconditions.checkArgument(path).checkArgument(data).shouldBeFunction(cb);
request({method: "POST", url: this.url + path, json: data}, cb);
}
Insight.prototype.destroy = function() {
@ -165,7 +165,7 @@ Insight.prototype.broadcast = function(rawtx, cb) {
this.requestPost('/api/tx/send', {rawtx: rawtx}, function(err, res, body) {
if (err || res.statusCode != 200) cb(err || res);
cb(null, JSON.parse(body).txid);
cb(null, body.txid);
});
};
@ -219,7 +219,7 @@ Insight.prototype.getUnspent = function(addresses, cb) {
this.requestPost('/api/addrs/utxo', {addrs: addresses.join(',')}, function(err, res, body) {
if (err || res.statusCode != 200) return cb(err || res);
cb(null, JSON.parse(body));
cb(null, body);
});
};

View File

@ -120,7 +120,7 @@ angular.module('copayApp.services')
});
w.on('ready', function(myPeerID) {
$rootScope.wallet = w;
root.setConnectionListeners();
root.setConnectionListeners($rootScope.wallet);
if ($rootScope.pendingPayment) {
$location.path('send');
@ -196,13 +196,7 @@ angular.module('copayApp.services')
$rootScope.updatingBalance = true;
w.getBalance(function(err, balanceSat, balanceByAddrSat, safeBalanceSat) {
if (err) {
console.error('Error: ' + err.message); //TODO
root._setCommError();
return null;
} else {
root._clearCommError();
}
if (err) throw err;
var satToUnit = 1 / config.unitToSatoshi;
var COIN = bitcore.util.COIN;
@ -325,7 +319,7 @@ angular.module('copayApp.services')
if (!$rootScope.wallet) return;
root.updateAddressList();
var currentAddrs = $rootScope.wallet.blockchain.getListeners();
var currentAddrs = $rootScope.wallet.blockchain.subscribed;
var allAddrs = $rootScope.addrInfos;
var newAddrs = [];

View File

@ -54,6 +54,7 @@ module.exports = function(config) {
'test/lib/chai-should.js',
'test/lib/chai-expect.js',
'test/mocks/FakeWallet.js',
'test/mocks/FakeBlockchainSocket.js',
'test/mocks/FakePayProServer.js',
'test/mocha.conf.js',

View File

@ -11,6 +11,7 @@
},
"version": "0.4.7",
"dependencies": {
"browser-request": "^0.3.2",
"mocha": "^1.18.2",
"mocha-lcov-reporter": "0.0.1",
"optimist": "^0.6.1",
@ -71,7 +72,7 @@
"travis-cov": "0.2.5",
"uglifyify": "1.2.3",
"crypto-js": "3.1.2",
"shelljs":"0.3.0"
"shelljs": "0.3.0"
},
"main": "app.js",
"homepage": "https://github.com/bitpay/copay",

View File

@ -40,6 +40,9 @@ var createBundle = function(opts) {
b.require('bitcore/node_modules/browserify-buffertools/buffertools.js', {
expose: 'buffertools'
});
b.require('browser-request', {
expose: 'request'
});
b.require('./copay', {
expose: 'copay'
@ -88,6 +91,9 @@ var createBundle = function(opts) {
b.require('./test/mocks/FakeBlockchain', {
expose: './mocks/FakeBlockchain'
});
b.require('./test/mocks/FakeBlockchainSocket', {
expose: './mocks/FakeBlockchainSocket'
});
b.require('./test/mocks/FakeNetwork', {
expose: './mocks/FakeNetwork'
});