Merge branch 'develop' into cl-21618-dapps-keycard-signing
This commit is contained in:
commit
0983e41d70
|
@ -22,12 +22,7 @@
|
||||||
[(if keycard?
|
[(if keycard?
|
||||||
(if keycard-supported?
|
(if keycard-supported?
|
||||||
[:effects.keycard/call-on-auth-success on-auth-success]
|
[:effects.keycard/call-on-auth-success on-auth-success]
|
||||||
[:effects.utils/show-popup
|
[:dispatch [:keycard/feature-unavailable-show]])
|
||||||
{:title "This feature is not supported yet "
|
|
||||||
:content
|
|
||||||
"Keycard support is limited to logging in
|
|
||||||
and signing the sending transaction.
|
|
||||||
Use Status Desktop to access all functions."}])
|
|
||||||
[:effects.biometric/check-if-available
|
[:effects.biometric/check-if-available
|
||||||
{:key-uid key-uid
|
{:key-uid key-uid
|
||||||
:on-success #(rf/dispatch [:standard-auth/authorize-with-biometric args])
|
:on-success #(rf/dispatch [:standard-auth/authorize-with-biometric args])
|
||||||
|
|
|
@ -329,6 +329,7 @@
|
||||||
(def ^:const privacy-policy-link "https://status.im/privacy-policy/")
|
(def ^:const privacy-policy-link "https://status.im/privacy-policy/")
|
||||||
(def ^:const terms-of-service-link "https://status.im/terms-of-use")
|
(def ^:const terms-of-service-link "https://status.im/terms-of-use")
|
||||||
(def ^:const create-account-link "https://status.app/help/wallet/create-wallet-accounts")
|
(def ^:const create-account-link "https://status.app/help/wallet/create-wallet-accounts")
|
||||||
|
(def ^:const mobile-upvote-link "https://status-mobile.featureupvote.com")
|
||||||
|
|
||||||
(def ^:const visibility-status-unknown 0)
|
(def ^:const visibility-status-unknown 0)
|
||||||
(def ^:const visibility-status-automatic 1)
|
(def ^:const visibility-status-automatic 1)
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
(ns status-im.contexts.keycard.feature-unavailable.events
|
||||||
|
(:require
|
||||||
|
[status-im.contexts.keycard.feature-unavailable.view :as feature-unavailable]
|
||||||
|
[utils.re-frame :as rf]))
|
||||||
|
|
||||||
|
(rf/reg-event-fx
|
||||||
|
:keycard/feature-unavailable-show
|
||||||
|
(fn [_]
|
||||||
|
{:fx [[:dispatch [:show-bottom-sheet {:content feature-unavailable/view}]]]}))
|
|
@ -0,0 +1,28 @@
|
||||||
|
(ns status-im.contexts.keycard.feature-unavailable.view
|
||||||
|
(:require
|
||||||
|
[quo.core :as quo]
|
||||||
|
[status-im.constants :as constants]
|
||||||
|
[utils.i18n :as i18n]
|
||||||
|
[utils.re-frame :as rf]))
|
||||||
|
|
||||||
|
(defn on-upvote
|
||||||
|
[]
|
||||||
|
(rf/dispatch [:open-url constants/mobile-upvote-link]))
|
||||||
|
|
||||||
|
(defn view
|
||||||
|
[]
|
||||||
|
[:<>
|
||||||
|
[quo/drawer-top
|
||||||
|
{:title (i18n/label :t/feature-unavailable)
|
||||||
|
:description (i18n/label :t/feature-unavailable-for-keycard-description)}]
|
||||||
|
[quo/information-box
|
||||||
|
{:type :default
|
||||||
|
:icon :i/info
|
||||||
|
:style {:margin-top 8 :margin-horizontal 20}}
|
||||||
|
[:<>
|
||||||
|
(i18n/label :t/feature-unavailable-info)
|
||||||
|
[quo/text
|
||||||
|
{:style {:text-decoration-line :underline}
|
||||||
|
:size :paragraph-2
|
||||||
|
:on-press on-upvote}
|
||||||
|
(i18n/label :t/upvote-it)]]]])
|
|
@ -30,7 +30,8 @@
|
||||||
type :no-title}}]
|
type :no-title}}]
|
||||||
(let [{:keys [color emoji watch-only?]} (rf/sub [:wallet/current-viewing-account])
|
(let [{:keys [color emoji watch-only?]} (rf/sub [:wallet/current-viewing-account])
|
||||||
networks (rf/sub [:wallet/selected-network-details])
|
networks (rf/sub [:wallet/selected-network-details])
|
||||||
sending-collectible? (rf/sub [:wallet/sending-collectible?])]
|
sending-collectible? (rf/sub [:wallet/sending-collectible?])
|
||||||
|
keycard? (rf/sub [:wallet/selected-keypair-keycard?])]
|
||||||
[quo/page-nav
|
[quo/page-nav
|
||||||
{:type type
|
{:type type
|
||||||
:icon-name icon-name
|
:icon-name icon-name
|
||||||
|
@ -45,7 +46,10 @@
|
||||||
(not watch-only?)
|
(not watch-only?)
|
||||||
show-dapps-button?)
|
show-dapps-button?)
|
||||||
{:icon-name :i/dapps
|
{:icon-name :i/dapps
|
||||||
:on-press #(rf/dispatch [:navigate-to :screen/wallet.connected-dapps])})
|
:on-press #(rf/dispatch
|
||||||
|
(if keycard?
|
||||||
|
[:keycard/feature-unavailable-show]
|
||||||
|
[:navigate-to :screen/wallet.connected-dapps]))})
|
||||||
(when-not sending-collectible?
|
(when-not sending-collectible?
|
||||||
{:content-type :account-switcher
|
{:content-type :account-switcher
|
||||||
:customization-color color
|
:customization-color color
|
||||||
|
|
|
@ -291,3 +291,10 @@
|
||||||
(cske/transform-keys transforms/->kebab-case-keyword)
|
(cske/transform-keys transforms/->kebab-case-keyword)
|
||||||
(map #(assoc % :unique-id (collectible-utils/get-collectible-unique-id %)))
|
(map #(assoc % :unique-id (collectible-utils/get-collectible-unique-id %)))
|
||||||
vec))
|
vec))
|
||||||
|
|
||||||
|
(defn selected-keypair-keycard?
|
||||||
|
[db]
|
||||||
|
(let [keypairs (get-in db [:wallet :keypairs])
|
||||||
|
selected-keypair-uid (get-in db [:wallet :ui :create-account :selected-keypair-uid])
|
||||||
|
keypair (get keypairs selected-keypair-uid)]
|
||||||
|
(boolean (seq (:keycards keypair)))))
|
||||||
|
|
|
@ -231,3 +231,37 @@
|
||||||
:wallet true
|
:wallet true
|
||||||
:default-account? true})]}}}
|
:default-account? true})]}}}
|
||||||
(sut/reconcile-keypairs [raw-keypair-profile])))))
|
(sut/reconcile-keypairs [raw-keypair-profile])))))
|
||||||
|
|
||||||
|
(def mock-db
|
||||||
|
{:wallet {:keypairs
|
||||||
|
{"0x123" {:type "key"
|
||||||
|
:key-uid "0x123"
|
||||||
|
:keycards [{:id "keycard1"}]}
|
||||||
|
"0x456" {:type "key"
|
||||||
|
:key-uid "0x456"
|
||||||
|
:keycards []}}
|
||||||
|
:ui {:create-account {:selected-keypair-uid "0x123"}}}})
|
||||||
|
|
||||||
|
(deftest selected-keypair-keycard?-test
|
||||||
|
(testing "returns true when the selected keypair has keycards"
|
||||||
|
(is (true? (sut/selected-keypair-keycard? mock-db))))
|
||||||
|
|
||||||
|
(testing "returns false when the selected keypair does not have keycards"
|
||||||
|
(let [db (assoc-in mock-db [:wallet :ui :create-account :selected-keypair-uid] "0x456")]
|
||||||
|
(is (false? (sut/selected-keypair-keycard? db)))))
|
||||||
|
|
||||||
|
(testing "returns false when the selected keypair does not exist"
|
||||||
|
(let [db (assoc-in mock-db [:wallet :ui :create-account :selected-keypair-uid] "0x789")]
|
||||||
|
(is (false? (sut/selected-keypair-keycard? db)))))
|
||||||
|
|
||||||
|
(testing "returns false when keypairs map is empty"
|
||||||
|
(let [db (assoc-in mock-db [:wallet :keypairs] {})]
|
||||||
|
(is (false? (sut/selected-keypair-keycard? db)))))
|
||||||
|
|
||||||
|
(testing "returns false when no keypair is selected"
|
||||||
|
(let [db (assoc-in mock-db [:wallet :ui :create-account :selected-keypair-uid] nil)]
|
||||||
|
(is (false? (sut/selected-keypair-keycard? db)))))
|
||||||
|
|
||||||
|
(testing "returns false when db does not contain wallet data"
|
||||||
|
(let [db {}]
|
||||||
|
(is (false? (sut/selected-keypair-keycard? db))))))
|
||||||
|
|
|
@ -102,6 +102,7 @@
|
||||||
:wallet/wallet-send-tx-type :tx/send
|
:wallet/wallet-send-tx-type :tx/send
|
||||||
:wallet/wallet-send-fee-fiat-formatted "$5,00"
|
:wallet/wallet-send-fee-fiat-formatted "$5,00"
|
||||||
:wallet/sending-collectible? false
|
:wallet/sending-collectible? false
|
||||||
|
:wallet/selected-keypair-keycard? false
|
||||||
:wallet/send-total-amount-formatted "250 ETH"
|
:wallet/send-total-amount-formatted "250 ETH"
|
||||||
:wallet/total-amount (money/bignumber "250")
|
:wallet/total-amount (money/bignumber "250")
|
||||||
:wallet/prices-per-token {:ETH {:usd 10}}
|
:wallet/prices-per-token {:ETH {:usd 10}}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
(:require [clojure.string :as string]
|
(:require [clojure.string :as string]
|
||||||
[re-frame.core :as rf]
|
[re-frame.core :as rf]
|
||||||
[react-native.wallet-connect :as wallet-connect]
|
[react-native.wallet-connect :as wallet-connect]
|
||||||
|
[status-im.contexts.wallet.data-store :as wallet-data-store]
|
||||||
[status-im.contexts.wallet.wallet-connect.utils.data-store :as
|
[status-im.contexts.wallet.wallet-connect.utils.data-store :as
|
||||||
data-store]
|
data-store]
|
||||||
[status-im.contexts.wallet.wallet-connect.utils.networks :as networks]
|
[status-im.contexts.wallet.wallet-connect.utils.networks :as networks]
|
||||||
|
@ -30,11 +31,17 @@
|
||||||
expired? (-> parsed-uri
|
expired? (-> parsed-uri
|
||||||
:expiryTimestamp
|
:expiryTimestamp
|
||||||
uri/timestamp-expired?)
|
uri/timestamp-expired?)
|
||||||
version-supported? (uri/version-supported? version)]
|
version-supported? (uri/version-supported? version)
|
||||||
(if (or (not valid-wc-uri?)
|
keycard? (wallet-data-store/selected-keypair-keycard? db)]
|
||||||
(not version-supported?)
|
(cond
|
||||||
(= network-status :offline)
|
|
||||||
expired?)
|
keycard?
|
||||||
|
{:fx [[:dispatch [:keycard/feature-unavailable-show]]]}
|
||||||
|
|
||||||
|
(or (not valid-wc-uri?)
|
||||||
|
(not version-supported?)
|
||||||
|
(= network-status :offline)
|
||||||
|
expired?)
|
||||||
{:fx [[:dispatch
|
{:fx [[:dispatch
|
||||||
[:toasts/upsert
|
[:toasts/upsert
|
||||||
{:type :negative
|
{:type :negative
|
||||||
|
@ -54,6 +61,8 @@
|
||||||
|
|
||||||
:else
|
:else
|
||||||
(i18n/label :t/something-went-wrong))}]]]}
|
(i18n/label :t/something-went-wrong))}]]]}
|
||||||
|
|
||||||
|
:else
|
||||||
{:fx [[:dispatch [:wallet-connect/pair scanned-text]]]}))))
|
{:fx [[:dispatch [:wallet-connect/pair scanned-text]]]}))))
|
||||||
|
|
||||||
(rf/reg-event-fx
|
(rf/reg-event-fx
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
status-im.contexts.contact.blocking.events
|
status-im.contexts.contact.blocking.events
|
||||||
status-im.contexts.keycard.effects
|
status-im.contexts.keycard.effects
|
||||||
status-im.contexts.keycard.events
|
status-im.contexts.keycard.events
|
||||||
|
status-im.contexts.keycard.feature-unavailable.events
|
||||||
status-im.contexts.network.effects
|
status-im.contexts.network.effects
|
||||||
status-im.contexts.network.events
|
status-im.contexts.network.events
|
||||||
status-im.contexts.onboarding.common.overlay.events
|
status-im.contexts.onboarding.common.overlay.events
|
||||||
|
|
|
@ -286,6 +286,12 @@
|
||||||
:<- [:wallet/create-account]
|
:<- [:wallet/create-account]
|
||||||
:-> :selected-keypair-uid)
|
:-> :selected-keypair-uid)
|
||||||
|
|
||||||
|
(rf/reg-sub
|
||||||
|
:wallet/selected-keypair-keycard?
|
||||||
|
:<- [:wallet/selected-keypair]
|
||||||
|
(fn [{:keys [keycards]}]
|
||||||
|
(boolean (seq keycards))))
|
||||||
|
|
||||||
(rf/reg-sub
|
(rf/reg-sub
|
||||||
:wallet/selected-keypair
|
:wallet/selected-keypair
|
||||||
:<- [:wallet/keypairs]
|
:<- [:wallet/keypairs]
|
||||||
|
|
|
@ -1133,3 +1133,25 @@
|
||||||
"0")
|
"0")
|
||||||
:has-error false}}}]}}))
|
:has-error false}}}]}}))
|
||||||
(is (false? (rf/sub [sub-name])))))
|
(is (false? (rf/sub [sub-name])))))
|
||||||
|
|
||||||
|
(h/deftest-sub :wallet/selected-keypair-keycard?
|
||||||
|
[sub-name]
|
||||||
|
(testing "returns true if the selected keypair has keycards"
|
||||||
|
(swap! rf-db/app-db
|
||||||
|
#(assoc-in %
|
||||||
|
[:wallet :keypairs]
|
||||||
|
{:keypair-1 {:id :keypair-1
|
||||||
|
:keycards [:keycard-1 :keycard-2]}}))
|
||||||
|
(swap! rf-db/app-db
|
||||||
|
#(assoc-in % [:wallet :ui :create-account :selected-keypair-uid] :keypair-1))
|
||||||
|
(is (true? (rf/sub [sub-name]))))
|
||||||
|
|
||||||
|
(testing "returns false if the selected keypair has no keycards"
|
||||||
|
(swap! rf-db/app-db
|
||||||
|
#(assoc-in %
|
||||||
|
[:wallet :keypairs]
|
||||||
|
{:keypair-2 {:id :keypair-2
|
||||||
|
:keycards []}}))
|
||||||
|
(swap! rf-db/app-db
|
||||||
|
#(assoc-in % [:wallet :ui :create-account :selected-keypair-uid] :keypair-2))
|
||||||
|
(is (false? (rf/sub [sub-name])))))
|
||||||
|
|
|
@ -1037,6 +1037,9 @@
|
||||||
"favourite-description": "Your favourite websites will appear here",
|
"favourite-description": "Your favourite websites will appear here",
|
||||||
"favourites": "Favourites",
|
"favourites": "Favourites",
|
||||||
"favourites-empty": "Addresses added to favourites will appear here",
|
"favourites-empty": "Addresses added to favourites will appear here",
|
||||||
|
"feature-unavailable": "Feature unavailable",
|
||||||
|
"feature-unavailable-for-keycard-description": "It’s not currently supported for Keycard users.",
|
||||||
|
"feature-unavailable-info": "If you'd like this feature on mobile, feel free to ",
|
||||||
"featured": "Featured",
|
"featured": "Featured",
|
||||||
"feb": "Feb",
|
"feb": "Feb",
|
||||||
"fee-cap": "Fee cap",
|
"fee-cap": "Fee cap",
|
||||||
|
@ -2719,6 +2722,7 @@
|
||||||
"update-to-see-sticker": "Update to latest version to see a nice sticker here!",
|
"update-to-see-sticker": "Update to latest version to see a nice sticker here!",
|
||||||
"updates-to-tos": "Updates to Terms of Use",
|
"updates-to-tos": "Updates to Terms of Use",
|
||||||
"updates-to-tos-desc": "Before you continue, please review the Terms of Use and confirm you take full responsibility for how you use the app.",
|
"updates-to-tos-desc": "Before you continue, please review the Terms of Use and confirm you take full responsibility for how you use the app.",
|
||||||
|
"upvote-it": "upvote it",
|
||||||
"url": "URL",
|
"url": "URL",
|
||||||
"usage-data-shared-from-all-profiles": "Usage data will be shared from all profiles added to device. ",
|
"usage-data-shared-from-all-profiles": "Usage data will be shared from all profiles added to device. ",
|
||||||
"usd-currency": "USD",
|
"usd-currency": "USD",
|
||||||
|
|
Loading…
Reference in New Issue