diff --git a/.env.e2e b/.env.e2e index d715dc3dbd..ae69314cd2 100644 --- a/.env.e2e +++ b/.env.e2e @@ -10,5 +10,5 @@ DEFAULT_NETWORK=testnet_rpc INSTABUG_TOKEN=758630ed52864cbad9c5eeeac596c60c DEBUG_WEBVIEW=1 GROUP_CHATS_ENABLED=0 -EXTENSIONS=0 +EXTENSIONS=1 PFS_ENCRYPTION_ENABLED=0 diff --git a/.env.jenkins b/.env.jenkins index e06c56f205..a1c45a67cb 100644 --- a/.env.jenkins +++ b/.env.jenkins @@ -14,5 +14,5 @@ DEBUG_WEBVIEW=1 GROUP_CHATS_ENABLED=1 MAINNET_WARNING_ENABLED=1 CACHED_WEBVIEWS_ENABLED=1 -EXTENSIONS=0 +EXTENSIONS=1 PFS_ENCRYPTION_ENABLED=0 diff --git a/.env.nightly.staging.fleet b/.env.nightly.staging.fleet index a05928377c..64118e3835 100644 --- a/.env.nightly.staging.fleet +++ b/.env.nightly.staging.fleet @@ -13,5 +13,5 @@ DEBUG_WEBVIEW=1 INSTABUG_SURVEYS=1 GROUP_CHATS_ENABLED=0 MAINNET_WARNING_ENABLED=1 -EXTENSIONS=0 +EXTENSIONS=1 PFS_ENCRYPTION_ENABLED=0 diff --git a/.env.prod b/.env.prod index 82fbd76bcc..adafe3ec3b 100644 --- a/.env.prod +++ b/.env.prod @@ -14,5 +14,5 @@ INSTABUG_TOKEN=758630ed52864cbad9c5eeeac596c60c DEBUG_WEBVIEW=0 GROUP_CHATS_ENABLED=0 MAINNET_WARNING_ENABLED=1 -EXTENSIONS=0 +EXTENSIONS=1 PFS_ENCRYPTION_ENABLED=0 diff --git a/deps.edn b/deps.edn index 59b36ccf9e..48d58868ff 100644 --- a/deps.edn +++ b/deps.edn @@ -11,7 +11,7 @@ com.taoensso/timbre {:mvn/version "4.10.0"} hickory {:mvn/version "0.7.1"} com.cognitect/transit-cljs {:mvn/version "0.8.248"} - status-im/pluto {:mvn/version "iteration-2-SNAPSHOT"} + status-im/pluto {:mvn/version "iteration-3-SNAPSHOT"} mvxcvi/alphabase {:mvn/version "1.0.0"} rasom/cljs-react-navigation {:mvn/version "0.1.4"}} diff --git a/project.clj b/project.clj index 471be4ccac..6b94db854c 100644 --- a/project.clj +++ b/project.clj @@ -11,7 +11,7 @@ [com.taoensso/timbre "4.10.0"] [hickory "0.7.1"] [com.cognitect/transit-cljs "0.8.248"] - [status-im/pluto "iteration-2-SNAPSHOT"] + [status-im/pluto "iteration-3-SNAPSHOT"] [mvxcvi/alphabase "1.0.0"] [rasom/cljs-react-navigation "0.1.4"]] :plugins [[lein-cljsbuild "1.1.7"] diff --git a/src/status_im/chat/commands/core.cljs b/src/status_im/chat/commands/core.cljs index 92b8dbc665..4a476e490e 100644 --- a/src/status_im/chat/commands/core.cljs +++ b/src/status_im/chat/commands/core.cljs @@ -1,7 +1,7 @@ (ns status-im.chat.commands.core (:require [re-frame.core :as re-frame] [clojure.set :as set] - [pluto.host :as host] + [pluto.reader.hooks :as hooks] [status-im.constants :as constants] [status-im.chat.constants :as chat-constants] [status-im.chat.commands.protocol :as protocol] @@ -129,30 +129,30 @@ (def command-hook "Hook for extensions" - (reify host/AppHook - (id [_] :commands) - (properties [_] {:scope #{:personal-chats :public-chats} - :description :string - :short-preview :view - :preview :view - :parameters [{:id :keyword - :type {:one-of #{:text :phone :password :number}} - :placeholder :string - :suggestions? :component}]}) - (hook-in [_ id {:keys [description scope parameters preview short-preview]} cofx] - (let [new-command (reify protocol/Command - (id [_] (name id)) - (scope [_] scope) - (description [_] description) - (parameters [_] parameters) - (validate [_ _ _]) - (on-send [_ _ _]) - (on-receive [_ _ _]) - (short-preview [_ props] (short-preview props)) - (preview [_ props] (preview props)))] - (load-commands [new-command] cofx))) - (unhook [_ id {:keys [scope]} {:keys [db] :as cofx}] - (remove-command (get-in db [:id->command [(name id) scope] :type]) cofx)))) + {:properties + {:scope #{:personal-chats :public-chats} + :short-preview :view + :preview :view + :parameters [{:id :keyword + :type {:one-of #{:text :phone :password :number}} + :placeholder :string + :suggestions :view}]} + :hook + (reify hooks/Hook + (hook-in [_ id {:keys [description scope parameters preview short-preview]} cofx] + (let [new-command (reify protocol/Command + (id [_] (name id)) + (scope [_] scope) + (description [_] description) + (parameters [_] parameters) + (validate [_ _ _]) + (on-send [_ _ _]) + (on-receive [_ _ _]) + (short-preview [_ props] (short-preview props)) + (preview [_ props] (preview props)))] + (load-commands cofx [new-command]))) + (unhook [_ id {:keys [scope]} {:keys [db] :as cofx}] + (remove-command (get-in db [:id->command [(name id) scope] :type]) cofx)))}) (handlers/register-handler-fx :load-commands diff --git a/src/status_im/chat/commands/impl/transactions/subs.cljs b/src/status_im/chat/commands/impl/transactions/subs.cljs index 4b894f5b6f..25b9a06b97 100644 --- a/src/status_im/chat/commands/impl/transactions/subs.cljs +++ b/src/status_im/chat/commands/impl/transactions/subs.cljs @@ -4,5 +4,5 @@ (re-frame/reg-sub :get-collectible-token :<- [:collectibles] - (fn [collectibles [_ nft-symbol token-id]] - (get-in collectibles [(keyword nft-symbol) (js/parseInt token-id)]))) + (fn [collectibles [_ {:keys [symbol token]}]] + (get-in collectibles [(keyword symbol) (js/parseInt token)]))) diff --git a/src/status_im/chat/commands/protocol.cljs b/src/status_im/chat/commands/protocol.cljs index 6f3ff88feb..83ef65bae3 100644 --- a/src/status_im/chat/commands/protocol.cljs +++ b/src/status_im/chat/commands/protocol.cljs @@ -21,7 +21,7 @@ "Ordered sequence of command parameter templates, where each parameter is defined as map consisting of mandatory `:id`, `:title` and `:type` keys, and optional `:suggestions` field. - When used, `:suggestions` containes reference to any generic helper component + When used, `:suggestions` contains reference to any generic helper component rendering suggestions for the argument (input code will handle when and where to render it)") (validate [this parameters cofx] diff --git a/src/status_im/extensions/core.cljs b/src/status_im/extensions/core.cljs index b068d150b0..b1b64d4601 100644 --- a/src/status_im/extensions/core.cljs +++ b/src/status_im/extensions/core.cljs @@ -1,7 +1,45 @@ (ns status-im.extensions.core - (:require [clojure.string :as string])) + (:require [clojure.string :as string] + [pluto.reader :as reader] + [pluto.registry :as registry] + [pluto.storages :as storages] + [status-im.chat.commands.core :as commands] + [status-im.chat.commands.impl.transactions :as transactions] + [status-im.ui.components.react :as react])) -(defn url->storage-details [s] +(def components + {'view {:value react/view} + 'text {:value react/text} + 'nft-token {:value transactions/nft-token} + 'send-status {:value transactions/send-status} + 'asset-selector {:value transactions/choose-nft-asset-suggestion} + 'token-selector {:value transactions/choose-nft-token-suggestion}}) + +(def app-hooks #{commands/command-hook}) + +(def capacities + (reduce (fn [capacities hook] + (assoc-in capacities [:hooks :commands] hook)) + {:components components + :queries {'get-collectible-token {:value :get-collectible-token}} + :events {}} + app-hooks)) + +(defn read-extension [o] + (-> o :value first :content reader/read)) + +(defn parse [{:keys [data] :as m}] + (try + (let [{:keys [errors] :as extension-data} (reader/parse {:capacities capacities} data)] + (when errors + (println "Failed to parse status extensions" errors)) + extension-data) + (catch :default e (println "EXC" e)))) + +(defn url->uri [s] (when s - (let [[_ type id] (string/split s #".*[:/]([a-z]*)@(.*)")] - [(keyword type) id]))) + (string/replace s "https://get.status.im/extension/" ""))) + +(defn load-from [url f] + (when-let [uri (url->uri url)] + (storages/fetch uri f))) diff --git a/src/status_im/extensions/registry.cljs b/src/status_im/extensions/registry.cljs deleted file mode 100644 index cbf57ae666..0000000000 --- a/src/status_im/extensions/registry.cljs +++ /dev/null @@ -1,52 +0,0 @@ -(ns status-im.extensions.registry - (:require [pluto.reader :as reader] - [pluto.registry :as registry] - [pluto.host :as host] - [pluto.storage :as storage] - [pluto.storage.gist :as gist] - [status-im.extensions.core :as extension] - [status-im.chat.commands.core :as commands] - [status-im.chat.commands.impl.transactions :as transactions] - [status-im.ui.components.react :as react])) - -(def components - {'view react/view - 'text react/text - 'nft-token transactions/nft-token - 'send-status transactions/send-status - 'asset-selector transactions/choose-nft-asset-suggestion - 'token-selector transactions/choose-nft-token-suggestion}) - -(def app-hooks #{commands/command-hook}) - -(def capacities - (reduce (fn [capacities hook] - (assoc-in capacities [:hooks (host/id hook)] hook)) - {:components components - :queries #{:get-in :get-collectible-token} - :events #{:set-in} - :permissions {:read {:include-paths #{[:chats #".*"]}} - :write {:include-paths #{}}}} - app-hooks)) - -(defn parse [{:keys [data]}] - (try - (let [{:keys [errors] :as extension-data} (reader/parse {:capacities capacities} data)] - (when errors - (println "Failed to parse status extensions" errors)) - extension-data) - (catch :default e (println "EXC" e)))) - -(def storages - {:gist (gist/GistStorage.)}) - -(defn read-extension [o] - (-> o :value first :content reader/read)) - -(defn load-from [url f] - (let [[type id] (extension/url->storage-details url) - storage (get storages type)] - (when (and storage id) - (storage/fetch storage - {:value id} - #(f %))))) diff --git a/src/status_im/ui/screens/events.cljs b/src/status_im/ui/screens/events.cljs index 0419e88b44..41d5265860 100644 --- a/src/status_im/ui/screens/events.cljs +++ b/src/status_im/ui/screens/events.cljs @@ -9,7 +9,7 @@ status-im.web3.events status-im.ui.screens.add-new.new-chat.navigation status-im.ui.screens.profile.events - status-im.ui.screens.extensions.events + status-im.ui.screens.extensions.add.events status-im.ui.screens.wallet.events status-im.ui.screens.wallet.collectibles.events status-im.ui.screens.wallet.send.events diff --git a/src/status_im/ui/screens/extensions/add/events.cljs b/src/status_im/ui/screens/extensions/add/events.cljs index 4f9d4ebf5c..7e46c26c2e 100644 --- a/src/status_im/ui/screens/extensions/add/events.cljs +++ b/src/status_im/ui/screens/extensions/add/events.cljs @@ -1,7 +1,7 @@ (ns status-im.ui.screens.extensions.add.events (:require [re-frame.core :as re-frame] [pluto.registry :as registry] - [status-im.extensions.registry :as extensions] + [status-im.extensions.core :as extensions] [status-im.ui.screens.navigation :as navigation] [status-im.i18n :as i18n] [status-im.utils.handlers :as handlers] @@ -19,7 +19,7 @@ (fx/merge cofx {:ui/show-confirmation {:title (i18n/label :t/success) :content (i18n/label :t/extension-installed) - :on-accept #(re-frame/dispatch [:navigate-to-clean :home]) + :on-accept #(re-frame/dispatch [:navigate-to-clean :my-profile]) :on-cancel nil}} #(registry/add extension-data %) #(registry/activate extension-key %))))) diff --git a/src/status_im/ui/screens/extensions/add/styles.cljs b/src/status_im/ui/screens/extensions/add/styles.cljs index 5f724bee7c..60853dd273 100644 --- a/src/status_im/ui/screens/extensions/add/styles.cljs +++ b/src/status_im/ui/screens/extensions/add/styles.cljs @@ -3,6 +3,10 @@ (:require [status-im.ui.components.styles :as styles] [status-im.ui.components.colors :as colors])) +(def screen + {:flex 1 + :background-color colors/white}) + (def wrapper {:flex 1 :margin 16}) diff --git a/src/status_im/ui/screens/extensions/add/views.cljs b/src/status_im/ui/screens/extensions/add/views.cljs index e23021253e..91d696bacb 100644 --- a/src/status_im/ui/screens/extensions/add/views.cljs +++ b/src/status_im/ui/screens/extensions/add/views.cljs @@ -29,7 +29,7 @@ (views/defview show-extension [] (views/letsubs [{:keys [data errors]} [:get-staged-extension]] - [react/view components.styles/flex + [react/view styles/screen [status-bar/status-bar] [react/keyboard-avoiding-view components.styles/flex [toolbar/simple-toolbar (i18n/label :t/extension)] @@ -52,12 +52,12 @@ [components.common/bottom-button {:forward? true :label (i18n/label :t/install) - :disabled? (seq errors) + :disabled? (not (empty? errors)) :on-press #(re-frame/dispatch [:extension/install data])}]]]])) (views/defview add-extension [] (views/letsubs [extension-url [:get-extension-url]] - [react/view components.styles/flex + [react/view styles/screen [status-bar/status-bar] [react/keyboard-avoiding-view components.styles/flex [toolbar/simple-toolbar (i18n/label :t/extension-find)] diff --git a/src/status_im/ui/screens/extensions/events.cljs b/src/status_im/ui/screens/extensions/events.cljs deleted file mode 100644 index 0eba85c5fe..0000000000 --- a/src/status_im/ui/screens/extensions/events.cljs +++ /dev/null @@ -1,10 +0,0 @@ -(ns status-im.ui.screens.extensions.events - (:require [re-frame.core :as re-frame] - [pluto.registry :as registry] - [status-im.utils.handlers :as handlers] - status-im.ui.screens.extensions.add.events)) - -(handlers/register-handler-fx - :extensions/toggle-activation - (fn [{:keys [db]} [_ id m]] - nil)) diff --git a/src/status_im/ui/screens/extensions/views.cljs b/src/status_im/ui/screens/extensions/views.cljs index d25b72b04f..9aca99047d 100644 --- a/src/status_im/ui/screens/extensions/views.cljs +++ b/src/status_im/ui/screens/extensions/views.cljs @@ -2,7 +2,6 @@ (:require-macros [status-im.utils.views :as views]) (:require [re-frame.core :as re-frame] [status-im.i18n :as i18n] - [status-im.extensions.registry :as registry] [status-im.ui.components.icons.vector-icons :as vector-icons] [status-im.ui.components.list.views :as list] [status-im.ui.components.react :as react]