Skip to content

Commit 1ff6a61

Browse files
flexsurferibrkhalil
authored andcommitted
[#17347] move [status-im.utils.http :as http] to status-im2 (#17350)
1 parent 3c6f279 commit 1ff6a61

File tree

23 files changed

+123
-305
lines changed

23 files changed

+123
-305
lines changed

ios/Podfile.lock

+3-3
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ SPEC CHECKSUMS:
707707
FBLazyVector: a8af91c2b5a0029d12ff6b32e428863d63c48991
708708
FBReactNativeSpec: 1b2309b096448a1dc9d0c43999216f8fda809ae8
709709
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
710-
glog: 166d178815c300e8126de9a7900101814eb16253
710+
glog: d93527a855523adb8c113837db4be68fb00e230d
711711
HMSegmentedControl: 34c1f54d822d8308e7b24f5d901ec674dfa31352
712712
Keycard: ac6df4d91525c3c82635ac24d4ddd9a80aca5fc8
713713
libwebp: f62cb61d0a484ba548448a4bd52aabf150ff6eef
@@ -772,7 +772,7 @@ SPEC CHECKSUMS:
772772
RNLanguages: 962e562af0d34ab1958d89bcfdb64fafc37c513e
773773
RNPermissions: ad71dd4f767ec254f2cd57592fbee02afee75467
774774
RNReactNativeHapticFeedback: 2566b468cc8d0e7bb2f84b23adc0f4614594d071
775-
RNReanimated: b3b67ebe099c0b0e7b5c7386b18d2468e29c9d41
775+
RNReanimated: 43adb0307a62c1ce9694f36f124ca3b51a15272a
776776
RNShare: d82e10f6b7677f4b0048c23709bd04098d5aee6c
777777
RNStaticSafeAreaInsets: 055ddbf5e476321720457cdaeec0ff2ba40ec1b8
778778
RNSVG: 80584470ff1ffc7994923ea135a3e5ad825546b9
@@ -785,6 +785,6 @@ SPEC CHECKSUMS:
785785
TouchID: ba4c656d849cceabc2e4eef722dea5e55959ecf4
786786
Yoga: d24d6184b6b85f742536bd93bd07d69d7b9bb4c1
787787

788-
PODFILE CHECKSUM: 8df67467da1e4e60ec164479744536c6f8fc98ed
788+
PODFILE CHECKSUM: ac30a0172ff0126b6f307c20f34c47ce0ebf278f
789789

790790
COCOAPODS: 1.12.0

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
"react-native-dialogs": "^1.0.4",
4646
"react-native-draggable-flatlist": "^4.0.1",
4747
"react-native-fast-image": "^8.5.11",
48-
"react-native-fetch-polyfill": "^1.1.2",
4948
"react-native-fs": "^2.14.1",
5049
"react-native-gesture-handler": "2.6.1",
5150
"react-native-gifted-charts": "git+https://github.com/status-im/react-native-gifted-charts.git#refs/tags/1.3.2-status.1",

src/status_im/browser/core.cljs

+11-11
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
[status-im.signing.core :as signing]
1818
[status-im.ui.components.list-selection :as list-selection]
1919
[utils.re-frame :as rf]
20-
[status-im.utils.http :as http]
20+
[utils.url :as url]
2121
[status-im.utils.platform :as platform]
2222
[status-im.utils.random :as random]
2323
[status-im.utils.types :as types]
@@ -75,7 +75,7 @@
7575

7676
(defn check-if-phishing-url
7777
[{:keys [history history-index] :as browser}]
78-
(let [history-host (http/url-host (try (nth history history-index) (catch js/Error _)))]
78+
(let [history-host (url/url-host (try (nth history history-index) (catch js/Error _)))]
7979
(cond-> browser history-host (assoc :unsafe? (eth-phishing-detect history-host)))))
8080

8181
(defn resolve-ens-contenthash-callback
@@ -88,7 +88,7 @@
8888
[{:keys [db]} {:keys [error? resolved-url]}]
8989
(when (not error?)
9090
(let [current-url (get-current-url (get-current-browser db))
91-
host (http/url-host current-url)]
91+
host (url/url-host current-url)]
9292
(if (and (not resolved-url) (ens/is-valid-eth-name? host))
9393
{:db (update db :browser/options assoc :resolving? true)
9494
:browser/resolve-ens-contenthash {:chain-id (ethereum/chain-id db)
@@ -162,7 +162,7 @@
162162
{:events [:browser/ignore-unsafe]}
163163
[cofx]
164164
(let [browser (get-current-browser (:db cofx))
165-
host (http/url-host (get-current-url browser))]
165+
host (url/url-host (get-current-url browser))]
166166
(update-browser cofx (assoc browser :ignore-unsafe host))))
167167

168168
(defn can-go-forward?
@@ -194,7 +194,7 @@
194194
{:events [:browser.callback/resolve-ens-multihash-success]}
195195
[{:keys [db] :as cofx} url]
196196
(let [current-url (get-current-url (get-current-browser db))
197-
host (http/url-host current-url)
197+
host (url/url-host current-url)
198198
path (subs current-url (+ (.indexOf ^js current-url host) (count host)))
199199
gateway url]
200200
(rf/merge cofx
@@ -247,9 +247,9 @@
247247
(not= (.indexOf ^js url (second v)) -1))
248248
(:resolved-ens options)))
249249
resolved-url (if resolved-ens
250-
(http/normalize-url (string/replace url
251-
(second resolved-ens)
252-
(first resolved-ens)))
250+
(url/normalize-url (string/replace url
251+
(second resolved-ens)
252+
(first resolved-ens)))
253253
url)]
254254
(rf/merge cofx
255255
(update-browser-history browser resolved-url)
@@ -282,7 +282,7 @@
282282
{:events [:browser.ui/url-submitted]}
283283
[cofx url]
284284
(let [browser (get-current-browser (:db cofx))
285-
normalized-url (http/normalize-and-decode-url url)]
285+
normalized-url (url/normalize-and-decode-url url)]
286286
(if (links/universal-link? normalized-url)
287287
{:dispatch [:universal-links/handle-url normalized-url]}
288288
(rf/merge cofx
@@ -296,7 +296,7 @@
296296
If the browser is reused, the history is flushed"
297297
{:events [:browser.ui/open-url]}
298298
[{:keys [db] :as cofx} url]
299-
(let [normalized-url (http/normalize-and-decode-url url)
299+
(let [normalized-url (url/normalize-and-decode-url url)
300300
browser {:browser-id (random/id)
301301
:history-index 0
302302
:history [normalized-url]}]
@@ -503,7 +503,7 @@
503503
{:keys [dapp? name]} browser
504504
dapp-name (if dapp?
505505
name
506-
(http/url-host
506+
(url/url-host
507507
url-original))]
508508
(cond
509509
(and (= type constants/history-state-changed)

src/status_im/browser/core_test.cljs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
(ns status-im.browser.core-test
22
(:require [cljs.test :refer-macros [deftest is testing]]
33
[status-im.browser.core :as browser]
4-
[status-im.utils.http :as http]))
4+
[utils.url :as url]))
55

66
(defn has-wrong-properties?
77
[result dapp-url expected-browser]
@@ -16,7 +16,7 @@
1616

1717
(defn get-dapp-id
1818
[result dapp-url]
19-
(some #(when (= (http/normalize-and-decode-url dapp-url) (first (:history %))) (:browser-id %))
19+
(some #(when (= (url/normalize-and-decode-url dapp-url) (first (:history %))) (:browser-id %))
2020
(vals (get-in result [:db :browser/browsers]))))
2121

2222
(deftest browser-test

src/status_im/events.cljs

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
status-im.currency.core
1818
status-im.ethereum.subscriptions
1919
status-im.fleet.core
20-
status-im.http.core
2120
[utils.i18n :as i18n]
2221
[status-im.keycard.core :as keycard]
2322
status-im.log-level.core

src/status_im/http/core.cljs

-11
This file was deleted.

src/status_im/network/core.cljs

+2-27
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
[utils.i18n :as i18n]
66
[status-im.node.core :as node]
77
[utils.re-frame :as rf]
8-
[status-im.utils.http :as http]
9-
[status-im.utils.types :as types]
108
[status-im2.navigation.events :as navigation]))
119

1210
(def url-regex
@@ -97,31 +95,8 @@
9795
(rf/defn connect
9896
{:events [::connect-network-pressed]}
9997
[{:keys [db] :as cofx} network-id]
100-
(if-let [config (get-in db [:networks/networks network-id :config])]
101-
(if-let [upstream-url (get-in config [:UpstreamConfig :URL])]
102-
{:http-post {:url upstream-url
103-
:data (types/clj->json {:jsonrpc "2.0"
104-
:method "net_version"
105-
:id 2})
106-
:opts {:headers {"Content-Type" "application/json"}}
107-
:on-success (fn [{:keys [response-body]}]
108-
(let [response (http/parse-payload response-body)
109-
expected-network-id (:NetworkId config)
110-
rpc-network-id (when-let [res (:result response)]
111-
(js/parseInt res))]
112-
(if (and network-id (= expected-network-id rpc-network-id))
113-
(re-frame/dispatch [::connect-success network-id])
114-
(re-frame/dispatch [::connect-failure
115-
(if (not= expected-network-id rpc-network-id)
116-
(i18n/label :t/network-invalid-network-id)
117-
(i18n/label :t/network-invalid-url))]))))
118-
:on-error (fn [{:keys [response-body status-code]}]
119-
(let [reason (if status-code
120-
(i18n/label :t/network-invalid-status-code
121-
{:code status-code})
122-
(str response-body))]
123-
(re-frame/dispatch [::connect-failure reason])))}}
124-
(connect-success cofx network-id))
98+
(if (get-in db [:networks/networks network-id :config])
99+
(connect-success cofx network-id)
125100
(connect-failure cofx "A network with the specified id doesn't exist")))
126101

127102
(rf/defn delete

src/status_im/router/core.cljs

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
[native-module.core :as native-module]
1212
[status-im.ethereum.stateofus :as stateofus]
1313
[utils.validators :as validators]
14-
[status-im.utils.http :as http]
14+
[utils.url :as url]
1515
[status-im.utils.wallet-connect :as wallet-connect]
1616
[taoensso.timbre :as log]
1717
[utils.security.core :as security]))
@@ -60,7 +60,7 @@
6060
(defn parse-query-params
6161
[url]
6262
(let [url (goog.Uri. url)]
63-
(http/query->map (.getQuery url))))
63+
(url/query->map (.getQuery url))))
6464

6565
(defn match-uri
6666
[uri]
@@ -247,7 +247,7 @@
247247
(ethereum/address? uri)
248248
(cb (address->eip681 uri))
249249

250-
(http/url? uri)
250+
(url/url? uri)
251251
(cb (match-browser-string uri))
252252

253253
(wallet-connect/url? uri)

src/status_im/ui/components/list_selection.cljs

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[status-im.ui.components.action-sheet :as action-sheet]
55
[status-im.ui.components.dialog :as dialog]
66
[status-im.ui.components.react :as react]
7-
[status-im.utils.http :as http]
7+
[utils.url :as url]
88
[status-im.utils.platform :as platform]))
99

1010
(defn open-share
@@ -29,12 +29,12 @@
2929
:options [{:label (i18n/label :t/browsing-open-in-status)
3030
:action #(re-frame/dispatch [:browser.ui/open-url link])}
3131
{:label (i18n/label (platform-web-browser))
32-
:action #(.openURL ^js react/linking (http/normalize-url link))}]
32+
:action #(.openURL ^js react/linking (url/normalize-url link))}]
3333
:cancel-text (i18n/label :t/browsing-cancel)}))
3434

3535
(defn browse-in-web-browser
3636
[link]
3737
(show {:title (i18n/label :t/browsing-title)
3838
:options [{:label (i18n/label (platform-web-browser))
39-
:action #(.openURL ^js react/linking (http/normalize-url link))}]
39+
:action #(.openURL ^js react/linking (url/normalize-url link))}]
4040
:cancel-text (i18n/label :t/browsing-cancel)}))

src/status_im/ui/screens/browser/empty_tab/views.cljs

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
[status-im.ui.screens.browser.empty-tab.styles :as styles]
1414
[status-im.ui.screens.browser.views :as browser]
1515
[status-im.ui.screens.wallet.components.views :as components]
16-
[status-im.utils.http :as http])
16+
[utils.url :as url])
1717
(:require-macros [status-im.utils.views :as views]))
1818

1919
(defn hide-sheet-and-dispatch
@@ -67,7 +67,7 @@
6767
[react/image
6868
{:onLoad #(reset! loaded true)
6969
:style {:width 32 :height 32 :position :absolute :top 4 :left 4}
70-
:source {:uri (str "https://" (http/url-host url) "/favicon.ico")}}])
70+
:source {:uri (str "https://" (url/url-host url) "/favicon.ico")}}])
7171
(when-not @loaded
7272
[react/view
7373
{:width 40

src/status_im/ui/screens/browser/options/views.cljs

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
[status-im.ui.components.icons.icons :as icons]
1111
[status-im.ui.components.react :as react]
1212
[status-im.ui.screens.wallet.components.views :as components]
13-
[status-im.utils.http :as http]
13+
[utils.url :as url]
1414
[status-im.utils.utils :as utils]))
1515

1616
(defn hide-sheet-and-dispatch
@@ -45,7 +45,7 @@
4545
permissions @(re-frame/subscribe [:dapps/permissions])
4646
fav? (get bookmarks url)
4747
connected? (some #{constants/dapp-permission-web3}
48-
(get-in permissions [(http/url-host url) :permissions]))]
48+
(get-in permissions [(url/url-host url) :permissions]))]
4949
[react/view {:flex 1}
5050
[quo/button
5151
{:style {:align-self :flex-end
@@ -94,7 +94,7 @@
9494
:chevron true
9595
:on-press #(hide-sheet-and-dispatch
9696
[:bottom-sheet/show-sheet-old
97-
{:content (wallet-connection (http/url-host url) account)}])}]
97+
{:content (wallet-connection (url/url-host url) account)}])}]
9898
[quo/list-item
9999
{:theme :accent
100100
:title (i18n/label :t/connect-wallet)

src/status_im/ui/screens/browser/tabs/views.cljs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
[status-im.ui.components.react :as react]
1212
[status-im.ui.components.topbar :as topbar]
1313
[status-im.ui.screens.wallet.components.views :as components]
14-
[status-im.utils.http :as http]))
14+
[utils.url :as url]))
1515

1616
(defn list-item
1717
[_]
@@ -35,7 +35,7 @@
3535
[react/image
3636
{:onLoad #(reset! loaded true)
3737
:style {:width 32 :height 32 :position :absolute :top 4 :left 4}
38-
:source {:uri (str "https://" (http/url-host url) "/favicon.ico")}}])
38+
:source {:uri (str "https://" (url/url-host url) "/favicon.ico")}}])
3939
(when-not @loaded
4040
[react/view
4141
{:width 40

src/status_im/ui/screens/browser/views.cljs

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
[status-im.ui.screens.browser.site-blocked.views :as site-blocked.views]
2222
[status-im.ui.screens.browser.styles :as styles]
2323
[status-im.ui.screens.wallet.components.views :as components]
24-
[status-im.utils.http :as http]
24+
[utils.url :as url]
2525
[status-im.utils.js-resources :as js-res]
2626
[utils.debounce :as debounce])
2727
(:require-macros [status-im.utils.views :as views]))
@@ -52,7 +52,7 @@
5252
[react/touchable-highlight
5353
{:style styles/url-text-container
5454
:on-press #(re-frame/dispatch [:browser.ui/url-input-pressed])}
55-
[react/text {:number-of-lines 1} (http/url-host url-original)]])
55+
[react/text {:number-of-lines 1} (url/url-host url-original)]])
5656
(when-not unsafe?
5757
[react/touchable-highlight
5858
{:on-press #(.reload ^js @webview-ref/webview-ref)
@@ -192,7 +192,7 @@
192192
{:flex 1
193193
:elevation -10}
194194
[react/view {:flex 1}
195-
(if (and unsafe? (not= (http/url-host url) ignore-unsafe))
195+
(if (and unsafe? (not= (url/url-host url) ignore-unsafe))
196196
[site-blocked.views/view
197197
{:can-go-back? can-go-back?
198198
:site browser-id}]

0 commit comments

Comments
 (0)