Added contacts/all event and wallet.settings lifecycle hooks
Signed-off-by: Julien Eluard <julien.eluard@gmail.com>
This commit is contained in:
parent
0563abff54
commit
3770243546
|
@ -60,4 +60,4 @@
|
|||
{:handler :extensions/camera-qr-code-scanned
|
||||
:cancel-handler :extensions/camera-cancel
|
||||
:data {:on-success on-success
|
||||
:on-failure on-failure}})))
|
||||
:on-failure on-failure}})))
|
||||
|
|
|
@ -125,6 +125,18 @@
|
|||
(fn [db [_ {id :id} {:keys [key]}]]
|
||||
(get-in db [:extensions/store id key])))
|
||||
|
||||
(defn- ->contact [{:keys [photo-path address name public-key]}]
|
||||
{:photo photo-path
|
||||
:name name
|
||||
:address (str "0x" address)
|
||||
:public-key public-key})
|
||||
|
||||
(re-frame/reg-sub
|
||||
:extensions.contacts/all
|
||||
:<- [:contacts/active]
|
||||
(fn [[contacts] _]
|
||||
(map #(update % :address ->contact))))
|
||||
|
||||
(defn- empty-value? [o]
|
||||
(cond
|
||||
(seqable? o) (empty? o)
|
||||
|
@ -419,6 +431,7 @@
|
|||
'transaction-status {:value transactions/transaction-status :properties {:outgoing :string :tx-hash :string}}}
|
||||
:queries {'identity {:value :extensions/identity :arguments {:value :map}}
|
||||
'store/get {:value :store/get :arguments {:key :string}}
|
||||
'contacts/all {:value :extensions.contacts/all} ;; :photo :name :address :public-key
|
||||
'wallet/collectibles {:value :get-collectible-token :arguments {:token :string :symbol :string}}
|
||||
'wallet/balance {:value :extensions.wallet/balance :arguments {:token :string}}
|
||||
'wallet/token {:value :extensions.wallet/token :arguments {:token :string :amount? :number :amount-in-wei? :number}}
|
||||
|
@ -575,7 +588,7 @@
|
|||
:method? :string
|
||||
:params? :vector
|
||||
:nonce? :string
|
||||
:on-success :event
|
||||
:on-success? :event
|
||||
:on-failure? :event}}
|
||||
'ethereum/logs
|
||||
{:permissions [:read]
|
||||
|
|
|
@ -15,4 +15,5 @@
|
|||
(when show-box?
|
||||
[react/view]
|
||||
[expandable/expandable-view {:key :parameter-box}
|
||||
;; TODO need to add the whole payload (and details about previous parameters?)
|
||||
[parameter-box-container]])))
|
||||
|
|
|
@ -18,7 +18,9 @@
|
|||
"Hook for extensions"
|
||||
{:properties
|
||||
{:label :string
|
||||
:view :view}
|
||||
:view :view
|
||||
:on-open? :event
|
||||
:on-close? :event}
|
||||
:hook
|
||||
(reify hooks/Hook
|
||||
(hook-in [_ id _ {:keys [label view _]} {:keys [db]}]
|
||||
|
@ -55,24 +57,33 @@
|
|||
:key-fn (comp str :symbol)
|
||||
:render-fn #(render-token % visible-tokens)}]]]))
|
||||
|
||||
(defn- create-payload [address]
|
||||
{:address (ethereum/normalized-address address)})
|
||||
|
||||
(defview settings-hook []
|
||||
(letsubs [{:keys [label view]} [:get-screen-params :wallet-settings-hook]
|
||||
{address :address} [:account/account]]
|
||||
(letsubs [{:keys [label view on-close]} [:get-screen-params :wallet-settings-hook]
|
||||
{address :address} [:account/account]]
|
||||
[react/keyboard-avoiding-view {:style {:flex 1 :background-color colors/blue}}
|
||||
[status-bar/status-bar {:type :wallet}]
|
||||
[toolbar/toolbar {:style wallet.styles/toolbar}
|
||||
[toolbar/nav-button (actions/back-white #(do (re-frame/dispatch [:update-wallet])
|
||||
[toolbar/nav-button (actions/back-white #(do (when on-close
|
||||
(on-close (create-payload address)))
|
||||
(re-frame/dispatch [:update-wallet])
|
||||
(re-frame/dispatch [:navigate-back])))]
|
||||
[toolbar/content-title {:color colors/white}
|
||||
label]]
|
||||
[view {:address (ethereum/normalized-address address)}]]))
|
||||
[view (create-payload address)]]))
|
||||
|
||||
(defn- setting->action [{:keys [label] :as m}]
|
||||
(defn- setting->action [address {:keys [label on-open] :as m}]
|
||||
{:label label
|
||||
:action #(re-frame/dispatch [:navigate-to :wallet-settings-hook m])})
|
||||
:action #(do
|
||||
(when on-open
|
||||
(on-open address))
|
||||
(re-frame/dispatch [:navigate-to :wallet-settings-hook m]))})
|
||||
|
||||
(defview toolbar-view []
|
||||
(letsubs [settings [:wallet/settings]]
|
||||
(letsubs [settings [:wallet/settings]
|
||||
{address :address} [:account/account]]
|
||||
[toolbar/toolbar {:style wallet.styles/toolbar :flat? true}
|
||||
nil
|
||||
[toolbar/content-wrapper]
|
||||
|
@ -82,4 +93,4 @@
|
|||
:accessibility-label :options-menu-button}
|
||||
:options (into [{:label (i18n/label :t/wallet-manage-assets)
|
||||
:action #(re-frame/dispatch [:navigate-to :wallet-settings-assets])}]
|
||||
(map setting->action settings))}]]]))
|
||||
(map #(setting->action address %) settings))}]]]))
|
||||
|
|
|
@ -136,7 +136,9 @@
|
|||
(.getGasPrice (.-eth web3) cb))
|
||||
|
||||
(defn estimate-gas-web3 [web3 obj cb]
|
||||
(.estimateGas (.-eth web3) obj cb))
|
||||
(try
|
||||
(.estimateGas (.-eth web3) obj cb)
|
||||
(catch :default _)))
|
||||
|
||||
(defn estimate-gas [symbol]
|
||||
(if (tokens/ethereum? symbol)
|
||||
|
|
Loading…
Reference in New Issue