Fixed some extensions issues (smallish)
Signed-off-by: Julien Eluard <julien.eluard@gmail.com>
This commit is contained in:
parent
9248db8dfb
commit
fceaa0981f
|
@ -136,7 +136,7 @@
|
|||
:preview :view
|
||||
:on-send? :event
|
||||
:on-receive? :event
|
||||
:parameters [{:id :keyword
|
||||
:parameters? [{:id :keyword
|
||||
:type {:one-of #{:text :phone :password :number}}
|
||||
:placeholder :string
|
||||
:suggestions? :view}]}
|
||||
|
@ -149,8 +149,8 @@
|
|||
(description [_] description)
|
||||
(parameters [_] parameters)
|
||||
(validate [_ _ _])
|
||||
(on-send [_ command-message _] (when on-send {:dispatch (on-send {:value command-message})}))
|
||||
(on-receive [_ command-message _] (when on-receive {:dispatch (on-receive {:value command-message})}))
|
||||
(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] (short-preview props))
|
||||
(preview [_ props] (preview props)))]
|
||||
(load-commands cofx [new-command])))
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
(fn [db [_ {:keys [key]}]]
|
||||
(get-in db [:extensions-store :collectible key])))
|
||||
|
||||
(re-frame/reg-sub :identity
|
||||
(re-frame/reg-sub :extensions/identity
|
||||
(fn [_ [_ {:keys [value]}]] value))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
|
@ -152,11 +152,12 @@
|
|||
:style {:width "100%"}
|
||||
:on-change-text #(re-frame/dispatch (on-change {:value %}))}])
|
||||
|
||||
(defn touchable-opacity [{:keys [on-press]} & children]
|
||||
(into [react/touchable-opacity {:on-press #(re-frame/dispatch (on-press {}))}] children))
|
||||
(defn touchable-opacity [{:keys [style on-press]} & children]
|
||||
(into [react/touchable-opacity (merge {:on-press #(re-frame/dispatch (on-press {}))}
|
||||
(when style {:style style}))] children))
|
||||
|
||||
(defn image [{:keys [uri style]}]
|
||||
[react/image (merge {:style (merge {:width 100 :height 100} style)} (when uri {:source {:uri uri}}))])
|
||||
[react/image (merge {:style (merge {:width 100 :height 100} style)} {:source {:uri uri}})])
|
||||
|
||||
(defn link [{:keys [uri]}]
|
||||
[react/text
|
||||
|
@ -165,17 +166,23 @@
|
|||
:on-press #(re-frame/dispatch [:browser.ui/message-link-pressed uri])}
|
||||
uri])
|
||||
|
||||
(defn text [o & children]
|
||||
(if (map? o)
|
||||
[react/text o children]
|
||||
(into [react/text {} o] children)))
|
||||
|
||||
(defn list [{:keys [data item-view]}]
|
||||
[list/flat-list {:data data :key-fn (fn [_ i] (str i)) :render-fn item-view}])
|
||||
|
||||
(defn checkbox [{:keys [on-change checked]}]
|
||||
[react/view {:style {:background-color colors/white}}
|
||||
[checkbox/checkbox (merge {:checked checked :style {:padding 0}}
|
||||
(when on-change {:on-value-change #(re-frame/dispatch (on-change {:value %}))}))]])
|
||||
[checkbox/checkbox {:checked? checked
|
||||
:style {:padding 0}
|
||||
:on-value-change #(re-frame/dispatch (on-change {:value %}))}]])
|
||||
|
||||
(def capacities
|
||||
{:components {'view {:value react/view}
|
||||
'text {:value react/text}
|
||||
'text {:value text}
|
||||
'touchable-opacity {:value touchable-opacity :properties {:on-press :event}}
|
||||
'image {:value image :properties {:uri :string}}
|
||||
'input {:value input :properties {:on-change :event :placeholder :string}}
|
||||
|
@ -217,11 +224,11 @@
|
|||
'store/put
|
||||
{:permissions [:read]
|
||||
:value :store/put
|
||||
:arguments {:key :string :value :string}}
|
||||
:arguments {:key :string :value :map}}
|
||||
'store/append
|
||||
{:permissions [:read]
|
||||
:value :store/append
|
||||
:arguments {:key :string :value :string}}
|
||||
:arguments {:key :string :value :map}}
|
||||
'store/clear
|
||||
{:permissions [:read]
|
||||
:value :store/put
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
(ns status-im.extensions.ethereum
|
||||
(:require [status-im.utils.handlers :as handlers]
|
||||
(:require [clojure.string :as string]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.constants :as constants]
|
||||
[status-im.i18n :as i18n]
|
||||
[status-im.models.wallet :as models.wallet]
|
||||
[status-im.utils.hex :as hex]
|
||||
[status-im.ui.screens.navigation :as navigation]
|
||||
[status-im.utils.ethereum.abi-spec :as abi-spec]
|
||||
[status-im.utils.fx :as fx]
|
||||
[status-im.ui.screens.navigation :as navigation]
|
||||
[clojure.string :as string]))
|
||||
[status-im.utils.handlers :as handlers]
|
||||
[status-im.utils.money :as money]))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:extensions/transaction-on-result
|
||||
|
@ -20,12 +24,37 @@
|
|||
(fn [{db :db} [_ on-result message]]
|
||||
(when on-result {:dispatch (on-result {:error message :result nil})})))
|
||||
|
||||
;; EXTENSION TRANSACTION -> SEND TRANSACTION
|
||||
(defn prepare-extension-transaction [params contacts on-result]
|
||||
(let [{:keys [to value data gas gasPrice nonce]} params
|
||||
contact (get contacts (hex/normalize-hex to))]
|
||||
(cond-> {:id "extension-id"
|
||||
:to-name (or (when (nil? to)
|
||||
(i18n/label :t/new-contract))
|
||||
contact)
|
||||
:symbol :ETH
|
||||
:method constants/web3-send-transaction
|
||||
:to to
|
||||
:amount (money/bignumber (or value 0))
|
||||
:gas (cond
|
||||
gas
|
||||
(money/bignumber gas)
|
||||
(and value (empty? data))
|
||||
(money/bignumber 21000))
|
||||
:gas-price (when gasPrice
|
||||
(money/bignumber gasPrice))
|
||||
:data data
|
||||
:on-result [:extensions/transaction-on-result on-result]
|
||||
:on-error [:extensions/transaction-on-error on-result]}
|
||||
nonce
|
||||
(assoc :nonce nonce))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
:extensions/ethereum-send-transaction
|
||||
(fn [{db :db} [_ {:keys [method params on-result] :as arguments}]]
|
||||
(let [tx-object (assoc (select-keys arguments [:to :gas :gas-price :value :nonce])
|
||||
:data (when (and method params) (abi-spec/encode method params)))
|
||||
transaction (models.wallet/prepare-extension-transaction tx-object (:contacts/contacts db) on-result)]
|
||||
transaction (prepare-extension-transaction tx-object (:contacts/contacts db) on-result)]
|
||||
(models.wallet/open-modal-wallet-for-transaction db transaction tx-object))))
|
||||
|
||||
(handlers/register-handler-fx
|
||||
|
|
|
@ -88,31 +88,6 @@
|
|||
nonce
|
||||
(assoc :nonce nonce))))
|
||||
|
||||
;; EXTENSION TRANSACTION -> SEND TRANSACTION
|
||||
(defn prepare-extension-transaction [params contacts on-result]
|
||||
(let [{:keys [to value data gas gasPrice nonce]} params
|
||||
contact (get contacts (utils.hex/normalize-hex to))]
|
||||
(cond-> {:id "extension-id"
|
||||
:to-name (or (when (nil? to)
|
||||
(i18n/label :t/new-contract))
|
||||
contact)
|
||||
:symbol :ETH
|
||||
:method constants/web3-send-transaction
|
||||
:to to
|
||||
:amount (money/bignumber (or value 0))
|
||||
:gas (cond
|
||||
gas
|
||||
(money/bignumber gas)
|
||||
(and value (empty? data))
|
||||
(money/bignumber 21000))
|
||||
:gas-price (when gasPrice
|
||||
(money/bignumber gasPrice))
|
||||
:data data
|
||||
:on-result [:extensions/transaction-on-result on-result]
|
||||
:on-error [:extensions/transaction-on-error on-result]}
|
||||
nonce
|
||||
(assoc :nonce nonce))))
|
||||
|
||||
;; SEND TRANSACTION -> RPC TRANSACTION
|
||||
(defn prepare-send-transaction [from {:keys [amount to gas gas-price data nonce]}]
|
||||
(cond-> {:from (ethereum/normalized-address from)
|
||||
|
|
Loading…
Reference in New Issue