Skip to content

Commit

Permalink
move login out/login to account recovery step
Browse files Browse the repository at this point in the history
  • Loading branch information
J-Son89 committed Feb 19, 2024
1 parent 2093ac8 commit 1951d54
Show file tree
Hide file tree
Showing 9 changed files with 129 additions and 220 deletions.
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -347,11 +347,9 @@ _test-clojure: export TARGET := clojure
_test-clojure: export WATCH ?= false
_test-clojure:
ifeq ($(WATCH), true)
yarn install && \
yarn shadow-cljs compile mocks && \
nodemon --exec "yarn shadow-cljs compile test && node --require ./test-resources/override.js $$SHADOW_OUTPUT_TO" -e cljs
else
yarn install && \
yarn shadow-cljs compile mocks && \
yarn shadow-cljs compile test && \
node --require ./test-resources/override.js "$$SHADOW_OUTPUT_TO"
Expand Down
32 changes: 32 additions & 0 deletions modules/react-native-status/nodejs/status.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,37 @@ void _ToChecksumAddress(const FunctionCallbackInfo<Value>& args) {

}


void _LoginAccount(const FunctionCallbackInfo<Value>& args) {
Isolate* isolate = args.GetIsolate();
Local<Context> context = isolate->GetCurrentContext();

if (args.Length() != 1) {
// Throw an Error that is passed back to JavaScript
isolate->ThrowException(Exception::TypeError(
String::NewFromUtf8Literal(isolate, "Wrong number of arguments for Login")));
return;
}

// Check the argument types

if (!args[0]->IsString()) {
isolate->ThrowException(Exception::TypeError(
String::NewFromUtf8Literal(isolate, "Wrong argument type for 'passwords'")));
return;
}

String::Utf8Value arg0Obj(isolate, args[0]->ToString(context).ToLocalChecked());
char *arg0 = *arg0Obj;

// Call exported Go function, which returns a C string
char *c = LoginAccount(arg0);

Local<String> ret = String::NewFromUtf8(isolate, c).ToLocalChecked();
args.GetReturnValue().Set(ret);
delete c;
}

void _Logout(const FunctionCallbackInfo<Value>& args) {
Isolate* isolate = args.GetIsolate();

Expand Down Expand Up @@ -1941,6 +1972,7 @@ void init(Local<Object> exports) {
NODE_SET_METHOD(exports, "isAddress", _IsAddress);
NODE_SET_METHOD(exports, "sha3", _Sha3);
NODE_SET_METHOD(exports, "toChecksumAddress", _ToChecksumAddress);
NODE_SET_METHOD(exports, "loginAccount", _LoginAccount);
NODE_SET_METHOD(exports, "logout", _Logout);
NODE_SET_METHOD(exports, "hashMessage", _HashMessage);
NODE_SET_METHOD(exports, "resetChainData", _ResetChainData);
Expand Down
2 changes: 1 addition & 1 deletion src/status_im/config.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

(defn enabled? [v] (= "1" v))

(goog-define INFURA_TOKEN "")
(goog-define INFURA_TOKEN "d7aaebc4a3584b5198682ced53801cd3")
(goog-define POKT_TOKEN "3ef2018191814b7e1009b8d9")
(goog-define OPENSEA_API_KEY "")
(goog-define RARIBLE_MAINNET_API_KEY "")
Expand Down
8 changes: 4 additions & 4 deletions src/test_helpers/integration.clj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
(do
(rf/dispatch [:app-started])
(rf-test/wait-for [:profile/get-profiles-overview-success]
~@body)))))
~@body)))))

(defmacro with-account
[& body]
Expand All @@ -20,15 +20,15 @@
(do
(test-helpers.integration/create-multiaccount!)
(rf-test/wait-for [:messenger-started]
(test-helpers.integration/assert-messenger-started)
~@body))))
(test-helpers.integration/assert-messenger-started)
~@body))))

(defmacro with-recovered-account
[& body]
`(if (test-helpers.integration/messenger-started)
(do ~@body)
(do
(test-helpers.integration/recover-multiaccount! "destroy end torch puzzle develop note wise island disease chaos kind bus")
(rf-test/wait-for [:messenger-started]
(rf-test/wait-for [:wallet/start-wallet]
(test-helpers.integration/assert-messenger-started)
~@body))))
83 changes: 38 additions & 45 deletions src/test_helpers/integration.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
[utils.transforms :as transforms]))

(defn validate-mnemonic [mnemonic on-success on-error]
(prn "MNENMOMCIC" mnemonic)
(native-module/validate-mnemonic
(security/safe-unmask-data mnemonic)
(fn [result]
Expand All @@ -33,57 +32,51 @@
(rf/dispatch [:profile.create/create-and-login
{:display-name constants/account-name :password constants/password :color "blue"}]))

;; (rf/reg-fx :do (fn [_ [seed-phrase on-error]]
;; (prn "seed-phrase")
;; (prn seed-phrase)
;; {:fx [[:dispatch [:multiaccount/validate-mnemonic [seed-phrase
;; (fn [mnemonic key-uid]
;; (prn "|||||||||||||")
;; (prn mnemonic)
;; (prn key-uid)
;; (prn "|||||||||||||")

;; (rf/dispatch [:onboarding/seed-phrase-validated
;; mnemonic key-uid])
;; (rf/dispatch [:pop-to-root :profiles])
;; (rf/dispatch [:profile/profile-selected key-uid]))
;; on-error]]]]}))


(defn recover-multiaccount2!
[seed-phrase]
(rf/dispatch [:profile.recover/recover-and-login
{:display-name constants/recovery-account-name
:seed-phrase seed-phrase
:password constants/password
:color "blue"}]))
(rf/dispatch [:profile.recover/recover-and-login
{:display-name constants/recovery-account-name
:seed-phrase seed-phrase
:password constants/password
:color "blue"}]))

;0x48b8b9e2a8f71e1beae729d83bcd385ffc6af0d5

(def ^:const seed-phrase "destroy end torch puzzle develop note wise island disease chaos kind bus")

(defn recover-multiaccount!
[_seed-phrase]
(let [x (security/mask-data "destroy end torch puzzle develop note wise island disease chaos kind bus")]
;; (prn "--------------")
;; (prn seed-phrase)
;; (prn "--------------")

(validate-mnemonic
x
(fn [mnemonic key-uid]
;; (prn "|||||||||||||")
;; (prn mnemonic)
;; (prn key-uid)
;; (prn "|||||||||||||")

(rf/dispatch [:onboarding/seed-phrase-validated
(security/mask-data mnemonic) key-uid])
(rf/dispatch [:pop-to-root :profiles])
(rf/dispatch [:profile/profile-selected key-uid])
(recover-multiaccount2! "destroy end torch puzzle develop note wise island disease chaos kind bus")
)
prn)
;; (prn "HHERHEHRHHHEELLLOOPP")
))
(let [x (security/mask-data "destroy end torch puzzle develop note wise island disease chaos kind bus")
p (js/Promise. (fn [res _rej]
(validate-mnemonic
x
(fn [mnemonic key-uid]
(rf/dispatch [:onboarding/seed-phrase-validated
(security/mask-data mnemonic) key-uid])
(rf/dispatch [:pop-to-root :profiles])
(rf/dispatch [:profile/profile-selected key-uid])
(recover-multiaccount2! mnemonic)
(res key-uid))
prn)))]


(.then p (fn [response]
(let [y (js/Promise. (fn [res _reject]
(js/setTimeout
(fn []
(rf/dispatch [:profile.settings/profile-update :test-networks-enabled?
true {}])

(rf/dispatch [:profile.settings/profile-update :is-sepolia-enabled?
true {:on-success (fn [] (rf/dispatch [:logout]))}])
(res))
12000)))]
(.then y (fn []
(rf/dispatch [:set-in [:profile/login :key-uid]
response])
(rf/dispatch [:set-in [:profile/login :password]
constants/password])
(rf/dispatch [:profile.login/login]))))))))

(defn app-initialized
[]
Expand Down
96 changes: 0 additions & 96 deletions src/tests/integration_test/chat_test.cljs

This file was deleted.

58 changes: 0 additions & 58 deletions src/tests/integration_test/profile_test.cljs

This file was deleted.

Loading

0 comments on commit 1951d54

Please sign in to comment.