diff --git a/src/status_im/contexts/wallet/sheets/missing_keypair/style.cljs b/src/status_im/contexts/wallet/sheets/missing_keypair/style.cljs new file mode 100644 index 0000000000..1fd58e9410 --- /dev/null +++ b/src/status_im/contexts/wallet/sheets/missing_keypair/style.cljs @@ -0,0 +1,6 @@ +(ns status-im.contexts.wallet.sheets.missing-keypair.style) + +(def description-container + {:padding-horizontal 20 + :padding-top 4 + :padding-bottom 12}) diff --git a/src/status_im/contexts/wallet/sheets/missing_keypair/view.cljs b/src/status_im/contexts/wallet/sheets/missing_keypair/view.cljs new file mode 100644 index 0000000000..c07ec80a82 --- /dev/null +++ b/src/status_im/contexts/wallet/sheets/missing_keypair/view.cljs @@ -0,0 +1,35 @@ +(ns status-im.contexts.wallet.sheets.missing-keypair.view + (:require + [quo.core :as quo] + [react-native.core :as rn] + [status-im.contexts.wallet.sheets.missing-keypair.style :as style] + [utils.i18n :as i18n] + [utils.re-frame :as rf])) + +(defn view + [{:keys [name emoji color] :as _account} keypair] + (let [customization-color (rf/sub [:profile/customization-color])] + [:<> + [quo/drawer-top + {:title (i18n/label :t/import-keypair-to-use-account) + :type :context-tag + :context-tag-type :account + :account-name name + :emoji emoji + :customization-color color}] + [rn/view {:style style/description-container} + [quo/text {:weight :medium} + (i18n/label :t/import-keypair-steps + {:account-name name + :keypair-name (:name keypair)})]] + [quo/bottom-actions + {:actions :two-actions + :button-one-label (i18n/label :t/import-key-pair) + :button-one-props {:on-press + (fn [] + (rf/dispatch [:navigate-to + :screen/settings.missing-keypair.import-seed-phrase keypair])) + :customization-color customization-color} + :button-two-label (i18n/label :t/not-now) + :button-two-props {:on-press #(rf/dispatch [:hide-bottom-sheet]) + :type :grey}}]])) diff --git a/src/status_im/subs/wallet/wallet.cljs b/src/status_im/subs/wallet/wallet.cljs index 69561b9992..e7f2faaac4 100644 --- a/src/status_im/subs/wallet/wallet.cljs +++ b/src/status_im/subs/wallet/wallet.cljs @@ -5,6 +5,7 @@ [status-im.contexts.wallet.common.utils :as utils] [status-im.contexts.wallet.common.utils.networks :as network-utils] [status-im.contexts.wallet.send.utils :as send-utils] + [status-im.contexts.wallet.sheets.missing-keypair.view :as missing-keypair] [status-im.subs.wallet.add-account.address-to-watch] [utils.number] [utils.security.core :as security])) @@ -329,14 +330,27 @@ :<- [:wallet/balances-in-selected-networks] :<- [:wallet/tokens-loading] :<- [:profile/currency-symbol] - (fn [[accounts balances tokens-loading currency-symbol]] - (mapv (fn [{:keys [color address watch-only?] :as account}] - (assoc account - :customization-color color - :type (if watch-only? :watch-only :empty) - :on-press #(rf/dispatch [:wallet/navigate-to-account address]) - :loading? (get tokens-loading address) - :balance (utils/prettify-balance currency-symbol (get balances address)))) + :<- [:wallet/keypairs] + (fn [[accounts balances tokens-loading currency-symbol keypairs]] + (mapv (fn [{:keys [color key-uid address watch-only? operable] :as account}] + (let [account-type (cond + (= operable :no) :missing-keypair + watch-only? :watch-only + :else :empty) + keypair (first (filter #(= key-uid (:key-uid %)) keypairs))] + (assoc account + :customization-color color + :type account-type + :on-press (if (= account-type :missing-keypair) + (fn [] + (rf/dispatch [:show-bottom-sheet + {:content #(missing-keypair/view + account + keypair)}])) + #(rf/dispatch [:wallet/navigate-to-account address])) + :loading? (get tokens-loading address) + :balance (utils/prettify-balance currency-symbol + (get balances address))))) accounts))) (rf/reg-sub diff --git a/translations/en.json b/translations/en.json index a9b88ba050..675a5eda65 100644 --- a/translations/en.json +++ b/translations/en.json @@ -2703,5 +2703,8 @@ "saved-address-network-preference-selection-description": "Only change if you know which networks the address owner is happy to to receive funds on", "add-preferences": "Add preferences", "buy-eth": "Buy ETH", - "not-enough-assets": "Not enough assets to pay gas fees" + "not-enough-assets": "Not enough assets to pay gas fees", + "import-keypair-to-use-account": "Import key pair to use this account", + "import-keypair-steps": "{{account-name}} was derived from your {{keypair-name}} key pair, which has not yet been imported to this device. To transact using this account, you will need to import the {{keypair-name}} key pair first.", + "not-now": "Not now" }