Merge pull request #447 from status-im/bug/#430
Prevent !send with null "to" address
This commit is contained in:
commit
acfedd19f6
|
@ -65,7 +65,17 @@ status.command({
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
|
|
||||||
function validateBalance(params, context) {
|
function validateSend(params, context) {
|
||||||
|
if (!context.to) {
|
||||||
|
return {
|
||||||
|
errors: [
|
||||||
|
status.components.validationMessage(
|
||||||
|
"Wrong address",
|
||||||
|
"Recipient address must be specified"
|
||||||
|
)
|
||||||
|
]
|
||||||
|
};
|
||||||
|
}
|
||||||
if (!params.amount) {
|
if (!params.amount) {
|
||||||
return {
|
return {
|
||||||
errors: [
|
errors: [
|
||||||
|
@ -136,7 +146,7 @@ var send = {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
handler: sendTransaction,
|
handler: sendTransaction,
|
||||||
validator: validateBalance
|
validator: validateSend
|
||||||
};
|
};
|
||||||
|
|
||||||
status.command(send);
|
status.command(send);
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
(dispatch [:navigate-to-clean :chat-list])
|
(dispatch [:navigate-to-clean :chat-list])
|
||||||
(dispatch [:navigate-to :chat console-chat-id]))
|
(dispatch [:navigate-to :chat console-chat-id]))
|
||||||
(do
|
(do
|
||||||
(dispatch [:navigate-to-clean :accounts])
|
(dispatch [:navigate-to-clean :chat-list])
|
||||||
(dispatch [:navigate-to :chat-list]))))
|
(dispatch [:navigate-to :chat-list]))))
|
||||||
|
|
||||||
(register-handler
|
(register-handler
|
||||||
|
|
|
@ -243,8 +243,10 @@
|
||||||
:params
|
:params
|
||||||
(get parameter-idx)
|
(get parameter-idx)
|
||||||
:name)
|
:name)
|
||||||
|
to (get-in db [:contacts chat-id :address])
|
||||||
context {:current-parameter current-parameter
|
context {:current-parameter current-parameter
|
||||||
:from address}
|
:from address
|
||||||
|
:to to}
|
||||||
path [(if (= :command type) :commands :responses)
|
path [(if (= :command type) :commands :responses)
|
||||||
name
|
name
|
||||||
:validator]
|
:validator]
|
||||||
|
|
|
@ -9,7 +9,8 @@
|
||||||
[status-im.commands.utils :as cu]
|
[status-im.commands.utils :as cu]
|
||||||
[status-im.components.status :as s]
|
[status-im.components.status :as s]
|
||||||
[status-im.constants :as c]
|
[status-im.constants :as c]
|
||||||
[cljs.reader :refer [read-string]]))
|
[cljs.reader :refer [read-string]]
|
||||||
|
[status-im.navigation.handlers :as nav]))
|
||||||
|
|
||||||
(def web3 (js/require "web3"))
|
(def web3 (js/require "web3"))
|
||||||
|
|
||||||
|
@ -79,18 +80,28 @@
|
||||||
params (:data options)]
|
params (:data options)]
|
||||||
(log/debug (str "message from webview: " message))
|
(log/debug (str "message from webview: " message))
|
||||||
(case event'
|
(case event'
|
||||||
:webview-send-transaction (dispatch [:show-contacts-menu contacts-click-handler :send params])
|
:webview-send-transaction
|
||||||
:webview-receive-transaction (dispatch [:show-contacts-menu contacts-click-handler :request params])
|
(dispatch [:navigate-to-modal
|
||||||
|
:contact-list-modal
|
||||||
|
{:handler contacts-click-handler
|
||||||
|
:action :send
|
||||||
|
:params params}])
|
||||||
|
:webview-receive-transaction
|
||||||
|
(dispatch [:navigate-to-modal
|
||||||
|
:contact-list-modal
|
||||||
|
{:handler contacts-click-handler
|
||||||
|
:action :request
|
||||||
|
:params params}])
|
||||||
:webview-scan-qr (dispatch [:show-scan-qr :webview-address-from-qr])
|
:webview-scan-qr (dispatch [:show-scan-qr :webview-address-from-qr])
|
||||||
:webview-send-eth (dispatch [:webview-send-eth! params])
|
:webview-send-eth (dispatch [:webview-send-eth! params])
|
||||||
(log/error (str "Unknown event: " event')))))))
|
(log/error (str "Unknown event: " event')))))))
|
||||||
|
|
||||||
(register-handler :show-contacts-menu
|
(defmethod nav/preload-data! :contact-list-modal
|
||||||
(after #(dispatch [:navigate-to-modal :contact-list-modal]))
|
[db [_ _ {:keys [handler action params]}]]
|
||||||
(fn [db [_ click-handler action params]]
|
(assoc db :contacts-click-handler handler
|
||||||
(assoc db :contacts-click-handler click-handler
|
:contacts-click-action action
|
||||||
:contacts-click-action action
|
:contacts-click-params params
|
||||||
:contacts-click-params params)))
|
:contacts-filter #(not (nil? (:address %)))))
|
||||||
|
|
||||||
(def qr-context {:toolbar-title (label :t/address)})
|
(def qr-context {:toolbar-title (label :t/address)})
|
||||||
|
|
||||||
|
|
|
@ -16,9 +16,11 @@
|
||||||
|
|
||||||
(defmethod nav/preload-data! :group-contacts
|
(defmethod nav/preload-data! :group-contacts
|
||||||
[db [_ _ group]]
|
[db [_ _ group]]
|
||||||
(if group
|
(dissoc
|
||||||
(assoc db :contacts-group group)
|
(if group
|
||||||
db))
|
(assoc db :contacts-group group)
|
||||||
|
db)
|
||||||
|
:contacts-filter))
|
||||||
|
|
||||||
(defmethod nav/preload-data! :new-group
|
(defmethod nav/preload-data! :new-group
|
||||||
[db _]
|
[db _]
|
||||||
|
@ -28,7 +30,8 @@
|
||||||
|
|
||||||
(defmethod nav/preload-data! :contact-list
|
(defmethod nav/preload-data! :contact-list
|
||||||
[db [_ _ click-handler]]
|
[db [_ _ click-handler]]
|
||||||
(assoc db :contacts-click-handler click-handler))
|
(assoc db :contacts-click-handler click-handler
|
||||||
|
:contacts-filter nil))
|
||||||
|
|
||||||
|
|
||||||
(register-handler :remove-contacts-click-handler
|
(register-handler :remove-contacts-click-handler
|
||||||
|
@ -132,7 +135,7 @@
|
||||||
|
|
||||||
(defn request-stored-contacts [contacts]
|
(defn request-stored-contacts [contacts]
|
||||||
(let [contacts-by-hash (get-contacts-by-hash contacts)
|
(let [contacts-by-hash (get-contacts-by-hash contacts)
|
||||||
data (or (keys contacts-by-hash) ())]
|
data (or (keys contacts-by-hash) ())]
|
||||||
(http-post "get-contacts" {:phone-number-hashes data}
|
(http-post "get-contacts" {:phone-number-hashes data}
|
||||||
(fn [{:keys [contacts]}]
|
(fn [{:keys [contacts]}]
|
||||||
(let [contacts' (add-identity contacts-by-hash contacts)]
|
(let [contacts' (add-identity contacts-by-hash contacts)]
|
||||||
|
@ -156,7 +159,7 @@
|
||||||
|
|
||||||
(defn add-new-contacts
|
(defn add-new-contacts
|
||||||
[{:keys [contacts] :as db} [_ new-contacts]]
|
[{:keys [contacts] :as db} [_ new-contacts]]
|
||||||
(let [identities (set (map :whisper-identity contacts))
|
(let [identities (set (map :whisper-identity contacts))
|
||||||
new-contacts' (->> new-contacts
|
new-contacts' (->> new-contacts
|
||||||
(map #(update-pending-status contacts %))
|
(map #(update-pending-status contacts %))
|
||||||
(remove #(identities (:whisper-identity %)))
|
(remove #(identities (:whisper-identity %)))
|
||||||
|
|
|
@ -60,9 +60,11 @@
|
||||||
|
|
||||||
(register-sub :contacts-with-letters
|
(register-sub :contacts-with-letters
|
||||||
(fn [db _]
|
(fn [db _]
|
||||||
(let [contacts (reaction (:contacts @db))]
|
(let [contacts (reaction (:contacts @db))
|
||||||
|
pred (subscribe [:get :contacts-filter])]
|
||||||
(reaction
|
(reaction
|
||||||
(let [ordered (sort-contacts @contacts)]
|
(let [ordered (sort-contacts @contacts)
|
||||||
|
ordered (if pred (filter @pred ordered) ordered)]
|
||||||
(reduce (fn [prev cur]
|
(reduce (fn [prev cur]
|
||||||
(let [prev-letter (get-contact-letter (last prev))
|
(let [prev-letter (get-contact-letter (last prev))
|
||||||
cur-letter (get-contact-letter cur)]
|
cur-letter (get-contact-letter cur)]
|
||||||
|
|
|
@ -123,6 +123,13 @@
|
||||||
(remove-pending-message db message-id)))
|
(remove-pending-message db message-id)))
|
||||||
|
|
||||||
(register-handler :transaction-queued
|
(register-handler :transaction-queued
|
||||||
|
(u/side-effect!
|
||||||
|
(fn [_ [_ {:keys [id args] :as transaction}]]
|
||||||
|
(if (:to args)
|
||||||
|
(dispatch [::transaction-queued transaction])
|
||||||
|
(status/discard-transaction id)))))
|
||||||
|
|
||||||
|
(register-handler ::transaction-queued
|
||||||
(after #(dispatch [:navigate-to-modal :confirm]))
|
(after #(dispatch [:navigate-to-modal :confirm]))
|
||||||
(fn [db [_ {:keys [id message_id args]}]]
|
(fn [db [_ {:keys [id message_id args]}]]
|
||||||
(let [{:keys [from to value]} args
|
(let [{:keys [from to value]} args
|
||||||
|
|
Loading…
Reference in New Issue