Signed-off-by: Andrey Shovkoplyas <motor4ik@gmail.com>
This commit is contained in:
parent
d794fccae7
commit
55d3095b7a
|
@ -235,6 +235,7 @@
|
|||
:wallet-transaction-sent-modal
|
||||
:wallet-send-transaction-request
|
||||
:wallet-transaction-fee
|
||||
:wallet-sign-message-modal
|
||||
:contact-code) styles/color-blue4
|
||||
(:qr-viewer
|
||||
:recipient-qr-code) "#2f3031"
|
||||
|
|
|
@ -17,7 +17,7 @@ dependencies {
|
|||
implementation 'com.github.ericwlange:AndroidJSCore:3.0.1'
|
||||
implementation 'status-im:function:0.0.1'
|
||||
|
||||
String statusGoVersion = 'develop-ge6610f3b'
|
||||
String statusGoVersion = 'develop-g4cc6028d'
|
||||
final String statusGoGroup = 'status-im', statusGoName = 'status-go'
|
||||
|
||||
// Check if the local status-go jar exists, and compile against that if it does
|
||||
|
|
|
@ -487,8 +487,8 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
|
|||
}
|
||||
|
||||
@ReactMethod
|
||||
public void completeTransactions(final String hashes, final String password, final Callback callback) {
|
||||
Log.d(TAG, "completeTransactions");
|
||||
public void approveSignRequests(final String hashes, final String password, final Callback callback) {
|
||||
Log.d(TAG, "approveSignRequests");
|
||||
if (!checkAvailability()) {
|
||||
callback.invoke(false);
|
||||
return;
|
||||
|
@ -497,7 +497,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
|
|||
Runnable r = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String res = Statusgo.CompleteTransactions(hashes, password);
|
||||
String res = Statusgo.ApproveSignRequests(hashes, password);
|
||||
callback.invoke(res);
|
||||
}
|
||||
};
|
||||
|
@ -507,8 +507,8 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
|
|||
|
||||
|
||||
@ReactMethod
|
||||
public void discardTransaction(final String id) {
|
||||
Log.d(TAG, "discardTransaction");
|
||||
public void discardSignRequest(final String id) {
|
||||
Log.d(TAG, "discardSignRequest");
|
||||
if (!checkAvailability()) {
|
||||
return;
|
||||
}
|
||||
|
@ -516,7 +516,7 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
|
|||
Runnable r = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Statusgo.DiscardTransaction(id);
|
||||
Statusgo.DiscardSignRequest(id);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -695,6 +695,19 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
|
|||
StatusThreadPoolExecutor.getInstance().execute(r);
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void sendWeb3PrivateRequest(final String payload, final Callback callback) {
|
||||
Runnable r = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String res = Statusgo.CallPrivateRPC(payload);
|
||||
callback.invoke(res);
|
||||
}
|
||||
};
|
||||
|
||||
StatusThreadPoolExecutor.getInstance().execute(r);
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void closeApplication() {
|
||||
System.exit(0);
|
||||
|
|
|
@ -323,26 +323,26 @@ RCT_EXPORT_METHOD(login:(NSString *)address
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
#pragma mark - Complete Transactions
|
||||
//////////////////////////////////////////////////////////////////// completeTransactions
|
||||
RCT_EXPORT_METHOD(completeTransactions:(NSString *)hashes
|
||||
#pragma mark - Approve Sign Requests
|
||||
//////////////////////////////////////////////////////////////////// approveSignRequests
|
||||
RCT_EXPORT_METHOD(approveSignRequests:(NSString *)hashes
|
||||
password:(NSString *)password
|
||||
callback:(RCTResponseSenderBlock)callback) {
|
||||
#if DEBUG
|
||||
NSLog(@"CompleteTransactions() method called");
|
||||
NSLog(@"ApproveSignRequests() method called");
|
||||
#endif
|
||||
char * result = CompleteTransactions((char *) [hashes UTF8String], (char *) [password UTF8String]);
|
||||
char * result = ApproveSignRequests((char *) [hashes UTF8String], (char *) [password UTF8String]);
|
||||
callback(@[[NSString stringWithUTF8String: result]]);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
#pragma mark - Discard Transaction
|
||||
//////////////////////////////////////////////////////////////////// discardTransaction
|
||||
RCT_EXPORT_METHOD(discardTransaction:(NSString *)id) {
|
||||
#pragma mark - Discard Sign Request
|
||||
//////////////////////////////////////////////////////////////////// discardSignRequest
|
||||
RCT_EXPORT_METHOD(discardSignRequest:(NSString *)id) {
|
||||
#if DEBUG
|
||||
NSLog(@"DiscardTransaction() method called");
|
||||
NSLog(@"DiscardSignRequest() method called");
|
||||
#endif
|
||||
DiscardTransaction((char *) [id UTF8String]);
|
||||
DiscardSignRequest((char *) [id UTF8String]);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
@ -396,6 +396,16 @@ RCT_EXPORT_METHOD(sendWeb3Request:(NSString *)payload
|
|||
});
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(sendWeb3PrivateRequest:(NSString *)payload
|
||||
callback:(RCTResponseSenderBlock)callback) {
|
||||
dispatch_async( dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
char * result = CallPrivateRPC((char *) [payload UTF8String]);
|
||||
dispatch_async( dispatch_get_main_queue(), ^{
|
||||
callback(@[[NSString stringWithUTF8String: result]]);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(closeApplication) {
|
||||
exit(0);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
<artifactItem>
|
||||
<groupId>status-im</groupId>
|
||||
<artifactId>status-go-ios-simulator</artifactId>
|
||||
<version>develop-ge6610f3b</version>
|
||||
<version>develop-g4cc6028d</version>
|
||||
<type>zip</type>
|
||||
<overWrite>true</overWrite>
|
||||
<outputDirectory>./</outputDirectory>
|
||||
|
|
|
@ -112,4 +112,7 @@
|
|||
(def ^:const send-transaction-timeout-error-code "3")
|
||||
(def ^:const send-transaction-discarded-error-code "4")
|
||||
|
||||
(def ^:const web3-send-transaction "eth_sendTransaction")
|
||||
(def ^:const web3-personal-sign "personal_sign")
|
||||
|
||||
(def regx-emoji #"^((?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC69\uDC6E\uDC70-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD18-\uDD1C\uDD1E\uDD1F\uDD26\uDD30-\uDD39\uDD3D\uDD3E\uDDD1-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])?|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDEEB\uDEEC\uDEF4-\uDEF8]|\uD83E[\uDD10-\uDD3A\uDD3C-\uDD3E\uDD40-\uDD45\uDD47-\uDD4C\uDD50-\uDD6B\uDD80-\uDD97\uDDC0\uDDD0-\uDDE6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u2660\u2663\u2665\u2666\u2668\u267B\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEF8]|\uD83E[\uDD10-\uDD3A\uDD3C-\uDD3E\uDD40-\uDD45\uDD47-\uDD4C\uDD50-\uDD6B\uDD80-\uDD97\uDDC0\uDDD0-\uDDE6])\uFE0F|[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF])+$")
|
||||
|
|
|
@ -48,13 +48,12 @@
|
|||
(module-interface/-login rns-module address password callback))
|
||||
|
||||
|
||||
(defn complete-transactions [hashes password callback]
|
||||
(module-interface/-complete-transactions rns-module hashes password callback))
|
||||
(defn approve-sign-requests [hashes password callback]
|
||||
(module-interface/-approve-sign-requests rns-module hashes password callback))
|
||||
|
||||
|
||||
(defn discard-transaction [id]
|
||||
(module-interface/-discard-transaction rns-module id))
|
||||
|
||||
(defn discard-sign-request [id]
|
||||
(module-interface/-discard-sign-request rns-module id))
|
||||
|
||||
(defn parse-jail [chat-id file callback]
|
||||
(module-interface/-parse-jail rns-module chat-id file callback))
|
||||
|
@ -78,6 +77,9 @@
|
|||
(defn call-web3 [payload callback]
|
||||
(module-interface/-call-web3 rns-module payload callback))
|
||||
|
||||
(defn call-web3-private [payload callback]
|
||||
(module-interface/-call-web3-private rns-module payload callback))
|
||||
|
||||
(defn module-initialized! []
|
||||
(module-interface/-module-initialized! rns-module))
|
||||
|
||||
|
|
|
@ -120,17 +120,17 @@
|
|||
(when status
|
||||
(call-module #(.login status address password on-result))))
|
||||
|
||||
(defn complete-transactions
|
||||
(defn approve-sign-requests
|
||||
[hashes password callback]
|
||||
(log/debug :complete-transactions (boolean status) hashes)
|
||||
(log/debug :approve-sign-requests (boolean status) hashes)
|
||||
(when status
|
||||
(call-module #(.completeTransactions status (types/clj->json hashes) password callback))))
|
||||
(call-module #(.approveSignRequests status (types/clj->json hashes) password callback))))
|
||||
|
||||
(defn discard-transaction
|
||||
(defn discard-sign-request
|
||||
[id]
|
||||
(log/debug :discard-transaction id)
|
||||
(log/debug :discard-sign-request id)
|
||||
(when status
|
||||
(call-module #(.discardTransaction status id))))
|
||||
(call-module #(.discardSignRequest status id))))
|
||||
|
||||
(defn- append-catalog-init [js]
|
||||
(str js "\n" "var catalog = JSON.stringify(_status_catalog); catalog;"))
|
||||
|
@ -230,6 +230,10 @@
|
|||
(when status
|
||||
(call-module #(.sendWeb3Request status payload callback))))
|
||||
|
||||
(defn call-web3-private [payload callback]
|
||||
(when status
|
||||
(call-module #(.sendWeb3PrivateRequest status payload callback))))
|
||||
|
||||
(defn close-application []
|
||||
(.closeApplication status))
|
||||
|
||||
|
@ -254,10 +258,10 @@
|
|||
(recover-account passphrase password callback))
|
||||
(-login [this address password callback]
|
||||
(login address password callback))
|
||||
(-complete-transactions [this hashes password callback]
|
||||
(complete-transactions hashes password callback))
|
||||
(-discard-transaction [this id]
|
||||
(discard-transaction id))
|
||||
(-approve-sign-requests [this hashes password callback]
|
||||
(approve-sign-requests hashes password callback))
|
||||
(-discard-sign-request [this id]
|
||||
(discard-sign-request id))
|
||||
(-parse-jail [this chat-id file callback]
|
||||
(parse-jail chat-id file callback))
|
||||
(-call-jail [this params]
|
||||
|
@ -266,6 +270,8 @@
|
|||
(call-function! params))
|
||||
(-call-web3 [this payload callback]
|
||||
(call-web3 payload callback))
|
||||
(-call-web3-private [this payload callback]
|
||||
(call-web3-private payload callback))
|
||||
(-notify-users [this {:keys [message payload tokens] :as m} callback]
|
||||
(notify-users m callback))
|
||||
(-add-peer [this enode callback]
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
(if (not= password wrong-password)
|
||||
(callback "{\"error\":\"\"}")
|
||||
(callback "{\"error\":\"cannot retrieve a valid key for a given account: could not decrypt key with given passphrase\"}")))
|
||||
(-complete-transactions [this hashes password callback])
|
||||
(-discard-transaction [this id])
|
||||
(-approve-sign-requests [this hashes password callback])
|
||||
(-discard-sign-request [this id])
|
||||
(-parse-jail [this chat-id file callback]
|
||||
(when (= chat-id constants/console-chat-id)
|
||||
(callback "{\"result\":\"{\\\"commands\\\":{\\\"phone,50\\\":{\\\"name\\\":\\\"phone\\\",\\\"title\\\":\\\"Send Phone Number\\\",\\\"description\\\":\\\"Find friends using your number\\\",\\\"has-handler\\\":true,\\\"async-handler\\\":false,\\\"color\\\":\\\"#5bb2a2\\\",\\\"icon\\\":\\\"phone_white\\\",\\\"params\\\":[{\\\"name\\\":\\\"phone\\\",\\\"type\\\":\\\"phone\\\",\\\"placeholder\\\":\\\"Phone number\\\"}],\\\"sequential-params\\\":true,\\\"scope\\\":[\\\"personal-chats\\\",\\\"registered\\\",\\\"dapps\\\"],\\\"scope-bitmask\\\":50},\\\"faucet,50\\\":{\\\"name\\\":\\\"faucet\\\",\\\"title\\\":\\\"Faucet\\\",\\\"description\\\":\\\"Get some ETH\\\",\\\"has-handler\\\":true,\\\"async-handler\\\":false,\\\"color\\\":\\\"#7099e6\\\",\\\"params\\\":[{\\\"name\\\":\\\"url\\\",\\\"type\\\":\\\"text\\\",\\\"placeholder\\\":\\\"Faucet URL\\\"}],\\\"scope\\\":[\\\"personal-chats\\\",\\\"registered\\\",\\\"dapps\\\"],\\\"scope-bitmask\\\":50},\\\"debug,50\\\":{\\\"name\\\":\\\"debug\\\",\\\"title\\\":\\\"Debug mode\\\",\\\"description\\\":\\\"Starts\\/stops a debug mode\\\",\\\"has-handler\\\":true,\\\"async-handler\\\":false,\\\"color\\\":\\\"#7099e6\\\",\\\"params\\\":[{\\\"name\\\":\\\"mode\\\",\\\"type\\\":\\\"text\\\"}],\\\"scope\\\":[\\\"personal-chats\\\",\\\"registered\\\",\\\"dapps\\\"],\\\"scope-bitmask\\\":50}},\\\"responses\\\":{\\\"phone,50\\\":{\\\"name\\\":\\\"phone\\\",\\\"title\\\":\\\"Send Phone Number\\\",\\\"description\\\":\\\"Find friends using your number\\\",\\\"has-handler\\\":true,\\\"async-handler\\\":false,\\\"color\\\":\\\"#5bb2a2\\\",\\\"icon\\\":\\\"phone_white\\\",\\\"params\\\":[{\\\"name\\\":\\\"phone\\\",\\\"type\\\":\\\"phone\\\",\\\"placeholder\\\":\\\"Phone number\\\"}],\\\"sequential-params\\\":true,\\\"scope\\\":[\\\"personal-chats\\\",\\\"registered\\\",\\\"dapps\\\"],\\\"scope-bitmask\\\":50},\\\"confirmation-code,50\\\":{\\\"name\\\":\\\"confirmation-code\\\",\\\"description\\\":\\\"Confirmation code\\\",\\\"has-handler\\\":true,\\\"async-handler\\\":false,\\\"color\\\":\\\"#7099e6\\\",\\\"params\\\":[{\\\"name\\\":\\\"code\\\",\\\"type\\\":\\\"number\\\"}],\\\"sequential-params\\\":true,\\\"scope\\\":[\\\"personal-chats\\\",\\\"registered\\\",\\\"dapps\\\"],\\\"scope-bitmask\\\":50},\\\"password,42\\\":{\\\"name\\\":\\\"password\\\",\\\"description\\\":\\\"Password\\\",\\\"has-handler\\\":true,\\\"async-handler\\\":false,\\\"color\\\":\\\"#7099e6\\\",\\\"icon\\\":\\\"lock_white\\\",\\\"params\\\":[{\\\"name\\\":\\\"password\\\",\\\"type\\\":\\\"password\\\",\\\"placeholder\\\":\\\"Type your password\\\",\\\"hidden\\\":true},{\\\"name\\\":\\\"password-confirmation\\\",\\\"type\\\":\\\"password\\\",\\\"placeholder\\\":\\\"Confirm\\\",\\\"hidden\\\":true}],\\\"sequential-params\\\":true,\\\"scope\\\":[\\\"personal-chats\\\",\\\"anonymous\\\",\\\"dapps\\\"],\\\"scope-bitmask\\\":42},\\\"grant-permissions,58\\\":{\\\"name\\\":\\\"grant-permissions\\\",\\\"description\\\":\\\"Grant permissions\\\",\\\"has-handler\\\":true,\\\"async-handler\\\":false,\\\"color\\\":\\\"#7099e6\\\",\\\"icon\\\":\\\"lock_white\\\",\\\"params\\\":[],\\\"execute-immediately?\\\":true,\\\"scope\\\":[\\\"personal-chats\\\",\\\"anonymous\\\",\\\"registered\\\",\\\"dapps\\\"],\\\"scope-bitmask\\\":58}},\\\"functions\\\":{},\\\"subscriptions\\\":{}}\"}")))
|
||||
|
@ -46,6 +46,7 @@
|
|||
:else (callback {:result nil})))
|
||||
(-call-function! [this params])
|
||||
(-call-web3 [this payload callback])
|
||||
(-call-web3-private [this payload callback])
|
||||
|
||||
;; other calls
|
||||
(-move-to-internal-storage [this callback]
|
||||
|
|
|
@ -8,14 +8,15 @@
|
|||
(-create-account [this password callback])
|
||||
(-recover-account [this passphrase password callback])
|
||||
(-login [this address password callback])
|
||||
(-complete-transactions [this hashes password callback])
|
||||
(-discard-transaction [this id])
|
||||
(-approve-sign-requests [this hashes password callback])
|
||||
(-discard-sign-request [this id])
|
||||
(-parse-jail [this chat-id file callback])
|
||||
(-call-jail [this params])
|
||||
(-call-function! [this params])
|
||||
(-set-soft-input-mode [this mode])
|
||||
(-clear-web-data [this])
|
||||
(-call-web3 [this payload callback])
|
||||
(-call-web3-private [this payload callback])
|
||||
(-module-initialized! [this])
|
||||
(-should-move-to-internal-storage? [this callback])
|
||||
(-notify-users [this {:keys [message payload tokens] :as m} callback])
|
||||
|
|
|
@ -401,6 +401,8 @@
|
|||
:wallet-total-value "Total value"
|
||||
:wallet-settings "Wallet settings"
|
||||
:wallet-manage-assets "Manage Assets"
|
||||
:sign-message "Sign Message"
|
||||
:signing-message-phrase-description "Sign the message by entering your password. Make sure that the words above match your secret signing phrase"
|
||||
:signing-phrase-description "Sign the transaction by entering your password. Make sure that the words above match your secret signing phrase"
|
||||
:wallet-insufficient-funds "Insufficient funds"
|
||||
:receive "Receive"
|
||||
|
|
|
@ -64,7 +64,7 @@
|
|||
:method "admin_peers"
|
||||
:params []}
|
||||
payload (.stringify js/JSON (clj->js args))]
|
||||
(status/call-web3 payload (response-handler error-fn success-fn))))
|
||||
(status/call-web3-private payload (response-handler error-fn success-fn))))
|
||||
|
||||
(defn registered-peer? [peers enode]
|
||||
(let [peer-ids (into #{} (map :id) peers)
|
||||
|
|
|
@ -351,8 +351,8 @@
|
|||
(inst/log (str "Signal event: " event-str))
|
||||
(let [{:keys [type event]} (types/json->clj event-str)
|
||||
to-dispatch (case type
|
||||
"transaction.queued" [:transaction-queued event]
|
||||
"transaction.failed" [:transaction-failed event]
|
||||
"sign-request.queued" [:sign-request-queued event]
|
||||
"sign-request.failed" [:sign-request-failed event]
|
||||
"node.started" [:status-node-started]
|
||||
"node.stopped" [:status-node-stopped]
|
||||
"module.initialized" [:status-module-initialized]
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
[status-im.ui.screens.profile.contact.views :as profile.contact]
|
||||
[status-im.ui.screens.profile.group-chat.views :as profile.group-chat]
|
||||
[status-im.ui.screens.profile.photo-capture.views :refer [profile-photo-capture]]
|
||||
[status-im.ui.screens.wallet.send.views :refer [send-transaction send-transaction-modal]]
|
||||
[status-im.ui.screens.wallet.send.views :refer [send-transaction send-transaction-modal sign-message-modal]]
|
||||
[status-im.ui.screens.wallet.choose-recipient.views :refer [choose-recipient]]
|
||||
[status-im.ui.screens.wallet.request.views :refer [request-transaction send-transaction-request]]
|
||||
[status-im.ui.screens.wallet.components.views :as wallet.components]
|
||||
|
@ -182,6 +182,7 @@
|
|||
:wallet-settings-assets wallet-settings/manage-assets
|
||||
:wallet-send-transaction-modal send-transaction-modal
|
||||
:wallet-transaction-sent-modal transaction-sent-modal
|
||||
:wallet-sign-message-modal sign-message-modal
|
||||
:wallet-transaction-fee wallet.send/transaction-fee
|
||||
[react/view [react/text (str "Unknown modal view: " modal-view)]])]
|
||||
[react/main-screen-modal-view modal-view
|
||||
|
|
|
@ -23,10 +23,11 @@
|
|||
(spec/def ::gas-price (spec/nilable money/valid?))
|
||||
(spec/def ::advanced? boolean?)
|
||||
(spec/def ::whisper-identity (spec/nilable string?))
|
||||
(spec/def ::method (spec/nilable string?))
|
||||
|
||||
(spec/def :wallet/send-transaction (allowed-keys
|
||||
:opt-un [::amount ::to ::to-name ::amount-error ::password
|
||||
::waiting-signal? ::signing? ::id ::later?
|
||||
::camera-flashlight ::in-progress?
|
||||
::wrong-password? ::from-chat? ::symbol ::advanced?
|
||||
::gas ::gas-price ::whisper-identity]))
|
||||
::gas ::gas-price ::whisper-identity ::method]))
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
(re-frame/reg-fx
|
||||
::accept-transaction
|
||||
(fn [{:keys [password id on-completed]}]
|
||||
(status/complete-transactions (list id) password on-completed)))
|
||||
(status/approve-sign-requests (list id) password on-completed)))
|
||||
|
||||
(defn- send-ethers [{:keys [web3 from to value gas gas-price]}]
|
||||
(.sendTransaction (.-eth web3)
|
||||
|
@ -52,7 +52,7 @@
|
|||
(re-frame/reg-fx
|
||||
:discard-transaction
|
||||
(fn [id]
|
||||
(status/discard-transaction id)))
|
||||
(status/discard-sign-request id)))
|
||||
|
||||
;;Helper functions
|
||||
|
||||
|
@ -95,10 +95,12 @@
|
|||
|
||||
;;TRANSACTION QUEUED signal from status-go
|
||||
(handlers/register-handler-fx
|
||||
:transaction-queued
|
||||
:sign-request-queued
|
||||
[(re-frame/inject-cofx :now)]
|
||||
(fn [{:keys [db now]} [_ {:keys [id message_id args] :as transaction}]]
|
||||
(if (transaction-valid? transaction)
|
||||
(fn [{:keys [db now]} [_ {:keys [id message_id method args]}]]
|
||||
(cond
|
||||
|
||||
(= method constants/web3-send-transaction)
|
||||
;;NOTE(goranjovic): the transactions started from chat using /send command
|
||||
;; are only in ether, so this parameter defaults to ETH
|
||||
(let [{:keys [from to value symbol data gas gasPrice] :or {symbol :ETH}} args
|
||||
|
@ -120,6 +122,7 @@
|
|||
sending-from-bot-or-dapp? (not (get-in db [:wallet :send-transaction :waiting-signal?]))
|
||||
new-db (assoc-in db [:wallet :transactions-unsigned id] transaction)
|
||||
sending-db {:id id
|
||||
:method method
|
||||
:from-chat? sending-from-bot-or-dapp?}]
|
||||
(if sending-from-bot-or-dapp?
|
||||
;;SENDING FROM BOT (CHAT) OR DAPP
|
||||
|
@ -143,17 +146,25 @@
|
|||
::accept-transaction {:id id
|
||||
:password password
|
||||
:on-completed on-transactions-completed}}))))
|
||||
{:discard-transaction id})))
|
||||
|
||||
(= method constants/web3-personal-sign)
|
||||
|
||||
(let [{:keys [data]} args]
|
||||
{:db (-> db
|
||||
(assoc-in [:wallet :transactions-unsigned id] {:data data :id id})
|
||||
(assoc-in [:wallet :send-transaction] {:id id :method method}))
|
||||
:dispatch [:navigate-to-modal :wallet-sign-message-modal]}))))
|
||||
|
||||
(defn this-transaction-signing? [id signing-id view-id modal]
|
||||
(and (= signing-id id)
|
||||
(or (= view-id :wallet-send-transaction)
|
||||
(= modal :wallet-send-transaction-modal))))
|
||||
(= modal :wallet-send-transaction-modal)
|
||||
(= modal :wallet-sign-message-modal))))
|
||||
|
||||
;;TRANSACTION FAILED signal from status-go
|
||||
(handlers/register-handler-fx
|
||||
:transaction-failed
|
||||
(fn [{{:keys [view-id modal] :as db} :db} [_ {:keys [id error_code error_message]}]]
|
||||
:sign-request-failed
|
||||
(fn [{{:keys [view-id modal] :as db} :db} [_ {:keys [id method error_code error_message]}]]
|
||||
(let [send-transaction (get-in db [:wallet :send-transaction])]
|
||||
(case error_code
|
||||
|
||||
|
@ -163,11 +174,12 @@
|
|||
|
||||
;;NO ERROR, DISCARDED, TIMEOUT or DEFAULT ERROR
|
||||
(if (this-transaction-signing? id (:id send-transaction) view-id modal)
|
||||
{:db (-> db
|
||||
(update-in [:wallet :transactions-unsigned] dissoc id)
|
||||
(update-in [:wallet :send-transaction] merge clear-send-properties))
|
||||
:dispatch [:navigate-back]
|
||||
::show-transaction-error error_message}
|
||||
(cond-> {:db (-> db
|
||||
(update-in [:wallet :transactions-unsigned] dissoc id)
|
||||
(update-in [:wallet :send-transaction] merge clear-send-properties))
|
||||
:dispatch [:navigate-back]}
|
||||
(= method constants/web3-send-transaction)
|
||||
(assoc ::show-transaction-error error_message))
|
||||
{:db (update-in db [:wallet :transactions-unsigned] dissoc id)})))))
|
||||
|
||||
(defn prepare-unconfirmed-transaction [db now hash id]
|
||||
|
@ -186,6 +198,7 @@
|
|||
::transaction-completed
|
||||
(fn [{db :db now :now} [_ {:keys [id response]} modal?]]
|
||||
(let [{:keys [hash error]} response
|
||||
{:keys [method]} (get-in db [:wallet :send-transaction])
|
||||
db' (assoc-in db [:wallet :send-transaction :in-progress?] false)]
|
||||
(if (and error (string? error) (not (string/blank? error))) ;; ignore error here, error will be handled in :transaction-failed
|
||||
{:db db'}
|
||||
|
@ -195,8 +208,9 @@
|
|||
(update-in [:wallet :transactions-unsigned] dissoc id)
|
||||
(update-in [:wallet :send-transaction] merge clear-send-properties))}
|
||||
(if modal?
|
||||
{:dispatch [:navigate-back]
|
||||
:dispatch-later [{:ms 400 :dispatch [:navigate-to-modal :wallet-transaction-sent-modal]}]}
|
||||
(cond-> {:dispatch [:navigate-back]}
|
||||
(= method constants/web3-send-transaction)
|
||||
(assoc :dispatch-later [{:ms 400 :dispatch [:navigate-to-modal :wallet-transaction-sent-modal]}]))
|
||||
{:dispatch [:navigate-to :wallet-transaction-sent]}))))))
|
||||
|
||||
(defn on-transactions-modal-completed [raw-results]
|
||||
|
@ -231,8 +245,7 @@
|
|||
|
||||
(handlers/register-handler-fx
|
||||
:wallet/sign-transaction-modal
|
||||
(fn [{{:keys [web3]
|
||||
:accounts/keys [accounts current-account-id] :as db} :db} [_ later?]]
|
||||
(fn [{db :db} _]
|
||||
(let [{:keys [id password]} (get-in db [:wallet :send-transaction])]
|
||||
{:db (assoc-in db [:wallet :send-transaction :in-progress?] true)
|
||||
::accept-transaction {:id id
|
||||
|
|
|
@ -20,18 +20,19 @@
|
|||
[status-im.ui.screens.wallet.send.styles :as styles]
|
||||
[status-im.ui.screens.wallet.styles :as wallet.styles]
|
||||
[status-im.utils.money :as money]
|
||||
[status-im.utils.utils :as utils]))
|
||||
[status-im.utils.utils :as utils]
|
||||
[status-im.transport.utils :as transport.utils]))
|
||||
|
||||
(defn sign-later-popup
|
||||
[from-chat?]
|
||||
(utils/show-question
|
||||
(i18n/label :t/sign-later-title)
|
||||
(i18n/label :t/sign-later-text)
|
||||
#(re-frame/dispatch (if from-chat?
|
||||
[:navigate-back]
|
||||
[:wallet/sign-transaction true]))))
|
||||
(i18n/label :t/sign-later-title)
|
||||
(i18n/label :t/sign-later-text)
|
||||
#(re-frame/dispatch (if from-chat?
|
||||
[:navigate-back]
|
||||
[:wallet/sign-transaction true]))))
|
||||
|
||||
(defview sign-panel []
|
||||
(defview sign-panel [message?]
|
||||
(letsubs [account [:get-current-account]
|
||||
wrong-password? [:wallet.send/wrong-password?]
|
||||
signing-phrase (:signing-phrase @account)
|
||||
|
@ -44,7 +45,9 @@
|
|||
[react/text {:style styles/signing-phrase
|
||||
:accessibility-label :signing-phrase-text}
|
||||
signing-phrase]]
|
||||
[react/text {:style styles/signing-phrase-description} (i18n/label :t/signing-phrase-description)]
|
||||
[react/text {:style styles/signing-phrase-description} (i18n/label (if message?
|
||||
:t/signing-message-phrase-description
|
||||
:t/signing-phrase-description))]
|
||||
[react/view styles/password-container
|
||||
[react/text-input
|
||||
{:auto-focus true
|
||||
|
@ -58,7 +61,7 @@
|
|||
[tooltip/tooltip (i18n/label :t/wrong-password)])]))
|
||||
|
||||
;; "Cancel" and "Sign Transaction >" buttons, signing with password
|
||||
(defview signing-buttons [cancel-handler sign-handler in-progress?]
|
||||
(defview signing-buttons [cancel-handler sign-handler & [sign-label]]
|
||||
(letsubs [sign-enabled? [:wallet.send/sign-password-enabled?]]
|
||||
[bottom-buttons/bottom-buttons
|
||||
styles/sign-buttons
|
||||
|
@ -69,18 +72,18 @@
|
|||
[button/button {:style (wallet.styles/button-container sign-enabled?)
|
||||
:on-press sign-handler
|
||||
:accessibility-label :sign-transaction-button}
|
||||
(i18n/label :t/transactions-sign-transaction)
|
||||
(i18n/label (or sign-label :t/transactions-sign-transaction))
|
||||
[vector-icons/icon :icons/forward {:color :white}]]]))
|
||||
|
||||
(defn- sign-enabled? [amount-error to amount]
|
||||
(and
|
||||
(nil? amount-error)
|
||||
(not (nil? to)) (not= to "")
|
||||
(not (nil? amount))))
|
||||
(nil? amount-error)
|
||||
(not (nil? to)) (not= to "")
|
||||
(not (nil? amount))))
|
||||
|
||||
;; "Sign Later" and "Sign Transaction >" buttons
|
||||
(defn- sign-buttons [amount-error to amount sufficient-funds? sign-later-handler]
|
||||
(let [sign-enabled? (sign-enabled? amount-error to amount)
|
||||
(let [sign-enabled? (sign-enabled? amount-error to amount)
|
||||
immediate-sign-enabled? (and sign-enabled? sufficient-funds?)]
|
||||
[bottom-buttons/bottom-buttons
|
||||
styles/sign-buttons
|
||||
|
@ -114,7 +117,7 @@
|
|||
(defview transaction-fee []
|
||||
(letsubs [{:keys [amount symbol] :as transaction} [:wallet.send/transaction]
|
||||
edit [:wallet/edit]]
|
||||
(let [gas (or (:gas edit) (:gas transaction))
|
||||
(let [gas (or (:gas edit) (:gas transaction))
|
||||
gas-price (or (:gas-price edit) (:gas-price transaction))]
|
||||
[wallet.components/simple-screen {:status-toolbar-type :modal-wallet}
|
||||
[toolbar true act/close-white
|
||||
|
@ -141,7 +144,7 @@
|
|||
[react/text {:style styles/transaction-fee-info-icon-text} "?"]]
|
||||
[react/view styles/transaction-fee-info-text-wrapper
|
||||
[react/text {:style styles/advanced-fees-text}
|
||||
(i18n/label :t/wallet-transaction-fee-details)]]]
|
||||
(i18n/label :t/wallet-transaction-fee-details)]]]
|
||||
[components/separator]
|
||||
[react/view styles/transaction-fee-block-wrapper
|
||||
[wallet.components/cartouche {:disabled? true}
|
||||
|
@ -173,7 +176,7 @@
|
|||
[react/view {:style styles/advanced-options-text-wrapper
|
||||
:accessibility-label :transaction-fee-button}
|
||||
[react/text {:style styles/advanced-fees-text}
|
||||
(str (money/to-fixed (max-fee gas gas-price)) " " (i18n/label :t/eth))]
|
||||
(str (money/to-fixed (max-fee gas gas-price)) " " (i18n/label :t/eth))]
|
||||
[react/text {:style styles/advanced-fees-details-text}
|
||||
(str (money/to-fixed gas) " * " (money/to-fixed (money/wei-> :gwei gas-price)) (i18n/label :t/gwei))]]]])
|
||||
|
||||
|
@ -220,28 +223,27 @@
|
|||
(if signing?
|
||||
[signing-buttons
|
||||
#(re-frame/dispatch (if modal? [:wallet/cancel-signing-modal] [:wallet/discard-transaction]))
|
||||
#(re-frame/dispatch (if modal? [:wallet/sign-transaction-modal] [:wallet/sign-transaction]))
|
||||
in-progress?]
|
||||
#(re-frame/dispatch (if modal? [:wallet/sign-transaction-modal] [:wallet/sign-transaction]))]
|
||||
[sign-buttons amount-error to amount sufficient-funds? (if modal? (if from-chat?
|
||||
#(sign-later-popup true)
|
||||
#(re-frame/dispatch [:navigate-back]))
|
||||
#(sign-later-popup false))])
|
||||
#(sign-later-popup false))])
|
||||
(when signing?
|
||||
[sign-panel])
|
||||
(when in-progress? [react/view styles/processing-view])]]))
|
||||
|
||||
(defview send-transaction []
|
||||
(letsubs [transaction [:wallet.send/transaction]
|
||||
symbol [:wallet.send/symbol]
|
||||
advanced? [:wallet.send/advanced?]
|
||||
scroll (atom nil)]
|
||||
symbol [:wallet.send/symbol]
|
||||
advanced? [:wallet.send/advanced?]
|
||||
scroll (atom nil)]
|
||||
[send-transaction-panel {:modal? false :transaction transaction :scroll scroll :advanced? advanced? :symbol symbol}]))
|
||||
|
||||
(defview send-transaction-modal []
|
||||
(letsubs [transaction [:wallet.send/unsigned-transaction]
|
||||
symbol [:wallet.send/symbol]
|
||||
advanced? [:wallet.send/advanced?]
|
||||
scroll (atom nil)]
|
||||
symbol [:wallet.send/symbol]
|
||||
advanced? [:wallet.send/advanced?]
|
||||
scroll (atom nil)]
|
||||
(if transaction
|
||||
[send-transaction-panel {:modal? true :transaction transaction :scroll scroll :advanced? advanced? :symbol symbol}]
|
||||
[react/view wallet.styles/wallet-modal-container
|
||||
|
@ -250,3 +252,24 @@
|
|||
[toolbar false act/close-white
|
||||
(i18n/label :t/send-transaction)]
|
||||
[react/text {:style styles/empty-text} (i18n/label :t/unsigned-transaction-expired)]]])))
|
||||
|
||||
(defview sign-message-modal []
|
||||
(letsubs [{:keys [data in-progress?]} [:wallet.send/unsigned-transaction]]
|
||||
[wallet.components/simple-screen {:status-bar-type :modal-wallet}
|
||||
[toolbar true act/close-white
|
||||
(i18n/label :t/sign-message)]
|
||||
[react/view components.styles/flex
|
||||
[react/scroll-view
|
||||
[react/view styles/send-transaction-form
|
||||
[wallet.components/cartouche {:disabled? true}
|
||||
(i18n/label :t/message)
|
||||
[components/amount-input {:disabled? true
|
||||
:input-options {:multiline true
|
||||
:default-value (transport.utils/to-utf8 data)}}]]]]
|
||||
[signing-buttons
|
||||
#(re-frame/dispatch [:wallet/discard-transaction-navigate-back])
|
||||
#(re-frame/dispatch [:wallet/sign-transaction-modal])
|
||||
:t/transactions-sign]
|
||||
[sign-panel true]
|
||||
(when in-progress?
|
||||
[react/view styles/processing-view])]]))
|
||||
|
|
|
@ -110,5 +110,5 @@
|
|||
(.round bn decimals)))
|
||||
|
||||
(defn sufficient-funds? [amount balance]
|
||||
(when balance
|
||||
(when (and amount balance)
|
||||
(.greaterThanOrEqualTo balance amount)))
|
||||
|
|
Loading…
Reference in New Issue