aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2016-01-17 15:38:40 +0800
committerkumavis <aaron@kumavis.me>2016-01-17 15:38:40 +0800
commite50e1894435e47e3e23a7c97e61ca679cfa3222b (patch)
tree735b2859e7988afe3b89150ff7da0b7f6c390a87 /app
parent722acdad35e229c80ebb59a8d6672c430016a7b2 (diff)
downloadtangerine-wallet-browser-e50e1894435e47e3e23a7c97e61ca679cfa3222b.tar
tangerine-wallet-browser-e50e1894435e47e3e23a7c97e61ca679cfa3222b.tar.gz
tangerine-wallet-browser-e50e1894435e47e3e23a7c97e61ca679cfa3222b.tar.bz2
tangerine-wallet-browser-e50e1894435e47e3e23a7c97e61ca679cfa3222b.tar.lz
tangerine-wallet-browser-e50e1894435e47e3e23a7c97e61ca679cfa3222b.tar.xz
tangerine-wallet-browser-e50e1894435e47e3e23a7c97e61ca679cfa3222b.tar.zst
tangerine-wallet-browser-e50e1894435e47e3e23a7c97e61ca679cfa3222b.zip
wallet sync fix
Diffstat (limited to 'app')
-rw-r--r--app/scripts/lib/idmgmt.js39
-rw-r--r--app/scripts/lib/stream-provider.js2
2 files changed, 33 insertions, 8 deletions
diff --git a/app/scripts/lib/idmgmt.js b/app/scripts/lib/idmgmt.js
index b13116a45..795418bb9 100644
--- a/app/scripts/lib/idmgmt.js
+++ b/app/scripts/lib/idmgmt.js
@@ -11,6 +11,10 @@ module.exports = IdentityManager
var provider = null
var pubsub = new EventEmitter()
+pubsub.on('block', function(){
+ updateIdentities()
+})
+
function IdentityManager(opts){
opts = opts || {}
providerEngine = opts.providerEngine
@@ -32,24 +36,41 @@ function IdentityManager(opts){
}
}
+// plugin popup
+IdentityManager.prototype.getState = getState
+IdentityManager.prototype.subscribe = subscribe
+IdentityManager.prototype.submitPassword = submitPassword
+IdentityManager.prototype.setSelectedAddress = setSelectedAddress
+IdentityManager.prototype.signTransaction = signTransaction
+IdentityManager.prototype.setLocked = setLocked
+// eth rpc
+IdentityManager.prototype.getAccounts = getAccounts
+IdentityManager.prototype.confirmTransaction = confirmTransaction
+// etc
+IdentityManager.prototype.newBlock = newBlock
+IdentityManager.prototype.setProvider = setProvider
+
+
+
function setProvider(_provider){
provider = _provider
}
function newBlock(block){
pubsub.emit('block', block)
- updateIdentities()
}
// on new block, update our accounts (but only if we're unlocked)
function subscribe(cb){
pubsub.on('block', sendUpdateState)
+ // we're not unsubbing
+ // this causes errors and potentially breaks shit
+ // we should emit on change instead
+ // and background should handle unsubbing
function sendUpdateState(){
if (!isUnlocked()) return
- updateIdentities(function(){
- var state = _getState()
- cb(state)
- })
+ var state = _getState()
+ cb(state)
}
}
@@ -152,7 +173,11 @@ function updateIdentity(address, cb){
function getTxCount(address, cb){
provider.sendAsync(createPayload({
method: 'eth_getTransactionCount',
- params: [address],
+ // we actually want the pending txCount
+ // but pending is broken in provider-engine
+ // https://github.com/MetaMask/provider-engine/issues/11
+ // params: [address, 'pending'],
+ params: [address, 'latest'],
}), function(err, res){
if (err) return cb(err)
if (res.error) return cb(res.error)
@@ -163,7 +188,7 @@ function getTxCount(address, cb){
function getAccountBalance(address, cb){
provider.sendAsync(createPayload({
method: 'eth_getBalance',
- params: [address],
+ params: [address, 'latest'],
}), function(err, res){
if (err) return cb(err)
if (res.error) return cb(res.error)
diff --git a/app/scripts/lib/stream-provider.js b/app/scripts/lib/stream-provider.js
index b0a922397..5a77979ee 100644
--- a/app/scripts/lib/stream-provider.js
+++ b/app/scripts/lib/stream-provider.js
@@ -17,7 +17,7 @@ function StreamProvider(){
// public
StreamProvider.prototype.send = function(payload){
- throw new Error('StreamProvider - does not support synchronous RPC calls')
+ throw new Error('StreamProvider - does not support synchronous RPC calls. called: "'+payload.method+'"')
}
StreamProvider.prototype.sendAsync = function(payload, callback){