chore(wallet): add missing keypair to wallet home cards

This commit is contained in:
Jamie Caprani 2024-06-13 15:03:28 +01:00
parent 435bf3dbd5
commit fd1c62fd1e
No known key found for this signature in database
GPG Key ID: 76A2A47D4CD8B428
4 changed files with 67 additions and 9 deletions

View File

@ -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})

View File

@ -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}}]]))

View File

@ -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

View File

@ -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"
}