Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#17347] move [status-im.utils.http :as http] to status-im2 #17350

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ SPEC CHECKSUMS:
FBLazyVector: a8af91c2b5a0029d12ff6b32e428863d63c48991
FBReactNativeSpec: 1b2309b096448a1dc9d0c43999216f8fda809ae8
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
glog: 166d178815c300e8126de9a7900101814eb16253
glog: d93527a855523adb8c113837db4be68fb00e230d
HMSegmentedControl: 34c1f54d822d8308e7b24f5d901ec674dfa31352
Keycard: ac6df4d91525c3c82635ac24d4ddd9a80aca5fc8
libwebp: f62cb61d0a484ba548448a4bd52aabf150ff6eef
Expand Down Expand Up @@ -772,7 +772,7 @@ SPEC CHECKSUMS:
RNLanguages: 962e562af0d34ab1958d89bcfdb64fafc37c513e
RNPermissions: ad71dd4f767ec254f2cd57592fbee02afee75467
RNReactNativeHapticFeedback: 2566b468cc8d0e7bb2f84b23adc0f4614594d071
RNReanimated: b3b67ebe099c0b0e7b5c7386b18d2468e29c9d41
RNReanimated: 43adb0307a62c1ce9694f36f124ca3b51a15272a
RNShare: d82e10f6b7677f4b0048c23709bd04098d5aee6c
RNStaticSafeAreaInsets: 055ddbf5e476321720457cdaeec0ff2ba40ec1b8
RNSVG: 80584470ff1ffc7994923ea135a3e5ad825546b9
Expand All @@ -785,6 +785,6 @@ SPEC CHECKSUMS:
TouchID: ba4c656d849cceabc2e4eef722dea5e55959ecf4
Yoga: d24d6184b6b85f742536bd93bd07d69d7b9bb4c1

PODFILE CHECKSUM: 8df67467da1e4e60ec164479744536c6f8fc98ed
PODFILE CHECKSUM: ac30a0172ff0126b6f307c20f34c47ce0ebf278f

COCOAPODS: 1.12.0
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
"react-native-dialogs": "^1.0.4",
"react-native-draggable-flatlist": "^4.0.1",
"react-native-fast-image": "^8.5.11",
"react-native-fetch-polyfill": "^1.1.2",
"react-native-fs": "^2.14.1",
"react-native-gesture-handler": "2.6.1",
"react-native-gifted-charts": "git+https://github.com/status-im/react-native-gifted-charts.git#refs/tags/1.3.2-status.1",
Expand Down
22 changes: 11 additions & 11 deletions src/status_im/browser/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
[status-im.signing.core :as signing]
[status-im.ui.components.list-selection :as list-selection]
[utils.re-frame :as rf]
[status-im.utils.http :as http]
[utils.url :as url]
[status-im.utils.platform :as platform]
[status-im.utils.random :as random]
[status-im.utils.types :as types]
Expand Down Expand Up @@ -75,7 +75,7 @@

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

(defn resolve-ens-contenthash-callback
Expand All @@ -88,7 +88,7 @@
[{:keys [db]} {:keys [error? resolved-url]}]
(when (not error?)
(let [current-url (get-current-url (get-current-browser db))
host (http/url-host current-url)]
host (url/url-host current-url)]
(if (and (not resolved-url) (ens/is-valid-eth-name? host))
{:db (update db :browser/options assoc :resolving? true)
:browser/resolve-ens-contenthash {:chain-id (ethereum/chain-id db)
Expand Down Expand Up @@ -162,7 +162,7 @@
{:events [:browser/ignore-unsafe]}
[cofx]
(let [browser (get-current-browser (:db cofx))
host (http/url-host (get-current-url browser))]
host (url/url-host (get-current-url browser))]
(update-browser cofx (assoc browser :ignore-unsafe host))))

(defn can-go-forward?
Expand Down Expand Up @@ -194,7 +194,7 @@
{:events [:browser.callback/resolve-ens-multihash-success]}
[{:keys [db] :as cofx} url]
(let [current-url (get-current-url (get-current-browser db))
host (http/url-host current-url)
host (url/url-host current-url)
path (subs current-url (+ (.indexOf ^js current-url host) (count host)))
gateway url]
(rf/merge cofx
Expand Down Expand Up @@ -247,9 +247,9 @@
(not= (.indexOf ^js url (second v)) -1))
(:resolved-ens options)))
resolved-url (if resolved-ens
(http/normalize-url (string/replace url
(second resolved-ens)
(first resolved-ens)))
(url/normalize-url (string/replace url
(second resolved-ens)
(first resolved-ens)))
url)]
(rf/merge cofx
(update-browser-history browser resolved-url)
Expand Down Expand Up @@ -282,7 +282,7 @@
{:events [:browser.ui/url-submitted]}
[cofx url]
(let [browser (get-current-browser (:db cofx))
normalized-url (http/normalize-and-decode-url url)]
normalized-url (url/normalize-and-decode-url url)]
(if (links/universal-link? normalized-url)
{:dispatch [:universal-links/handle-url normalized-url]}
(rf/merge cofx
Expand All @@ -296,7 +296,7 @@
If the browser is reused, the history is flushed"
{:events [:browser.ui/open-url]}
[{:keys [db] :as cofx} url]
(let [normalized-url (http/normalize-and-decode-url url)
(let [normalized-url (url/normalize-and-decode-url url)
browser {:browser-id (random/id)
:history-index 0
:history [normalized-url]}]
Expand Down Expand Up @@ -503,7 +503,7 @@
{:keys [dapp? name]} browser
dapp-name (if dapp?
name
(http/url-host
(url/url-host
url-original))]
(cond
(and (= type constants/history-state-changed)
Expand Down
4 changes: 2 additions & 2 deletions src/status_im/browser/core_test.cljs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(ns status-im.browser.core-test
(:require [cljs.test :refer-macros [deftest is testing]]
[status-im.browser.core :as browser]
[status-im.utils.http :as http]))
[utils.url :as url]))

(defn has-wrong-properties?
[result dapp-url expected-browser]
Expand All @@ -16,7 +16,7 @@

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

(deftest browser-test
Expand Down
1 change: 0 additions & 1 deletion src/status_im/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
status-im.currency.core
status-im.ethereum.subscriptions
status-im.fleet.core
status-im.http.core
[utils.i18n :as i18n]
[status-im.keycard.core :as keycard]
status-im.log-level.core
Expand Down
11 changes: 0 additions & 11 deletions src/status_im/http/core.cljs

This file was deleted.

29 changes: 2 additions & 27 deletions src/status_im/network/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
[utils.i18n :as i18n]
[status-im.node.core :as node]
[utils.re-frame :as rf]
[status-im.utils.http :as http]
[status-im.utils.types :as types]
[status-im2.navigation.events :as navigation]))

(def url-regex
Expand Down Expand Up @@ -97,31 +95,8 @@
(rf/defn connect
{:events [::connect-network-pressed]}
[{:keys [db] :as cofx} network-id]
(if-let [config (get-in db [:networks/networks network-id :config])]
(if-let [upstream-url (get-in config [:UpstreamConfig :URL])]
{:http-post {:url upstream-url
Comment on lines -100 to -102
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need this anymore?

:data (types/clj->json {:jsonrpc "2.0"
:method "net_version"
:id 2})
:opts {:headers {"Content-Type" "application/json"}}
:on-success (fn [{:keys [response-body]}]
(let [response (http/parse-payload response-body)
expected-network-id (:NetworkId config)
rpc-network-id (when-let [res (:result response)]
(js/parseInt res))]
(if (and network-id (= expected-network-id rpc-network-id))
(re-frame/dispatch [::connect-success network-id])
(re-frame/dispatch [::connect-failure
(if (not= expected-network-id rpc-network-id)
(i18n/label :t/network-invalid-network-id)
(i18n/label :t/network-invalid-url))]))))
:on-error (fn [{:keys [response-body status-code]}]
(let [reason (if status-code
(i18n/label :t/network-invalid-status-code
{:code status-code})
(str response-body))]
(re-frame/dispatch [::connect-failure reason])))}}
(connect-success cofx network-id))
(if (get-in db [:networks/networks network-id :config])
(connect-success cofx network-id)
(connect-failure cofx "A network with the specified id doesn't exist")))

(rf/defn delete
Expand Down
6 changes: 3 additions & 3 deletions src/status_im/router/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
[native-module.core :as native-module]
[status-im.ethereum.stateofus :as stateofus]
[utils.validators :as validators]
[status-im.utils.http :as http]
[utils.url :as url]
[status-im.utils.wallet-connect :as wallet-connect]
[taoensso.timbre :as log]
[utils.security.core :as security]))
Expand Down Expand Up @@ -60,7 +60,7 @@
(defn parse-query-params
[url]
(let [url (goog.Uri. url)]
(http/query->map (.getQuery url))))
(url/query->map (.getQuery url))))

(defn match-uri
[uri]
Expand Down Expand Up @@ -247,7 +247,7 @@
(ethereum/address? uri)
(cb (address->eip681 uri))

(http/url? uri)
(url/url? uri)
(cb (match-browser-string uri))

(wallet-connect/url? uri)
Expand Down
6 changes: 3 additions & 3 deletions src/status_im/ui/components/list_selection.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[status-im.ui.components.action-sheet :as action-sheet]
[status-im.ui.components.dialog :as dialog]
[status-im.ui.components.react :as react]
[status-im.utils.http :as http]
[utils.url :as url]
[status-im.utils.platform :as platform]))

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

(defn browse-in-web-browser
[link]
(show {:title (i18n/label :t/browsing-title)
:options [{:label (i18n/label (platform-web-browser))
:action #(.openURL ^js react/linking (http/normalize-url link))}]
:action #(.openURL ^js react/linking (url/normalize-url link))}]
:cancel-text (i18n/label :t/browsing-cancel)}))
4 changes: 2 additions & 2 deletions src/status_im/ui/screens/browser/empty_tab/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
[status-im.ui.screens.browser.empty-tab.styles :as styles]
[status-im.ui.screens.browser.views :as browser]
[status-im.ui.screens.wallet.components.views :as components]
[status-im.utils.http :as http])
[utils.url :as url])
(:require-macros [status-im.utils.views :as views]))

(defn hide-sheet-and-dispatch
Expand Down Expand Up @@ -67,7 +67,7 @@
[react/image
{:onLoad #(reset! loaded true)
:style {:width 32 :height 32 :position :absolute :top 4 :left 4}
:source {:uri (str "https://" (http/url-host url) "/favicon.ico")}}])
:source {:uri (str "https://" (url/url-host url) "/favicon.ico")}}])
(when-not @loaded
[react/view
{:width 40
Expand Down
6 changes: 3 additions & 3 deletions src/status_im/ui/screens/browser/options/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[status-im.ui.components.icons.icons :as icons]
[status-im.ui.components.react :as react]
[status-im.ui.screens.wallet.components.views :as components]
[status-im.utils.http :as http]
[utils.url :as url]
[status-im.utils.utils :as utils]))

(defn hide-sheet-and-dispatch
Expand Down Expand Up @@ -45,7 +45,7 @@
permissions @(re-frame/subscribe [:dapps/permissions])
fav? (get bookmarks url)
connected? (some #{constants/dapp-permission-web3}
(get-in permissions [(http/url-host url) :permissions]))]
(get-in permissions [(url/url-host url) :permissions]))]
[react/view {:flex 1}
[quo/button
{:style {:align-self :flex-end
Expand Down Expand Up @@ -94,7 +94,7 @@
:chevron true
:on-press #(hide-sheet-and-dispatch
[:bottom-sheet/show-sheet-old
{:content (wallet-connection (http/url-host url) account)}])}]
{:content (wallet-connection (url/url-host url) account)}])}]
[quo/list-item
{:theme :accent
:title (i18n/label :t/connect-wallet)
Expand Down
4 changes: 2 additions & 2 deletions src/status_im/ui/screens/browser/tabs/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
[status-im.ui.components.react :as react]
[status-im.ui.components.topbar :as topbar]
[status-im.ui.screens.wallet.components.views :as components]
[status-im.utils.http :as http]))
[utils.url :as url]))

(defn list-item
[_]
Expand All @@ -35,7 +35,7 @@
[react/image
{:onLoad #(reset! loaded true)
:style {:width 32 :height 32 :position :absolute :top 4 :left 4}
:source {:uri (str "https://" (http/url-host url) "/favicon.ico")}}])
:source {:uri (str "https://" (url/url-host url) "/favicon.ico")}}])
(when-not @loaded
[react/view
{:width 40
Expand Down
6 changes: 3 additions & 3 deletions src/status_im/ui/screens/browser/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
[status-im.ui.screens.browser.site-blocked.views :as site-blocked.views]
[status-im.ui.screens.browser.styles :as styles]
[status-im.ui.screens.wallet.components.views :as components]
[status-im.utils.http :as http]
[utils.url :as url]
[status-im.utils.js-resources :as js-res]
[utils.debounce :as debounce])
(:require-macros [status-im.utils.views :as views]))
Expand Down Expand Up @@ -52,7 +52,7 @@
[react/touchable-highlight
{:style styles/url-text-container
:on-press #(re-frame/dispatch [:browser.ui/url-input-pressed])}
[react/text {:number-of-lines 1} (http/url-host url-original)]])
[react/text {:number-of-lines 1} (url/url-host url-original)]])
(when-not unsafe?
[react/touchable-highlight
{:on-press #(.reload ^js @webview-ref/webview-ref)
Expand Down Expand Up @@ -192,7 +192,7 @@
{:flex 1
:elevation -10}
[react/view {:flex 1}
(if (and unsafe? (not= (http/url-host url) ignore-unsafe))
(if (and unsafe? (not= (url/url-host url) ignore-unsafe))
[site-blocked.views/view
{:can-go-back? can-go-back?
:site browser-id}]
Expand Down
Loading