-
Notifications
You must be signed in to change notification settings - Fork 984
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#20035] feat: import missing key pair by scanning QR code
- Loading branch information
1 parent
9de8613
commit 2c79af9
Showing
10 changed files
with
159 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/status_im/contexts/settings/wallet/keypairs_and_accounts/scan_qr/view.cljs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
(ns status-im.contexts.settings.wallet.keypairs-and-accounts.scan-qr.view | ||
(:require | ||
[status-im.common.scan-qr-code.view :as scan-qr-code] | ||
[status-im.contexts.communities.events] | ||
[status-im.contexts.syncing.utils :as sync-utils] | ||
[utils.debounce :as debounce] | ||
[utils.i18n :as i18n] | ||
[utils.re-frame :as rf])) | ||
|
||
(def invalid-qr-toast | ||
{:type :negative | ||
:theme :dark | ||
:text (i18n/label :t/invalid-qr)}) | ||
|
||
(defn show-invalid-qr-toast | ||
[] | ||
(debounce/debounce-and-dispatch | ||
[:toasts/upsert invalid-qr-toast] | ||
300)) | ||
|
||
(defn- on-valid-connection-received | ||
[connection-string keypairs-key-uids] | ||
(rf/dispatch | ||
[:standard-auth/authorize-with-password | ||
{:blur? true | ||
:theme :dark | ||
:auth-button-label (i18n/label :t/confirm) | ||
:on-auth-success (fn [password] | ||
(rf/dispatch [:hide-bottom-sheet]) | ||
(rf/dispatch | ||
[:wallet/connection-string-for-key-pair-import | ||
{:connection-string connection-string | ||
:keypairs-key-uids keypairs-key-uids | ||
:sha3-pwd password}]))}])) | ||
|
||
(defn on-qr-code-scanned | ||
[scanned-text keypairs-key-uids] | ||
(if (sync-utils/valid-connection-string? scanned-text) | ||
(on-valid-connection-received scanned-text keypairs-key-uids) | ||
(show-invalid-qr-toast))) | ||
|
||
(defn view | ||
[] | ||
(let [keypairs (rf/sub [:get-screen-params]) | ||
keypairs-key-uids (map :key-uid keypairs)] | ||
[scan-qr-code/view | ||
{:title (i18n/label :t/scan-key-pairs-qr-code) | ||
:subtitle (i18n/label :t/find-it-in-setting) | ||
:share-button? false | ||
:on-success-scan #(on-qr-code-scanned % keypairs-key-uids)}])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters