diff options
author | obscuren <geffobscura@gmail.com> | 2014-09-25 16:32:54 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-09-25 16:32:54 +0800 |
commit | d5d1e503652cc6c53a265404d8fdda53fad58fa8 (patch) | |
tree | 5e8441fc976e287440c9d6199ebf13ae76e75a4e /mist | |
parent | 29f5dd38e34b394d947e91597b322d50852effa4 (diff) | |
download | dexon-d5d1e503652cc6c53a265404d8fdda53fad58fa8.tar dexon-d5d1e503652cc6c53a265404d8fdda53fad58fa8.tar.gz dexon-d5d1e503652cc6c53a265404d8fdda53fad58fa8.tar.bz2 dexon-d5d1e503652cc6c53a265404d8fdda53fad58fa8.tar.lz dexon-d5d1e503652cc6c53a265404d8fdda53fad58fa8.tar.xz dexon-d5d1e503652cc6c53a265404d8fdda53fad58fa8.tar.zst dexon-d5d1e503652cc6c53a265404d8fdda53fad58fa8.zip |
Support multiple promises as data or mixed with non promises
Diffstat (limited to 'mist')
-rw-r--r-- | mist/assets/ext/html_messaging.js | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/mist/assets/ext/html_messaging.js b/mist/assets/ext/html_messaging.js index efb950b4b..0bedba997 100644 --- a/mist/assets/ext/html_messaging.js +++ b/mist/assets/ext/html_messaging.js @@ -92,19 +92,19 @@ promises.push(params.from.then(function(_from) { params.from = _from; })); } - if(isPromise(params.data)) { - promises.push(params.data.then(function(_code) { params.data = _code; })); - } else { - if(typeof params.data === "object") { - data = ""; - for(var i = 0; i < params.data.length; i++) { - data += params.data[i] - } - } else { - data = params.data; - } - } - + if(typeof params.data !== "object" || isPromise(params.data)) { + params.data = [params.data] + } + + var data = params.data; + for(var i = 0; i < params.data.length; i++) { + if(isPromise(params.data[i])) { + var promise = params.data[i]; + var _i = i; + promises.push(promise.then(function(_arg) { params.data[_i] = _arg; })); + } + } + // Make sure everything is string var fields = ["value", "gas", "gasPrice"]; for(var i = 0; i < fields.length; i++) { @@ -117,6 +117,7 @@ // Load promises then call the last "transact". return Q.all(promises).then(function() { return new Promise(function(resolve, reject) { + params.data = params.data.join(""); postData({call: "transact", args: params}, function(data) { if(data[1]) reject(data[0]); @@ -458,6 +459,7 @@ g_seed++; + console.log(data) navigator.qt.postMessage(JSON.stringify(data)); } |