Moved to newer pluto
Signed-off-by: Julien Eluard <julien.eluard@gmail.com>
This commit is contained in:
parent
02cb5dc8d4
commit
00ed5bc883
2
.env.e2e
2
.env.e2e
|
@ -10,5 +10,5 @@ DEFAULT_NETWORK=testnet_rpc
|
||||||
INSTABUG_TOKEN=758630ed52864cbad9c5eeeac596c60c
|
INSTABUG_TOKEN=758630ed52864cbad9c5eeeac596c60c
|
||||||
DEBUG_WEBVIEW=1
|
DEBUG_WEBVIEW=1
|
||||||
GROUP_CHATS_ENABLED=0
|
GROUP_CHATS_ENABLED=0
|
||||||
EXTENSIONS=0
|
EXTENSIONS=1
|
||||||
PFS_ENCRYPTION_ENABLED=0
|
PFS_ENCRYPTION_ENABLED=0
|
||||||
|
|
|
@ -14,5 +14,5 @@ DEBUG_WEBVIEW=1
|
||||||
GROUP_CHATS_ENABLED=1
|
GROUP_CHATS_ENABLED=1
|
||||||
MAINNET_WARNING_ENABLED=1
|
MAINNET_WARNING_ENABLED=1
|
||||||
CACHED_WEBVIEWS_ENABLED=1
|
CACHED_WEBVIEWS_ENABLED=1
|
||||||
EXTENSIONS=0
|
EXTENSIONS=1
|
||||||
PFS_ENCRYPTION_ENABLED=0
|
PFS_ENCRYPTION_ENABLED=0
|
||||||
|
|
|
@ -13,5 +13,5 @@ DEBUG_WEBVIEW=1
|
||||||
INSTABUG_SURVEYS=1
|
INSTABUG_SURVEYS=1
|
||||||
GROUP_CHATS_ENABLED=0
|
GROUP_CHATS_ENABLED=0
|
||||||
MAINNET_WARNING_ENABLED=1
|
MAINNET_WARNING_ENABLED=1
|
||||||
EXTENSIONS=0
|
EXTENSIONS=1
|
||||||
PFS_ENCRYPTION_ENABLED=0
|
PFS_ENCRYPTION_ENABLED=0
|
||||||
|
|
|
@ -14,5 +14,5 @@ INSTABUG_TOKEN=758630ed52864cbad9c5eeeac596c60c
|
||||||
DEBUG_WEBVIEW=0
|
DEBUG_WEBVIEW=0
|
||||||
GROUP_CHATS_ENABLED=0
|
GROUP_CHATS_ENABLED=0
|
||||||
MAINNET_WARNING_ENABLED=1
|
MAINNET_WARNING_ENABLED=1
|
||||||
EXTENSIONS=0
|
EXTENSIONS=1
|
||||||
PFS_ENCRYPTION_ENABLED=0
|
PFS_ENCRYPTION_ENABLED=0
|
||||||
|
|
2
deps.edn
2
deps.edn
|
@ -11,7 +11,7 @@
|
||||||
com.taoensso/timbre {:mvn/version "4.10.0"}
|
com.taoensso/timbre {:mvn/version "4.10.0"}
|
||||||
hickory {:mvn/version "0.7.1"}
|
hickory {:mvn/version "0.7.1"}
|
||||||
com.cognitect/transit-cljs {:mvn/version "0.8.248"}
|
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"}
|
mvxcvi/alphabase {:mvn/version "1.0.0"}
|
||||||
rasom/cljs-react-navigation {:mvn/version "0.1.4"}}
|
rasom/cljs-react-navigation {:mvn/version "0.1.4"}}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
[com.taoensso/timbre "4.10.0"]
|
[com.taoensso/timbre "4.10.0"]
|
||||||
[hickory "0.7.1"]
|
[hickory "0.7.1"]
|
||||||
[com.cognitect/transit-cljs "0.8.248"]
|
[com.cognitect/transit-cljs "0.8.248"]
|
||||||
[status-im/pluto "iteration-2-SNAPSHOT"]
|
[status-im/pluto "iteration-3-SNAPSHOT"]
|
||||||
[mvxcvi/alphabase "1.0.0"]
|
[mvxcvi/alphabase "1.0.0"]
|
||||||
[rasom/cljs-react-navigation "0.1.4"]]
|
[rasom/cljs-react-navigation "0.1.4"]]
|
||||||
:plugins [[lein-cljsbuild "1.1.7"]
|
:plugins [[lein-cljsbuild "1.1.7"]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
(ns status-im.chat.commands.core
|
(ns status-im.chat.commands.core
|
||||||
(:require [re-frame.core :as re-frame]
|
(:require [re-frame.core :as re-frame]
|
||||||
[clojure.set :as set]
|
[clojure.set :as set]
|
||||||
[pluto.host :as host]
|
[pluto.reader.hooks :as hooks]
|
||||||
[status-im.constants :as constants]
|
[status-im.constants :as constants]
|
||||||
[status-im.chat.constants :as chat-constants]
|
[status-im.chat.constants :as chat-constants]
|
||||||
[status-im.chat.commands.protocol :as protocol]
|
[status-im.chat.commands.protocol :as protocol]
|
||||||
|
@ -129,30 +129,30 @@
|
||||||
|
|
||||||
(def command-hook
|
(def command-hook
|
||||||
"Hook for extensions"
|
"Hook for extensions"
|
||||||
(reify host/AppHook
|
{:properties
|
||||||
(id [_] :commands)
|
{:scope #{:personal-chats :public-chats}
|
||||||
(properties [_] {:scope #{:personal-chats :public-chats}
|
:short-preview :view
|
||||||
:description :string
|
:preview :view
|
||||||
:short-preview :view
|
:parameters [{:id :keyword
|
||||||
:preview :view
|
:type {:one-of #{:text :phone :password :number}}
|
||||||
:parameters [{:id :keyword
|
:placeholder :string
|
||||||
:type {:one-of #{:text :phone :password :number}}
|
:suggestions :view}]}
|
||||||
:placeholder :string
|
:hook
|
||||||
:suggestions? :component}]})
|
(reify hooks/Hook
|
||||||
(hook-in [_ id {:keys [description scope parameters preview short-preview]} cofx]
|
(hook-in [_ id {:keys [description scope parameters preview short-preview]} cofx]
|
||||||
(let [new-command (reify protocol/Command
|
(let [new-command (reify protocol/Command
|
||||||
(id [_] (name id))
|
(id [_] (name id))
|
||||||
(scope [_] scope)
|
(scope [_] scope)
|
||||||
(description [_] description)
|
(description [_] description)
|
||||||
(parameters [_] parameters)
|
(parameters [_] parameters)
|
||||||
(validate [_ _ _])
|
(validate [_ _ _])
|
||||||
(on-send [_ _ _])
|
(on-send [_ _ _])
|
||||||
(on-receive [_ _ _])
|
(on-receive [_ _ _])
|
||||||
(short-preview [_ props] (short-preview props))
|
(short-preview [_ props] (short-preview props))
|
||||||
(preview [_ props] (preview props)))]
|
(preview [_ props] (preview props)))]
|
||||||
(load-commands [new-command] cofx)))
|
(load-commands cofx [new-command])))
|
||||||
(unhook [_ id {:keys [scope]} {:keys [db] :as cofx}]
|
(unhook [_ id {:keys [scope]} {:keys [db] :as cofx}]
|
||||||
(remove-command (get-in db [:id->command [(name id) scope] :type]) cofx))))
|
(remove-command (get-in db [:id->command [(name id) scope] :type]) cofx)))})
|
||||||
|
|
||||||
(handlers/register-handler-fx
|
(handlers/register-handler-fx
|
||||||
:load-commands
|
:load-commands
|
||||||
|
|
|
@ -4,5 +4,5 @@
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
:get-collectible-token
|
:get-collectible-token
|
||||||
:<- [:collectibles]
|
:<- [:collectibles]
|
||||||
(fn [collectibles [_ nft-symbol token-id]]
|
(fn [collectibles [_ {:keys [symbol token]}]]
|
||||||
(get-in collectibles [(keyword nft-symbol) (js/parseInt token-id)])))
|
(get-in collectibles [(keyword symbol) (js/parseInt token)])))
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
"Ordered sequence of command parameter templates, where each parameter
|
"Ordered sequence of command parameter templates, where each parameter
|
||||||
is defined as map consisting of mandatory `:id`, `:title` and `:type` keys,
|
is defined as map consisting of mandatory `:id`, `:title` and `:type` keys,
|
||||||
and optional `:suggestions` field.
|
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
|
rendering suggestions for the argument (input code will handle when and where
|
||||||
to render it)")
|
to render it)")
|
||||||
(validate [this parameters cofx]
|
(validate [this parameters cofx]
|
||||||
|
|
|
@ -1,7 +1,45 @@
|
||||||
(ns status-im.extensions.core
|
(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
|
(when s
|
||||||
(let [[_ type id] (string/split s #".*[:/]([a-z]*)@(.*)")]
|
(string/replace s "https://get.status.im/extension/" "")))
|
||||||
[(keyword type) id])))
|
|
||||||
|
(defn load-from [url f]
|
||||||
|
(when-let [uri (url->uri url)]
|
||||||
|
(storages/fetch uri f)))
|
||||||
|
|
|
@ -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 %)))))
|
|
|
@ -9,7 +9,7 @@
|
||||||
status-im.web3.events
|
status-im.web3.events
|
||||||
status-im.ui.screens.add-new.new-chat.navigation
|
status-im.ui.screens.add-new.new-chat.navigation
|
||||||
status-im.ui.screens.profile.events
|
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.events
|
||||||
status-im.ui.screens.wallet.collectibles.events
|
status-im.ui.screens.wallet.collectibles.events
|
||||||
status-im.ui.screens.wallet.send.events
|
status-im.ui.screens.wallet.send.events
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
(ns status-im.ui.screens.extensions.add.events
|
(ns status-im.ui.screens.extensions.add.events
|
||||||
(:require [re-frame.core :as re-frame]
|
(:require [re-frame.core :as re-frame]
|
||||||
[pluto.registry :as registry]
|
[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.ui.screens.navigation :as navigation]
|
||||||
[status-im.i18n :as i18n]
|
[status-im.i18n :as i18n]
|
||||||
[status-im.utils.handlers :as handlers]
|
[status-im.utils.handlers :as handlers]
|
||||||
|
@ -19,7 +19,7 @@
|
||||||
(fx/merge cofx
|
(fx/merge cofx
|
||||||
{:ui/show-confirmation {:title (i18n/label :t/success)
|
{:ui/show-confirmation {:title (i18n/label :t/success)
|
||||||
:content (i18n/label :t/extension-installed)
|
: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}}
|
:on-cancel nil}}
|
||||||
#(registry/add extension-data %)
|
#(registry/add extension-data %)
|
||||||
#(registry/activate extension-key %)))))
|
#(registry/activate extension-key %)))))
|
||||||
|
|
|
@ -3,6 +3,10 @@
|
||||||
(:require [status-im.ui.components.styles :as styles]
|
(:require [status-im.ui.components.styles :as styles]
|
||||||
[status-im.ui.components.colors :as colors]))
|
[status-im.ui.components.colors :as colors]))
|
||||||
|
|
||||||
|
(def screen
|
||||||
|
{:flex 1
|
||||||
|
:background-color colors/white})
|
||||||
|
|
||||||
(def wrapper
|
(def wrapper
|
||||||
{:flex 1
|
{:flex 1
|
||||||
:margin 16})
|
:margin 16})
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
(views/defview show-extension []
|
(views/defview show-extension []
|
||||||
(views/letsubs [{:keys [data errors]} [:get-staged-extension]]
|
(views/letsubs [{:keys [data errors]} [:get-staged-extension]]
|
||||||
[react/view components.styles/flex
|
[react/view styles/screen
|
||||||
[status-bar/status-bar]
|
[status-bar/status-bar]
|
||||||
[react/keyboard-avoiding-view components.styles/flex
|
[react/keyboard-avoiding-view components.styles/flex
|
||||||
[toolbar/simple-toolbar (i18n/label :t/extension)]
|
[toolbar/simple-toolbar (i18n/label :t/extension)]
|
||||||
|
@ -52,12 +52,12 @@
|
||||||
[components.common/bottom-button
|
[components.common/bottom-button
|
||||||
{:forward? true
|
{:forward? true
|
||||||
:label (i18n/label :t/install)
|
:label (i18n/label :t/install)
|
||||||
:disabled? (seq errors)
|
:disabled? (not (empty? errors))
|
||||||
:on-press #(re-frame/dispatch [:extension/install data])}]]]]))
|
:on-press #(re-frame/dispatch [:extension/install data])}]]]]))
|
||||||
|
|
||||||
(views/defview add-extension []
|
(views/defview add-extension []
|
||||||
(views/letsubs [extension-url [:get-extension-url]]
|
(views/letsubs [extension-url [:get-extension-url]]
|
||||||
[react/view components.styles/flex
|
[react/view styles/screen
|
||||||
[status-bar/status-bar]
|
[status-bar/status-bar]
|
||||||
[react/keyboard-avoiding-view components.styles/flex
|
[react/keyboard-avoiding-view components.styles/flex
|
||||||
[toolbar/simple-toolbar (i18n/label :t/extension-find)]
|
[toolbar/simple-toolbar (i18n/label :t/extension-find)]
|
||||||
|
|
|
@ -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))
|
|
|
@ -2,7 +2,6 @@
|
||||||
(:require-macros [status-im.utils.views :as views])
|
(:require-macros [status-im.utils.views :as views])
|
||||||
(:require [re-frame.core :as re-frame]
|
(:require [re-frame.core :as re-frame]
|
||||||
[status-im.i18n :as i18n]
|
[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.icons.vector-icons :as vector-icons]
|
||||||
[status-im.ui.components.list.views :as list]
|
[status-im.ui.components.list.views :as list]
|
||||||
[status-im.ui.components.react :as react]
|
[status-im.ui.components.react :as react]
|
||||||
|
|
Loading…
Reference in New Issue