Migrated to latest pluto release

Signed-off-by: Andrey Shovkoplyas <motor4ik@gmail.com>
This commit is contained in:
Julien Eluard 2019-02-04 14:12:46 +01:00 committed by Andrey Shovkoplyas
parent 3efeb71a16
commit 38570aa42f
No known key found for this signature in database
GPG Key ID: EAAB7C8622D860A4
10 changed files with 227 additions and 218 deletions

View File

@ -1,6 +1,6 @@
{:paths ["components/src" "src" "react-native/src/cljsjs" "resources"] {:paths ["components/src" "src" "react-native/src/cljsjs" "resources"]
:deps {org.clojure/clojure {:mvn/version "1.9.0"} ;; Keep in sync with .TOOLVERSIONS :deps {org.clojure/clojure {:mvn/version "1.9.0"} ;; Keep in sync with .TOOLVERSIONS
org.clojure/clojurescript {:mvn/version "1.10.439"} org.clojure/clojurescript {:mvn/version "1.10.238"}
org.clojure/core.async {:mvn/version "0.4.474"} org.clojure/core.async {:mvn/version "0.4.474"}
reagent {:mvn/version "0.7.0" reagent {:mvn/version "0.7.0"
:exclusions [cljsjs/react cljsjs/react-dom cljsjs/react-dom-server cljsjs/create-react-class]} :exclusions [cljsjs/react cljsjs/react-dom cljsjs/react-dom-server cljsjs/create-react-class]}
@ -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-4-7"} status-im/pluto {:mvn/version "iteration-4-8"}
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"}}

View File

@ -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-4-7"] [status-im/pluto "iteration-4-8"]
[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"]

View File

@ -1,8 +1,5 @@
(ns status-im.chat.commands.core (ns status-im.chat.commands.core
(:require [re-frame.core :as re-frame] (:require [clojure.set :as set]
[clojure.set :as set]
[pluto.reader.hooks :as hooks]
[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]
[status-im.chat.commands.impl.transactions :as transactions] [status-im.chat.commands.impl.transactions :as transactions]
@ -129,55 +126,6 @@
{} {}
access-scope->command-id))))})) access-scope->command-id))))}))
(def command-hook
"Hook for extensions"
{:properties
{:description? :string
:scope #{:personal-chats :public-chats :group-chats}
:short-preview? :view
:preview? :view
:on-send? :event
:on-receive? :event
:on-send-sync? :event
:parameters? [{:id :keyword
:type {:one-of #{:text :phone :password :number}}
:placeholder :string
:suggestions? :view}]}
:hook
(reify hooks/Hook
(hook-in [_ id {extension-id :id} {:keys [description scope parameters preview short-preview
on-send on-receive on-send-sync]} cofx]
(let [new-command (if on-send-sync
(reify protocol/Command
(id [_] (name id))
(scope [_] scope)
(description [_] description)
(parameters [_] (or parameters []))
(validate [_ _ _])
(on-send [_ command-message _] (when on-send {:dispatch (on-send command-message)}))
(on-receive [_ command-message _] (when on-receive {:dispatch (on-receive command-message)}))
(short-preview [_ props] (when short-preview (short-preview props)))
(preview [_ props] (when preview (preview props)))
protocol/Yielding
(yield-control [_ props _] {:dispatch (on-send-sync props)})
protocol/Extension
(extension-id [_] extension-id))
(reify protocol/Command
(id [_] (name id))
(scope [_] scope)
(description [_] description)
(parameters [_] (or parameters []))
(validate [_ _ _])
(on-send [_ command-message _] (when on-send {:dispatch (on-send command-message)}))
(on-receive [_ command-message _] (when on-receive {:dispatch (on-receive command-message)}))
(short-preview [_ props] (when short-preview (short-preview props)))
(preview [_ props] (when preview (preview props)))
protocol/Extension
(extension-id [_] extension-id)))]
(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 (handlers/register-handler-fx
:load-commands :load-commands
(fn [cofx [_ commands]] (fn [cofx [_ commands]]

View File

@ -28,13 +28,13 @@
:extensions/camera-error :extensions/camera-error
(fn [cofx [_ error {:keys [on-failure]}]] (fn [cofx [_ error {:keys [on-failure]}]]
(when on-failure (when on-failure
{:dispatch (on-failure {:result error})}))) (on-failure {:result error}))))
(handlers/register-handler-fx (handlers/register-handler-fx
:extensions/camera-picture-taken :extensions/camera-picture-taken
(fn [cofx [_ data {{:keys [on-success]} :data back? :back?}]] (fn [cofx [_ data {{:keys [on-success]} :data back? :back?}]]
(fx/merge cofx (fx/merge cofx
{:dispatch (on-success {:result data})} (on-success {:result data})
(when back? (when back?
(navigation/navigate-back))))) (navigation/navigate-back)))))
@ -50,7 +50,7 @@
:extensions/camera-qr-code-scanned :extensions/camera-qr-code-scanned
(fn [cofx [_ _ qr-code {{:keys [on-success]} :data}]] (fn [cofx [_ _ qr-code {{:keys [on-success]} :data}]]
(fx/merge cofx (fx/merge cofx
{:dispatch (on-success {:result qr-code})} (on-success {:result qr-code})
(navigation/navigate-back)))) (navigation/navigate-back))))
(handlers/register-handler-fx (handlers/register-handler-fx

View File

@ -1,9 +1,10 @@
(ns status-im.extensions.core (ns status-im.extensions.core
(:refer-clojure :exclude [list]) (:refer-clojure :exclude [list])
(:require [clojure.string :as string] (:require [clojure.string :as string]
[pluto.core :as pluto]
[pluto.storages :as storages] [pluto.storages :as storages]
[pluto.reader :as reader]
[re-frame.core :as re-frame] [re-frame.core :as re-frame]
[re-frame.registrar :as registrar]
[status-im.chat.commands.core :as commands] [status-im.chat.commands.core :as commands]
[status-im.chat.commands.impl.transactions :as transactions] [status-im.chat.commands.impl.transactions :as transactions]
[status-im.ui.components.button.view :as button] [status-im.ui.components.button.view :as button]
@ -30,7 +31,7 @@
(re-frame/reg-fx (re-frame/reg-fx
::identity-event ::identity-event
(fn [{:keys [cb]}] (re-frame/dispatch (cb {})))) (fn [{:keys [cb]}] (cb {})))
(re-frame/reg-event-fx (re-frame/reg-event-fx
:extensions/identity-event :extensions/identity-event
@ -58,8 +59,8 @@
(re-frame/reg-fx (re-frame/reg-fx
::schedule-start ::schedule-start
(fn [{:keys [interval on-created on-result]}] (fn [{:keys [interval on-created on-result]}]
(let [id (js/setInterval #(re-frame/dispatch (on-result {})) interval)] (let [id (js/setInterval #(on-result {}) interval)]
(re-frame/dispatch (on-created {:value id}))))) (on-created {:value id}))))
(handlers/register-handler-fx (handlers/register-handler-fx
:extensions/schedule-start :extensions/schedule-start
@ -190,7 +191,7 @@
(re-frame/reg-fx (re-frame/reg-fx
::json-parse ::json-parse
(fn [{:keys [value on-result]}] (fn [{:keys [value on-result]}]
(re-frame/dispatch (on-result {:value (parse-json value)})))) (on-result {:value (parse-json value)})))
(handlers/register-handler-fx (handlers/register-handler-fx
:extensions/json-parse :extensions/json-parse
@ -200,7 +201,7 @@
(re-frame/reg-fx (re-frame/reg-fx
::json-stringify ::json-stringify
(fn [value on-result] (fn [value on-result]
(re-frame/dispatch (on-result {:value (js/JSON.stringify (clj->js value))})))) (on-result {:value (js/JSON.stringify (clj->js value))})))
(handlers/register-handler-fx (handlers/register-handler-fx
:extensions/json-stringify :extensions/json-stringify
@ -309,7 +310,7 @@
:selection-modal-screen :selection-modal-screen
(assoc params :on-select #(do (assoc params :on-select #(do
(re-frame/dispatch [:navigate-back]) (re-frame/dispatch [:navigate-back])
(re-frame/dispatch (on-select %))))))) (on-select %))))))
(defn operation->fn [k] (defn operation->fn [k]
(case k (case k
@ -321,7 +322,7 @@
(re-frame/reg-fx (re-frame/reg-fx
::arithmetic ::arithmetic
(fn [{:keys [operation values on-result]}] (fn [{:keys [operation values on-result]}]
(re-frame/dispatch (on-result {:value (apply (operation->fn operation) values)})))) (on-result {:value (apply (operation->fn operation) values)})))
(handlers/register-handler-fx (handlers/register-handler-fx
:extensions/arithmetic :extensions/arithmetic
@ -335,10 +336,10 @@
(defn button [{:keys [on-click enabled disabled] :as m} label] (defn button [{:keys [on-click enabled disabled] :as m} label]
[button/secondary-button (merge {:disabled? (or (when (contains? m :enabled) (or (nil? enabled) (false? enabled))) disabled)} [button/secondary-button (merge {:disabled? (or (when (contains? m :enabled) (or (nil? enabled) (false? enabled))) disabled)}
(when on-click {:on-press #(re-frame/dispatch (on-click {}))})) label]) (when on-click {:on-press #(on-click {})})) label])
(defn on-input-change-text [on-change value] (defn on-input-change-text [on-change value]
(re-frame/dispatch (on-change {:value value}))) (on-change {:value value}))
(defn- on-input-change-text-delay [current on-change value delay] (defn- on-input-change-text-delay [current on-change value delay]
;; If an input change handler has been already scheduled cancel it. ;; If an input change handler has been already scheduled cancel it.
@ -360,7 +361,7 @@
#(on-input-change-text on-change %))}))]) #(on-input-change-text on-change %))}))])
(defn touchable-opacity [{:keys [style on-press]} & children] (defn touchable-opacity [{:keys [style on-press]} & children]
(into [react/touchable-opacity (merge (when on-press {:on-press #(re-frame/dispatch (on-press {}))}) (into [react/touchable-opacity (merge (when on-press {:on-press #(on-press {})})
(when style {:style style}))] children)) (when style {:style style}))] children))
(defn image [{:keys [source uri style]}] (defn image [{:keys [source uri style]}]
@ -396,7 +397,7 @@
[react/view {:style {:background-color colors/white}} [react/view {:style {:background-color colors/white}}
[checkbox/checkbox {:checked? checked [checkbox/checkbox {:checked? checked
:style {:padding 0} :style {:padding 0}
:on-value-change #(re-frame/dispatch (on-change {:value %}))}]]) :on-value-change #(on-change {:value %})}]])
(defn activity-indicator-size [k] (defn activity-indicator-size [k]
(condp = k (condp = k
@ -411,7 +412,7 @@
(when-let [size' (activity-indicator-size size)] {:size size'}))]) (when-let [size' (activity-indicator-size size)] {:size size'}))])
(defn picker [{:keys [style on-change selected enabled data]}] (defn picker [{:keys [style on-change selected enabled data]}]
[react/picker {:style style :on-change #(re-frame/dispatch (on-change {:value %})) :selected selected :enabled enabled :data data}]) [react/picker {:style style :on-change #(on-change {:value %}) :selected selected :enabled enabled :data data}])
(defn- wrap-text-child [o] (defn- wrap-text-child [o]
(if (ifn? o) o (str o))) (if (ifn? o) o (str o)))
@ -442,23 +443,23 @@
[icons/icon key o]) [icons/icon key o])
(def capacities (def capacities
{:components {'view {:value view} {:components {'view {:data view}
'scroll-view {:value scroll-view :properties {:keyboard-should-persist-taps :keyword :content-container-style :map}} 'scroll-view {:data scroll-view :properties {:keyboard-should-persist-taps :keyword :content-container-style :map}}
'keyboard-avoiding-view {:value react/keyboard-avoiding-view} 'keyboard-avoiding-view {:data react/keyboard-avoiding-view}
'text {:value text} 'text {:data text}
'touchable-opacity {:value touchable-opacity :properties {:on-press :event}} 'touchable-opacity {:data touchable-opacity :properties {:on-press :event}}
'icon {:value icon :properties {:key :keyword :color :any}} 'icon {:data icon :properties {:key :keyword :color :any}}
'image {:value image :properties {:uri :string :source :string}} 'image {:data image :properties {:uri :string :source :string}}
'input {:value input :properties {:on-change :event :placeholder :string :keyboard-type :keyword :change-delay? :number :placeholder-text-color :any :selection-color :any}} 'input {:data input :properties {:on-change :event :placeholder :string :keyboard-type :keyword :change-delay? :number :placeholder-text-color :any :selection-color :any}}
'button {:value button :properties {:enabled :boolean :disabled :boolean :on-click :event}} 'button {:data button :properties {:enabled :boolean :disabled :boolean :on-click :event}}
'link {:value link :properties {:uri :string :text? :string :open-in? {:one-of #{:device :status}}}} 'link {:data link :properties {:uri :string :text? :string :open-in? {:one-of #{:device :status}}}}
'list {:value list :properties {:data :vector :item-view :view :key? :keyword}} 'list {:data list :properties {:data :vector :item-view :view :key? :keyword}}
'checkbox {:value checkbox :properties {:on-change :event :checked :boolean}} 'checkbox {:data checkbox :properties {:on-change :event :checked :boolean}}
'activity-indicator {:value activity-indicator :properties {:animating :boolean :color :string :size :keyword :hides-when-stopped :boolean}} 'activity-indicator {:data activity-indicator :properties {:animating :boolean :color :string :size :keyword :hides-when-stopped :boolean}}
'picker {:value picker :properties {:on-change :event :selected :string :enabled :boolean :data :vector}} 'picker {:data picker :properties {:on-change :event :selected :string :enabled :boolean :data :vector}}
'nft-token-viewer {:value transactions/nft-token :properties {:token :string}} 'nft-token-viewer {:data transactions/nft-token :properties {:token :string}}
'transaction-status {:value transactions/transaction-status :properties {:outgoing :string :tx-hash :string}} 'transaction-status {:data transactions/transaction-status :properties {:outgoing :string :tx-hash :string}}
'map {:value map/map-webview 'map {:data map/map-webview
:properties {:marker {:lng :number :properties {:marker {:lng :number
:lat :number :lat :number
:boundingbox {:lng1 :number :boundingbox {:lng1 :number
@ -468,45 +469,45 @@
:fly? :boolean :fly? :boolean
:interactive? :boolean :interactive? :boolean
:on-change :event}} :on-change :event}}
'map-link {:value map-link :properties {:text :string :lng :any :lat :any}}} 'map-link {:data map-link :properties {:text :string :lng :any :lat :any}}}
:queries {'identity {:value :extensions/identity :arguments {:value :map}} :queries {'identity {:data :extensions/identity :arguments {:value :map}}
'store/get {:value :store/get :arguments {:key :string}} 'store/get {:data :store/get :arguments {:key :string}}
'contacts/all {:value :extensions.contacts/all} ;; :photo :name :address :public-key 'contacts/all {:data :extensions.contacts/all} ;; :photo :name :address :public-key
'wallet/collectibles {:value :get-collectible-token :arguments {:token :string :symbol :string}} 'wallet/collectibles {:data :get-collectible-token :arguments {:token :string :symbol :string}}
'wallet/balance {:value :extensions.wallet/balance :arguments {:token :string}} 'wallet/balance {:data :extensions.wallet/balance :arguments {:token :string}}
'wallet/token {:value :extensions.wallet/token :arguments {:token :string :amount? :number :amount-in-wei? :number}} 'wallet/token {:data :extensions.wallet/token :arguments {:token :string :amount? :number :amount-in-wei? :number}}
'wallet/tokens {:value :extensions.wallet/tokens :arguments {:filter? :vector :visible? :boolean}}} 'wallet/tokens {:data :extensions.wallet/tokens :arguments {:filter? :vector :visible? :boolean}}}
:events {'identity :events {'identity
{:permissions [:read] {:permissions [:read]
:value :extensions/identity-event :data :extensions/identity-event
:arguments {:cb :event}} :arguments {:cb :event}}
'alert 'alert
{:permissions [:read] {:permissions [:read]
:value :alert :data :alert
:arguments {:value :string}} :arguments {:value :string}}
'selection-screen 'selection-screen
{:permissions [:read] {:permissions [:read]
:value :extensions/show-selection-screen :data :extensions/show-selection-screen
:arguments {:items :vector :on-select :event :render :view :title :string :extractor-key :keyword}} :arguments {:items :vector :on-select :event :render :view :title :string :extractor-key :keyword}}
'chat.command/set-parameter 'chat.command/set-parameter
{:permissions [:read] {:permissions [:read]
:value :extensions.chat.command/set-parameter :data :extensions.chat.command/set-parameter
:arguments {:value :any}} :arguments {:value :any}}
'chat.command/set-custom-parameter 'chat.command/set-custom-parameter
{:permissions [:read] {:permissions [:read]
:value :extensions.chat.command/set-custom-parameter :data :extensions.chat.command/set-custom-parameter
:arguments {:key :keyword :value :any}} :arguments {:key :keyword :value :any}}
'chat.command/set-parameter-with-custom-params 'chat.command/set-parameter-with-custom-params
{:permissions [:read] {:permissions [:read]
:value :extensions.chat.command/set-parameter-with-custom-params :data :extensions.chat.command/set-parameter-with-custom-params
:arguments {:value :string :params :map}} :arguments {:value :string :params :map}}
'chat.command/send-plain-text-message 'chat.command/send-plain-text-message
{:permissions [:read] {:permissions [:read]
:value :extensions.chat.command/send-plain-text-message :data :extensions.chat.command/send-plain-text-message
:arguments {:value :string}} :arguments {:value :string}}
'chat.command/send-message 'chat.command/send-message
{:permissions [:read] {:permissions [:read]
:value :extensions.chat.command/send-message :data :extensions.chat.command/send-message
:arguments {:params :map}} :arguments {:params :map}}
'chat.command/open-public-chat 'chat.command/open-public-chat
{:permissions [:read] {:permissions [:read]
@ -514,11 +515,11 @@
:arguments {:topic :string :navigate-to :boolean}} :arguments {:topic :string :navigate-to :boolean}}
'log 'log
{:permissions [:read] {:permissions [:read]
:value :log :data :log
:arguments {:value :string}} :arguments {:value :string}}
'arithmetic 'arithmetic
{:permissions [:read] {:permissions [:read]
:value :extensions/arithmetic :data :extensions/arithmetic
:arguments {:values :vector :arguments {:values :vector
:operation {:one-of #{:plus :minus :times :divide}} :operation {:one-of #{:plus :minus :times :divide}}
:on-result :event}} :on-result :event}}
@ -538,53 +539,53 @@
:on-failure? :event}} :on-failure? :event}}
'schedule/start 'schedule/start
{:permissions [:read] {:permissions [:read]
:value :extensions/schedule-start :data :extensions/schedule-start
:arguments {:interval :number :arguments {:interval :number
:on-created :event :on-created :event
:on-result :event}} :on-result :event}}
'schedule/cancel 'schedule/cancel
{:permissions [:read] {:permissions [:read]
:value :extensions/schedule-cancel :data :extensions/schedule-cancel
:arguments {:value :number}} :arguments {:value :number}}
'json/parse 'json/parse
{:permissions [:read] {:permissions [:read]
:value :extensions/json-parse :data :extensions/json-parse
:arguments {:value :string :arguments {:value :string
:on-result :event}} :on-result :event}}
'json/stringify 'json/stringify
{:permissions [:read] {:permissions [:read]
:value :extensions/json-stringify :data :extensions/json-stringify
:arguments {:value :string :arguments {:value :string
:on-result :event}} :on-result :event}}
'store/put 'store/put
{:permissions [:read] {:permissions [:read]
:value :store/put :data :store/put
:arguments {:key :string :value :any}} :arguments {:key :string :value :any}}
'store/puts 'store/puts
{:permissions [:read] {:permissions [:read]
:value :store/puts :data :store/puts
:arguments {:value :vector}} :arguments {:value :vector}}
'store/append 'store/append
{:permissions [:read] {:permissions [:read]
:value :store/append :data :store/append
:arguments {:key :string :value :any}} :arguments {:key :string :value :any}}
'store/clear 'store/clear
{:permissions [:read] {:permissions [:read]
:value :store/clear :data :store/clear
:arguments {:key :string}} :arguments {:key :string}}
'store/clear-all 'store/clear-all
{:permissions [:read] {:permissions [:read]
:value :store/clear-all} :data :store/clear-all}
'http/get 'http/get
{:permissions [:read] {:permissions [:read]
:value :http/get :data :http/get
:arguments {:url :string :arguments {:url :string
:timeout? :string :timeout? :string
:on-success :event :on-success :event
:on-failure? :event}} :on-failure? :event}}
'http/post 'http/post
{:permissions [:read] {:permissions [:read]
:value :http/post :data :http/post
:arguments {:url :string :arguments {:url :string
:body :string :body :string
:timeout? :string :timeout? :string
@ -592,26 +593,26 @@
:on-failure? :event}} :on-failure? :event}}
'ipfs/cat 'ipfs/cat
{:permissions [:read] {:permissions [:read]
:value :ipfs/cat :data :ipfs/cat
:arguments {:hash :string :arguments {:hash :string
:on-success :event :on-success :event
:on-failure? :event}} :on-failure? :event}}
'ipfs/add 'ipfs/add
{:permissions [:read] {:permissions [:read]
:value :ipfs/add :data :ipfs/add
:arguments {:value :string :arguments {:value :string
:on-success :event :on-success :event
:on-failure? :event}} :on-failure? :event}}
'ethereum/transaction-receipt 'ethereum/transaction-receipt
{:permissions [:read] {:permissions [:read]
:value :extensions/ethereum-transaction-receipt :data :extensions/ethereum-transaction-receipt
:arguments {:value :string :arguments {:value :string
:topics-hints :vector :topics-hints :vector
:on-success :event :on-success :event
:on-failure? :event}} :on-failure? :event}}
'ethereum/await-transaction-receipt 'ethereum/await-transaction-receipt
{:permissions [:read] {:permissions [:read]
:value :extensions/ethereum-await-transaction-receipt :data :extensions/ethereum-await-transaction-receipt
:arguments {:value :string :arguments {:value :string
:interval :number :interval :number
:topics-hints :vector :topics-hints :vector
@ -619,18 +620,18 @@
:on-failure? :event}} :on-failure? :event}}
'ethereum/sign 'ethereum/sign
{:permissions [:read] {:permissions [:read]
:value :extensions/ethereum-sign :data :extensions/ethereum-sign
:arguments {:message? :string :arguments {:message? :string
:data? :string :data? :string
:on-success :event :on-success :event
:on-failure? :event}} :on-failure? :event}}
'ethereum/create-address 'ethereum/create-address
{:permissions [:read] {:permissions [:read]
:value :extensions/ethereum-create-address :data :extensions/ethereum-create-address
:arguments {:on-result :event}} :arguments {:on-result :event}}
'ethereum/send-transaction 'ethereum/send-transaction
{:permissions [:read] {:permissions [:read]
:value :extensions/ethereum-send-transaction :data :extensions/ethereum-send-transaction
:arguments {:to :string :arguments {:to :string
:gas? :string :gas? :string
:gas-price? :string :gas-price? :string
@ -642,7 +643,7 @@
:on-failure? :event}} :on-failure? :event}}
'ethereum/logs 'ethereum/logs
{:permissions [:read] {:permissions [:read]
:value :extensions/ethereum-logs :data :extensions/ethereum-logs
:arguments {:from? :string :arguments {:from? :string
:to? :string :to? :string
:address? :vector :address? :vector
@ -652,7 +653,7 @@
:on-failure? :event}} :on-failure? :event}}
'ethereum/create-filter 'ethereum/create-filter
{:permissions [:read] {:permissions [:read]
:value :extensions/ethereum-create-filter :data :extensions/ethereum-create-filter
:arguments {:type {:one-of #{:filter :block :pending-transaction}} :arguments {:type {:one-of #{:filter :block :pending-transaction}}
:from? :string :from? :string
:to? :string :to? :string
@ -663,35 +664,35 @@
:on-failure? :event}} :on-failure? :event}}
'ethereum/logs-changes 'ethereum/logs-changes
{:permissions [:read] {:permissions [:read]
:value :extensions/ethereum-logs-changes :data :extensions/ethereum-logs-changes
:arguments {:id :string :arguments {:id :string
:topics-hints :vector}} :topics-hints :vector}}
'ethereum/cancel-filter 'ethereum/cancel-filter
{:permissions [:read] {:permissions [:read]
:value :extensions/ethereum-cancel-filter :data :extensions/ethereum-cancel-filter
:arguments {:id :string}} :arguments {:id :string}}
'ethereum.ens/resolve 'ethereum.ens/resolve
{:permissions [:read] {:permissions [:read]
:value :extensions/ethereum-resolve-ens :data :extensions/ethereum-resolve-ens
:arguments {:name :string :arguments {:name :string
:on-success :event :on-success :event
:on-failure? :event}} :on-failure? :event}}
'ethereum.erc20/total-supply 'ethereum.erc20/total-supply
{:permissions [:read] {:permissions [:read]
:value :extensions/ethereum-erc20-total-supply :data :extensions/ethereum-erc20-total-supply
:arguments {:contract :string :arguments {:contract :string
:on-success :event :on-success :event
:on-failure? :event}} :on-failure? :event}}
'ethereum.erc20/balance-of 'ethereum.erc20/balance-of
{:permissions [:read] {:permissions [:read]
:value :extensions/ethereum-erc20-balance-of :data :extensions/ethereum-erc20-balance-of
:arguments {:contract :string :arguments {:contract :string
:token-owner :string :token-owner :string
:on-success :event :on-success :event
:on-failure? :event}} :on-failure? :event}}
'ethereum.erc20/transfer 'ethereum.erc20/transfer
{:permissions [:read] {:permissions [:read]
:value :extensions/ethereum-erc20-transfer :data :extensions/ethereum-erc20-transfer
:arguments {:contract :string :arguments {:contract :string
:to :string :to :string
:value :number :value :number
@ -699,7 +700,7 @@
:on-failure? :event}} :on-failure? :event}}
'ethereum.erc20/transfer-from 'ethereum.erc20/transfer-from
{:permissions [:read] {:permissions [:read]
:value :extensions/ethereum-erc20-transfer-from :data :extensions/ethereum-erc20-transfer-from
:arguments {:contract :string :arguments {:contract :string
:from :string :from :string
:to :string :to :string
@ -708,7 +709,7 @@
:on-failure? :event}} :on-failure? :event}}
'ethereum.erc20/approve 'ethereum.erc20/approve
{:permissions [:read] {:permissions [:read]
:value :extensions/ethereum-erc20-approve :data :extensions/ethereum-erc20-approve
:arguments {:contract :string :arguments {:contract :string
:spender :string :spender :string
:value :number :value :number
@ -716,7 +717,7 @@
:on-failure? :event}} :on-failure? :event}}
'ethereum.erc20/allowance 'ethereum.erc20/allowance
{:permissions [:read] {:permissions [:read]
:value :extensions/ethereum-erc20-allowance :data :extensions/ethereum-erc20-allowance
:arguments {:contract :string :arguments {:contract :string
:token-owner :string :token-owner :string
:spender :string :spender :string
@ -724,14 +725,14 @@
:on-failure? :event}} :on-failure? :event}}
'ethereum.erc721/owner-of 'ethereum.erc721/owner-of
{:permissions [:read] {:permissions [:read]
:value :extensions/ethereum-erc721-owner-of :data :extensions/ethereum-erc721-owner-of
:arguments {:contract :string :arguments {:contract :string
:token-id :string :token-id :string
:on-success :event :on-success :event
:on-failure? :event}} :on-failure? :event}}
'ethereum.erc721/is-approved-for-all 'ethereum.erc721/is-approved-for-all
{:permissions [:read] {:permissions [:read]
:value :extensions/ethereum-erc721-is-approved-for-all :data :extensions/ethereum-erc721-is-approved-for-all
:arguments {:contract :string :arguments {:contract :string
:owner :string :owner :string
:operator :string :operator :string
@ -739,14 +740,14 @@
:on-failure? :event}} :on-failure? :event}}
'ethereum.erc721/get-approved 'ethereum.erc721/get-approved
{:permissions [:read] {:permissions [:read]
:value :extensions/ethereum-erc721-get-approved :data :extensions/ethereum-erc721-get-approved
:arguments {:contract :string :arguments {:contract :string
:token-id :string :token-id :string
:on-success :event :on-success :event
:on-failure? :event}} :on-failure? :event}}
'ethereum.erc721/set-approval-for-all 'ethereum.erc721/set-approval-for-all
{:permissions [:read] {:permissions [:read]
:value :extensions/ethereum-erc721-set-approval-for-all :data :extensions/ethereum-erc721-set-approval-for-all
:arguments {:contract :string :arguments {:contract :string
:operator :string :operator :string
:approved :boolean :approved :boolean
@ -754,7 +755,7 @@
:on-failure? :event}} :on-failure? :event}}
'ethereum.erc721/safe-transfer-from 'ethereum.erc721/safe-transfer-from
{:permissions [:read] {:permissions [:read]
:value :extensions/ethereum-erc721-safe-transfer-from :data :extensions/ethereum-erc721-safe-transfer-from
:arguments {:contract :string :arguments {:contract :string
:from :string :from :string
:to :string :to :string
@ -764,7 +765,7 @@
:on-failure? :event}} :on-failure? :event}}
'ethereum/call 'ethereum/call
{:permissions [:read] {:permissions [:read]
:value :extensions/ethereum-call :data :extensions/ethereum-call
:arguments {:to :string :arguments {:to :string
:method :string :method :string
:params? :vector :params? :vector
@ -773,7 +774,7 @@
:on-failure? :event}} :on-failure? :event}}
'ethereum/shh_post 'ethereum/shh_post
{:permissions [:read] {:permissions [:read]
:value :extensions/shh-post :data :extensions/shh-post
:arguments {:from? :string :arguments {:from? :string
:to? :string :to? :string
:topics :vector :topics :vector
@ -784,7 +785,7 @@
:on-failure? :event}} :on-failure? :event}}
'ethereum/shh-new-identity 'ethereum/shh-new-identity
{:permissions [:read] {:permissions [:read]
:value :extensions/shh-new-identity :data :extensions/shh-new-identity
:arguments {:on-success :event :arguments {:on-success :event
:on-failure? :event}} :on-failure? :event}}
'ethereum/shh-has-identity 'ethereum/shh-has-identity
@ -795,45 +796,75 @@
:on-failure? :event}} :on-failure? :event}}
'ethereum/shh-new-group 'ethereum/shh-new-group
{:permissions [:read] {:permissions [:read]
:value :extensions/shh-new-group :data :extensions/shh-new-group
:arguments {:on-success :event :arguments {:on-success :event
:on-failure? :event}} :on-failure? :event}}
'ethereum/shh-add-to-group 'ethereum/shh-add-to-group
{:permissions [:read] {:permissions [:read]
:value :extensions/shh-add-to-group :data :extensions/shh-add-to-group
:arguments {:address :string :arguments {:address :string
:on-success :event :on-success :event
:on-failure? :event}} :on-failure? :event}}
'ethereum/shh_new-filter 'ethereum/shh_new-filter
{:permissions [:read] {:permissions [:read]
:value :extensions/shh-new-filter :data :extensions/shh-new-filter
:arguments {:to? :string :arguments {:to? :string
:topics :vector :topics :vector
:on-success :event :on-success :event
:on-failure? :event}} :on-failure? :event}}
'ethereum/shh-uninstall-filter 'ethereum/shh-uninstall-filter
{:permissions [:read] {:permissions [:read]
:value :extensions/shh-uninstall-filter :data :extensions/shh-uninstall-filter
:arguments {:id :string}} :arguments {:id :string}}
'ethereum/shh-get-filter-changes 'ethereum/shh-get-filter-changes
{:permissions [:read] {:permissions [:read]
:value :extensions/shh-get-filter-changes :data :extensions/shh-get-filter-changes
:arguments {:id :string}} :arguments {:id :string}}
'ethereum/shh-get-messages 'ethereum/shh-get-messages
{:permissions [:read] {:permissions [:read]
:value :extensions/shh-get-messages :data :extensions/shh-get-messages
:arguments {:id :string}}} :arguments {:id :string}}}
:hooks {:chat.command commands/command-hook :hooks {:wallet.settings
:wallet.settings settings/hook}}) {:properties
{:label :string
:view :view
:on-open? :event
:on-close? :event}}
:chat.command
{:properties
{:description? :string
:scope #{:personal-chats :public-chats :group-chats}
:short-preview? :view
:preview? :view
:on-send? :event
:on-receive? :event
:on-send-sync? :event
:parameters? [{:id :keyword
:type {:one-of #{:text :phone :password :number}}
:placeholder :string
:suggestions? :view}]}}}})
(defn dispatch-events [_ events]
(doseq [event events]
(when (vector? event)
(re-frame/dispatch event))))
(defn resolve-query [[id :as data]]
(when (registrar/get-handler :sub id)
(re-frame/subscribe data)))
(defn parse [{:keys [data]} id] (defn parse [{:keys [data]} id]
(try (try
(reader/parse {:capacities capacities :env {:id id}} data) (pluto/parse {:capacities capacities
:env {:id id}
:event-fn dispatch-events
:query-fn resolve-query}
data)
(catch :default e {:errors [{:value (str e)}]}))) (catch :default e {:errors [{:value (str e)}]})))
(defn parse-extension [{:keys [type value]} id] (defn parse-extension [{:keys [type value]} id]
(if (= type :success) (if (= type :success)
(parse (reader/read (:content value)) id) (parse (pluto/read (:content value)) id)
{:errors [{:type type :value value}]})) {:errors [{:type type :value value}]}))
(def uri-prefix "https://get.status.im/extension/") (def uri-prefix "https://get.status.im/extension/")

View File

@ -1,6 +1,5 @@
(ns status-im.extensions.ethereum (ns status-im.extensions.ethereum
(:require [clojure.string :as string] (:require [clojure.string :as string]
[re-frame.core :as re-frame]
[status-im.constants :as constants] [status-im.constants :as constants]
[status-im.i18n :as i18n] [status-im.i18n :as i18n]
[status-im.models.wallet :as models.wallet] [status-im.models.wallet :as models.wallet]
@ -12,7 +11,6 @@
[status-im.utils.ethereum.core :as ethereum] [status-im.utils.ethereum.core :as ethereum]
[status-im.utils.handlers :as handlers] [status-im.utils.handlers :as handlers]
[status-im.utils.money :as money] [status-im.utils.money :as money]
[clojure.string :as string]
[status-im.utils.types :as types] [status-im.utils.types :as types]
[status-im.native-module.core :as status])) [status-im.native-module.core :as status]))
@ -20,13 +18,13 @@
:extensions/wallet-ui-on-success :extensions/wallet-ui-on-success
(fn [cofx [_ on-success _ result _]] (fn [cofx [_ on-success _ result _]]
(fx/merge cofx (fx/merge cofx
{:dispatch (on-success {:value result})} (when on-success (on-success {:value result}))
(navigation/navigate-back)))) (navigation/navigate-back))))
(handlers/register-handler-fx (handlers/register-handler-fx
:extensions/wallet-ui-on-failure :extensions/wallet-ui-on-failure
(fn [_ [_ on-failure message]] (fn [_ [_ on-failure message]]
(when on-failure {:dispatch (on-failure {:value message})}))) (when on-failure (on-failure {:value message}))))
(defn- wrap-with-resolution [db arguments address-keyword f] (defn- wrap-with-resolution [db arguments address-keyword f]
"function responsible to resolve ens taken from argument "function responsible to resolve ens taken from argument
@ -85,9 +83,9 @@
(defn- rpc-dispatch [error result f on-success on-failure] (defn- rpc-dispatch [error result f on-success on-failure]
(when result (when result
(re-frame/dispatch (on-success {:value (f result)}))) (on-success {:value (f result)}))
(when (and error on-failure) (when (and error on-failure)
(re-frame/dispatch (on-failure {:value error})))) (on-failure {:value error})))
(defn- rpc-handler [o f on-success on-failure] (defn- rpc-handler [o f on-success on-failure]
(let [{:keys [error result]} (types/json->clj o)] (let [{:keys [error result]} (types/json->clj o)]
@ -370,9 +368,9 @@
network-info (get-in db [:account/account :networks network]) network-info (get-in db [:account/account :networks network])
chain (ethereum/network->chain-keyword network-info) chain (ethereum/network->chain-keyword network-info)
registry (get ens/ens-registries chain)] registry (get ens/ens-registries chain)]
(ens/get-addr web3 registry name #(re-frame/dispatch (on-success {:value %})))) (ens/get-addr web3 registry name #(on-success {:value %})))
(when on-failure (when on-failure
(re-frame/dispatch (on-failure {:value (str "'" name "' is not a valid name")})))))) (on-failure {:value (str "'" name "' is not a valid name")})))))
;; EXTENSION SIGN -> SIGN MESSAGE ;; EXTENSION SIGN -> SIGN MESSAGE
(handlers/register-handler-fx (handlers/register-handler-fx
@ -380,7 +378,7 @@
(fn [{db :db :as cofx} [_ _ {:keys [message data id on-success on-failure]}]] (fn [{db :db :as cofx} [_ _ {:keys [message data id on-success on-failure]}]]
(if (and message data) (if (and message data)
(when on-failure (when on-failure
{:dispatch (on-failure {:error "only one of :message and :data can be used"})}) (on-failure {:error "only one of :message and :data can be used"}))
(fx/merge cofx (fx/merge cofx
{:db (assoc-in db [:wallet :send-transaction] {:db (assoc-in db [:wallet :send-transaction]
{:id id {:id id
@ -400,7 +398,7 @@
(status/call-private-rpc payload #(let [{:keys [error result]} (types/json->clj %1) (status/call-private-rpc payload #(let [{:keys [error result]} (types/json->clj %1)
response (if error {:result result :error error} response (if error {:result result :error error}
{:result result})] {:result result})]
(re-frame/dispatch (on-result response))))))) (on-result response))))))
;; poll logs implementation ;; poll logs implementation
(handlers/register-handler-fx (handlers/register-handler-fx

View File

@ -1,29 +1,88 @@
(ns status-im.extensions.registry (ns status-im.extensions.registry
(:refer-clojure :exclude [list]) (:refer-clojure :exclude [list])
(:require [clojure.string :as string] (:require [clojure.set :as set]
[pluto.reader.hooks :as hooks] [clojure.string :as string]
[re-frame.core :as re-frame] [re-frame.core :as re-frame]
[pluto.core :as pluto]
[status-im.accounts.update.core :as accounts.update] [status-im.accounts.update.core :as accounts.update]
[status-im.chat.commands.core :as commands]
[status-im.chat.commands.protocol :as protocol]
[status-im.i18n :as i18n] [status-im.i18n :as i18n]
[status-im.utils.fx :as fx] [status-im.ui.screens.navigation :as navigation]
[clojure.set :as set] [status-im.utils.fx :as fx]))
[status-im.ui.screens.navigation :as navigation]))
(defprotocol Hook
"Encapsulate hook lifecycle."
(hook-in [this id env properties cofx] "Hook it into host app.")
(unhook [this id env properties cofx] "Remove extension hook from app."))
(defmulti hook-for (fn [hook] (pluto/hook-type hook)))
(defmethod hook-for "wallet.settings" [_]
(reify Hook
(hook-in [_ id _ m {:keys [db]}]
{:db (assoc-in db [:wallet :settings id] m)})
(unhook [_ id _ _ {:keys [db]}]
{:db (update-in db [:wallet :settings] dissoc id)})))
(defmethod hook-for "chat.command" [_]
(reify Hook
(hook-in [_ id {extension-id :id} {:keys [description scope parameters preview short-preview
on-send on-receive on-send-sync]} cofx]
(let [new-command (if on-send-sync
(reify protocol/Command
(id [_] (name id))
(scope [_] scope)
(description [_] description)
(parameters [_] (or parameters []))
(validate [_ _ _])
(on-send [_ command-message _] (when on-send (on-send command-message)))
(on-receive [_ command-message _] (when on-receive (on-receive command-message)))
(short-preview [_ props] (when short-preview (short-preview props)))
(preview [_ props] (when preview (preview props)))
protocol/Yielding
(yield-control [_ props _] (on-send-sync props))
protocol/Extension
(extension-id [_] extension-id))
(reify protocol/Command
(id [_] (name id))
(scope [_] scope)
(description [_] description)
(parameters [_] (or parameters []))
(validate [_ _ _])
(on-send [_ command-message _] (when on-send (on-send command-message)))
(on-receive [_ command-message _] (when on-receive (on-receive command-message)))
(short-preview [_ props] (when short-preview (short-preview props)))
(preview [_ props] (when preview (preview props)))
protocol/Extension
(extension-id [_] extension-id)))]
(commands/load-commands cofx [new-command])))
(unhook [_ id _ {:keys [scope]} {:keys [db] :as cofx}]
(when-let [command (get-in db [:id->command [(name id) scope] :type])]
(commands/remove-command command cofx)))))
(defmethod hook-for :default [a]
(reify Hook
(hook-in [this id env properties cofx])
(unhook [this id env properties cofx])))
(defn hook-id
[s]
(when s
(last (string/split (name s) #"\."))))
(fx/defn update-hooks (fx/defn update-hooks
[{:keys [db] :as cofx} hook-fn extension-id] [{:keys [db] :as cofx} hook-fn extension-id]
(let [account (get db :account/account) (let [account (get db :account/account)
hooks (get-in account [:extensions extension-id :hooks])] hooks (get-in account [:extensions extension-id :hooks])]
(apply fx/merge cofx (apply fx/merge cofx
(mapcat (fn [[_ extension-hooks]] (map (fn [[type extension]]
(map (fn [[hook-id {parsed :parsed {hook :hook} :hook-ref}]] (hook-fn (hook-for type) (hook-id type) {:id extension-id} extension cofx))
(when hook hooks))))
(partial hook-fn hook hook-id {:id extension-id} parsed)))
extension-hooks))
hooks))))
(fx/defn disable-hooks (fx/defn disable-hooks
[{:keys [db] :as cofx} extension-id] [{:keys [db] :as cofx} extension-id]
(update-hooks cofx hooks/unhook extension-id)) (update-hooks cofx unhook extension-id))
(fx/defn add-to-registry (fx/defn add-to-registry
[{:keys [db] :as cofx} extension-id extension-data active?] [{:keys [db] :as cofx} extension-id extension-data active?]
@ -32,14 +91,14 @@
:active? active?}] :active? active?}]
(fx/merge cofx (fx/merge cofx
{:db (update-in db [:account/account :extensions extension-id] merge data)} {:db (update-in db [:account/account :extensions extension-id] merge data)}
(update-hooks hooks/hook-in extension-id)))) (update-hooks hook-in extension-id))))
(fx/defn remove-from-registry (fx/defn remove-from-registry
[cofx extension-id] [cofx extension-id]
(let [extensions (get-in cofx [:db :account/account :extensions])] (let [extensions (get-in cofx [:db :account/account :extensions])]
(fx/merge cofx (fx/merge cofx
(when (get-in extensions [extension-id :active?]) (when (get-in extensions [extension-id :active?])
(update-hooks hooks/unhook extension-id)) (update-hooks unhook extension-id))
{:db (update-in cofx [:db :account/account :extensions] dissoc extension-id)}))) {:db (update-in cofx [:db :account/account :extensions] dissoc extension-id)})))
(fx/defn change-state (fx/defn change-state
@ -47,8 +106,8 @@
(let [extensions (get-in cofx [:db :account/account :extensions]) (let [extensions (get-in cofx [:db :account/account :extensions])
new-extensions (assoc-in extensions [extension-key :active?] active?) new-extensions (assoc-in extensions [extension-key :active?] active?)
hook-fn (if active? hook-fn (if active?
hooks/hook-in hook-in
hooks/unhook)] unhook)]
(fx/merge cofx (fx/merge cofx
(accounts.update/account-update {:extensions new-extensions} {:success-event nil}) (accounts.update/account-update {:extensions new-extensions} {:success-event nil})
(update-hooks hook-fn extension-key)))) (update-hooks hook-fn extension-key))))
@ -57,7 +116,7 @@
[{:keys [db] :as cofx} url {:keys [hooks] :as extension-data} modal?] [{:keys [db] :as cofx} url {:keys [hooks] :as extension-data} modal?]
(let [{:account/keys [account]} db (let [{:account/keys [account]} db
extension {:id url extension {:id url
:name (get-in extension-data ['meta :name]) :name (or (get-in extension-data [:meta :name]) "Unnamed")
:url url :url url
:active? true} :active? true}
new-extensions (assoc (:extensions account) url extension)] new-extensions (assoc (:extensions account) url extension)]
@ -115,13 +174,13 @@
(into acc))) (into acc)))
#{} #{}
(get-in cofx [:db :account/account :extensions])) (get-in cofx [:db :account/account :extensions]))
hooks (->> (get-in extension-data [:data :hooks type]) hooks (->> (get-in extension-data [:hooks type])
(keys) (keys)
(into #{}))] (into #{}))]
(set/intersection added-hooks hooks))) (set/intersection added-hooks hooks)))
(defn existing-hooks [cofx extension-data] (defn existing-hooks [cofx extension-data]
(->> (get-in extension-data [:data :hooks]) (->> (get-in extension-data [:hooks])
(keys) (keys)
(map #(existing-hooks-for % cofx extension-data)) (map #(existing-hooks-for % cofx extension-data))
(apply set/union))) (apply set/union)))

View File

@ -1,12 +1,6 @@
(ns status-im.native-module.impl.module (ns status-im.native-module.impl.module
(:require-macros
[cljs.core.async.macros :refer [go-loop go]])
(:require [status-im.ui.components.react :as r] (:require [status-im.ui.components.react :as r]
[re-frame.core :as re-frame] [re-frame.core :as re-frame]
[taoensso.timbre :as log]
[cljs.core.async :as async]
[status-im.utils.platform :as p]
[status-im.utils.async :as async-util]
[status-im.react-native.js-dependencies :as rn-dependencies] [status-im.react-native.js-dependencies :as rn-dependencies]
[clojure.string :as string] [clojure.string :as string]
[status-im.utils.platform :as platform])) [status-im.utils.platform :as platform]))

View File

@ -3,6 +3,7 @@
(:require [re-frame.core :as re-frame] (:require [re-frame.core :as re-frame]
[reagent.core :as reagent] [reagent.core :as reagent]
[clojure.string :as string] [clojure.string :as string]
[pluto.reader.errors :as errors]
[status-im.extensions.core :as extensions] [status-im.extensions.core :as extensions]
[status-im.i18n :as i18n] [status-im.i18n :as i18n]
[status-im.ui.components.react :as react] [status-im.ui.components.react :as react]
@ -23,13 +24,6 @@
[react/view {:flex 1} [react/view {:flex 1}
content]]]) content]]])
(defn hooks [{:keys [hooks]}]
(mapcat (fn [[hook-id values]]
(map (fn [[id]]
(str (name hook-id) "." (name id)))
values))
hooks))
(views/defview show-extension-base [modal?] (views/defview show-extension-base [modal?]
(views/letsubs [{:keys [extension-data url]} [:get-staged-extension]] (views/letsubs [{:keys [extension-data url]} [:get-staged-extension]]
(let [{:keys [data errors]} extension-data] (let [{:keys [data errors]} extension-data]
@ -45,15 +39,15 @@
(i18n/label :t/extensions-disclaimer)]] (i18n/label :t/extensions-disclaimer)]]
[cartouche {:header (i18n/label :t/identifier)} [cartouche {:header (i18n/label :t/identifier)}
[react/text {:style styles/text} [react/text {:style styles/text}
(str (get-in data ['meta :name]))]] (str (get-in data [:meta :name]))]]
[cartouche {:header (i18n/label :t/name)} [cartouche {:header (i18n/label :t/name)}
[react/text {:style styles/text} [react/text {:style styles/text}
(str (get-in data ['meta :name]))]] (str (get-in data [:meta :name]))]]
[cartouche {:header (i18n/label :t/description)} [cartouche {:header (i18n/label :t/description)}
[react/text {:style styles/text} [react/text {:style styles/text}
(str (get-in data ['meta :description]))]] (str (get-in data [:meta :description]))]]
[cartouche {:header (i18n/label :t/hooks)} [cartouche {:header (i18n/label :t/hooks)}
(into [react/view] (for [hook (hooks data)] (into [react/view] (for [hook (keys (:hooks data))]
[react/text {:style styles/text} [react/text {:style styles/text}
(str hook)]))] (str hook)]))]
[cartouche {:header (i18n/label :t/permissions)} [cartouche {:header (i18n/label :t/permissions)}
@ -61,9 +55,9 @@
(i18n/label :t/none)]] (i18n/label :t/none)]]
[cartouche {:header (i18n/label :t/errors)} [cartouche {:header (i18n/label :t/errors)}
(if errors (if errors
(into [react/view] (for [error errors] (into [react/view] (for [{::errors/keys [type value]} errors]
[react/text {:style styles/text} [react/text {:style styles/text}
(str (name (:pluto.reader.errors/type error)) " " (str (:pluto.reader.errors/value error)))])) (str (when type (name type)) " " (str value))]))
[react/text {:style styles/text} [react/text {:style styles/text}
(i18n/label :t/none)])]]] (i18n/label :t/none)])]]]
[react/view styles/bottom-container [react/view styles/bottom-container

View File

@ -1,7 +1,6 @@
(ns status-im.ui.screens.wallet.settings.views (ns status-im.ui.screens.wallet.settings.views
(:require-macros [status-im.utils.views :refer [defview letsubs]]) (:require-macros [status-im.utils.views :refer [defview letsubs]])
(:require [re-frame.core :as re-frame] (:require [re-frame.core :as re-frame]
[pluto.reader.hooks :as hooks]
[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.list.views :as list] [status-im.ui.components.list.views :as list]
@ -15,20 +14,6 @@
[status-im.utils.ethereum.tokens :as tokens] [status-im.utils.ethereum.tokens :as tokens]
[status-im.ui.components.toolbar.actions :as actions])) [status-im.ui.components.toolbar.actions :as actions]))
(def hook
"Hook for extensions"
{:properties
{:label :string
:view :view
:on-open? :event
:on-close? :event}
:hook
(reify hooks/Hook
(hook-in [_ id _ {:keys [label view _]} {:keys [db]}]
{:db (assoc-in db [:wallet :settings id] {:label label :view view})})
(unhook [_ id _ _ {:keys [db]}]
{:db (update-in db [:wallet :settings] dissoc id)}))})
(defn- render-token [{:keys [symbol name icon]} visible-tokens] (defn- render-token [{:keys [symbol name icon]} visible-tokens]
[list/list-item-with-checkbox [list/list-item-with-checkbox
{:checked? (contains? visible-tokens (keyword symbol)) {:checked? (contains? visible-tokens (keyword symbol))
@ -80,7 +65,7 @@
{:label label {:label label
:action #(do :action #(do
(when on-open (when on-open
(re-frame/dispatch (on-open address))) (on-open address))
(re-frame/dispatch [:navigate-to :wallet-settings-hook m]))}) (re-frame/dispatch [:navigate-to :wallet-settings-hook m]))})
(defview toolbar-view [] (defview toolbar-view []