-
Notifications
You must be signed in to change notification settings - Fork 981
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Andrey Shovkoplyas <motor4ik@gmail.com>
- Loading branch information
1 parent
8395b2f
commit f80e901
Showing
6 changed files
with
148 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
(ns status-im.extensions.ethereum | ||
(:require [status-im.utils.handlers :as handlers] | ||
[re-frame.core :as re-frame] | ||
[status-im.models.wallet :as models.wallet] | ||
[status-im.utils.ethereum.abi-spec :as abi-spec] | ||
[status-im.utils.fx :as fx] | ||
[status-im.ui.screens.navigation :as navigation])) | ||
|
||
(handlers/register-handler-fx | ||
:extensions/transaction-on-result | ||
(fn [cofx [_ on-result id result method]] | ||
(fx/merge cofx | ||
(when on-result | ||
{:dispatch (on-result {:error nil :result result})}) | ||
(navigation/navigate-to-clean :wallet-transaction-sent nil)))) | ||
|
||
(handlers/register-handler-fx | ||
:extensions/transaction-on-error | ||
(fn [{db :db} [_ on-result message]] | ||
(when on-result {:dispatch (on-result {:error message :result nil})}))) | ||
|
||
(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)] | ||
(models.wallet/open-modal-wallet-for-transaction db transaction tx-object)))) | ||
|
||
(handlers/register-handler-fx | ||
:extensions/ethereum-call | ||
(fn [_ [_ {:keys [to method params on-result]}]] | ||
(let [tx-object {:to to :data (when method (abi-spec/encode method params))}] | ||
{:browser/call-rpc [{"jsonrpc" "2.0" | ||
"method" "eth_call" | ||
"params" [tx-object "latest"]} | ||
#(when on-result | ||
(re-frame/dispatch (on-result {:error %1 :result (when %2 | ||
(get (js->clj %2) "result"))})))]}))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters