Skip to content

Commit

Permalink
Getting rid of status-im.multiaccounts.core + removing three word ran…
Browse files Browse the repository at this point in the history
…dom names (#17384)
  • Loading branch information
alwx authored Nov 6, 2023
1 parent fb8a7d2 commit dc571b6
Show file tree
Hide file tree
Showing 76 changed files with 565 additions and 912 deletions.
2 changes: 1 addition & 1 deletion ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ SPEC CHECKSUMS:
RNLanguages: 962e562af0d34ab1958d89bcfdb64fafc37c513e
RNPermissions: ad71dd4f767ec254f2cd57592fbee02afee75467
RNReactNativeHapticFeedback: 2566b468cc8d0e7bb2f84b23adc0f4614594d071
RNReanimated: 62e43ee6baafb9ba3d3af1857d7fd23a1d41bff0
RNReanimated: 42f56dc5c032a11177b9ea12cdb57285318b432e
RNShare: d82e10f6b7677f4b0048c23709bd04098d5aee6c
RNStaticSafeAreaInsets: 055ddbf5e476321720457cdaeec0ff2ba40ec1b8
RNSVG: 80584470ff1ffc7994923ea135a3e5ad825546b9
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1194,21 +1194,6 @@ public String logFileDirectory() {
return getPublicStorageDirectory().getAbsolutePath();
}

@ReactMethod(isBlockingSynchronousMethod = true)
public String generateAlias(final String seed) {
return Statusgo.generateAlias(seed);
}

@ReactMethod
public void generateAliasAsync(final String seed, final Callback callback) throws JSONException {
executeRunnableStatusGoMethod(() -> Statusgo.generateAlias(seed), callback);
}

@ReactMethod(isBlockingSynchronousMethod = true)
public String identicon(final String seed) {
return Statusgo.identicon(seed);
}

@ReactMethod(isBlockingSynchronousMethod = true)
public String encodeTransfer(final String to, final String value) {
return Statusgo.encodeTransfer(to, value);
Expand Down Expand Up @@ -1269,31 +1254,6 @@ public void identiconAsync(final String seed, final Callback callback) throws JS
executeRunnableStatusGoMethod(() -> Statusgo.identicon(seed), callback);
}

@ReactMethod
public void generateAliasAndIdenticonAsync(final String seed, final Callback callback) {

Log.d(TAG, "generateAliasAndIdenticonAsync");
if (!checkAvailability()) {
callback.invoke(false);
return;
}

Runnable r = new Runnable() {
@Override
public void run() {
String resIdenticon = Statusgo.identicon(seed);
String resAlias = Statusgo.generateAlias(seed);

Log.d(TAG, resIdenticon);
Log.d(TAG, resAlias);
callback.invoke(resAlias, resIdenticon);
}
};

StatusThreadPoolExecutor.getInstance().execute(r);

}

@Override
public @Nullable
Map<String, Object> getConstants() {
Expand Down
36 changes: 0 additions & 36 deletions modules/react-native-status/ios/RCTStatus/RCTStatus.m
Original file line number Diff line number Diff line change
Expand Up @@ -880,10 +880,6 @@ - (void) migrateKeystore:(NSString *)accountData
});
}

RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(generateAlias:(NSString *)publicKey) {
return StatusgoGenerateAlias(publicKey);
}

RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(keystoreDir) {
NSFileManager *fileManager = [NSFileManager defaultManager];
NSURL *rootUrl =[[fileManager
Expand Down Expand Up @@ -943,19 +939,6 @@ - (void) migrateKeystore:(NSString *)accountData
callback(@[initResult]);
}

RCT_EXPORT_METHOD(generateAliasAsync:(NSString *)publicKey
callback:(RCTResponseSenderBlock)callback) {
#if DEBUG
NSLog(@"generateAliasAsync() method called");
#endif
NSString *result = StatusgoGenerateAlias(publicKey);
callback(@[result]);
}

RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(identicon:(NSString *)publicKey) {
return StatusgoIdenticon(publicKey);
}

RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(encodeTransfer:(NSString *)to
value:(NSString *)value) {
return StatusgoEncodeTransfer(to,value);
Expand Down Expand Up @@ -1011,15 +994,6 @@ - (void) migrateKeystore:(NSString *)accountData
callback(@[result]);
}

RCT_EXPORT_METHOD(identiconAsync:(NSString *)publicKey
callback:(RCTResponseSenderBlock)callback) {
#if DEBUG
NSLog(@"identiconAsync() method called");
#endif
NSString *result = StatusgoIdenticon(publicKey);
callback(@[result]);
}

RCT_EXPORT_METHOD(createAccountAndLogin:(NSString *)request) {
#if DEBUG
NSLog(@"createAccountAndLogin() method called");
Expand All @@ -1034,16 +1008,6 @@ - (void) migrateKeystore:(NSString *)accountData
StatusgoRestoreAccountAndLogin(request);
}

RCT_EXPORT_METHOD(generateAliasAndIdenticonAsync:(NSString *)publicKey
callback:(RCTResponseSenderBlock)callback) {
#if DEBUG
NSLog(@"generateAliasAndIdenticonAsync() method called");
#endif
NSString *identiconResult = StatusgoIdenticon(publicKey);
NSString *aliasResult = StatusgoGenerateAlias(publicKey);
callback(@[aliasResult, identiconResult]);
}

RCT_EXPORT_METHOD(callPrivateRPC:(NSString *)payload
callback:(RCTResponseSenderBlock)callback) {
dispatch_async( dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
Expand Down
66 changes: 0 additions & 66 deletions modules/react-native-status/nodejs/status.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,38 +354,6 @@ void _StopCPUProfiling(const FunctionCallbackInfo<Value>& args) {

}

void _Identicon(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 Identicon")));
return;
}

// Check the argument types

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


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

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

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

}

void _EncodeTransfer(const FunctionCallbackInfo<Value>& args) {
Isolate* isolate = args.GetIsolate();
Local<Context> context = isolate->GetCurrentContext();
Expand Down Expand Up @@ -864,38 +832,6 @@ void _CreateAccountAndLogin(const FunctionCallbackInfo<Value>& args) {

}

void _GenerateAlias(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 GenerateAlias")));
return;
}

// Check the argument types

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


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

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

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

}

void _ValidateMnemonic(const FunctionCallbackInfo<Value>& args) {
Isolate* isolate = args.GetIsolate();
Local<Context> context = isolate->GetCurrentContext();
Expand Down Expand Up @@ -1953,7 +1889,6 @@ void init(Local<Object> exports) {
NODE_SET_METHOD(exports, "multiAccountStoreAccount", _MultiAccountStoreAccount);
NODE_SET_METHOD(exports, "initKeystore", _InitKeystore);
NODE_SET_METHOD(exports, "stopCPUProfiling", _StopCPUProfiling);
NODE_SET_METHOD(exports, "identicon", _Identicon);
NODE_SET_METHOD(exports, "encodeTransfer", _EncodeTransfer);
NODE_SET_METHOD(exports, "encodeFunctionCall", _EncodeFunctionCall);
NODE_SET_METHOD(exports, "decodeParameters", _DecodeParameters);
Expand All @@ -1968,7 +1903,6 @@ void init(Local<Object> exports) {
NODE_SET_METHOD(exports, "resetChainData", _ResetChainData);
NODE_SET_METHOD(exports, "saveAccountAndLogin", _SaveAccountAndLogin);
NODE_SET_METHOD(exports, "createAccountAndLogin", _CreateAccountAndLogin);
NODE_SET_METHOD(exports, "generateAlias", _GenerateAlias);
NODE_SET_METHOD(exports, "validateMnemonic", _ValidateMnemonic);
NODE_SET_METHOD(exports, "multiformatSerializePublicKey", _MultiformatSerializePublicKey);
NODE_SET_METHOD(exports, "saveAccountAndLoginWithKeycard", _SaveAccountAndLoginWithKeycard);
Expand Down
22 changes: 1 addition & 21 deletions src/native_module/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
[clojure.string :as string]
[react-native.platform :as platform]
[taoensso.timbre :as log]
[utils.transforms :as types]
[utils.validators :as validators]))
[utils.transforms :as types]))

(defn status
[]
Expand Down Expand Up @@ -431,19 +430,6 @@
;; in unknown scenarios we also consider the device rooted to avoid degrading security
:else (callback true)))

(defn generate-gfycat
"Generate a 3 words random name based on the user public-key, synchronously"
[public-key]
(log/debug "[native-module] generate-gfycat")
(when (validators/valid-public-key? public-key)
(.generateAlias ^js (status) public-key)))

(defn identicon
"Generate a icon based on a string, synchronously"
[seed]
(log/debug "[native-module] identicon")
(.identicon ^js (status) seed))

(defn encode-transfer
[to-norm amount-hex]
(log/debug "[native-module] encode-transfer")
Expand Down Expand Up @@ -501,12 +487,6 @@
(log/debug "[native-module] to-checksum-address")
(.toChecksumAddress ^js (status) address))

(defn gfycat-identicon-async
"Generate an icon based on a string and 3 words random name asynchronously"
[seed callback]
(log/debug "[native-module] gfycat-identicon-async")
(.generateAliasAndIdenticonAsync ^js (status) seed callback))

(defn validate-mnemonic
"Validate that a mnemonic conforms to BIP39 dictionary/checksum standards"
[mnemonic callback]
Expand Down
6 changes: 0 additions & 6 deletions src/status_im/contact/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,3 @@
:group/selected-contacts #{}
:new-chat-name "")}
(navigation/navigate-to :contact-toggle-list nil)))

(defn displayed-photo
[{:keys [images]}]
(or (:large images)
(:thumbnail images)
(first images)))
23 changes: 9 additions & 14 deletions src/status_im/contact/db.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,12 @@
(:require
[clojure.set :as set]
[clojure.string :as string]
[status-im.utils.gfycat.core :as gfycat]
[status-im2.constants :as constants]
[utils.address :as address]))

(defn public-key->new-contact
[public-key]
(let [alias (gfycat/generate-gfy public-key)]
{:alias alias
:name alias
:primary-name alias
:public-key public-key}))

(defn public-key-and-ens-name->new-contact
[public-key ens-name]
(let [contact (public-key->new-contact public-key)]
(let [contact {:public-key public-key}]
(if ens-name
(-> contact
(assoc :ens-name ens-name)
Expand All @@ -27,8 +18,7 @@
(defn public-key->contact
[contacts public-key]
(when public-key
(or (get contacts public-key)
(public-key->new-contact public-key))))
(get contacts public-key {:public-key public-key})))

(defn- contact-by-address
[[addr contact] address]
Expand Down Expand Up @@ -66,8 +56,13 @@
(assoc public-key current-contact))]
(->> members
(map #(or (get all-contacts %)
(public-key->new-contact %)))
(sort-by (comp string/lower-case #(or (:primary-name %) (:name %) (:alias %))))
{:public-key %}))
(sort-by (comp string/lower-case
(fn [{:keys [primary-name name alias public-key]}]
(or primary-name
name
alias
public-key))))
(map #(if (get admins (:public-key %))
(assoc % :admin? true)
%)))))
Expand Down
Loading

0 comments on commit dc571b6

Please sign in to comment.