removed dapps list and introduced simple Dapp store dapp

Signed-off-by: Andrey Shovkoplyas <motor4ik@gmail.com>
This commit is contained in:
Andrey Shovkoplyas 2019-03-14 14:39:46 +01:00
parent d5f8853b81
commit 159199a1b3
No known key found for this signature in database
GPG Key ID: EAAB7C8622D860A4
72 changed files with 120 additions and 453 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 446 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 622 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1003 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 151 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -8,7 +8,6 @@
[status-im.js-dependencies :as dependencies] [status-im.js-dependencies :as dependencies]
[status-im.native-module.core :as status] [status-im.native-module.core :as status]
[status-im.ui.components.list-selection :as list-selection] [status-im.ui.components.list-selection :as list-selection]
[status-im.ui.screens.browser.default-dapps :as default-dapps]
[status-im.ui.screens.navigation :as navigation] [status-im.ui.screens.navigation :as navigation]
[status-im.utils.ethereum.core :as ethereum] [status-im.utils.ethereum.core :as ethereum]
[status-im.utils.ethereum.ens :as ens] [status-im.utils.ethereum.ens :as ens]
@ -21,7 +20,8 @@
[status-im.utils.types :as types] [status-im.utils.types :as types]
[status-im.utils.universal-links.core :as utils.universal-links] [status-im.utils.universal-links.core :as utils.universal-links]
[taoensso.timbre :as log] [taoensso.timbre :as log]
[status-im.js-dependencies :as js-dependencies])) [status-im.js-dependencies :as js-dependencies]
[status-im.utils.universal-links.core :as universal-links]))
(fx/defn initialize-browsers (fx/defn initialize-browsers
[{:keys [db all-stored-browsers]}] [{:keys [db all-stored-browsers]}]
@ -59,16 +59,8 @@
{:db (update-in db [:browser/browsers] dissoc browser-id) {:db (update-in db [:browser/browsers] dissoc browser-id)
:data-store/tx [(browser-store/remove-browser-tx browser-id)]}) :data-store/tx [(browser-store/remove-browser-tx browser-id)]})
(defn check-if-dapp-in-list [{:keys [history history-index name] :as browser}] (defn update-dapp-name [{:keys [name] :as browser}]
(let [history-host (http/url-host (try (nth history history-index) (catch js/Error _))) (assoc browser :dapp? false :name (or name (i18n/label :t/browser))))
dapp (first (filter #(= history-host (http/url-host (http/normalize-url (:dapp-url %))))
(apply concat (mapv :data default-dapps/all))))]
(if dapp
;;TODO(yenda): the consequence of this is that if user goes to a different
;;url from a dapp browser, the name of the browser in the home screen will
;;change
(assoc browser :dapp? true :name (:name dapp))
(assoc browser :dapp? false :name (or name (i18n/label :t/browser))))))
(defn check-if-phishing-url [{:keys [history history-index] :as browser}] (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 (http/url-host (try (nth history history-index) (catch js/Error _)))]
@ -118,7 +110,7 @@
[{:keys [db now]} [{:keys [db now]}
{:keys [browser-id] :as browser}] {:keys [browser-id] :as browser}]
(let [updated-browser (-> (assoc browser :timestamp now) (let [updated-browser (-> (assoc browser :timestamp now)
(check-if-dapp-in-list) (update-dapp-name)
(check-if-phishing-url))] (check-if-phishing-url))]
{:db (update-in db {:db (update-in db
[:browser/browsers browser-id] [:browser/browsers browser-id]
@ -250,8 +242,7 @@
If the browser is reused, the history is flushed" If the browser is reused, the history is flushed"
[{:keys [db] :as cofx} url] [{:keys [db] :as cofx} url]
(let [normalized-url (http/normalize-and-decode-url url) (let [normalized-url (http/normalize-and-decode-url url)
host (http/url-host normalized-url) browser {:browser-id (random/id)
browser {:browser-id (or host (random/id))
:history-index 0 :history-index 0
:history [normalized-url]}] :history [normalized-url]}]
(if (utils.universal-links/universal-link? normalized-url) (if (utils.universal-links/universal-link? normalized-url)
@ -394,3 +385,8 @@
:browser/show-web-browser-selection :browser/show-web-browser-selection
(fn [link] (fn [link]
(list-selection/browse-in-web-browser link))) (list-selection/browse-in-web-browser link)))
(defn share-link [url]
(let [link (universal-links/generate-link :browse :external url)
message (i18n/label :t/share-dapp-text {:link link})]
(list-selection/open-share {:message message})))

View File

@ -63,7 +63,7 @@
(fx/defn initialize-chats (fx/defn initialize-chats
"Initialize persisted chats on startup" "Initialize persisted chats on startup"
[{:keys [db default-dapps get-all-stored-chats] :as cofx} [{:keys [db get-all-stored-chats] :as cofx}
{:keys [from to] :or {from 0 to nil}}] {:keys [from to] :or {from 0 to nil}}]
(let [old-chats (:chats db) (let [old-chats (:chats db)
chats (reduce (fn [acc {:keys [chat-id] :as chat}] chats (reduce (fn [acc {:keys [chat-id] :as chat}]
@ -76,9 +76,7 @@
(get-all-stored-chats from to)) (get-all-stored-chats from to))
chats (merge old-chats chats)] chats (merge old-chats chats)]
(fx/merge cofx (fx/merge cofx
{:db (assoc db {:db (assoc db :chats chats)}
:chats chats
:contacts/dapps default-dapps)}
(commands/load-commands commands/register)))) (commands/load-commands commands/register))))
(defn load-more-messages (defn load-more-messages

View File

@ -3,11 +3,6 @@
[status-im.utils.identicon :as identicon] [status-im.utils.identicon :as identicon]
[status-im.contact.db :as contact.db])) [status-im.contact.db :as contact.db]))
(re-frame/reg-sub
::dapps
(fn [db]
(:contacts/dapps db)))
(re-frame/reg-sub (re-frame/reg-sub
::contacts ::contacts
(fn [db] (fn [db]
@ -68,28 +63,6 @@
contact.db/public-key->new-contact contact.db/public-key->new-contact
contact.db/enrich-contact)))) contact.db/enrich-contact))))
(re-frame/reg-sub
:contacts/all-dapps
:<- [::dapps]
:<- [:account/account]
(fn [[dapps {:keys [dev-mode?]}]]
(map (fn [m] (update m :data
#(contact.db/filter-dapps % dev-mode?)))
dapps)))
(re-frame/reg-sub
:contacts/dapps-by-name
:<- [:contacts/all-dapps]
(fn [dapps]
(reduce (fn [dapps-by-name category]
(merge dapps-by-name
(reduce (fn [acc {:keys [name] :as dapp}]
(assoc acc name dapp))
{}
(:data category))))
{}
dapps)))
(re-frame/reg-sub (re-frame/reg-sub
:contacts/contact-name-by-identity :contacts/contact-name-by-identity
:<- [:contacts/contacts] :<- [:contacts/contacts]

View File

@ -103,7 +103,6 @@
(handlers/register-handler-fx (handlers/register-handler-fx
:init-rest-of-chats :init-rest-of-chats
[(re-frame/inject-cofx :web3/get-web3) [(re-frame/inject-cofx :web3/get-web3)
(re-frame/inject-cofx :get-default-dapps)
(re-frame/inject-cofx :data-store/all-chats)] (re-frame/inject-cofx :data-store/all-chats)]
(fn [{:keys [db] :as cofx} [_]] (fn [{:keys [db] :as cofx} [_]]
(log/debug "PERF" :init-rest-of-chats (.now js/Date)) (log/debug "PERF" :init-rest-of-chats (.now js/Date))
@ -131,7 +130,6 @@
(re-frame/inject-cofx :data-store/get-all-installations) (re-frame/inject-cofx :data-store/get-all-installations)
(re-frame/inject-cofx :data-store/all-browsers) (re-frame/inject-cofx :data-store/all-browsers)
(re-frame/inject-cofx :data-store/all-dapp-permissions) (re-frame/inject-cofx :data-store/all-dapp-permissions)
(re-frame/inject-cofx :get-default-dapps)
(re-frame/inject-cofx :data-store/all-chats)] (re-frame/inject-cofx :data-store/all-chats)]
account-change-success) account-change-success)
@ -1455,7 +1453,7 @@
(handlers/register-handler-fx (handlers/register-handler-fx
:browser/loading-started :browser/loading-started
(fn [cofx _] (fn [cofx _]
(browser/update-browser-option cofx :error? false))) (browser/update-browser-options cofx {:error? false :loading? true})))
(handlers/register-handler-fx (handlers/register-handler-fx
:browser.callback/resolve-ens-multihash-success :browser.callback/resolve-ens-multihash-success

View File

@ -1,61 +1,5 @@
(ns status-im.react-native.resources) (ns status-im.react-native.resources)
(def contacts
{:mkr-market (js/require "./resources/images/contacts/mkr-market.png")
:oaken-water-meter (js/require "./resources/images/contacts/oaken-water-meter.png")
:gnosis (js/require "./resources/images/contacts/gnosis.png")
:melonport (js/require "./resources/images/contacts/melonport.png")
:bchat (js/require "./resources/images/contacts/bchat.png")
:dentacoin (js/require "./resources/images/contacts/Dentacoin.png")
:augur (js/require "./resources/images/contacts/augur.png")
:ethlance (js/require "./resources/images/contacts/ethlance.png")
:commiteth (js/require "./resources/images/contacts/commiteth.png")
:etherplay (js/require "./resources/images/contacts/etherplay.png")
:ethcro (js/require "./resources/images/contacts/ethcro.png")
:easytrade (js/require "./resources/images/contacts/easytrade.png")
:dragonereum (js/require "./resources/images/contacts/dragonereum.png")
:name-bazaar (js/require "./resources/images/contacts/name-bazaar.png")
:cryptographics (js/require "./resources/images/contacts/cryptographics.png")
:cryptopunks (js/require "./resources/images/contacts/cryptopunks.png")
:cryptotakeovers (js/require "./resources/images/contacts/cryptotakeovers.png")
:cryptokitties (js/require "./resources/images/contacts/cryptokitties.png")
:decentraland (js/require "./resources/images/contacts/decentraland.png")
:etheremon (js/require "./resources/images/contacts/etheremon.png")
:cryptostrikers (js/require "./resources/images/contacts/cryptostrikers.png")
:cent (js/require "./resources/images/contacts/cent.png")
:kickback (js/require "./resources/images/contacts/kickback.png")
:hexel (js/require "./resources/images/contacts/hexel.png")
:peepeth (js/require "./resources/images/contacts/peepeth.png")
:etherbots (js/require "./resources/images/contacts/etherbots.png")
:opensea (js/require "./resources/images/contacts/opensea.png")
:kyber (js/require "./resources/images/contacts/kyber.png")
:bancor (js/require "./resources/images/contacts/bancor.png")
:blockimmo (js/require "./resources/images/contacts/blockimmo.png")
:cryptocribs (js/require "./resources/images/contacts/cryptocribs.png")
:cryptofighters (js/require "./resources/images/contacts/cryptofighters.png")
:etherman (js/require "./resources/images/contacts/etherman.png")
:airswap (js/require "./resources/images/contacts/airswap.png")
:civitas (js/require "./resources/images/contacts/civitas.png")
:dai (js/require "./resources/images/contacts/dai.png")
:local-ethereum (js/require "./resources/images/contacts/local-ethereum.png")
:eth2phone (js/require "./resources/images/contacts/eth2phone.png")
:bounties-network (js/require "./resources/images/contacts/bounties-network.png")
:cryptopurr (js/require "./resources/images/contacts/cryptopurr.png")
:ethlend (js/require "./resources/images/contacts/ethlend.png")
:smartz (js/require "./resources/images/contacts/smartz.png")
:snt-voting (js/require "./resources/images/contacts/snt-voting.png")
:superrare (js/require "./resources/images/contacts/superrare.png")
:3box (js/require "./resources/images/contacts/3Box.png")
:aragon (js/require "./resources/images/contacts/aragon.png")
:slowtrade (js/require "./resources/images/contacts/slowtrade.png")
:ddex (js/require "./resources/images/contacts/ddex.png")
:emoon (js/require "./resources/images/contacts/emoon.png")
:livepeer (js/require "./resources/images/contacts/livepeer.png")
:console (js/require "./resources/images/contacts/console.png")})
(def ui (def ui
{:empty-hashtags (js/require "./resources/images/ui/empty-hashtags.png") {:empty-hashtags (js/require "./resources/images/ui/empty-hashtags.png")
:empty-recent (js/require "./resources/images/ui/empty-recent.png") :empty-recent (js/require "./resources/images/ui/empty-recent.png")

View File

@ -1,184 +0,0 @@
(ns status-im.ui.screens.browser.default-dapps
(:require [re-frame.core :as re-frame]
[status-im.i18n :as i18n]))
(def all
[{:title (i18n/label :t/default-dapps-exchanges)
:data [{:name "Airswap"
:dapp-url "https://instant.airswap.io/"
:photo-path "contacts://airswap"
:description "Meet the future of trading."}
{:name "Bancor"
:dapp-url "https://www.bancor.network/"
:photo-path "contacts://bancor"
:description "Bancor is a decentralized liquidity network"}
{:name "Kyber"
:dapp-url "https://web3.kyber.network"
:photo-path "contacts://kyber"
:description "On-chain, instant and liquid platform for exchange and payment service"}
{:name "DAI by MakerDao"
:dapp-url "https://dai.makerdao.com"
:photo-path "contacts://dai"
:description "Stability for the blockchain"}
{:name "LocalEthereum"
:dapp-url "https://localethereum.com/"
:photo-path "contacts://local-ethereum"
:description "The smartest way to buy and sell Ether"}
{:name "Eth2phone"
:dapp-url "https://eth2.io"
:photo-path "contacts://eth2phone"
:description "Send Ether by phone number"}
{:name "DDEX"
:dapp-url "https://ddex.io/"
:photo-path "contacts://ddex"
:description "Instant, real-time order matching with secure on-chain settlement"}
{:name "EasyTrade"
:dapp-url "https://easytrade.io"
:photo-path "contacts://easytrade"
:description "One exchange for every token"}
{:name "slow.trade"
:dapp-url "https://slow.trade/"
:photo-path "contacts://slowtrade"
:description "Trade fairly priced crypto assets on the first platform built with the DutchX protocol."}]}
{:title (i18n/label :t/default-dapps-marketplaces)
:data [{:name "blockimmo"
:dapp-url "https://blockimmo.ch"
:photo-path "contacts://blockimmo"
:description "blockimmo is a blockchain powered, regulated platform enabling shared property investments and ownership."}
{:name "CryptoCribs"
:dapp-url "https://cryptocribs.com"
:photo-path "contacts://cryptocribs"
:description "Travel the globe. Pay in crypto."}
{:name "Ethlance"
:dapp-url "https://ethlance.com"
:photo-path "contacts://ethlance"
:description "The future of work is now. Hire people or work yourself in return for ETH."}
{:name "OpenSea"
:dapp-url "https://opensea.io"
:photo-path "contacts://opensea"
:description "The largest decentralized marketplace for cryptogoods"}
{:name "Name Bazaar"
:dapp-url "https://namebazaar.io"
:photo-path "contacts://name-bazaar"
:description "ENS name marketplace"}
{:name "The Bounties Network"
:dapp-url "https://bounties.network/"
:photo-path "contacts://bounties-network"
:description "Bounties on any task, paid in any token"}
{:name "Emoon"
:dapp-url "https://www.emoon.io/"
:photo-path "contacts://emoon"
:description "A decentralized marketplace for buying & selling crypto assets"}
{:name "SuperRare"
:dapp-url "https://superrare.co/market"
:photo-path "contacts://superrare"
:description "Buy, sell and collect unique digital creations by artists around the world"}]}
{:title (i18n/label :t/default-dapps-fun-games)
:data [{:name "CryptoKitties"
:dapp-url "https://www.cryptokitties.co"
:photo-path "contacts://cryptokitties"
:description "Collect and breed adorable digital cats."}
{:name "CryptoFighters"
:dapp-url "https://cryptofighters.io"
:photo-path "contacts://cryptofighters"
:description "Collect train and fight digital fighters."}
{:name "Cryptographics"
:dapp-url "https://cryptographics.app/"
:photo-path "contacts://cryptographics"
:description "Cryptographics is a digital art hub where artists, creators and collectors can submit asset packs, create unique cryptographics and trade them."}
{:name "CryptoPunks"
:dapp-url "https://www.larvalabs.com/cryptopunks"
:photo-path "contacts://cryptopunks"
:description "10,000 unique collectible punks"}
{:name "Crypto Takeovers"
:dapp-url "https://cryptotakeovers.com/"
:photo-path "contacts://cryptotakeovers"
:description "Predict and conquer the world. Make a crypto fortune."}
{:name "Decentraland"
:dapp-url "https://market.decentraland.org/"
:photo-path "contacts://decentraland"
:description "Decentraland is a virtual reality platform powered by the Ethereum blockchain."}
{:name "Dragonereum"
:dapp-url "https://dapp.dragonereum.io"
:photo-path "contacts://dragonereum"
:description "Own and trade dragons, fight with other players."}
{:name "Etherbots"
:dapp-url "https://etherbots.io/"
:photo-path "contacts://etherbots"
:description "Robot wars on the Ethereum Platform"}
{:name "Etheremon"
:dapp-url "https://www.etheremon.com/"
:photo-path "contacts://etheremon"
:description "Decentralized World of Ether Monsters"}
{:name "CryptoStrikers"
:dapp-url "https://www.cryptostrikers.com/"
:photo-path "contacts://cryptostrikers"
:description "The Beautiful (card) Game"}
{:name "Etherman"
:dapp-url "https://www.etherman.app"
:photo-path "contacts://etherman"
:description "Bomberman on Ethereum"}]}
{:title (i18n/label :t/default-dapps-social-networks)
:data [{:name "Cent"
:dapp-url "https://beta.cent.co/"
:photo-path "contacts://cent"
:description "Get wisdom, get money"}
{:name "Kickback"
:dapp-url "https://kickback.events/"
:photo-path "contacts://kickback"
:description "Event no shows? No problem. Kickback asks event attendees to put skin in the game with Ethereum."}
{:name "Peepeth"
:dapp-url "https://peepeth.com/"
:photo-path "contacts://peepeth"
:description "Blockchain-powered microblogging"}
{:name "Purrbook"
:dapp-url "https://cryptopurr.co/"
:photo-path "contacts://cryptopurr"
:description "A social network for CryptoKitties"}]}
{:title (i18n/label :t/default-dapps-media)
:data [{:name "livepeer.tv"
:dapp-url "http://livepeer.tv/"
:photo-path "contacts://livepeer"
:description "Decentralized video broadcasting"}]}
{:title (i18n/label :t/default-dapps-social-utilities)
:data [{:name "3Box"
:dapp-url "https://3box.io/"
:photo-path "contacts://3box"
:description "Create and manage your Ethereum Profile."}
{:name "Aragon"
:dapp-url "https://mainnet.aragon.org/"
:photo-path "contacts://aragon"
:description "Build unstoppable organizations on Ethereum."}
{:name "Civitas"
:dapp-url "https://communities.colu.com/"
:photo-path "contacts://civitas"
:description "Blockchain-powered local communities"}
{:name "ETHLend"
:dapp-url "https://app.ethlend.io"
:photo-path "contacts://ethlend"
:description "Decentralized lending on Ethereum"}
{:name "Hexel"
:dapp-url "https://www.onhexel.com/"
:photo-path "contacts://hexel"
:description "Create your own cryptocurrency"}
{:name "Livepeer"
:dapp-url "https://explorer.livepeer.org/"
:photo-path "contacts://livepeer"
:description "Decentralized video broadcasting"}
{:name "Smartz"
:dapp-url "https://smartz.io"
:photo-path "contacts://smartz"
:description "Easy smart contract management"}
{:name "SNT Voting DApp"
:dapp-url "https://vote.status.im"
:photo-path "contacts://snt-voting"
:description "Let your SNT be heard! Vote on decisions exclusive to SNT holders, or create a poll of your own."}
{:name "Status Test DApp"
:dapp-url "simpledapp.eth"
:description "Request test assets and test basic web3 functionality."
:developer? true}]}])
(re-frame/reg-cofx
:get-default-dapps
(fn [coeffects _]
(assoc coeffects :default-dapps all)))

View File

@ -17,5 +17,28 @@
{:flex 1 {:flex 1
:padding-horizontal 14 :padding-horizontal 14
:desktop {:height 30 :desktop {:height 30
:width "100%"} :width "100%"}
:android {:padding 0}}) :android {:padding 0}})
(def browser-icon-container
{:width 40
:height 40
:border-radius 20
:background-color colors/gray-lighter
:align-items :center
:justify-content :center})
(def dapp-store-container
{:margin 16
:border-color colors/gray-lighter
:border-width 1
:border-radius 12
:padding-vertical 16
:padding-horizontal 44
:align-items :center})
(def open-dapp-store
{:margin-top 12
:font-size 15
:font-weight "500"
:line-height 22})

View File

@ -7,64 +7,46 @@
[status-im.ui.components.status-bar.view :as status-bar] [status-im.ui.components.status-bar.view :as status-bar]
[status-im.ui.screens.browser.open-dapp.styles :as styles] [status-im.ui.screens.browser.open-dapp.styles :as styles]
[status-im.ui.components.list.views :as list] [status-im.ui.components.list.views :as list]
[status-im.ui.screens.home.views.inner-item :as inner-item]
[status-im.ui.components.common.common :as components.common] [status-im.ui.components.common.common :as components.common]
[status-im.ui.screens.wallet.components.views :as components] [status-im.ui.screens.wallet.components.views :as components]
[status-im.ui.components.bottom-bar.styles :as tabs.styles] [status-im.ui.components.bottom-bar.styles :as tabs.styles]
[status-im.react-native.resources :as resources] [status-im.react-native.resources :as resources]
[status-im.ui.components.chat-icon.screen :as chat-icon]) [status-im.ui.components.list-item.views :as list-item]
[status-im.ui.components.icons.vector-icons :as vector-icons])
(:require-macros [status-im.utils.views :as views])) (:require-macros [status-im.utils.views :as views]))
(defn list-item [{:keys [browser-id] :as home-item}] (defn list-item [{:keys [browser-id name url]}]
[list/deletable-list-item {:type :browsers [list/deletable-list-item {:type :browsers
:id browser-id :id browser-id
:on-delete #(do :on-delete #(do
(re-frame/dispatch [:set-swipe-position :browsers browser-id false]) (re-frame/dispatch [:set-swipe-position :browsers browser-id false])
(re-frame/dispatch [:browser.ui/remove-browser-pressed browser-id]))} (re-frame/dispatch [:browser.ui/remove-browser-pressed browser-id]))}
[inner-item/home-list-browser-item-inner-view home-item]]) [list-item/list-item
{:on-press #(re-frame/dispatch [:browser.ui/browser-item-selected browser-id])
:title name
:subtitle (or url (i18n/label :t/dapp))
:image [react/view styles/browser-icon-container
[vector-icons/icon :main-icons/browser {:color colors/gray}]]}]])
(defn- render-dapp [{:keys [dapp-url recent? description name] :as dapp}] (def dapp-image-data {:image (:dapp-store resources/ui) :width 768 :height 333})
(if recent? (def dapp-image (components.common/image-contain nil dapp-image-data))
[list-item dapp]
[react/touchable-highlight {:on-press #(re-frame/dispatch [:browser.ui/open-dapp-button-pressed dapp-url])}
[react/view {:style {:padding-top 11 :padding-horizontal 16 :padding-bottom 7 :flex-direction :row}}
[chat-icon/contact-icon-contacts-tab dapp]
[react/view {:padding-left 16 :padding-right 2 :flex 1}
[react/text {:style {:typography :main-medium}} name]
[react/text {:flex 1}
[react/text {:style {:font-size 13
:color "#939BA1"
:margin-top 5
:margin-bottom 2}}
description]]
[react/text {:style {:font-size 12
:color "#4360DF"}}
(str dapp-url " ->")]]]]))
(defn list-header [empty?] (defn list-header [empty?]
[react/view (when empty? {:flex 1}) [react/view (when empty? {:flex 1})
[react/view {:margin 16 [react/touchable-highlight {:on-press #(re-frame/dispatch [:browser.ui/dapp-url-submitted "https://dap.ps"])}
:border-color colors/gray-lighter [react/view styles/dapp-store-container
:border-width 1 [dapp-image nil dapp-image-data]
:border-radius 12 [react/text {:style styles/open-dapp-store} (i18n/label :t/open-dapp-store)]
:padding-vertical 16 [react/text {:style {:color colors/blue :font-size 13 :line-height 22}} "https://dap.ps ->"]]]
:padding-horizontal 44
:align-items :center}
[components.common/image-contain {:container-style {}} {:image (:dapp-store resources/ui) :width 768 :height 333}]
[react/text {:style {:typography :main-medium
:margin-top 12}}
"Open the ÐApp Store"]
[react/text {:style {:color colors/blue
:font-size 13}} "https://discover.dapps.eth ->"]]
(if empty? (if empty?
[react/view {:flex 1 :align-items :center :justify-content :center} [react/view {:flex 1 :align-items :center :justify-content :center}
[react/text {:style {:color colors/gray}} "Browsed websites will appear here."]] [react/text {:style {:color colors/gray :font-size 15}} (i18n/label :t/browsed-websites)]]
[react/view {:margin-top 14 :margin-left 16 :margin-bottom 4} [react/view {:margin-top 14 :margin-left 16 :margin-bottom 4}
[react/text {:style {:color colors/gray}} (i18n/label :t/recent)]])]) [react/text {:style {:line-height 22 :font-size 15 :color colors/gray}}
(i18n/label :t/recent)]])])
(views/defview open-dapp [] (views/defview open-dapp []
(views/letsubs [browsers [:browser/browsers-vals] (views/letsubs [browsers [:browser/browsers-vals]
dapps [:contacts/all-dapps]
url-text (atom nil)] url-text (atom nil)]
[react/keyboard-avoiding-view {:style {:flex 1}} [react/keyboard-avoiding-view {:style {:flex 1}}
[status-bar/status-bar] [status-bar/status-bar]
@ -78,25 +60,13 @@
:accessibility-label :dapp-url-input :accessibility-label :dapp-url-input
:return-key-type :go}]] :return-key-type :go}]]
[components/separator] [components/separator]
[list/section-list {:sections (cond-> dapps (if (empty? browsers)
(not (empty? browsers)) [list-header true]
(conj {:title (i18n/label :t/recent) [list/flat-list {:header [list-header false]
:data (map #(assoc % :dapp-url (:url %) :recent? true) browsers)})) :data browsers
:key-fn :dapp-url :footer [react/view
:render-fn render-dapp {:style {:height tabs.styles/tabs-diff
:enableEmptySections true :align-self :stretch}}]
:footer [react/view :key-fn :browser-id
{:style {:height tabs.styles/tabs-diff :end-fill-color colors/white
:align-self :stretch}}] :render-fn list-item}])]))
:keyboardShouldPersistTaps :always}]
;;TODO next iteration in next PR
#_(if (empty? browsers)
[list-header true]
[list/flat-list {:header [list-header false]
:data (vals browsers)
:footer [react/view
{:style {:height tabs.styles/tabs-diff
:align-self :stretch}}]
:key-fn :browser-id
:end-fill-color colors/white
:render-fn list-item}])]))

View File

@ -10,12 +10,9 @@
(re-frame/reg-sub (re-frame/reg-sub
:browser/browsers :browser/browsers
:<- [:browsers] :<- [:browsers]
:<- [:contacts/dapps-by-name] (fn [browsers]
(fn [[browsers dapps]] (reduce (fn [acc [k browser]]
(reduce (fn [acc [k {:keys [dapp? name] :as browser}]] (update acc k assoc :url (browser/get-current-url browser)))
(cond-> (update acc k assoc
:url (browser/get-current-url browser))
dapp? (assoc-in [k :dapp] (get dapps name))))
browsers browsers
browsers))) browsers)))

View File

@ -6,7 +6,6 @@
[status-im.i18n :as i18n] [status-im.i18n :as i18n]
[status-im.ui.components.colors :as colors] [status-im.ui.components.colors :as colors]
[status-im.ui.components.icons.vector-icons :as icons] [status-im.ui.components.icons.vector-icons :as icons]
[status-im.ui.components.list-selection :as list-selection]
[status-im.ui.components.react :as react] [status-im.ui.components.react :as react]
[status-im.ui.components.status-bar.view :as status-bar] [status-im.ui.components.status-bar.view :as status-bar]
[status-im.ui.components.styles :as components.styles] [status-im.ui.components.styles :as components.styles]
@ -17,7 +16,6 @@
[status-im.ui.screens.browser.permissions.views :as permissions.views] [status-im.ui.screens.browser.permissions.views :as permissions.views]
[status-im.ui.screens.browser.site-blocked.views :as site-blocked.views] [status-im.ui.screens.browser.site-blocked.views :as site-blocked.views]
[status-im.ui.screens.browser.styles :as styles] [status-im.ui.screens.browser.styles :as styles]
[status-im.ui.screens.wallet.actions :as wallet.actions]
[status-im.utils.ethereum.core :as ethereum] [status-im.utils.ethereum.core :as ethereum]
[status-im.utils.http :as http] [status-im.utils.http :as http]
[status-im.utils.js-resources :as js-res] [status-im.utils.js-resources :as js-res]
@ -94,7 +92,7 @@
:accessibility-label :modal-chat-button} :accessibility-label :modal-chat-button}
[icons/icon :main-icons/message]] [icons/icon :main-icons/message]]
[react/touchable-highlight [react/touchable-highlight
{:on-press #(wallet.actions/share-link browser-id) {:on-press #(browser/share-link url)
:accessibility-label :modal-share-link-button} :accessibility-label :modal-share-link-button}
[icons/icon :main-icons/share]] [icons/icon :main-icons/share]]
[react/touchable-highlight {:on-press #(.reload @webview) [react/touchable-highlight {:on-press #(.reload @webview)

View File

@ -200,7 +200,6 @@
(spec/def :extensions/profile (spec/nilable any?)) (spec/def :extensions/profile (spec/nilable any?))
(spec/def ::db (spec/keys :opt [:contacts/contacts (spec/def ::db (spec/keys :opt [:contacts/contacts
:contacts/dapps
:contacts/new-identity :contacts/new-identity
:contacts/new-identity-error :contacts/new-identity-error
:contacts/identity :contacts/identity

View File

@ -27,14 +27,6 @@
:android {:height 76} :android {:height 76}
:ios {:height 74}}) :ios {:height 74}})
(def browser-icon-container
{:width 40
:height 40
:border-radius 20
:background-color colors/gray-lighter
:align-items :center
:justify-content :center})
(defstyle chat-info-container (defstyle chat-info-container
{:margin-bottom 13 {:margin-bottom 13
:justify-content :space-between :justify-content :space-between

View File

@ -14,9 +14,6 @@
[status-im.ui.components.icons.vector-icons :as vector-icons] [status-im.ui.components.icons.vector-icons :as vector-icons]
[status-im.ui.components.chat-icon.screen :as chat-icon.screen] [status-im.ui.components.chat-icon.screen :as chat-icon.screen]
[status-im.ui.components.common.common :as components.common] [status-im.ui.components.common.common :as components.common]
[status-im.ui.components.list-item.views :as list-item]
[clojure.string :as string]
[status-im.ui.components.chat-icon.screen :as chat-icon]
[status-im.ui.components.list.views :as list])) [status-im.ui.components.list.views :as list]))
(defview command-short-preview [message] (defview command-short-preview [message]
@ -123,18 +120,4 @@
:on-delete #(do :on-delete #(do
(re-frame/dispatch [:set-swipe-position :chats home-item-id false]) (re-frame/dispatch [:set-swipe-position :chats home-item-id false])
(re-frame/dispatch [delete-action home-item-id]))} (re-frame/dispatch [delete-action home-item-id]))}
[home-list-chat-item-inner-view home-item]])) [home-list-chat-item-inner-view home-item]]))
(defn home-list-browser-item-inner-view [{:keys [dapp url name browser-id]}]
(let [photo-path (:photo-path dapp)]
[list-item/list-item
(merge
{:title name
:subtitle (or url (i18n/label :t/dapp))
:on-press #(re-frame/dispatch [:browser.ui/browser-item-selected browser-id])}
(if dapp
(if (and photo-path (not (string/blank? (:photo-path dapp))))
{:image-path photo-path}
{:image [chat-icon/default-browser-icon name]})
{:image [react/view styles/browser-icon-container
[vector-icons/icon :main-icons/browser {:color colors/gray}]]}))]))

View File

@ -1,17 +0,0 @@
(ns status-im.ui.screens.wallet.actions
(:require [status-im.i18n :as i18n]
[re-frame.core :as re-frame]
[status-im.utils.universal-links.core :as universal-links]
[status-im.ui.components.list-selection :as list-selection]))
(defn share-link [browser-id]
(let [link (universal-links/generate-link :browse :external browser-id)
message (i18n/label :t/share-dapp-text {:link link})]
(list-selection/open-share {:message message})))
(defn share [browser-id]
{:label (i18n/label :t/share-link)
:action #(share-link browser-id)})
(defn actions [browser-id]
[(share browser-id)])

View File

@ -1,11 +1,7 @@
(ns status-im.utils.image (ns status-im.utils.image
(:require [clojure.string :as string] (:require [clojure.string :as string]))
[status-im.react-native.resources :as resources]))
(defn source [photo-path] (defn source [photo-path]
(if (and (not (string/blank? photo-path)) (when-not (and (not (string/blank? photo-path))
(string/starts-with? photo-path "contacts://")) (string/starts-with? photo-path "contacts://"))
(->> (string/replace photo-path #"contacts://" "")
(keyword)
(get resources/contacts))
{:uri photo-path})) {:uri photo-path}))

View File

@ -1,7 +1,7 @@
(ns status-im.test.browser.core (ns status-im.test.browser.core
(:require [cljs.test :refer-macros [deftest is testing]] (:require [cljs.test :refer-macros [deftest is testing]]
[status-im.browser.core :as browser] [status-im.browser.core :as browser]
[status-im.utils.types :as types])) [status-im.utils.http :as http]))
(defn has-navigated-to-browser? [result] (defn has-navigated-to-browser? [result]
(and (= (get result :status-im.ui.screens.navigation/navigate-to) (and (= (get result :status-im.ui.screens.navigation/navigate-to)
@ -20,23 +20,28 @@
nil nil
(keys expected-browser)))) (keys expected-browser))))
(defn get-dapp-id [result dapp-url]
(some #(when (= (http/normalize-and-decode-url dapp-url) (first (:history %))) (:browser-id %))
(vals (get-in result [:db :browser/browsers]))))
(deftest browser-test (deftest browser-test
(let [dapp1-url "cryptokitties.co" (let [dapp1-url "cryptokitties.co"
dapp2-url "http://test2.com"] dapp2-url "http://test2.com"]
(testing "user opens a dapp" (testing "user opens a dapp"
(let [result-open (browser/open-url {:db {} :now 1} dapp1-url)] (let [result-open (browser/open-url {:db {} :now 1} dapp1-url)
(is (= dapp1-url (get-in result-open [:db :browser/options :browser-id])) dapp1-id (get-dapp-id result-open dapp1-url)]
(is (= dapp1-id (get-in result-open [:db :browser/options :browser-id]))
"browser-id should be dapp1-url") "browser-id should be dapp1-url")
(is (has-navigated-to-browser? result-open) (is (has-navigated-to-browser? result-open)
"should navigate to :browser") "should navigate to :browser")
(is (not (has-wrong-properties? result-open (is (not (has-wrong-properties? result-open
dapp1-url dapp1-id
{:browser-id "cryptokitties.co" {:browser-id dapp1-id
:history-index 0 :history-index 0
:history ["http://cryptokitties.co"] :history ["http://cryptokitties.co"]
:dapp? true :dapp? false
:name "CryptoKitties" :name "browser"
:timestamp 1})) :timestamp 1}))
"some properties of the browser are not correct") "some properties of the browser are not correct")
@ -44,14 +49,14 @@
(let [result-open-2 (browser/open-url {:db (:db result-open) (let [result-open-2 (browser/open-url {:db (:db result-open)
:now 2} :now 2}
dapp2-url) dapp2-url)
dapp2-host "test2.com"] dapp2-id (get-dapp-id result-open-2 dapp2-url)]
(is (= dapp2-host (get-in result-open-2 [:db :browser/options :browser-id])) (is (= dapp2-id (get-in result-open-2 [:db :browser/options :browser-id]))
"browser-id should be dapp2 host") "browser-id should be dapp2 host")
(is (has-navigated-to-browser? result-open-2) (is (has-navigated-to-browser? result-open-2)
"should navigate to :browser") "should navigate to :browser")
(is (not (has-wrong-properties? result-open-2 (is (not (has-wrong-properties? result-open-2
dapp2-host dapp2-id
{:browser-id "test2.com" {:browser-id dapp2-id
:history-index 0 :history-index 0
:history ["http://test2.com"] :history ["http://test2.com"]
:dapp? false :dapp? false
@ -59,24 +64,23 @@
"some properties of the browser are not correct") "some properties of the browser are not correct")
(testing "then removes the second dapp" (testing "then removes the second dapp"
(let [result-remove-2 (browser/remove-browser {:db (:db result-open-2)} dapp2-host)] (let [result-remove-2 (browser/remove-browser {:db (:db result-open-2)} dapp2-id)]
(is (= #{dapp1-url} (is (= #{dapp1-id}
(set (keys (get-in result-remove-2 [:db :browser/browsers])))) (set (keys (get-in result-remove-2 [:db :browser/browsers]))))
"the second dapp shouldn't be in the browser list anymore"))))) "the second dapp shouldn't be in the browser list anymore")))))
(testing "then opens the dapp again" (testing "then opens the dapp again"
(let [result-open-existing (browser/open-existing-browser {:db (:db result-open) (let [result-open-existing (browser/open-existing-browser {:db (:db result-open)
:now 2} :now 2}
dapp1-url) dapp1-id)
dapp1-url2 (str "http://" dapp1-url "/nav2") dapp1-url2 (str "http://" dapp1-url "/nav2")]
browser (get-in result-open-existing [:db :browser/browsers dapp1-url])]
(is (not (has-wrong-properties? result-open-existing (is (not (has-wrong-properties? result-open-existing
dapp1-url dapp1-id
{:browser-id "cryptokitties.co" {:browser-id dapp1-id
:history-index 0 :history-index 0
:history ["http://cryptokitties.co"] :history ["http://cryptokitties.co"]
:dapp? true :dapp? false
:name "CryptoKitties" :name "browser"
:timestamp 2})) :timestamp 2}))
"some properties of the browser are not correct") "some properties of the browser are not correct")
(is (nil? (browser/navigate-to-next-page result-open-existing)) (is (nil? (browser/navigate-to-next-page result-open-existing))
@ -92,12 +96,12 @@
"loading" false}) "loading" false})
false)] false)]
(is (not (has-wrong-properties? result-navigate (is (not (has-wrong-properties? result-navigate
dapp1-url dapp1-id
{:browser-id "cryptokitties.co" {:browser-id dapp1-id
:history-index 1 :history-index 1
:history ["http://cryptokitties.co" dapp1-url2] :history ["http://cryptokitties.co" dapp1-url2]
:dapp? true :dapp? false
:name "CryptoKitties" :name "browser"
:timestamp 4})) :timestamp 4}))
"some properties of the browser are not correct") "some properties of the browser are not correct")
@ -105,12 +109,12 @@
(let [result-previous (browser/navigate-to-previous-page {:db (:db result-navigate) (let [result-previous (browser/navigate-to-previous-page {:db (:db result-navigate)
:now 5})] :now 5})]
(is (not (has-wrong-properties? result-previous (is (not (has-wrong-properties? result-previous
dapp1-url dapp1-id
{:browser-id "cryptokitties.co" {:browser-id dapp1-id
:history-index 0 :history-index 0
:history ["http://cryptokitties.co" dapp1-url2] :history ["http://cryptokitties.co" dapp1-url2]
:dapp? true :dapp? false
:name "CryptoKitties" :name "browser"
:timestamp 5})) :timestamp 5}))
"some properties of the browser are not correct") "some properties of the browser are not correct")
@ -118,11 +122,11 @@
(let [result-next (browser/navigate-to-next-page {:db (:db result-previous) (let [result-next (browser/navigate-to-next-page {:db (:db result-previous)
:now 6})] :now 6})]
(is (not (has-wrong-properties? result-next (is (not (has-wrong-properties? result-next
dapp1-url dapp1-id
{:browser-id "cryptokitties.co" {:browser-id dapp1-id
:history-index 1 :history-index 1
:history ["http://cryptokitties.co" dapp1-url2] :history ["http://cryptokitties.co" dapp1-url2]
:dapp? true :dapp? false
:name "CryptoKitties" :name "browser"
:timestamp 6})) :timestamp 6}))
"some properties of the browser are not correct")))))))))))) "some properties of the browser are not correct"))))))))))))

View File

@ -2,16 +2,18 @@
(:require [cljs.test :refer-macros [deftest is testing]] (:require [cljs.test :refer-macros [deftest is testing]]
[status-im.browser.permissions :as permissions] [status-im.browser.permissions :as permissions]
[status-im.utils.types :as types] [status-im.utils.types :as types]
[status-im.browser.core :as browser])) [status-im.browser.core :as browser]
[status-im.test.browser.core :as core.tests]))
(deftest permissions-test (deftest permissions-test
(let [dapp-name "test.com" (let [dapp-name "test.com"
dapp-name2 "test2.org" dapp-name2 "test2.org"
cofx {:db (assoc-in (:db (browser/open-url {:db {}} dapp-name)) cofx {:db (assoc-in (:db (browser/open-url {:db {}} dapp-name))
[:account/account :public-key] "public-key")}] [:account/account :public-key] "public-key")}
dapp-id (core.tests/get-dapp-id cofx dapp-name)]
(testing "dapps permissions are initialized" (testing "dapps permissions are initialized"
(is (zero? (count (get-in cofx [:db :dapps/permissions])))) (is (zero? (count (get-in cofx [:db :dapps/permissions]))))
(is (= dapp-name (get-in cofx [:db :browser/options :browser-id])))) (is (= dapp-id (get-in cofx [:db :browser/options :browser-id]))))
(testing "receiving an unsupported permission" (testing "receiving an unsupported permission"
(let [result-ask (browser/process-bridge-message cofx (let [result-ask (browser/process-bridge-message cofx

View File

@ -1,13 +1,8 @@
(ns status-im.test.chat.views.photos (ns status-im.test.chat.views.photos
(:require [cljs.test :refer [deftest testing is]] (:require [cljs.test :refer [deftest testing is]]
[status-im.react-native.resources :as resources]
[status-im.utils.image :as utils.image])) [status-im.utils.image :as utils.image]))
(deftest photos-test (deftest photos-test
(testing "a normal string" (testing "a normal string"
(let [actual (utils.image/source "some-string")] (let [actual (utils.image/source "some-string")]
(is (= {:uri "some-string"} actual)))) (is (= {:uri "some-string"} actual)))))
(testing "a contact string"
(with-redefs [resources/contacts {:test "something"}]
(let [actual (utils.image/source "contacts://test")]
(is (= "something" actual))))))

View File

@ -5,7 +5,6 @@
(:require [cljs.test :refer-macros [deftest is are testing]] (:require [cljs.test :refer-macros [deftest is are testing]]
[status-im.accounts.login.core :as login.core] [status-im.accounts.login.core :as login.core]
[status-im.events :as events] [status-im.events :as events]
[status-im.ui.screens.browser.default-dapps :as default-dapps]
[status-im.test.sign-in.data :as data] [status-im.test.sign-in.data :as data]
[status-im.signals.core :as signals])) [status-im.signals.core :as signals]))
@ -41,7 +40,6 @@
:all-installations [] :all-installations []
:all-stored-browsers [] :all-stored-browsers []
:all-dapp-permissions [] :all-dapp-permissions []
:default-dapps default-dapps/all
:get-all-stored-chats data/get-chats} :get-all-stored-chats data/get-chats}
efx (events/account-change-success cofx [nil "address"]) efx (events/account-change-success cofx [nil "address"])
new-db (:db efx)] new-db (:db efx)]

View File

@ -998,5 +998,7 @@
"invalid-format": "Invalid format\nMust be {{format}}", "invalid-format": "Invalid format\nMust be {{format}}",
"mailserver-format": "enode://{enode-id}:{password}@{ip-address}:{port}", "mailserver-format": "enode://{enode-id}:{password}@{ip-address}:{port}",
"bootnode-format": "enode://{enode-id}@{ip-address}:{port}", "bootnode-format": "enode://{enode-id}@{ip-address}:{port}",
"fetch-messages": "↓ Fetch messages" "fetch-messages": "↓ Fetch messages",
"open-dapp-store": "Discover ÐApps",
"browsed-websites": "Browsed websites will appear here."
} }