Compare commits

...
Author SHA1 Message Date
andrey 877acff46c 1.6.1 2020-09-08 11:35:16 +02:00
Volodymyr Kozieiev a7aac8f488 Restrict message size on input
Signed-off-by: Volodymyr Kozieiev <vkjr.sp@gmail.com>
2020-09-08 11:33:39 +02:00
Gheorghe Pinzaru 21cac9084d Use different acquisition gateway based on chain
Do not persist empty tx

Signed-off-by: Gheorghe Pinzaru <feross95@gmail.com>
2020-08-26 13:27:04 +02:00
11 changed files with 48 additions and 37 deletions
+1 -1
View File
@@ -1 +1 @@
1.6.0 1.6.1
+1 -1
View File
@@ -23,7 +23,7 @@
(if (= decision :accept) (if (= decision :accept)
(gateway/handle-acquisition {:message payload (gateway/handle-acquisition {:message payload
:method "PATCH" :method "PATCH"
:url (gateway/get-url :clicks referral) :url [:clicks referral]
:on-success [::claim/success-starter-pack-claim]}) :on-success [::claim/success-starter-pack-claim]})
{::persistence/set-referrer-state :declined}) {::persistence/set-referrer-state :declined})
(popover/hide-popover)))) (popover/hide-popover))))
+1 -1
View File
@@ -32,5 +32,5 @@
{:db (update db :acquisition dissoc :chat-referrer)} {:db (update db :acquisition dissoc :chat-referrer)}
(gateway/handle-acquisition {:message payload (gateway/handle-acquisition {:message payload
:method "PATCH" :method "PATCH"
:url (gateway/get-url :clicks referral) :url [:clicks referral]
:on-success [::claim/success-starter-pack-claim]})))) :on-success [::claim/success-starter-pack-claim]}))))
+8 -8
View File
@@ -15,19 +15,19 @@
(fx/defn add-tx-watcher (fx/defn add-tx-watcher
{:events [::add-tx-watcher]} {:events [::add-tx-watcher]}
[cofx tx] [cofx tx]
(transaction/watch-transaction cofx (fx/merge cofx
tx {::persistence/set-watch-tx tx}
{:trigger-fn (constantly true) (transaction/watch-transaction tx
:on-trigger {:trigger-fn (constantly true)
(fn [] :on-trigger
{:dispatch [::success-tx-received]})})) (fn []
{:dispatch [::success-tx-received]})})))
(fx/defn success-starter-pack-claim (fx/defn success-starter-pack-claim
{:events [::success-starter-pack-claim]} {:events [::success-starter-pack-claim]}
[cofx {:keys [tx]}] [cofx {:keys [tx]}]
(fx/merge cofx (fx/merge cofx
{::persistence/set-watch-tx tx {::persistence/set-referrer-state (if tx :accepted :claimed)}
::persistence/set-referrer-state (if tx :accepted :claimed)}
(when tx (when tx
(add-tx-watcher tx)) (add-tx-watcher tx))
(notifications/request-permission))) (notifications/request-permission)))
+1 -1
View File
@@ -24,7 +24,7 @@
{:message message {:message message
:on-success on-success :on-success on-success
:method "POST" :method "POST"
:url (gateway/get-url :registrations nil)})) :url [:registrations nil]}))
(re-frame/reg-fx (re-frame/reg-fx
::get-referrer ::get-referrer
+1 -1
View File
@@ -34,7 +34,7 @@
(if (= decision :accept) (if (= decision :accept)
(gateway/handle-acquisition {:message payload (gateway/handle-acquisition {:message payload
:method "PATCH" :method "PATCH"
:url (gateway/get-url :clicks referral) :url [:clicks referral]
:on-success [::success-claim]}) :on-success [::success-claim]})
{::persistence/set-referrer-state :declined}) {::persistence/set-referrer-state :declined})
(popover/hide-popover)))) (popover/hide-popover))))
+23 -17
View File
@@ -1,25 +1,29 @@
(ns status-im.acquisition.gateway (ns status-im.acquisition.gateway
(:require [re-frame.core :as re-frame] (:require [re-frame.core :as re-frame]
[status-im.utils.fx :as fx] [status-im.utils.fx :as fx]
[status-im.ethereum.core :as ethereum]
[status-im.i18n :as i18n] [status-im.i18n :as i18n]
[status-im.ethereum.json-rpc :as json-rpc] [status-im.ethereum.json-rpc :as json-rpc]
[status-im.waku.core :as waku] [status-im.waku.core :as waku]
[status-im.utils.types :as types])) [status-im.utils.types :as types]))
(def acquisition-gateway "https://test-referral.status.im") (def acquisition-gateway {:mainnet "https://get.status.im"
:rinkeby "https://test-referral.status.im"})
(def acquisition-routes {:clicks (str acquisition-gateway "/clicks") (defn acquisition-routes [network type]
:registrations (str acquisition-gateway "/registrations")}) (get {:clicks (str (get acquisition-gateway network) "/clicks")
:registrations (str (get acquisition-gateway network) "/registrations")}
type))
(def network-statuses {:initiated 1 (def network-statuses {:initiated 1
:in-flight 2 :in-flight 2
:error 3 :error 3
:success 4}) :success 4})
(defn get-url [type referral] (defn get-url [network [type referral]]
(if (= type :clicks) (if (= type :clicks)
(str (get acquisition-routes :clicks) "/" referral) (str (acquisition-routes network :clicks) "/" referral)
(get acquisition-routes :registrations))) (acquisition-routes network :registrations)))
(fx/defn handle-error (fx/defn handle-error
{:events [::on-error]} {:events [::on-error]}
@@ -32,7 +36,8 @@
(fx/defn handle-acquisition (fx/defn handle-acquisition
{:events [::handle-acquisition]} {:events [::handle-acquisition]}
[{:keys [db] :as cofx} {:keys [message on-success method url]}] [{:keys [db] :as cofx} {:keys [message on-success method url]}]
(let [msg (types/clj->json message)] (let [msg (types/clj->json message)
network (ethereum/chain-keyword db)]
{:db (assoc-in db [:acquisition :network-status] {:db (assoc-in db [:acquisition :network-status]
(get network-statuses :initiated)) (get network-statuses :initiated))
::json-rpc/call [{:method (json-rpc/call-ext-method (waku/enabled? cofx) "signMessageWithChatKey") ::json-rpc/call [{:method (json-rpc/call-ext-method (waku/enabled? cofx) "signMessageWithChatKey")
@@ -42,7 +47,7 @@
{:chat-key (get-in db [:multiaccount :public-key]) {:chat-key (get-in db [:multiaccount :public-key])
:message msg :message msg
:method method :method method
:url url :url (get-url network url)
:on-success on-success} %])}]})) :on-success on-success} %])}]}))
(fx/defn call-acquisition-gateway (fx/defn call-acquisition-gateway
{:events [::call-acquisition-gateway]} {:events [::call-acquisition-gateway]}
@@ -67,15 +72,16 @@
(re-frame/dispatch [::on-error (:error (types/json->clj (get error :response-body)))]))}})) (re-frame/dispatch [::on-error (:error (types/json->clj (get error :response-body)))]))}}))
(fx/defn get-referrer (fx/defn get-referrer
[cofx referrer on-success handled-error handle-error] [{:keys [db]} referrer on-success handled-error handle-error]
{:http-get {:url (get-url :clicks referrer) (let [network (ethereum/chain-keyword db)]
:on-success (fn [response] {:http-get {:url (get-url network [:clicks referrer])
(re-frame/dispatch (on-success (types/json->clj response)))) :on-success (fn [response]
:on-error (fn [response] (re-frame/dispatch (on-success (types/json->clj response))))
(let [error (types/json->clj response)] :on-error (fn [response]
(if (handled-error error) (let [error (types/json->clj response)]
(handle-error error) (if (handled-error error)
(re-frame/dispatch [::on-error (:error error)]))))}}) (handle-error error)
(re-frame/dispatch [::on-error (:error error)]))))}}))
(re-frame/reg-sub (re-frame/reg-sub
::network-status ::network-status
(fn [db] (fn [db]
+5 -4
View File
@@ -44,10 +44,11 @@
(re-frame/reg-fx (re-frame/reg-fx
::set-watch-tx ::set-watch-tx
(fn [tx] (fn [tx]
(-> ^js async-storage (when tx
(.setItem tx-store-key tx) (-> ^js async-storage
(.catch (fn [error] (.setItem tx-store-key tx)
(log/error "[async-storage]" error)))))) (.catch (fn [error]
(log/error "[async-storage]" error)))))))
(re-frame/reg-fx (re-frame/reg-fx
::chat-initalized! ::chat-initalized!
+2
View File
@@ -12,3 +12,5 @@
{1 2000 {1 2000
2 5000 2 5000
3 10000}) 3 10000})
(def max-text-size 4096)
@@ -6,6 +6,7 @@
[quo.design-system.colors :as colors] [quo.design-system.colors :as colors]
[status-im.ui.screens.chat.components.style :as styles] [status-im.ui.screens.chat.components.style :as styles]
[status-im.ui.screens.chat.components.reply :as reply] [status-im.ui.screens.chat.components.reply :as reply]
[status-im.chat.constants :as chat.constants]
[status-im.utils.utils :as utils.utils] [status-im.utils.utils :as utils.utils]
[quo.components.animated.pressable :as pressable] [quo.components.animated.pressable :as pressable]
[quo.animated :as animated] [quo.animated :as animated]
@@ -86,6 +87,7 @@
:auto-focus false :auto-focus false
:on-focus #(set-active-panel nil) :on-focus #(set-active-panel nil)
:on-change #(on-text-change (.-text ^js (.-nativeEvent ^js %))) :on-change #(on-text-change (.-text ^js (.-nativeEvent ^js %)))
:max-length chat.constants/max-text-size
:placeholder-text-color (:text-02 @colors/theme) :placeholder-text-color (:text-02 @colors/theme)
:placeholder (if cooldown-enabled? :placeholder (if cooldown-enabled?
(i18n/label :cooldown/text-input-disabled) (i18n/label :cooldown/text-input-disabled)
+3 -3
View File
@@ -2,7 +2,7 @@
"_comment": "DO NOT EDIT THIS FILE BY HAND. USE 'scripts/update-status-go.sh <tag>' instead", "_comment": "DO NOT EDIT THIS FILE BY HAND. USE 'scripts/update-status-go.sh <tag>' instead",
"owner": "status-im", "owner": "status-im",
"repo": "status-go", "repo": "status-go",
"version": "v0.56.9", "version": "v0.56.10",
"commit-sha1": "435eacecb587571887ef547d78f82d67f026db28", "commit-sha1": "b7a7f2187fbcccd00a278b9bb0b5e639db1bd645",
"src-sha256": "0nk4fn7avj5yqsbvc3yjb2hdfhswxsvyvmxcgf0g3rr9rdhm7m19" "src-sha256": "0cclwk2x1x1v241gmdgrvrg19xmsbibislkjmax3m51j9grn43bz"
} }