[#5623] Bancor: "Oh, no..." error if try to buy token for ETH (or SNT)
Signed-off-by: Igor Mandrigin <i@mandrigin.ru>
This commit is contained in:
parent
172d63af4c
commit
11199c13ee
|
@ -2,6 +2,10 @@ if(typeof StatusHttpProvider === "undefined"){
|
|||
var callbackId = 0;
|
||||
var callbacks = {};
|
||||
|
||||
function bridgeSend(data){
|
||||
WebViewBridge.send(JSON.stringify(data));
|
||||
}
|
||||
|
||||
WebViewBridge.onMessage = function (message) {
|
||||
data = JSON.parse(message);
|
||||
|
||||
|
@ -24,8 +28,18 @@ WebViewBridge.onMessage = function (message) {
|
|||
else if (data.type === "web3-send-async-callback")
|
||||
{
|
||||
var id = data.messageId;
|
||||
if (callbacks[id]) {
|
||||
callbacks[id](data.error, data.result);
|
||||
var callback = callbacks[id];
|
||||
if (callback) {
|
||||
if (callback.results)
|
||||
{
|
||||
callback.results.push(data.error || data.result);
|
||||
if (callback.results.length == callback.num)
|
||||
callback.callback(undefined, callback.results);
|
||||
}
|
||||
else
|
||||
{
|
||||
callback.callback(data.error, data.result);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -76,10 +90,26 @@ StatusHttpProvider.prototype.sendAsync = function (payload, callback) {
|
|||
}
|
||||
else {
|
||||
var messageId = callbackId++;
|
||||
callbacks[messageId] = callback;
|
||||
WebViewBridge.send(JSON.stringify({type: 'web3-send-async',
|
||||
messageId: messageId,
|
||||
payload: payload}));
|
||||
|
||||
if (Array.isArray(payload))
|
||||
{
|
||||
callbacks[messageId] = {num: payload.length,
|
||||
results: [],
|
||||
callback: callback};
|
||||
for (var i in payload) {
|
||||
bridgeSend({type: 'web3-send-async',
|
||||
messageId: messageId,
|
||||
payload: payload[i]});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
callbacks[messageId] = {callback: callback};
|
||||
bridgeSend({type: 'web3-send-async',
|
||||
messageId: messageId,
|
||||
payload: payload});
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -128,7 +128,10 @@
|
|||
(defn discard-transaction
|
||||
[{:keys [db]}]
|
||||
(let [{:keys [dapp-transaction]} (get-in db [:wallet :send-transaction])]
|
||||
(cond-> {:db (assoc-in db [:wallet :send-transaction] {})}
|
||||
(cond-> {:db (update db :wallet
|
||||
assoc
|
||||
:send-transaction {}
|
||||
:transactions-queue nil)}
|
||||
dapp-transaction
|
||||
(web3-error-callback db dapp-transaction "discarded"))))
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
(spec/def ::gas-price (spec/nilable money/valid?))
|
||||
; dapp transaction
|
||||
(spec/def ::data (spec/nilable string?))
|
||||
(spec/def ::nonce (spec/nilable money/valid?))
|
||||
(spec/def ::nonce (spec/nilable string?))
|
||||
|
||||
(spec/def ::to-name (spec/nilable string?))
|
||||
(spec/def ::amount-error (spec/nilable string?))
|
||||
|
@ -36,7 +36,7 @@
|
|||
|
||||
(spec/def :wallet/send-transaction (allowed-keys
|
||||
:opt-un [::amount ::to ::to-name ::amount-error ::asset-error ::amount-text
|
||||
::password ::show-password-input? ::id ::from ::data
|
||||
::password ::show-password-input? ::id ::from ::data ::nonce
|
||||
::camera-flashlight ::in-progress? ::dapp-transaction
|
||||
::wrong-password? ::from-chat? ::symbol ::advanced?
|
||||
::gas ::gas-price ::whisper-identity ::method ::tx-hash]))
|
||||
|
|
|
@ -125,14 +125,14 @@
|
|||
|
||||
;;SEND TRANSACTION
|
||||
(= method constants/web3-send-transaction)
|
||||
(let [{:keys [gas gasPrice] :as transaction} (models.wallet/prepare-dapp-transaction
|
||||
queued-transaction (:contacts/contacts db))
|
||||
(let [{:keys [gas gas-price] :as transaction} (models.wallet/prepare-dapp-transaction
|
||||
queued-transaction (:contacts/contacts db))
|
||||
{:keys [wallet-set-up-passed?]} (:account/account db)]
|
||||
{:db (assoc-in db' [:wallet :send-transaction] transaction)
|
||||
:dispatch-n [[:update-wallet]
|
||||
(when-not gas
|
||||
[:wallet/update-estimated-gas (first params)])
|
||||
(when-not gasPrice
|
||||
(when-not gas-price
|
||||
[:wallet/update-gas-price])
|
||||
[:navigate-to-modal (if wallet-set-up-passed?
|
||||
:wallet-send-transaction-modal
|
||||
|
|
Loading…
Reference in New Issue