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
|
||||
DEBUG_WEBVIEW=1
|
||||
GROUP_CHATS_ENABLED=0
|
||||
EXTENSIONS=0
|
||||
EXTENSIONS=1
|
||||
PFS_ENCRYPTION_ENABLED=0
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
2
deps.edn
2
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"}}
|
||||
|
||||
|
|
|
@ -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"]
|
||||
|
|
|
@ -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,16 +129,16 @@
|
|||
|
||||
(def command-hook
|
||||
"Hook for extensions"
|
||||
(reify host/AppHook
|
||||
(id [_] :commands)
|
||||
(properties [_] {:scope #{:personal-chats :public-chats}
|
||||
:description :string
|
||||
{:properties
|
||||
{:scope #{:personal-chats :public-chats}
|
||||
:short-preview :view
|
||||
:preview :view
|
||||
:parameters [{:id :keyword
|
||||
:type {:one-of #{:text :phone :password :number}}
|
||||
:placeholder :string
|
||||
:suggestions? :component}]})
|
||||
: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))
|
||||
|
@ -150,9 +150,9 @@
|
|||
(on-receive [_ _ _])
|
||||
(short-preview [_ props] (short-preview props))
|
||||
(preview [_ props] (preview props)))]
|
||||
(load-commands [new-command] cofx)))
|
||||
(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))))
|
||||
(remove-command (get-in db [:id->command [(name id) scope] :type]) cofx)))})
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:load-commands
|
||||
|
|
|
@ -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)])))
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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)))
|
||||
|
|
|
@ -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.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
|
||||
|
|
|
@ -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 %)))))
|
||||
|
|
|
@ -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})
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -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 [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]
|
||||
|
|
Loading…
Reference in New Issue