Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ef1aafa644 |
@@ -4,6 +4,7 @@ DEFAULT_NETWORK=mainnet_rpc
|
||||
DEV_BUILD=1
|
||||
ETHEREUM_DEV_CLUSTER=1
|
||||
EXTENSIONS=0
|
||||
FLEET=status.prod
|
||||
GROUP_CHATS_ENABLED=1
|
||||
LOG_LEVEL=info
|
||||
MAILSERVER_CONFIRMATIONS_ENABLED=1
|
||||
|
||||
@@ -2,7 +2,7 @@ DEBUG_WEBVIEW=1
|
||||
DEFAULT_NETWORK=goerli_rpc
|
||||
ETHEREUM_DEV_CLUSTER=1
|
||||
EXTENSIONS=0
|
||||
FLEET=status.staging
|
||||
FLEET=status.prod
|
||||
GROUP_CHATS_ENABLED=1
|
||||
LOG_LEVEL=debug
|
||||
MAILSERVER_CONFIRMATIONS_ENABLED=0
|
||||
|
||||
@@ -3,6 +3,7 @@ DEBUG_WEBVIEW=1
|
||||
DEFAULT_NETWORK=goerli_rpc
|
||||
ETHEREUM_DEV_CLUSTER=1
|
||||
EXTENSIONS=0
|
||||
FLEET=status.prod
|
||||
GROUP_CHATS_ENABLED=1
|
||||
LOG_LEVEL=debug
|
||||
MAILSERVER_CONFIRMATIONS_ENABLED=1
|
||||
|
||||
@@ -2,6 +2,7 @@ DEBUG_WEBVIEW=1
|
||||
DEFAULT_NETWORK=mainnet_rpc
|
||||
ETHEREUM_DEV_CLUSTER=1
|
||||
EXTENSIONS=0
|
||||
FLEET=status.prod
|
||||
GROUP_CHATS_ENABLED=1
|
||||
LOG_LEVEL=info
|
||||
MAILSERVER_CONFIRMATIONS_ENABLED=1
|
||||
|
||||
@@ -2,6 +2,7 @@ DEBUG_WEBVIEW=0
|
||||
DEFAULT_NETWORK=mainnet_rpc
|
||||
ETHEREUM_DEV_CLUSTER=0
|
||||
EXTENSIONS=0
|
||||
FLEET=status.prod
|
||||
GROUP_CHATS_ENABLED=1
|
||||
LOG_LEVEL=
|
||||
MAILSERVER_CONFIRMATIONS_ENABLED=1
|
||||
|
||||
+9
-14
@@ -1,15 +1,10 @@
|
||||
/*
|
||||
|
||||
# Format top-level js files.
|
||||
*
|
||||
!*.js
|
||||
|
||||
# Ignore all except src/js/**/*.js
|
||||
!/src/
|
||||
/src/*
|
||||
!/src/js
|
||||
!/src/js/**/*.js
|
||||
|
||||
# Ignore all except translations/en.json
|
||||
!/translations/
|
||||
/translations/*
|
||||
!/translations/en.json
|
||||
!*/
|
||||
*.clj-kondo
|
||||
*.shadow-cljs
|
||||
modules
|
||||
result
|
||||
target
|
||||
component-spec
|
||||
/app
|
||||
|
||||
@@ -6,8 +6,4 @@ module.exports = {
|
||||
tabWidth: 2,
|
||||
trailingComma: 'all',
|
||||
useTabs: false,
|
||||
|
||||
// JSON sorting
|
||||
jsonSortOrder: '{ "/.*/": "caseInsensitiveLexical" } ',
|
||||
plugins: ['prettier-plugin-sort-json'],
|
||||
};
|
||||
|
||||
@@ -317,7 +317,7 @@ lint: ##@test Run code style checks
|
||||
scripts/lint/translations.clj && \
|
||||
zprint '{:search-config? true}' -sfc $$ALL_CLOJURE_FILES && \
|
||||
sh scripts/lint/trailing-newline.sh && \
|
||||
node_modules/.bin/prettier --check .
|
||||
node_modules/.bin/prettier --write .
|
||||
|
||||
# NOTE: We run the linter twice because of https://github.com/kkinnear/zprint/issues/271
|
||||
lint-fix: export TARGET := clojure
|
||||
|
||||
@@ -99,7 +99,7 @@ pipeline {
|
||||
--rerun_count=2 \
|
||||
--testrail_report=True \
|
||||
-m testrail_id \
|
||||
-m \"nightly\" \
|
||||
-m \"new_ui_critical or new_ui_medium\" \
|
||||
-k \"${params.KEYWORD_EXPRESSION}\" \
|
||||
--apk=${params.APK_URL ?: apk_path}
|
||||
"""
|
||||
|
||||
@@ -35,11 +35,13 @@ pipeline {
|
||||
description: 'OBSOLETE ARGUMENT TO BE REMOVED',
|
||||
defaultValue: 'DUMMY',
|
||||
)
|
||||
/* Commented to use TEST_MARKERS values from job params
|
||||
string(
|
||||
name: 'TEST_MARKERS',
|
||||
description: 'Marker expression for matching tests to run.',
|
||||
defaultValue: 'smoke',
|
||||
defaultValue: 'new_ui_critical',
|
||||
)
|
||||
*/
|
||||
}
|
||||
|
||||
options {
|
||||
|
||||
+2
-2
@@ -915,7 +915,7 @@ PODS:
|
||||
- glog
|
||||
- RCT-Folly (= 2022.05.16.00)
|
||||
- React-Core
|
||||
- react-native-compat (2.11.2):
|
||||
- react-native-compat (2.12.2):
|
||||
- glog
|
||||
- RCT-Folly (= 2022.05.16.00)
|
||||
- React-Core
|
||||
@@ -1517,7 +1517,7 @@ SPEC CHECKSUMS:
|
||||
react-native-blob-util: 600972b1782380a5a7d5db61a3817ea32349dae9
|
||||
react-native-blur: 799045500f56146afc46245148080e7b7623cb75
|
||||
react-native-cameraroll: af8eec1e585d053ff485d98ec837f9a8a11b5745
|
||||
react-native-compat: 3af9add14d349701306d3d052638435f6795ac2c
|
||||
react-native-compat: 84e00e8dcff9251278c0d48f2bce81f4502e3925
|
||||
react-native-config: 5330c8258265c1e5fdb8c009d2cabd6badd96727
|
||||
react-native-get-random-values: 21325b2244dfa6b58878f51f9aa42821e7ba3d06
|
||||
react-native-hole-view: 6935448993bac79f2b5a4ad7e9741094cf810679
|
||||
|
||||
-5
@@ -92,11 +92,6 @@ public class EncryptionUtils extends ReactContextBaseJavaModule {
|
||||
return Statusgo.hexToUtf8(str);
|
||||
}
|
||||
|
||||
@ReactMethod(isBlockingSynchronousMethod = true)
|
||||
public String serializeLegacyKey(final String publicKey) {
|
||||
return Statusgo.serializeLegacyKey(publicKey);
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void setBlankPreviewFlag(final Boolean blankPreview) {
|
||||
final SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this.reactContext);
|
||||
|
||||
@@ -94,10 +94,6 @@ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(hexToUtf8:(NSString *)str) {
|
||||
return StatusgoHexToUtf8(str);
|
||||
}
|
||||
|
||||
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(serializeLegacyKey:(NSString *)str) {
|
||||
return StatusgoSerializeLegacyKey(str);
|
||||
}
|
||||
|
||||
RCT_EXPORT_METHOD(setBlankPreviewFlag:(BOOL *)newValue)
|
||||
{
|
||||
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
|
||||
|
||||
@@ -672,38 +672,6 @@ void _Sha3(const FunctionCallbackInfo<Value>& args) {
|
||||
|
||||
}
|
||||
|
||||
void _SerializeLegacyKey(const FunctionCallbackInfo<Value>& args) {
|
||||
Isolate* isolate = args.GetIsolate();
|
||||
Local<Context> context = isolate->GetCurrentContext();
|
||||
|
||||
if (args.Length() != 1) {
|
||||
// Throw an Error that is passed back to JavaScript
|
||||
isolate->ThrowException(Exception::TypeError(
|
||||
String::NewFromUtf8Literal(isolate, "Wrong number of arguments for SerializeLegacyKey")));
|
||||
return;
|
||||
}
|
||||
|
||||
// Check the argument types
|
||||
|
||||
if (!args[0]->IsString()) {
|
||||
isolate->ThrowException(Exception::TypeError(
|
||||
String::NewFromUtf8Literal(isolate, "Wrong argument type for 'str'")));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
String::Utf8Value arg0Obj(isolate, args[0]->ToString(context).ToLocalChecked());
|
||||
char *arg0 = *arg0Obj;
|
||||
|
||||
// Call exported Go function, which returns a C string
|
||||
char *c = SerializeLegacyKey(arg0);
|
||||
|
||||
Local<String> ret = String::NewFromUtf8(isolate, c).ToLocalChecked();
|
||||
args.GetReturnValue().Set(ret);
|
||||
delete c;
|
||||
|
||||
}
|
||||
|
||||
void _ToChecksumAddress(const FunctionCallbackInfo<Value>& args) {
|
||||
Isolate* isolate = args.GetIsolate();
|
||||
Local<Context> context = isolate->GetCurrentContext();
|
||||
@@ -2008,7 +1976,6 @@ void init(Local<Object> exports) {
|
||||
NODE_SET_METHOD(exports, "checkAddressChecksum", _CheckAddressChecksum);
|
||||
NODE_SET_METHOD(exports, "isAddress", _IsAddress);
|
||||
NODE_SET_METHOD(exports, "sha3", _Sha3);
|
||||
NODE_SET_METHOD(exports, "serializeLegacyKey", _SerializeLegacyKey);
|
||||
NODE_SET_METHOD(exports, "toChecksumAddress", _ToChecksumAddress);
|
||||
NODE_SET_METHOD(exports, "logout", _Logout);
|
||||
NODE_SET_METHOD(exports, "hashMessage", _HashMessage);
|
||||
|
||||
+1
-2
@@ -97,8 +97,7 @@
|
||||
"jest-silent-reporter": "^0.5.0",
|
||||
"nodemon": "^2.0.16",
|
||||
"nyc": "^14.1.1",
|
||||
"prettier": "^3.3.3",
|
||||
"prettier-plugin-sort-json": "^4.0.0",
|
||||
"prettier": "^2.8.8",
|
||||
"process": "0.11.10",
|
||||
"react-test-renderer": "18.1.0",
|
||||
"shadow-cljs": "2.26.2",
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 6.0 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 8.8 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 6.1 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 9.2 KiB |
+37
-276
@@ -1,277 +1,38 @@
|
||||
(ns keycard.keycard
|
||||
(:require
|
||||
["react-native" :as rn]
|
||||
["react-native-status-keycard" :default status-keycard]
|
||||
[react-native.platform :as platform]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.address :as address]))
|
||||
(ns keycard.keycard)
|
||||
|
||||
(defonce event-emitter
|
||||
(if platform/ios?
|
||||
(new (.-NativeEventEmitter rn) status-keycard)
|
||||
(.-DeviceEventEmitter rn)))
|
||||
|
||||
(defn start-nfc
|
||||
[{:keys [on-success on-failure prompt-message]}]
|
||||
(log/debug "start-nfc")
|
||||
(.. status-keycard
|
||||
(startNFC (str prompt-message))
|
||||
(then on-success)
|
||||
(catch on-failure)))
|
||||
|
||||
(defn stop-nfc
|
||||
[{:keys [on-success on-failure error-message]}]
|
||||
(log/debug "stop-nfc")
|
||||
(.. status-keycard
|
||||
(stopNFC (str error-message))
|
||||
(then on-success)
|
||||
(catch on-failure)))
|
||||
|
||||
(defn set-nfc-message
|
||||
[{:keys [on-success on-failure status-message]}]
|
||||
(log/debug "set-nfc-message")
|
||||
(.. status-keycard
|
||||
(setNFCMessage (str status-message))
|
||||
(then on-success)
|
||||
(catch on-failure)))
|
||||
|
||||
(defn check-nfc-support
|
||||
[{:keys [on-success]}]
|
||||
(.. status-keycard
|
||||
nfcIsSupported
|
||||
(then on-success)))
|
||||
|
||||
(defn check-nfc-enabled
|
||||
[{:keys [on-success]}]
|
||||
(.. status-keycard
|
||||
nfcIsEnabled
|
||||
(then on-success)))
|
||||
|
||||
(defn open-nfc-settings
|
||||
[]
|
||||
(.openNfcSettings status-keycard))
|
||||
|
||||
(defn remove-event-listeners
|
||||
[]
|
||||
(doseq [event ["keyCardOnConnected" "keyCardOnDisconnected" "keyCardOnNFCUserCancelled"
|
||||
"keyCardOnNFCTimeout"]]
|
||||
(.removeAllListeners ^js event-emitter event)))
|
||||
|
||||
(defn remove-event-listener
|
||||
[^js event]
|
||||
(when event
|
||||
(.remove event)))
|
||||
|
||||
(defn on-card-connected
|
||||
[callback]
|
||||
(.addListener ^js event-emitter "keyCardOnConnected" callback))
|
||||
|
||||
(defn on-card-disconnected
|
||||
[callback]
|
||||
(.addListener ^js event-emitter "keyCardOnDisconnected" callback))
|
||||
|
||||
(defn on-nfc-user-cancelled
|
||||
[callback]
|
||||
(.addListener ^js event-emitter "keyCardOnNFCUserCancelled" callback))
|
||||
|
||||
(defn on-nfc-timeout
|
||||
[callback]
|
||||
(.addListener ^js event-emitter "keyCardOnNFCTimeout" callback))
|
||||
|
||||
(defn on-nfc-enabled
|
||||
[callback]
|
||||
(.addListener ^js event-emitter "keyCardOnNFCEnabled" callback))
|
||||
|
||||
(defn on-nfc-disabled
|
||||
[callback]
|
||||
(.addListener ^js event-emitter "keyCardOnNFCDisabled" callback))
|
||||
|
||||
(defn set-pairings
|
||||
[pairings]
|
||||
(.. status-keycard (setPairings (clj->js (or pairings {})))))
|
||||
|
||||
(defn get-application-info
|
||||
[{:keys [on-success on-failure]}]
|
||||
(.. status-keycard
|
||||
(getApplicationInfo)
|
||||
(then (fn [response]
|
||||
(let [info (-> response
|
||||
(js->clj :keywordize-keys true)
|
||||
(update :key-uid address/normalized-hex))]
|
||||
(on-success info))))
|
||||
(catch on-failure)))
|
||||
|
||||
(defn factory-reset
|
||||
[{:keys [on-success on-failure]}]
|
||||
(.. status-keycard
|
||||
(factoryReset)
|
||||
(then (fn [response]
|
||||
(let [info (-> response
|
||||
(js->clj :keywordize-keys true)
|
||||
(update :key-uid address/normalized-hex))]
|
||||
(on-success info))))
|
||||
(catch on-failure)))
|
||||
|
||||
(defn install-applet
|
||||
[{:keys [on-success on-failure]}]
|
||||
(.. status-keycard
|
||||
installApplet
|
||||
(then on-success)
|
||||
(catch on-failure)))
|
||||
|
||||
(defn install-cash-applet
|
||||
[{:keys [on-success on-failure]}]
|
||||
(.. status-keycard
|
||||
installCashApplet
|
||||
(then on-success)
|
||||
(catch on-failure)))
|
||||
|
||||
(defn init-card
|
||||
[{:keys [pin on-success on-failure]}]
|
||||
(.. status-keycard
|
||||
(init pin)
|
||||
(then on-success)
|
||||
(catch on-failure)))
|
||||
|
||||
(defn install-applet-and-init-card
|
||||
[{:keys [pin on-success on-failure]}]
|
||||
(.. status-keycard
|
||||
(installAppletAndInitCard pin)
|
||||
(then on-success)
|
||||
(catch on-failure)))
|
||||
|
||||
(defn pair
|
||||
[{:keys [password on-success on-failure]}]
|
||||
(when password
|
||||
(.. status-keycard
|
||||
(pair password)
|
||||
(then on-success)
|
||||
(catch on-failure))))
|
||||
|
||||
(defn generate-and-load-key
|
||||
[{:keys [mnemonic pin on-success on-failure]}]
|
||||
(.. status-keycard
|
||||
(generateAndLoadKey mnemonic pin)
|
||||
(then on-success)
|
||||
(catch on-failure)))
|
||||
|
||||
(defn unblock-pin
|
||||
[{:keys [puk new-pin on-success on-failure]}]
|
||||
(when (and new-pin puk)
|
||||
(.. status-keycard
|
||||
(unblockPin puk new-pin)
|
||||
(then on-success)
|
||||
(catch on-failure))))
|
||||
|
||||
(defn verify-pin
|
||||
[{:keys [pin on-success on-failure]}]
|
||||
(when (not-empty pin)
|
||||
(.. status-keycard
|
||||
(verifyPin pin)
|
||||
(then on-success)
|
||||
(catch on-failure))))
|
||||
|
||||
(defn change-pin
|
||||
[{:keys [current-pin new-pin on-success on-failure]}]
|
||||
(when (and current-pin new-pin)
|
||||
(.. status-keycard
|
||||
(changePin current-pin new-pin)
|
||||
(then on-success)
|
||||
(catch on-failure))))
|
||||
|
||||
(defn change-puk
|
||||
[{:keys [pin puk on-success on-failure]}]
|
||||
(when (and pin puk)
|
||||
(.. status-keycard
|
||||
(changePUK pin puk)
|
||||
(then on-success)
|
||||
(catch on-failure))))
|
||||
|
||||
(defn change-pairing
|
||||
[{:keys [pin pairing on-success on-failure]}]
|
||||
(when (and pin pairing)
|
||||
(.. status-keycard
|
||||
(changePairingPassword pin pairing)
|
||||
(then on-success)
|
||||
(catch on-failure))))
|
||||
|
||||
(defn unpair
|
||||
[{:keys [pin on-success on-failure]}]
|
||||
(when pin
|
||||
(.. status-keycard
|
||||
(unpair pin)
|
||||
(then on-success)
|
||||
(catch on-failure))))
|
||||
|
||||
(defn delete
|
||||
[{:keys [on-success on-failure]}]
|
||||
(.. status-keycard
|
||||
(delete)
|
||||
(then on-success)
|
||||
(catch on-failure)))
|
||||
|
||||
(defn remove-key
|
||||
[{:keys [pin on-success on-failure]}]
|
||||
(.. status-keycard
|
||||
(removeKey pin)
|
||||
(then on-success)
|
||||
(catch on-failure)))
|
||||
|
||||
(defn remove-key-with-unpair
|
||||
[{:keys [pin on-success on-failure]}]
|
||||
(.. status-keycard
|
||||
(removeKeyWithUnpair pin)
|
||||
(then on-success)
|
||||
(catch on-failure)))
|
||||
|
||||
(defn export-key
|
||||
[{:keys [pin path on-success on-failure]}]
|
||||
(.. status-keycard
|
||||
(exportKeyWithPath pin path)
|
||||
(then on-success)
|
||||
(catch on-failure)))
|
||||
|
||||
(defn unpair-and-delete
|
||||
[{:keys [pin on-success on-failure]}]
|
||||
(when (not-empty pin)
|
||||
(.. status-keycard
|
||||
(unpairAndDelete pin)
|
||||
(then on-success)
|
||||
(catch on-failure))))
|
||||
|
||||
(defn import-keys
|
||||
[{:keys [pin on-success on-failure]}]
|
||||
(when (not-empty pin)
|
||||
(.. status-keycard
|
||||
(importKeys pin)
|
||||
(then on-success)
|
||||
(catch on-failure))))
|
||||
|
||||
(defn get-keys
|
||||
[{:keys [pin on-success on-failure]}]
|
||||
(when (not-empty pin)
|
||||
(.. status-keycard
|
||||
(getKeys pin)
|
||||
(then on-success)
|
||||
(catch on-failure))))
|
||||
|
||||
(defn sign
|
||||
[{pin :pin path :path card-hash :hash on-success :on-success on-failure :on-failure}]
|
||||
(when (and pin card-hash)
|
||||
(if path
|
||||
(.. status-keycard
|
||||
(signWithPath pin path card-hash)
|
||||
(then on-success)
|
||||
(catch on-failure))
|
||||
(.. status-keycard
|
||||
(sign pin card-hash)
|
||||
(then on-success)
|
||||
(catch on-failure)))))
|
||||
|
||||
(defn sign-typed-data
|
||||
[{card-hash :hash on-success :on-success on-failure :on-failure}]
|
||||
(when card-hash
|
||||
(.. status-keycard
|
||||
(signPinless card-hash)
|
||||
(then on-success)
|
||||
(catch on-failure))))
|
||||
(defprotocol Keycard
|
||||
(start-nfc [this args])
|
||||
(stop-nfc [this args])
|
||||
(set-nfc-message [this args])
|
||||
(check-nfc-support [this args])
|
||||
(check-nfc-enabled [this args])
|
||||
(open-nfc-settings [this])
|
||||
(register-card-events [this args])
|
||||
(set-pairings [this args])
|
||||
(on-card-disconnected [this callback])
|
||||
(on-card-connected [this callback])
|
||||
(remove-event-listener [this event])
|
||||
(remove-event-listeners [this])
|
||||
(get-application-info [this args])
|
||||
(factory-reset [this args])
|
||||
(install-applet [this args])
|
||||
(install-cash-applet [this args])
|
||||
(init-card [this args])
|
||||
(install-applet-and-init-card [this args])
|
||||
(pair [this args])
|
||||
(generate-and-load-key [this args])
|
||||
(unblock-pin [this args])
|
||||
(verify-pin [this args])
|
||||
(change-pin [this args])
|
||||
(change-puk [this args])
|
||||
(change-pairing [this args])
|
||||
(unpair [this args])
|
||||
(delete [this args])
|
||||
(remove-key [this args])
|
||||
(remove-key-with-unpair [this args])
|
||||
(export-key [this args])
|
||||
(unpair-and-delete [this args])
|
||||
(import-keys [this args])
|
||||
(get-keys [this args])
|
||||
(sign [this args])
|
||||
(sign-typed-data [this args]))
|
||||
|
||||
@@ -0,0 +1,365 @@
|
||||
(ns keycard.real-keycard
|
||||
(:require
|
||||
["react-native" :as rn]
|
||||
["react-native-status-keycard" :default status-keycard]
|
||||
[keycard.keycard :as keycard]
|
||||
[react-native.platform :as platform]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.address :as address]))
|
||||
|
||||
(defonce event-emitter
|
||||
(if platform/ios?
|
||||
(new (.-NativeEventEmitter rn) status-keycard)
|
||||
(.-DeviceEventEmitter rn)))
|
||||
|
||||
(defonce active-listeners (atom []))
|
||||
|
||||
(defn start-nfc
|
||||
[{:keys [on-success on-failure prompt-message]}]
|
||||
(log/debug "start-nfc")
|
||||
(.. status-keycard
|
||||
(startNFC (str prompt-message))
|
||||
(then on-success)
|
||||
(catch on-failure)))
|
||||
|
||||
(defn stop-nfc
|
||||
[{:keys [on-success on-failure error-message]}]
|
||||
(log/debug "stop-nfc")
|
||||
(.. status-keycard
|
||||
(stopNFC (str error-message))
|
||||
(then on-success)
|
||||
(catch on-failure)))
|
||||
|
||||
(defn set-nfc-message
|
||||
[{:keys [on-success on-failure status-message]}]
|
||||
(log/debug "set-nfc-message")
|
||||
(.. status-keycard
|
||||
(setNFCMessage (str status-message))
|
||||
(then on-success)
|
||||
(catch on-failure)))
|
||||
|
||||
(defn check-nfc-support
|
||||
[{:keys [on-success]}]
|
||||
(.. status-keycard
|
||||
nfcIsSupported
|
||||
(then on-success)))
|
||||
|
||||
(defn check-nfc-enabled
|
||||
[{:keys [on-success]}]
|
||||
(.. status-keycard
|
||||
nfcIsEnabled
|
||||
(then on-success)))
|
||||
|
||||
(defn open-nfc-settings
|
||||
[]
|
||||
(.openNfcSettings status-keycard))
|
||||
|
||||
(defn remove-event-listeners
|
||||
[]
|
||||
(doseq [event ["keyCardOnConnected" "keyCardOnDisconnected" "keyCardOnNFCUserCancelled"
|
||||
"keyCardOnNFCTimeout"]]
|
||||
(.removeAllListeners ^js event-emitter event)))
|
||||
|
||||
(defn remove-event-listener
|
||||
[^js event]
|
||||
(.remove event))
|
||||
|
||||
(defn on-card-connected
|
||||
[callback]
|
||||
(.addListener ^js event-emitter "keyCardOnConnected" callback))
|
||||
|
||||
(defn on-card-disconnected
|
||||
[callback]
|
||||
(.addListener ^js event-emitter "keyCardOnDisconnected" callback))
|
||||
|
||||
(defn on-nfc-user-cancelled
|
||||
[callback]
|
||||
(.addListener ^js event-emitter "keyCardOnNFCUserCancelled" callback))
|
||||
|
||||
(defn on-nfc-timeout
|
||||
[callback]
|
||||
(.addListener ^js event-emitter "keyCardOnNFCTimeout" callback))
|
||||
|
||||
(defn on-nfc-enabled
|
||||
[callback]
|
||||
(.addListener ^js event-emitter "keyCardOnNFCEnabled" callback))
|
||||
|
||||
(defn on-nfc-disabled
|
||||
[callback]
|
||||
(.addListener ^js event-emitter "keyCardOnNFCDisabled" callback))
|
||||
|
||||
(defn set-pairings
|
||||
[{:keys [pairings]}]
|
||||
(.. status-keycard (setPairings (clj->js (or pairings {})))))
|
||||
|
||||
(defn register-card-events
|
||||
[args]
|
||||
(doseq [listener @active-listeners]
|
||||
(remove-event-listener listener))
|
||||
(reset! active-listeners
|
||||
[(on-card-connected (:on-card-connected args))
|
||||
(on-card-disconnected (:on-card-disconnected args))
|
||||
(on-nfc-user-cancelled (:on-nfc-user-cancelled args))
|
||||
(on-nfc-timeout (:on-nfc-timeout args))
|
||||
(on-nfc-enabled (:on-nfc-enabled args))
|
||||
(on-nfc-disabled (:on-nfc-disabled args))]))
|
||||
|
||||
(defn get-application-info
|
||||
[{:keys [on-success on-failure]}]
|
||||
|
||||
(.. status-keycard
|
||||
(getApplicationInfo)
|
||||
(then (fn [response]
|
||||
(let [info (-> response
|
||||
(js->clj :keywordize-keys true)
|
||||
(update :key-uid address/normalized-hex))]
|
||||
(on-success info))))
|
||||
(catch on-failure)))
|
||||
|
||||
(defn factory-reset
|
||||
[{:keys [on-success on-failure]}]
|
||||
(.. status-keycard
|
||||
(factoryReset)
|
||||
(then (fn [response]
|
||||
(let [info (-> response
|
||||
(js->clj :keywordize-keys true)
|
||||
(update :key-uid address/normalized-hex))]
|
||||
(on-success info))))
|
||||
(catch on-failure)))
|
||||
|
||||
(defn install-applet
|
||||
[{:keys [on-success on-failure]}]
|
||||
(.. status-keycard
|
||||
installApplet
|
||||
(then on-success)
|
||||
(catch on-failure)))
|
||||
|
||||
(defn install-cash-applet
|
||||
[{:keys [on-success on-failure]}]
|
||||
(.. status-keycard
|
||||
installCashApplet
|
||||
(then on-success)
|
||||
(catch on-failure)))
|
||||
|
||||
(defn init-card
|
||||
[{:keys [pin on-success on-failure]}]
|
||||
(.. status-keycard
|
||||
(init pin)
|
||||
(then on-success)
|
||||
(catch on-failure)))
|
||||
|
||||
(defn install-applet-and-init-card
|
||||
[{:keys [pin on-success on-failure]}]
|
||||
(.. status-keycard
|
||||
(installAppletAndInitCard pin)
|
||||
(then on-success)
|
||||
(catch on-failure)))
|
||||
|
||||
(defn pair
|
||||
[{:keys [password on-success on-failure]}]
|
||||
(when password
|
||||
(.. status-keycard
|
||||
(pair password)
|
||||
(then on-success)
|
||||
(catch on-failure))))
|
||||
|
||||
(defn generate-and-load-key
|
||||
[{:keys [mnemonic pin on-success on-failure]}]
|
||||
(.. status-keycard
|
||||
(generateAndLoadKey mnemonic pin)
|
||||
(then on-success)
|
||||
(catch on-failure)))
|
||||
|
||||
(defn unblock-pin
|
||||
[{:keys [puk new-pin on-success on-failure]}]
|
||||
(when (and new-pin puk)
|
||||
(.. status-keycard
|
||||
(unblockPin puk new-pin)
|
||||
(then on-success)
|
||||
(catch on-failure))))
|
||||
|
||||
(defn verify-pin
|
||||
[{:keys [pin on-success on-failure]}]
|
||||
(when (not-empty pin)
|
||||
(.. status-keycard
|
||||
(verifyPin pin)
|
||||
(then on-success)
|
||||
(catch on-failure))))
|
||||
|
||||
(defn change-pin
|
||||
[{:keys [current-pin new-pin on-success on-failure]}]
|
||||
(when (and current-pin new-pin)
|
||||
(.. status-keycard
|
||||
(changePin current-pin new-pin)
|
||||
(then on-success)
|
||||
(catch on-failure))))
|
||||
|
||||
(defn change-puk
|
||||
[{:keys [pin puk on-success on-failure]}]
|
||||
(when (and pin puk)
|
||||
(.. status-keycard
|
||||
(changePUK pin puk)
|
||||
(then on-success)
|
||||
(catch on-failure))))
|
||||
|
||||
(defn change-pairing
|
||||
[{:keys [pin pairing on-success on-failure]}]
|
||||
(when (and pin pairing)
|
||||
(.. status-keycard
|
||||
(changePairingPassword pin pairing)
|
||||
(then on-success)
|
||||
(catch on-failure))))
|
||||
|
||||
(defn unpair
|
||||
[{:keys [pin on-success on-failure]}]
|
||||
(when pin
|
||||
(.. status-keycard
|
||||
(unpair pin)
|
||||
(then on-success)
|
||||
(catch on-failure))))
|
||||
|
||||
(defn delete
|
||||
[{:keys [on-success on-failure]}]
|
||||
(.. status-keycard
|
||||
(delete)
|
||||
(then on-success)
|
||||
(catch on-failure)))
|
||||
|
||||
(defn remove-key
|
||||
[{:keys [pin on-success on-failure]}]
|
||||
(.. status-keycard
|
||||
(removeKey pin)
|
||||
(then on-success)
|
||||
(catch on-failure)))
|
||||
|
||||
(defn remove-key-with-unpair
|
||||
[{:keys [pin on-success on-failure]}]
|
||||
(.. status-keycard
|
||||
(removeKeyWithUnpair pin)
|
||||
(then on-success)
|
||||
(catch on-failure)))
|
||||
|
||||
(defn export-key
|
||||
[{:keys [pin path on-success on-failure]}]
|
||||
(.. status-keycard
|
||||
(exportKeyWithPath pin path)
|
||||
(then on-success)
|
||||
(catch on-failure)))
|
||||
|
||||
(defn unpair-and-delete
|
||||
[{:keys [pin on-success on-failure]}]
|
||||
(when (not-empty pin)
|
||||
(.. status-keycard
|
||||
(unpairAndDelete pin)
|
||||
(then on-success)
|
||||
(catch on-failure))))
|
||||
|
||||
(defn import-keys
|
||||
[{:keys [pin on-success on-failure]}]
|
||||
(when (not-empty pin)
|
||||
(.. status-keycard
|
||||
(importKeys pin)
|
||||
(then on-success)
|
||||
(catch on-failure))))
|
||||
|
||||
(defn get-keys
|
||||
[{:keys [pin on-success on-failure]}]
|
||||
(when (not-empty pin)
|
||||
(.. status-keycard
|
||||
(getKeys pin)
|
||||
(then on-success)
|
||||
(catch on-failure))))
|
||||
|
||||
(defn sign
|
||||
[{pin :pin path :path card-hash :hash on-success :on-success on-failure :on-failure}]
|
||||
(when (and pin card-hash)
|
||||
(if path
|
||||
(.. status-keycard
|
||||
(signWithPath pin path card-hash)
|
||||
(then on-success)
|
||||
(catch on-failure))
|
||||
(.. status-keycard
|
||||
(sign pin card-hash)
|
||||
(then on-success)
|
||||
(catch on-failure)))))
|
||||
|
||||
(defn sign-typed-data
|
||||
[{card-hash :hash on-success :on-success on-failure :on-failure}]
|
||||
(when card-hash
|
||||
(.. status-keycard
|
||||
(signPinless card-hash)
|
||||
(then on-success)
|
||||
(catch on-failure))))
|
||||
|
||||
(defrecord RealKeycard []
|
||||
keycard/Keycard
|
||||
(keycard/start-nfc [_this args]
|
||||
(start-nfc args))
|
||||
(keycard/stop-nfc [_this args]
|
||||
(stop-nfc args))
|
||||
(keycard/set-nfc-message [_this args]
|
||||
(set-nfc-message args))
|
||||
(keycard/check-nfc-support [_this args]
|
||||
(check-nfc-support args))
|
||||
(keycard/check-nfc-enabled [_this args]
|
||||
(check-nfc-enabled args))
|
||||
(keycard/open-nfc-settings [_this]
|
||||
(open-nfc-settings))
|
||||
(keycard/register-card-events [_this args]
|
||||
(register-card-events args))
|
||||
(keycard/on-card-connected [_this callback]
|
||||
(on-card-connected callback))
|
||||
(keycard/on-card-disconnected [_this callback]
|
||||
(on-card-disconnected callback))
|
||||
(keycard/remove-event-listener [_this event]
|
||||
(remove-event-listener event))
|
||||
(keycard/remove-event-listeners [_this]
|
||||
(remove-event-listeners))
|
||||
(keycard/set-pairings [_this args]
|
||||
(set-pairings args))
|
||||
(keycard/get-application-info [_this args]
|
||||
(get-application-info args))
|
||||
(keycard/factory-reset [_this args]
|
||||
(factory-reset args))
|
||||
(keycard/install-applet [_this args]
|
||||
(install-applet args))
|
||||
(keycard/install-cash-applet [_this args]
|
||||
(install-cash-applet args))
|
||||
(keycard/init-card [_this args]
|
||||
(init-card args))
|
||||
(keycard/install-applet-and-init-card [_this args]
|
||||
(install-applet-and-init-card args))
|
||||
(keycard/pair [_this args]
|
||||
(pair args))
|
||||
(keycard/generate-and-load-key [_this args]
|
||||
(generate-and-load-key args))
|
||||
(keycard/unblock-pin [_this args]
|
||||
(unblock-pin args))
|
||||
(keycard/verify-pin [_this args]
|
||||
(verify-pin args))
|
||||
(keycard/change-pin [_this args]
|
||||
(change-pin args))
|
||||
(keycard/change-puk [_this args]
|
||||
(change-puk args))
|
||||
(keycard/change-pairing [_this args]
|
||||
(change-pairing args))
|
||||
(keycard/unpair [_this args]
|
||||
(unpair args))
|
||||
(keycard/delete [_this args]
|
||||
(delete args))
|
||||
(keycard/remove-key [_this args]
|
||||
(remove-key args))
|
||||
(keycard/remove-key-with-unpair [_this args]
|
||||
(remove-key-with-unpair args))
|
||||
(keycard/export-key [_this args]
|
||||
(export-key args))
|
||||
(keycard/unpair-and-delete [_this args]
|
||||
(unpair-and-delete args))
|
||||
(keycard/import-keys [_this args]
|
||||
(import-keys args))
|
||||
(keycard/get-keys [_this args]
|
||||
(get-keys args))
|
||||
(keycard/sign [_this args]
|
||||
(sign args))
|
||||
(keycard/sign-typed-data [_this args]
|
||||
(sign-typed-data args)))
|
||||
@@ -18,7 +18,6 @@
|
||||
[{:keys [current-log-level
|
||||
telemetry-enabled?
|
||||
light-client-enabled?
|
||||
store-confirmations-enabled?
|
||||
current-fleet
|
||||
test-networks-enabled?
|
||||
is-goerli-enabled?
|
||||
@@ -78,15 +77,6 @@
|
||||
[:wakuv2.ui/toggle-light-client (not light-client-enabled?)])
|
||||
:accessory :switch
|
||||
:active light-client-enabled?}
|
||||
{:size :small
|
||||
:title (i18n/label :t/store-confirmations)
|
||||
:accessibility-label :store-confirmations
|
||||
:container-margin-bottom 8
|
||||
:on-press
|
||||
#(re-frame/dispatch
|
||||
[:wakuv2.ui/toggle-store-confirmations (not store-confirmations-enabled?)])
|
||||
:accessory :switch
|
||||
:active store-confirmations-enabled?}
|
||||
{:size :small
|
||||
:title "Testnet mode"
|
||||
:accessibility-label :test-networks-enabled
|
||||
@@ -124,14 +114,13 @@
|
||||
|
||||
(views/defview advanced-settings
|
||||
[]
|
||||
(views/letsubs [test-networks-enabled? [:profile/test-networks-enabled?]
|
||||
is-goerli-enabled? [:profile/is-goerli-enabled?]
|
||||
light-client-enabled? [:profile/light-client-enabled?]
|
||||
store-confirmations-enabled? [:profile/store-confirmations-enabled?]
|
||||
telemetry-enabled? [:profile/telemetry-enabled?]
|
||||
current-log-level [:log-level/current-log-level]
|
||||
current-fleet [:fleets/current-fleet]
|
||||
peer-syncing-enabled? [:profile/peer-syncing-enabled?]]
|
||||
(views/letsubs [test-networks-enabled? [:profile/test-networks-enabled?]
|
||||
is-goerli-enabled? [:profile/is-goerli-enabled?]
|
||||
light-client-enabled? [:profile/light-client-enabled?]
|
||||
telemetry-enabled? [:profile/telemetry-enabled?]
|
||||
current-log-level [:log-level/current-log-level]
|
||||
current-fleet [:fleets/current-fleet]
|
||||
peer-syncing-enabled? [:profile/peer-syncing-enabled?]]
|
||||
[:<>
|
||||
[quo/page-nav
|
||||
{:type :title
|
||||
@@ -141,14 +130,13 @@
|
||||
:on-press #(rf/dispatch [:navigate-back])}]
|
||||
[list/flat-list
|
||||
{:data (flat-list-data
|
||||
{:current-log-level current-log-level
|
||||
:telemetry-enabled? telemetry-enabled?
|
||||
:light-client-enabled? light-client-enabled?
|
||||
:store-confirmations-enabled? store-confirmations-enabled?
|
||||
:current-fleet current-fleet
|
||||
:dev-mode? false
|
||||
:test-networks-enabled? test-networks-enabled?
|
||||
:is-goerli-enabled? is-goerli-enabled?
|
||||
:peer-syncing-enabled? peer-syncing-enabled?})
|
||||
{:current-log-level current-log-level
|
||||
:telemetry-enabled? telemetry-enabled?
|
||||
:light-client-enabled? light-client-enabled?
|
||||
:current-fleet current-fleet
|
||||
:dev-mode? false
|
||||
:test-networks-enabled? test-networks-enabled?
|
||||
:is-goerli-enabled? is-goerli-enabled?
|
||||
:peer-syncing-enabled? peer-syncing-enabled?})
|
||||
:key-fn (fn [_ i] (str i))
|
||||
:render-fn render-item}]]))
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
(ns legacy.status-im.ui.screens.peers-stats
|
||||
(:require
|
||||
[quo.foundations.colors :as colors]
|
||||
[react-native.core :as rn]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(defn peers-stats
|
||||
[]
|
||||
(let [peers-count (rf/sub [:peer-stats/count])
|
||||
theme (rf/sub [:theme])]
|
||||
(let [peers-count (rf/sub [:peer-stats/count])]
|
||||
(rn/use-mount
|
||||
(fn []
|
||||
(rf/dispatch [:peer-stats/get-count])))
|
||||
@@ -20,5 +18,4 @@
|
||||
{:style {:flex-direction :row
|
||||
:margin-vertical 8
|
||||
:justify-content :space-between}}
|
||||
[rn/text {:style {:color (colors/theme-colors colors/neutral-100 colors/white theme)}}
|
||||
(str (i18n/label :t/peers-count) ": " peers-count)]]]))
|
||||
[rn/text (str (i18n/label :t/peers-count) ": " peers-count)]]]))
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
(ns legacy.status-im.utils.hex
|
||||
(:require
|
||||
[clojure.string :as string]))
|
||||
|
||||
(defn normalize-hex
|
||||
[hex]
|
||||
(when hex
|
||||
(string/lower-case (if (string/starts-with? hex "0x")
|
||||
(subs hex 2)
|
||||
hex))))
|
||||
|
||||
(defn valid-hex?
|
||||
[hex]
|
||||
(let [hex (normalize-hex hex)]
|
||||
(and (re-matches #"^[0-9a-fA-F]+$" hex)
|
||||
(not= (js/parseInt hex 16) 0))))
|
||||
@@ -0,0 +1,58 @@
|
||||
(ns legacy.status-im.utils.keychain.core
|
||||
(:require
|
||||
[oops.core :as oops]
|
||||
[re-frame.core :as re-frame]
|
||||
[react-native.keychain :as keychain]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(defn- whisper-key-name
|
||||
[address]
|
||||
(str address "-whisper"))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:keychain/get-keycard-keys
|
||||
(fn [[key-uid callback]]
|
||||
(keychain/get-credentials
|
||||
key-uid
|
||||
(fn [encryption-key-data]
|
||||
(if encryption-key-data
|
||||
(keychain/get-credentials
|
||||
(whisper-key-name key-uid)
|
||||
(fn [whisper-key-data]
|
||||
(if whisper-key-data
|
||||
(callback [(oops/oget encryption-key-data "password")
|
||||
(oops/oget whisper-key-data "password")])
|
||||
(callback nil))))
|
||||
(callback nil))))))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:keychain/save-keycard-keys
|
||||
(fn [[key-uid encryption-public-key whisper-private-key]]
|
||||
(keychain/save-credentials
|
||||
key-uid
|
||||
key-uid
|
||||
encryption-public-key
|
||||
#(when-not %
|
||||
(log/error
|
||||
(str "Error while saving encryption-public-key"))))
|
||||
(keychain/save-credentials
|
||||
(whisper-key-name key-uid)
|
||||
key-uid
|
||||
whisper-private-key
|
||||
#(when-not %
|
||||
(log/error
|
||||
(str "Error while saving whisper-private-key"))))))
|
||||
|
||||
(rf/defn get-keycard-keys
|
||||
[_ key-uid]
|
||||
{:keychain/get-keycard-keys
|
||||
[key-uid
|
||||
#(re-frame/dispatch
|
||||
[:multiaccounts.login.callback/get-keycard-keys-success key-uid %])]})
|
||||
|
||||
(rf/defn save-keycard-keys
|
||||
[_ key-uid encryption-public-key whisper-private-key]
|
||||
{:keychain/save-keycard-keys [key-uid
|
||||
encryption-public-key
|
||||
whisper-private-key]})
|
||||
@@ -137,19 +137,3 @@
|
||||
:on-error #(log/error "failed to set light client"
|
||||
{:error %
|
||||
:enabled? enabled?})}]})
|
||||
|
||||
(rf/defn toggle-store-confirmations
|
||||
{:events [:wakuv2.ui/toggle-store-confirmations]}
|
||||
[{:keys [db]} enabled?]
|
||||
{:db (assoc-in db
|
||||
[:profile/profile :wakuv2-config :EnableStoreConfirmationForMessagesSent]
|
||||
enabled?)
|
||||
|
||||
:json-rpc/call [{:method "wakuext_setStoreConfirmationForMessagesSent"
|
||||
:params [{:enabled enabled?}]
|
||||
:on-success (fn []
|
||||
(log/info "store confirmation set successfully" enabled?)
|
||||
(re-frame/dispatch [:logout]))
|
||||
:on-error #(log/error "failed to set store confirmation"
|
||||
{:error %
|
||||
:enabled? enabled?})}]})
|
||||
|
||||
@@ -110,11 +110,8 @@
|
||||
(def status-keycard
|
||||
#js
|
||||
{:default #js
|
||||
{:nfcIsSupported (fn [] #js {:then identity})
|
||||
:nfcIsEnabled (fn [] #js {:then identity})
|
||||
:getApplicationInfo (fn [] #js {:then identity})
|
||||
:getKeys (fn [] #js {:then identity})
|
||||
:setPairings (fn [] #js {:then identity})}})
|
||||
{:nfcIsSupported (fn [] #js {:then identity})
|
||||
:nfcIsEnabled (fn [] #js {:then identity})}})
|
||||
|
||||
(def snoopy #js {:default #js {}})
|
||||
(def snoopy-filter #js {:default #js {}})
|
||||
|
||||
@@ -87,6 +87,31 @@
|
||||
config
|
||||
#(callback (types/json->clj %))))
|
||||
|
||||
(defn save-multiaccount-and-login-with-keycard
|
||||
"NOTE: chat-key is a whisper private key sent from keycard"
|
||||
[key-uid multiaccount-data password settings config accounts-data chat-key]
|
||||
(log/debug "[native-module] save-account-and-login-with-keycard")
|
||||
(init-keystore
|
||||
key-uid
|
||||
#(.saveAccountAndLoginWithKeycard
|
||||
^js (account-manager)
|
||||
multiaccount-data
|
||||
password
|
||||
settings
|
||||
config
|
||||
accounts-data
|
||||
chat-key)))
|
||||
|
||||
(defn login-with-config
|
||||
"NOTE: beware, the password has to be sha3 hashed"
|
||||
[key-uid account-data hashed-password config]
|
||||
(log/debug "[native-module] loginWithConfig")
|
||||
(clear-web-data)
|
||||
(let [config (if config (types/clj->json config) "")]
|
||||
(init-keystore
|
||||
key-uid
|
||||
#(.loginWithConfig ^js (account-manager) account-data hashed-password config))))
|
||||
|
||||
(defn login-account
|
||||
"NOTE: beware, the password has to be sha3 hashed"
|
||||
[{:keys [keyUid] :as request}]
|
||||
@@ -128,6 +153,19 @@
|
||||
(clear-web-data)
|
||||
(.logout ^js (account-manager)))
|
||||
|
||||
(defn multiaccount-load-account
|
||||
"NOTE: beware, the password has to be sha3 hashed
|
||||
|
||||
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 hashed-password callback]
|
||||
(log/debug "[native-module] multiaccount-load-account")
|
||||
(.multiAccountLoadAccount ^js (account-manager)
|
||||
(types/clj->json {:address address
|
||||
:password hashed-password})
|
||||
callback))
|
||||
|
||||
(defn multiaccount-derive-addresses
|
||||
"NOTE: this should be named derive-accounts
|
||||
this only derive addresses, they still need to be stored
|
||||
@@ -141,6 +179,38 @@
|
||||
:paths paths})
|
||||
callback)))
|
||||
|
||||
(defn multiaccount-store-account
|
||||
"NOTE: beware, the password has to be sha3 hashed
|
||||
|
||||
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 key-uid hashed-password callback]
|
||||
(log/debug "[native-module] multiaccount-store-account")
|
||||
(when (status)
|
||||
(init-keystore
|
||||
key-uid
|
||||
#(.multiAccountStoreAccount ^js (account-manager)
|
||||
(types/clj->json {:accountID account-id
|
||||
:password hashed-password})
|
||||
callback))))
|
||||
|
||||
(defn multiaccount-store-derived
|
||||
"NOTE: beware, the password has to be sha3 hashed"
|
||||
[account-id key-uid paths hashed-password callback]
|
||||
(log/debug "[native-module] multiaccount-store-derived"
|
||||
"account-id"
|
||||
account-id)
|
||||
(init-keystore
|
||||
key-uid
|
||||
#(.multiAccountStoreDerived ^js (account-manager)
|
||||
(types/clj->json {:accountID account-id
|
||||
:paths paths
|
||||
:password hashed-password})
|
||||
callback)))
|
||||
|
||||
(defn multiaccount-generate-and-derive-addresses
|
||||
"used to generate multiple multiaccounts for onboarding
|
||||
NOTE: nothing is saved so you will need to use
|
||||
@@ -164,12 +234,37 @@
|
||||
:Bip39Passphrase password})
|
||||
callback))
|
||||
|
||||
(defn multiaccount-import-private-key
|
||||
[private-key callback]
|
||||
(log/debug "[native-module] multiaccount-import-private-key")
|
||||
(.multiAccountImportPrivateKey ^js (account-manager)
|
||||
(types/clj->json {:privateKey private-key})
|
||||
callback))
|
||||
|
||||
(defn verify
|
||||
"NOTE: beware, the password has to be sha3 hashed"
|
||||
[address hashed-password callback]
|
||||
(log/debug "[native-module] verify")
|
||||
(.verify ^js (account-manager) address hashed-password callback))
|
||||
|
||||
(defn verify-database-password
|
||||
"NOTE: beware, the password has to be sha3 hashed"
|
||||
[key-uid hashed-password callback]
|
||||
(log/debug "[native-module] verify-database-password")
|
||||
(.verifyDatabasePassword ^js (account-manager) key-uid hashed-password callback))
|
||||
|
||||
(defn login-with-keycard
|
||||
[{:keys [key-uid multiaccount-data password chat-key node-config]}]
|
||||
(log/debug "[native-module] login-with-keycard")
|
||||
(clear-web-data)
|
||||
(init-keystore
|
||||
key-uid
|
||||
#(.loginWithKeycard ^js (account-manager)
|
||||
multiaccount-data
|
||||
password
|
||||
chat-key
|
||||
(types/clj->json node-config))))
|
||||
|
||||
(defn set-soft-input-mode
|
||||
[mode]
|
||||
(log/debug "[native-module] set-soft-input-mode")
|
||||
@@ -238,11 +333,6 @@
|
||||
:key input-key})
|
||||
(.deserializeAndCompressKey ^js (encryption) input-key callback))
|
||||
|
||||
(defn serialize-legacy-key
|
||||
"Compresses an old format public key (0x04...) to the new one zQ..."
|
||||
[public-key]
|
||||
(.serializeLegacyKey ^js (encryption) public-key))
|
||||
|
||||
(defn compressed-key->public-key
|
||||
"Provides compressed key to status-go and gets back the uncompressed public key via deserialization"
|
||||
[public-key deserialization-key callback]
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
(defn- get-dimensions
|
||||
[size]
|
||||
(case size
|
||||
:size-32 32
|
||||
:size-24 24
|
||||
:size-20 20
|
||||
nil))
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
(ns quo.components.avatars.token-avatar.view
|
||||
(:require [quo.components.avatars.token-avatar.style :as style]
|
||||
[quo.components.utilities.token.view :as token]
|
||||
[react-native.core :as rn]
|
||||
[react-native.hole-view :as hole-view]
|
||||
[react-native.platform :as platform]
|
||||
@@ -13,14 +12,13 @@
|
||||
[:map {:closed true}
|
||||
[:type {:optional true} [:enum :asset :collectible]]
|
||||
[:context? {:optional true} [:maybe :boolean]]
|
||||
[:image {:optional true} [:maybe :schema.common/image-source]]
|
||||
[:token {:optional true} [:maybe [:or :keyword :string]]]
|
||||
[:image :schema.common/image-source]
|
||||
[:network-image {:optional true} [:maybe :schema.common/image-source]]
|
||||
[:container-style {:optional true} [:maybe :map]]]]]
|
||||
:any])
|
||||
|
||||
(defn- view-internal
|
||||
[{:keys [type context? image token network-image container-style]}]
|
||||
[{:keys [type context? image network-image container-style]}]
|
||||
[rn/view
|
||||
{:style (merge style/container container-style)
|
||||
:accessibility-label :token-avatar}
|
||||
@@ -34,11 +32,9 @@
|
||||
[])
|
||||
:style style/hole-view}
|
||||
platform/android? (assoc :key context?))
|
||||
[token/view
|
||||
{:size :size-32
|
||||
:token token
|
||||
:style (style/image type)
|
||||
:image-source image}]]
|
||||
[rn/image
|
||||
{:source image
|
||||
:style (style/image type)}]]
|
||||
(when context?
|
||||
[rn/image
|
||||
{:source network-image
|
||||
|
||||
@@ -21,17 +21,15 @@
|
||||
(colors/theme-colors colors/white colors/neutral-95 theme))})
|
||||
|
||||
(defn buttons-container
|
||||
[actions container-style]
|
||||
(merge
|
||||
{:flex-direction (if (= actions :two-vertical-actions) :column :row)
|
||||
:justify-content :space-around
|
||||
:padding-vertical 12
|
||||
:gap 12
|
||||
:padding-horizontal 20}
|
||||
container-style))
|
||||
[actions]
|
||||
{:flex-direction (if (= actions :two-vertical-actions) :column :row)
|
||||
:justify-content :space-around
|
||||
:padding-vertical 12
|
||||
:gap 12
|
||||
:padding-horizontal 20})
|
||||
|
||||
(def button-container
|
||||
{:flex-grow 1})
|
||||
{:flex 1})
|
||||
|
||||
(def description-top
|
||||
{:flex-direction :row
|
||||
|
||||
@@ -30,8 +30,7 @@
|
||||
[:button-two-props {:optional true} [:maybe :map]]
|
||||
[:scroll? {:optional true} [:maybe :boolean]]
|
||||
[:blur? {:optional true} [:maybe :boolean]]
|
||||
[:container-style {:optional true} [:maybe :map]]
|
||||
[:buttons-container-style {:optional true} [:maybe :map]]]]]
|
||||
[:container-style {:optional true} [:maybe :map]]]]]
|
||||
:any])
|
||||
|
||||
(def ^:private role-icon
|
||||
@@ -43,7 +42,7 @@
|
||||
(defn- view-internal
|
||||
[{:keys [actions description description-text description-top-text error-message role button-one-label
|
||||
button-two-label blur? button-one-props button-two-props scroll? container-style
|
||||
buttons-container-style context-tag-props]}]
|
||||
context-tag-props]}]
|
||||
(let [theme (quo.theme/use-theme)]
|
||||
[rn/view
|
||||
{:style (merge (style/container scroll? blur? theme) container-style)}
|
||||
@@ -73,14 +72,14 @@
|
||||
:context (i18n/label (keyword "t" role))}
|
||||
context-tag-props)]])
|
||||
|
||||
[rn/view {:style (style/buttons-container actions buttons-container-style)}
|
||||
[rn/view {:style (style/buttons-container actions)}
|
||||
(when (or (= actions :two-actions)
|
||||
(= actions :two-vertical-actions))
|
||||
[button/button
|
||||
(merge
|
||||
{:size 40
|
||||
:container-style style/button-container
|
||||
:background (when (or blur? scroll?) :blur)
|
||||
:container-style style/button-container
|
||||
:theme theme
|
||||
:accessibility-label :button-two}
|
||||
button-two-props)
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
(ns quo.components.list-items.approval-info.component-spec
|
||||
(:require [quo.components.list-items.approval-info.view :as approval-info]
|
||||
[test-helpers.component :as h]))
|
||||
|
||||
(h/describe "List Items: Approval Info"
|
||||
(h/test "should render correctly with basic props"
|
||||
(h/render-with-theme-provider
|
||||
[approval-info/view
|
||||
{:type :spending-cap
|
||||
:label "Spending Cap"
|
||||
:avatar-props {:image "image"}}])
|
||||
(h/is-truthy (h/get-by-label-text :approval-info)))
|
||||
|
||||
(h/test "should render correctly with label & description"
|
||||
(h/render-with-theme-provider
|
||||
[approval-info/view
|
||||
{:type :spending-cap
|
||||
:label "Spending Cap"
|
||||
:description "Description"
|
||||
:avatar-props {:image "image"}}])
|
||||
(h/is-truthy (h/get-by-text "Spending Cap"))
|
||||
(h/is-truthy (h/get-by-text "Description")))
|
||||
|
||||
(h/test "on-button-press event is called when button is pressed"
|
||||
(let [on-button-press (h/mock-fn)]
|
||||
(h/render-with-theme-provider
|
||||
[approval-info/view
|
||||
{:type :spending-cap
|
||||
:label "Spending Cap"
|
||||
:button-label "Edit"
|
||||
:on-button-press on-button-press
|
||||
:avatar-props {:image "image"}}])
|
||||
(h/fire-event :press (h/get-by-text "Edit"))
|
||||
(h/was-called on-button-press)))
|
||||
|
||||
(h/test "on-option-press event is called when option icon is pressed"
|
||||
(let [on-option-press (h/mock-fn)]
|
||||
(h/render-with-theme-provider
|
||||
[approval-info/view
|
||||
{:type :spending-cap
|
||||
:label "Spending Cap"
|
||||
:option-icon :i/options
|
||||
:on-option-press on-option-press
|
||||
:avatar-props {:image "image"}}])
|
||||
(h/fire-event :press (h/get-by-label-text :icon))
|
||||
(h/was-called on-option-press)))
|
||||
|
||||
(h/test "on-avatar-press event is called when avatar is pressed"
|
||||
(let [on-avatar-press (h/mock-fn)]
|
||||
(h/render-with-theme-provider
|
||||
[approval-info/view
|
||||
{:type :spending-cap
|
||||
:label "Spending Cap"
|
||||
:on-avatar-press on-avatar-press
|
||||
:avatar-props {:image "image"}}])
|
||||
(h/fire-event :press (h/get-by-label-text :token-avatar))
|
||||
(h/was-called on-avatar-press))))
|
||||
@@ -1,36 +0,0 @@
|
||||
(ns quo.components.list-items.approval-info.style
|
||||
(:require [quo.foundations.colors :as colors]))
|
||||
|
||||
(defn icon-description-color
|
||||
[blur? theme]
|
||||
(if blur?
|
||||
colors/white-opa-40
|
||||
(colors/theme-colors colors/neutral-50 colors/neutral-40 theme)))
|
||||
|
||||
(defn container
|
||||
[description? blur? theme]
|
||||
{:flex-direction :row
|
||||
:padding-horizontal 12
|
||||
:padding-vertical (if description? 8 12)
|
||||
:border-radius 16
|
||||
:gap 8
|
||||
:align-items :center
|
||||
:border-width 1
|
||||
:border-color (if blur?
|
||||
colors/white-opa-5
|
||||
(colors/theme-colors colors/neutral-10 colors/neutral-80 theme))})
|
||||
|
||||
(def labels
|
||||
{:flex 1
|
||||
:justify-content :center
|
||||
:padding-right 4})
|
||||
|
||||
(defn label
|
||||
[blur? theme]
|
||||
{:color (if blur?
|
||||
colors/white
|
||||
(colors/theme-colors colors/neutral-100 colors/white theme))})
|
||||
|
||||
(defn description
|
||||
[blur? theme]
|
||||
{:color (icon-description-color blur? theme)})
|
||||
@@ -1,124 +0,0 @@
|
||||
(ns quo.components.list-items.approval-info.view
|
||||
(:require [clojure.string :as string]
|
||||
[quo.components.avatars.account-avatar.view :as account-avatar]
|
||||
[quo.components.avatars.collection-avatar.view :as collection-avatar]
|
||||
[quo.components.avatars.community-avatar.view :as community-avatar]
|
||||
[quo.components.avatars.dapp-avatar.view :as dapp-avatar]
|
||||
[quo.components.avatars.icon-avatar :as icon-avatar]
|
||||
[quo.components.avatars.token-avatar.view :as token-avatar]
|
||||
[quo.components.avatars.wallet-user-avatar.view :as wallet-user-avatar]
|
||||
[quo.components.buttons.button.view :as button]
|
||||
[quo.components.icon :as icon]
|
||||
[quo.components.list-items.approval-info.style :as style]
|
||||
[quo.components.markdown.text :as text]
|
||||
[quo.components.tags.tiny-tag.view :as tiny-tag]
|
||||
[quo.foundations.colors :as colors]
|
||||
quo.theme
|
||||
[react-native.core :as rn]
|
||||
[schema.core :as schema]))
|
||||
|
||||
(def ?schema
|
||||
[:=>
|
||||
[:catn
|
||||
[:props
|
||||
[:map {:closed true}
|
||||
[:type
|
||||
[:enum :spending-cap :token-contract :account :spending-contract :network :date-signed
|
||||
:collectible :address :community :collectible-contract]]
|
||||
[:avatar-props :map]
|
||||
[:label :string]
|
||||
[:description {:optional true} [:maybe :string]]
|
||||
[:button-label {:optional true} [:maybe :string]]
|
||||
[:button-icon {:optional true} [:maybe :keyword]]
|
||||
[:blur? {:optional true} [:maybe :boolean]]
|
||||
[:unlimited-icon? {:optional true} [:maybe :boolean]]
|
||||
[:option-icon {:optional true} [:maybe :keyword]]
|
||||
[:tag-label {:optional true} [:maybe :string]]
|
||||
[:on-button-press {:optional true} [:maybe fn?]]
|
||||
[:on-avatar-press {:optional true} [:maybe fn?]]
|
||||
[:on-option-press {:optional true} [:maybe fn?]]
|
||||
[:container-style {:optional true} [:maybe :any]]]]]
|
||||
:any])
|
||||
|
||||
(defn- avatar
|
||||
[{:keys [type avatar-props blur? theme on-press]}]
|
||||
[rn/pressable {:on-press on-press}
|
||||
(case type
|
||||
:account [account-avatar/view (assoc avatar-props :size 32)]
|
||||
:collectible-contract [collection-avatar/view (assoc avatar-props :size :size-32)]
|
||||
:spending-contract [dapp-avatar/view avatar-props]
|
||||
:date-signed [icon-avatar/icon-avatar
|
||||
(assoc avatar-props
|
||||
:size :size-32
|
||||
:opacity 10
|
||||
:color (if blur?
|
||||
colors/white
|
||||
(colors/theme-colors colors/neutral-50
|
||||
colors/neutral-40
|
||||
theme)))]
|
||||
:address [wallet-user-avatar/wallet-user-avatar
|
||||
(assoc avatar-props
|
||||
:size :size-32
|
||||
:monospace? true
|
||||
:lowercase? true
|
||||
:neutral? true)]
|
||||
:community [community-avatar/view avatar-props]
|
||||
[token-avatar/view
|
||||
(assoc avatar-props
|
||||
:type
|
||||
(if (= type :collectible) :collectible :asset))])])
|
||||
|
||||
(defn- view-internal
|
||||
[{:keys [type avatar-props label description blur? unlimited-icon? container-style
|
||||
on-option-press on-avatar-press on-button-press button-label button-icon tag-label
|
||||
option-icon]}]
|
||||
(let [theme (quo.theme/use-theme)
|
||||
description? (not (string/blank? description))]
|
||||
[rn/view
|
||||
{:style (merge (style/container description? blur? theme) container-style)
|
||||
:accessibility-label :approval-info}
|
||||
[avatar
|
||||
{:type type
|
||||
:blur? blur?
|
||||
:theme theme
|
||||
:on-press on-avatar-press
|
||||
:avatar-props avatar-props}]
|
||||
[rn/view
|
||||
{:style style/labels}
|
||||
[rn/view
|
||||
{:style {:flex-direction :row :align-items :center}}
|
||||
[text/text
|
||||
{:size :paragraph-1
|
||||
:weight (if (= type :address) :monospace :semi-bold)
|
||||
:style (style/label blur? theme)}
|
||||
label]
|
||||
(when unlimited-icon?
|
||||
[icon/icon :i/alert
|
||||
{:container-style {:margin-left 4}
|
||||
:size 16
|
||||
:color (style/icon-description-color blur? theme)}])]
|
||||
(when description?
|
||||
[text/text
|
||||
{:size :paragraph-2
|
||||
:weight (if (contains? #{:collectible-contract :spending-contract :account :token-contract}
|
||||
type)
|
||||
:monospace
|
||||
:regular)
|
||||
:style (style/description blur? theme)}
|
||||
description])]
|
||||
(when (= type :account) [tiny-tag/view {:label tag-label}])
|
||||
(when (= type :spending-cap)
|
||||
[button/button
|
||||
{:type :outline
|
||||
:size 24
|
||||
:blur? blur?
|
||||
:icon-left button-icon
|
||||
:on-press on-button-press}
|
||||
button-label])
|
||||
(when option-icon
|
||||
[rn/pressable {:on-press on-option-press}
|
||||
[icon/icon option-icon
|
||||
{:color (style/icon-description-color blur? theme)
|
||||
:size 20}]])]))
|
||||
|
||||
(def view (schema/instrument #'view-internal ?schema))
|
||||
@@ -1,43 +0,0 @@
|
||||
(ns quo.components.pin-input.pin.view
|
||||
(:require [quo.foundations.colors :as colors]
|
||||
quo.theme
|
||||
[react-native.core :as rn]))
|
||||
|
||||
(defn view
|
||||
[{:keys [theme state blur?]}]
|
||||
(let [app-theme (quo.theme/use-theme)
|
||||
theme (or theme app-theme)]
|
||||
[rn/view {:style {:width 36 :height 36 :align-items :center :justify-content :center}}
|
||||
(case state
|
||||
:active
|
||||
[rn/view
|
||||
{:style {:width 16
|
||||
:height 16
|
||||
:border-radius 8
|
||||
:background-color (if blur?
|
||||
colors/white-opa-20
|
||||
(colors/theme-colors colors/neutral-40 colors/neutral-50 theme))}}]
|
||||
:filled
|
||||
[rn/view
|
||||
{:style {:width 16
|
||||
:height 16
|
||||
:border-radius 8
|
||||
:background-color (if blur?
|
||||
colors/white
|
||||
(colors/theme-colors colors/neutral-100 colors/white theme))}}]
|
||||
:error
|
||||
[rn/view
|
||||
{:style {:width 16
|
||||
:height 16
|
||||
:border-radius 8
|
||||
:background-color (if blur?
|
||||
colors/danger-60
|
||||
(colors/theme-colors colors/danger-50 colors/danger-60 theme))}}]
|
||||
[rn/view
|
||||
{:style
|
||||
{:width 12
|
||||
:height 12
|
||||
:border-radius 6
|
||||
:background-color (if blur?
|
||||
colors/white-opa-20
|
||||
(colors/theme-colors colors/neutral-40 colors/neutral-50 theme))}}])]))
|
||||
@@ -1,27 +0,0 @@
|
||||
(ns quo.components.pin-input.view
|
||||
(:require [quo.components.markdown.text :as text]
|
||||
[quo.components.pin-input.pin.view :as pin]
|
||||
[quo.foundations.colors :as colors]
|
||||
quo.theme
|
||||
[react-native.core :as rn]))
|
||||
|
||||
(defn view
|
||||
[{:keys [number-of-pins number-of-filled-pins error? info]
|
||||
:or {number-of-pins 6 number-of-filled-pins 0}}]
|
||||
(let [theme (quo.theme/use-theme)]
|
||||
[rn/view {:style {:align-items :center}}
|
||||
[rn/view {:style {:flex-direction :row}}
|
||||
(for [i (range 1 (inc number-of-pins))]
|
||||
^{:key i}
|
||||
[pin/view
|
||||
{:state (cond
|
||||
error? :error
|
||||
(<= i number-of-filled-pins) :filled
|
||||
(= i (inc number-of-filled-pins)) :active)}])]
|
||||
(when info
|
||||
[text/text
|
||||
{:style {:color (if error?
|
||||
(colors/theme-colors colors/danger-50 colors/danger-60 theme)
|
||||
(colors/theme-colors colors/neutral-50 colors/neutral-40 theme))}
|
||||
:size :paragraph-2}
|
||||
info])]))
|
||||
@@ -79,20 +79,14 @@
|
||||
[counter-view counter])
|
||||
[rn/view {:style (style/collectible-border theme)}]]]))
|
||||
|
||||
(defn invalid-image?
|
||||
[image-src]
|
||||
(or (nil? image-src)
|
||||
(string/blank? image-src)))
|
||||
|
||||
(defn view-internal
|
||||
[{:keys [container-style square? on-press counter image-src native-ID supported-file?
|
||||
on-collectible-load aspect-ratio gradient-color-index]
|
||||
:or {gradient-color-index :gradient-1
|
||||
on-collectible-load (fn [])}}]
|
||||
(let [theme (quo.theme/use-theme)
|
||||
[error? set-error] (rn/use-state (invalid-image? image-src))]
|
||||
(rn/use-effect #(set-error (invalid-image? image-src))
|
||||
[image-src])
|
||||
[error? set-error] (rn/use-state (or (nil? image-src)
|
||||
(string/blank? image-src)))]
|
||||
[rn/pressable
|
||||
{:style (merge container-style (style/container aspect-ratio))
|
||||
:accessibility-label :expanded-collectible
|
||||
|
||||
@@ -159,19 +159,4 @@
|
||||
:icon :i/placeholder
|
||||
:emoji "🎮"
|
||||
:customization-color :yellow}])
|
||||
(h/is-truthy (h/query-by-label-text :account-emoji)))
|
||||
|
||||
(h/test "edit icon is visible when subtitle type is editable"
|
||||
(h/render [quo/data-item
|
||||
{:on-press (h/mock-fn)
|
||||
:blur? false
|
||||
:card? true
|
||||
:status :default
|
||||
:size :default
|
||||
:title "Label"
|
||||
:subtitle "Subtitle"
|
||||
:subtitle-type :editable
|
||||
:icon :i/placeholder
|
||||
:emoji "🎮"
|
||||
:customization-color :yellow}])
|
||||
(h/is-truthy (h/query-by-label-text :edit-icon))))
|
||||
(h/is-truthy (h/query-by-label-text :account-emoji))))
|
||||
|
||||
@@ -54,7 +54,6 @@
|
||||
|
||||
(def subtitle-container
|
||||
{:flex-direction :row
|
||||
:align-items :center
|
||||
:margin-bottom 1})
|
||||
|
||||
(def right-container
|
||||
@@ -63,7 +62,7 @@
|
||||
|
||||
(defn subtitle-icon-container
|
||||
[subtitle-type]
|
||||
{:margin-right (when-not (contains? #{:editable :default} subtitle-type) 4)
|
||||
{:margin-right (when (not= :default subtitle-type) 4)
|
||||
:justify-content :center})
|
||||
|
||||
(defn title
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
[quo.components.settings.data-item.style :as style]
|
||||
[quo.foundations.colors :as colors]
|
||||
[quo.theme :as quo.theme]
|
||||
[react-native.core :as rn]
|
||||
[schema.core :as schema]))
|
||||
[react-native.core :as rn]))
|
||||
|
||||
(defn- left-loading
|
||||
[{:keys [size blur?]}]
|
||||
@@ -41,17 +40,7 @@
|
||||
{:weight :medium
|
||||
:size :paragraph-2
|
||||
:style (style/description blur? theme)}
|
||||
subtitle]
|
||||
(when (= subtitle-type :editable)
|
||||
[icons/icon :i/edit
|
||||
{:accessibility-label :edit-icon
|
||||
:size 12
|
||||
:container-style {:margin-left 2}
|
||||
:color (if blur?
|
||||
colors/neutral-40
|
||||
(colors/theme-colors colors/neutral-50
|
||||
colors/neutral-40
|
||||
theme))}])]))
|
||||
subtitle]]))
|
||||
|
||||
(defn- left-title
|
||||
[{:keys [title blur?]}]
|
||||
@@ -111,32 +100,7 @@
|
||||
:color icon-color
|
||||
:size 20}]])]))
|
||||
|
||||
|
||||
(def ?schema
|
||||
[:=>
|
||||
[:catn
|
||||
[:props
|
||||
[:map {:closed true}
|
||||
[:blur? {:optional true} [:maybe :boolean]]
|
||||
[:card? {:optional true} [:maybe :boolean]]
|
||||
[:right-icon {:optional true} [:maybe :keyword]]
|
||||
[:right-content {:optional true} [:maybe :map]]
|
||||
[:icon-color {:optional true} [:maybe :schema.common/customization-color]]
|
||||
[:status {:optional true} [:maybe [:enum :default :loading]]]
|
||||
[:subtitle-type {:optional true} [:maybe [:enum :default :icon :network :account :editable]]]
|
||||
[:size {:optional true} [:maybe [:enum :default :small :large]]]
|
||||
[:title :string]
|
||||
[:subtitle {:optional true} [:maybe :string]]
|
||||
[:custom-subtitle {:optional true} [:maybe fn?]]
|
||||
[:icon {:optional true} [:maybe :keyword]]
|
||||
[:emoji {:optional true} [:maybe :string]]
|
||||
[:customization-color {:optional true} [:maybe :schema.common/customization-color]]
|
||||
[:network-image {:optional true} [:maybe :schema.common/image-source]]
|
||||
[:on-press {:optional true} [:maybe fn?]]
|
||||
[:container-style {:optional true} [:maybe :map]]]]]
|
||||
:any])
|
||||
|
||||
(defn view-internal
|
||||
(defn view
|
||||
[{:keys [blur? card? right-icon right-content status size on-press container-style]
|
||||
:as props}]
|
||||
(let [theme (quo.theme/use-theme)
|
||||
@@ -159,5 +123,3 @@
|
||||
{:right-icon right-icon
|
||||
:right-content right-content
|
||||
:icon-color icon-color}])]))
|
||||
|
||||
(def view (schema/instrument #'view-internal ?schema))
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
(ns quo.components.slideshow.slider-bar.component-spec
|
||||
(:require
|
||||
[quo.components.slideshow.slider-bar.view :as slider-bar]
|
||||
[test-helpers.component :as h]))
|
||||
|
||||
(h/describe "Slideshow: slider-bar"
|
||||
(h/test "default render"
|
||||
(h/render-with-theme-provider [slider-bar/view {:accessibility-label :slider-bar}])
|
||||
(h/is-truthy (h/query-by-label-text :slider-bar)))
|
||||
|
||||
(h/test "render with total-amount and active-index"
|
||||
(h/render-with-theme-provider [slider-bar/view
|
||||
{:total-amount 4
|
||||
:active-index 1
|
||||
:accessibility-label :slider-bar}])
|
||||
(h/is-truthy (h/query-by-label-text :slider-bar))
|
||||
(h/is-equal 4 (count (h/query-all-by-label-text :slide-bar-item))))
|
||||
|
||||
(h/test "render with total-amount active-index and possible scroll"
|
||||
(h/render-with-theme-provider [slider-bar/view
|
||||
{:total-amount 10
|
||||
:active-index 7
|
||||
:accessibility-label :slider-bar}])
|
||||
(h/is-truthy (h/query-by-label-text :slider-bar))
|
||||
(h/is-equal 10 (count (h/query-all-by-label-text :slide-bar-item)))))
|
||||
@@ -1,14 +0,0 @@
|
||||
(ns quo.components.slideshow.slider-bar.schema)
|
||||
|
||||
(def ?schema
|
||||
[:=>
|
||||
[:cat
|
||||
[:map {:closed true}
|
||||
[:total-amount {:optional true} [:maybe :int]]
|
||||
[:active-index {:optional true} :int]
|
||||
[:customization-color {:optional true}
|
||||
[:maybe :schema.common/customization-color]]
|
||||
[:blur? {:optional true} [:maybe :boolean]]
|
||||
[:accessibility-label {:optional true} [:maybe :keyword]]
|
||||
[:container-style {:optional true} [:maybe :map]]]]
|
||||
:any])
|
||||
@@ -1,31 +0,0 @@
|
||||
(ns quo.components.slideshow.slider-bar.style
|
||||
(:require
|
||||
[quo.foundations.colors :as colors]))
|
||||
|
||||
(def list-wrapper
|
||||
{:align-items :center})
|
||||
|
||||
(defn list-bar
|
||||
[bar-width]
|
||||
{:width bar-width})
|
||||
|
||||
(defn item-wrapper
|
||||
[{:keys [size spacing]}]
|
||||
{:width size
|
||||
:height size
|
||||
:margin-left spacing
|
||||
:flex 1
|
||||
:align-items :center
|
||||
:justify-content :center})
|
||||
|
||||
(defn item
|
||||
[{:keys [size spacing active? customization-color theme blur?]}]
|
||||
{:width size
|
||||
:height size
|
||||
:border-radius spacing
|
||||
:background-color
|
||||
(cond
|
||||
(and blur? active?) colors/white
|
||||
(and blur? (not active?)) colors/white-opa-10
|
||||
(and (not blur?) active?) (colors/resolve-color customization-color theme)
|
||||
:else (colors/theme-colors colors/neutral-20 colors/neutral-80 theme))})
|
||||
@@ -1,150 +0,0 @@
|
||||
(ns quo.components.slideshow.slider-bar.view
|
||||
(:require
|
||||
[quo.components.slideshow.slider-bar.schema :as component-schema]
|
||||
[quo.components.slideshow.slider-bar.style :as style]
|
||||
[quo.theme]
|
||||
[react-native.core :as rn]
|
||||
[react-native.reanimated :as reanimated]
|
||||
[schema.core :as schema]))
|
||||
|
||||
(def item-size 8)
|
||||
(def item-spacing item-size)
|
||||
(def max-length 6)
|
||||
(def bar-width (* (+ item-spacing item-size) max-length))
|
||||
|
||||
(def micro-scale 0.25)
|
||||
(def small-scale 0.5)
|
||||
(def medium-scale 0.75)
|
||||
(def default-scale 1)
|
||||
|
||||
(def items-before-scroll
|
||||
(/ max-length 2))
|
||||
|
||||
(defn- calc-relative-index
|
||||
"Calculates item index in visible area"
|
||||
[index active-index total-length]
|
||||
(let [last-index (dec total-length)]
|
||||
(cond
|
||||
(< active-index items-before-scroll) index
|
||||
(> active-index
|
||||
(- last-index items-before-scroll)) (+ (- index total-length) max-length)
|
||||
:else (+ (- index active-index) items-before-scroll))))
|
||||
|
||||
(defn- calc-first-item-scale
|
||||
"Calculates scale for first item in visible area"
|
||||
[active-index]
|
||||
(cond
|
||||
(= active-index items-before-scroll) medium-scale
|
||||
(> active-index items-before-scroll) small-scale
|
||||
:else default-scale))
|
||||
|
||||
(defn- calc-second-item-scale
|
||||
"Calculates scale for second item in visible area"
|
||||
[active-index]
|
||||
(if (> active-index items-before-scroll)
|
||||
medium-scale
|
||||
default-scale))
|
||||
|
||||
(defn- calc-last-item-scale
|
||||
"Calculates scale for last item in visible area"
|
||||
[active-index total-length]
|
||||
(let [last-index (dec total-length)]
|
||||
(if (> active-index (- last-index items-before-scroll))
|
||||
medium-scale
|
||||
small-scale)))
|
||||
|
||||
(defn- calc-last-but-one-item-scale
|
||||
"Calculates scale for before last item in visible area"
|
||||
[active-index total-length]
|
||||
(if (> active-index (- (dec total-length) items-before-scroll))
|
||||
default-scale
|
||||
medium-scale))
|
||||
|
||||
(defn- get-scale
|
||||
[index active-index total-length]
|
||||
(let [relative-index (calc-relative-index index active-index total-length)]
|
||||
(if (or (= index active-index)
|
||||
(< total-length max-length))
|
||||
default-scale
|
||||
(cond
|
||||
(< relative-index 0) micro-scale
|
||||
(= relative-index 0) (calc-first-item-scale active-index)
|
||||
(= relative-index 1) (calc-second-item-scale active-index)
|
||||
(= relative-index 4) (calc-last-but-one-item-scale active-index total-length)
|
||||
(= relative-index 5) (calc-last-item-scale active-index total-length)
|
||||
(> relative-index 5) micro-scale
|
||||
:else
|
||||
default-scale))))
|
||||
|
||||
(defn- bar-item
|
||||
[index _ _ {:keys [active-index total-length customization-color theme blur?]}]
|
||||
(let [active? (= index active-index)
|
||||
shared-scale (reanimated/use-shared-value (get-scale index active-index total-length))]
|
||||
(rn/use-effect (fn []
|
||||
(let [new-scale-value (get-scale index active-index total-length)]
|
||||
(reanimated/animate shared-scale new-scale-value)))
|
||||
[index active-index total-length])
|
||||
[rn/view
|
||||
{:key index
|
||||
:style (style/item-wrapper {:size item-size
|
||||
:spacing item-spacing})}
|
||||
[reanimated/view
|
||||
{:accessibility-label :slide-bar-item
|
||||
:style
|
||||
(reanimated/apply-animations-to-style
|
||||
{:transform [{:scale shared-scale}]}
|
||||
(style/item {:size item-size
|
||||
:spacing item-spacing
|
||||
:active? active?
|
||||
:customization-color customization-color
|
||||
:theme theme
|
||||
:blur? blur?}))}]]))
|
||||
|
||||
(defn- get-item-layout
|
||||
[_ index]
|
||||
(let [length (+ item-size item-spacing)]
|
||||
#js {:length length
|
||||
:index index
|
||||
:offset (* index length)}))
|
||||
|
||||
(defn- view-internal
|
||||
[{:keys [customization-color blur? accessibility-label container-style]
|
||||
:as props}]
|
||||
(let [active-index (or (:active-index props) 0)
|
||||
total-amount (or (:total-amount props) 1)
|
||||
theme (quo.theme/use-theme)
|
||||
flat-list-ref (rn/use-ref-atom nil)
|
||||
set-flat-list-ref (rn/use-callback #(reset! flat-list-ref %))
|
||||
center-position 0.5
|
||||
data (range total-amount)
|
||||
scroll-to-index (rn/use-callback
|
||||
(fn []
|
||||
(some-> ^js @flat-list-ref
|
||||
(.scrollToIndex #js {:animated true
|
||||
:index active-index
|
||||
:viewOffset item-spacing
|
||||
:viewPosition center-position})))
|
||||
[flat-list-ref active-index])]
|
||||
(rn/use-effect scroll-to-index [active-index])
|
||||
[rn/view
|
||||
{:style (merge style/list-wrapper container-style)
|
||||
:accessibility-label accessibility-label}
|
||||
[reanimated/flat-list
|
||||
{:style (style/list-bar bar-width)
|
||||
:data data
|
||||
:scroll-enabled false
|
||||
:ref set-flat-list-ref
|
||||
:shows-horizontal-scroll-indicator false
|
||||
:bounces false
|
||||
:horizontal true
|
||||
:extra-data (str active-index)
|
||||
:render-data {:active-index active-index
|
||||
:total-length total-amount
|
||||
:customization-color customization-color
|
||||
:theme theme
|
||||
:blur? blur?}
|
||||
:get-item-layout get-item-layout
|
||||
:render-fn bar-item
|
||||
:key-fn identity}]]))
|
||||
|
||||
(def view (schema/instrument #'view-internal component-schema/?schema))
|
||||
@@ -53,7 +53,7 @@
|
||||
(def ^:private ?network
|
||||
[:map
|
||||
[:network-logo {:optional true} [:maybe :schema.common/image-source]]
|
||||
[:network-name {:optional true} [:maybe [:or :string :keyword]]]])
|
||||
[:network-name {:optional true} [:maybe :string]]])
|
||||
|
||||
(def ^:private ?multinetwork
|
||||
[:map
|
||||
|
||||
@@ -41,8 +41,7 @@
|
||||
:align-items :center
|
||||
:height size
|
||||
:background-color background-color
|
||||
:border-radius border-radius
|
||||
:flex-shrink 1}
|
||||
:border-radius border-radius}
|
||||
(= state :selected) (assoc :height (+ size 2)
|
||||
:border-color border-color
|
||||
:border-width 1))))
|
||||
@@ -51,13 +50,11 @@
|
||||
[size]
|
||||
{:margin-right (if (= size 24) 6 10)
|
||||
:flex-direction :row
|
||||
:flex-shrink 1
|
||||
:align-items :center})
|
||||
|
||||
(defn tag-spacing
|
||||
[size shrinkable?]
|
||||
(cond-> {:margin-left (if (= size 24) 4 8)}
|
||||
shrinkable? (assoc :flex-shrink 1)))
|
||||
[size]
|
||||
{:margin-left (if (= size 24) 4 8)})
|
||||
|
||||
(defn text
|
||||
[theme]
|
||||
|
||||
@@ -17,19 +17,17 @@
|
||||
[schema.core :as schema]))
|
||||
|
||||
(defn- tag-skeleton
|
||||
[{:keys [size text theme shrinkable?]
|
||||
[{:keys [size text theme]
|
||||
:or {size 24
|
||||
theme (quo.theme/use-theme)}}
|
||||
logo-component]
|
||||
[rn/view {:style (style/tag-container size)}
|
||||
logo-component
|
||||
[rn/view {:style (style/tag-spacing size shrinkable?)}
|
||||
[rn/view {:style (style/tag-spacing size)}
|
||||
[text/text
|
||||
{:style (style/text theme)
|
||||
:weight :medium
|
||||
:size (if (= size 24) :paragraph-2 :paragraph-1)
|
||||
:number-of-lines 1
|
||||
:ellipsize-mode :middle}
|
||||
{:style (style/text theme)
|
||||
:weight :medium
|
||||
:size (if (= size 24) :paragraph-2 :paragraph-1)}
|
||||
text]]])
|
||||
|
||||
(defn- communities-tag
|
||||
@@ -39,7 +37,7 @@
|
||||
icon-size (if (= size 24) 16 20)]
|
||||
[rn/view {:style (style/tag-container size)}
|
||||
[fast-image/fast-image {:style (style/circle-logo size) :source community-logo}]
|
||||
[rn/view {:style (style/tag-spacing size false)}
|
||||
[rn/view {:style (style/tag-spacing size)}
|
||||
[text/text
|
||||
{:style (style/text theme)
|
||||
:weight :medium
|
||||
@@ -150,10 +148,9 @@
|
||||
|
||||
:collectible
|
||||
[tag-skeleton
|
||||
{:theme theme
|
||||
:size size
|
||||
:text (str collectible-name " #" collectible-number)
|
||||
:shrinkable? true}
|
||||
{:theme theme
|
||||
:size size
|
||||
:text (str collectible-name " #" collectible-number)}
|
||||
[rn/image {:style (style/rounded-logo size) :source collectible}]]
|
||||
|
||||
:account
|
||||
|
||||
@@ -5,9 +5,8 @@
|
||||
[:catn
|
||||
[:props
|
||||
[:map
|
||||
[:type [:enum :status-account :saved-account :account :user :token]]
|
||||
[:type [:enum :status-account :saved-account :account :user]]
|
||||
[:account-props {:optional true} [:maybe :map]]
|
||||
[:token-props {:optional true} [:maybe :map]]
|
||||
[:networks? {:optional true} [:maybe :boolean]]
|
||||
[:values {:optional true} [:maybe :map]]]]]
|
||||
:any])
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
[quo.components.avatars.user-avatar.view :as user-avatar]
|
||||
[quo.components.avatars.wallet-user-avatar.view :as wallet-user-avatar]
|
||||
[quo.components.markdown.text :as text]
|
||||
[quo.components.utilities.token.view :as token]
|
||||
[quo.components.wallet.summary-info.schema :as summary-info-schema]
|
||||
[quo.components.wallet.summary-info.style :as style]
|
||||
[quo.foundations.colors :as colors]
|
||||
@@ -59,14 +58,13 @@
|
||||
:theme theme}])]))
|
||||
|
||||
(defn- view-internal
|
||||
[{:keys [type account-props token-props networks? values]}]
|
||||
[{:keys [type account-props networks? values]}]
|
||||
(let [theme (quo.theme/use-theme)]
|
||||
[rn/view
|
||||
{:style (style/container networks? theme)}
|
||||
[rn/view
|
||||
{:style style/info-container}
|
||||
(case type
|
||||
:token [token/view (select-keys token-props #{:token :size})]
|
||||
:status-account [account-avatar/view account-props]
|
||||
:saved-account [wallet-user-avatar/wallet-user-avatar (assoc account-props :size :size-32)]
|
||||
:account [wallet-user-avatar/wallet-user-avatar
|
||||
@@ -75,8 +73,7 @@
|
||||
:neutral? true)]
|
||||
[user-avatar/user-avatar account-props])
|
||||
[rn/view {:style {:margin-left 8}}
|
||||
(when (not= type :account)
|
||||
[text/text {:weight :semi-bold} (or (:name account-props) (:label token-props))])
|
||||
(when (not= type :account) [text/text {:weight :semi-bold} (:name account-props)])
|
||||
[rn/view
|
||||
{:style {:flex-direction :row
|
||||
:align-items :center}}
|
||||
@@ -94,7 +91,7 @@
|
||||
:weight (when (= type :account) :semi-bold)
|
||||
:style {:color (when (not= type :account)
|
||||
(colors/theme-colors colors/neutral-50 colors/neutral-40 theme))}}
|
||||
(or (:address account-props) (:address token-props))]]]]
|
||||
(:address account-props)]]]]
|
||||
(when networks?
|
||||
[:<>
|
||||
[rn/view
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
(ns quo.components.wallet.swap-input.component-spec
|
||||
(:require [quo.components.wallet.swap-input.view :as swap-input]
|
||||
[test-helpers.component :as h]))
|
||||
|
||||
(h/describe "Wallet: Swap Input"
|
||||
(h/test "should render correctly with props"
|
||||
(h/render-with-theme-provider
|
||||
[swap-input/view
|
||||
{:type :pay
|
||||
:error? false
|
||||
:token "SNT"
|
||||
:status :default
|
||||
:currency-symbol "€"
|
||||
:value "5"
|
||||
:fiat-value "1.50"
|
||||
:network-tag-props {:title "Max: 200 SNT"}}])
|
||||
(h/is-truthy (h/get-by-label-text :swap-input))
|
||||
(h/is-truthy (h/get-by-text "SNT"))
|
||||
(h/is-truthy (h/get-by-text "€1.50"))
|
||||
(h/is-truthy (h/get-by-text "Max: 200 SNT")))
|
||||
|
||||
(h/test "should render correctly with approval label"
|
||||
(h/render-with-theme-provider
|
||||
[swap-input/view
|
||||
{:type :pay
|
||||
:show-approval-label? true
|
||||
:approval-label-props
|
||||
{:status :approve
|
||||
:token-value "10"
|
||||
:token-symbol "SNT"}}])
|
||||
(h/is-truthy (h/get-by-text "Approve 10 SNT"))))
|
||||
@@ -1,74 +0,0 @@
|
||||
(ns quo.components.wallet.swap-input.style
|
||||
(:require [quo.foundations.colors :as colors]
|
||||
[quo.foundations.typography :as typography]))
|
||||
|
||||
(defn- border-color
|
||||
[theme]
|
||||
(colors/theme-colors colors/neutral-10 colors/neutral-80 theme))
|
||||
|
||||
(defn- loader-color
|
||||
[theme]
|
||||
(colors/theme-colors colors/neutral-5 colors/neutral-90 theme))
|
||||
|
||||
(defn content
|
||||
[theme]
|
||||
{:border-width 1
|
||||
:border-radius 16
|
||||
:border-color (border-color theme)
|
||||
:background-color (colors/theme-colors colors/white colors/neutral-95 theme)})
|
||||
|
||||
(defn row-1
|
||||
[loading?]
|
||||
{:padding 12
|
||||
:gap 8
|
||||
:align-items (if loading? :center :flex-end)
|
||||
:flex-direction :row})
|
||||
|
||||
(defn row-1-loader
|
||||
[theme]
|
||||
{:width 74
|
||||
:height 14
|
||||
:border-radius 6
|
||||
:background-color (loader-color theme)})
|
||||
|
||||
(def input-container
|
||||
{:flex 1
|
||||
:flex-direction :row
|
||||
:gap 5
|
||||
:height 32
|
||||
:align-items :flex-end})
|
||||
|
||||
(defn input
|
||||
[disabled? error? theme]
|
||||
(assoc typography/font-semi-bold
|
||||
:font-size 27
|
||||
:flex-shrink 1
|
||||
:padding 0
|
||||
:color (cond
|
||||
error? (colors/resolve-color :danger theme)
|
||||
disabled? (colors/theme-colors colors/neutral-50 colors/neutral-40 theme)
|
||||
:else (colors/theme-colors colors/neutral-100 colors/white theme))
|
||||
:line-height 32))
|
||||
|
||||
(defn token-symbol
|
||||
[theme]
|
||||
{:padding-bottom 3
|
||||
:color (colors/theme-colors colors/neutral-50 colors/neutral-40 theme)})
|
||||
|
||||
(defn row-2
|
||||
[align-right?]
|
||||
{:flex-direction :row
|
||||
:justify-content (if align-right? :flex-end :space-between)
|
||||
:align-items :center
|
||||
:padding 12})
|
||||
|
||||
(defn row-2-loader
|
||||
[theme]
|
||||
{:width 80
|
||||
:height 10
|
||||
:margin-vertical 7
|
||||
:border-radius 6
|
||||
:background-color (loader-color theme)})
|
||||
|
||||
(def fiat-amount
|
||||
{:color colors/neutral-50})
|
||||
@@ -1,121 +0,0 @@
|
||||
(ns quo.components.wallet.swap-input.view
|
||||
(:require [oops.core :as oops]
|
||||
[quo.components.avatars.token-avatar.view :as token-avatar]
|
||||
[quo.components.buttons.button.view :as buttons]
|
||||
[quo.components.dividers.divider-line.view :as divider-line]
|
||||
[quo.components.markdown.text :as text]
|
||||
[quo.components.tags.network-tags.view :as network-tag]
|
||||
[quo.components.wallet.approval-label.schema :as approval-label.schema]
|
||||
[quo.components.wallet.approval-label.view :as approval-label]
|
||||
[quo.components.wallet.swap-input.style :as style]
|
||||
[quo.foundations.colors :as colors]
|
||||
quo.theme
|
||||
[react-native.core :as rn]
|
||||
[schema.core :as schema]))
|
||||
|
||||
(def ?schema
|
||||
[:=>
|
||||
[:catn
|
||||
[:props
|
||||
[:map {:closed true}
|
||||
[:type {:optional true} [:maybe [:enum :pay :receive]]]
|
||||
[:status {:optional true} [:maybe [:enum :default :disabled :loading]]]
|
||||
[:token {:optional true} [:maybe :string]]
|
||||
[:value {:optional true} [:maybe :string]]
|
||||
[:default-value {:optional true} [:maybe :string]]
|
||||
[:currency-symbol {:optional true} [:maybe :string]]
|
||||
[:fiat-value {:optional true} [:maybe :string]]
|
||||
[:show-approval-label? {:optional true} [:maybe :boolean]]
|
||||
[:error? {:optional true} [:maybe :boolean]]
|
||||
[:show-keyboard? {:optional true} [:maybe :boolean]]
|
||||
[:approval-label-props {:optional true} [:maybe approval-label.schema/?schema]]
|
||||
[:network-tag-props {:optional true} [:maybe :map]]
|
||||
[:on-change-text {:optional true} [:maybe fn?]]
|
||||
[:enable-swap? {:optional true} [:maybe :boolean]]
|
||||
[:on-swap-press {:optional true} [:maybe fn?]]
|
||||
[:on-token-press {:optional true} [:maybe fn?]]
|
||||
[:on-max-press {:optional true} [:maybe fn?]]
|
||||
[:customization-color {:optional true} [:maybe :schema.common/customization-color]]
|
||||
[:container-style {:optional true} [:maybe :map]]]]]
|
||||
:any])
|
||||
|
||||
(defn view-internal
|
||||
[{:keys [type status token value fiat-value show-approval-label? error? network-tag-props
|
||||
approval-label-props default-value enable-swap?
|
||||
currency-symbol on-change-text show-keyboard?
|
||||
container-style on-swap-press on-token-press on-max-press]}]
|
||||
(let [theme (quo.theme/use-theme)
|
||||
pay? (= type :pay)
|
||||
disabled? (= status :disabled)
|
||||
loading? (= status :loading)
|
||||
controlled-input? (some? value)
|
||||
input-ref (rn/use-ref-atom nil)
|
||||
set-input-ref (rn/use-callback (fn [ref] (reset! input-ref ref)) [])
|
||||
focus-input (rn/use-callback (fn []
|
||||
(some-> @input-ref
|
||||
(oops/ocall "focus")))
|
||||
[input-ref])]
|
||||
[rn/view
|
||||
{:style container-style
|
||||
:accessibility-label :swap-input}
|
||||
[rn/view {:style (style/content theme)}
|
||||
[rn/view
|
||||
{:style (style/row-1 loading?)}
|
||||
[rn/pressable {:on-press on-token-press}
|
||||
[token-avatar/view
|
||||
{:type :asset
|
||||
:token token}]]
|
||||
(if loading?
|
||||
[rn/view {:style (style/row-1-loader theme)}]
|
||||
[:<>
|
||||
[rn/pressable
|
||||
{:style style/input-container
|
||||
:on-press focus-input}
|
||||
[rn/text-input
|
||||
(cond-> {:ref set-input-ref
|
||||
:style (style/input disabled? error? theme)
|
||||
:placeholder-text-color (colors/theme-colors colors/neutral-40
|
||||
colors/neutral-50
|
||||
theme)
|
||||
:keyboard-type :numeric
|
||||
:auto-focus true
|
||||
:on-change-text on-change-text
|
||||
:show-soft-input-on-focus show-keyboard?
|
||||
:default-value default-value
|
||||
:placeholder "0"}
|
||||
controlled-input? (assoc :value value))]
|
||||
[text/text
|
||||
{:size :paragraph-2
|
||||
:weight :semi-bold
|
||||
:style (style/token-symbol theme)}
|
||||
token]]
|
||||
(when (and pay? enable-swap?)
|
||||
[buttons/button
|
||||
{:type :outline
|
||||
:size 32
|
||||
:on-press on-swap-press
|
||||
:icon-only? true}
|
||||
:i/reorder])])]
|
||||
[divider-line/view]
|
||||
[rn/view
|
||||
{:style (style/row-2 (or (not pay?) loading?))}
|
||||
(when-not loading?
|
||||
[:<>
|
||||
(when pay?
|
||||
[rn/pressable {:on-press on-max-press}
|
||||
[network-tag/view
|
||||
(assoc network-tag-props
|
||||
:status
|
||||
(if error? :error :default))]])
|
||||
[text/text
|
||||
{:size :paragraph-2
|
||||
:style style/fiat-amount
|
||||
:weight :medium}
|
||||
(str currency-symbol fiat-value)]])
|
||||
(when loading?
|
||||
[rn/view {:style (style/row-2-loader theme)}])]]
|
||||
(when (and (not= status :loading) (= type :pay) show-approval-label?)
|
||||
[approval-label/view
|
||||
approval-label-props])]))
|
||||
|
||||
(def view (schema/instrument #'view-internal ?schema))
|
||||
@@ -51,7 +51,8 @@
|
||||
|
||||
(defn prop-text
|
||||
[theme]
|
||||
{:color (colors/theme-colors colors/neutral-100 colors/white theme)})
|
||||
{:margin-right 4
|
||||
:color (colors/theme-colors colors/neutral-100 colors/white theme)})
|
||||
|
||||
(def icon-container
|
||||
{:width 32
|
||||
@@ -60,15 +61,12 @@
|
||||
|
||||
(def container
|
||||
{:flex-direction :row
|
||||
:flex 1
|
||||
:column-gap 8})
|
||||
|
||||
(def content-line
|
||||
{:flex-direction :row
|
||||
:margin-top 2
|
||||
:align-items :center
|
||||
:column-gap 4
|
||||
:justify-content :flex-start})
|
||||
{:flex-direction :row
|
||||
:margin-top 2
|
||||
:align-items :center})
|
||||
|
||||
(def icon-hole-view
|
||||
{:width 32
|
||||
|
||||
@@ -98,11 +98,8 @@
|
||||
|
||||
(defn prop-tag
|
||||
[props blur?]
|
||||
[context-tag/view
|
||||
(assoc props
|
||||
:size 24
|
||||
:blur? blur?
|
||||
:container-style {:flex-shrink 1})])
|
||||
[rn/view {:style {:margin-right 4}}
|
||||
[context-tag/view (merge props {:size 24 :blur? blur?})]])
|
||||
|
||||
(defn- view-internal
|
||||
[{:keys [state blur? first-tag second-tag third-tag fourth-tag on-press
|
||||
@@ -124,7 +121,7 @@
|
||||
:on-press-out on-press-out}
|
||||
[rn/view {:style style/container}
|
||||
[transaction-icon-view props theme]
|
||||
[rn/view {:style {:flex 1}}
|
||||
[rn/view
|
||||
[transaction-header props theme]
|
||||
[rn/view {:style style/content-line}
|
||||
(when first-tag [prop-tag first-tag blur?])
|
||||
|
||||
@@ -86,7 +86,6 @@
|
||||
quo.components.list-items.account-list-card.view
|
||||
quo.components.list-items.account.view
|
||||
quo.components.list-items.address.view
|
||||
quo.components.list-items.approval-info.view
|
||||
quo.components.list-items.channel.view
|
||||
quo.components.list-items.community.view
|
||||
quo.components.list-items.dapp.view
|
||||
@@ -121,7 +120,6 @@
|
||||
quo.components.overlay.view
|
||||
quo.components.password.password-tips.view
|
||||
quo.components.password.tips.view
|
||||
quo.components.pin-input.view
|
||||
quo.components.profile.collectible-list-item.view
|
||||
quo.components.profile.collectible.view
|
||||
quo.components.profile.expanded-collectible.view
|
||||
@@ -147,7 +145,6 @@
|
||||
quo.components.settings.settings-item.view
|
||||
quo.components.share.qr-code.view
|
||||
quo.components.share.share-qr-code.view
|
||||
quo.components.slideshow.slider-bar.view
|
||||
quo.components.switchers.group-messaging-card.view
|
||||
quo.components.tabs.account-selector
|
||||
quo.components.tabs.segmented-tab
|
||||
@@ -186,7 +183,6 @@
|
||||
quo.components.wallet.progress-bar.view
|
||||
quo.components.wallet.required-tokens.view
|
||||
quo.components.wallet.summary-info.view
|
||||
quo.components.wallet.swap-input.view
|
||||
quo.components.wallet.token-input.view
|
||||
quo.components.wallet.transaction-progress.view
|
||||
quo.components.wallet.transaction-summary.view
|
||||
@@ -324,9 +320,6 @@
|
||||
(def keyboard-key quo.components.numbered-keyboard.keyboard-key.view/view)
|
||||
(def numbered-keyboard quo.components.numbered-keyboard.numbered-keyboard.view/view)
|
||||
|
||||
;;;; PIN input
|
||||
(def pin-input quo.components.pin-input.view/view)
|
||||
|
||||
;;;; Links
|
||||
(def internal-link-card quo.components.links.internal-link-card.view/view)
|
||||
(def link-preview quo.components.links.link-preview.view/view)
|
||||
@@ -337,7 +330,6 @@
|
||||
(def account-item quo.components.list-items.account.view/view)
|
||||
(def account-list-card quo.components.list-items.account-list-card.view/view)
|
||||
(def address quo.components.list-items.address.view/view)
|
||||
(def approval-info quo.components.list-items.approval-info.view/view)
|
||||
(def channel quo.components.list-items.channel.view/view)
|
||||
(def community-list quo.components.list-items.community.view/view)
|
||||
(def dapp quo.components.list-items.dapp.view/view)
|
||||
@@ -420,9 +412,6 @@
|
||||
(def qr-code quo.components.share.qr-code.view/view)
|
||||
(def share-qr-code quo.components.share.share-qr-code.view/view)
|
||||
|
||||
;;;; Slideshow
|
||||
(def slider-bar quo.components.slideshow.slider-bar.view/view)
|
||||
|
||||
;;;; SWITCHER
|
||||
(def group-messaging-card quo.components.switchers.group-messaging-card.view/view)
|
||||
|
||||
@@ -473,7 +462,6 @@
|
||||
(def progress-bar quo.components.wallet.progress-bar.view/view)
|
||||
(def required-tokens quo.components.wallet.required-tokens.view/view)
|
||||
(def summary-info quo.components.wallet.summary-info.view/view)
|
||||
(def swap-input quo.components.wallet.swap-input.view/view)
|
||||
(def network-link quo.components.wallet.network-link.view/view)
|
||||
(def token-input quo.components.wallet.token-input.view/view)
|
||||
(def wallet-overview quo.components.wallet.wallet-overview.view/view)
|
||||
|
||||
@@ -55,7 +55,6 @@
|
||||
quo.components.links.url-preview.component-spec
|
||||
quo.components.list-items.account.component-spec
|
||||
quo.components.list-items.address.component-spec
|
||||
quo.components.list-items.approval-info.component-spec
|
||||
quo.components.list-items.channel.component-spec
|
||||
quo.components.list-items.community.component-spec
|
||||
quo.components.list-items.dapp.component-spec
|
||||
@@ -87,7 +86,6 @@
|
||||
quo.components.settings.reorder-item.component-spec
|
||||
quo.components.settings.settings-item.component-spec
|
||||
quo.components.share.share-qr-code.component-spec
|
||||
quo.components.slideshow.slider-bar.component-spec
|
||||
quo.components.switchers.base-card.component-spec
|
||||
quo.components.switchers.group-messaging-card.component-spec
|
||||
quo.components.tags.collectible-tag.component-spec
|
||||
@@ -112,7 +110,6 @@
|
||||
quo.components.wallet.progress-bar.component-spec
|
||||
quo.components.wallet.required-tokens.component-spec
|
||||
quo.components.wallet.summary-info.component-spec
|
||||
quo.components.wallet.swap-input.component-spec
|
||||
quo.components.wallet.token-input.component-spec
|
||||
quo.components.wallet.transaction-progress.component-spec
|
||||
quo.components.wallet.transaction-summary.component-spec
|
||||
|
||||
@@ -1,91 +1,35 @@
|
||||
(ns react-native.wallet-connect
|
||||
(:require
|
||||
["@walletconnect/core" :as wc-core]
|
||||
["@walletconnect/utils" :as wc-utils]
|
||||
["@walletconnect/web3wallet$default" :as Web3Wallet]
|
||||
[cljs-bean.core :as bean]
|
||||
[oops.core :as oops]))
|
||||
["@walletconnect/core" :refer [Core]]
|
||||
["@walletconnect/utils" :refer
|
||||
[buildApprovedNamespaces getSdkError parseUri]]
|
||||
["@walletconnect/web3wallet" :refer [Web3Wallet]]))
|
||||
|
||||
(defn- wallet-connect-core
|
||||
[project-id]
|
||||
(new ^js wc-core/Core (clj->js {:projectId project-id})))
|
||||
(Core. #js {:projectId project-id}))
|
||||
|
||||
(defn init
|
||||
[project-id metadata]
|
||||
(let [core (wallet-connect-core project-id)]
|
||||
(oops/ocall Web3Wallet
|
||||
"init"
|
||||
(bean/->js {:core core
|
||||
:metadata metadata}))))
|
||||
(Web3Wallet.init
|
||||
(clj->js {:core core
|
||||
:metadata metadata}))))
|
||||
|
||||
(defn build-approved-namespaces
|
||||
[proposal supported-namespaces]
|
||||
(oops/ocall wc-utils
|
||||
"buildApprovedNamespaces"
|
||||
(bean/->js {:proposal proposal
|
||||
:supportedNamespaces supported-namespaces})))
|
||||
(buildApprovedNamespaces
|
||||
(clj->js {:proposal proposal
|
||||
:supportedNamespaces supported-namespaces})))
|
||||
|
||||
;; Get an error from this list:
|
||||
;; https://github.com/WalletConnect/walletconnect-monorepo/blob/c6e9529418a0c81d4efcc6ac4e61f242a50b56c5/packages/utils/src/errors.ts
|
||||
(defn get-sdk-error
|
||||
[error-key]
|
||||
(oops/ocall wc-utils "getSdkError" error-key))
|
||||
(getSdkError error-key))
|
||||
|
||||
(defn parse-uri
|
||||
[uri]
|
||||
(-> (oops/ocall wc-utils "parseUri" uri)
|
||||
(bean/->clj)))
|
||||
|
||||
(defn respond-session-request
|
||||
[{:keys [web3-wallet topic id result error]}]
|
||||
(oops/ocall web3-wallet
|
||||
"respondSessionRequest"
|
||||
(bean/->js {:topic topic
|
||||
:response
|
||||
(merge {:id id
|
||||
:jsonrpc "2.0"}
|
||||
(when result
|
||||
{:result result})
|
||||
(when error
|
||||
{:error error}))})))
|
||||
|
||||
(defn reject-session
|
||||
[{:keys [web3-wallet id reason]}]
|
||||
(.rejectSession web3-wallet
|
||||
(clj->js {:id id
|
||||
:reason reason})))
|
||||
|
||||
(defn approve-session
|
||||
[{:keys [web3-wallet id approved-namespaces]}]
|
||||
(oops/ocall web3-wallet
|
||||
"approveSession"
|
||||
(bean/->js {:id id
|
||||
:namespaces approved-namespaces})))
|
||||
|
||||
(defn get-active-sessions
|
||||
[web3-wallet]
|
||||
(oops/ocall web3-wallet "getActiveSessions"))
|
||||
|
||||
(defn core-pairing-disconnnect
|
||||
[web3-wallet topic]
|
||||
(oops/ocall web3-wallet
|
||||
"core.pairing.disconnect"
|
||||
(bean/->js {:topic topic})))
|
||||
|
||||
(defn core-pairing-pair
|
||||
[web3-wallet url]
|
||||
(oops/ocall web3-wallet
|
||||
"core.pairing.pair"
|
||||
(bean/->js {:uri url})))
|
||||
|
||||
(defn get-pairings
|
||||
[web3-wallet]
|
||||
(oops/ocall web3-wallet "core.pairing.getPairings"))
|
||||
|
||||
(defn register-handler
|
||||
[{:keys [web3-wallet event handler]}]
|
||||
(oops/ocall web3-wallet
|
||||
"on"
|
||||
event
|
||||
#(-> (bean/->clj %)
|
||||
handler)))
|
||||
(-> uri
|
||||
parseUri
|
||||
(js->clj :keywordize-keys true)))
|
||||
|
||||
@@ -63,10 +63,8 @@
|
||||
(defn view
|
||||
[{:keys [hide? insets]}
|
||||
{:keys [content selected-item padding-bottom-override border-radius on-close shell?
|
||||
gradient-cover? customization-color hide-handle? blur-radius
|
||||
hide-on-background-press?]
|
||||
:or {border-radius 12
|
||||
hide-on-background-press? true}}]
|
||||
gradient-cover? customization-color hide-handle? blur-radius]
|
||||
:or {border-radius 12}}]
|
||||
(let [theme (quo.theme/use-theme)
|
||||
{window-height :height} (rn/get-window)
|
||||
[sheet-height set-sheet-height] (rn/use-state 0)
|
||||
@@ -121,7 +119,7 @@
|
||||
:on-layout handle-layout-height}
|
||||
;; backdrop
|
||||
[rn/pressable
|
||||
{:on-press #(when hide-on-background-press? (rf/dispatch [:hide-bottom-sheet]))
|
||||
{:on-press #(rf/dispatch [:hide-bottom-sheet])
|
||||
:style {:flex 1}}
|
||||
[reanimated/view
|
||||
{:style (reanimated/apply-animations-to-style
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
set-animating-true #(reset! animating? true)
|
||||
set-animating-false (fn [ms]
|
||||
(js/setTimeout #(reset! animating? false) ms))]
|
||||
(fn [{:keys [content skip-background? on-dismiss]}]
|
||||
(fn [{:keys [content skip-background?]}]
|
||||
(let [theme (quo.theme/use-theme)
|
||||
{:keys [top] :as insets} (safe-area/get-insets)
|
||||
alert-banners-top-margin (rf/sub [:alert-banners/top-margin])
|
||||
@@ -63,10 +63,6 @@
|
||||
(reanimated/animate opacity 0 300)
|
||||
(rf/dispatch [:navigate-back])
|
||||
true)
|
||||
dismiss (fn []
|
||||
(when on-dismiss
|
||||
(on-dismiss))
|
||||
(close))
|
||||
reset-open-sheet (fn []
|
||||
(reanimated/animate translate-y 0 300)
|
||||
(reanimated/animate opacity 1 300)
|
||||
@@ -87,7 +83,7 @@
|
||||
:opacity opacity
|
||||
:scroll-enabled? scroll-enabled?
|
||||
:curr-scroll curr-scroll
|
||||
:close dismiss
|
||||
:close close
|
||||
:reset-open-sheet reset-open-sheet
|
||||
:set-animating-true set-animating-true})}
|
||||
[reanimated/view {:style (style/main-view translate-y theme)}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
(ns status-im.common.floating-button-page.floating-container.style
|
||||
(:require [quo.foundations.colors :as colors]
|
||||
[react-native.safe-area :as safe-area]))
|
||||
(:require [react-native.safe-area :as safe-area]))
|
||||
|
||||
(defn content-container
|
||||
[blur? keyboard-shown?]
|
||||
@@ -12,12 +11,7 @@
|
||||
:padding-horizontal 20}
|
||||
blur? (dissoc :padding-vertical :padding-horizontal))))
|
||||
|
||||
(defn blur-inner-container
|
||||
[theme shell-overlay?]
|
||||
{:background-color (colors/theme-colors colors/white-70-blur
|
||||
(if shell-overlay?
|
||||
colors/neutral-80-opa-80-blur
|
||||
colors/neutral-95-opa-70-blur)
|
||||
theme)
|
||||
(def blur-inner-container
|
||||
{:background-color :transparent ; required, otherwise blur-view will shrink
|
||||
:padding-vertical 12
|
||||
:padding-horizontal 20})
|
||||
|
||||
@@ -1,25 +1,27 @@
|
||||
(ns status-im.common.floating-button-page.floating-container.view
|
||||
(:require
|
||||
[quo.core :as quo]
|
||||
[quo.foundations.colors :as colors]
|
||||
[quo.theme :as quo.theme]
|
||||
[react-native.core :as rn]
|
||||
[status-im.common.floating-button-page.floating-container.style :as style]))
|
||||
|
||||
(defn- blur-container
|
||||
[child shell-overlay?]
|
||||
[child]
|
||||
(let [theme (quo.theme/use-theme)]
|
||||
[quo/blur
|
||||
{:blur-amount 20
|
||||
:blur-type :transparent
|
||||
:overlay-color :transparent}
|
||||
[rn/view {:style (style/blur-inner-container theme shell-overlay?)}
|
||||
{:blur-amount 52
|
||||
:blur-radius 20
|
||||
:blur-type :transparent
|
||||
:blur-overlay-color (colors/theme-colors colors/white-70-blur colors/neutral-95-opa-70-blur theme)}
|
||||
[rn/view {:style style/blur-inner-container}
|
||||
child]]))
|
||||
|
||||
(defn view
|
||||
[{:keys [on-layout keyboard-shown? blur? shell-overlay?]} child]
|
||||
[{:keys [on-layout keyboard-shown? blur?]} child]
|
||||
[rn/view
|
||||
{:style (style/content-container blur? keyboard-shown?)
|
||||
:on-layout on-layout}
|
||||
(if blur?
|
||||
[blur-container child shell-overlay?]
|
||||
[blur-container child]
|
||||
child)])
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
|
||||
(defn view
|
||||
[{:keys [header footer customization-color footer-container-padding header-container-style
|
||||
content-container-style gradient-cover? keyboard-should-persist-taps shell-overlay?]
|
||||
content-container-style gradient-cover? keyboard-should-persist-taps]
|
||||
:or {footer-container-padding (safe-area/get-top)}}
|
||||
& children]
|
||||
(reagent/with-let [scroll-view-ref (atom nil)
|
||||
@@ -121,8 +121,7 @@
|
||||
[floating-container/view
|
||||
{:on-layout set-footer-container-height
|
||||
:keyboard-shown? keyboard-shown?
|
||||
:blur? show-background?
|
||||
:shell-overlay? shell-overlay?}
|
||||
:blur? show-background?}
|
||||
footer]]]])
|
||||
(finally
|
||||
(remove-listeners))))
|
||||
|
||||
@@ -144,10 +144,6 @@
|
||||
(fn [_ [opts]]
|
||||
{:keychain/save-password-and-auth-method opts}))
|
||||
|
||||
(defn- whisper-key-name
|
||||
[address]
|
||||
(str address "-whisper"))
|
||||
|
||||
;; NOTE: migrating the plaintext password in the keychain
|
||||
;; with the hashed one. Added due to the sync onboarding
|
||||
;; flow, where the password arrives already hashed.
|
||||
@@ -155,38 +151,17 @@
|
||||
:keychain/password-hash-migration
|
||||
(fn [{:keys [key-uid callback]
|
||||
:or {callback identity}}]
|
||||
(keychain/get-credentials
|
||||
(whisper-key-name key-uid)
|
||||
(fn [whisper-key-data]
|
||||
(if whisper-key-data
|
||||
(callback) ;; we don't need to migrate keycard password
|
||||
(-> (get-password-migration! key-uid identity)
|
||||
(.then (fn [migrated?]
|
||||
(if migrated?
|
||||
(callback)
|
||||
(-> (get-user-password! key-uid identity)
|
||||
(.then security/hash-masked-password)
|
||||
(.then #(save-user-password! key-uid %))
|
||||
(.then #(save-password-migration! key-uid))
|
||||
(.then callback)))))
|
||||
(.catch (fn [err]
|
||||
(log/error "Failed to migrate the keychain password"
|
||||
{:error err
|
||||
:key-uid key-uid
|
||||
:event :keychain/password-hash-migration})))))))))
|
||||
|
||||
(re-frame/reg-fx
|
||||
:keychain/get-keycard-keys
|
||||
(fn [[key-uid callback]]
|
||||
(keychain/get-credentials
|
||||
key-uid
|
||||
(fn [encryption-key-data]
|
||||
(if encryption-key-data
|
||||
(keychain/get-credentials
|
||||
(whisper-key-name key-uid)
|
||||
(fn [whisper-key-data]
|
||||
(if whisper-key-data
|
||||
(callback [(oops/oget encryption-key-data "password")
|
||||
(oops/oget whisper-key-data "password")])
|
||||
(callback nil))))
|
||||
(callback nil))))))
|
||||
(-> (get-password-migration! key-uid identity)
|
||||
(.then (fn [migrated?]
|
||||
(if migrated?
|
||||
(callback)
|
||||
(-> (get-user-password! key-uid identity)
|
||||
(.then security/hash-masked-password)
|
||||
(.then #(save-user-password! key-uid %))
|
||||
(.then #(save-password-migration! key-uid))
|
||||
(.then callback)))))
|
||||
(.catch (fn [err]
|
||||
(log/error "Failed to migrate the keychain password"
|
||||
{:error err
|
||||
:key-uid key-uid
|
||||
:event :keychain/password-hash-migration}))))))
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
(ns status-im.common.metrics-confirmation-modal.style)
|
||||
|
||||
(def points-wrapper
|
||||
{:margin-top 11
|
||||
:margin-horizontal 20
|
||||
:gap 21
|
||||
:margin-bottom 15})
|
||||
|
||||
(def item-text
|
||||
{:margin-top 10
|
||||
:margin-left -4})
|
||||
|
||||
(def info-text
|
||||
{:margin-top -5})
|
||||
@@ -1,79 +0,0 @@
|
||||
(ns status-im.common.metrics-confirmation-modal.view
|
||||
(:require
|
||||
[quo.core :as quo]
|
||||
[react-native.core :as rn]
|
||||
[status-im.common.metrics-confirmation-modal.style :as style]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(defn- dismiss-keyboard
|
||||
[]
|
||||
(rf/dispatch [:dismiss-keyboard]))
|
||||
|
||||
(defn- hide-bottom-sheet
|
||||
[]
|
||||
(rf/dispatch [:hide-bottom-sheet]))
|
||||
|
||||
(defn- toggle-metrics
|
||||
[enabled?]
|
||||
(rf/dispatch [:centralized-metrics/toggle-centralized-metrics enabled?]))
|
||||
|
||||
(def ^:private will-receive-points
|
||||
[:t/ip-address
|
||||
:t/universally-unique-identifiers-of-device
|
||||
:t/logs-of-actions-withing-the-app])
|
||||
|
||||
(def ^:private not-receive-points
|
||||
[:t/your-profile-information
|
||||
:t/your-addresses
|
||||
:t/information-you-input-and-send])
|
||||
|
||||
(defn- bullet-points
|
||||
[{:keys [title points]}]
|
||||
[rn/view
|
||||
[quo/text {:weight :semi-bold}
|
||||
title]
|
||||
(for [label points]
|
||||
^{:key label}
|
||||
[quo/markdown-list
|
||||
{:description (i18n/label label)
|
||||
:blur? true
|
||||
:container-style style/item-text}])])
|
||||
|
||||
(defn- on-share-usage
|
||||
[]
|
||||
(toggle-metrics true)
|
||||
(hide-bottom-sheet))
|
||||
|
||||
(defn- on-do-not-share
|
||||
[]
|
||||
(toggle-metrics false)
|
||||
(hide-bottom-sheet))
|
||||
|
||||
(defn view
|
||||
[{:keys [settings?]}]
|
||||
(rn/use-mount #(dismiss-keyboard))
|
||||
[:<>
|
||||
[quo/drawer-top
|
||||
{:title (i18n/label :t/help-us-improve-status)
|
||||
:description (i18n/label :t/collecting-usage-data)}]
|
||||
[rn/view {:style style/points-wrapper}
|
||||
[bullet-points
|
||||
{:title (i18n/label :t/what-we-will-receive)
|
||||
:points will-receive-points}]
|
||||
[bullet-points
|
||||
{:title (i18n/label :t/what-we-wont-receive)
|
||||
:points not-receive-points}]
|
||||
(when-not settings?
|
||||
[quo/text
|
||||
{:size :paragraph-2
|
||||
:style style/info-text}
|
||||
(i18n/label :t/sharing-usage-data-can-be-turned-off)])]
|
||||
[quo/bottom-actions
|
||||
{:actions :two-actions
|
||||
:blur? true
|
||||
:button-one-label (i18n/label :t/share-usage-data)
|
||||
:button-one-props {:on-press on-share-usage}
|
||||
:button-two-label (i18n/label (if settings? :t/do-not-share :t/not-now))
|
||||
:button-two-props {:type :grey
|
||||
:on-press on-do-not-share}}]])
|
||||
@@ -25,9 +25,7 @@
|
||||
:invite-friends (js/require "../resources/images/ui2/invite-friends.png")
|
||||
:transaction-progress (js/require "../resources/images/ui2/transaction-progress.png")
|
||||
:welcome-illustration (js/require "../resources/images/ui2/welcome_illustration.png")
|
||||
:notifications (js/require "../resources/images/ui2/notifications.png")
|
||||
:nfc-prompt (js/require "../resources/images/ui2/nfc-prompt.png")
|
||||
:nfc-success (js/require "../resources/images/ui2/nfc-success.png")})
|
||||
:notifications (js/require "../resources/images/ui2/notifications.png")})
|
||||
|
||||
(def ui-themed
|
||||
{:angry-man
|
||||
|
||||
@@ -10,14 +10,11 @@
|
||||
|
||||
(defn authorize
|
||||
[{:keys [db]} [args]]
|
||||
(let [key-uid (get-in db [:profile/profile :key-uid])
|
||||
keycard? (get-in db [:profile/profile :keycard-pairing])]
|
||||
(let [key-uid (get-in db [:profile/profile :key-uid])]
|
||||
{:fx [[:effects.biometric/check-if-available
|
||||
{:key-uid key-uid
|
||||
:on-success #(rf/dispatch [:standard-auth/authorize-with-biometric args])
|
||||
:on-fail (if keycard?
|
||||
#(rf/dispatch [:standard-auth/authorize-with-keycard args])
|
||||
#(rf/dispatch [:standard-auth/authorize-with-password args]))}]]}))
|
||||
:on-fail #(rf/dispatch [:standard-auth/authorize-with-password args])}]]}))
|
||||
|
||||
(schema/=> authorize events-schema/?authorize)
|
||||
(rf/reg-event-fx :standard-auth/authorize authorize)
|
||||
@@ -48,11 +45,8 @@
|
||||
|
||||
(defn on-biometric-success
|
||||
[{:keys [db]} [on-auth-success]]
|
||||
(let [key-uid (get-in db [:profile/profile :key-uid])
|
||||
keycard? (get-in db [:profile/profile :keycard-pairing])]
|
||||
{:fx [(if keycard?
|
||||
[:keychain/get-keycard-keys [key-uid on-auth-success]]
|
||||
[:keychain/get-user-password [key-uid on-auth-success]])
|
||||
(let [key-uid (get-in db [:profile/profile :key-uid])]
|
||||
{:fx [[:keychain/get-user-password [key-uid on-auth-success]]
|
||||
[:dispatch [:standard-auth/set-success true]]
|
||||
[:dispatch [:standard-auth/reset-login-password]]]}))
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
|
||||
;; CONFIG VALUES
|
||||
(def log-level (string/upper-case (get-config :LOG_LEVEL "")))
|
||||
(def fleet (get-config :FLEET ""))
|
||||
(def fleet (get-config :FLEET "waku.sandbox"))
|
||||
(def apn-topic (get-config :APN_TOPIC "im.status.ethereum"))
|
||||
(def default-network (get-config :DEFAULT_NETWORK "goerli_rpc"))
|
||||
(def max-installations 2)
|
||||
|
||||
@@ -45,11 +45,6 @@
|
||||
(def ^:const activity-center-membership-status-accepted 2)
|
||||
(def ^:const activity-center-membership-status-declined 3)
|
||||
|
||||
;; Choose the maximum number of notifications that *usually/safely* fit on
|
||||
;; most screens, so that the UI doesn't have to needlessly render
|
||||
;; notifications.
|
||||
(def ^:const notifications-per-page 7)
|
||||
|
||||
(def ^:const mute-for-15-mins-type 1)
|
||||
(def ^:const mute-for-1-hour-type 2)
|
||||
(def ^:const mute-for-8-hours-type 3)
|
||||
@@ -131,7 +126,6 @@
|
||||
(def ^:const profile-pictures-visibility-none 3)
|
||||
|
||||
(def ^:const min-password-length 6)
|
||||
(def ^:const pincode-length 6)
|
||||
(def ^:const new-password-min-length 10)
|
||||
(def ^:const max-group-chat-participants 20)
|
||||
(def ^:const max-group-chat-name-length 24)
|
||||
@@ -281,14 +275,12 @@
|
||||
#{wallet-connect-personal-sign-method
|
||||
wallet-connect-eth-sign-method
|
||||
wallet-connect-eth-send-transaction-method
|
||||
;; NOTE: disabled, as we have no clear use cases for it and other wallets don't support it
|
||||
;; wallet-connect-eth-sign-transaction-method
|
||||
wallet-connect-eth-sign-transaction-method
|
||||
wallet-connect-eth-sign-typed-method
|
||||
wallet-connect-eth-sign-typed-v4-method})
|
||||
(def ^:const wallet-connect-supported-events #{"accountsChanged" "chainChanged"})
|
||||
(def ^:const wallet-connect-session-proposal-event "session_proposal")
|
||||
(def ^:const wallet-connect-session-request-event "session_request")
|
||||
(def ^:const wallet-connect-session-delete-event "session_delete")
|
||||
(def ^:const wallet-connect-user-rejected-error-key "USER_REJECTED")
|
||||
|
||||
(def ^:const transaction-pending-type-wallet-connect-transfer "WalletConnectTransfer")
|
||||
@@ -513,9 +505,6 @@
|
||||
(def ^:const optimism-full-name "Optimism")
|
||||
(def ^:const arbitrum-full-name "Arbitrum")
|
||||
|
||||
(def ^:const sepolia-full-name "Sepolia")
|
||||
(def ^:const goerli-full-name "Goerli")
|
||||
|
||||
(def ^:const mainnet-network-name :mainnet)
|
||||
(def ^:const ethereum-network-name :ethereum)
|
||||
(def ^:const optimism-network-name :optimism)
|
||||
@@ -576,6 +565,3 @@
|
||||
(def ^:const default-slippage 0.5)
|
||||
(def ^:const max-recommended-slippage 5)
|
||||
(def ^:const max-slippage-decimal-places 2)
|
||||
(def ^:const swap-default-provider
|
||||
{:name "Paraswap"
|
||||
:terms-and-conditions-url "https://files.paraswap.io/tos_v4.pdf"})
|
||||
|
||||
@@ -7,17 +7,10 @@
|
||||
[taoensso.timbre :as log]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(def ^:const user-confirmed-key :centralized-metrics/user-confirmed?)
|
||||
(def ^:const enabled-key :centralized-metrics/enabled?)
|
||||
|
||||
(defn show-confirmation-modal?
|
||||
[db]
|
||||
(not (user-confirmed-key db)))
|
||||
|
||||
(defn push-event?
|
||||
[db]
|
||||
(or (not (user-confirmed-key db))
|
||||
(enabled-key db)))
|
||||
(or (not (:centralized-metrics/user-confirmed? db))
|
||||
(:centralized-metrics/enabled? db)))
|
||||
|
||||
(defn centralized-metrics-interceptor
|
||||
[context]
|
||||
@@ -36,16 +29,5 @@
|
||||
(fn [{:keys [db]} [enabled?]]
|
||||
{:fx [[:effects.centralized-metrics/toggle-metrics enabled?]]
|
||||
:db (assoc db
|
||||
user-confirmed-key
|
||||
true
|
||||
enabled-key
|
||||
enabled?)}))
|
||||
|
||||
(rf/reg-event-fx :centralized-metrics/check-modal
|
||||
(fn [{:keys [db]} [modal-view]]
|
||||
(when (show-confirmation-modal? db)
|
||||
{:fx [[:dispatch
|
||||
[:show-bottom-sheet
|
||||
{:content (fn [] [modal-view])
|
||||
:shell? true}]]]})))
|
||||
|
||||
:centralized-metrics/user-confirmed? true
|
||||
:centralized-metrics/enabled? enabled?)}))
|
||||
|
||||
@@ -6,11 +6,6 @@
|
||||
[status-im.contexts.centralized-metrics.tracking :as tracking]
|
||||
[test-helpers.unit :as h]))
|
||||
|
||||
(deftest show-confirmation-modal-test
|
||||
(testing "returns true if the user confirmed"
|
||||
(is (false? (events/show-confirmation-modal? {events/user-confirmed-key true})))
|
||||
(is (true? (events/show-confirmation-modal? {})))))
|
||||
|
||||
(deftest push-event-test
|
||||
(testing "returns correct boolean value"
|
||||
(is (true? (events/push-event? {:centralized-metrics/user-confirmed? false})))
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
:on-error #(p-reject (str "failed to sign data\n" %))}))))
|
||||
|
||||
(defn- edit-shared-addresses-for-community
|
||||
[community-id signatures addresses-to-reveal airdrop-address _share-future-addresses?]
|
||||
[community-id signatures addresses-to-reveal airdrop-address]
|
||||
(promesa/create
|
||||
(fn [p-resolve p-reject]
|
||||
(rpc/call
|
||||
@@ -41,16 +41,15 @@
|
||||
:on-error p-reject}))))
|
||||
|
||||
(defn- request-to-join
|
||||
[community-id signatures addresses-to-reveal airdrop-address share-future-addresses?]
|
||||
[community-id signatures addresses-to-reveal airdrop-address]
|
||||
(promesa/create
|
||||
(fn [p-resolve p-reject]
|
||||
(rpc/call
|
||||
{:method :wakuext_requestToJoinCommunity
|
||||
:params [{:communityId community-id
|
||||
:signatures signatures
|
||||
:addressesToReveal addresses-to-reveal
|
||||
:airdropAddress airdrop-address
|
||||
:shareFutureAddresses share-future-addresses?}]
|
||||
:params [{:communityId community-id
|
||||
:signatures signatures
|
||||
:addressesToReveal addresses-to-reveal
|
||||
:airdropAddress airdrop-address}]
|
||||
:js-response true
|
||||
:on-success p-resolve
|
||||
:on-error p-reject}))))
|
||||
@@ -65,18 +64,15 @@
|
||||
|
||||
(defn- sign-and-call-endpoint
|
||||
[{:keys [community-id password pub-key
|
||||
addresses-to-reveal airdrop-address share-future-addresses?
|
||||
addresses-to-reveal airdrop-address
|
||||
on-success on-error
|
||||
callback]}]
|
||||
(-> (promesa/let [sign-params (generate-requests-for-signing pub-key
|
||||
community-id
|
||||
addresses-to-reveal)
|
||||
(-> (promesa/let [sign-params (generate-requests-for-signing pub-key community-id addresses-to-reveal)
|
||||
signatures (sign-data sign-params password)
|
||||
result (callback community-id
|
||||
signatures
|
||||
addresses-to-reveal
|
||||
airdrop-address
|
||||
share-future-addresses?)]
|
||||
airdrop-address)]
|
||||
(run-callback-or-event on-success result))
|
||||
(promesa/catch #(run-callback-or-event on-error %))))
|
||||
|
||||
@@ -91,7 +87,6 @@
|
||||
[:or [:set string?]
|
||||
[:sequential string?]]]
|
||||
[:airdrop-address string?]
|
||||
[:share-future-addresses? boolean?]
|
||||
[:on-success [:or fn? :schema.re-frame/event]]
|
||||
[:on-error [:or fn? :schema.re-frame/event]]
|
||||
[:callback fn?]]]
|
||||
|
||||
@@ -17,12 +17,13 @@
|
||||
(rf/reg-event-fx :communities/initialize-permission-addresses initialize-permission-addresses)
|
||||
|
||||
(defn do-init-permission-addresses
|
||||
[{:keys [db]} [community-id revealed-accounts share-future-addresses?]]
|
||||
(let [wallet-accounts (utils/sorted-operable-non-watch-only-accounts db)
|
||||
[{:keys [db]} [community-id revealed-accounts]]
|
||||
(let [wallet-accounts (utils/sorted-non-watch-only-accounts db)
|
||||
addresses-to-reveal (if (seq revealed-accounts)
|
||||
(set (keys revealed-accounts))
|
||||
;; Reveal all addresses as fallback.
|
||||
(set (map :address wallet-accounts)))
|
||||
|
||||
;; When there are no revealed addresses, such as when joining a
|
||||
;; community, use first address for airdrops.
|
||||
airdrop-address (or (->> revealed-accounts
|
||||
@@ -34,7 +35,10 @@
|
||||
first
|
||||
:address))]
|
||||
{:db (-> db
|
||||
(assoc-in [:communities/selected-share-all-addresses community-id] share-future-addresses?)
|
||||
;; Set to false by default while we don't persist the user's choice
|
||||
;; in status-go, otherwise whenever the view is mounted, the choice
|
||||
;; of selected addresses won't be respected.
|
||||
(assoc-in [:communities/selected-share-all-addresses community-id] false)
|
||||
(assoc-in [:communities/all-addresses-to-reveal community-id] addresses-to-reveal)
|
||||
(assoc-in [:communities/all-airdrop-addresses community-id] airdrop-address))
|
||||
:fx [[:dispatch
|
||||
@@ -56,44 +60,36 @@
|
||||
is selecting an airdrop address, we must submit to status-go the current
|
||||
choice of addresses to share, and vice-versa. If we omit addresses to share,
|
||||
status-go will default to all available."
|
||||
[{:keys [db]}
|
||||
[{:keys [community-id password on-success addresses airdrop-address share-future-addresses?]}]]
|
||||
(let [pub-key (get-in db [:profile/profile :public-key])
|
||||
wallet-accounts (utils/sorted-operable-non-watch-only-accounts db)
|
||||
addresses-to-reveal (if (seq addresses)
|
||||
(set addresses)
|
||||
(get-in db [:communities/all-addresses-to-reveal community-id]))
|
||||
new-airdrop-address (if (contains? addresses-to-reveal airdrop-address)
|
||||
airdrop-address
|
||||
(->> wallet-accounts
|
||||
(filter #(contains? addresses-to-reveal (:address %)))
|
||||
first
|
||||
:address))
|
||||
share-future-addresses? (if (nil? share-future-addresses?)
|
||||
(get-in db [:communities/selected-share-all-addresses community-id])
|
||||
share-future-addresses?)]
|
||||
[{:keys [db]} [{:keys [community-id password on-success addresses airdrop-address]}]]
|
||||
(let [pub-key (get-in db [:profile/profile :public-key])
|
||||
wallet-accounts (utils/sorted-non-watch-only-accounts db)
|
||||
addresses-to-reveal (if (seq addresses)
|
||||
(set addresses)
|
||||
(get-in db [:communities/all-addresses-to-reveal community-id]))
|
||||
new-airdrop-address (if (contains? addresses-to-reveal airdrop-address)
|
||||
airdrop-address
|
||||
(->> wallet-accounts
|
||||
(filter #(contains? addresses-to-reveal (:address %)))
|
||||
first
|
||||
:address))]
|
||||
{:fx [[:effects.community/edit-shared-addresses
|
||||
{:community-id community-id
|
||||
:password password
|
||||
:pub-key pub-key
|
||||
:addresses-to-reveal addresses-to-reveal
|
||||
:share-future-addresses? share-future-addresses?
|
||||
:airdrop-address new-airdrop-address
|
||||
:on-success (fn []
|
||||
(when (fn? on-success)
|
||||
(on-success addresses-to-reveal
|
||||
new-airdrop-address
|
||||
share-future-addresses?))
|
||||
(rf/dispatch [:communities/edit-shared-addresses-success
|
||||
community-id addresses-to-reveal airdrop-address]))
|
||||
:on-error [:communities/edit-shared-addresses-failure community-id]}]]}))
|
||||
{:community-id community-id
|
||||
:password password
|
||||
:pub-key pub-key
|
||||
:addresses-to-reveal addresses-to-reveal
|
||||
:airdrop-address new-airdrop-address
|
||||
:on-success (fn []
|
||||
(when (fn? on-success)
|
||||
(on-success addresses-to-reveal new-airdrop-address))
|
||||
(rf/dispatch [:communities/edit-shared-addresses-success
|
||||
community-id addresses-to-reveal airdrop-address]))
|
||||
:on-error [:communities/edit-shared-addresses-failure community-id]}]]}))
|
||||
|
||||
(rf/reg-event-fx :communities/edit-shared-addresses edit-shared-addresses)
|
||||
|
||||
(rf/reg-event-fx :communities/edit-shared-addresses-success
|
||||
(fn [_ [community-id addresses-to-reveal airdrop-address share-future-addresses?]]
|
||||
(fn [_ [community-id addresses-to-reveal airdrop-address]]
|
||||
{:fx [[:dispatch [:communities/set-airdrop-address community-id airdrop-address]]
|
||||
[:dispatch [:communities/set-share-all-addresses community-id share-future-addresses?]]
|
||||
[:dispatch [:communities/set-addresses-to-reveal community-id addresses-to-reveal]]]}))
|
||||
|
||||
(rf/reg-event-fx :communities/edit-shared-addresses-failure
|
||||
|
||||
@@ -9,25 +9,17 @@
|
||||
(def wallet-accounts
|
||||
{"0xA" {:address "0xA"
|
||||
:watch-only? true
|
||||
:operable? true
|
||||
:position 2
|
||||
:color :red
|
||||
:emoji "🦇"}
|
||||
"0xB" {:address "0xB"
|
||||
:operable? true
|
||||
:position 0
|
||||
:color :blue
|
||||
:emoji "🐈"}
|
||||
"0xC" {:address "0xC"
|
||||
:operable? true
|
||||
:position 1
|
||||
:color :orange
|
||||
:emoji "🛏️"}
|
||||
"0xD" {:address "0xD"
|
||||
:operable? false
|
||||
:position 3
|
||||
:color :flamingo
|
||||
:emoji "🦩"}})
|
||||
"0xB" {:address "0xB"
|
||||
:position 0
|
||||
:color :blue
|
||||
:emoji "🐈"}
|
||||
"0xC" {:address "0xC"
|
||||
:position 1
|
||||
:color :orange
|
||||
:emoji "🛏️"}})
|
||||
|
||||
(def permissioned-accounts
|
||||
[{:address "0xB"
|
||||
@@ -70,7 +62,7 @@
|
||||
(is
|
||||
(match?
|
||||
{:db (-> (:db cofx)
|
||||
(assoc-in [:communities/selected-share-all-addresses community-id] true)
|
||||
(assoc-in [:communities/selected-share-all-addresses community-id] false)
|
||||
(assoc-in [:communities/all-addresses-to-reveal community-id] addresses-to-reveal)
|
||||
(assoc-in [:communities/all-airdrop-addresses community-id] airdrop-address))
|
||||
:fx [[:dispatch
|
||||
@@ -82,7 +74,7 @@
|
||||
[:dispatch
|
||||
[:communities/check-permissions-to-join-during-selection community-id
|
||||
addresses-to-reveal]]]}
|
||||
(sut/do-init-permission-addresses cofx [community-id revealed-accounts true])))))
|
||||
(sut/do-init-permission-addresses cofx [community-id revealed-accounts])))))
|
||||
|
||||
;; Expect to mark all addresses to be revealed and first one to receive
|
||||
;; airdrops when no addresses were previously revealed.
|
||||
@@ -93,7 +85,7 @@
|
||||
(is
|
||||
(match?
|
||||
{:db (-> (:db cofx)
|
||||
(assoc-in [:communities/selected-share-all-addresses community-id] true)
|
||||
(assoc-in [:communities/selected-share-all-addresses community-id] false)
|
||||
(assoc-in [:communities/all-addresses-to-reveal community-id] addresses-to-reveal))
|
||||
:fx [[:dispatch
|
||||
[:communities/check-permissions-to-join-community
|
||||
@@ -101,7 +93,7 @@
|
||||
[:dispatch
|
||||
[:communities/check-permissions-to-join-during-selection community-id
|
||||
addresses-to-reveal]]]}
|
||||
(sut/do-init-permission-addresses cofx [community-id revealed-accounts true]))))))
|
||||
(sut/do-init-permission-addresses cofx [community-id revealed-accounts]))))))
|
||||
|
||||
(deftest edit-shared-addresses-test
|
||||
(testing
|
||||
@@ -109,7 +101,6 @@
|
||||
fallback to all wallet addresses"
|
||||
(let [pub-key "abcdef"
|
||||
revealed-addresses #{"0xB" "0xC"}
|
||||
share-future-addresses? true
|
||||
cofx {:db {:profile/profile {:public-key pub-key}
|
||||
:communities/all-addresses-to-reveal {community-id revealed-addresses}}}
|
||||
airdrop-address "0xB"
|
||||
@@ -117,24 +108,22 @@
|
||||
actual
|
||||
(sut/edit-shared-addresses
|
||||
cofx
|
||||
[{:community-id community-id
|
||||
:password password
|
||||
:airdrop-address airdrop-address
|
||||
:share-future-addresses? share-future-addresses?
|
||||
:on-success (fn [new-addresses-to-reveal]
|
||||
(is (match? revealed-addresses new-addresses-to-reveal)))}])
|
||||
[{:community-id community-id
|
||||
:password password
|
||||
:airdrop-address airdrop-address
|
||||
:on-success (fn [new-addresses-to-reveal]
|
||||
(is (match? revealed-addresses new-addresses-to-reveal)))}])
|
||||
|
||||
on-success-wrapper (-> actual :fx first second :on-success)]
|
||||
(is (match?
|
||||
{:fx [[:effects.community/edit-shared-addresses
|
||||
{:community-id community-id
|
||||
:password password
|
||||
:pub-key pub-key
|
||||
:addresses-to-reveal revealed-addresses
|
||||
:share-future-addresses? share-future-addresses?
|
||||
:airdrop-address airdrop-address
|
||||
:on-success fn?
|
||||
:on-error [:communities/edit-shared-addresses-failure community-id]}]]}
|
||||
{:community-id community-id
|
||||
:password password
|
||||
:pub-key pub-key
|
||||
:addresses-to-reveal revealed-addresses
|
||||
:airdrop-address airdrop-address
|
||||
:on-success fn?
|
||||
:on-error [:communities/edit-shared-addresses-failure community-id]}]]}
|
||||
actual))
|
||||
|
||||
(on-success-wrapper)))
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
airdrop-account (rf/sub [:communities/airdrop-account id])
|
||||
revealed-accounts (rf/sub [:communities/accounts-to-reveal id])
|
||||
revealed-accounts-count (count revealed-accounts)
|
||||
wallet-accounts-count (count (rf/sub [:wallet/operable-accounts-without-watched-accounts]))
|
||||
wallet-accounts-count (count (rf/sub [:wallet/accounts-without-watched-accounts]))
|
||||
addresses-shared-text (if (= revealed-accounts-count wallet-accounts-count)
|
||||
(i18n/label :t/all-addresses)
|
||||
(i18n/label-pluralize
|
||||
|
||||
@@ -120,7 +120,7 @@
|
||||
(defn set-permissioned-accounts
|
||||
[{:keys [db]} [community-id addresses-to-reveal]]
|
||||
(let [addresses-to-reveal (set addresses-to-reveal)
|
||||
wallet-accounts (utils/sorted-operable-non-watch-only-accounts db)
|
||||
wallet-accounts (utils/sorted-non-watch-only-accounts db)
|
||||
current-airdrop-address (get-in db [:communities/all-airdrop-addresses community-id])
|
||||
new-airdrop-address (if (contains? addresses-to-reveal current-airdrop-address)
|
||||
current-airdrop-address
|
||||
@@ -142,7 +142,7 @@
|
||||
[{:keys [db]} [community-id new-value]]
|
||||
(let [current-addresses (get-in db [:communities/all-addresses-to-reveal community-id])
|
||||
addresses-to-reveal (if new-value
|
||||
(->> (utils/sorted-operable-non-watch-only-accounts db)
|
||||
(->> (utils/sorted-non-watch-only-accounts db)
|
||||
(map :address)
|
||||
set)
|
||||
current-addresses)]
|
||||
|
||||
+6
-12
@@ -33,15 +33,9 @@
|
||||
(let [cofx
|
||||
{:db {:communities/all-addresses-to-reveal {community-id #{"0xA" "0xB" "0xC"}}
|
||||
:communities/all-airdrop-addresses {community-id "0xB"}
|
||||
:wallet {:accounts {"0xB" {:address "0xB"
|
||||
:operable? true
|
||||
:position 0}
|
||||
"0xA" {:address "0xA"
|
||||
:operable? true
|
||||
:position 1}
|
||||
"0xC" {:address "0xC"
|
||||
:operable? true
|
||||
:position 2}}}}}
|
||||
:wallet {:accounts {"0xB" {:address "0xB" :position 0}
|
||||
"0xA" {:address "0xA" :position 1}
|
||||
"0xC" {:address "0xC" :position 2}}}}}
|
||||
addresses-to-reveal ["0xA" "0xC"]]
|
||||
(is (match?
|
||||
{:db {:communities/all-addresses-to-reveal
|
||||
@@ -58,9 +52,9 @@
|
||||
(testing "sets flag from false -> true will mark all addresses to be revealed"
|
||||
(let [cofx {:db
|
||||
{:wallet
|
||||
{:accounts {"0xB" {:address "0xB" :operable? true :position 0}
|
||||
"0xA" {:address "0xA" :operable? true :position 1}
|
||||
"0xC" {:address "0xC" :operable? true :position 2}}}
|
||||
{:accounts {"0xB" {:address "0xB" :position 0}
|
||||
"0xA" {:address "0xA" :position 1}
|
||||
"0xC" {:address "0xC" :position 2}}}
|
||||
:communities/all-addresses-to-reveal {community-id #{"0xA"}}
|
||||
:communities/selected-share-all-addresses {community-id false}}}
|
||||
addresses-to-reveal #{"0xA" "0xB" "0xC"}]
|
||||
|
||||
@@ -203,9 +203,7 @@
|
||||
:addresses-for-permissions])
|
||||
(rf/dispatch [:hide-bottom-sheet]))}]))}])
|
||||
(rf/dispatch [:communities/set-share-all-addresses id flag-share-all-addresses]))
|
||||
(do
|
||||
(rf/dispatch [:communities/set-share-all-addresses id flag-share-all-addresses])
|
||||
(rf/dispatch [:communities/set-addresses-to-reveal id addresses-to-reveal]))))
|
||||
(rf/dispatch [:communities/set-addresses-to-reveal id addresses-to-reveal])))
|
||||
highest-role (rf/sub [:communities/highest-role-for-selection id])
|
||||
[unmodified-role _] (rn/use-state highest-role)]
|
||||
|
||||
@@ -262,8 +260,7 @@
|
||||
|
||||
can-edit-addresses? (rf/sub [:communities/can-edit-shared-addresses? id])
|
||||
|
||||
wallet-accounts (rf/sub [:wallet/operable-accounts-without-watched-accounts])
|
||||
joined (rf/sub [:communities/community-joined id])
|
||||
wallet-accounts (rf/sub [:wallet/accounts-without-watched-accounts])
|
||||
unmodified-addresses-to-reveal (rf/sub [:communities/addresses-to-reveal id])
|
||||
[addresses-to-reveal set-addresses-to-reveal] (rn/use-state unmodified-addresses-to-reveal)
|
||||
|
||||
@@ -288,6 +285,7 @@
|
||||
(set-flag-share-all-addresses new-value)
|
||||
(when new-value
|
||||
(set-addresses-to-reveal (set (map :address wallet-accounts))))))]
|
||||
|
||||
(rn/use-mount
|
||||
(fn []
|
||||
(when-not flag-share-all-addresses
|
||||
@@ -312,7 +310,6 @@
|
||||
flag-share-all-addresses]
|
||||
:header [quo/page-setting
|
||||
{:checked? flag-share-all-addresses
|
||||
:disabled? joined
|
||||
:customization-color color
|
||||
:on-change toggle-flag-share-all-addresses
|
||||
:setting-text (i18n/label
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
[status-im.navigation.events :as navigation]
|
||||
[status-im.navigation.transitions :as transitions]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.collection :as collection-utils]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(defn handle-community
|
||||
@@ -155,7 +154,7 @@
|
||||
(defn update-previous-permission-addresses
|
||||
[{:keys [db]} [community-id]]
|
||||
(when community-id
|
||||
(let [accounts (utils/sorted-operable-non-watch-only-accounts db)
|
||||
(let [accounts (utils/sorted-non-watch-only-accounts db)
|
||||
selected-permission-addresses (get-in db
|
||||
[:communities community-id
|
||||
:selected-permission-addresses])
|
||||
@@ -199,7 +198,7 @@
|
||||
[{:keys [db]} [community-id]]
|
||||
(let [share-all-addresses? (get-in db [:communities community-id :share-all-addresses?])
|
||||
next-share-all-addresses? (not share-all-addresses?)
|
||||
accounts (utils/sorted-operable-non-watch-only-accounts db)
|
||||
accounts (utils/sorted-non-watch-only-accounts db)
|
||||
addresses (set (map :address accounts))]
|
||||
{:db (update-in db
|
||||
[:communities community-id]
|
||||
@@ -373,14 +372,15 @@
|
||||
(when (and community joined (not fetching-revealed-accounts))
|
||||
{:db (assoc-in db [:communities community-id :fetching-revealed-accounts] true)
|
||||
:json-rpc/call
|
||||
[{:method "wakuext_latestRequestToJoinForCommunity"
|
||||
:params [community-id]
|
||||
:on-success [:communities/get-revealed-accounts-success community-id on-success]
|
||||
:on-error (fn [err]
|
||||
(log/error {:message "failed to fetch revealed accounts"
|
||||
:community-id community-id
|
||||
:err err})
|
||||
(rf/dispatch [:communities/get-revealed-accounts-failed community-id]))}]})))
|
||||
[{:method "wakuext_getRevealedAccounts"
|
||||
:params [community-id (get-in db [:profile/profile :public-key])]
|
||||
:js-response true
|
||||
:on-success [:communities/get-revealed-accounts-success community-id on-success]
|
||||
:on-error (fn [err]
|
||||
(log/error {:message "failed to fetch revealed accounts"
|
||||
:community-id community-id
|
||||
:err err})
|
||||
(rf/dispatch [:communities/get-revealed-accounts-failed community-id]))}]})))
|
||||
|
||||
(rf/reg-event-fx :communities/get-revealed-accounts get-revealed-accounts)
|
||||
|
||||
@@ -399,18 +399,22 @@
|
||||
[:json-rpc/call :schema.common/rpc-call]]]])
|
||||
|
||||
(rf/reg-event-fx :communities/get-revealed-accounts-success
|
||||
(fn [{:keys [db]} [community-id on-success request-to-join]]
|
||||
(fn [{:keys [db]} [community-id on-success revealed-accounts-js]]
|
||||
(when-let [community (get-in db [:communities community-id])]
|
||||
(let [revealed-accounts (collection-utils/index-by :address (:revealedAccounts request-to-join))
|
||||
share-future-addresses? (:shareFutureAddresses request-to-join)
|
||||
(let [revealed-accounts
|
||||
(reduce
|
||||
(fn [acc {:keys [address] :as revealed-account}]
|
||||
(assoc acc address revealed-account))
|
||||
{}
|
||||
(data-store.communities/<-revealed-accounts-rpc revealed-accounts-js))
|
||||
|
||||
community-with-revealed-accounts
|
||||
(-> community
|
||||
(assoc :revealed-accounts revealed-accounts)
|
||||
(assoc :share-future-addresses? share-future-addresses?)
|
||||
(dissoc :fetching-revealed-accounts))]
|
||||
{:db (assoc-in db [:communities community-id] community-with-revealed-accounts)
|
||||
:fx [(when (vector? on-success)
|
||||
[:dispatch (conj on-success revealed-accounts share-future-addresses?)])]}))))
|
||||
[:dispatch (conj on-success revealed-accounts)])]}))))
|
||||
|
||||
(rf/reg-event-fx :communities/get-revealed-accounts-failed
|
||||
(fn [{:keys [db]} [community-id]]
|
||||
|
||||
@@ -146,8 +146,8 @@
|
||||
effects (events/get-revealed-accounts {:db db} [community-id])]
|
||||
(is (match? (assoc-in db [:communities community-id :fetching-revealed-accounts] true)
|
||||
(:db effects)))
|
||||
(is (match? {:method "wakuext_latestRequestToJoinForCommunity"
|
||||
:params [community-id]}
|
||||
(is (match? {:method "wakuext_getRevealedAccounts"
|
||||
:params [community-id "profile-public-key"]}
|
||||
(-> effects :json-rpc/call first (select-keys [:method :params]))))))))
|
||||
|
||||
(deftest handle-community-test
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
|
||||
(rf/reg-event-fx :communities/check-permissions-to-join-community-with-all-addresses
|
||||
(fn [{:keys [db]} [community-id]]
|
||||
(let [accounts (utils/sorted-operable-non-watch-only-accounts db)
|
||||
(let [accounts (utils/sorted-non-watch-only-accounts db)
|
||||
addresses (set (map :address accounts))]
|
||||
{:db (assoc-in db [:communities/permissions-check community-id :checking?] true)
|
||||
:json-rpc/call [{:method "wakuext_checkPermissionsToJoinCommunity"
|
||||
@@ -117,14 +117,13 @@
|
||||
{:community community-name})}]]]})))
|
||||
|
||||
(defn request-to-join-with-signatures
|
||||
[_ [community-id addresses-to-reveal signatures share-future-addresses?]]
|
||||
[_ [community-id addresses-to-reveal signatures]]
|
||||
{:fx [[:json-rpc/call
|
||||
[{:method "wakuext_requestToJoinCommunity"
|
||||
:params [{:communityId community-id
|
||||
:signatures signatures
|
||||
:addressesToReveal addresses-to-reveal
|
||||
:shareFutureAddresses share-future-addresses?
|
||||
:airdropAddress (first addresses-to-reveal)}]
|
||||
:params [{:communityId community-id
|
||||
:signatures signatures
|
||||
:addressesToReveal addresses-to-reveal
|
||||
:airdropAddress (first addresses-to-reveal)}]
|
||||
:js-response true
|
||||
:on-success [:communities/requested-to-join]
|
||||
:on-error [:communities/requested-to-join-error community-id]}]]]})
|
||||
@@ -154,18 +153,16 @@
|
||||
(defn request-to-join-with-addresses
|
||||
[{:keys [db]}
|
||||
[{:keys [community-id password]}]]
|
||||
(let [pub-key (get-in db [:profile/profile :public-key])
|
||||
addresses-to-reveal (get-in db [:communities/all-addresses-to-reveal community-id])
|
||||
share-future-addresses? (get-in db [:communities/selected-share-all-addresses community-id])
|
||||
airdrop-address (get-in db [:communities/all-airdrop-addresses community-id])]
|
||||
(let [pub-key (get-in db [:profile/profile :public-key])
|
||||
addresses-to-reveal (get-in db [:communities/all-addresses-to-reveal community-id])
|
||||
airdrop-address (get-in db [:communities/all-airdrop-addresses community-id])]
|
||||
{:fx [[:effects.community/request-to-join
|
||||
{:community-id community-id
|
||||
:password password
|
||||
:pub-key pub-key
|
||||
:addresses-to-reveal addresses-to-reveal
|
||||
:airdrop-address airdrop-address
|
||||
:share-future-addresses? share-future-addresses?
|
||||
:on-success [:communities/requested-to-join]
|
||||
:on-error [:communities/requested-to-join-error community-id]}]]}))
|
||||
{:community-id community-id
|
||||
:password password
|
||||
:pub-key pub-key
|
||||
:addresses-to-reveal addresses-to-reveal
|
||||
:airdrop-address airdrop-address
|
||||
:on-success [:communities/requested-to-join]
|
||||
:on-error [:communities/requested-to-join-error community-id]}]]}))
|
||||
|
||||
(rf/reg-event-fx :communities/request-to-join-with-addresses request-to-join-with-addresses)
|
||||
|
||||
@@ -37,22 +37,19 @@
|
||||
(sut/sign-data cofx [community-id password sign-params])))))
|
||||
|
||||
(deftest request-to-join-with-signatures-test
|
||||
(let [cofx {:db {}}
|
||||
addresses-to-reveal [account-pub-key "0x2"]
|
||||
share-future-addresses? true
|
||||
signatures ["11111" "222222"]
|
||||
expected {:fx [[:json-rpc/call
|
||||
[{:method "wakuext_requestToJoinCommunity"
|
||||
:params [{:communityId community-id
|
||||
:signatures signatures
|
||||
:addressesToReveal addresses-to-reveal
|
||||
:shareFutureAddresses share-future-addresses?
|
||||
:airdropAddress "0x1"}]
|
||||
:js-response true
|
||||
:on-success [:communities/requested-to-join]
|
||||
:on-error [:communities/requested-to-join-error
|
||||
community-id]}]]]}]
|
||||
(let [cofx {:db {}}
|
||||
addresses-to-reveal [account-pub-key "0x2"]
|
||||
signatures ["11111" "222222"]
|
||||
expected {:fx [[:json-rpc/call
|
||||
[{:method "wakuext_requestToJoinCommunity"
|
||||
:params [{:communityId community-id
|
||||
:signatures signatures
|
||||
:addressesToReveal addresses-to-reveal
|
||||
:airdropAddress "0x1"}]
|
||||
:js-response true
|
||||
:on-success [:communities/requested-to-join]
|
||||
:on-error [:communities/requested-to-join-error
|
||||
community-id]}]]]}]
|
||||
(is (match? expected
|
||||
(sut/request-to-join-with-signatures cofx
|
||||
[community-id addresses-to-reveal signatures
|
||||
share-future-addresses?])))))
|
||||
[community-id addresses-to-reveal signatures])))))
|
||||
|
||||
@@ -12,10 +12,9 @@
|
||||
constants/community-token-permission-become-member :t/member
|
||||
fallback-to)))
|
||||
|
||||
(defn sorted-operable-non-watch-only-accounts
|
||||
(defn sorted-non-watch-only-accounts
|
||||
[db]
|
||||
(->> (get-in db [:wallet :accounts])
|
||||
(vals)
|
||||
(remove :watch-only?)
|
||||
(filter :operable?)
|
||||
(sort-by :position)))
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
(ns status-im.contexts.keycard.effects
|
||||
(:require [keycard.keycard :as keycard]
|
||||
[native-module.core :as native-module]
|
||||
[react-native.async-storage :as async-storage]
|
||||
[react-native.platform :as platform]
|
||||
[status-im.contexts.profile.config :as profile.config]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.re-frame :as rf]
|
||||
[utils.transforms :as transforms]))
|
||||
|
||||
(defonce ^:private active-listeners (atom []))
|
||||
|
||||
(defn register-card-events
|
||||
[]
|
||||
(doseq [listener @active-listeners]
|
||||
(keycard/remove-event-listener listener))
|
||||
(reset! active-listeners
|
||||
[(keycard/on-card-connected #(rf/dispatch [:keycard/on-card-connected]))
|
||||
(keycard/on-card-disconnected #(rf/dispatch [:keycard/on-card-disconnected]))
|
||||
(when platform/ios?
|
||||
(keycard/on-nfc-user-cancelled #(rf/dispatch [:keycard.ios/on-nfc-user-cancelled])))
|
||||
(when platform/ios?
|
||||
(keycard/on-nfc-timeout #(rf/dispatch [:keycard.ios/on-nfc-timeout])))
|
||||
(keycard/on-nfc-enabled #(rf/dispatch [:keycard/on-check-nfc-enabled-success true]))
|
||||
(keycard/on-nfc-disabled #(rf/dispatch [:keycard/on-check-nfc-enabled-success false]))]))
|
||||
(rf/reg-fx :effects.keycard/register-card-events register-card-events)
|
||||
|
||||
(defn check-nfc-enabled
|
||||
[]
|
||||
(log/debug "[keycard] check-nfc-enabled")
|
||||
(keycard/check-nfc-enabled
|
||||
{:on-success
|
||||
(fn [response]
|
||||
(log/debug "[keycard response] check-nfc-enabled")
|
||||
(rf/dispatch [:keycard/on-check-nfc-enabled-success response]))}))
|
||||
(rf/reg-fx :effects.keycard/check-nfc-enabled check-nfc-enabled)
|
||||
|
||||
(rf/reg-fx
|
||||
:effects.keycard.ios/start-nfc
|
||||
(fn [args]
|
||||
(log/debug "fx start-nfc")
|
||||
(keycard/start-nfc args)))
|
||||
|
||||
(rf/reg-fx
|
||||
:effects.keycard.ios/stop-nfc
|
||||
(fn [args]
|
||||
(log/debug "fx stop-nfc")
|
||||
(keycard/stop-nfc args)))
|
||||
|
||||
(defn- error-object->map
|
||||
[^js object]
|
||||
{:code (.-code object)
|
||||
:error (.-message object)})
|
||||
|
||||
(defn get-application-info
|
||||
[{:keys [on-success on-failure] :as args}]
|
||||
(log/debug "[keycard] get-application-info")
|
||||
(keycard/get-application-info
|
||||
(assoc
|
||||
args
|
||||
:on-success
|
||||
(fn [response]
|
||||
(log/debug "[keycard response succ] get-application-info")
|
||||
(when on-success
|
||||
(on-success response)))
|
||||
:on-failure
|
||||
(fn [response]
|
||||
(log/error "[keycard response fail] get-application-info")
|
||||
(when on-failure
|
||||
(on-failure (error-object->map response)))))))
|
||||
(rf/reg-fx :effects.keycard/get-application-info get-application-info)
|
||||
|
||||
(defn get-keys
|
||||
[{:keys [on-success on-failure] :as args}]
|
||||
(log/debug "[keycard] get-keys")
|
||||
(keycard/get-keys
|
||||
(assoc
|
||||
args
|
||||
:on-success
|
||||
(fn [response]
|
||||
(log/debug "[keycard response succ] get-keys")
|
||||
(when on-success
|
||||
(on-success (transforms/js->clj response))))
|
||||
:on-failure
|
||||
(fn [response]
|
||||
(log/warn "[keycard response fail] get-keys"
|
||||
(error-object->map response))
|
||||
(when on-failure
|
||||
(on-failure (error-object->map response)))))))
|
||||
(rf/reg-fx :effects.keycard/get-keys get-keys)
|
||||
|
||||
(defn login
|
||||
[{:keys [key-uid password whisper-private-key]}]
|
||||
(native-module/login-account
|
||||
(assoc (profile.config/login)
|
||||
:keyUid key-uid
|
||||
:password password
|
||||
:keycardWhisperPrivateKey whisper-private-key)))
|
||||
(rf/reg-fx :effects.keycard/login-with-keycard login)
|
||||
|
||||
(defn retrieve-pairings
|
||||
[]
|
||||
(async-storage/get-item
|
||||
"status-keycard-pairings"
|
||||
#(rf/dispatch [:keycard/on-retrieve-pairings-success %])))
|
||||
(rf/reg-fx :effects.keycard/retrieve-pairings retrieve-pairings)
|
||||
|
||||
(defn set-pairing-to-keycard
|
||||
[pairings]
|
||||
(keycard/set-pairings pairings))
|
||||
(rf/reg-fx :effects.keycard/set-pairing-to-keycard set-pairing-to-keycard)
|
||||
@@ -1,57 +0,0 @@
|
||||
(ns status-im.contexts.keycard.events
|
||||
(:require [re-frame.core :as rf]
|
||||
status-im.contexts.keycard.login.events
|
||||
status-im.contexts.keycard.pin.events
|
||||
status-im.contexts.keycard.sheet.events
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
(rf/reg-event-fx :keycard/on-check-nfc-enabled-success
|
||||
(fn [{:keys [db]} [nfc-enabled?]]
|
||||
{:db (assoc-in db [:keycard :nfc-enabled?] nfc-enabled?)}))
|
||||
|
||||
(rf/reg-event-fx :keycard.ios/on-nfc-user-cancelled
|
||||
(fn [{:keys [db]}]
|
||||
(log/debug "[keycard] nfc user cancelled")
|
||||
{:db (assoc-in db [:keycard :pin :status] nil)
|
||||
:fx [(when-let [on-nfc-cancelled-event-vector (get-in db [:keycard :on-nfc-cancelled-event-vector])]
|
||||
[:dispatch on-nfc-cancelled-event-vector])]}))
|
||||
|
||||
(rf/reg-event-fx :keycard/on-card-connected
|
||||
(fn [{:keys [db]} _]
|
||||
(log/debug "[keycard] card globally connected")
|
||||
{:db (assoc-in db [:keycard :card-connected?] true)
|
||||
:fx [(when-let [event (get-in db [:keycard :on-card-connected-event-vector])]
|
||||
[:dispatch event])]}))
|
||||
|
||||
(rf/reg-event-fx :keycard/on-card-disconnected
|
||||
(fn [{:keys [db]} _]
|
||||
(log/debug "[keycard] card disconnected")
|
||||
{:db (assoc-in db [:keycard :card-connected?] false)
|
||||
:fx [(when-let [event (get-in db [:keycard :on-card-disconnected-event-vector])]
|
||||
[:dispatch event])]}))
|
||||
|
||||
(rf/reg-event-fx :keycard.ios/start-nfc
|
||||
(fn [_]
|
||||
{:effects.keycard.ios/start-nfc nil}))
|
||||
|
||||
(rf/reg-event-fx :keycard.ios/on-nfc-timeout
|
||||
(fn [{:keys [db]} _]
|
||||
(log/debug "[keycard] nfc timeout")
|
||||
{:db (assoc-in db [:keycard :card-connected?] false)
|
||||
:fx [[:dispatch-later [{:ms 500 :dispatch [:keycard.ios/start-nfc]}]]]}))
|
||||
|
||||
(rf/reg-event-fx :keycard/get-application-info
|
||||
(fn [_ [{:keys [on-success on-failure]}]]
|
||||
(log/debug "[keycard] get-application-info")
|
||||
{:effects.keycard/get-application-info {:on-success on-success
|
||||
:on-failure on-failure}}))
|
||||
|
||||
(rf/reg-event-fx :keycard/on-retrieve-pairings-success
|
||||
(fn [{:keys [db]} [pairings]]
|
||||
{:db (assoc-in db [:keycard :pairings] pairings)
|
||||
:fx [[:effects.keycard/set-pairing-to-keycard pairings]]}))
|
||||
|
||||
(rf/reg-event-fx :keycard.ios/on-start-nfc-success
|
||||
(fn [{:keys [db]} [{:keys [on-cancel-event-vector]}]]
|
||||
(log/debug "[keycard] nfc started success")
|
||||
{:db (assoc-in db [:keycard :on-nfc-cancelled-event-vector] on-cancel-event-vector)}))
|
||||
@@ -1,87 +0,0 @@
|
||||
(ns status-im.contexts.keycard.login.events
|
||||
(:require [status-im.contexts.keycard.utils :as keycard.utils]
|
||||
[taoensso.timbre :as log]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(rf/reg-event-fx :keycard.login/on-get-keys-error
|
||||
(fn [{:keys [db]} [error]]
|
||||
(log/debug "[keycard] get keys error: " error)
|
||||
(let [tag-was-lost? (keycard.utils/tag-lost? (:error error))
|
||||
pin-retries-count (keycard.utils/pin-retries (:error error))]
|
||||
(if tag-was-lost?
|
||||
{:db (assoc-in db [:keycard :pin :status] nil)}
|
||||
(if (nil? pin-retries-count)
|
||||
{:effects.utils/show-popup {:title "wrong-keycard"}}
|
||||
{:db (-> db
|
||||
(assoc-in [:keycard :application-info :pin-retry-counter] pin-retries-count)
|
||||
(update-in [:keycard :pin] assoc :status :error))
|
||||
:fx [[:dispatch [:keycard/hide-connection-sheet]]
|
||||
(when (zero? pin-retries-count)
|
||||
[:effects.utils/show-popup {:title "frozen-keycard"}])]})))))
|
||||
|
||||
(rf/reg-event-fx :keycard.login/on-get-keys-success
|
||||
(fn [{:keys [db]} [data]]
|
||||
(let [{:keys [key-uid encryption-public-key
|
||||
whisper-private-key]} data
|
||||
key-uid (str "0x" key-uid)
|
||||
profile (get-in db [:profile/profiles-overview key-uid])]
|
||||
{:db
|
||||
(-> db
|
||||
(dissoc :keycard)
|
||||
(update :profile/login assoc
|
||||
:password encryption-public-key
|
||||
:key-uid key-uid
|
||||
:name (:name profile)))
|
||||
:fx [[:dispatch [:keycard/hide-connection-sheet]]
|
||||
[:effects.keycard/login-with-keycard
|
||||
{:password encryption-public-key
|
||||
:whisper-private-key whisper-private-key
|
||||
:key-uid key-uid}]]})))
|
||||
|
||||
(rf/reg-event-fx :keycard.login/on-get-keys-from-keychain-success
|
||||
(fn [{:keys [db]} [key-uid [encryption-public-key whisper-private-key]]]
|
||||
(when (and encryption-public-key whisper-private-key)
|
||||
(let [profile (get-in db [:profile/profiles-overview key-uid])]
|
||||
{:db
|
||||
(-> db
|
||||
(dissoc :keycard)
|
||||
(update :profile/login assoc
|
||||
:password encryption-public-key
|
||||
:key-uid key-uid
|
||||
:name (:name profile)))
|
||||
:fx [[:dispatch [:keycard/hide-connection-sheet]]
|
||||
[:effects.keycard/login-with-keycard
|
||||
{:password encryption-public-key
|
||||
:whisper-private-key whisper-private-key
|
||||
:key-uid key-uid}]]}))))
|
||||
|
||||
(rf/reg-event-fx :keycard.login/on-get-application-info-success
|
||||
(fn [{:keys [db]} [application-info]]
|
||||
(let [profile (get-in db [:profile/profiles-overview (get-in db [:profile/login :key-uid])])
|
||||
pin (get-in db [:keycard :pin :text])
|
||||
error (keycard.utils/validate-application-info profile application-info)]
|
||||
(if error
|
||||
{:effects.utils/show-popup {:title (str error)}}
|
||||
{:db (-> db
|
||||
(assoc-in [:keycard :application-info] application-info)
|
||||
(assoc-in [:keycard :pin :status] :verifying))
|
||||
:effects.keycard/get-keys {:pin pin
|
||||
:on-success #(rf/dispatch [:keycard.login/on-get-keys-success %])
|
||||
:on-failure #(rf/dispatch [:keycard.login/on-get-keys-error %])}}))))
|
||||
|
||||
(rf/reg-event-fx :keycard.login/cancel-reading-card
|
||||
(fn [{:keys [db]}]
|
||||
{:db (assoc-in db [:keycard :on-card-connected-event-vector] nil)}))
|
||||
|
||||
(rf/reg-event-fx :keycard/read-card-and-login
|
||||
(fn [{:keys [db]}]
|
||||
(let [connected? (get-in db [:keycard :card-connected?])
|
||||
event-vector [:keycard/get-application-info
|
||||
{:on-success #(rf/dispatch [:keycard.login/on-get-application-info-success %])}]]
|
||||
(log/debug "[keycard] proceed-to-login")
|
||||
{:db (assoc-in db [:keycard :on-card-connected-event-vector] event-vector)
|
||||
:fx [[:dispatch
|
||||
[:keycard/show-connection-sheet
|
||||
{:on-cancel-event-vector [:keycard.login/cancel-reading-card]}]]
|
||||
(when connected?
|
||||
[:dispatch event-vector])]})))
|
||||
@@ -1,21 +0,0 @@
|
||||
(ns status-im.contexts.keycard.pin.events
|
||||
(:require [utils.re-frame :as rf]))
|
||||
|
||||
(rf/reg-event-fx :keycard.pin/delete-pressed
|
||||
(fn [{:keys [db]}]
|
||||
(let [pin (get-in db [:keycard :pin :text])]
|
||||
(when (and pin (pos? (count pin)))
|
||||
{:db (-> db
|
||||
(assoc-in [:keycard :pin :text] (.slice pin 0 -1))
|
||||
(assoc-in [:keycard :pin :status] nil))}))))
|
||||
|
||||
(rf/reg-event-fx :keycard.pin/number-pressed
|
||||
(fn [{:keys [db]} [number max-numbers on-complete-event]]
|
||||
(let [pin (get-in db [:keycard :pin :text])
|
||||
new-pin (str pin number)]
|
||||
(when (<= (count new-pin) max-numbers)
|
||||
{:db (-> db
|
||||
(assoc-in [:keycard :pin :text] new-pin)
|
||||
(assoc-in [:keycard :pin :status] nil))
|
||||
:fx [(when (= (dec max-numbers) (count pin))
|
||||
[:dispatch [on-complete-event]])]}))))
|
||||
@@ -1,26 +0,0 @@
|
||||
(ns status-im.contexts.keycard.pin.view
|
||||
(:require [quo.core :as quo]
|
||||
[react-native.core :as rn]
|
||||
[status-im.constants :as constants]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(defn auth
|
||||
[callback-event-key]
|
||||
(let [{:keys [text status]} (rf/sub [:keycard/pin])
|
||||
pin-retry-counter (rf/sub [:keycard/pin-retry-counter])
|
||||
error? (= status :error)]
|
||||
[rn/view {:padding-bottom 12 :flex 1}
|
||||
[rn/view {:flex 1 :justify-content :center :align-items :center :padding 34}
|
||||
[quo/pin-input
|
||||
{:blur? false
|
||||
:number-of-pins constants/pincode-length
|
||||
:number-of-filled-pins (count text)
|
||||
:error? error?
|
||||
:info (when error?
|
||||
(i18n/label :t/pin-retries-left {:number pin-retry-counter}))}]]
|
||||
[quo/numbered-keyboard
|
||||
{:delete-key? true
|
||||
:on-delete #(rf/dispatch [:keycard.pin/delete-pressed])
|
||||
:on-press #(rf/dispatch [:keycard.pin/number-pressed % constants/pincode-length
|
||||
callback-event-key])}]]))
|
||||
@@ -1,30 +0,0 @@
|
||||
(ns status-im.contexts.keycard.sheet.events
|
||||
(:require [re-frame.core :as rf]
|
||||
[react-native.platform :as platform]
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
(rf/reg-event-fx :keycard/show-connection-sheet-component
|
||||
(fn [{:keys [db]} [{:keys [on-cancel-event-vector]}]]
|
||||
{:db (assoc-in db [:keycard :connection-sheet-opts] {:on-close #(rf/dispatch on-cancel-event-vector)})
|
||||
:fx [[:dismiss-keyboard true]
|
||||
[:show-nfc-sheet nil]]}))
|
||||
|
||||
(rf/reg-event-fx :keycard/show-connection-sheet
|
||||
(fn [_ [args]]
|
||||
(if platform/android?
|
||||
{:dispatch [:keycard/show-connection-sheet-component args]}
|
||||
{:effects.keycard.ios/start-nfc
|
||||
{:on-success
|
||||
(fn []
|
||||
(log/debug "nfc started successfully. next: show-connection-sheet")
|
||||
(rf/dispatch [:keycard.ios/on-start-nfc-success args]))
|
||||
:on-failure
|
||||
(fn []
|
||||
(log/debug "nfc failed star starting. not calling show-connection-sheet"))}})))
|
||||
|
||||
(rf/reg-event-fx :keycard/hide-connection-sheet
|
||||
(fn [{:keys [db]}]
|
||||
(if platform/android?
|
||||
{:db (assoc-in db [:keycard :connection-sheet-opts] nil)
|
||||
:fx [[:hide-nfc-sheet nil]]}
|
||||
{:effects.keycard.ios/stop-nfc nil})))
|
||||
@@ -1,36 +0,0 @@
|
||||
(ns status-im.contexts.keycard.sheet.view
|
||||
(:require [quo.foundations.colors :as colors]
|
||||
quo.theme
|
||||
[react-native.core :as rn]
|
||||
[status-im.common.resources :as resources]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(defn connect-keycard
|
||||
[]
|
||||
(let [connected? (rf/sub [:keycard/connected?])
|
||||
{:keys [on-close]} (rf/sub [:keycard/connection-sheet-opts])
|
||||
theme (quo.theme/use-theme)]
|
||||
[rn/view {:flex 1}
|
||||
[rn/view {:flex 1}]
|
||||
[rn/view
|
||||
{:style {:align-items :center
|
||||
:padding-horizontal 36
|
||||
:padding-vertical 30
|
||||
:background-color (colors/theme-colors colors/white colors/neutral-95 theme)}}
|
||||
[rn/text {:style {:font-size 26 :color "#9F9FA5" :margin-bottom 36}}
|
||||
"Ready to Scan"]
|
||||
[rn/image
|
||||
{:source (resources/get-image :nfc-prompt)}]
|
||||
[rn/text {:style {:font-size 16 :color :white :margin-vertical 36}}
|
||||
(if connected?
|
||||
"Connected. Don’t move your card."
|
||||
"Hold your phone near a Status Keycard")]
|
||||
[rn/pressable
|
||||
{:on-press (fn []
|
||||
(when on-close (on-close))
|
||||
(rf/dispatch [:keycard/hide-connection-sheet]))
|
||||
:style {:flex-direction :row}}
|
||||
[rn/view
|
||||
{:style {:background-color "#8E8E93" :flex 1 :align-items :center :padding 18 :border-radius 10}}
|
||||
[rn/text {:style {:color :white :font-size 16}}
|
||||
"Cancel"]]]]]))
|
||||
@@ -1,45 +0,0 @@
|
||||
(ns status-im.contexts.keycard.utils
|
||||
(:require [taoensso.timbre :as log]))
|
||||
|
||||
(def pin-mismatch-error #"Unexpected error SW, 0x63C(\d+)|wrongPIN\(retryCounter: (\d+)\)")
|
||||
|
||||
(defn pin-retries
|
||||
[error]
|
||||
(when-let [matched-error (re-matches pin-mismatch-error error)]
|
||||
(js/parseInt (second (filter some? matched-error)))))
|
||||
|
||||
(defn tag-lost?
|
||||
[error]
|
||||
(or
|
||||
(= error "Tag was lost.")
|
||||
(= error "NFCError:100")
|
||||
(re-matches #".*NFCError:100.*" error)))
|
||||
|
||||
(defn validate-application-info
|
||||
[profile {:keys [key-uid paired? pin-retry-counter puk-retry-counter] :as application-info}]
|
||||
(let [profile-mismatch? (or (nil? profile) (not= (:key-uid profile) key-uid))]
|
||||
(log/debug "[keycard] login-with-keycard"
|
||||
"empty application info" (empty? application-info)
|
||||
"no key-uid" (empty? key-uid)
|
||||
"profile-mismatch?" profile-mismatch?
|
||||
"no pairing" paired?)
|
||||
(cond
|
||||
(empty? application-info)
|
||||
:not-keycard
|
||||
|
||||
(empty? (:key-uid application-info))
|
||||
:keycard-blank
|
||||
|
||||
profile-mismatch?
|
||||
:keycard-wrong
|
||||
|
||||
(not paired?)
|
||||
:keycard-unpaired
|
||||
|
||||
(and (zero? pin-retry-counter)
|
||||
(or (nil? puk-retry-counter)
|
||||
(pos? puk-retry-counter)))
|
||||
nil
|
||||
|
||||
:else
|
||||
nil)))
|
||||
@@ -5,8 +5,13 @@
|
||||
|
||||
(def background-container
|
||||
{:background-color colors/neutral-100
|
||||
:flex 1
|
||||
:overflow :hidden})
|
||||
:flex-direction :row
|
||||
:position :absolute
|
||||
:overflow :hidden
|
||||
:top 0
|
||||
:bottom 0
|
||||
:left 0
|
||||
:right 0})
|
||||
|
||||
(def background-blur-overlay
|
||||
{:position :absolute
|
||||
|
||||
@@ -25,12 +25,13 @@
|
||||
:sub-text (i18n/label :t/explore-the-decentralized-web)}])
|
||||
|
||||
(defn background-image
|
||||
[image-view-width]
|
||||
[content-width]
|
||||
[rn/image
|
||||
{:resize-mode :stretch
|
||||
:style {:flex 1
|
||||
:width image-view-width}
|
||||
:source (resources/get-image :onboarding-illustration)}])
|
||||
{:resize-mode :stretch
|
||||
:resize-method :scale
|
||||
:style {:top 138
|
||||
:width content-width}
|
||||
:source (resources/get-image :onboarding-illustration)}])
|
||||
|
||||
(defonce progress (atom nil))
|
||||
(defonce paused? (atom nil))
|
||||
|
||||
@@ -5,9 +5,12 @@
|
||||
|
||||
(defn header-container
|
||||
[status-bar-height content-width index header-background]
|
||||
{:margin-left (* content-width index)
|
||||
{:position :absolute
|
||||
:top 0
|
||||
:left (* content-width index)
|
||||
:padding-top (+ 30 status-bar-height)
|
||||
:width content-width
|
||||
:height (+ 96 status-bar-height)
|
||||
:flex-direction :row
|
||||
:background-color (when header-background colors/onboarding-header-black)})
|
||||
|
||||
@@ -59,9 +62,9 @@
|
||||
:top (+ 12 status-bar-height)})
|
||||
|
||||
(defn carousel-container
|
||||
[left animate? width]
|
||||
(cond->> {:flex-direction :row
|
||||
:flex 1
|
||||
:width width
|
||||
:margin-left left}
|
||||
animate? (reanimated/apply-animations-to-style {:margin-left left})))
|
||||
[left animate?]
|
||||
(cond->> {:position :absolute
|
||||
:top 0
|
||||
:flex-direction :row
|
||||
:left left}
|
||||
animate? (reanimated/apply-animations-to-style {:left left})))
|
||||
|
||||
@@ -18,18 +18,19 @@
|
||||
:size :heading-2}
|
||||
(get-in header-text [index :text])]
|
||||
[quo/text
|
||||
{:style style/carousel-sub-text}
|
||||
{:style style/carousel-sub-text
|
||||
:size :paragraph-1}
|
||||
(get-in header-text [index :sub-text])]])
|
||||
|
||||
(defn content-view
|
||||
[{:keys [window-width status-bar-height index header-text header-background]} content]
|
||||
(let [content-width (* 4 window-width)]
|
||||
[rn/view {:style {:flex 1}}
|
||||
[:<>
|
||||
(when content content)
|
||||
[rn/view {:style (style/header-container status-bar-height content-width index header-background)}
|
||||
(for [index (range 4)]
|
||||
^{:key index}
|
||||
[header-text-view index window-width header-text])]
|
||||
(when content content)]))
|
||||
[header-text-view index window-width header-text])]]))
|
||||
|
||||
(defn progress-bar
|
||||
[{:keys [static? progress-bar-width]}]
|
||||
@@ -63,10 +64,10 @@
|
||||
:swipeable (animation/composed-gestures progress paused? is-dragging? drag-amount)
|
||||
:tappable (animation/tap-gesture progress paused?)
|
||||
nil)]
|
||||
[rn/view {:style {:flex 1}}
|
||||
[:<>
|
||||
[gesture/gesture-detector {:gesture identified-gesture}
|
||||
[container-view {:style (style/carousel-container carousel-left animate? (* 4 window-width))}
|
||||
(for [index (range 1)]
|
||||
[container-view {:style (style/carousel-container carousel-left animate?)}
|
||||
(for [index (range 2)]
|
||||
^{:key index}
|
||||
[content-view
|
||||
{:window-width window-width
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
[react-native.core :as rn]
|
||||
[react-native.safe-area :as safe-area]
|
||||
[status-im.common.check-before-syncing.view :as check-before-syncing]
|
||||
[status-im.common.metrics-confirmation-modal.view :as metrics-modal]
|
||||
[status-im.common.not-implemented :as not-implemented]
|
||||
[status-im.common.resources :as resources]
|
||||
[status-im.config :as config]
|
||||
@@ -127,7 +126,6 @@
|
||||
|
||||
(defn- internal-view
|
||||
[sign-in-type]
|
||||
(rn/use-mount #(rf/dispatch [:centralized-metrics/check-modal metrics-modal/view]))
|
||||
(let [{:keys [top]} (safe-area/get-insets)]
|
||||
[rn/view {:style style/content-container}
|
||||
[quo/page-nav
|
||||
|
||||
@@ -4,20 +4,20 @@
|
||||
|
||||
(def title-container
|
||||
{:margin-horizontal 20
|
||||
:padding-bottom 20
|
||||
:padding-top 12})
|
||||
:padding-vertical 12})
|
||||
|
||||
(defn page-container
|
||||
[insets]
|
||||
{:flex 1
|
||||
:padding-top (+ (:top insets) 56)})
|
||||
{:flex 1
|
||||
:justify-content :space-between
|
||||
:padding-top (+ (:top insets) 56)})
|
||||
|
||||
(defn page-illustration
|
||||
[width]
|
||||
{:flex 1
|
||||
:margin-top 12
|
||||
:margin-bottom 10
|
||||
:width width})
|
||||
{:flex 1
|
||||
:padding-top 12
|
||||
:padding-bottom 10
|
||||
:width width})
|
||||
|
||||
(defn buttons
|
||||
[insets]
|
||||
|
||||
@@ -2,16 +2,11 @@
|
||||
|
||||
(defn page-container
|
||||
[insets]
|
||||
{:flex 1
|
||||
:padding-top (:top insets)})
|
||||
{:flex 1
|
||||
:justify-content :space-between
|
||||
:padding-top (:top insets)})
|
||||
|
||||
(defn page-illustration
|
||||
[width]
|
||||
{:flex 1
|
||||
:width width})
|
||||
|
||||
(def title-style
|
||||
{:position :absolute
|
||||
:left 0
|
||||
:right 0
|
||||
:top 0})
|
||||
|
||||
@@ -17,22 +17,19 @@
|
||||
(defn generate-keys-title
|
||||
[]
|
||||
[quo/text-combinations
|
||||
{:container-style {:margin-horizontal 20
|
||||
:margin-vertical 12}
|
||||
{:container-style {:margin-horizontal 20}
|
||||
:title (i18n/label :t/generating-keys)}])
|
||||
|
||||
(defn saving-keys-title
|
||||
[]
|
||||
[quo/text-combinations
|
||||
{:container-style {:margin-horizontal 20
|
||||
:margin-vertical 12}
|
||||
{:container-style {:margin-horizontal 20}
|
||||
:title (i18n/label :t/saving-keys-to-device)}])
|
||||
|
||||
(defn keys-saved-title
|
||||
[]
|
||||
[quo/text-combinations
|
||||
{:container-style {:margin-horizontal 20
|
||||
:margin-vertical 12}
|
||||
{:container-style {:margin-horizontal 20}
|
||||
:title (i18n/label :t/keys-saved)}])
|
||||
|
||||
(defn sequence-animation
|
||||
@@ -64,42 +61,46 @@
|
||||
reanimated/easings))))))
|
||||
|
||||
(defn title
|
||||
[]
|
||||
(let [generate-keys-opacity (reanimated/use-shared-value 1)
|
||||
[insets]
|
||||
(let [top-insets (+ (if rn/small-screen? 62 112) (:insets insets))
|
||||
generate-keys-opacity (reanimated/use-shared-value 1)
|
||||
saving-keys-opacity (reanimated/use-shared-value 0)
|
||||
keys-saved-opacity (reanimated/use-shared-value 0)]
|
||||
(sequence-animation generate-keys-opacity saving-keys-opacity keys-saved-opacity)
|
||||
[rn/view
|
||||
{:style {:margin-top 56
|
||||
:height 56}}
|
||||
{:position :absolute
|
||||
:top top-insets}
|
||||
[reanimated/view
|
||||
{:style (reanimated/apply-animations-to-style
|
||||
{:opacity generate-keys-opacity}
|
||||
style/title-style)}
|
||||
{:position :absolute})}
|
||||
[generate-keys-title]]
|
||||
[reanimated/view
|
||||
{:style (reanimated/apply-animations-to-style
|
||||
{:opacity saving-keys-opacity}
|
||||
style/title-style)}
|
||||
{:position :absolute})}
|
||||
[saving-keys-title]]
|
||||
[reanimated/view
|
||||
{:style (reanimated/apply-animations-to-style
|
||||
{:opacity keys-saved-opacity}
|
||||
style/title-style)}
|
||||
{:position :absolute})}
|
||||
[keys-saved-title]]]))
|
||||
|
||||
(defn content
|
||||
[]
|
||||
(let [width (:width (rn/get-window))]
|
||||
[rn/image
|
||||
{:resize-mode :contain
|
||||
:style (style/page-illustration width)
|
||||
:source (resources/get-image :generate-keys1)}]))
|
||||
[rn/view
|
||||
{:top 156
|
||||
:position :absolute}
|
||||
[rn/image
|
||||
{:resize-mode :contain
|
||||
:style (style/page-illustration width)
|
||||
:source (resources/get-image :generate-keys1)}]]))
|
||||
|
||||
(defn view
|
||||
[]
|
||||
(let [insets (safe-area/get-insets)]
|
||||
[rn/view {:style (style/page-container insets)}
|
||||
[:<>
|
||||
[title]
|
||||
[title insets]
|
||||
[content]]]))
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user