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)
(gateway/handle-acquisition {:message payload
:method "PATCH"
:url (gateway/get-url :clicks referral)
:url [:clicks referral]
:on-success [::claim/success-starter-pack-claim]})
{::persistence/set-referrer-state :declined})
(popover/hide-popover))))
+1 -1
View File
@@ -32,5 +32,5 @@
{:db (update db :acquisition dissoc :chat-referrer)}
(gateway/handle-acquisition {:message payload
:method "PATCH"
:url (gateway/get-url :clicks referral)
:url [:clicks referral]
:on-success [::claim/success-starter-pack-claim]}))))
+8 -8
View File
@@ -15,19 +15,19 @@
(fx/defn add-tx-watcher
{:events [::add-tx-watcher]}
[cofx tx]
(transaction/watch-transaction cofx
tx
{:trigger-fn (constantly true)
:on-trigger
(fn []
{:dispatch [::success-tx-received]})}))
(fx/merge cofx
{::persistence/set-watch-tx tx}
(transaction/watch-transaction tx
{:trigger-fn (constantly true)
:on-trigger
(fn []
{:dispatch [::success-tx-received]})})))
(fx/defn success-starter-pack-claim
{:events [::success-starter-pack-claim]}
[cofx {:keys [tx]}]
(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
(add-tx-watcher tx))
(notifications/request-permission)))
+1 -1
View File
@@ -24,7 +24,7 @@
{:message message
:on-success on-success
:method "POST"
:url (gateway/get-url :registrations nil)}))
:url [:registrations nil]}))
(re-frame/reg-fx
::get-referrer
+1 -1
View File
@@ -34,7 +34,7 @@
(if (= decision :accept)
(gateway/handle-acquisition {:message payload
:method "PATCH"
:url (gateway/get-url :clicks referral)
:url [:clicks referral]
:on-success [::success-claim]})
{::persistence/set-referrer-state :declined})
(popover/hide-popover))))
+23 -17
View File
@@ -1,25 +1,29 @@
(ns status-im.acquisition.gateway
(:require [re-frame.core :as re-frame]
[status-im.utils.fx :as fx]
[status-im.ethereum.core :as ethereum]
[status-im.i18n :as i18n]
[status-im.ethereum.json-rpc :as json-rpc]
[status-im.waku.core :as waku]
[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")
:registrations (str acquisition-gateway "/registrations")})
(defn acquisition-routes [network type]
(get {:clicks (str (get acquisition-gateway network) "/clicks")
:registrations (str (get acquisition-gateway network) "/registrations")}
type))
(def network-statuses {:initiated 1
:in-flight 2
:error 3
:success 4})
(defn get-url [type referral]
(defn get-url [network [type referral]]
(if (= type :clicks)
(str (get acquisition-routes :clicks) "/" referral)
(get acquisition-routes :registrations)))
(str (acquisition-routes network :clicks) "/" referral)
(acquisition-routes network :registrations)))
(fx/defn handle-error
{:events [::on-error]}
@@ -32,7 +36,8 @@
(fx/defn handle-acquisition
{:events [::handle-acquisition]}
[{: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]
(get network-statuses :initiated))
::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])
:message msg
:method method
:url url
:url (get-url network url)
:on-success on-success} %])}]}))
(fx/defn call-acquisition-gateway
{:events [::call-acquisition-gateway]}
@@ -67,15 +72,16 @@
(re-frame/dispatch [::on-error (:error (types/json->clj (get error :response-body)))]))}}))
(fx/defn get-referrer
[cofx referrer on-success handled-error handle-error]
{:http-get {:url (get-url :clicks referrer)
:on-success (fn [response]
(re-frame/dispatch (on-success (types/json->clj response))))
:on-error (fn [response]
(let [error (types/json->clj response)]
(if (handled-error error)
(handle-error error)
(re-frame/dispatch [::on-error (:error error)]))))}})
[{:keys [db]} referrer on-success handled-error handle-error]
(let [network (ethereum/chain-keyword db)]
{:http-get {:url (get-url network [:clicks referrer])
:on-success (fn [response]
(re-frame/dispatch (on-success (types/json->clj response))))
:on-error (fn [response]
(let [error (types/json->clj response)]
(if (handled-error error)
(handle-error error)
(re-frame/dispatch [::on-error (:error error)]))))}}))
(re-frame/reg-sub
::network-status
(fn [db]
+5 -4
View File
@@ -44,10 +44,11 @@
(re-frame/reg-fx
::set-watch-tx
(fn [tx]
(-> ^js async-storage
(.setItem tx-store-key tx)
(.catch (fn [error]
(log/error "[async-storage]" error))))))
(when tx
(-> ^js async-storage
(.setItem tx-store-key tx)
(.catch (fn [error]
(log/error "[async-storage]" error)))))))
(re-frame/reg-fx
::chat-initalized!
+2
View File
@@ -12,3 +12,5 @@
{1 2000
2 5000
3 10000})
(def max-text-size 4096)
@@ -6,6 +6,7 @@
[quo.design-system.colors :as colors]
[status-im.ui.screens.chat.components.style :as styles]
[status-im.ui.screens.chat.components.reply :as reply]
[status-im.chat.constants :as chat.constants]
[status-im.utils.utils :as utils.utils]
[quo.components.animated.pressable :as pressable]
[quo.animated :as animated]
@@ -86,6 +87,7 @@
:auto-focus false
:on-focus #(set-active-panel nil)
:on-change #(on-text-change (.-text ^js (.-nativeEvent ^js %)))
:max-length chat.constants/max-text-size
:placeholder-text-color (:text-02 @colors/theme)
:placeholder (if cooldown-enabled?
(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",
"owner": "status-im",
"repo": "status-go",
"version": "v0.56.9",
"commit-sha1": "435eacecb587571887ef547d78f82d67f026db28",
"src-sha256": "0nk4fn7avj5yqsbvc3yjb2hdfhswxsvyvmxcgf0g3rr9rdhm7m19"
"version": "v0.56.10",
"commit-sha1": "b7a7f2187fbcccd00a278b9bb0b5e639db1bd645",
"src-sha256": "0cclwk2x1x1v241gmdgrvrg19xmsbibislkjmax3m51j9grn43bz"
}