mirror of
https://github.com/status-im/status-react.git
synced 2025-01-09 10:42:53 +00:00
clean up native-module
- remove impl/modules.cljs namespace because it was needlessly redundant - remove `create-account` unused call - add documentation for some calls - only keep `(status)` check for relevant calls that are failing tests because they are evaluated
This commit is contained in:
parent
dbf8d60f8b
commit
d312192209
@ -450,26 +450,6 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
|
|||||||
StatusThreadPoolExecutor.getInstance().execute(r);
|
StatusThreadPoolExecutor.getInstance().execute(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ReactMethod
|
|
||||||
public void createAccount(final String password, final Callback callback) {
|
|
||||||
Log.d(TAG, "createAccount");
|
|
||||||
if (!checkAvailability()) {
|
|
||||||
callback.invoke(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Runnable r = new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
String res = Statusgo.createAccount(password);
|
|
||||||
|
|
||||||
callback.invoke(res);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
StatusThreadPoolExecutor.getInstance().execute(r);
|
|
||||||
}
|
|
||||||
|
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void sendDataNotification(final String dataPayloadJSON, final String tokensJSON, final Callback callback) {
|
public void sendDataNotification(final String dataPayloadJSON, final String tokensJSON, final Callback callback) {
|
||||||
Log.d(TAG, "sendDataNotification");
|
Log.d(TAG, "sendDataNotification");
|
||||||
|
@ -135,17 +135,6 @@ void RCTStatus::initKeystore() {
|
|||||||
logStatusGoResult("::initKeystore InitKeystore", result);
|
logStatusGoResult("::initKeystore InitKeystore", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RCTStatus::createAccount(QString password, double callbackId) {
|
|
||||||
Q_D(RCTStatus);
|
|
||||||
qCInfo(RCTSTATUS) << "::createAccount call - callbackId:" << callbackId;
|
|
||||||
QtConcurrent::run([&](QString password, double callbackId) {
|
|
||||||
const char* result = CreateAccount(password.toUtf8().data());
|
|
||||||
logStatusGoResult("::createAccount CreateAccount", result);
|
|
||||||
d->bridge->invokePromiseCallback(callbackId, QVariantList{result});
|
|
||||||
}, password, callbackId);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void RCTStatus::sendDataNotification(QString dataPayloadJSON, QString tokensJSON, double callbackId) {
|
void RCTStatus::sendDataNotification(QString dataPayloadJSON, QString tokensJSON, double callbackId) {
|
||||||
Q_D(RCTStatus);
|
Q_D(RCTStatus);
|
||||||
qCDebug(RCTSTATUS) << "::sendDataNotification call - callbackId:" << callbackId;
|
qCDebug(RCTSTATUS) << "::sendDataNotification call - callbackId:" << callbackId;
|
||||||
|
@ -36,7 +36,6 @@ public:
|
|||||||
QVariantMap constantsToExport() override;
|
QVariantMap constantsToExport() override;
|
||||||
|
|
||||||
Q_INVOKABLE void initKeystore();
|
Q_INVOKABLE void initKeystore();
|
||||||
Q_INVOKABLE void createAccount(QString password, double callbackId);
|
|
||||||
Q_INVOKABLE void sendDataNotification(QString dataPayloadJSON, QString tokensJSON, double callbackId);
|
Q_INVOKABLE void sendDataNotification(QString dataPayloadJSON, QString tokensJSON, double callbackId);
|
||||||
Q_INVOKABLE void sendLogs(QString dbJSON, QString jsLogs, double callbackId);
|
Q_INVOKABLE void sendLogs(QString dbJSON, QString jsLogs, double callbackId);
|
||||||
Q_INVOKABLE void addPeer(QString enode, double callbackId);
|
Q_INVOKABLE void addPeer(QString enode, double callbackId);
|
||||||
|
@ -128,18 +128,6 @@ RCT_EXPORT_METHOD(initKeystore) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
#pragma mark - Accounts method
|
|
||||||
//////////////////////////////////////////////////////////////////// createAccount
|
|
||||||
RCT_EXPORT_METHOD(createAccount:(NSString *)password
|
|
||||||
callback:(RCTResponseSenderBlock)callback) {
|
|
||||||
#if DEBUG
|
|
||||||
NSLog(@"CreateAccount() method called");
|
|
||||||
#endif
|
|
||||||
NSString *result = StatusgoCreateAccount(password);
|
|
||||||
callback(@[result]);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
#pragma mark - SendDataNotification method
|
#pragma mark - SendDataNotification method
|
||||||
//////////////////////////////////////////////////////////////////// sendDataNotification
|
//////////////////////////////////////////////////////////////////// sendDataNotification
|
||||||
|
@ -1,130 +1,238 @@
|
|||||||
(ns status-im.native-module.core
|
(ns status-im.native-module.core
|
||||||
(:require [status-im.native-module.impl.module :as native-module]))
|
(:require [status-im.ui.components.react :as r]
|
||||||
|
[re-frame.core :as re-frame]
|
||||||
|
[status-im.react-native.js-dependencies :as rn-dependencies]
|
||||||
|
[clojure.string :as string]
|
||||||
|
[status-im.utils.platform :as platform]
|
||||||
|
[status-im.utils.types :as types]))
|
||||||
|
|
||||||
|
(defn status []
|
||||||
|
(when (exists? (.-NativeModules rn-dependencies/react-native))
|
||||||
|
(.-Status (.-NativeModules rn-dependencies/react-native))))
|
||||||
|
|
||||||
(def adjust-resize 16)
|
(def adjust-resize 16)
|
||||||
|
|
||||||
|
(defn clear-web-data []
|
||||||
|
(when (status)
|
||||||
|
(.clearCookies (status))
|
||||||
|
(.clearStorageAPIs (status))))
|
||||||
|
|
||||||
(defn init-keystore []
|
(defn init-keystore []
|
||||||
(native-module/init-keystore))
|
(.initKeystore (status)))
|
||||||
|
|
||||||
(defn open-accounts [callback]
|
(defn open-accounts [callback]
|
||||||
(native-module/open-accounts callback))
|
(.openAccounts (status) #(callback (types/json->clj %))))
|
||||||
|
|
||||||
(defn prepare-dir-and-update-config [config callback]
|
(defn prepare-dir-and-update-config
|
||||||
(native-module/prepare-dir-and-update-config config callback))
|
[config callback]
|
||||||
|
(.prepareDirAndUpdateConfig (status)
|
||||||
|
config
|
||||||
|
#(callback (types/json->clj %))))
|
||||||
|
|
||||||
(defn save-account-and-login
|
(defn save-account-and-login
|
||||||
[multiaccount-data password config accounts-data]
|
[multiaccount-data password config accounts-data]
|
||||||
(native-module/save-account-and-login multiaccount-data password config accounts-data))
|
(clear-web-data)
|
||||||
|
(.saveAccountAndLogin (status) multiaccount-data password config accounts-data))
|
||||||
|
|
||||||
(defn login
|
(defn login
|
||||||
[account-data password]
|
[account-data password]
|
||||||
(native-module/login account-data password))
|
(clear-web-data)
|
||||||
|
(.login (status) account-data password))
|
||||||
|
|
||||||
(defn logout
|
(defn logout []
|
||||||
[]
|
(clear-web-data)
|
||||||
(native-module/logout))
|
(.logout (status)))
|
||||||
|
|
||||||
(defn node-ready [])
|
(defonce listener
|
||||||
|
(.addListener r/device-event-emitter "gethEvent"
|
||||||
|
#(re-frame/dispatch [:signals/signal-received (.-jsonEvent %)])))
|
||||||
|
|
||||||
(defn create-multiaccount [password callback]
|
(defn multiaccount-load-account
|
||||||
(native-module/create-account password callback))
|
"this function is used after storing an account when you still want to
|
||||||
|
derive accounts from it, because saving an account flushes the loaded keys
|
||||||
|
from memory"
|
||||||
|
[address password callback]
|
||||||
|
(.multiAccountLoadAccount (status)
|
||||||
|
(types/clj->json {:address address
|
||||||
|
:password password})
|
||||||
|
callback))
|
||||||
|
|
||||||
(defn multiaccount-load-account [address password callback]
|
(defn multiaccount-reset
|
||||||
(native-module/multiaccount-load-account address password callback))
|
"TODO: this function is not used anywhere
|
||||||
|
if usage isn't planned, remove"
|
||||||
|
[callback]
|
||||||
|
(.multiAccountReset (status)
|
||||||
|
callback))
|
||||||
|
|
||||||
(defn multiaccount-reset [callback]
|
(defn multiaccount-derive-addresses
|
||||||
(native-module/multiaccount-reset callback))
|
"NOTE: this should be named derive-accounts
|
||||||
|
this only derive addresses, they still need to be stored
|
||||||
|
with `multiaccount-store-derived` if you want to be able to
|
||||||
|
reuse the derived addresses later"
|
||||||
|
[account-id paths callback]
|
||||||
|
(when (status)
|
||||||
|
(.multiAccountDeriveAddresses (status)
|
||||||
|
(types/clj->json {:accountID account-id
|
||||||
|
:paths paths})
|
||||||
|
callback)))
|
||||||
|
|
||||||
(defn multiaccount-derive-addresses [account-id paths callback]
|
(defn multiaccount-store-account
|
||||||
(native-module/multiaccount-derive-addresses account-id paths callback))
|
"this stores the account and flush keys in memory so
|
||||||
|
in order to also store derived accounts like initial wallet
|
||||||
|
and chat accounts, you need to load the account again with
|
||||||
|
`multiaccount-load-account` before using `multiaccount-store-derived`
|
||||||
|
and the id of the account stored will have changed"
|
||||||
|
[account-id password callback]
|
||||||
|
(when (status)
|
||||||
|
(.multiAccountStoreAccount (status)
|
||||||
|
(types/clj->json {:accountID account-id
|
||||||
|
:password password})
|
||||||
|
callback)))
|
||||||
|
|
||||||
(defn multiaccount-store-account [account-id password callback]
|
(defn multiaccount-store-derived
|
||||||
(native-module/multiaccount-store-account account-id password callback))
|
[account-id paths password callback]
|
||||||
|
(.multiAccountStoreDerived (status)
|
||||||
|
(types/clj->json {:accountID account-id
|
||||||
|
:paths paths
|
||||||
|
:password password})
|
||||||
|
|
||||||
(defn multiaccount-store-derived [account-id paths password callback]
|
callback))
|
||||||
(native-module/multiaccount-store-derived account-id paths password callback))
|
|
||||||
|
|
||||||
(defn multiaccount-generate-and-derive-addresses [n mnemonic-length paths callback]
|
(defn multiaccount-generate-and-derive-addresses
|
||||||
(native-module/multiaccount-generate-and-derive-addresses n mnemonic-length paths callback))
|
"used to generate multiple multiaccounts for onboarding
|
||||||
|
NOTE: nothing is saved so you will need to use
|
||||||
|
`multiaccount-store-account` on the selected multiaccount
|
||||||
|
to store the key"
|
||||||
|
[n mnemonic-length paths callback]
|
||||||
|
(.multiAccountGenerateAndDeriveAddresses (status)
|
||||||
|
(types/clj->json {:n n
|
||||||
|
:mnemonicPhraseLength mnemonic-length
|
||||||
|
:bip39Passphrase ""
|
||||||
|
:paths paths})
|
||||||
|
callback))
|
||||||
|
|
||||||
(defn multiaccount-import-mnemonic [mnemonic password callback]
|
(defn multiaccount-import-mnemonic
|
||||||
(native-module/multiaccount-import-mnemonic mnemonic password callback))
|
[mnemonic password callback]
|
||||||
|
(.multiAccountImportMnemonic (status)
|
||||||
|
(types/clj->json {:mnemonicPhrase mnemonic
|
||||||
|
:Bip39Passphrase password})
|
||||||
|
|
||||||
|
callback))
|
||||||
|
|
||||||
(defn verify [address password callback]
|
(defn verify [address password callback]
|
||||||
(native-module/verify address password callback))
|
(.verify (status) address password callback))
|
||||||
|
|
||||||
(defn login-with-keycard
|
(defn login-with-keycard
|
||||||
[{:keys [whisper-private-key encryption-public-key on-result]}]
|
[{:keys [whisper-private-key encryption-public-key on-result]}]
|
||||||
(native-module/login-with-keycard whisper-private-key encryption-public-key on-result))
|
(clear-web-data)
|
||||||
|
(.loginWithKeycard (status) whisper-private-key encryption-public-key on-result))
|
||||||
|
|
||||||
(defn set-soft-input-mode [mode]
|
(defn set-soft-input-mode [mode]
|
||||||
(native-module/set-soft-input-mode mode))
|
(.setSoftInputMode (status) mode))
|
||||||
|
|
||||||
(defn call-rpc [payload callback]
|
(defn call-rpc [payload callback]
|
||||||
(native-module/call-rpc payload callback))
|
(.callRPC (status) payload callback))
|
||||||
|
|
||||||
(defn call-private-rpc [payload callback]
|
(defn call-private-rpc [payload callback]
|
||||||
(native-module/call-private-rpc payload callback))
|
(.callPrivateRPC (status) payload callback))
|
||||||
|
|
||||||
(defn sign-message [rpcParams callback]
|
|
||||||
(native-module/sign-message rpcParams callback))
|
|
||||||
|
|
||||||
(defn sign-typed-data [data account password callback]
|
|
||||||
(native-module/sign-typed-data data account password callback))
|
|
||||||
|
|
||||||
(defn send-transaction [rpcParams password callback]
|
|
||||||
(native-module/send-transaction rpcParams password callback))
|
|
||||||
|
|
||||||
(defn hash-transaction [rpcParams callback]
|
(defn hash-transaction [rpcParams callback]
|
||||||
(native-module/hash-transaction rpcParams callback))
|
(.hashTransaction (status) rpcParams callback))
|
||||||
|
|
||||||
(defn hash-message [message callback]
|
(defn hash-message [message callback]
|
||||||
(native-module/hash-message message callback))
|
(.hashMessage (status) message callback))
|
||||||
|
|
||||||
(defn hash-typed-data [data callback]
|
(defn hash-typed-data [data callback]
|
||||||
(native-module/hash-typed-data data callback))
|
(.hashTypedData (status) data callback))
|
||||||
|
|
||||||
|
(defn sign-message [rpcParams callback]
|
||||||
|
(.signMessage (status) rpcParams callback))
|
||||||
|
|
||||||
|
(defn sign-typed-data [data account password callback]
|
||||||
|
(.signTypedData (status) data account password callback))
|
||||||
|
|
||||||
|
(defn send-transaction [rpcParams password callback]
|
||||||
|
(.sendTransaction (status) rpcParams password callback))
|
||||||
|
|
||||||
(defn send-transaction-with-signature [rpcParams sig callback]
|
(defn send-transaction-with-signature [rpcParams sig callback]
|
||||||
(native-module/send-transaction-with-signature rpcParams sig callback))
|
(.sendTransactionWithSignature (status) rpcParams sig callback))
|
||||||
|
|
||||||
(defn send-data-notification [m callback]
|
(defn send-data-notification
|
||||||
(native-module/send-data-notification m callback))
|
[{:keys [data-payload tokens] :as m} on-result]
|
||||||
|
(.sendDataNotification (status) data-payload tokens on-result))
|
||||||
|
|
||||||
(defn send-logs [dbJson js-logs callback]
|
(defn send-logs [dbJson js-logs callback]
|
||||||
(native-module/send-logs dbJson js-logs callback))
|
(.sendLogs (status) dbJson js-logs callback))
|
||||||
|
|
||||||
(defn add-peer [enode callback]
|
(defn add-peer [enode on-result]
|
||||||
(native-module/add-peer enode callback))
|
(.addPeer (status) enode on-result))
|
||||||
|
|
||||||
(defn close-application []
|
(defn close-application []
|
||||||
(native-module/close-application))
|
(.closeApplication (status)))
|
||||||
|
|
||||||
(defn connection-change [type expensive?]
|
(defn connection-change [type expensive?]
|
||||||
(native-module/connection-change type expensive?))
|
(.connectionChange (status) type (boolean expensive?)))
|
||||||
|
|
||||||
(defn app-state-change [state]
|
(defn app-state-change [state]
|
||||||
(native-module/app-state-change state))
|
(.appStateChange (status) state))
|
||||||
|
|
||||||
(defn get-device-UUID [callback]
|
(defn get-device-UUID [callback]
|
||||||
(native-module/get-device-UUID callback))
|
(.getDeviceUUID
|
||||||
|
(status)
|
||||||
|
(fn [UUID]
|
||||||
|
(callback (string/upper-case UUID)))))
|
||||||
|
|
||||||
(defn set-blank-preview-flag [flag]
|
(defn set-blank-preview-flag [flag]
|
||||||
(native-module/set-blank-preview-flag flag))
|
(.setBlankPreviewFlag (status) flag))
|
||||||
|
|
||||||
(defn is24Hour []
|
(defn is24Hour []
|
||||||
(native-module/is24Hour))
|
;;NOTE: we have to check for status module because of tests
|
||||||
|
(when (status)
|
||||||
|
(.-is24Hour (status))))
|
||||||
|
|
||||||
(defn get-device-model-info []
|
(defn get-device-model-info []
|
||||||
(native-module/get-device-model-info))
|
;;NOTE: we have to check for status module because of tests
|
||||||
|
(when (status)
|
||||||
|
{:model (.-model (status))
|
||||||
|
:brand (.-brand (status))
|
||||||
|
:build-id (.-buildId (status))
|
||||||
|
:device-id (.-deviceId (status))}))
|
||||||
|
|
||||||
(def extract-group-membership-signatures native-module/extract-group-membership-signatures)
|
(defn extract-group-membership-signatures
|
||||||
|
[signature-pairs callback]
|
||||||
|
(.extractGroupMembershipSignatures (status) signature-pairs callback))
|
||||||
|
|
||||||
(def sign-group-membership native-module/sign-group-membership)
|
(defn sign-group-membership [content callback]
|
||||||
|
(.signGroupMembership (status) content callback))
|
||||||
|
|
||||||
(def update-mailservers native-module/update-mailservers)
|
(defn update-mailservers
|
||||||
|
[enodes on-result]
|
||||||
|
(.updateMailservers (status) enodes on-result))
|
||||||
|
|
||||||
(def rooted-device? native-module/rooted-device?)
|
(defn chaos-mode-update [on on-result]
|
||||||
|
(.chaosModeUpdate (status) on on-result))
|
||||||
|
|
||||||
(def chaos-mode-update native-module/chaos-mode-update)
|
(defn get-nodes-from-contract
|
||||||
|
[rpc-endpoint contract-address on-result]
|
||||||
|
(.getNodesFromContract (status) rpc-endpoint contract-address on-result))
|
||||||
|
|
||||||
(def get-nodes-from-contract native-module/get-nodes-from-contract)
|
(defn rooted-device? [callback]
|
||||||
|
(cond
|
||||||
|
;; we assume that iOS is safe by default
|
||||||
|
platform/ios?
|
||||||
|
(callback false)
|
||||||
|
|
||||||
|
;; we assume that Desktop is unsafe by default
|
||||||
|
;; (theoretically, Desktop is always "rooted", by design
|
||||||
|
platform/desktop?
|
||||||
|
(callback true)
|
||||||
|
|
||||||
|
;; we check root on android
|
||||||
|
platform/android?
|
||||||
|
(if (status)
|
||||||
|
(.isDeviceRooted (status) callback)
|
||||||
|
;; if module isn't initialized we return true to avoid degrading security
|
||||||
|
(callback true))
|
||||||
|
|
||||||
|
;; in unknown scenarios we also consider the device rooted to avoid degrading security
|
||||||
|
:else (callback true)))
|
||||||
|
@ -1,236 +0,0 @@
|
|||||||
(ns status-im.native-module.impl.module
|
|
||||||
(:require [status-im.ui.components.react :as r]
|
|
||||||
[re-frame.core :as re-frame]
|
|
||||||
[status-im.react-native.js-dependencies :as rn-dependencies]
|
|
||||||
[clojure.string :as string]
|
|
||||||
[status-im.utils.platform :as platform]
|
|
||||||
[status-im.utils.types :as types]))
|
|
||||||
|
|
||||||
(defn status []
|
|
||||||
(when (exists? (.-NativeModules rn-dependencies/react-native))
|
|
||||||
(.-Status (.-NativeModules rn-dependencies/react-native))))
|
|
||||||
|
|
||||||
(defn clear-web-data []
|
|
||||||
(when (status)
|
|
||||||
(.clearCookies (status))
|
|
||||||
(.clearStorageAPIs (status))))
|
|
||||||
|
|
||||||
(defn init-keystore []
|
|
||||||
(.initKeystore (status)))
|
|
||||||
|
|
||||||
(defn open-accounts [callback]
|
|
||||||
(.openAccounts (status) #(callback (types/json->clj %))))
|
|
||||||
|
|
||||||
(defn prepare-dir-and-update-config [config callback]
|
|
||||||
(.prepareDirAndUpdateConfig (status)
|
|
||||||
config
|
|
||||||
#(callback (types/json->clj %))))
|
|
||||||
|
|
||||||
(defn save-account-and-login
|
|
||||||
[multiaccount-data password config accounts-data]
|
|
||||||
(clear-web-data)
|
|
||||||
(.saveAccountAndLogin (status) multiaccount-data password config accounts-data))
|
|
||||||
|
|
||||||
(defn login
|
|
||||||
[account-data password]
|
|
||||||
(clear-web-data)
|
|
||||||
(.login (status) account-data password))
|
|
||||||
|
|
||||||
(defn logout []
|
|
||||||
(clear-web-data)
|
|
||||||
(.logout (status)))
|
|
||||||
|
|
||||||
(defonce listener-initialized (atom false))
|
|
||||||
|
|
||||||
(when-not @listener-initialized
|
|
||||||
(reset! listener-initialized true)
|
|
||||||
(.addListener r/device-event-emitter "gethEvent"
|
|
||||||
#(re-frame/dispatch [:signals/signal-received (.-jsonEvent %)])))
|
|
||||||
|
|
||||||
(defn node-ready [])
|
|
||||||
|
|
||||||
(defonce account-creation? (atom false))
|
|
||||||
|
|
||||||
(defn create-account [password on-result]
|
|
||||||
(when (status)
|
|
||||||
(let [callback (fn [data]
|
|
||||||
(reset! account-creation? false)
|
|
||||||
(on-result data))]
|
|
||||||
(swap! account-creation?
|
|
||||||
(fn [creation?]
|
|
||||||
(if-not creation?
|
|
||||||
(do
|
|
||||||
(.createAccount (status) password callback)
|
|
||||||
true)
|
|
||||||
false))))))
|
|
||||||
|
|
||||||
(defn send-data-notification [{:keys [data-payload tokens] :as m} on-result]
|
|
||||||
(when (status)
|
|
||||||
(.sendDataNotification (status) data-payload tokens on-result)))
|
|
||||||
|
|
||||||
(defn send-logs [dbJson js-logs callback]
|
|
||||||
(when (status)
|
|
||||||
(.sendLogs (status) dbJson js-logs callback)))
|
|
||||||
|
|
||||||
(defn add-peer [enode on-result]
|
|
||||||
(when (status)
|
|
||||||
(.addPeer (status) enode on-result)))
|
|
||||||
|
|
||||||
(defn multiaccount-generate-and-derive-addresses [n mnemonic-length paths on-result]
|
|
||||||
(.multiAccountGenerateAndDeriveAddresses (status)
|
|
||||||
(types/clj->json {:n n
|
|
||||||
:mnemonicPhraseLength mnemonic-length
|
|
||||||
:bip39Passphrase ""
|
|
||||||
:paths paths})
|
|
||||||
on-result))
|
|
||||||
|
|
||||||
(defn multiaccount-derive-addresses [account-id paths on-result]
|
|
||||||
(when (status)
|
|
||||||
(.multiAccountDeriveAddresses (status)
|
|
||||||
(types/clj->json {:accountID account-id
|
|
||||||
:paths paths})
|
|
||||||
on-result)))
|
|
||||||
|
|
||||||
(defn multiaccount-store-account [account-id password on-result]
|
|
||||||
(when (status)
|
|
||||||
(.multiAccountStoreAccount (status)
|
|
||||||
(types/clj->json {:accountID account-id
|
|
||||||
:password password})
|
|
||||||
on-result)))
|
|
||||||
|
|
||||||
(defn multiaccount-load-account [address password on-result]
|
|
||||||
(when (status)
|
|
||||||
(.multiAccountLoadAccount (status)
|
|
||||||
(types/clj->json {:address address
|
|
||||||
:password password})
|
|
||||||
on-result)))
|
|
||||||
|
|
||||||
(defn multiaccount-reset [on-result]
|
|
||||||
(when (status)
|
|
||||||
(.multiAccountReset (status)
|
|
||||||
on-result)))
|
|
||||||
|
|
||||||
(defn multiaccount-store-derived
|
|
||||||
[account-id paths password on-result]
|
|
||||||
(.multiAccountStoreDerived (status)
|
|
||||||
(types/clj->json {:accountID account-id
|
|
||||||
:paths paths
|
|
||||||
:password password})
|
|
||||||
|
|
||||||
on-result))
|
|
||||||
|
|
||||||
(defn multiaccount-import-mnemonic [mnemonic password on-result]
|
|
||||||
(when (status)
|
|
||||||
(.multiAccountImportMnemonic (status)
|
|
||||||
(types/clj->json {:mnemonicPhrase mnemonic
|
|
||||||
:Bip39Passphrase password})
|
|
||||||
|
|
||||||
on-result)))
|
|
||||||
|
|
||||||
(defn verify [address password on-result]
|
|
||||||
(.verify (status) address password on-result))
|
|
||||||
|
|
||||||
(defn login-with-keycard [whisper-private-key encryption-public-key on-result]
|
|
||||||
(clear-web-data)
|
|
||||||
(.loginWithKeycard (status) whisper-private-key encryption-public-key on-result))
|
|
||||||
|
|
||||||
(defn set-soft-input-mode [mode]
|
|
||||||
(when (status)
|
|
||||||
(.setSoftInputMode (status) mode)))
|
|
||||||
|
|
||||||
(defn call-rpc [payload callback]
|
|
||||||
(.callRPC (status) payload callback))
|
|
||||||
|
|
||||||
(defn call-private-rpc [payload callback]
|
|
||||||
(.callPrivateRPC (status) payload callback))
|
|
||||||
|
|
||||||
(defn sign-message [rpcParams callback]
|
|
||||||
(.signMessage (status) rpcParams callback))
|
|
||||||
|
|
||||||
(defn hash-transaction [rpcParams callback]
|
|
||||||
(.hashTransaction (status) rpcParams callback))
|
|
||||||
|
|
||||||
(defn hash-message [message callback]
|
|
||||||
(.hashMessage (status) message callback))
|
|
||||||
|
|
||||||
(defn hash-typed-data [data callback]
|
|
||||||
(.hashTypedData (status) data callback))
|
|
||||||
|
|
||||||
(defn sign-typed-data [data account password callback]
|
|
||||||
(.signTypedData (status) data account password callback))
|
|
||||||
|
|
||||||
(defn send-transaction [rpcParams password callback]
|
|
||||||
(.sendTransaction (status) rpcParams password callback))
|
|
||||||
|
|
||||||
(defn send-transaction-with-signature [rpcParams sig callback]
|
|
||||||
(.sendTransactionWithSignature (status) rpcParams sig callback))
|
|
||||||
|
|
||||||
(defn close-application []
|
|
||||||
(.closeApplication (status)))
|
|
||||||
|
|
||||||
(defn connection-change [type expensive?]
|
|
||||||
(.connectionChange (status) type (boolean expensive?)))
|
|
||||||
|
|
||||||
(defn app-state-change [state]
|
|
||||||
(.appStateChange (status) state))
|
|
||||||
|
|
||||||
(defn get-device-UUID [callback]
|
|
||||||
(.getDeviceUUID
|
|
||||||
(status)
|
|
||||||
(fn [UUID]
|
|
||||||
(callback (string/upper-case UUID)))))
|
|
||||||
|
|
||||||
(defn set-blank-preview-flag [flag]
|
|
||||||
(.setBlankPreviewFlag (status) flag))
|
|
||||||
|
|
||||||
(defn extract-group-membership-signatures [signature-pairs callback]
|
|
||||||
(when (status)
|
|
||||||
(.extractGroupMembershipSignatures (status) signature-pairs callback)))
|
|
||||||
|
|
||||||
(defn sign-group-membership [content callback]
|
|
||||||
(when (status)
|
|
||||||
(.signGroupMembership (status) content callback)))
|
|
||||||
|
|
||||||
(defn is24Hour []
|
|
||||||
(when (status)
|
|
||||||
(.-is24Hour (status))))
|
|
||||||
|
|
||||||
(defn get-device-model-info []
|
|
||||||
(when status
|
|
||||||
{:model (.-model status)
|
|
||||||
:brand (.-brand status)
|
|
||||||
:build-id (.-buildId status)
|
|
||||||
:device-id (.-deviceId status)}))
|
|
||||||
|
|
||||||
(defn update-mailservers [enodes on-result]
|
|
||||||
(when (status)
|
|
||||||
(.updateMailservers (status) enodes on-result)))
|
|
||||||
|
|
||||||
(defn chaos-mode-update [on on-result]
|
|
||||||
(when (status)
|
|
||||||
(.chaosModeUpdate (status) on on-result)))
|
|
||||||
|
|
||||||
(defn get-nodes-from-contract [rpc-endpoint contract-address on-result]
|
|
||||||
(when (status)
|
|
||||||
(.getNodesFromContract (status) rpc-endpoint contract-address on-result)))
|
|
||||||
|
|
||||||
(defn rooted-device? [callback]
|
|
||||||
(cond
|
|
||||||
;; we assume that iOS is safe by default
|
|
||||||
platform/ios?
|
|
||||||
(callback false)
|
|
||||||
|
|
||||||
;; we assume that Desktop is unsafe by default
|
|
||||||
;; (theoretically, Desktop is always "rooted", by design
|
|
||||||
platform/desktop?
|
|
||||||
(callback true)
|
|
||||||
|
|
||||||
;; we check root on android
|
|
||||||
platform/android?
|
|
||||||
(if (status)
|
|
||||||
(.isDeviceRooted (status) callback)
|
|
||||||
;; if module isn't initialized we return true to avoid degrading security
|
|
||||||
(callback true))
|
|
||||||
|
|
||||||
;; in unknown scenarios we also consider the device rooted to avoid degrading security
|
|
||||||
:else (callback true)))
|
|
@ -186,11 +186,6 @@
|
|||||||
(fn [[config callback]]
|
(fn [[config callback]]
|
||||||
(status/prepare-dir-and-update-config config callback)))
|
(status/prepare-dir-and-update-config config callback)))
|
||||||
|
|
||||||
(re-frame/reg-fx
|
|
||||||
:node/ready
|
|
||||||
(fn [config]
|
|
||||||
(status/node-ready)))
|
|
||||||
|
|
||||||
(re-frame/reg-fx
|
(re-frame/reg-fx
|
||||||
:node/les-show-debug-info
|
:node/les-show-debug-info
|
||||||
(fn [[multiaccount]]
|
(fn [[multiaccount]]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user