Compare commits

..
Author SHA1 Message Date
Richard Ramos d94cbb752e chore_: update status-go to reduce the interval for batch subscriptions in waku filter 2024-08-23 09:51:05 -04:00
Andrea Maria Piana f71863c831 reduce filter loop to 300ms 2024-08-23 14:46:07 +01:00
Parvesh Monu 93f7826c2c fix: Not visible status bar on light theme (#21105)
The issue occurred because we updated the theme value after setting the root
(not before), which caused the root to be initialized with the old theme value.
2024-08-22 14:29:28 +01:00
Cristian Lungu fb628cd0f3 fix: send collectible token-id hex conversion 2024-08-21 21:12:51 +01:00
Ulises Manuel 330fb2c9bb feat(settings): Add Privacy Policy and metrics modal for the sharing usage data toggle (#21087)
* Open metrics modal when changing metrics in settings

* Move privacy policy & terms of use components under `status-im.common`

* Add a link to the Privacy Policy in the metrics modal

* Update privacy policy and terms of use content

* Remove extra function wrapper
2024-08-21 21:12:40 +01:00
Mohamed Javid a8c7aa66de Fix: app upgrade issues in wallet (#21104)
This commit:

- hides keypairs with empty origin in selection while creating an account
- hides remove account button for accounts with empty origin


Signed-off-by: Mohamed Javid <19339952+smohamedjavid@users.noreply.github.com>
2024-08-21 15:10:41 +01:00
Andrea Maria Piana 1625ac8bed update statusgo version 2024-08-21 14:28:36 +01:00
Andrea Maria Piana 5af5975ccd Revert "REMOVE ME - add logs"
This reverts commit a6688fb866.
2024-08-20 15:28:47 +01:00
Andrea Maria Piana 2f246a29cf update statusgo version 2024-08-20 15:27:30 +01:00
Sean Hagstrom 8241afaeea fix: adjust spacing and verbiage for terms-of-use and privacy-statement onboarding checkbox 2024-08-20 15:25:40 +01:00
frank 0f9d276032 fix_:parse route response
https://github.com/status-im/status-go/compare/9e7d1303...90b3d0fd
2024-08-20 14:35:52 +01:00
Lungu Cristian 411c892022 fix: dapp tx get-standard-crypto-format arg order (#21086) 2024-08-20 09:49:20 +01:00
Andrea Maria Piana a6688fb866 REMOVE ME - add logs
https://github.com/status-im/status-go/compare/9e7d1303...1abe2dec
2024-08-20 09:09:01 +01:00
Andrea Maria Piana 3e6ff0400e Revert "[Remove me] Set credentials to test:test in prod proxy"
This reverts commit 6b29021075.
2024-08-19 15:27:34 +01:00
Andrea Maria Piana de30a0fd83 update statusgo version 2024-08-19 10:40:23 +01:00
Andrea Maria Piana a0cc8c5686 update statusgo 2024-08-19 09:03:27 +01:00
Icaro Motta 5cdf964add feat(wallet): Make wallet behave well when device is offline (#21067)
We make the wallet closer to being offline-first, that is, once data is loaded,
going offline won’t cause unnecessary data re-fetches which currently cause all
balances and data to stay loading forever or eventually balances end up zeroed.

Areas that may be impacted: read-only data displayed in the wallet and editing
accounts.

Fixes https://github.com/status-im/status-mobile/issues/21066
2024-08-19 09:02:27 +01:00
Andrea Maria Piana 98653be7f8 flush hystrix 2024-08-16 19:56:04 +01:00
Andrea Maria Piana 22d47bcffa update statusgo 2024-08-16 14:59:49 +01:00
Andrea Maria Piana 24f82f0b10 Add caching of token amounts
https://github.com/status-im/status-go/compare/1f7816dd...da70d6f1
2024-08-16 14:14:57 +01:00
09c4e33834 Jc/cp3 (#21058)
* chore(status-go) bump to latest

https://github.com/status-im/status-go/compare/a93c8572...dd787c98

* feature: require manual acceptance of terms-of-use and privacy-statement (#21010)

This change changes the initial onboarding screen to require users to manually accept the terms-of-use and privacy-statement before continuing to onboard into the app.


* Hide provider down toast
---------

Co-authored-by: Yevheniia Berdnyk <ie.berdnyk@gmail.com>

* 👓 Hide chain down toasts (#21055)

---------

Co-authored-by: Sean Hagstrom <sean@seanhagstrom.com>
Co-authored-by: Yevheniia Berdnyk <ie.berdnyk@gmail.com>
Co-authored-by: Shivek Khurana <khuranashivek@outlook.com>
2024-08-15 15:57:06 +01:00
Andrea Maria Piana 5b79f40de1 add logs 2024-08-15 12:52:40 +01:00
Andrea Maria Piana 6b29021075 [Remove me] Set credentials to test:test in prod proxy
Prod server is misconfigured, it's using test server credentials.
This commit hardcodes those credentials to continue testing. It will
break once prod is updated.
2024-08-15 08:29:08 +01:00
Andrea Maria Piana 236dc37159 Revert "REMOVE ME, log config"
This reverts commit b43fc6fabf.
2024-08-15 08:28:33 +01:00
Andrea Maria Piana b43fc6fabf REMOVE ME, log config 2024-08-15 08:03:35 +01:00
Andrea Maria Piana 3d205c837c drive stage from config
https://github.com/status-im/status-go/compare/1f7816dd...5bb7c6a8
2024-08-14 20:12:32 +01:00
frank 5c8fc2f700 fix_:enable light client after sync (#21041) (#21042) 2024-08-14 16:46:50 +05:30
Jamie Caprani 1c9d69416b cherry pick to release (#21038) 2024-08-13 15:48:17 +01:00
Andrea Maria Piana 26fb0b20e7 update status-go version 2024-08-13 14:00:50 +01:00
Mohsen b47f53777d [#20971] fix: app crash when collectible max limit is nan (#20992) 2024-08-12 10:24:45 -03:00
Parvesh Monu 1d298d0a5d Improve theme switch (#20984) 2024-08-12 10:24:45 -03:00
Andrea Maria Piana b6f59bc5c0 update status-go version 2024-08-12 13:54:40 +01:00
Andrea Maria Piana 38dd9c46c2 update status-go version 2024-08-12 13:49:42 +01:00
Ulises Manuel 2b6e782e80 fix(wallet): Remove redirection to send flow when the user scans an address QR code (#20979) 2024-08-08 17:28:32 +01:00
Andrea Maria Piana c32f31f8cd update status-go version 2024-08-08 13:57:27 +01:00
flexsurfer 50e41c8ed5 Token-gated permissions are not displayed on community's homepage #20965 (#20976) 2024-08-08 13:50:14 +01:00
Siddarth Kumar 93b748a629 update status-go version to latest release 2024-08-07 14:50:33 +05:30
frankandSiddarth Kumar a324481206 chore:enable status proxy (#20931)
* feat_: enable status proxy

* chore: update jenkins lib

* chore: add missing env reference

---------

Co-authored-by: Siddarth Kumar <siddarthkay@gmail.com>
2024-08-07 14:46:44 +05:30
Jamie Caprani 254717971e Cherry pick to release branch (#20963) 2024-08-06 15:43:10 +01:00
Icaro Motta 05279c111e Bump status-go version 2024-08-02 11:20:20 -03:00
Lungu Cristian b4a49bfe55 Fix typed-data chainid check (#20943)
* fix: typed-data chainid check & toast on sign fail

* fix: parsing the chain-id and error-handling
2024-08-02 11:20:20 -03:00
Sean Hagstrom e5c3357317 fix: remove mobile-data sync setting inside legacy settings (#20942) 2024-08-02 11:20:20 -03:00
Parvesh Monu da2e5ff1c0 fix 'Usage data' bottom sheet reappears after reopening the app if you swipe it down on onboarding (#20945) 2024-08-02 11:20:20 -03:00
Parvesh Monu f69f075e29 fix Mobile app doesn't allow taking screenshots when the 'Block Screenshots' toggle is turned off (#20941) 2024-08-02 11:20:20 -03:00
Ulises Manuel 81350b978f fix(wallet): Error while bridging tokens due to bonderFees (#20929) 2024-08-02 11:20:20 -03:00
Brian Sztamfater f59dca0589 chore: bump react-native-camera-link version to Status fork to remove usage of ML Kit (#20891) 2024-08-02 11:20:20 -03:00
Brian Sztamfater 745e5d75fb fix(wallet): inverted values of receiver and sender when displaying bridging routes (#20893)
Signed-off-by: Brian Sztamfater <brian@status.im>
2024-08-02 11:20:20 -03:00
Mohamed Javid 7c6f2bf878 fix(android): send and bridge ERC-20 tokens (#20924)
This commit adds the missing "encodeFunctionCall" method in Android

Signed-off-by: Mohamed Javid <19339952+smohamedjavid@users.noreply.github.com>
2024-08-02 11:20:20 -03:00
Icaro MottaandMohamed Javid 29203e57ec Update release branch 2.30.x (#20925)
* fix_: use usd as default currency (#20916)

This commit uses "usd" currency as default for the fiat price calculation for the tokens. 

Every currency has a different format - decimal which we need to rely on a separate RPC to fetch currency format and do the calculation. So, this PR will change to use usd as the default for v2.30.

Signed-off-by: Mohamed Javid <19339952+smohamedjavid@users.noreply.github.com>

* Bump status-go version

---------

Signed-off-by: Mohamed Javid <19339952+smohamedjavid@users.noreply.github.com>
Co-authored-by: Mohamed Javid <19339952+smohamedjavid@users.noreply.github.com>
2024-07-30 16:09:44 -03:00
Icaro Motta 0f15c0192d Update release branch 2.30.x (#20903)
Revisions from develop:

- 59ceddbaa develop origin/develop fix(wallet): fix bridge transactions (#20902)
- 99ccbc338 Cover wallet send events with tests Part 2 #20411 #20533 (#20721)
- 8c2d5398b Enabling WalletConnect feature flag (#20906)
- 67c83b13e fix(wallet): remove edit routes button in bridging (#20874)
- 11a84ba14 feat(wallet): disable complex routing (#20901)
- 1f5bb579c chore(wallet): disable bridging on unsupported tokens (#20846)
- 4586f8007 Add toggle in advanced settings for mobile data
- 55c620e59 fix: create password for small screen (#20645)
- 525609f0a Wallet Activity: transactions are not sorted by time #20808 (#20862)
- 90653955a chore(settings): Disable telemetry option (#20881)
- d27ab756d fix_:display group message using the new ui (#20787)
- c6a1db633 ci: enable split apks & build only for arm64-v8a (#20683)
- 73777e052 Ensure keycard account can send transaction after upgrading from v1 to v2 #20552 (#20845)
- a6d3fc374 [#20524] fix: the missed keypairs are shown in the key pair list screen (#20888)
- a671c7083 fix broken screen and navigation when syncing fails (#20887)
- a45991b6d 🥅 Filter connected dapps based on testnet mode, reject proposals and requests gracefully (#20799)
- 2e9fa22e4 feat: wallet router v2 (#20631)
- 737d8c4d5 rename sub to fix error when requesting to join community (#20868)
- 3aa7e103f Sync process is blocked on Enabled notifications screen (#20883)
- c1d2d44da perf: Fix app freeze after login (#20729)
- 0fed8113d e2e: updated testnet switching and added one test into smoke
- 53c35cb55 fix(wallet): Linear gradient exception on invalid colors for watched account cards (#20854)
- be8236554 chore(settings)_: Remove testnet toggle from legacy advanced settings (#20875)
- eae8a6559 feat(wallet)_: Add beta info box in activity tab (#20873)
- fe54a25a3 fix: not clearing network & web3-wallet on logout (#20886)
- 15a4219ef Reject wallet-connect request by dragging the modal down (#20763) (#20836)
- 2ffbdac89 WalletConnect show expired toast (#20857)
- 402eb8397 fix Issue with scrolling WalletConnect transaction on Android (#20867)
- ff88049a0 Fix WalletConnect header alignment on Android (#20860)
- cee21241d WalletConnect no internet edge-cases (#20826)
- 60ad7c8a2 chore(tests): New match-strict? cljs.test directive (#20825)
- 4989c9278 fix_: Adding own address as saved addresses (#20839)
2024-07-30 11:28:07 -03:00
Andrea Maria Piana a1784c5e1f Merge branch 'develop' into release/2.30.x
https://github.com/status-im/status-go/compare/4a43b2b2...4a43b2b2
2024-07-24 13:48:37 +01:00
Andrea Maria Piana 45cf31d469 Enable lightclient by default 2024-07-05 09:22:33 +01:00
Andrea Maria Piana f958d95467 Bump status-go version 2024-07-05 09:21:52 +01:00
Andrea Maria Piana 894f8f26ee Bump release to 2.30.0 2024-07-05 09:20:15 +01:00
69 changed files with 828 additions and 1005 deletions
+2 -3
View File
@@ -436,11 +436,10 @@ android-clean: ##@prepare Clean Gradle state
rm -rf ~/.gradle
android-ports: export FLOWSTORM_PORT ?= 7722
android-ports: export FLOWSTORM_PORT := 7722
android-ports: export TARGET := android-sdk
android-ports: export RCT_METRO_PORT ?= 8081
android-ports: ##@other Add proxies to Android Device/Simulator
adb reverse tcp:$(RCT_METRO_PORT) tcp:$(RCT_METRO_PORT) && \
adb reverse tcp:8081 tcp:8081 && \
adb reverse tcp:3449 tcp:3449 && \
adb reverse tcp:4567 tcp:4567 && \
adb reverse tcp:$(FLOWSTORM_PORT) tcp:$(FLOWSTORM_PORT) && \
+1 -1
View File
@@ -1 +1 @@
2.29.0
2.30.0
+3 -3
View File
@@ -1115,7 +1115,7 @@ PODS:
- React-perflogger (= 0.73.5)
- ReactNativeAudioToolkit (2.0.3):
- React
- ReactNativeCameraKit (14.0.0-beta15):
- ReactNativeCameraKit (14.0.0-beta13):
- React-Core
- ReactNativeNavigation (7.39.0):
- HMSegmentedControl
@@ -1485,7 +1485,7 @@ SPEC CHECKSUMS:
FBLazyVector: 56e0e498dbb513b96c40bac6284729ba4e62672d
FBReactNativeSpec: 146c741a3f40361f6bc13a4ba284678cbedb5881
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
glog: 36c15c01d70ed395c6e4f3619f98a23ee415b07a
glog: 530710e7949eb12c82670bd09e946becf50a3c2a
hermes-engine: 1d1835b2cc54c381909d94d1b3c8e0a2f1a94a0e
HMSegmentedControl: 34c1f54d822d8308e7b24f5d901ec674dfa31352
Keycard: ac6df4d91525c3c82635ac24d4ddd9a80aca5fc8
@@ -1551,7 +1551,7 @@ SPEC CHECKSUMS:
React-utils: 987a4526a2fc0acdfaf87888adfe0bf9d0452066
ReactCommon: 2947b0bffd82ea0e58ca7928881152d4c6dae9af
ReactNativeAudioToolkit: de9610f323e855ac6574be8c99621f3d57c5df06
ReactNativeCameraKit: 71343efc1256720184ce980f164c7eedb78d5c16
ReactNativeCameraKit: d95d3e19c514526a234d9f93c6db7e7f10eef9ea
ReactNativeNavigation: 679d8c8bf3b8ae98d285bce810964d10da85dbdb
RNCAsyncStorage: c913ede1fa163a71cea118ed4670bbaaa4b511bb
RNCClipboard: 60fed4b71560d7bfe40e9d35dea9762b024da86d
@@ -36,6 +36,11 @@ class NetworkManager(private val reactContext: ReactApplicationContext) : ReactC
@ReactMethod
fun inputConnectionStringForBootstrapping(connectionString: String, configJSON: String, callback: Callback) {
val jsonConfig = JSONObject(configJSON)
val receiverConfig = jsonConfig.getJSONObject("receiverConfig")
val keyStorePath = utils.pathCombine(utils.getNoBackupDirectory(), "/keystore")
receiverConfig.put("keystorePath", keyStorePath)
receiverConfig.getJSONObject("nodeConfig").put("rootDataDir", utils.getNoBackupDirectory())
utils.executeRunnableStatusGoMethod(
{ Statusgo.inputConnectionStringForBootstrapping(connectionString, jsonConfig.toString()) },
callback
@@ -35,7 +35,21 @@ RCT_EXPORT_METHOD(inputConnectionStringForBootstrapping:(NSString *)cs
configJSON:(NSString *)configJSON
callback:(RCTResponseSenderBlock)callback) {
NSString *result = StatusgoInputConnectionStringForBootstrapping(cs, configJSON);
NSData *configData = [configJSON dataUsingEncoding:NSUTF8StringEncoding];
NSError *error;
NSMutableDictionary *configDict = [NSJSONSerialization JSONObjectWithData:configData options:NSJSONReadingMutableContainers error:&error];
NSMutableDictionary *receiverConfig = configDict[@"receiverConfig"];
NSMutableDictionary *nodeConfig = receiverConfig[@"nodeConfig"];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSURL *rootUrl =[[fileManager URLsForDirectory:NSLibraryDirectory inDomains:NSUserDomainMask] lastObject];
NSURL *multiaccountKeystoreDir = [rootUrl URLByAppendingPathComponent:@"keystore"];
NSString *keystoreDir = multiaccountKeystoreDir.path;
NSString *rootDataDir = rootUrl.path;
[receiverConfig setValue:keystoreDir forKey:@"keystorePath"];
[nodeConfig setValue:rootDataDir forKey:@"rootDataDir"];
NSString *modifiedConfigJSON = [Utils jsonStringWithPrettyPrint:NO fromDictionary:configDict];
NSString *result = StatusgoInputConnectionStringForBootstrapping(cs, modifiedConfigJSON);
callback(@[result]);
}
-2
View File
@@ -17,7 +17,6 @@
hermesEnabled ? lib.getEnvWithDefault "ORG_GRADLE_PROJECT_hermesEnabled" "true",
buildUrl ? lib.getEnvWithDefault "ORG_GRADLE_PROJECT_buildUrl" null,
statusGoSrcOverride ? lib.getEnvWithDefault "STATUS_GO_SRC_OVERRIDE" null,
reactMetroPort ? lib.getEnvWithDefault "RCT_METRO_PORT" 8081,
# If APKs should be split based on architectures
androidAbiSplit ? lib.getEnvWithDefault "ANDROID_ABI_SPLIT" "true",
# Android architectures to build for
@@ -159,7 +158,6 @@ in stdenv.mkDerivation rec {
--no-build-cache \
--parallel \
-Dmaven.repo.local='${deps.gradle}' \
-PreactNativeDevServerPort=${toString reactMetroPort} \
assemble${gradleBuildType}
'';
in
+1 -1
View File
@@ -6,7 +6,7 @@ if pgrep -f 'shadow-cljs watch mobile' > /dev/null; then
exit 1
fi
if pgrep -f "react-native start --port=${RCT_METRO_PORT:-8081}" > /dev/null; then
if pgrep -f 'react-native start' > /dev/null; then
echo "Error: make run-metro is already running in another terminal" >&2
echo "Please close that terminal before running this command." >&2
exit 1
+1 -1
View File
@@ -13,7 +13,7 @@ export BUILD_TYPE=debug
# Install the APK on running emulator or android device.
installAndLaunchApp() {
adb install -r "./result/app-${ANDROID_ABI_INCLUDE}-debug.apk" > "${ADB_INSTALL_LOG_FILE}" 2>&1
adb install -r ./result/app-arm64-v8a-debug.apk > "${ADB_INSTALL_LOG_FILE}" 2>&1
"${GIT_ROOT}/scripts/wait-for-metro-port.sh" 2>&1
# connected android devices need this port to be exposed for metro
adb reverse "tcp:${RCT_METRO_PORT}" "tcp:${RCT_METRO_PORT}"
+2 -2
View File
@@ -1,8 +1,8 @@
#!/usr/bin/env bash
if pgrep -f "react-native start --port=${RCT_METRO_PORT:-8081}" > /dev/null; then
if pgrep -f 'react-native start' > /dev/null; then
echo "Info: metro is already running in another terminal"
else
echo "Info: starting a new metro terminal"
react-native start --port=${RCT_METRO_PORT:-8081} --reset-cache
react-native start --reset-cache
fi
+1 -1
View File
@@ -4,7 +4,7 @@ set -euo pipefail
TIMEOUT=10 # Metro should not take this long to start.
while [ "${TIMEOUT}" -gt 0 ]; do
if ! lsof -i:"${RCT_METRO_PORT:-8081}" &> /dev/null; then
if ! lsof -i:8081 &> /dev/null; then
echo "."
sleep 1
((TIMEOUT--))
+2 -2
View File
@@ -99,9 +99,9 @@
(rf/defn system-theme-mode-changed
{:events [:system-theme-mode-changed]}
[{:keys [db] :as cofx} _]
(let [appearance-type (get-in cofx [:db :profile/profile :appearance])]
(let [current-theme-type (get-in cofx [:db :profile/profile :appearance])]
(when (and (multiaccounts.model/logged-in? db)
(= appearance-type status-im.constants/appearance-type-system))
(= current-theme-type status-im.constants/theme-type-system))
{:dispatch [:theme/switch]})))
(defn- on-biometric-auth-fail
@@ -107,12 +107,11 @@
(assoc network-tag-props
:status
(if error? :error :default))]])
(when fiat-value
[text/text
{:size :paragraph-2
:style style/fiat-amount
:weight :medium}
(str currency-symbol fiat-value)])])
[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?)
@@ -6,20 +6,16 @@
(h/describe "Wallet: Token Input"
(h/test "Token label renders"
(h/render-with-theme-provider [token-input/view
{:token-symbol :snt
:currency-symbol :snt
:on-swap nil
:error? false
:value "1"
:converted-value "10"}])
{:token :snt
:currency :eur
:currency-symbol "€"
:conversion 1}])
(h/is-truthy (h/get-by-text "SNT")))
(h/test "Amount renders"
(h/render-with-theme-provider [token-input/view
{:token-symbol :snt
:currency-symbol :snt
:on-swap nil
:error? false
:value "1"
:converted-value "€0.00"}])
{:token :snt
:currency :eur
:currency-symbol "€"
:conversion 1}])
(h/is-truthy (h/get-by-text "€0.00"))))
@@ -4,14 +4,15 @@
[:=>
[:catn
[:props
[:map {:closed true}
[:token-symbol [:maybe [:or :string :keyword]]]
[:currency-symbol [:maybe [:or :string :keyword]]]
[:hint-component {:optional true} [:maybe :schema.common/hiccup]]
[:on-token-press {:optional true} [:maybe fn?]]
[:on-swap [:maybe fn?]]
[:container-style {:optional true} [:maybe :map]]
[:error? [:maybe :boolean]]
[:value [:maybe :string]]
[:converted-value [:maybe :string]]]]]
[:map
[:token {:optional true} [:maybe [:or :string :keyword]]]
[:currency {:optional true} [:maybe [:or :string :keyword]]]
[:error? {:optional true} [:maybe :boolean]]
[:title {:optional true} [:maybe :string]]
[:conversion {:optional true} [:maybe :double]]
[:show-keyboard? {:optional true} [:maybe :boolean]]
[:networks {:optional true}
[:maybe [:sequential [:map [:source [:maybe :schema.common/image-source]]]]]]
[:customization-color {:optional true} [:maybe :schema.common/customization-color]]
[:value {:optional true} [:maybe :string]]]]]
:any])
@@ -25,11 +25,9 @@
(defn input-container
[window-width]
{:width (- window-width 120)
:margin-left 8
:margin-right 8
:flex-direction :row
:align-items :flex-end})
{:width (- window-width 120)
:margin-left 8
:margin-right 8})
(def text-input-dimensions
(-> typography/heading-1
@@ -67,6 +65,6 @@
:justify-content :space-between
:align-items :center})
(defn converted-amount
(defn fiat-amount
[theme]
{:color (colors/theme-colors colors/neutral-50 colors/neutral-40 theme)})
+123 -53
View File
@@ -1,15 +1,57 @@
(ns quo.components.wallet.token-input.view
(:require
[clojure.string :as string]
[oops.core :as oops]
[quo.components.buttons.button.view :as button]
[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.utilities.token.view :as token]
[quo.components.wallet.token-input.schema :as component-schema]
[quo.components.wallet.token-input.style :as style]
[quo.theme :as quo.theme]
[react-native.core :as rn]
[schema.core :as schema]))
[schema.core :as schema]
[utils.number :as number]))
(defn fiat-format
[currency-symbol num-value conversion]
(str currency-symbol (.toFixed (* num-value conversion) 2)))
(defn crypto-format
[num-value conversion crypto-decimals token]
(str (number/remove-trailing-zeroes
(.toFixed (/ num-value conversion) (or crypto-decimals 2)))
" "
(string/upper-case (or (clj->js token) ""))))
(defn calc-value
[{:keys [crypto? currency-symbol token value conversion crypto-decimals]}]
(let [num-value (if (string? value)
(or (parse-double value) 0)
value)]
(if crypto?
(fiat-format currency-symbol num-value conversion)
(crypto-format num-value conversion crypto-decimals token))))
(defn- data-info
[{:keys [theme token crypto-decimals conversion networks title crypto? currency-symbol amount
error?]}]
[rn/view {:style style/data-container}
[network-tag/view
{:networks networks
:title title
:status (when error? :error)}]
[text/text
{:size :paragraph-2
:weight :medium
:style (style/fiat-amount theme)}
(calc-value {:crypto? crypto?
:currency-symbol currency-symbol
:token token
:value amount
:conversion conversion
:crypto-decimals crypto-decimals})]])
(defn- token-name-text
[theme text]
@@ -20,63 +62,91 @@
(string/upper-case (or (clj->js text) ""))])
(defn input-section
[{:keys [token-symbol on-token-press value error? on-swap currency-symbol]}]
(let [theme (quo.theme/use-theme)
window-width (:width (rn/get-window))]
[rn/pressable
{:style {:width "100%"
:flex-direction :row}
:on-press on-token-press}
[token/view
{:token token-symbol
:size :size-32}]
[rn/view {:style (style/input-container window-width)}
[rn/text-input
{:style (style/text-input theme error?)
:placeholder-text-color (style/placeholder-text theme)
:placeholder "0"
:keyboard-type :numeric
:editable false
:value value}]
[token-name-text theme currency-symbol]]
[button/button
{:icon true
:icon-only? true
:size 32
:on-press #(when on-swap (on-swap))
:type :outline
:accessibility-label :reorder}
:i/reorder]]))
[{:keys [on-change-text value value-internal set-value-internal on-selection-change
on-token-press]}]
(let [input-ref (atom nil)
set-ref #(reset! input-ref %)
focus-input #(when-let [ref ^js @input-ref]
(.focus ref))
controlled-input? (some? value)
handle-on-change-text (fn [v]
(when-not controlled-input?
(set-value-internal v))
(when on-change-text
(on-change-text v)))
handle-selection-change (fn [^js e]
(when on-selection-change
(-> e
(oops/oget "nativeEvent.selection")
(js->clj :keywordize-keys true)
(on-selection-change))))]
(fn [{:keys [token customization-color show-keyboard? crypto? currency value error? selection
handle-on-swap allow-selection?]
:or {show-keyboard? true
allow-selection? true}}]
(let [theme (quo.theme/use-theme)
window-width (:width (rn/get-window))]
[rn/pressable
{:style {:width "100%"
:flex-direction :row}
:on-press on-token-press}
[token/view
{:token token
:size :size-32}]
[rn/view {:style (style/input-container window-width)}
[rn/pressable
{:style style/text-input-container
:on-press focus-input}
[rn/text-input
(cond-> {:style (style/text-input theme error?)
:placeholder-text-color (style/placeholder-text theme)
:auto-focus true
:ref set-ref
:placeholder "0"
:keyboard-type :numeric
:on-change-text handle-on-change-text
:selection-color customization-color
:show-soft-input-on-focus show-keyboard?
:on-selection-change handle-selection-change
:selection (clj->js selection)
:editable allow-selection?}
controlled-input? (assoc :value value)
(not controlled-input?) (assoc :default-value value-internal))]
[token-name-text theme (if crypto? token currency)]]]
[button/button
{:icon true
:icon-only? true
:size 32
:on-press handle-on-swap
:type :outline
:accessibility-label :reorder}
:i/reorder]]))))
(defn- view-internal
[{:keys [token-symbol
value
on-token-press
error?
container-style
on-swap
converted-value
hint-component
currency-symbol]}]
(let [theme (quo.theme/use-theme)
width (:width (rn/get-window))]
[{:keys [container-style value on-swap] :as props}]
(let [theme (quo.theme/use-theme)
width (:width (rn/get-window))
[value-internal set-value-internal] (rn/use-state nil)
[crypto? set-crypto] (rn/use-state true)
handle-on-swap (rn/use-callback
(fn []
(set-crypto (not crypto?))
(when on-swap (on-swap (not crypto?))))
[crypto? on-swap])]
[rn/view {:style (merge (style/main-container width) container-style)}
[rn/view {:style style/amount-container}
[input-section
{:theme theme
:token-symbol token-symbol
:on-token-press on-token-press
:value value
:error? error?
:on-swap on-swap
:currency-symbol currency-symbol}]]
(assoc props
:value-internal value-internal
:theme theme
:set-value-internal set-value-internal
:handle-on-swap handle-on-swap
:crypto? crypto?)]]
[divider-line/view {:container-style (style/divider theme)}]
[rn/view {:style style/data-container}
hint-component
[text/text
{:size :paragraph-2
:weight :medium
:style (style/converted-amount theme)}
converted-value]]]))
[data-info
(assoc props
:theme theme
:crypto? crypto?
:amount (or value value-internal))]]))
(def view (schema/instrument #'view-internal component-schema/?schema))
+2 -4
View File
@@ -19,10 +19,8 @@
:text-color (colors/resolve-color :danger theme)}})
(defn- banner
[{:keys [text type second-banner? colors-map on-press]}]
[rn/pressable
{:on-press #(when on-press (on-press))
:style (when second-banner? style/second-banner-wrapper)}
[{:keys [text type second-banner? colors-map]}]
[rn/view (when second-banner? {:style style/second-banner-wrapper})
[hole-view/hole-view
{:style (style/hole-view (get-in colors-map [type :background-color]))
:holes (if second-banner?
+2 -3
View File
@@ -126,8 +126,7 @@
[reanimated/view
{:style (reanimated/apply-animations-to-style
{:opacity bg-opacity}
{:flex 1
:background-color (if shell? colors/neutral-100-opa-60 colors/neutral-100-opa-70)})}]]
{:flex 1 :background-color colors/neutral-100-opa-70})}]]
;; sheet
[gesture/gesture-detector {:gesture sheet-gesture}
[reanimated/view
@@ -139,7 +138,7 @@
[quo/blur
{:style style/shell-bg
:blur-radius (or blur-radius 20)
:blur-amount 15
:blur-amount 32
:blur-type :transparent
:overlay-color :transparent}]])
(when selected-item
@@ -1,8 +1,6 @@
(ns status-im.common.controlled-input.utils
(:require
[clojure.string :as string]
[status-im.contexts.wallet.common.utils :as wallet-utils]
[utils.money :as money]))
[clojure.string :as string]))
(def init-state
{:value ""
@@ -16,7 +14,7 @@
(defn numeric-value
[state]
(money/bignumber (input-value state)))
(or (parse-double (input-value state)) 0))
(defn input-error
[state]
@@ -28,29 +26,23 @@
(defn upper-limit
[state]
(money/bignumber (:upper-limit state)))
(:upper-limit state))
(defn lower-limit
[state]
(money/bignumber (:lower-limit state)))
(:lower-limit state))
(defn upper-limit-exceeded?
[state]
(let [num-value (numeric-value state)]
(and
(upper-limit state)
(if (money/bignumber? num-value)
(money/greater-than (numeric-value state) (upper-limit state))
false))))
(and
(upper-limit state)
(> (numeric-value state) (upper-limit state))))
(defn- lower-limit-exceeded?
(defn lower-limit-exceeded?
[state]
(let [num-value (numeric-value state)]
(and
(lower-limit state)
(if (money/bignumber? num-value)
(money/less-than (numeric-value state) (lower-limit state))
false))))
(and
(lower-limit state)
(< (numeric-value state) (lower-limit state))))
(defn- recheck-errorness
[state]
@@ -83,11 +75,13 @@
(defn increase
[state]
(set-input-value state (str (money/add (numeric-value state) 1))))
(let [new-val (inc (numeric-value state))]
(set-input-value state (str new-val))))
(defn decrease
[state]
(set-input-value state (str (money/add (numeric-value state) -1))))
(let [new-val (dec (numeric-value state))]
(set-input-value state (str new-val))))
(def ^:private not-digits-or-dot-pattern
#"[^0-9+\.]")
@@ -136,29 +130,3 @@
(defn empty-value?
[state]
(string/blank? (:value state)))
(defn- fiat->crypto
[value conversion-rate]
(-> value
(money/fiat->crypto conversion-rate)
(wallet-utils/cut-crypto-decimals-to-fit-usd-cents conversion-rate)))
(defn- crypto->fiat
[value conversion-rate]
(-> value
(money/crypto->fiat conversion-rate)
(wallet-utils/cut-fiat-balance-to-two-decimals)))
(defn ->crypto
[state conversion-rate]
(-> state
(set-input-value (fiat->crypto (input-value state) conversion-rate))
(set-upper-limit (fiat->crypto (upper-limit state) conversion-rate))
(set-lower-limit (fiat->crypto (lower-limit state) conversion-rate))))
(defn ->fiat
[state conversion-rate]
(-> state
(set-input-value (crypto->fiat (input-value state) conversion-rate))
(set-upper-limit (crypto->fiat (upper-limit state) conversion-rate))
(set-lower-limit (crypto->fiat (lower-limit state) conversion-rate))))
@@ -3,14 +3,14 @@
[quo.core :as quo]
[react-native.core :as rn]
[status-im.common.data-confirmation-sheet.style :as style]
[status-im.common.events-helper :as events-helper]
[utils.i18n :as i18n]
[utils.navigation :as navigation]
[utils.re-frame :as rf]))
(defn on-choice-callback
[syncing-on-mobile-network?]
(rf/dispatch [:network/set-syncing-on-mobile-network syncing-on-mobile-network?])
(events-helper/hide-bottom-sheet))
(navigation/hide-bottom-sheet))
(def on-wifi-only (partial on-choice-callback false))
(def on-mobile-and-wifi (partial on-choice-callback true))
@@ -19,7 +19,7 @@
[]
(let [settings-drawer? (= (rf/sub [:view-id]) :screen/settings.syncing)
syncing-on-mobile-network? (rf/sub [:profile/syncing-on-mobile-network?])]
(rn/use-mount events-helper/dismiss-keyboard)
(rn/use-mount navigation/dismiss-keyboard)
[:<>
[quo/text
{:weight :semi-bold
@@ -21,7 +21,7 @@
:padding-bottom 2}}
[quo/tag
{:accessibility-label :communities-chat-beta-tag
:size 24
:size 32
:type :label
:label (i18n/label :t/beta)
:labelled? true
+9 -28
View File
@@ -2,42 +2,23 @@
(:require
[re-frame.core :as re-frame]
[status-im.common.theme.core :as theme]
[status-im.constants :as constants]))
[status-im.common.theme.utils :as utils]))
(re-frame/reg-fx
:theme/init-theme
(fn []
(theme/add-device-theme-change-listener)))
(defn- appearance-type->theme
"Converts appearance type identifier to a theme keyword.
Returns `:light` or `:dark` based on `appearance-type`:
- `appearance-type-light` (1): Light theme.
- `appearance-type-dark` (2): Dark theme.
- `appearance-type-system` (0): Uses system preference."
[appearance-type]
(condp = appearance-type
constants/appearance-type-dark :dark
constants/appearance-type-light :light
constants/appearance-type-system (if (theme/device-theme-dark?) :dark :light)
:dark))
;; Switches the theme and triggers related effects.
;;
;; Parameters:
;; - `theme`: Optional theme keyword to apply. If not provided, defaults to the theme determined by
;; `appearance-type`.
;; - `appearance-type`: Optional appearance type to determine the theme. If not provided, defaults to
;; the appearance type from the user's profile.
;; - `view-id`: Optional view ID for updating status and navigation color. If not provided, uses the
;; current view ID from the database. `view-id` is required because status and navigation bar colors
;; depends on the screen. For example, on the home screen, the navigation color should always be dark,
;; regardless of the theme, due to the bottom tabs.
(re-frame/reg-event-fx
:theme/switch
(fn [{db :db} [{:keys [theme view-id appearance-type]}]]
(let [appearance-type (or appearance-type (get-in db [:profile/profile :appearance]))
theme (or theme (appearance-type->theme appearance-type))]
(fn [{db :db} [{:keys [theme view-id theme-type]}]]
"Switches the theme and triggers related effects.
Parameters:
- theme: Optional theme keyword to apply. If not provided, defaults to the theme determined by theme-type.
- theme-type: Optional theme type to determine the theme. If not provided, defaults to the theme type from the user's profile.
- view-id: Optional view ID for updating status color. If not provided, uses the current view ID from the database."
(let [theme-type (or theme-type (get-in db [:profile/profile :appearance]))
theme (or theme (utils/theme-type->theme-value theme-type))]
{:db (assoc db :theme theme)
:fx [[:theme/legacy-theme-fx theme]
[:dispatch
+17
View File
@@ -0,0 +1,17 @@
(ns status-im.common.theme.utils
(:require
[status-im.common.theme.core :as theme]
[status-im.constants :as constants]))
(defn theme-type->theme-value
"Converts theme type identifier to a theme keyword.
Returns `:light` or `:dark` based on `theme-type`:
- `theme-type-light` (1): Light theme.
- `theme-type-dark` (2): Dark theme.
- `theme-type-system` (0): Uses system preference."
[theme-type]
(condp = theme-type
constants/theme-type-dark :dark
constants/theme-type-light :light
constants/theme-type-system (if (theme/device-theme-dark?) :dark :light)
:dark))
+2
View File
@@ -123,6 +123,8 @@
:waku.test
["enrtree://AOGYWMBYOUIMOENHXCHILPKY3ZRFEULMFI4DOM442QSZ73TT2A7VI@test.waku.nodes.status.im"]})
(def default-kdf-iterations 3200)
(def community-accounts-selection-enabled? true)
(def fetch-messages-enabled? (enabled? (get-config :FETCH_MESSAGES_ENABLED "1")))
(def test-networks-enabled? (enabled? (get-config :TEST_NETWORKS_ENABLED "0")))
+3 -3
View File
@@ -425,9 +425,9 @@
"We prefix our keys with 0xe701 prior to serialisation them"
"0xe701")
(def ^:const appearance-type-system 0)
(def ^:const appearance-type-light 1)
(def ^:const appearance-type-dark 2)
(def ^:const theme-type-system 0)
(def ^:const theme-type-light 1)
(def ^:const theme-type-dark 2)
(def ^:const bottom-sheet-animation-delay 450)
(def ^:const local-pair-event-process-success "process-success")
@@ -7,15 +7,19 @@
:justify-content :flex-end})
(def text-container
{:flex 1
:flex-direction :row
:flex-wrap :wrap
:align-self :center})
{:flex-direction :row
:flex-wrap :wrap})
(def text-aligner
{:flex 1
:flex-direction :row
:justify-content :center})
(def terms-privacy-container
{:gap 8
{:flex-direction :row
:padding-horizontal 20
:padding-vertical 8})
:padding-vertical 8
:gap 8})
(def plain-text
{:color colors/white-opa-70})
@@ -21,8 +21,7 @@
:actions :two-vertical-actions
:description :top
:description-top-text [rn/view
{:style style/terms-privacy-container
:flex-direction :row}
{:style style/terms-privacy-container}
[rn/view
{:accessibility-label :terms-privacy-checkbox-container}
[quo/selectors
@@ -30,7 +29,7 @@
:blur? true
:checked? terms-accepted?
:on-change #(set-terms-accepted? not)}]]
[rn/view {:style {:flex 1}}
[rn/view {:style style/text-aligner}
[rn/view {:style style/text-container}
[quo/text
{:style style/plain-text
@@ -47,7 +46,7 @@
[quo/text
{:style style/plain-text
:size :paragraph-2}
" & "]
" " (i18n/label :t/and) " "]
[quo/text
{:on-press #(rf/dispatch [:show-bottom-sheet
{:content privacy/privacy-statement
@@ -2,10 +2,12 @@
(:require
[quo.core :as quo]
[quo.foundations.colors :as colors]
[re-frame.core :as re-frame]
[react-native.core :as rn]
[react-native.linear-gradient :as linear-gradient]
[react-native.safe-area :as safe-area]
[status-im.common.resources :as resources]
[status-im.constants :as constants]
[status-im.contexts.onboarding.welcome.style :as style]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))
@@ -22,12 +24,20 @@
:description (i18n/label :t/welcome-to-web3-sub-title)
:description-accessibility-label :welcome-sub-title}]))
(defn dispatch-visibility-status-update
[status-type]
(re-frame/dispatch
[:visibility-status-updates/delayed-visibility-status-update status-type]))
(defn view
[]
(let [profile-color (rf/sub [:onboarding/customization-color])
window (rf/sub [:dimensions/window])
insets (safe-area/get-insets)]
(let [profile-color (rf/sub [:onboarding/customization-color])
{:keys [status-type]} (rf/sub [:multiaccount/current-user-visibility-status])
window (rf/sub [:dimensions/window])
insets (safe-area/get-insets)]
[rn/view {:style (style/page-container insets)}
(when (nil? status-type)
(dispatch-visibility-status-update constants/visibility-status-automatic))
[quo/page-nav
{:type :no-title
:background :blur
@@ -2,13 +2,9 @@
(:require
[quo.core :as quo]
[quo.foundations.resources :as resources]
[react-native.core :as rn]
[react-native.safe-area :as safe-area]
[reagent.core :as reagent]
[status-im.common.controlled-input.utils :as controlled-input]
[status-im.contexts.preview.quo.preview :as preview]
[status-im.contexts.wallet.common.utils :as utils]
[utils.money :as money]))
[status-im.contexts.preview.quo.preview :as preview]))
(def networks
[{:source (resources/get-network :arbitrum)}
@@ -16,75 +12,47 @@
{:source (resources/get-network :ethereum)}])
(def title "Max: 200 SNT")
(def conversion-rate 3450.28)
(def descriptor
[{:key :token-symbol
[{:key :token
:type :select
:options [{:key :eth}
{:key :snt}]}
{:key :currency
:type :select
:options [{:key "$"}
{:key "€"}]}
:options [{:key :usd}
{:key :eur}]}
{:key :error?
:type :boolean}
{:key :allow-selection?
:type :boolean}])
(defn view
[]
(let [state (reagent/atom {:token-symbol :eth
:currency "$"
:crypto? true
:error? false})]
(let [state (reagent/atom {:token :eth
:currency :usd
:conversion 0.02
:networks networks
:title title
:customization-color :blue
:show-keyboard? false
:allow-selection? true})
value (reagent/atom "")
set-value (fn [v]
(swap! value str v))
delete (fn [_]
(swap! value #(subs % 0 (dec (count %)))))]
(fn []
(let [{:keys [currency token-symbol crypto? error?]} @state
[input-state set-input-state] (rn/use-state controlled-input/init-state)
input-amount (controlled-input/input-value input-state)
swap-between-fiat-and-crypto (fn []
(if crypto?
(set-input-state #(controlled-input/->fiat
%
conversion-rate))
(set-input-state
#(controlled-input/->crypto
%
conversion-rate))))
converted-value (if crypto?
(utils/prettify-balance currency
(money/crypto->fiat
input-amount
conversion-rate))
(utils/prettify-crypto-balance
(or (clj->js token-symbol) "")
(money/fiat->crypto input-amount
conversion-rate)
conversion-rate))]
[preview/preview-container
{:state state
:descriptor descriptor
:full-screen? true
:component-container-style {:flex 1
:justify-content :space-between}}
[quo/token-input
{:token-symbol token-symbol
:currency-symbol (if crypto? token-symbol currency)
:error? error?
:value input-amount
:converted-value converted-value
:on-swap (fn []
(swap! state assoc :crypto? (not crypto?))
(swap-between-fiat-and-crypto))
:hint-component [quo/network-tags
{:networks networks
:title title
:status (when (:error? @state) :error)}]}]
[quo/numbered-keyboard
{:container-style {:padding-bottom (safe-area/get-top)}
:left-action :dot
:delete-key? true
:on-press (fn [c]
(set-input-state #(controlled-input/add-character % c)))
:on-delete (fn []
(set-input-state controlled-input/delete-last))}]]))))
[preview/preview-container
{:state state
:descriptor descriptor
:full-screen? true
:component-container-style {:flex 1
:justify-content :space-between}}
[quo/token-input (assoc @state :value @value)]
[quo/numbered-keyboard
{:container-style {:padding-bottom (safe-area/get-top)}
:left-action :dot
:delete-key? true
:on-press set-value
:on-delete delete}]])))
@@ -251,6 +251,5 @@
config/enable-alert-banner?)
{:fx [[:dispatch
[:alert-banners/add
{:type :alert
:text (i18n/label :t/testnet-mode-enabled)
:on-press #(rf/dispatch [:wallet/show-disable-testnet-mode-confirmation])}]]]})))
{:type :alert
:text (i18n/label :t/testnet-mode-enabled)}]]]})))
@@ -95,7 +95,7 @@
(rf/reg-event-fx :profile.settings/change-appearance
(fn [_ [theme]]
{:fx [[:dispatch [:profile.settings/profile-update :appearance theme]]
[:dispatch [:theme/switch {:appearance-type theme}]]]}))
[:dispatch [:theme/switch {:theme-type theme}]]]}))
(rf/reg-fx :profile.settings/get-profile-picture
(fn [key-uid]
@@ -2,8 +2,8 @@
(:require
[quo.core :as quo]
[react-native.core :as rn]
[status-im.common.events-helper :as events-helper]
[utils.i18n :as i18n]
[utils.navigation :as navigation]
[utils.re-frame :as rf]))
(defn- open-blocked-users
@@ -21,7 +21,7 @@
[quo/page-nav
{:background :blur
:icon-name :i/arrow-left
:on-press events-helper/navigate-back}]
:on-press navigation/navigate-back}]
[quo/page-top {:title (i18n/label :t/messages)}]
[quo/category
{:label (i18n/label :t/contacts)
@@ -2,8 +2,8 @@
(:require
[quo.core :as quo]
[status-im.common.data-confirmation-sheet.view :as data-confirmation-sheet]
[status-im.common.events-helper :as events-helper]
[utils.i18n :as i18n]
[utils.navigation :as navigation]
[utils.re-frame :as rf]))
(defn- open-paired-devices-list
@@ -26,7 +26,7 @@
[quo/page-nav
{:background :blur
:icon-name :i/arrow-left
:on-press events-helper/navigate-back}]
:on-press navigation/navigate-back}]
[quo/page-top {:title (i18n/label :t/syncing)}]
[quo/category
{:data [{:title (i18n/label :t/sync-and-backup)
@@ -5,12 +5,12 @@
[react-native.core :as rn]
[react-native.platform :as platform]
[react-native.safe-area :as safe-area]
[status-im.common.events-helper :as events-helper]
[status-im.common.metrics-confirmation-modal.view :as metrics-modal]
[status-im.contexts.settings.privacy-and-security.profile-picture.view :as profile-picture.view]
[status-im.contexts.settings.privacy-and-security.style :as style]
[status-im.feature-flags :as ff]
[utils.i18n :as i18n]
[utils.navigation :as navigation]
[utils.re-frame :as rf]))
(defn- setting-preview-privacy
@@ -78,7 +78,7 @@
{:key :header
:background :blur
:icon-name :i/arrow-left
:on-press events-helper/navigate-back}]
:on-press navigation/navigate-back}]
[quo/standard-title
{:title (i18n/label :t/privacy-and-security)
:container-style style/title-container
@@ -2,9 +2,7 @@
(:require
[clojure.string :as string]
[native-module.core :as native-module]
[react-native.platform :as platform]
[status-im.contexts.settings.wallet.data-store :as data-store]
[status-im.contexts.settings.wallet.network-settings.testnet-mode.view :as testnet]
[taoensso.timbre :as log]
[utils.i18n :as i18n]
[utils.re-frame :as rf]
@@ -294,15 +292,3 @@
(rf/reg-event-fx :wallet/make-partially-operable-accounts-fully-operable
make-partially-operable-accounts-fully-operable)
(rf/reg-event-fx :wallet/show-disable-testnet-mode-confirmation
(fn [{:keys [db]} _]
(let [theme (:theme db)
blur? (and (not platform/android?) (= theme :dark))]
{:fx [[:dispatch
[:show-bottom-sheet
{:content (fn [] [testnet/view
{:enable? false
:blur? blur?}])
:shell? blur?
:theme (when-not platform/android? theme)}]]]})))
+39 -10
View File
@@ -3,8 +3,8 @@
[clojure.string :as string]
[native-module.core :as native-module]
[react-native.platform :as platform]
[status-im.config :as config]
[status-im.constants :as constants]
[status-im.contexts.profile.config :as profile.config]
[status-im.contexts.syncing.utils :as sync-utils]
[taoensso.timbre :as log]
[utils.i18n :as i18n]
@@ -21,6 +21,26 @@
{:events [:syncing/clear-states]}
[{:keys [db]} role]
{:db (dissoc db :syncing)})
(defn- get-default-node-config
[]
(let [log-level config/log-level
log-config (if (empty? log-level)
{:LogLevel "ERROR" :LogEnabled false}
{:LogLevel log-level :LogEnabled true})]
(merge {:WalletConfig (cond-> {:Enabled true}
(not= config/opensea-api-key "")
(assoc :OpenseaAPIKey config/opensea-api-key))
:WakuV2Config {;; Temporary fix until https://github.com/status-im/status-go/issues/3024
;; is resolved
:Nameserver "8.8.8.8"
:LightClient true}
:ShhextConfig {:VerifyTransactionURL config/verify-transaction-url
:VerifyENSURL config/verify-ens-url
:VerifyENSContractAddress config/verify-ens-contract-address
:VerifyTransactionChainID config/verify-transaction-chain-id}}
log-config)))
(defn- input-connection-string-callback
[res]
(log/info "[local-pairing] input-connection-string-for-bootstrapping callback"
@@ -49,15 +69,24 @@
(rf/defn initiate-local-pairing-with-connection-string
{:events [:syncing/input-connection-string-for-bootstrapping]}
[{:keys [db]} connection-string]
(let [config-map (.stringify js/JSON
(clj->js
{:receiverConfig
{:createAccount (profile.config/create)}}))]
(rf/dispatch [:syncing/update-role constants/local-pairing-role-receiver])
(native-module/input-connection-string-for-bootstrapping
connection-string
config-map
input-connection-string-callback)))
(let [default-node-config-string (.stringify js/JSON (clj->js (get-default-node-config)))
callback
(fn [final-node-config]
(let [config-map (.stringify js/JSON
(clj->js
{:receiverConfig
{:kdfIterations config/default-kdf-iterations
:nodeConfig final-node-config
:settingCurrentNetwork config/default-network
:deviceType platform/os
:deviceName
(native-module/get-installation-name)}}))]
(rf/dispatch [:syncing/update-role constants/local-pairing-role-receiver])
(native-module/input-connection-string-for-bootstrapping
connection-string
config-map
input-connection-string-callback)))]
(native-module/prepare-dir-and-update-config "" default-node-config-string callback)))
(rf/defn preparations-for-connection-string
{:events [:syncing/get-connection-string]}
+36 -58
View File
@@ -12,17 +12,14 @@
[full-name]
(first (string/split full-name #" ")))
(defn cut-fiat-balance-to-two-decimals
[balance]
(defn prettify-balance
[currency-symbol balance]
(let [valid-balance? (and balance
(or (number? balance) (.-toFixed balance)))]
(as-> balance $
(if valid-balance? $ 0)
(.toFixed $ 2))))
(defn prettify-balance
[currency-symbol balance]
(str currency-symbol (cut-fiat-balance-to-two-decimals balance)))
(.toFixed $ 2)
(str currency-symbol $))))
(defn get-derivation-path
[number-of-accounts]
@@ -50,8 +47,8 @@
nil))
(defn calc-max-crypto-decimals
[one-cent-value]
(let [str-representation (str one-cent-value)
[value]
(let [str-representation (str value)
decimal-part (second (clojure.string/split str-representation #"\."))
exponent (extract-exponent str-representation)
zeroes-count (count (take-while #(= \0 %) decimal-part))
@@ -61,60 +58,29 @@
(inc max-decimals)
max-decimals)))
(defn token-usd-price
[token]
(get-in token [:market-values-per-currency :usd :price]))
(defn one-cent-value
[token-price-in-usd]
(if (pos? token-price-in-usd)
(/ 0.01 token-price-in-usd)
0))
(defn analyze-token-amount-for-price
"For full details: https://github.com/status-im/status-mobile/issues/18225"
[token-price-in-usd token-units]
(if (or (nil? token-units)
(not (money/bignumber? token-units))
(money/equal-to token-units 0))
{:zero-value? true}
(let [cent-value (one-cent-value token-price-in-usd)]
{:usd-cent-value cent-value
:standardized-decimals-count (if (nil? token-price-in-usd)
missing-price-decimals
(calc-max-crypto-decimals cent-value))})))
(defn cut-crypto-decimals-to-fit-usd-cents
[token-units token-price-in-usd]
(let [{:keys [zero-value? usd-cent-value standardized-decimals-count]}
(analyze-token-amount-for-price token-price-in-usd token-units)]
(cond
zero-value? "0"
(< token-units usd-cent-value) "0"
:else (number/remove-trailing-zeroes
(.toFixed token-units standardized-decimals-count)))))
(defn prettify-crypto-balance
[token-symbol crypto-balance conversion-rate]
(str (cut-crypto-decimals-to-fit-usd-cents crypto-balance conversion-rate)
" "
(string/upper-case token-symbol)))
(defn get-crypto-decimals-count
[{:keys [market-values-per-currency]}]
(let [price (get-in market-values-per-currency [:usd :price])
one-cent-value (if (pos? price) (/ 0.01 price) 0)]
(calc-max-crypto-decimals one-cent-value)))
(defn get-standard-crypto-format
"For full details: https://github.com/status-im/status-mobile/issues/18225"
[token token-units]
(let [token-price-in-usd (token-usd-price token)
{:keys [zero-value? usd-cent-value standardized-decimals-count]}
(analyze-token-amount-for-price token-price-in-usd token-units)]
(cond
zero-value?
"0"
[{:keys [market-values-per-currency]} token-units]
(cond (or (nil? token-units)
(money/equal-to token-units 0))
"0"
(< token-units usd-cent-value)
(str "<" (number/remove-trailing-zeroes (.toFixed usd-cent-value standardized-decimals-count)))
(nil? (-> market-values-per-currency :usd :price))
(number/remove-trailing-zeroes (.toFixed token-units missing-price-decimals))
:else
(number/remove-trailing-zeroes (.toFixed token-units standardized-decimals-count)))))
:else
(let [price (-> market-values-per-currency :usd :price)
one-cent-value (if (pos? price) (/ 0.01 price) 0)
decimals-count (calc-max-crypto-decimals one-cent-value)]
(if (< token-units one-cent-value)
(str "<" (number/remove-trailing-zeroes (.toFixed one-cent-value decimals-count)))
(number/remove-trailing-zeroes (.toFixed token-units decimals-count))))))
(defn get-market-value
[currency {:keys [market-values-per-currency]}]
@@ -320,6 +286,18 @@
(let [counter (count address)]
(str (subs address 0 6) "\u2026" (subs address (- counter 3) counter)))))
(defn make-limit-label-crypto
[amount currency]
(str amount
" "
(some-> currency
name
string/upper-case)))
(defn make-limit-label-fiat
[amount currency-symbol]
(str currency-symbol amount))
(defn get-account-name-error
[s existing-account-names]
(cond
@@ -73,12 +73,7 @@
token-units (money/bignumber 0.01)]
(is (= (utils/get-standard-crypto-format {:market-values-per-currency market-values-per-currency}
token-units)
"<2")))
(let [market-values-per-currency {:usd {:price 0.005}}
token-units "0.01"]
(is (= (utils/get-standard-crypto-format {:market-values-per-currency market-values-per-currency}
token-units)
"0")))))
"<2")))))
(deftest calculate-total-token-balance-test
(testing "calculate-total-token-balance function"
@@ -168,3 +163,5 @@
expected-order ["DAI" "ETH" "SNT"]]
(is (= expected-order sorted-tokens)))))
@@ -731,8 +731,8 @@
:route route
:token-address token-address
:token-id (if collectible
(money/to-hex
(js/parseInt token-id))
(utils.hex/number-to-hex
token-id)
token-id)
:data data
:eth-transfer? eth-transfer?})]
@@ -110,23 +110,22 @@
(h/setup-subs sub-mocks)
(h/render-with-theme-provider [input-amount/view
{:crypto-decimals 2
:limit-crypto (money/bignumber 250)
:limit-crypto 250
:initial-crypto-currency? false}])
(h/is-truthy (h/get-by-text "0"))
(h/is-truthy (h/get-by-text "USD"))
(h/is-truthy (h/get-by-text "0 ETH"))
(h/is-truthy (h/get-by-text "ETH"))
(h/is-truthy (h/get-by-text "$0.00"))
(h/is-truthy (h/get-by-label-text :container))
(h/is-disabled (h/get-by-label-text :button-one)))
(h/test "Fill token input and confirm"
(h/setup-subs sub-mocks)
(let [on-confirm (h/mock-fn)]
(h/render-with-theme-provider [input-amount/view
{:crypto-decimals 10
:limit-crypto (money/bignumber 1000)
:on-confirm on-confirm
:initial-crypto-currency? true}])
{:on-confirm on-confirm
:crypto-decimals 10
:limit-crypto 1000
:initial-crypto-currency? false}])
(h/fire-event :press (h/query-by-label-text :keyboard-key-1))
(h/fire-event :press (h/query-by-label-text :keyboard-key-2))
@@ -135,19 +134,42 @@
(h/fire-event :press (h/query-by-label-text :keyboard-key-4))
(h/fire-event :press (h/query-by-label-text :keyboard-key-5))
(-> (h/wait-for #(h/get-by-text "$1234.50"))
(.then (fn []
(h/is-truthy (h/get-by-label-text :button-one))
(h/is-truthy (h/get-by-label-text :container))
(h/fire-event :press (h/get-by-label-text :button-one))
(h/was-called on-confirm))))))
(h/test "Fill token input and confirm"
(h/setup-subs sub-mocks)
(let [on-confirm (h/mock-fn)]
(h/render-with-theme-provider [input-amount/view
{:crypto-decimals 10
:limit-crypto 1000
:on-confirm on-confirm
:initial-crypto-currency? false}])
(h/fire-event :press (h/query-by-label-text :keyboard-key-1))
(h/fire-event :press (h/query-by-label-text :keyboard-key-2))
(h/fire-event :press (h/query-by-label-text :keyboard-key-3))
(h/fire-event :press (h/query-by-label-text :keyboard-key-.))
(h/fire-event :press (h/query-by-label-text :keyboard-key-4))
(h/fire-event :press (h/query-by-label-text :keyboard-key-5))
(-> (h/wait-for #(h/get-by-text "$1234.50"))
(.then (fn []
(let [btn (h/get-by-label-text :button-one)]
(h/is-truthy btn)
(h/fire-event :press btn)
(h/was-called on-confirm)))))))
(h/is-truthy (h/get-by-label-text :button-one))
(h/is-truthy (h/get-by-label-text :container))
(h/fire-event :press (h/get-by-label-text :button-one))
(h/was-called on-confirm))))))
(h/test "Try to fill more than limit"
(h/setup-subs sub-mocks)
(h/render-with-theme-provider [input-amount/view
{:crypto-decimals 1
:limit-crypto (money/bignumber 1)}])
:limit-crypto 1}])
(h/fire-event :press (h/query-by-label-text :keyboard-key-2))
(h/fire-event :press (h/query-by-label-text :keyboard-key-9))
@@ -159,12 +181,13 @@
(h/setup-subs sub-mocks)
(h/render-with-theme-provider [input-amount/view
{:crypto-decimals 1
:limit-crypto (money/bignumber 10)
:limit-crypto 1
:on-confirm #()}])
(h/fire-event :press (h/query-by-label-text :keyboard-key-9))
(h/fire-event :press (h/query-by-label-text :keyboard-key-9))
(h/is-truthy (h/get-by-label-text :container-error))
(h/fire-event :press (h/query-by-label-text :reorder))
(h/is-truthy #(h/get-by-text "Max: $100.00"))))
(-> (h/wait-for #(h/get-by-text "Max: $1000.00"))
(.then (fn []
(h/wait-for #(h/is-truthy (h/get-by-label-text :container))))))))
@@ -153,8 +153,9 @@
bottom (safe-area/get-bottom)
[crypto-currency? set-crypto-currency] (rn/use-state initial-crypto-currency?)
on-navigate-back on-navigate-back
[input-state set-input-state] (rn/use-state controlled-input/init-state)
[just-toggled-mode? set-just-toggled-mode?] (rn/use-state false)
clear-input! #(set-input-state controlled-input/delete-all)
handle-on-confirm (fn [amount]
(rf/dispatch [:wallet/set-token-amount-to-send
{:amount amount
@@ -166,39 +167,59 @@
:as
token} (rf/sub [:wallet/wallet-send-token])
send-from-locked-amounts (rf/sub [:wallet/wallet-send-from-locked-amounts])
{token-balance :total-balance
:as token-by-symbol} (rf/sub [:wallet/token-by-symbol
{token-balance :total-balance
available-balance :available-balance
:as token-by-symbol} (rf/sub [:wallet/token-by-symbol
(str token-symbol)
enabled-from-chain-ids])
currency-symbol (rf/sub [:profile/currency-symbol])
currency (rf/sub [:profile/currency])
conversion-rate (-> token
:market-values-per-currency
currency
:price)
[input-state set-input-state] (rn/use-state
(-> controlled-input/init-state
(controlled-input/set-upper-limit
(utils/cut-crypto-decimals-to-fit-usd-cents
(or default-limit-crypto token-balance)
conversion-rate))))
clear-input! #(set-input-state controlled-input/delete-all)
currency-symbol (rf/sub [:profile/currency-symbol])
loading-routes? (rf/sub
[:wallet/wallet-send-loading-suggested-routes?])
route (rf/sub [:wallet/wallet-send-route])
on-confirm (or default-on-confirm handle-on-confirm)
crypto-decimals (or token-decimals default-crypto-decimals)
input-value (controlled-input/input-value input-state)
valid-input? (not (or (controlled-input/empty-value? input-state)
(controlled-input/input-error input-state)))
current-crypto-limit (or default-limit-crypto
(utils/get-standard-crypto-format
token
token-balance))
available-crypto-limit (or default-limit-crypto
(utils/get-standard-crypto-format
token
available-balance))
current-fiat-limit (.toFixed (* token-balance conversion-rate) 2)
available-fiat-limit (.toFixed (* available-balance conversion-rate) 2)
current-limit (if crypto-currency?
current-crypto-limit
current-fiat-limit)
available-limit (if crypto-currency?
available-crypto-limit
available-fiat-limit)
valid-input? (not (or (string/blank?
(controlled-input/input-value
input-state))
(<= (controlled-input/numeric-value
input-state)
0)
(> (controlled-input/numeric-value
input-state)
available-limit)))
input-num-value (controlled-input/numeric-value input-state)
input-amount (controlled-input/input-value input-state)
confirm-disabled? (or (nil? route)
(empty? route)
(not valid-input?))
(string/blank? (controlled-input/input-value
input-state))
(<= input-num-value 0)
(> input-num-value current-limit))
amount-in-crypto (if crypto-currency?
input-value
input-amount
(number/remove-trailing-zeroes
(.toFixed (/ input-value conversion-rate)
(.toFixed (/ input-amount conversion-rate)
crypto-decimals)))
total-amount-receiver (rf/sub [:wallet/total-amount true])
amount-text (str (number/remove-trailing-zeroes
@@ -210,9 +231,11 @@
native-currency-symbol (when-not confirm-disabled?
(get-in first-route
[:from :native-currency-symbol]))
fee-formatted (when native-currency-symbol
(rf/sub [:wallet/wallet-send-fee-fiat-formatted
native-token (when native-currency-symbol
(rf/sub [:wallet/token-by-symbol
native-currency-symbol]))
fee-formatted (rf/sub [:wallet/wallet-send-fee-fiat-formatted
native-token])
show-select-asset-sheet #(rf/dispatch
[:show-bottom-sheet
{:content (fn []
@@ -246,7 +269,8 @@
receiver-selected-network))
receiver-networks))
input-error (controlled-input/input-error input-state)
limit-insufficient? (controlled-input/upper-limit-exceeded? input-state)
limit-insufficient? (> (controlled-input/numeric-value input-state)
current-limit)
should-try-again? (and (not limit-insufficient?) no-routes-found?)
current-address (rf/sub [:wallet/current-viewing-account-address])
owned-eth-token (rf/sub [:wallet/token-by-symbol
@@ -259,9 +283,7 @@
(if (= token-symbol
(string/upper-case
constants/mainnet-short-name))
(money/equal-to
(controlled-input/numeric-value input-state)
(controlled-input/upper-limit input-state))
(= current-limit input-amount)
(money/equal-to (:total-balance
owned-eth-token)
0)))
@@ -275,20 +297,34 @@
:valid-input? valid-input?
:bounce-duration-ms bounce-duration-ms
:token token}))
swap-between-fiat-and-crypto (fn []
swap-between-fiat-and-crypto (fn [swap-to-crypto-currency?]
(set-just-toggled-mode? true)
(if crypto-currency?
(set-input-state
#(controlled-input/->fiat % conversion-rate))
(set-input-state
#(controlled-input/->crypto % conversion-rate)))
(set-crypto-currency (not crypto-currency?)))]
(set-crypto-currency swap-to-crypto-currency?)
(set-input-state
(fn [input-state]
(controlled-input/set-input-value
input-state
(let [value (controlled-input/input-value
input-state)
new-value (if swap-to-crypto-currency?
(.toFixed (/ value
conversion-rate)
crypto-decimals)
(.toFixed (* value
conversion-rate)
12))]
(number/remove-trailing-zeroes
new-value))))))]
(rn/use-mount
(fn []
(let [dismiss-keyboard-fn #(when (= % "active") (rn/dismiss-keyboard!))
app-keyboard-listener (.addEventListener rn/app-state "change" dismiss-keyboard-fn)]
#(.remove app-keyboard-listener))))
(hot-reload/use-safe-unmount on-navigate-back)
(rn/use-effect
(fn []
(set-input-state #(controlled-input/set-upper-limit % current-limit)))
[current-limit])
(rn/use-effect
(fn []
(when input-error (debounce/clear-all))
@@ -312,36 +348,24 @@
:on-press #(rf/dispatch [:navigate-back])
:switcher-type :select-account}]
[quo/token-input
{:container-style style/input-container
:token-symbol token-symbol
:value input-value
:on-swap swap-between-fiat-and-crypto
:on-token-press show-select-asset-sheet
:error? (controlled-input/input-error input-state)
:currency-symbol (if crypto-currency? token-symbol fiat-currency)
:converted-value (if crypto-currency?
(utils/prettify-balance
currency-symbol
(money/crypto->fiat input-value
conversion-rate))
(utils/prettify-crypto-balance
(or (clj->js token-symbol) "")
(money/fiat->crypto input-value
conversion-rate)
conversion-rate))
:hint-component [quo/network-tags
{:networks (seq from-enabled-networks)
:title (i18n/label
:t/send-limit
{:limit (if crypto-currency?
(utils/prettify-crypto-balance
(or (clj->js token-symbol) "")
(controlled-input/upper-limit input-state)
conversion-rate)
(utils/prettify-balance currency-symbol
(controlled-input/upper-limit
input-state)))})
:status (when (controlled-input/input-error input-state) :error)}]}]
{:container-style style/input-container
:token token-symbol
:currency fiat-currency
:currency-symbol currency-symbol
:crypto-decimals (min token-decimals 6)
:error? (controlled-input/input-error input-state)
:networks (seq from-enabled-networks)
:title (i18n/label
:t/send-limit
{:limit (if crypto-currency?
(utils/make-limit-label-crypto current-limit token-symbol)
(utils/make-limit-label-fiat current-limit currency-symbol))})
:conversion conversion-rate
:show-keyboard? false
:value input-amount
:on-swap swap-between-fiat-and-crypto
:on-token-press show-select-asset-sheet
:allow-selection? false}]
[routes/view
{:token token-by-symbol
:send-amount-in-crypto amount-in-crypto
@@ -386,7 +410,7 @@
:left-action :dot
:delete-key? true
:on-press (fn [c]
(let [new-text (str input-value c)
(let [new-text (str input-amount c)
max-decimals (if crypto-currency? crypto-decimals 2)
regex-pattern (str "^\\d*\\.?\\d{0," max-decimals "}$")
regex (re-pattern regex-pattern)]
@@ -1,12 +1,19 @@
(ns status-im.contexts.wallet.send.routes.view
(:require
[clojure.string :as string]
[quo.core :as quo]
[react-native.core :as rn]
[react-native.safe-area :as safe-area]
[status-im.common.controlled-input.utils :as controlled-input]
[status-im.contexts.wallet.common.utils :as utils]
[status-im.contexts.wallet.common.utils.networks :as network-utils]
[status-im.contexts.wallet.send.routes.style :as style]
[status-im.contexts.wallet.send.utils :as send-utils]
[status-im.contexts.wallet.sheets.network-preferences.view :as network-preferences]
[status-im.feature-flags :as ff]
[utils.i18n :as i18n]
[utils.money :as money]
[utils.number :as number]
[utils.re-frame :as rf]))
@@ -80,164 +87,160 @@
(rf/dispatch [:wallet/update-receiver-networks
chain-ids]))}]))}]))
#_(defn- edit-amount
[{:keys [chain-id token-symbol send-amount-in-crypto init-amount]}]
(rf/dispatch
[:show-bottom-sheet
{:content
(fn []
(let [{:keys [network-name] :as network-details} (rf/sub [:wallet/network-details-by-chain-id
chain-id])
{fiat-currency :currency} (rf/sub [:profile/profile])
{token-decimals :decimals
:as
token} (rf/sub [:wallet/wallet-send-token])
currency (rf/sub [:profile/currency])
currency-symbol (rf/sub [:profile/currency-symbol])
send-from-locked-amounts (rf/sub
[:wallet/wallet-send-from-locked-amounts])
{account-color :color} (rf/sub [:wallet/current-viewing-account])
locked-amount (get send-from-locked-amounts chain-id)
network-name-str (string/capitalize (name network-name))
[input-state set-input-state] (rn/use-state
(cond-> controlled-input/init-state
init-amount
(defn- edit-amount
[{:keys [chain-id token-symbol send-amount-in-crypto init-amount]}]
(rf/dispatch
[:show-bottom-sheet
{:content
(fn []
(let [{:keys [network-name] :as network-details} (rf/sub [:wallet/network-details-by-chain-id
chain-id])
{fiat-currency :currency} (rf/sub [:profile/profile])
{token-decimals :decimals
:as
token} (rf/sub [:wallet/wallet-send-token])
currency (rf/sub [:profile/currency])
currency-symbol (rf/sub [:profile/currency-symbol])
send-from-locked-amounts (rf/sub
[:wallet/wallet-send-from-locked-amounts])
{account-color :color} (rf/sub [:wallet/current-viewing-account])
locked-amount (get send-from-locked-amounts chain-id)
network-name-str (string/capitalize (name network-name))
[input-state set-input-state] (rn/use-state (cond-> controlled-input/init-state
init-amount
(controlled-input/set-input-value
(money/to-string init-amount))
locked-amount
(controlled-input/set-input-value
locked-amount)))
[crypto-currency? set-crypto-currency] (rn/use-state true)
conversion-rate (-> token
:market-values-per-currency
currency
:price)
{token-balance :total-balance} (rf/sub [:wallet/token-by-symbol
(str token-symbol)
[chain-id]])
current-crypto-limit (utils/get-standard-crypto-format
token
token-balance)
current-fiat-limit (.toFixed (* token-balance conversion-rate) 2)
current-limit (if crypto-currency?
current-crypto-limit
current-fiat-limit)
crypto-decimals token-decimals
input-amount (controlled-input/input-value input-state)
[is-amount-locked? set-is-amount-locked] (rn/use-state (some? locked-amount))
bottom (safe-area/get-bottom)
amount-in-crypto (if crypto-currency?
input-amount
(number/remove-trailing-zeroes
(.toFixed (/ input-amount
conversion-rate)
crypto-decimals)))
locked-greater-then-send-amount? (let [amount (money/bignumber
amount-in-crypto)
send-amount (money/bignumber
send-amount-in-crypto)]
(and (money/bignumber? amount)
(money/bignumber? send-amount)
(money/greater-than amount send-amount)))
swap-between-fiat-and-crypto (fn [swap-to-crypto-currency?]
(set-crypto-currency swap-to-crypto-currency?)
(set-input-state
(fn [input-state]
(controlled-input/set-input-value
(money/to-string init-amount))
locked-amount
(controlled-input/set-input-value
locked-amount)))
[crypto-currency? set-crypto-currency] (rn/use-state true)
conversion-rate (-> token
:market-values-per-currency
currency
:price)
{token-balance :total-balance} (rf/sub [:wallet/token-by-symbol
(str token-symbol)
[chain-id]])
current-crypto-limit (utils/get-standard-crypto-format
token
token-balance)
current-fiat-limit (.toFixed (* token-balance conversion-rate) 2)
current-limit (if crypto-currency?
current-crypto-limit
current-fiat-limit)
crypto-decimals token-decimals
input-amount (controlled-input/input-value input-state)
[is-amount-locked? set-is-amount-locked] (rn/use-state (some? locked-amount))
bottom (safe-area/get-bottom)
amount-in-crypto (if crypto-currency?
input-amount
(number/remove-trailing-zeroes
(.toFixed (/ input-amount
conversion-rate)
crypto-decimals)))
locked-greater-then-send-amount? (let [amount (money/bignumber
amount-in-crypto)
send-amount (money/bignumber
send-amount-in-crypto)]
(and (money/bignumber? amount)
(money/bignumber? send-amount)
(money/greater-than amount
send-amount)))
swap-between-fiat-and-crypto (fn [swap-to-crypto-currency?]
(set-crypto-currency
swap-to-crypto-currency?)
(set-input-state
(fn [input-state]
(controlled-input/set-input-value
input-state
(let [value (controlled-input/input-value
input-state)
new-value
(if
swap-to-crypto-currency?
(.toFixed
(/ value
conversion-rate)
crypto-decimals)
(.toFixed
(* value
conversion-rate)
12))]
(number/remove-trailing-zeroes
new-value))))))
lock-or-unlock-amount (fn []
(if is-amount-locked?
(rf/dispatch [:wallet/lock-from-amount
chain-id
amount-in-crypto])
(rf/dispatch [:wallet/unlock-from-amount
chain-id]))
(rf/dispatch [:hide-bottom-sheet]))]
(rn/use-effect
(fn []
(set-input-state #(controlled-input/set-upper-limit % current-limit)))
[current-limit])
[:<>
[quo/drawer-top
{:title (i18n/label :t/send-from-network {:network network-name-str})
:description (i18n/label :t/define-amount-sent-from-network {:network network-name-str})}]
[quo/token-input
{:container-style style/input-container
:token token-symbol
:currency fiat-currency
:currency-symbol currency-symbol
:crypto-decimals (min token-decimals 6)
:error? (controlled-input/input-error input-state)
:networks [network-details]
:title (i18n/label
:t/send-limit
{:limit (if crypto-currency?
(utils/make-limit-label-crypto current-limit token-symbol)
(utils/make-limit-label-fiat current-limit currency-symbol))})
:conversion conversion-rate
:show-keyboard? false
:value (controlled-input/input-value input-state)
:on-swap swap-between-fiat-and-crypto
:allow-selection? false}]
(when locked-greater-then-send-amount?
[quo/information-box
{:type :error
:icon :i/info
:style style/error-box}
(i18n/label :t/value-higher-than-send-amount)])
[quo/disclaimer
{:on-change (fn [checked?]
(set-is-amount-locked checked?))
:checked? is-amount-locked?
:container-style style/disclaimer
:icon (if is-amount-locked?
:i/locked
:i/unlocked)
:customization-color account-color}
(i18n/label :t/dont-auto-recalculate-network {:network network-name-str})]
[quo/bottom-actions
{:actions :one-action
:button-one-label (i18n/label :t/update)
:button-one-props {:on-press lock-or-unlock-amount
:customization-color account-color
:disabled? (or (controlled-input/empty-value? input-state)
(controlled-input/input-error input-state)
locked-greater-then-send-amount?)}}]
[quo/numbered-keyboard
{:container-style (style/keyboard-container bottom)
:left-action :dot
:delete-key? true
:on-press (fn [c]
(let [new-text (str input-amount c)
max-decimals (if crypto-currency? crypto-decimals 2)
regex-pattern (str "^\\d*\\.?\\d{0," max-decimals "}$")
regex (re-pattern regex-pattern)]
(when (re-matches regex new-text)
(set-is-amount-locked true)
(set-input-state #(controlled-input/add-character % c)))))
:on-delete (fn []
(set-is-amount-locked true)
(set-input-state controlled-input/delete-last))
:on-long-press-delete (fn []
(set-is-amount-locked true)
(set-input-state controlled-input/delete-all))}]]))}]))
input-state
(let [value (controlled-input/input-value
input-state)
new-value (if
swap-to-crypto-currency?
(.toFixed
(/ value
conversion-rate)
crypto-decimals)
(.toFixed
(* value
conversion-rate)
12))]
(number/remove-trailing-zeroes
new-value))))))
lock-or-unlock-amount (fn []
(if is-amount-locked?
(rf/dispatch [:wallet/lock-from-amount
chain-id
amount-in-crypto])
(rf/dispatch [:wallet/unlock-from-amount
chain-id]))
(rf/dispatch [:hide-bottom-sheet]))]
(rn/use-effect
(fn []
(set-input-state #(controlled-input/set-upper-limit % current-limit)))
[current-limit])
[:<>
[quo/drawer-top
{:title (i18n/label :t/send-from-network {:network network-name-str})
:description (i18n/label :t/define-amount-sent-from-network {:network network-name-str})}]
[quo/token-input
{:container-style style/input-container
:token token-symbol
:currency fiat-currency
:currency-symbol currency-symbol
:crypto-decimals (min token-decimals 6)
:error? (controlled-input/input-error input-state)
:networks [network-details]
:title (i18n/label
:t/send-limit
{:limit (if crypto-currency?
(utils/make-limit-label-crypto current-limit token-symbol)
(utils/make-limit-label-fiat current-limit currency-symbol))})
:conversion conversion-rate
:show-keyboard? false
:value (controlled-input/input-value input-state)
:on-swap swap-between-fiat-and-crypto
:allow-selection? false}]
(when locked-greater-then-send-amount?
[quo/information-box
{:type :error
:icon :i/info
:style style/error-box}
(i18n/label :t/value-higher-than-send-amount)])
[quo/disclaimer
{:on-change (fn [checked?]
(set-is-amount-locked checked?))
:checked? is-amount-locked?
:container-style style/disclaimer
:icon (if is-amount-locked?
:i/locked
:i/unlocked)
:customization-color account-color}
(i18n/label :t/dont-auto-recalculate-network {:network network-name-str})]
[quo/bottom-actions
{:actions :one-action
:button-one-label (i18n/label :t/update)
:button-one-props {:on-press lock-or-unlock-amount
:customization-color account-color
:disabled? (or (controlled-input/empty-value? input-state)
(controlled-input/input-error input-state)
locked-greater-then-send-amount?)}}]
[quo/numbered-keyboard
{:container-style (style/keyboard-container bottom)
:left-action :dot
:delete-key? true
:on-press (fn [c]
(let [new-text (str input-amount c)
max-decimals (if crypto-currency? crypto-decimals 2)
regex-pattern (str "^\\d*\\.?\\d{0," max-decimals "}$")
regex (re-pattern regex-pattern)]
(when (re-matches regex new-text)
(set-is-amount-locked true)
(set-input-state #(controlled-input/add-character % c)))))
:on-delete (fn []
(set-is-amount-locked true)
(set-input-state controlled-input/delete-last))
:on-long-press-delete (fn []
(set-is-amount-locked true)
(set-input-state controlled-input/delete-all))}]]))}]))
(defn render-network-values
[{:keys [network-values token-symbol on-press on-long-press receiver? loading-routes?
@@ -385,6 +388,13 @@
chain-id-to-disable
disabled-from-chain-ids
token-available-networks-for-suggested-routes))
(when (ff/enabled? ::ff/wallet.custom-network-amounts)
:on-long-press) (fn [chain-id amount-calculated-for-chain]
(edit-amount
{:chain-id chain-id
:token-symbol token-symbol
:send-amount-in-crypto send-amount-in-crypto
:init-amount amount-calculated-for-chain}))
:receiver? false
:theme theme
:loading-routes? loading-routes?
@@ -213,8 +213,11 @@
first-route (first route)
native-currency-symbol (get-in first-route
[:from :native-currency-symbol])
native-token (when native-currency-symbol
(rf/sub [:wallet/token-by-symbol
native-currency-symbol]))
fee-formatted (rf/sub [:wallet/wallet-send-fee-fiat-formatted
native-currency-symbol])
native-token])
account (rf/sub [:wallet/current-viewing-account])
account-color (:color account)
bridge-to-network (when bridge-to-chain-id
@@ -28,23 +28,20 @@
:max-priority-fee-per-gas "0.011000001"
:eip1559-enabled true}
:estimated-time 3
:receive-amount "99.98"
:pay-token {:symbol "SNT"
:address "0x432492384728934239789"}
:receive-token {:symbol "USDT"
:receive-amount 99.98
:receive-token {:symbol "SNT"
:address "0x432492384728934239789"}})
(defn- assets-view
[search-text on-change-text]
(let [on-token-press (fn [token]
(let [token-networks (:networks token)
asset-to-receive (rf/sub [:wallet/token-by-symbol "SNT"])]
(let [token-networks (:networks token)]
(rf/dispatch [:wallet.swap/select-asset-to-pay
{:token token
:network (when (= (count token-networks) 1)
(first token-networks))
:stack-id :screen/wallet.swap-select-asset-to-pay}])
(rf/dispatch [:wallet.swap/select-asset-to-receive {:token asset-to-receive}])
(rf/dispatch [:wallet.swap/select-asset-to-receive {:token token}])
(rf/dispatch [:wallet.swap/set-pay-amount 100])
(rf/dispatch [:wallet.swap/set-swap-proposal dummy-swap-proposal])
(rf/dispatch [:wallet.swap/set-provider])))]
@@ -4,13 +4,13 @@
[quo.foundations.resources :as resources]
[quo.theme :as quo.theme]
[react-native.core :as rn]
[status-im.common.events-helper :as events-helper]
[status-im.common.floating-button-page.view :as floating-button-page]
[status-im.common.standard-authentication.core :as standard-auth]
[status-im.contexts.wallet.common.utils.external-links :as external-links]
[status-im.contexts.wallet.swap.set-spending-cap.style :as style]
[utils.address :as address-utils]
[utils.i18n :as i18n]
[utils.navigation :as navigation]
[utils.re-frame :as rf]))
(defn- swap-title
@@ -172,7 +172,11 @@
(defn footer
[{:keys [estimated-time-min native-currency-symbol network theme account-color loading-fees?]}]
(let [fee-formatted (rf/sub [:wallet/wallet-send-fee-fiat-formatted native-currency-symbol])
(let [native-token (when native-currency-symbol
(rf/sub [:wallet/token-by-symbol
native-currency-symbol]))
fee-formatted (rf/sub [:wallet/wallet-send-fee-fiat-formatted
native-token])
on-auth-success (rn/use-callback #(js/alert "Not implemented yet"))]
[rn/view {:style {:margin-bottom -10}}
[transaction-details
@@ -209,7 +213,7 @@
{:footer-container-padding 0
:header [quo/page-nav
{:icon-name :i/close
:on-press events-helper/navigate-back
:on-press navigation/navigate-back
:margin-top 8
:background :blur
:accessibility-label :top-bar}]
@@ -1,35 +0,0 @@
(ns status-im.contexts.wallet.swap.setup-swap.style)
(def container
{:flex 1})
(def keyboard-container
{:align-self :flex-end
:width "100%"})
(def inputs-container
{:padding-top 12
:padding-horizontal 20})
(def details-container
{:flex-direction :row
:justify-content :space-between
:padding-top 7
:padding-horizontal 20})
(def detail-item
{:flex 1
:height 36
:background-color :transparent})
(def swap-order-button
{:margin-top -9
:z-index 2
:align-self :center})
(def receive-token-swap-input-container
{:margin-top -9})
(def footer-container
{:flex 1
:justify-content :flex-end})
@@ -1,132 +0,0 @@
(ns status-im.contexts.wallet.swap.setup-swap.view
(:require [quo.core :as quo]
[react-native.core :as rn]
[react-native.safe-area :as safe-area]
[status-im.common.events-helper :as events-helper]
[status-im.contexts.wallet.common.account-switcher.view :as account-switcher]
[status-im.contexts.wallet.common.utils :as utils]
[status-im.contexts.wallet.swap.setup-swap.style :as style]
[utils.i18n :as i18n]
[utils.re-frame :as rf]))
(defn- data-item
[{:keys [title subtitle size subtitle-icon loading?]}]
[quo/data-item
{:container-style style/detail-item
:blur? false
:card? false
:subtitle-type (if subtitle-icon :editable :default)
:status (if loading? :loading :default)
:title title
:subtitle subtitle
:size size
:icon subtitle-icon}])
(defn- transaction-details
[{:keys [max-slippage native-currency-symbol loading-fees?]}]
(let [max-fees (rf/sub [:wallet/wallet-send-fee-fiat-formatted native-currency-symbol])]
[rn/view {:style style/details-container}
[data-item
{:title (i18n/label :t/max-fees)
:subtitle max-fees
:loading? loading-fees?
:size :small}]
[data-item
{:title (i18n/label :t/max-slippage)
:subtitle max-slippage
:subtitle-icon :i/edit
:loading? loading-fees?}]]))
(defn view
[]
(let [[pay-value set-pay-value] (rn/use-state "")
{:keys [color]} (rf/sub [:wallet/current-viewing-account])
{:keys [max-slippage swap-proposal loading-fees?
receive-amount network]} (rf/sub [:wallet/swap])
currency (rf/sub [:profile/currency])
currency-symbol (rf/sub [:profile/currency-symbol])
asset-to-pay (rf/sub [:wallet/swap-asset-to-pay])
asset-to-receive (rf/sub [:wallet/swap-asset-to-receive])
pay-token-fiat-value (utils/calculate-token-fiat-value
{:currency currency
:balance (or pay-value 0)
:token asset-to-pay})
receive-token-fiat-value (utils/calculate-token-fiat-value
{:currency currency
:balance (or receive-amount 0)
:token asset-to-receive})
native-currency-symbol (get-in swap-proposal
[:from :native-currency-symbol])
pay-token-symbol (:symbol asset-to-pay)
receive-token-symbol (:symbol asset-to-receive)
on-press (fn [v] (set-pay-value (str pay-value v)))
delete (fn []
(set-pay-value #(subs % 0 (dec (count %)))))]
[rn/view {:style style/container}
[account-switcher/view
{:on-press events-helper/navigate-back
:icon-name :i/arrow-left
:margin-top (safe-area/get-top)
:switcher-type :select-account}]
[rn/view {:style style/inputs-container}
[quo/swap-input
{:type :pay
:error? false
:token pay-token-symbol
:customization-color :blue
:show-approval-label? false
:status :default
:currency-symbol currency-symbol
:on-swap-press #(js/alert "Swap Pressed")
:on-token-press #(js/alert "Token Pressed")
:on-max-press #(js/alert "Max Pressed")
:value pay-value
:fiat-value pay-token-fiat-value
:network-tag-props {:title (i18n/label :t/max-token
{:number 200
:token-symbol pay-token-symbol})
:networks [{:source (:source network)}]}
:approval-label-props {:status :approve
:token-value pay-value
:button-props {:on-press
#(js/alert "Approve Pressed")}
:customization-color color
:token-symbol pay-token-symbol}}]
[quo/swap-order-button
{:container-style style/swap-order-button
:on-press #(js/alert "Pressed")}]
[quo/swap-input
{:type :receive
:error? false
:token receive-token-symbol
:customization-color color
:show-approval-label? false
:enable-swap? true
:status :default
:currency-symbol currency-symbol
:on-swap-press #(js/alert "Swap Pressed")
:on-token-press #(js/alert "Token Pressed")
:on-max-press #(js/alert "Max Pressed")
:value receive-amount
:fiat-value receive-token-fiat-value
:container-style style/receive-token-swap-input-container}]]
[rn/view {:style style/footer-container}
(when swap-proposal
[transaction-details
{:native-currency-symbol native-currency-symbol
:max-slippage max-slippage
:loading-fees? loading-fees?}])
[quo/bottom-actions
{:actions :one-action
:button-one-label (i18n/label :t/review-swap)
:button-one-props {:disabled? (or (not swap-proposal)
loading-fees?)
:customization-color color
:on-press #(js/alert "Review swap pressed")}}]]
[quo/numbered-keyboard
{:container-style style/keyboard-container
:left-action :dot
:delete-key? true
:on-press on-press
:on-delete delete}]]))
@@ -103,7 +103,11 @@
(defn footer
[{:keys [estimated-time-min native-currency-symbol max-slippage theme account-color provider
loading-fees?]}]
(let [fee-formatted (rf/sub [:wallet/wallet-send-fee-fiat-formatted native-currency-symbol])]
(let [native-token (when native-currency-symbol
(rf/sub [:wallet/token-by-symbol
native-currency-symbol]))
fee-formatted (rf/sub [:wallet/wallet-send-fee-fiat-formatted
native-token])]
[:<>
[transaction-details
{:estimated-time-min estimated-time-min
@@ -19,8 +19,4 @@
"Swap confirmation"]
[quo/button
{:on-press #(rf/dispatch [:open-modal :screen/wallet.swap-set-spending-cap])}
"Set spending cap"]
[quo/button
{:on-press #(rf/dispatch [:navigate-to-within-stack
[:screen/wallet.setup-swap :screen/wallet.swap-propasal]])}
"Setup swap"]]))
"Set spending cap"]]))
-5
View File
@@ -120,7 +120,6 @@
[status-im.contexts.wallet.send.transaction-progress.view :as wallet-transaction-progress]
[status-im.contexts.wallet.swap.select-asset-to-pay.view :as wallet-swap-select-asset-to-pay]
[status-im.contexts.wallet.swap.set-spending-cap.view :as wallet-swap-set-spending-cap]
[status-im.contexts.wallet.swap.setup-swap.view :as wallet-swap-setup-swap]
[status-im.contexts.wallet.swap.swap-confirmation.view :as wallet-swap-confirmation]
[status-im.contexts.wallet.swap.swap-proposal.view :as wallet-swap-propasal]
[status-im.contexts.wallet.wallet-connect.modals.send-transaction.view :as
@@ -523,10 +522,6 @@
:insets {:top? true}}
:component wallet-swap-select-asset-to-pay/view}
{:name :screen/wallet.setup-swap
:options {:insets {:bottom? true}}
:component wallet-swap-setup-swap/view}
{:name :screen/wallet.swap-propasal
:options {:insets {:top? true}}
:component wallet-swap-propasal/view}
-5
View File
@@ -14,11 +14,6 @@
:<- [:wallet/swap]
:-> :asset-to-pay)
(rf/reg-sub
:wallet/swap-asset-to-receive
:<- [:wallet/swap]
:-> :asset-to-receive)
(rf/reg-sub
:wallet/swap-asset-to-pay-token-symbol
:<- [:wallet/swap-asset-to-pay]
-45
View File
@@ -64,43 +64,6 @@
:token-list-id ""
:built-on "ETH"
:verified true}
:asset-to-receive
{:description "Dai Stablecoin"
:decimals 18
:symbol "DAI"
:name "Dai Stablecoin"
:total-balance 1
:balances-per-chain
{1
{:raw-balance 1000000000000000000
:balance "1"
:chain-id 1}
10
{:raw-balance 0
:balance "0"
:chain-id 10}
42161
{:raw-balance 0
:balance "0"
:chain-id 42161}}
:networks (concat [(networks :mainnet-network)] (networks :layer-2-networks))
:chain-id 0
:market-values-per-currency
{:usd
{:change-24hour -0.00109422754667007
:change-pct-day -5.57352274163899
:change-pct-24hour -4.177805426737527
:high-day 0.0271858672171352
:market-cap 170783296.1155821
:has-error false
:change-pct-hour -0.0160462113709363
:low-day 0.02473516779550377
:price 0.0251}}
:asset-website-url "https://status.im/"
:available-balance 1
:token-list-id ""
:built-on "ETH"
:verified true}
:network nil})
(h/deftest-sub :wallet/swap
@@ -119,14 +82,6 @@
swap-data)
(is (match? (swap-data :asset-to-pay) (rf/sub [sub-name])))))
(h/deftest-sub :wallet/swap-asset-to-receive
[sub-name]
(testing "Return swap asset-to-receive"
(swap! rf-db/app-db assoc-in
[:wallet :ui :swap]
swap-data)
(is (match? (swap-data :asset-to-receive) (rf/sub [sub-name])))))
(h/deftest-sub :wallet/swap-asset-to-pay-token-symbol
[sub-name]
(testing "Return asset-to-pay token symbol"
+14 -20
View File
@@ -691,29 +691,23 @@
(rf/reg-sub
:wallet/wallet-send-fee-fiat-formatted
:<- [:wallet/current-viewing-account]
:<- [:wallet/wallet-send-route]
:<- [:profile/currency]
:<- [:profile/currency-symbol]
(fn [[account route currency currency-symbol] [_ token-symbol-for-fees]]
(when token-symbol-for-fees
(let [tokens (:tokens account)
token-for-fees (first (filter #(= (string/lower-case (:symbol %))
(string/lower-case token-symbol-for-fees))
tokens))
fee-in-native-token (send-utils/calculate-full-route-gas-fee route)
fee-in-crypto-formatted (utils/get-standard-crypto-format
token-for-fees
fee-in-native-token)
fee-in-fiat (utils/calculate-token-fiat-value
{:currency currency
:balance fee-in-native-token
:token token-for-fees})
fee-formatted (utils/get-standard-fiat-format
fee-in-crypto-formatted
currency-symbol
fee-in-fiat)]
fee-formatted))))
(fn [[route currency currency-symbol] [_ token-for-fees]]
(let [fee-in-native-token (send-utils/calculate-full-route-gas-fee route)
fee-in-crypto-formatted (utils/get-standard-crypto-format
token-for-fees
fee-in-native-token)
fee-in-fiat (utils/calculate-token-fiat-value
{:currency currency
:balance fee-in-native-token
:token token-for-fees})
fee-formatted (utils/get-standard-fiat-format
fee-in-crypto-formatted
currency-symbol
fee-in-fiat)]
fee-formatted)))
(rf/reg-sub
:wallet/has-partially-operable-accounts?
+19 -25
View File
@@ -13,20 +13,17 @@
{:before #(reset! rf-db/app-db {})})
(def ^:private accounts-with-tokens
{:0x1 {:tokens [{:symbol "ETH"
:balances-per-chain {1 {:raw-balance "100"}}
:market-values-per-currency {:usd {:price 10000}}}
{:symbol "SNT"
:balances-per-chain {1 {:raw-balance "100"}}
:market-values-per-currency {:usd {:price 10000}}}]
{:0x1 {:tokens [{:symbol "ETH"
:balances-per-chain {1 {:raw-balance "100"}}}
{:symbol "SNT"
:balances-per-chain {1 {:raw-balance "100"}}}]
:network-preferences-names #{}
:customization-color nil
:operable? true
:operable :fully
:address "0x1"}
:0x2 {:tokens [{:symbol "SNT"
:balances-per-chain {1 {:raw-balance "200"}}
:market-values-per-currency {:usd {:price 10000}}}]
:0x2 {:tokens [{:symbol "SNT"
:balances-per-chain {1 {:raw-balance "200"}}}]
:network-preferences-names #{}
:customization-color nil
:operable? true
@@ -504,12 +501,10 @@
(assoc-in [:wallet :ui :send :token-symbol] "ETH")))
(let [result (rf/sub [sub-name])]
(is (match? result
[{:tokens [{:symbol "ETH"
:balances-per-chain {1 {:raw-balance "100"}}
:market-values-per-currency {:usd {:price 10000}}}
{:symbol "SNT"
:balances-per-chain {1 {:raw-balance "100"}}
:market-values-per-currency {:usd {:price 10000}}}]
[{:tokens [{:symbol "ETH"
:balances-per-chain {1 {:raw-balance "100"}}}
{:symbol "SNT"
:balances-per-chain {1 {:raw-balance "100"}}}]
:network-preferences-names #{}
:customization-color nil
:operable? true
@@ -523,12 +518,10 @@
(assoc-in [:wallet :ui :send :token] {:symbol "ETH"})))
(let [result (rf/sub [sub-name])]
(is (match? result
[{:tokens [{:symbol "ETH"
:balances-per-chain {1 {:raw-balance "100"}}
:market-values-per-currency {:usd {:price 10000}}}
{:symbol "SNT"
:balances-per-chain {1 {:raw-balance "100"}}
:market-values-per-currency {:usd {:price 10000}}}]
[{:tokens [{:symbol "ETH"
:balances-per-chain {1 {:raw-balance "100"}}}
{:symbol "SNT"
:balances-per-chain {1 {:raw-balance "100"}}}]
:network-preferences-names #{}
:customization-color nil
:operable? true
@@ -966,14 +959,15 @@
(testing "wallet send fee calculated and formatted in fiat"
(swap! rf-db/app-db
#(-> %
(assoc-in [:wallet :accounts] accounts-with-tokens)
(assoc-in [:wallet :current-viewing-account-address] "0x1")
(assoc-in [:wallet :ui :send :route] route-data)
(assoc-in [:profile/profile :currency] :usd)
(assoc-in [:profile/profile :currency-symbol] "$")))
(let [token-symbol-for-fees "ETH"
result (rf/sub [sub-name token-symbol-for-fees])]
(let [token-for-fees {:decimals 18
:symbol "ETH"
:name "Ether"
:market-values-per-currency {:usd {:price 10000}}}
result (rf/sub [sub-name token-for-fees])]
(is (match? result "$1.00")))))
(h/deftest-sub :wallet/has-partially-operable-accounts?
-2
View File
@@ -6,8 +6,6 @@
prefer to use it for more general purpose concepts, such as the re-frame event
layer."
(:require-macros test-helpers.unit)
;; We must require test-helpers.matchers namespace to register the custom cljs.test directive
;; `match-strict?`
(:require
[re-frame.core :as rf]
[re-frame.db :as rf-db]
+12
View File
@@ -1,6 +1,7 @@
(ns utils.hex
(:require
[clojure.string :as string]
[native-module.core :as native-module]
[schema.core :as schema]))
(defn normalize-hex
@@ -25,3 +26,14 @@
[:=>
[:cat :string]
:string])
(defn number-to-hex
[value]
(->> value
native-module/number-to-hex
prefix-hex))
(schema/=> number-to-hex
[:=>
[:cat [:or :string :int]]
:string])
+2 -9
View File
@@ -55,9 +55,8 @@
(.lessThan ^js bn1 bn2))
(defn equal-to
[n1 n2]
(when-let [^js bn1 (bignumber n1)]
(.eq ^js bn1 n2)))
[bn1 bn2]
(.eq ^js bn1 bn2))
(extend-type BigNumber
IEquiv
@@ -263,12 +262,6 @@
[bn1 bn2]
(.round (.dividedBy ^js bn1 bn2) 0))
(defn fiat->crypto
[crypto fiat-price]
(when-let [crypto-bn (bignumber crypto)]
(div crypto-bn
(bignumber fiat-price))))
(defn absolute-value
[bn]
(when bn
@@ -1,6 +1,6 @@
(ns status-im.common.events-helper
"Provides highly reusable dispatch functions to ensure consistency and avoid duplication in managing various events,
including navigation and other actions that affect application behavior."
(ns utils.navigation
"Prefer to declare in this namespace only reusable navigation functions that
aren't better suited in a particular bounded context."
(:require [utils.re-frame :as rf]))
(defn navigate-back
+3 -3
View File
@@ -3,7 +3,7 @@
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
"owner": "status-im",
"repo": "status-go",
"version": "v0.184.47",
"commit-sha1": "83aa01c7daf69d518e624fc584ea22ca27b34b73",
"src-sha256": "07gqijx652ap0lf0kvcpd0lxx5x58air19pxgjawwymq2b8kly16"
"version": "fff0b7fe08105bcdd964c7de6f8d7ec7dee9f8d0",
"commit-sha1": "fff0b7fe08105bcdd964c7de6f8d7ec7dee9f8d0",
"src-sha256": "1brgiaiq57254hvvwmppx7q85z2f2zdfycgxsnsbqcglzn3b9a04"
}
+10 -18
View File
@@ -1,13 +1,11 @@
import logging
import time
from datetime import datetime
from decimal import Decimal
from json import JSONDecodeError
from os import environ
from typing import List
import pytest
import pytz
import requests
from selenium.common import TimeoutException
@@ -40,7 +38,7 @@ class NetworkApi:
return self.send_etherscan_request(params)
def get_transactions(self, address: str) -> List[dict]:
params = {'module': 'account', 'action': 'txlist', 'address': address, 'page': 1, 'offset': 10, 'sort': 'desc'}
params = {'module': 'account', 'action': 'txlist', 'address': address, 'sort': 'desc'}
return self.send_etherscan_request(params)
def is_transaction_successful(self, transaction_hash: str) -> int:
@@ -108,28 +106,22 @@ class NetworkApi:
self.log("Failed iterate transactions(Etherscan unexpected error): " + str(e))
continue
def wait_for_confirmation_of_transaction(self, address, tx_time, confirmations=7, token=False):
expected_tx_timestamp = datetime.strptime(tx_time, "%Y-%m-%dT%H:%M:%S%z").replace(tzinfo=pytz.UTC)
def wait_for_confirmation_of_transaction(self, address, amount, confirmations=6, token=False):
start_time = time.time()
if token:
token_info = "token transaction"
else:
token_info = "ETH transaction"
self.log('Waiting for %s of %s to have %s confirmations' % (token_info, address, confirmations))
self.log('Waiting %s %s for %s to have %s confirmations' % (amount, token_info, address, confirmations))
while round(time.time() - start_time, ndigits=2) < 600: # should be < idleTimeout capability
if token:
transaction = self.get_token_transactions(address)[0]
else:
transaction = self.get_transactions(address)[0]
tx_timestamp = datetime.fromtimestamp(int(transaction['timeStamp'])).replace(tzinfo=pytz.UTC)
if tx_timestamp > expected_tx_timestamp:
if int(transaction['confirmations']) >= confirmations:
return
time.sleep(20)
transaction = self.find_transaction_by_unique_amount(address, amount, token)
self.log(
'Expected amount of confirmations is %s, in fact %s' % (confirmations, transaction['confirmations']))
pytest.fail('The last transaction was not confirmed, address is %s, still has %s confirmations' % (
address, int(transaction['confirmations'])))
if int(transaction['confirmations']) >= confirmations:
return
time.sleep(20)
pytest.fail('Transaction with amount %s was not confirmed, address is %s, still has %s confirmations' % (
amount, address, int(transaction['confirmations'])))
def verify_balance_is_updated(self, initial_balance, recipient_address, wait_time=360):
counter = 0
@@ -150,7 +142,7 @@ class NetworkApi:
balance = round(self.get_balance(address), 4)
if balance == expected_balance:
return
time.sleep(20)
time.sleep(10)
raise TimeoutException(
'balance is not updated on Etherscan, it is %s but expected to be %s' % (balance, expected_balance))
@@ -264,15 +264,15 @@ class TestCommunityOneDeviceMerged(MultipleSharedDeviceTestCase):
expected_communities = {
# ' 0xUX': ['Design', 'Ethereum', 'Collaboration'],
'Status': ['Web3', 'Blockchain', 'Ethereum'],
# 'Status Inu': ['News', 'Social', 'Web3'],
'Status Inu': ['News', 'Social', 'Web3'],
}
for community_name, tags in expected_communities.items():
self.home.just_fyi("Check %s community tags in the Discover communities screen" % community_name)
card = self.home.get_discover_community_card_by_name(community_name=community_name)
try:
card.wait_for_visibility_of_element(30)
# if community_name == 'Status':
# card.swipe_to_web_element()
if community_name == 'Status':
card.swipe_to_web_element()
missing_tags = list()
for text in tags:
try:
@@ -281,17 +281,18 @@ class TestCommunityOneDeviceMerged(MultipleSharedDeviceTestCase):
missing_tags.append(text)
if missing_tags:
self.errors.append("Community '%s' is missing tag(s) %s." % (community_name, ','.join(tags)))
# if community_name == 'Status':
self.home.just_fyi("Check Status community screen")
card.click()
if self.community_view.join_button.is_element_differs_from_template(
'status_community_join_button.png'):
self.errors.append("Status community Join button is different from expected template.")
if self.community_view.community_logo.is_element_differs_from_template('status_community_logo.png'):
self.errors.append("Status community logo is different from expected template.")
# self.community_view.close_community_view_button.click()
# self.home.swipe_up()
if community_name == 'Status':
self.home.just_fyi("Check Status community screen")
card.click()
if self.community_view.join_button.is_element_differs_from_template(
'status_community_join_button.png'):
self.errors.append("Status community Join button is different from expected template.")
if self.community_view.community_logo.is_element_differs_from_template('status_community_logo.png'):
self.errors.append("Status community logo is different from expected template.")
self.community_view.close_community_view_button.click()
self.home.swipe_up()
except TimeoutException:
self.errors.append("Community '%s' is not in the Discover Communities list." % community_name)
@@ -17,14 +17,13 @@ class TestDeepLinksOneDevice(MultipleSharedDeviceTestCase):
self.home = self.sign_in.create_user(username=self.username)
self.home.communities_tab.click_until_presence_of_element(self.home.plus_community_button)
self.open_community_name = "open community"
self.community_name = "open community"
self.channel_name = "general"
self.community = self.home.create_community(community_type="open")
self.profile_view = self.home.get_profile_view()
self.browser_view = self.home.get_dapp_view()
self.home.get_chat(self.open_community_name, community=True).click()
self.home.get_chat(self.community_name, community=True).click()
self.community_view = self.home.get_community_view()
self.open_community_url = self.community_view.copy_community_link()
self.channel = self.community_view.get_channel(self.channel_name).click()
@marks.testrail_id(704613)
@@ -40,6 +39,7 @@ class TestDeepLinksOneDevice(MultipleSharedDeviceTestCase):
self.channel.send_message(url)
self.channel.chat_element_by_text(url).click_on_link_inside_message_body()
if self.channel.profile_send_contact_request_button.is_element_displayed(10):
# username_text = self.profile_view.default_username_text.text
username_text = self.profile_view.contact_name_text.text
if not (username_text.endswith(url[-6:]) or username_text == text):
self.errors.append("Incorrect username is shown for profile url %s" % url)
@@ -47,10 +47,34 @@ class TestDeepLinksOneDevice(MultipleSharedDeviceTestCase):
self.errors.append("Profile was not opened by the profile url %s" % url)
self.profile_view.close_button.click()
community_urls = {
"https://status.app/c/ixyACjgKDVNOVCBjb21tdW5pdHkSHHJlcXVpcmUgMTAgU05UIEdvZXJsaSB0byB1c2UYASIHI2VhYjcwMAM=#zQ3shUeGnhM33QW4g9JfYfeLFAH9ZwbDboNYn5exCR7S3ii1y":
"SNT community",
"https://status.app/c/G0UAAMTyNsn2QZDEG0EXftOl8pOEfwEBOOSA_YTfIk85xmADDgINGmxpUHAXzK36bN0fK42Xf4YD2yjPk1z2pbFwFw==#zQ3sheoNX5kiuM393TJ6xDnL57aQoiwFWEuJnazJ6W2eNuh9u":
"open community",
"https://status.app/c/G00AAGS9TbI9mSR-ZNmFrhRjNuEeXAAbcAIUaLLJyjMOG3ACJQ12oIHD78QhzO9s_T5bUeU7rnATWJg3mGgTUemrAg==#zQ3shp9f5M3uyMpwTi3rFpFrP6WCWmNsW9pgK9cjXVTaf2vgj":
"closed community"
}
for url, text in community_urls.items():
self.channel.just_fyi("Opening community '%s' by the url %s" % (text, url))
self.channel.chat_message_input.clear()
self.channel.send_message(url)
self.channel.chat_element_by_text(url).click_on_link_inside_message_body()
if text == 'SNT community':
if self.community_view.community_title.text != text:
self.errors.append("Community '%s' was not requested to join by the url %s" % (text, url))
else:
if not self.community_view.join_button.is_element_displayed(
10) or self.community_view.community_title.text != text:
self.errors.append("Community '%s' was not requested to join by the url %s" % (text, url))
if text != "closed community": # the last one
self.home.navigate_back_to_home_view()
self.home.get_to_community_channel_from_home(self.community_name)
self.errors.verify_no_errors()
@marks.testrail_id(702775)
def test_links_deep_links_profile(self):
def test_links_deep_links(self):
self.home.navigate_back_to_home_view()
self.home.browser_tab.click()
@@ -63,6 +87,7 @@ class TestDeepLinksOneDevice(MultipleSharedDeviceTestCase):
for link, text in profile_links.items():
self.channel.just_fyi("Opening profile link %s" % link)
self.browser_view.open_url(link)
# shown_name_text = self.profile_view.default_username_text.text
shown_name_text = self.profile_view.contact_name_text.text
if text:
name_is_shown = shown_name_text == text or shown_name_text.endswith(link[-6:])
@@ -72,43 +97,25 @@ class TestDeepLinksOneDevice(MultipleSharedDeviceTestCase):
self.errors.append("Profile was not opened by the profile deep link %s" % link)
self.browser_view.click_system_back_button()
self.errors.verify_no_errors()
@marks.testrail_id(739307)
def test_deep_links_communities(self):
closed_community_name, snt_community_name = "closed community", "SNT community"
self.home.navigate_back_to_home_view()
self.home.communities_tab.click()
self.home.create_community(community_type="closed")
if not self.community_view.community_options_button.is_element_displayed():
self.home.get_chat(closed_community_name, community=True).click()
closed_community_url = self.community_view.copy_community_link()
self.home.navigate_back_to_home_view()
self.home.create_community(community_type="token-gated")
if not self.community_view.community_options_button.is_element_displayed():
self.home.get_chat(snt_community_name, community=True).click()
snt_community_url = self.community_view.copy_community_link()
self.home.reopen_app(sign_in=False)
self.sign_in.create_user(username="second user", first_user=False)
self.home.browser_tab.click()
old, new = "https://status.app/", "status-app://"
community_links = {
snt_community_name: snt_community_url.replace(old, new),
self.open_community_name: self.open_community_url.replace(old, new),
closed_community_name: closed_community_url.replace(old, new)
"status.app://c/ixyACjgKDVNOVCBjb21tdW5pdHkSHHJlcXVpcmUgMTAgU05UIEdvZXJsaSB0byB1c2UYASIHI2VhYjcwMAM=#zQ3shUeGnhM33QW4g9JfYfeLFAH9ZwbDboNYn5exCR7S3ii1y":
"SNT community",
"status.app://c/G0UAAMTyNsn2QZDEG0EXftOl8pOEfwEBOOSA_YTfIk85xmADDgINGmxpUHAXzK36bN0fK42Xf4YD2yjPk1z2pbFwFw==#zQ3sheoNX5kiuM393TJ6xDnL57aQoiwFWEuJnazJ6W2eNuh9u":
"open community",
"status.app://c/G00AAGS9TbI9mSR-ZNmFrhRjNuEeXAAbcAIUaLLJyjMOG3ACJQ12oIHD78QhzO9s_T5bUeU7rnATWJg3mGgTUemrAg==#zQ3shp9f5M3uyMpwTi3rFpFrP6WCWmNsW9pgK9cjXVTaf2vgj":
"closed community"
}
for text, link in community_links.items():
for link, text in community_links.items():
self.channel.just_fyi("Opening community '%s' by the link %s" % (text, link))
self.browser_view.open_url(link)
if text == snt_community_name:
if text == 'SNT community':
if self.community_view.community_title.text != text:
self.errors.append("Community '%s' was not requested to join by the deep link %s" % (text, link))
else:
if not self.community_view.join_button.is_element_displayed(
10) or self.community_view.community_title.text != text:
self.errors.append("Community '%s' was not requested to join by the deep link %s" % (text, link))
if text != closed_community_name: # the last one
if text != "closed community": # the last one
self.home.navigate_back_to_home_view()
self.home.browser_tab.click()
+2 -8
View File
@@ -135,14 +135,11 @@ class TestWalletMultipleDevice(MultipleSharedDeviceTestCase):
self.wallet_1.just_fyi("Sending funds from wallet")
amount_to_send = 0.0001
device_time_before_sending = self.wallet_1.driver.device_time
self.wallet_1.send_asset(address='arb1:' + self.receiver['wallet_address'],
asset_name='Ether',
amount=amount_to_send)
self.network_api.wait_for_confirmation_of_transaction(address=self.sender['wallet_address'],
tx_time=device_time_before_sending)
device_time_after_sending = self.wallet_1.driver.device_time
device_time = self.wallet_1.driver.device_time
self._check_balances_after_tx(amount_to_send, sender_balance, receiver_balance, eth_amount_sender,
eth_amount_receiver)
@@ -167,13 +164,10 @@ class TestWalletMultipleDevice(MultipleSharedDeviceTestCase):
self.wallet_1.just_fyi("Sending asset from drawer")
amount_to_send = 0.0001
device_time_before_sending = self.wallet_1.driver.device_time
self.wallet_1.send_asset_from_drawer(address='arb1:' + self.receiver['wallet_address'],
asset_name='Ether',
amount=amount_to_send)
self.network_api.wait_for_confirmation_of_transaction(address=self.sender['wallet_address'],
tx_time=device_time_before_sending)
device_time_after_sending = self.wallet_1.driver.device_time
device_time = self.wallet_1.driver.device_time
self._check_balances_after_tx(amount_to_send, sender_balance, receiver_balance, eth_amount_sender,
eth_amount_receiver)
+6 -5
View File
@@ -372,7 +372,7 @@ class CommunityView(HomeView):
self.community_create_a_channel_button = Button(self.driver, accessibility_id="community-create-channel")
self.channel_name_edit_box = EditBox(self.driver, translation_id="name-your-channel-placeholder")
self.channel_descripton = ChatView(self.driver).community_description_edit_box
self.community_options_button = Button(self.driver, accessibility_id="community-options-for-community")
self.community_options_button = Button(self.driver, accessibility_id="community-menu-button")
self.view_members_button = Button(self.driver, accessibility_id="view-members")
self.community_info_button = Button(self.driver, translation_id="community-info")
self.invite_button = Button(self.driver, accessibility_id="community-invite-people")
@@ -455,10 +455,11 @@ class CommunityView(HomeView):
def copy_community_link(self):
self.driver.info("Copy community link")
self.community_options_button.click()
self.share_community_button.click()
text = self.sharing_text_native.text
self.click_system_back_button(times=2)
return text
self.community_info_button.click()
self.element_starts_with_text('join.status.im/c/').click()
community_link_text = self.element_starts_with_text('join.status.im/c/').text
self.home_button.double_click()
return 'https://%s' % community_link_text
def handle_membership_request(self, username: str, approve=True):
self.driver.info("Handling membership request of user '%s', approve='%s'" % (username, str(approve)))
Binary file not shown.

Before

Width:  |  Height:  |  Size: 172 KiB

After

Width:  |  Height:  |  Size: 172 KiB

+2 -6
View File
@@ -290,11 +290,8 @@ class ProfileView(BaseView):
self.advertise_device_button = Button(self.driver, accessibility_id="advertise-device")
self.sync_all_button = Button(self.driver, translation_id="sync-all-devices")
self.syncing_button = Button(self.driver, accessibility_id="icon, Syncing, label-component, icon")
self.paired_devices_button = Button(self.driver,
accessibility_id="icon, Paired devices, 0 devices, label-component, icon")
self.sync_plus_button = Button(
self.driver,
xpath="//*[@text='Paired devices']/following-sibling::android.view.ViewGroup[@content-desc='icon']")
self.sync_plus_button = Button(self.driver,
xpath="//*[@text='Syncing']/following-sibling::android.view.ViewGroup[1]")
# Keycard
self.keycard_button = Button(self.driver, accessibility_id="keycard-button")
@@ -542,7 +539,6 @@ class ProfileView(BaseView):
def get_sync_code(self):
self.syncing_button.scroll_and_click()
self.paired_devices_button.click()
self.sync_plus_button.click()
for checkbox in Button(
self.driver,
+3 -8
View File
@@ -263,15 +263,11 @@ class SignInView(BaseView):
# self.next_button.click()
# self.identifiers_button.wait_and_click(30)
if enable_notifications:
self.enable_notifications_button.wait_and_click()
for _ in range(3):
self.allow_button.click_if_shown(sec=10)
self.enable_notifications_button.click_if_shown()
if self.start_button.is_element_displayed():
break
self.enable_notifications_button.click_until_presence_of_element(self.start_button)
if self.allow_button.is_element_displayed():
self.allow_button.click()
else:
self.maybe_later_button.click_until_presence_of_element(self.start_button)
self.cancel_button.click_if_shown() # TODO: remove when issue 20806 is fixed
self.start_button.click()
self.chats_tab.wait_for_visibility_of_element(30)
self.driver.info("## New multiaccount is created successfully!", device=False)
@@ -301,7 +297,6 @@ class SignInView(BaseView):
self.enable_notifications_button.click_until_presence_of_element(self.start_button)
else:
self.maybe_later_button.click_until_presence_of_element(self.start_button)
self.cancel_button.click_if_shown() # TODO: remove when issue 20806 is fixed
self.start_button.click()
self.chats_tab.wait_for_visibility_of_element(30)
self.driver.info("## Multiaccount is recovered successfully!", device=False)
+2 -8
View File
@@ -1,5 +1,3 @@
import time
import pytest
from tests import common_password
@@ -122,12 +120,7 @@ class WalletView(BaseView):
self.login_button.click()
def confirm_transaction(self):
self.confirm_button.click()
for _ in range(3):
if self.slide_button_track.is_element_displayed():
break
time.sleep(1)
self.confirm_button.click()
self.confirm_button.click_until_presence_of_element(self.slide_button_track)
self.slide_and_confirm_with_password()
def set_amount(self, amount: float):
@@ -167,6 +160,7 @@ class WalletView(BaseView):
self.add_account_button.click()
self.add_account_to_watch.click()
self.address_to_watch_input.send_keys(address)
self.account_has_activity_label.wait_for_visibility_of_element()
self.add_account_continue_button.click()
SignInView(self.driver).profile_title_input.send_keys(account_name)
self.add_watched_address_button.click()
-2
View File
@@ -1479,7 +1479,6 @@
"max-fees": "Max fees",
"max-priority-fee": "Max priority fee",
"max-slippage": "Max slippage",
"max-token": "Max: {{number}} {{token-symbol}}",
"maximum-fee": "Maximum fee",
"maximum-fee-desc": "Maximum overall price for the transaction. If the current block base fee exceeds this, your transaction will be included in a following block with a lower base fee.",
"may": "May",
@@ -2074,7 +2073,6 @@
"reveal-sync-code": "Reveal sync code",
"review-bridge": "Review bridge",
"review-send": "Review send",
"review-swap": "Review swap",
"revoke-access": "Revoke access",
"ropsten-testnet": "Ropsten Testnet",
"rpc-usage-copy": "Copy",