Add gfycat/identicon from status-go

Signed-off-by: yenda <eric@status.im>
This commit is contained in:
Andrea Maria Piana 2019-09-12 11:41:25 +02:00 committed by yenda
parent 42a65a7a1e
commit acd7e56d1d
No known key found for this signature in database
GPG Key ID: 0095623C0069DCE6
46 changed files with 613 additions and 3631 deletions

View File

@ -14,7 +14,6 @@
"react-native-status-keycard"
"react-native-camera"
"qrcode"
"identicon.js"
"react-native-fs"
"react-native-dialogs"
"react-native-image-resizer"

View File

@ -126,6 +126,8 @@ var TopLevel = {
"exists" : function () {},
"extPost" : function () {},
"extractGroupMembershipSignatures" : function () {},
"identicon": function() {},
"generateAlias": function() {},
"fallbacks" : function () {},
"fetch" : function () {},
"firebase" : function () {},

View File

@ -16,7 +16,6 @@
"hermes-engine": "0.2.1",
"hi-base32": "^0.5.0",
"i18n-js": "^3.3.0",
"identicon.js": "git+https://github.com/status-im/identicon.js.git#v1.2.1-status",
"qrcode": "^1.4.1",
"react": "16.8.6",
"react-dom": "16.4.2",

View File

@ -1154,6 +1154,17 @@ class StatusModule extends ReactContextBaseJavaModule implements LifecycleEventL
StatusThreadPoolExecutor.getInstance().execute(r);
}
@ReactMethod(isBlockingSynchronousMethod = true)
public String generateAlias(final String seed) {
return Statusgo.generateAlias(seed);
}
@ReactMethod(isBlockingSynchronousMethod = true)
public String identicon(final String seed) {
return Statusgo.identicon(seed);
}
@ReactMethod
public void getNodesFromContract(final String rpcEndpoint, final String contractAddress, final Callback callback) {
Log.d(TAG, "getNodesFromContract");

View File

@ -490,3 +490,17 @@ void RCTStatus::chaosModeUpdate(bool on, double callbackId) {
d->bridge->invokePromiseCallback(callbackId, QVariantList{result});
}, on, callbackId);
}
QString RCTStatus::generateAlias(QString publicKey) {
Q_D(RCTStatus);
qCDebug(RCTSTATUS) << "::generateAlias call";
//return GenerateGfycat(publicKey.toUtf8().data());
return "test";
}
QString RCTStatus::identicon(QString publicKey) {
Q_D(RCTStatus);
qCDebug(RCTSTATUS) << "::identicon call";
//return Identicon(publicKey.toUtf8().data());
return "test";
}

View File

@ -71,6 +71,9 @@ public:
Q_INVOKABLE static bool JSCEnabled();
Q_INVOKABLE static void statusGoEventCallback(const char* event);
Q_INVOKABLE QString identicon(QString publicKey);
Q_INVOKABLE QString generateAlias(QString publicKey);
void emitStatusGoEvent(QString event);
Q_SIGNALS:

View File

@ -594,6 +594,14 @@ RCT_EXPORT_METHOD(callRPC:(NSString *)payload
});
}
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(generateAlias:(NSString *)publicKey) {
return StatusgoGenerateAlias(publicKey);
}
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(identicon:(NSString *)publicKey) {
return StatusgoIdenticon(publicKey);
}
RCT_EXPORT_METHOD(callPrivateRPC:(NSString *)payload
callback:(RCTResponseSenderBlock)callback) {
dispatch_async( dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

View File

@ -85,7 +85,7 @@
[chat-id {:keys [db now]}]
(let [name (get-in db [:contacts/contacts chat-id :name])]
{:chat-id chat-id
:name (or name (gfycat/generate-gfy chat-id))
:name (or name "")
:color (rand-nth colors/chat-colors)
:group-chat false
:is-active true
@ -145,12 +145,11 @@
#(chats-store/save-chat % (get-in % [:db :chats chat-id])))))
(fx/defn deactivate-chat
"Deactivate chat in db, no side effects"
[{:keys [db now] :as cofx} chat-id]
(fx/merge cofx
{:db (-> db
(assoc-in [:chats chat-id :is-active] false)
(assoc-in [:current-chat-id] nil))}
#(chats-store/save-chat % (get-in % [:db :chats chat-id]))))
{:db (-> db
(assoc-in [:chats chat-id :is-active] false)
(assoc-in [:current-chat-id] nil))})
(fx/defn remove-chat
"Removes chat completely from app, producing all necessary effects for that"

View File

@ -14,7 +14,7 @@
(spec/def :contact/fcm-token (spec/nilable string?))
(spec/def :contact/last-online (spec/nilable int?))
(spec/def :contact/last-updated (spec/nilable int?))
(spec/def :contact/name :global/not-empty-string)
(spec/def :contact/name (spec/nilable string?))
(spec/def :contact/public-key :global/not-empty-string)
(spec/def :contact/photo-path (spec/nilable string?))
@ -27,11 +27,11 @@
(spec/def :contact/tribute-transaction (spec/nilable string?))
(spec/def :contact/contact (spec/keys :req-un [:contact/address
:contact/name
:contact/photo-path
:contact/public-key
:contact/system-tags]
:opt-un [:contact/fcm-token
:contact/name
:contact/photo-path
:contact/last-online
:contact/last-updated
:contact/tags
@ -65,7 +65,7 @@
(defn public-key->new-contact [public-key]
{:name (gfycat/generate-gfy public-key)
:address (ethereum/public-key->address public-key)
:photo-path (identicon/identicon public-key)
:identicon (identicon/identicon public-key)
:public-key public-key
:system-tags #{}})

View File

@ -4,6 +4,7 @@
[clojure.spec.alpha :as spec]
[clojure.string :as string]
[re-frame.core :as re-frame]
[status-im.multiaccounts.core :as multiaccounts]
[status-im.multiaccounts.model :as multiaccounts.model]
[status-im.utils.pairing :as pairing.utils]
[status-im.chat.models :as models.chat]
@ -392,31 +393,31 @@
creator-contact (conj (format-message creator-contact
(i18n/label :t/group-chat-created
{:name chat-name
:member (:name creator-contact)})
:member (multiaccounts/displayed-name creator-contact)})
(:created-at clock-values)))
name-changed? (conj (format-message name-changed-author
(i18n/label :t/group-chat-name-changed
{:name chat-name
:member (:name name-changed-author)})
:member (multiaccounts/displayed-name name-changed-author)})
(:name-changed-at clock-values)))
(seq members-added) (concat (map #(format-message
%
(i18n/label :t/group-chat-member-added {:member (:name %)})
(i18n/label :t/group-chat-member-added {:member (multiaccounts/displayed-name %)})
(get-in clock-values [(:public-key %) :added]))
contacts-added))
(seq members-joined) (concat (map #(format-message
%
(i18n/label :t/group-chat-member-joined {:member (:name %)})
(i18n/label :t/group-chat-member-joined {:member (multiaccounts/displayed-name %)})
(get-in clock-values [(:public-key %) :joined]))
contacts-joined))
(seq admins-added) (concat (map #(format-message
%
(i18n/label :t/group-chat-admin-added {:member (:name %)})
(i18n/label :t/group-chat-admin-added {:member (multiaccounts/displayed-name %)})
(get-in clock-values [(:public-key %) :admin-added]))
admins-added))
(seq members-removed) (concat (map #(format-message
%
(i18n/label :t/group-chat-member-removed {:member (:name %)})
(i18n/label :t/group-chat-member-removed {:member (multiaccounts/displayed-name %)})
(get-in clock-values [(:public-key %) :removed]))
contacts-removed)))))

View File

@ -3,7 +3,6 @@
(def Chance (js/require "chance"))
(def emojis (js/require "emojilib"))
(def phishing-detect (js/require "eth-phishing-detect"))
(def identicon-js (js/require "identicon.js"))
(def BigNumber (js/require "bignumber.js"))
(def web3-utils (js/require "web3-utils"))
(def hi-base32 (js/require "hi-base32"))

View File

@ -10,15 +10,27 @@
[status-im.utils.fx :as fx]
[status-im.utils.handlers]
[status-im.utils.gfycat.core :as gfycat]
[status-im.utils.identicon :as identicon]
[status-im.utils.platform :as platform]
[status-im.utils.utils :as utils]))
(defn displayed-name [account]
(let [name (or (:preferred-name account) (:name account))]
(defn displayed-name
"Use preferred name, name or alias in that order"
[{:keys [name preferred-name alias public-key]}]
(let [name (or preferred-name
name
alias)]
(if (ens/is-valid-eth-name? name)
(let [username (stateofus/username name)]
(str "@" (or username name)))
(or name (gfycat/generate-gfy (:public-key account))))))
(or name (gfycat/generate-gfy public-key)))))
(defn displayed-photo
"If a photo-path is set use it, otherwise fallback on identicon or generate"
[{:keys [photo-path identicon public-key]}]
(or photo-path
identicon
(identicon/identicon public-key)))
(re-frame/reg-fx
::chaos-mode-changed

View File

@ -1,6 +1,7 @@
(ns status-im.native-module.core
(:require [clojure.string :as string]
[re-frame.core :as re-frame]
[status_im.utils.db :as utils.db]
[status-im.react-native.js-dependencies :as rn-dependencies]
[status-im.ui.components.react :as react]
[status-im.utils.platform :as platform]
@ -265,3 +266,15 @@
;; 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]
{:pre [(utils.db/valid-public-key? public-key)]}
(.generateAlias (status) public-key))
(defn identicon
"Generate a icon based on a string, synchronously"
[seed]
(.identicon (status) seed))

View File

@ -18,6 +18,7 @@
[status-im.group-chats.db :as group-chats.db]
[status-im.i18n :as i18n]
[status-im.multiaccounts.model :as multiaccounts.model]
[status-im.multiaccounts.core :as multiaccounts]
[status-im.multiaccounts.db :as multiaccounts.db]
[status-im.pairing.core :as pairing]
[status-im.tribute-to-talk.core :as tribute-to-talk]
@ -722,9 +723,10 @@
:<- [:contacts/contacts]
:<- [:multiaccount]
(fn [[contacts multiaccount] [_ id]]
(or (:photo-path (contacts id))
(when (= id (:public-key multiaccount))
(:photo-path multiaccount)))))
(multiaccounts/displayed-photo (or (contacts id)
(when (= id (:public-key multiaccount))
multiaccount)
(contact.db/public-key->new-contact id)))))
(re-frame/reg-sub
:chats/unread-messages-number
@ -1510,15 +1512,9 @@
(re-frame/subscribe [:contacts/contacts-by-chat filter chat-id])])
(fn [[chat contacts] [_ chat-id]]
(when (and chat (not (:group-chat chat)))
(cond
(:photo-path chat)
(:photo-path chat)
(pos? (count contacts))
(:photo-path (first contacts))
:else
(identicon/identicon chat-id)))))
(if (pos? (count contacts))
(multiaccounts/displayed-photo (first contacts))
(multiaccounts/displayed-photo chat)))))
(re-frame/reg-sub
:contacts/contact-by-address

View File

@ -27,12 +27,13 @@
in order to stop receiving that message"
[cofx now-in-s filter-chat-id message]
(let [blocked-contacts (get-in cofx [:db :contacts/blocked] #{})
{{:keys [payload sig timestamp ttl hash]} :message
{{:keys [payload timestamp]} :message
metadata :metadata
raw-payload :raw-payload} (add-raw-payload message)
status-message (-> payload
ethereum/hex-to-utf8
transit/deserialize)]
transit/deserialize)
sig (-> metadata :author :publicKey)]
(when (and sig
status-message
(not (blocked-contacts sig)))

View File

@ -82,6 +82,8 @@
:whisper-timestamp timestamp
:raw-payload-hash (ethereum/sha3
(.-payload (:js-obj cofx)))
:alias (get-in cofx [:metadata :author :alias])
:identicon (get-in cofx [:metadata :author :identicon])
:from signature
:metadata (:metadata cofx)
:js-obj (:js-obj cofx))]}]

View File

@ -1,6 +1,7 @@
(ns status-im.ui.components.chat-icon.screen
(:require [clojure.string :as string]
[re-frame.core :as re-frame.core]
[status-im.multiaccounts.core :as multiaccounts]
[status-im.ui.components.chat-icon.styles :as styles]
[status-im.ui.components.colors :as colors]
[status-im.ui.components.react :as react]
@ -42,10 +43,10 @@
[react/view pending-inner-circle]]])
(defn chat-icon-view
[{:keys [photo-path added?] :as contact} _group-chat name _online styles & [hide-dapp?]]
[{:keys [photo-path added?] :as contact} group-chat name _online styles & [hide-dapp?]]
[react/view (:container styles)
(if-not (string/blank? photo-path)
[photos/photo photo-path styles]
(if-not group-chat
[photos/photo (multiaccounts/displayed-photo contact) styles]
[default-chat-icon name styles])
(when (and contact (not added?))
[pending-contact-badge styles])])
@ -90,11 +91,11 @@
:default-chat-icon-text styles/default-chat-icon-text}]])
(defn contact-icon-view
[{:keys [photo-path name dapp?]} {:keys [container] :as styles}]
[{:keys [name dapp?] :as contact} {:keys [container] :as styles}]
[react/view container
(if-not (string/blank? photo-path)
[photos/photo photo-path styles]
[default-chat-icon name styles])
(if dapp?
[default-chat-icon name styles]
[photos/photo (multiaccounts/displayed-photo contact) styles])
(when dapp?
[dapp-badge styles])])
@ -168,14 +169,24 @@
[photos/photo photo-path styles]
[default-chat-icon name styles])]))
(defn my-profile-icon [{{:keys [photo-path name]} :multiaccount
edit? :edit?}]
(defn my-profile-icon [{multiaccount :multiaccount
edit? :edit?}]
(let [color colors/default-chat-color
size 64]
[profile-icon-view photo-path name color edit? size {}]))
[profile-icon-view
(multiaccounts/displayed-photo multiaccount)
(multiaccounts/displayed-name multiaccount)
color
edit?
size {}]))
(defn my-profile-header-icon [{{:keys [photo-path name]} :multiaccount
edit? :edit?}]
(defn my-profile-header-icon [{multiaccount :multiaccount
edit? :edit?}]
(let [color colors/default-chat-color
size 40]
[profile-icon-view photo-path name color edit? size {}]))
[profile-icon-view
(multiaccounts/displayed-photo multiaccount)
(multiaccounts/displayed-name multiaccount)
color
edit?
size {}]))

View File

@ -196,13 +196,14 @@
(:command content))
[command-status content]))))
(defview message-author-name [from name]
(letsubs [username [:contacts/contact-name-by-identity from]]
(chat.utils/format-author from style/message-author-name name)))
(defview message-author-name [alias name]
(letsubs [username [:contacts/contact-name-by-identity alias]]
(chat.utils/format-author alias style/message-author-name name)))
(defn message-body
[{:keys [last-in-group?
display-photo?
alias
display-username?
from
outgoing
@ -219,7 +220,7 @@
[react/view (style/group-message-view outgoing display-photo?)
(when display-username?
[react/touchable-opacity {:on-press #(re-frame/dispatch [:chat.ui/show-profile from])}
[message-author-name from (:name content)]])
[message-author-name alias (:name content)]])
[react/view {:style (style/timestamp-content-wrapper outgoing)}
child]]]
[react/view (style/delivery-status outgoing)

View File

@ -1,5 +1,6 @@
(ns status-im.ui.screens.chat.photos
(:require [clojure.string :as string]
[status-im.multiaccounts.core :as multiaccounts]
[status-im.ui.components.react :as react]
[status-im.ui.screens.chat.styles.photos :as style]
[status-im.ui.screens.profile.db :as profile.db]
@ -20,8 +21,6 @@
(defview member-photo [from & [size]]
(letsubs [photo-path [:chats/photo-path from]]
(photo (if (string/blank? photo-path)
(identicon/identicon from)
photo-path)
(photo photo-path
{:accessibility-label :member-photo
:size (or size style/default-size)})))

View File

@ -21,7 +21,7 @@
name]
:else
[react/text {:style {:color colors/gray :font-size 12 :font-weight "400"}}
(gfycat/generate-gfy from)]))
from]))
(defn format-reply-author [from username current-public-key style]
(or (and (= from current-public-key)

View File

@ -313,7 +313,6 @@
[{:keys [group-chat chat-id pending-invite-inviter-name contact] :as chat}
modal?]
(letsubs [messages [:chats/current-chat-messages-stream]
photo-path [:chats/photo-path chat-id]
current-public-key [:multiaccount/public-key]]
{:component-did-mount
(fn [args]

View File

@ -1,5 +1,6 @@
(ns status-im.ui.screens.contacts-list.views
(:require [re-frame.core :as re-frame]
[status-im.multiaccounts.core :as multiaccounts]
[status-im.ui.components.colors :as colors]
[status-im.ui.components.list.views :as list.views]
[status-im.ui.components.react :as react]
@ -9,11 +10,12 @@
[status-im.ui.components.toolbar.view :as toolbar.view])
(:require-macros [status-im.utils.views :refer [defview letsubs]]))
(defn contacts-list-item [{:keys [public-key name photo-path] :as contact}]
(defn contacts-list-item [{:keys [public-key] :as contact}]
[list.views/big-list-item
{:text name
:image-source photo-path
:action-fn #(re-frame/dispatch [:chat.ui/show-profile public-key])}])
;;TODO this should be done in a subscription
{:text (multiaccounts/displayed-name contact)
:image-source (multiaccounts/displayed-photo contact)
:action-fn #(re-frame/dispatch [:chat.ui/show-profile public-key])}])
(defview contacts-list []
(letsubs [blocked-contacts-count [:contacts/blocked-count]

View File

@ -1,6 +1,7 @@
(ns status-im.ui.screens.hardwallet.login.views
(:require-macros [status-im.utils.views :refer [defview letsubs]])
(:require [status-im.ui.screens.hardwallet.pin.views :as pin.views]
(:require [status-im.multiaccounts.core :as multiaccounts]
[status-im.ui.screens.hardwallet.pin.views :as pin.views]
[status-im.ui.screens.hardwallet.connect.views :as connect.views]
[status-im.ui.screens.hardwallet.components :as components]
[status-im.ui.screens.hardwallet.login.styles :as styles]
@ -17,7 +18,7 @@
[re-frame.core :as re-frame]))
(defview hardwallet-login []
(letsubs [{:keys [photo-path name processing]} [:multiaccounts/login]
(letsubs [{:keys [photo-path name processing] :as account} [:multiaccounts/login]
nfc-enabled? [:hardwallet/nfc-enabled?]]
[react/keyboard-avoiding-view styles/container
[status-bar/status-bar]
@ -30,7 +31,8 @@
[react/view styles/login-view
[react/view styles/login-badge-container
[react/view styles/login-badge
[photos/photo photo-path {:size styles/login-badge-image-size}]
;;TODO this should be done in a subscription
[photos/photo (multiaccounts/displayed-photo account) {:size styles/login-badge-image-size}]
[react/view
[react/text {:style styles/login-badge-name
:numberOfLines 1}

View File

@ -1,6 +1,7 @@
(ns status-im.ui.screens.keycard.views
(:require-macros [status-im.utils.views :refer [defview letsubs]])
(:require [status-im.ui.components.react :as react]
(:require [status-im.multiaccounts.core :as multiaccounts]
[status-im.ui.components.react :as react]
[status-im.ui.components.toolbar.view :as toolbar]
[status-im.ui.screens.keycard.styles :as styles]
[status-im.i18n :as i18n]
@ -362,7 +363,7 @@
enter-step [:hardwallet/pin-enter-step]
status [:hardwallet/pin-status]
error-label [:hardwallet/pin-error-label]
{:keys [address name photo-path]} [:multiaccounts/login]]
{:keys [address name] :as account} [:multiaccounts/login]]
[react/view styles/container
[toolbar/toolbar
{:transparent? true
@ -397,7 +398,8 @@
:height 69
:justify-content :center
:align-items :center}
[photos/photo photo-path {:size 61}]
;;TODO this should be done in a subscription
[photos/photo (multiaccounts/displayed-photo account) {:size 61}]
[react/view {:justify-content :center
:align-items :center
:width 24
@ -439,7 +441,7 @@
(defview login-connect-card []
(letsubs [status [:hardwallet/pin-status]
{:keys [address name photo-path]} [:multiaccounts/login]]
{:keys [address name] :as account} [:multiaccounts/login]]
(let [in-progress? (= status :verifying)]
[react/view styles/container
[toolbar/toolbar
@ -471,7 +473,8 @@
:height 69
:justify-content :center
:align-items :center}
[photos/photo photo-path {:size 61}]
;;TODO this should be done in a subscription
[photos/photo (multiaccounts/displayed-photo account) {:size 61}]
[react/view {:justify-content :center
:align-items :center
:width 24

View File

@ -1,6 +1,7 @@
(ns status-im.ui.screens.multiaccounts.login.views
(:require [re-frame.core :as re-frame]
[status-im.i18n :as i18n]
[status-im.multiaccounts.core :as multiaccounts]
[status-im.ui.components.checkbox.view :as checkbox]
[status-im.ui.components.colors :as colors]
[status-im.ui.components.common.common :as components.common]
@ -29,19 +30,23 @@
(.blur password-text-input)
(re-frame/dispatch [:multiaccounts.login.ui/password-input-submitted]))
(defn multiaccount-login-badge [photo-path name public-key]
(defn multiaccount-login-badge [{:keys [public-key] :as multiaccount}]
[react/view styles/login-badge
[photos/photo photo-path {:size styles/login-badge-image-size}]
[photos/photo
;;TODO this should be done in a subscription
(multiaccounts/displayed-photo multiaccount)
{:size styles/login-badge-image-size}]
[react/view
[react/text {:style styles/login-badge-name
:ellipsize-mode :middle
:numberOfLines 1}
name]
;;TODO this should be done in a subscription
(multiaccounts/displayed-name multiaccount)]
[react/text {:style styles/login-badge-pubkey}
(utils/get-shortened-address public-key)]]])
(defview login []
(letsubs [{:keys [photo-path name public-key error processing save-password? can-save-password?] :as multiaccount} [:multiaccounts/login]
(letsubs [{:keys [error processing save-password? can-save-password?] :as multiaccount} [:multiaccounts/login]
can-navigate-back? [:can-navigate-back?]
password-text-input (atom nil)
sign-in-enabled? [:sign-in-enabled?]
@ -51,7 +56,7 @@
[login-toolbar can-navigate-back?]
[react/scroll-view styles/login-view
[react/view styles/login-badge-container
[multiaccount-login-badge photo-path name public-key]
[multiaccount-login-badge multiaccount]
[react/view {:style styles/password-container
:important-for-accessibility :no-hide-descendants}
[text-input/text-input-with-label

View File

@ -70,11 +70,12 @@
:render-fn render-detail}])
(defn profile-details [contact]
[react/view
[list-item/list-item {:type :section-header
:title :t/profile-details
:title-accessibility-label :profile-details}]
[profile-details-list-view contact]])
(when contact
[react/view
[list-item/list-item {:type :section-header
:title :t/profile-details
:title-accessibility-label :profile-details}]
[profile-details-list-view contact]]))
(defn block-contact-action [{:keys [blocked? public-key] :as contact}]
[react/touchable-highlight {:on-press (if blocked?
@ -91,13 +92,15 @@
(i18n/label :t/unblock-contact)
(i18n/label :t/block-contact))]])
(defn- header-in-toolbar [{:keys [photo-path] :as account}]
(defn- header-in-toolbar [account]
(let [displayed-name (multiaccounts/displayed-name account)]
[react/view {:flex 1
:flex-direction :row
:align-items :center
:align-self :stretch}
[photos/photo photo-path {:size 40}]
;;TODO this should be done in a subscription
[photos/photo (multiaccounts/displayed-photo account)
{:size 40}]
[react/text {:style {:typography :title-bold
:line-height 21
:margin-right 40
@ -115,31 +118,32 @@
(views/defview profile []
(views/letsubs [list-ref (reagent/atom nil)
contact [:contacts/current-contact]]
(let [header-in-toolbar (header-in-toolbar contact)
header (header contact)
content
[[list/action-list (actions contact)
{:container-style styles/action-container
:action-style styles/action
:action-label-style styles/action-label
:action-subtext-style styles/action-subtext
:action-separator-style styles/action-separator
:icon-opts styles/action-icon-opts}]
[react/view styles/contact-profile-details-container
[profile-details contact]]
[block-contact-action contact]]
generated-view (large-toolbar/generate-view
header-in-toolbar
toolbar/default-nav-back
nil
header
content
list-ref)]
[react/safe-area-view
{:style
(merge {:flex 1}
(when platform/ios?
{:margin-bottom tabs.styles/tabs-diff}))}
[status-bar/status-bar {:type :main}]
(:minimized-toolbar generated-view)
(:content-with-header generated-view)])))
(when contact
(let [header-in-toolbar (header-in-toolbar contact)
header (header contact)
content
[[list/action-list (actions contact)
{:container-style styles/action-container
:action-style styles/action
:action-label-style styles/action-label
:action-subtext-style styles/action-subtext
:action-separator-style styles/action-separator
:icon-opts styles/action-icon-opts}]
[react/view styles/contact-profile-details-container
[profile-details contact]]
[block-contact-action contact]]
generated-view (large-toolbar/generate-view
header-in-toolbar
toolbar/default-nav-back
nil
header
content
list-ref)]
[react/safe-area-view
{:style
(merge {:flex 1}
(when platform/ios?
{:margin-bottom tabs.styles/tabs-diff}))}
[status-bar/status-bar {:type :main}]
(:minimized-toolbar generated-view)
(:content-with-header generated-view)]))))

View File

@ -70,19 +70,20 @@
;:icon :main-icons/link
:accessibility-label :share-my-contact-code-button}]]])))
(defn- header [{:keys [public-key photo-path] :as account}]
(defn- header [{:keys [photo-path] :as account}]
[profile.components/profile-header
{:contact account
:allow-icon-change? true
:include-remove-action? (not= (identicon/identicon public-key) photo-path)}])
:include-remove-action? (seq photo-path)}])
(defn- header-in-toolbar [{:keys [photo-path] :as account}]
(defn- header-in-toolbar [account]
(let [displayed-name (multiaccounts/displayed-name account)]
[react/view {:flex 1
:flex-direction :row
:align-items :center
:align-self :stretch}
[photos/photo photo-path {:size 40}]
;;TODO this should be done in a subscription
[photos/photo (multiaccounts/displayed-photo account) {:size 40}]
[react/text {:style {:typography :title-bold
:line-height 21
:margin-right 40

View File

@ -173,7 +173,10 @@
[react/view styles/recipient-container
[react/view styles/recipient-icon
(when contact
[photos/photo (:photo-path contact) {:size list.styles/image-size}])]
[photos/photo
;;TODO this should be done in a subscription
(multiaccounts/displayed-photo contact)
{:size list.styles/image-size}])]
[react/view {:style styles/recipient-name}
[react/text {:style (styles/participant true)
:accessibility-label (if request? :contact-name-text :recipient-name-text)
@ -186,7 +189,10 @@
(defn render-contact [contact request?]
[list/touchable-item #(re-frame/dispatch [:wallet/fill-request-from-contact contact request?])
[list/item
[photos/photo (:photo-path contact) {:size list.styles/image-size}]
[photos/photo
;;TODO this should be done in a subscription
(multiaccounts/displayed-photo contact)
{:size list.styles/image-size}]
[list/item-content
[list/item-primary {:accessibility-label :contact-name-text}
(multiaccounts/displayed-name contact)]
@ -333,4 +339,4 @@
(i18n/label :t/sidechain-text {:sidechain (get-in ethereum/chains [(ethereum/chain-id->chain-keyword network-id) :name] "Unknown")})
:else
(i18n/label :t/mainnet-text))]]]))
(i18n/label :t/mainnet-text))]]]))

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,28 +1,14 @@
(ns status-im.utils.gfycat.core
(:require [status-im.utils.gfycat.animals :as animals]
[status-im.utils.gfycat.adjectives :as adjectives]
[clojure.string :as str]
[status-im.utils.random :as rnd]
(:require [status-im.native-module.core :as native-module]
[status-im.utils.datetime :as datetime]))
(defn- pick-random
[gen vector]
(str/capitalize (rnd/seeded-rand-nth gen vector)))
(defn- build-gfy
[public-key]
(let [gen (rnd/rand-gen public-key)
first-adjective (pick-random gen adjectives/data)
second-adjective (pick-random gen adjectives/data)
animal (pick-random gen animals/data)]
(str first-adjective " " second-adjective " " animal)))
(def unknown-gfy "Unknown")
(defn generate-gfy
([public-key]
(case public-key
nil unknown-gfy
"0" unknown-gfy
(build-gfy public-key)))
([] (generate-gfy (datetime/timestamp))))
(defn- build-gfy
[public-key]
(case public-key
nil unknown-gfy
"0" unknown-gfy
(native-module/generate-gfycat public-key)))
(def generate-gfy (memoize build-gfy))

View File

@ -1,13 +1,5 @@
(ns status-im.utils.identicon
(:require [status-im.js-dependencies :as dependencies]))
(:require
[status-im.native-module.core :as native-module]))
(def default-size 150)
(defn identicon
([hash] (identicon hash (clj->js {:background [255 255 255 255]
:margin 0.24
:size default-size})))
([hash options]
(str "data:image/png;base64,"
(let [identicon-js dependencies/identicon-js]
(str (new identicon-js hash options))))))
(def identicon (memoize native-module/identicon))

View File

@ -3,6 +3,6 @@
"owner": "status-im",
"repo": "status-go",
"version": "develop",
"commit-sha1": "963ea94e08ed46e20a4feee1f5d2a294e9cdf6c1",
"src-sha256": "19zz3ccjpk8dnrani4hccpyx6q0gvzr4s43cqr8ybk97z09w175l"
"commit-sha1": "40e66e6186164a422e432fd754b8f86b958014f3",
"src-sha256": "0ra9agglqz9jpxqh4rwzljq73g0gy0zzy4n8vcqqf0dsrw26fhcn"
}

View File

@ -1,6 +1,6 @@
basic_user = dict()
basic_user['passphrase'] = "tree weekend ceiling awkward universe pyramid glimpse raven pair lounge grant grief"
basic_user['username'] = "Cadetblue Popular Monoclonius"
basic_user['username'] = "Royal Defensive Solenodon"
basic_user['public_key'] = "0x042e0309b5f6bedee93a1b984af08f89a101aff62d01ddd0a1c8f4a1d4db3b91e648c914019d09de9f07dd" \
"baacb77fdf07e89b5e0d60e9a8df05b75f213661fcad"
basic_user['address'] = "f184747445c3B85CEb147DfB136067CB93d95F1D"
@ -8,7 +8,7 @@ basic_user['special_chars_password'] = " !\"#$Á%Ö&'()*+Í, -./:ä;<=>?@[\\]^_`
ens_user = dict()
ens_user['passphrase'] = "husband rough hotel obey annual you member reopen struggle air evoke taxi"
ens_user['username'] = "Bouncy Powderblue Xeme"
ens_user['username'] = "Outstanding Actual Eyas"
ens_user['public_key'] = "0x04318d20a2ca5fd0022579005ed24802e07d4ec610bede808dd13d3318af439e16d55be1a59af007a11120b" \
"d1c205861e5f53fe7b000a25e2b0d4eee7f0c5ebf7e"
ens_user['ens'] = 'autotester'
@ -17,34 +17,34 @@ wallet_users = dict()
wallet_users['A'] = dict()
wallet_users['A']['passphrase'] = "heavy earn fence pool drift balcony act coast stairs basic juice hip"
wallet_users['A']['username'] = "Fuzzy Lightyellow Mara"
wallet_users['A']['username'] = "Equatorial Navyblue Tegus"
wallet_users['A']['address'] = "c8f8b3376814d0dfe61e4b9eaf7970697c24f6b2"
wallet_users['A']['public_key'] = "0x04fa759cc29261fd7779cf8b3566de61e3fb22aca4699a0a77a930a4f5af83b6f922a9cd67" \
"9a957fdab86e277e4bb7ec90f7998d21fc16690397d3783b8d8711e1"
wallet_users['B'] = dict()
wallet_users['B']['passphrase'] = "subway size dial screen stomach route skin kitchen radar true coffee six"
wallet_users['B']['username'] = "Highlevel Sticky Dragon"
wallet_users['B']['username'] = "Idealistic Assured Spidermonkey"
wallet_users['B']['address'] = "85b159bad0d500483b307ec6892c7fa3be591cbc"
wallet_users['B']['public_key'] = "0x04c068a1467abf8d18ea4a020e52880d855c5a418e52c1ef29cc9b30999ed986cf5c9fe55" \
"d6ffd10659be32c8c1ce15dbf7dc0659e238a0169eb7e18be9757baa8"
wallet_users['C'] = dict()
wallet_users['C']['passphrase'] = "purchase ensure mistake crystal person similar shaft family shield clog risk market"
wallet_users['C']['username'] = "Trustworthy Acidic Shorebird"
wallet_users['C']['username'] = "Mellow Virtual Nubiangoat"
wallet_users['C']['address'] = "8dce052ccda2f6f6b555759cee6957e04a6ddf5b"
wallet_users['C']['public_key'] = "0x040e562b69362e7e57492bca50b6095acfa636c48b85eef2bc0e4180b6e99fc5e73f45c3" \
"40837da01728d4585695fda7f1de2ed193a1dd4080291d90812e1cae77"
wallet_users['D'] = dict()
wallet_users['D']['passphrase'] = "hen mango since lottery laundry flag report whisper cycle rate festival carry"
wallet_users['D']['username'] = "Agile Discrete Galapagossealion"
wallet_users['D']['username'] = "Competent Rectangular Albino"
wallet_users['D']['address'] = "80b663e82657caf5657ce79b11aeaeda02c6cd92"
wallet_users['D']['public_key'] = "0x04f79d02bab51efe903645e74b23df471b041ce3c964a5cf376c7ae572039569af7cf934d094e" \
"86b2177db49b6943d0c8720550e39868ef5c7108ebffb5522b140"
wallet_users['E'] = dict()
wallet_users['E']['passphrase'] = "record sphere illegal section blame swing wreck estate celery same excite summer"
wallet_users['E']['username'] = "Favorable Trusting Bats"
wallet_users['E']['username'] = "Wry Shiny Damselfly"
wallet_users['E']['address'] = "0x3e2e4077753d3c229a9ae332b9ca46958945e2f6"
wallet_users['E']['public_key'] = "0x044cf0620ec3ea0aba9fb0e19cb42a6fbd6b4e74f234f0da82580564817b238cc6434745d31" \
"fa1649927ba48adfa7c95991fd51940bc00a71e80b095db5b107f1b"
@ -54,14 +54,14 @@ chat_users = dict()
chat_users['A'] = dict()
chat_users['A']['passphrase'] = "canoe edit leg exit game glue blame electric bar now box point"
chat_users['A']['username'] = "Kooky Quintessential Bumblebee"
chat_users['A']['username'] = "Petty Mediumaquamarine Avians"
chat_users['A']['address'] = "0x5626db866676d70f5fa58366d8df3b1053b8d9cc"
chat_users['A']['public_key'] = "0x0445c001a3b365b55304e2cd23b8418a8381786d96be01a69cf7569786086a2a4c7b2a602ea" \
"355c85225ae1e7b0444a666fefe9902b465414e6c0ef0b5997b073a"
chat_users['B'] = dict()
chat_users['B']['passphrase'] = "found ridge build seven whisper enact weekend nation during law external december"
chat_users['B']['username'] = "Wasteful Solid Piedstarling"
chat_users['B']['username'] = "Repentant Velvety Adeliepenguin"
chat_users['B']['address'] = "0xB094A8c0A3F71e3246C3eD89a51f81008c800088"
chat_users['B']['public_key'] = "0x0439a66cd420082741147ef8b1ab9c8d8558d21f2cc3cb4099fd0aa5507c5d8bdb94ded8beccfa" \
"2812f6b641de9f9c31fa62379af6d148fdec45335196b2e6307b"
@ -71,7 +71,7 @@ transaction_senders = dict()
transaction_senders['A'] = dict()
transaction_senders['A']['passphrase'] = \
'night fortune spider version version armed amused winner matter tonight cave flag'
transaction_senders['A']['username'] = 'Mortified Darling Bats'
transaction_senders['A']['username'] = 'Darkorchid Clueless Ewe'
transaction_senders['A']['address'] = 'efca4fd47b98b9f01c4eef4827e576a01459728a'
transaction_senders['A']['public_key'] = "0x046c0ec05e1f13481af0e3d9cc7869e6f1b64306adcfb325827518c66f4ea3dafbd18de3" \
"0269f95aadcf3aae40a27075505b625c1cd08b41a335b318bf3fe7ca21"
@ -79,21 +79,21 @@ transaction_senders['A']['public_key'] = "0x046c0ec05e1f13481af0e3d9cc7869e6f1b6
transaction_senders['B'] = dict()
transaction_senders['B']['passphrase'] = \
"quality walk globe dune rally distance fragile year turn horror sample lobster"
transaction_senders['B']['username'] = "Mellow Luxurious Sloth"
transaction_senders['B']['username'] = "New Awesome Tenrec"
transaction_senders['B']['address'] = "a456a6bde144695879a754b19dd13e9f75ea43f2"
transaction_senders['B']['public_key'] = "0x04b9687c94bc9d573d7455d9fed1039253b1fa063afda5ca3280de605208c760202479645" \
"ff84755d5bf20cc029daa0881c94cab9a65bdfe9568849efe4ac707e3"
transaction_senders['C'] = dict()
transaction_senders['C']['passphrase'] = "potato labor object reward minor casino dismiss size flame task winter report"
transaction_senders['C']['username'] = "Uneven Dramatic Trumpeterbird"
transaction_senders['C']['username'] = "Breakable Productive Prayingmantis"
transaction_senders['C']['address'] = "549b9bcd069d720390a6819ff8b3d9dd252fa3be"
transaction_senders['C']['public_key'] = "0x048536ec9fcc25e879920fb548a484de5be64b4a93a0b16c6d78deb1d140ac636ed3ca1" \
"d86e17a75f83422ab651f0743c162ffb006707721719e02d2cbd5f54d51"
transaction_senders['D'] = dict()
transaction_senders['D']['passphrase'] = "weekend unable empty crime blind rhythm crunch answer travel coast silly like"
transaction_senders['D']['username'] = "Instructive Graceful Icelandichorse"
transaction_senders['D']['username'] = "Indelible Dapper Hoatzin"
transaction_senders['D']['address'] = "616874dc6cc2810cdc930dea26496fcf217d58ca"
transaction_senders['D']['public_key'] = "0x044764a9ba22bb4ae355619ca3824ee66b9f704c7fc08280e6305112bf80fd96b2fcd73" \
"d0dd570471986c229c077c8053ee47784416eb6604d52e41f8f9d566ef8"
@ -101,96 +101,96 @@ transaction_senders['D']['public_key'] = "0x044764a9ba22bb4ae355619ca3824ee66b9f
transaction_senders['E'] = dict()
transaction_senders['E']['passphrase'] = \
"sea ill guard bounce gesture tomato walnut fitness plastic affair oven transfer"
transaction_senders['E']['username'] = "Dual Occasional Birdofparadise"
transaction_senders['E']['username'] = "Fatal Metallic Imperialeagle"
transaction_senders['E']['address'] = "f7cb60839c0de25e37be0391c33bb34a8f0f8414"
transaction_senders['E']['public_key'] = "0x04db6128352e5c2d05ee5a6556848453cf3a7af34e94b3e20a302de684e9906461e38adf" \
"51c39e1abf20f5ae7f418e0383633e08d7acee31d4aaee0473af2e6ed8"
transaction_senders['F'] = dict()
transaction_senders['F']['passphrase'] = "style case lazy pole general section dawn royal slice evoke crowd boat"
transaction_senders['F']['username'] = "Deadly Caring Peacock"
transaction_senders['F']['username'] = "Lightsalmon Wry Umbrette"
transaction_senders['F']['address'] = "a94a2a7584620677d290549a96046e59a18f09ef"
transaction_senders['F']['public_key'] = "0x044f13fa489032ad7fefd82a5d9dedc40ab3787096ef2870848a7537b26c5262ea7a29b" \
"53026d1cbf992b99bce5d0609a933a06f89fb6206606b34a43c1f160e35"
transaction_senders['G'] = dict()
transaction_senders['G']['passphrase'] = "load other time gadget fury sudden gossip hurry entry curtain jaguar inflict"
transaction_senders['G']['username'] = "Several Firebrick Frigatebird"
transaction_senders['G']['username'] = "Acidic Focused Xantus"
transaction_senders['G']['address'] = "876c331d60aedd175ca78cb6a50eaeb9681a1868"
transaction_senders['G']['public_key'] = "0x04885bb487d9e8c3b51f963e564669118f7a9bead224df5334dd3242d463dc0420b2c1e" \
"2dfced6dc9dca1a36771584e2edb83da39edaaae969616254f26da5b07a"
transaction_senders['H'] = dict()
transaction_senders['H']['passphrase'] = "age three camp tip jump radio copper merry mention top panther motor"
transaction_senders['H']['username'] = "Twin Hollow Booby"
transaction_senders['H']['username'] = "Fine Huge Beagle"
transaction_senders['H']['address'] = "762d87f77c88048281ddad78501fcfe0700f08ce"
transaction_senders['H']['public_key'] = "0x042b9be3f4887d0504ebc31f42e809919641e95ed98ba9b643961019ad6af7bc258064d" \
"ca2ca860f182e4f528a9be3d969e4536f04f3e4e1b9203e16b57508ec1b"
transaction_senders['I'] = dict()
transaction_senders['I']['passphrase'] = "six runway asthma blur secret rebuild parent logic horror decline rib buyer"
transaction_senders['I']['username'] = "Revolving Minty Osprey"
transaction_senders['I']['username'] = "Finished Infatuated Whiteeye"
transaction_senders['I']['address'] = "0887afe0ee3e1b195f596350bb04bba034514af9"
transaction_senders['I']['public_key'] = "0x04e61e616f881383e807cd1fb714fa2e06b5ad1cb6cd7b97a9265da2ad9a133ee750954a" \
"6c4da3635f2e406b310f6e294ca94ea3a686287a1276e4e86612886f8e"
transaction_senders['J'] = dict()
transaction_senders['J']['passphrase'] = "shrug during breeze mercy install net reopen uniform atom guilt sadness elite"
transaction_senders['J']['username'] = "Strict Quarterly Abyssiniangroundhornbill"
transaction_senders['J']['username'] = "Outrageous Knotty Shearwater"
transaction_senders['J']['address'] = "ad0f319ca0cfa051f625ad1a3fc6bf0cbad45b24"
transaction_senders['J']['public_key'] = "0x04fedbb6114918babbdabdc7bd5cb5f3aaa13f4bd5df5c27c2b2adfc91dffae15f75bf9f" \
"0e9bb747ef1996b63260f40dee1e00f62b061d95c6878b8c5ecfb33835"
transaction_senders['K'] = dict()
transaction_senders['K']['passphrase'] = "fly west avoid depend tape direct foster off cry crucial blame elegant"
transaction_senders['K']['username'] = "Elegant Lightsteelblue Cuckoo"
transaction_senders['K']['username'] = "Decimal Healthy Harpyeagle"
transaction_senders['K']['address'] = "6a4dd6e2dcef1139cd04e6a24c19ded819340f85"
transaction_senders['K']['public_key'] = "0x044ab7a9d8f6f146a52534327bd301e85afe02b61108a03cd5afdd1c555f7268e46cb8ac" \
"37636f3590f9fed80a1124d78be041d010dba61d09f6278dee272dc661"
transaction_senders['L'] = dict()
transaction_senders['L']['passphrase'] = "road rabbit tuna bacon man raccoon equal note cream rescue core chunk"
transaction_senders['L']['username'] = "Greedy Nutty Macaque"
transaction_senders['L']['username'] = "Funny Lavish Goldfinch"
transaction_senders['L']['address'] = "002881321fd06d77ba2deed035140631f49506be"
transaction_senders['L']['public_key'] = "0x04dfe571200b1cf05b1f743f5730a833da60b46de9437d29c0573c4970ba8e8e5980f76b" \
"80aa71a7e66b54235e869ade8f91dfde925d06ef3b2397fa007540dd34"
transaction_senders['M'] = dict()
transaction_senders['M']['passphrase'] = "thank fruit brisk pond opera census grid husband claw sight chunk arena"
transaction_senders['M']['username'] = "Noxious Respectful Tilefish"
transaction_senders['M']['username'] = "Wellgroomed Impartial Cornsnake"
transaction_senders['M']['address'] = 'bd4e3eede0f942b843a031007190c08cab373248'
transaction_senders['M']['public_key'] = "0x04d52c290fbd4f32bba82e5efa673d8f6aaf698f99ed16266662acd0cd583ee534703c547" \
"a06e24b4a2244c6788e2e92f22aa95f0ad999d07e6b993c9274132e13"
transaction_senders['N'] = dict()
transaction_senders['N']['passphrase'] = "label ill slender audit atom love vote snap edit program climb beyond"
transaction_senders['N']['username'] = "Itchy Lawful Hermitcrab"
transaction_senders['N']['username'] = "Immaculate Aqua Banteng"
transaction_senders['N']['address'] = 'd117188dbf1c160074cc4850a1d140286fdfc831'
transaction_senders['N']['public_key'] = "0x04331e35cdb205e201502719edb97c307f5f997dd58aa68d9f6378188f4ed8ccf0b3908e" \
"f0151f60aa639c3652937e9df30f1c0c1b8b43f922167c5c0447dda6b5"
transaction_senders['O'] = dict()
transaction_senders['O']['passphrase'] = "you salmon ticket antique spray panther flee neck scale mad trial exile"
transaction_senders['O']['username'] = "Orderly Hardtofind Iguana"
transaction_senders['O']['username'] = "Wavy Yellow Rainbowfish"
transaction_senders['O']['address'] = '45798efe501340efbe265bce950f9ddcad8d7ce5'
transaction_senders['O']['public_key'] = "0x045925e701303feb8c1c98be2c9825e2c1c7005a0da7ab509d2d989e1d837c064fc8e06be" \
"51b417113f55cfe147cf7413c4016df748c29a6fd2efe20b2d8f59a05"
transaction_senders['P'] = dict()
transaction_senders['P']['passphrase'] = "warm beach mind real stay oil evil giggle core tilt paddle invest"
transaction_senders['P']['username'] = "Loving Minty Fox"
transaction_senders['P']['username'] = "Grave Able Arcticfox"
transaction_senders['P']['address'] = "9164f86170290ba3080e37d19d1953d3c5945913"
transaction_senders['P']['public_key'] = "0x04a7d3e9f637325f6195607ec5b60d1198487da9f172cc717729fa475f6ea682a93dc56" \
"f00bbb3652e014d9569da5bf3de0e1ba98884fcb64d3ca5a724eb24cfbc"
transaction_senders['Q'] = dict()
transaction_senders['Q']['passphrase'] = "junior forum symptom twin route scare source cycle extra engage worth prison"
transaction_senders['Q']['username'] = "Harmonious Soft Trumpeterbird"
transaction_senders['Q']['username'] = "Jealous Third Howlermonkey"
transaction_senders['Q']['address'] = "e9fd13b1bcfff497f21b28e141fa2e5049ebcee4"
transaction_senders['Q']['public_key'] = "0x044cee9f6c12a46da7142d5fa3cc29e34f1a82d22435cebcd73d41981a73577cd31adc38b" \
"b6b747dfa75857d452b94630b4672b80e6fc8d6974421b95fcf9d6513"
transaction_senders['R'] = dict()
transaction_senders['R']['passphrase'] = "ahead warrior poet radio image topic wasp clever banner angry age quality"
transaction_senders['R']['username'] = "Insubstantial Darkslateblue Diplodocus"
transaction_senders['R']['username'] = "Icky Tan Flickertailsquirrel"
transaction_senders['R']['address'] = "d54bf6c67e349bf889fd5d411a8c410b3a4cc099"
transaction_senders['R']['public_key'] = "0x04ec7a5b6cd54a2d7aa7f156013870e8c7559a14239752dfbe879167b3deb55fc713da44d" \
"096fd2e02aac143cb8999139ebd4a07b7e7c1fd72cc192a2a2f576682"
@ -198,7 +198,7 @@ transaction_senders['R']['public_key'] = "0x04ec7a5b6cd54a2d7aa7f156013870e8c755
transaction_senders['S'] = dict()
transaction_senders['S']['passphrase'] = \
"tree capable picnic swap venture correct open enforce assault news inform pear"
transaction_senders['S']['username'] = "Quixotic Private Turaco"
transaction_senders['S']['username'] = "Cyan Intent Meadowlark"
transaction_senders['S']['address'] = "061fae3dd75beab5855f584837ca0c0a8e84f5c1"
transaction_senders['S']['public_key'] = "0x04579ab8085e685a6ab1dee8435b05bcb04c8332d22f96ecc7300da95e7565c8e4a950a6f" \
"b1809db7590ad87d28c7aec58632e8870cb642df839252e356010a9eb"
@ -206,49 +206,49 @@ transaction_senders['S']['public_key'] = "0x04579ab8085e685a6ab1dee8435b05bcb04c
transaction_senders['T'] = dict()
transaction_senders['T']['passphrase'] = \
"describe adult cat kidney disagree stick timber unaware yellow jungle leave warrior"
transaction_senders['T']['username'] = "Peppery Darkgray Blackrhino"
transaction_senders['T']['username'] = "Faithful Specific Brownbutterfly"
transaction_senders['T']['address'] = "7e33ab11ae8ca21e8d3c15ceb74b6cc429834b5b"
transaction_senders['T']['public_key'] = "0x04cd6e1b7c76bd7abe54c8cd30fb1be6a08233d9c77b298700c3983d812c98698963c9db" \
"4b0c4648de69237e9e140397258f3e3bdd526a11a37c64c477be4953fa"
transaction_senders['U'] = dict()
transaction_senders['U']['passphrase'] = "club script position scare face medal already quality company flat item pill"
transaction_senders['U']['username'] = "Intelligent Parallel Avocet"
transaction_senders['U']['username'] = "Qualified Gifted Prayingmantis"
transaction_senders['U']['address'] = "b92496fffd668c2de08694623303456aa98cdf33"
transaction_senders['U']['public_key'] = "0x048f6828bad09baabbead08de7fc9672d6d15d6433e7941d99322bf0f61f3b5891a2bf740" \
"2027fd46896b869d46ae85c7096d4a47d7184682fa14bee7bb772f29a"
transaction_senders['V'] = dict()
transaction_senders['V']['passphrase'] = "true bus equip ensure speed blame universe renew gasp clip glide unaware"
transaction_senders['V']['username'] = "Open Superb Shoveler"
transaction_senders['V']['username'] = "Likely Imaginary Hound"
transaction_senders['V']['address'] = "785acde6058a670e674aa0f66ccbabe98bbce7b1"
transaction_senders['V']['public_key'] = "0x04ebd187fba2169f7544fc5c1cee4f486c2d498d94f42ed4b570420b6e926da163bc514b" \
"7f3b234bcad3062a48cacf51411d2f7e4dfd079d8eabdfd12f0ee774f6"
transaction_senders['W'] = dict()
transaction_senders['W']['passphrase'] = \
"setup portion luxury fatigue unhappy position pioneer sell angry trust hat magic"
transaction_senders['W']['username'] = "Rowdy Leafy Penguin"
transaction_senders['W']['username'] = "Stable Blueviolet Stonefly"
transaction_senders['W']['address'] = "d5de9a58a3eab0643ecbd01729312215ef647a4d"
transaction_senders['W']['public_key'] = "0x04e801e4cf211a7846fdd96c6591cf75f5c37cb8df6b1bd5c9e4471b6b3f7f2936d29dc93" \
"4820ea0fabd460b90aef3b66c7b1552baf60146ba8fc354c2fa22b3cf"
transaction_senders['X'] = dict()
transaction_senders['X']['passphrase'] = "denial lend kit learn jacket mail ceiling crack affair stool spike sound"
transaction_senders['X']['username'] = "Bland Specific Atlanticsharpnosepuffer"
transaction_senders['X']['username'] = "Polite Experienced Hackee"
transaction_senders['X']['address'] = "0xc9cf2ff3ca98a91f2e3dfc35a13cf8425ecaf082"
transaction_senders['X']['public_key'] = "0x04907b745916c763613654a9a679c6b04da97c142c2ad1f08ebe9412e9745fd9721d5237b" \
"9374a2b3217da001c50481e83467cb98b1a9bd1ed50501638db1f08bd"
transaction_senders['Y'] = dict()
transaction_senders['Y']['passphrase'] = "slight thunder cup divorce hawk paper blush memory shaft extend laundry bone"
transaction_senders['Y']['username'] = "Tricky Wasteful Fishingcat"
transaction_senders['Y']['username'] = "Navajowhite Goldenrod Rasbora"
transaction_senders['Y']['address'] = "0x2a5ed44a7092404ae08369ffde6e54ce47e3761c"
transaction_senders['Y']['public_key'] = "0x04245454f9fe931133388a228bd9ed98e36ad1969f76a027bf92d3a0f26a44ee168a2c790" \
"35d4d1c49b0b932b2f093c3636a11bb8d893f4d719e4d61d9bd52f278"
transaction_senders['Z'] = dict()
transaction_senders['Z']['passphrase'] = "congress club image core lens hope clever transfer tiny true alien favorite"
transaction_senders['Z']['username'] = "Rare Bountiful Borzoi"
transaction_senders['Z']['username'] = "Ill Brisk Cleanerwrasse"
transaction_senders['Z']['address'] = "29ff033fa04f5ba4192823ddbf23f8397809995c"
transaction_senders['Z']['public_key'] = "0x04563c506aaf728a37e19b00dd3db3d0e44acd01069191a68e4063ed09bc47e91eac5e0c" \
"7c77fae568960ec9ce7f1ba7b49d3b930389e387665dcde213c344eafc"
@ -257,48 +257,48 @@ transaction_recipients = dict()
transaction_recipients['A'] = dict()
transaction_recipients['A']['passphrase'] = "lesson pull call also fork credit cycle spray purity force sail hub"
transaction_recipients['A']['username'] = "Roasted Modern Azurevase"
transaction_recipients['A']['username'] = "Genuine Sane Islandcanary"
transaction_recipients['A']['address'] = 'd630b1224683a438582e3e14e35ba5e03513eaab'
transaction_recipients['A']['public_key'] = "0x040f0b01746f3bad9887ffcd6f2099382b0713bcbaa00883709200b17fc65563d9278" \
"200ac1e095e0c5993e95427b44aa93e981798b19b4256f1058125518ec07b"
transaction_recipients['B'] = dict()
transaction_recipients['B']['passphrase'] = "night grit town donate length zoo meat collect vapor brush topic check"
transaction_recipients['B']['username'] = "Classic Forked Gentoopenguin"
transaction_recipients['B']['username'] = "Glass Poised Spoonbill"
transaction_recipients['B']['address'] = "1fc705a336a0a2e48eb3c953ce577e591f2767ad"
transaction_recipients['B']['public_key'] = "0x0476459f2e03920dec063bab5e7e85443bda598a97746cab7eb306d9bcb99fe2548af" \
"301922bc84030ad181876401faef0eda4019fdae1a5cc1b41435536317906"
transaction_recipients['C'] = dict()
transaction_recipients['C']['passphrase'] = "pig public focus dream mango match use aunt machine potato depend toilet"
transaction_recipients['C']['username'] = "Evergreen Lumpy Crustacean"
transaction_recipients['C']['username'] = "Concrete Khaki Velvetcrab"
transaction_recipients['C']['address'] = "702995aa7dc6aad543661aab35494f4986022659"
transaction_recipients['C']['public_key'] = "0x04547d1bdec51a73b4df80c2a6bfa873e38f9c6f5ebeb71ab0350e3baf6e545b34a888" \
"f34e5e26889a79cbb4b28d32c82fce052788172328a3ddb59970978de14f"
transaction_recipients['D'] = dict()
transaction_recipients['D']['passphrase'] = "dog smooth myth loud unveil excite chimney cousin rain license cross palm"
transaction_recipients['D']['username'] = "Clever Thorough Velociraptor"
transaction_recipients['D']['username'] = "Blushing Occasional Nudibranch"
transaction_recipients['D']['address'] = "e71c43413559e40ebcb602fb95c33662926cc000"
transaction_recipients['D']['public_key'] = "0x041ff79cb8e5a8280bcc80d9d28810ae08c96b3558238e0c87f806baffdd3fbeccde9a" \
"041c745fc15ffa7ec428a135edb11ff32104e054de644194509c733e5269"
transaction_recipients['E'] = dict()
transaction_recipients['E']['passphrase'] = "private dial force harsh crunch bottom draw fish image used notable school"
transaction_recipients['E']['username'] = "Huge Delectable Sandpiper"
transaction_recipients['E']['username'] = "Devoted Frank Alpineroadguidetigerbeetle"
transaction_recipients['E']['address'] = "5c1d183ca67f651d864a2c88318c05dc0e32f188"
transaction_recipients['E']['public_key'] = "0x0429f5d1588be860c24ff57b699366bf5e3e25fc697be5e204adfd4cd438de42db5f2" \
"a6fd860b7431a3c91f5f2e1bc8703c0e92b8beb19c8979c1e11550b9e7ce6"
transaction_recipients['F'] = dict()
transaction_recipients['F']['passphrase'] = "gather please ritual cactus plunge cruel foil armor sock topic fence urge"
transaction_recipients['F']['username'] = "Stormy Joyful Wobbegongshark"
transaction_recipients['F']['username'] = "Pretty Super Myna"
transaction_recipients['F']['address'] = "81e0b035fe73f4f1aefeb5c75537c7d9b423149f"
transaction_recipients['F']['public_key'] = "0x04adbd5386508ecfb493d663f3c197aeebc2e3953492680489ee66d5d208e573c20eb" \
"4f0cead0c5634f29df6921f08f8fb5b3cb8a15cb91330d58d37b3358783e6"
transaction_recipients['G'] = dict()
transaction_recipients['G']['passphrase'] = \
"spray tired dentist case please list occur envelope they across picture spatial"
transaction_recipients['G']['username'] = "Suburban Colossal Frogmouth"
transaction_recipients['G']['username'] = "Acrobatic Foolish Marabou"
transaction_recipients['G']['address'] = "b1f8b0db0f12e45d7712625bc53535235d245a9f"
transaction_recipients['G']['public_key'] = "0x04659aa00141aa2f9a0658f56427f3ee06abb7218f5c8a5c6afd377581fde3c474645" \
"334f7cfd2faeac627e65536dca578bc0bad3f91bba0862de5ebac98ef4eeb"
@ -306,7 +306,7 @@ transaction_recipients['G']['public_key'] = "0x04659aa00141aa2f9a0658f56427f3ee0
transaction_recipients['H'] = dict()
transaction_recipients['H']['passphrase'] = \
"rail change device celery metal husband panda avoid often shiver payment real"
transaction_recipients['H']['username'] = "Wellgroomed Navajowhite Fairyfly"
transaction_recipients['H']['username'] = "Prudent Big Nerka"
transaction_recipients['H']['address'] = "0xe9676a57a28800d83301d9d3f9c77fd2e933609c"
transaction_recipients['H']['public_key'] = "0x042b6405c7a4c34342c950cfb330f779ab27f49bc58f35e204fd927abda4706f1b9367" \
"cd68166661a62266447ecfe4f320280174e87f3c7867a3c6583c1933ab5a"
@ -314,14 +314,14 @@ transaction_recipients['H']['public_key'] = "0x042b6405c7a4c34342c950cfb330f779a
transaction_recipients['I'] = dict()
transaction_recipients['I']['passphrase'] = \
"engine equal wisdom saddle icon spring express limit surprise salute unique rose"
transaction_recipients['I']['username'] = "Aggravating Scornful Graysquirrel"
transaction_recipients['I']['username'] = "Teal Sienna Perch"
transaction_recipients['I']['address'] = "0x4e6c60f344b13d730682f0a6d8ae1255c75e730e"
transaction_recipients['I']['public_key'] = "0x041f67fd8c2c4fd2ece77b51a72bb9e31ba8848af8585b4c7e8fcf8f77a750faa868" \
"ada014c77fcb11b9a5342e188d8892b669320dc4f9e6283fb7bdf1dd33897a"
transaction_recipients['J'] = dict()
transaction_recipients['J']['passphrase'] = "estate add believe wonder riot used brain wing lecture misery order echo"
transaction_recipients['J']['username'] = "Extraneous Deficient Crow"
transaction_recipients['J']['username'] = "Seashell Amazing Gemsbuck"
transaction_recipients['J']['address'] = "0xa03a75b7888cac24b35b4d1f5924406f3b491795"
transaction_recipients['J']['public_key'] = "0x04e7e481932714c1a13ffb29fc79446ee9f30d27b4dec47af9dcd20c68a771c2520a0e" \
"7a80804ff59a750693492a65be9682d0b850b4080d976cf9e43ff37ec841"

View File

@ -1,5 +1,7 @@
(ns status-im.test.chat.db
(:require [cljs.test :refer-macros [deftest is testing]]
[status-im.utils.gfycat.core :as gfycat]
[status-im.utils.identicon :as identicon]
[status-im.chat.db :as db]))
(deftest group-chat-name
@ -106,14 +108,16 @@
(is (not (:display-username? actual-m1))))))))
(deftest active-chats-test
(let [active-chat-1 {:is-active true :chat-id "1"}
active-chat-2 {:is-active true :chat-id "2"}
chats {"1" active-chat-1
"2" active-chat-2
"3" {:is-active false :chat-id "3"}}]
(testing "it returns only chats with is-active"
(is (= #{"1" "2"}
(set (keys (db/active-chats {} chats {}))))))))
(with-redefs [gfycat/generate-gfy (constantly "generated")
identicon/identicon (constantly "generated")]
(let [active-chat-1 {:is-active true :chat-id "1"}
active-chat-2 {:is-active true :chat-id "2"}
chats {"1" active-chat-1
"2" active-chat-2
"3" {:is-active false :chat-id "3"}}]
(testing "it returns only chats with is-active"
(is (= #{"1" "2"}
(set (keys (db/active-chats {} chats {})))))))))
#_(deftest messages-with-datemarks
(testing "empty state"

View File

@ -1,5 +1,7 @@
(ns status-im.test.chat.models
(:require [cljs.test :refer-macros [deftest is testing]]
[status-im.utils.gfycat.core :as gfycat]
[status-im.utils.identicon :as identicon]
[status-im.ethereum.json-rpc :as json-rpc]
[status-im.utils.clocks :as utils.clocks]
[status-im.chat.models :as chat]))
@ -44,19 +46,21 @@
(is (= "new-name" (:name actual-chat)))))))
(deftest add-public-chat
(let [topic "topic"
fx (chat/add-public-chat {:db {}} topic)
chat (get-in fx [:db :chats topic])]
(testing "it sets the name"
(is (= topic (:name chat))))
(testing "it sets the participants"
(is (= #{} (:contacts chat))))
(testing "it sets the chat-id"
(is (= topic (:chat-id chat))))
(testing "it sets the group-chat flag"
(is (:group-chat chat)))
(testing "it does not sets the public flag"
(is (:public? chat)))))
(with-redefs [gfycat/generate-gfy (constantly "generated")
identicon/identicon (constantly "generated")]
(let [topic "topic"
fx (chat/add-public-chat {:db {}} topic)
chat (get-in fx [:db :chats topic])]
(testing "it sets the name"
(is (= topic (:name chat))))
(testing "it sets the participants"
(is (= #{} (:contacts chat))))
(testing "it sets the chat-id"
(is (= topic (:chat-id chat))))
(testing "it sets the group-chat flag"
(is (:group-chat chat)))
(testing "it does not sets the public flag"
(is (:public? chat))))))
(deftest clear-history-test
(let [chat-id "1"
@ -115,7 +119,7 @@
(testing "it makes the relevant json-rpc calls"
(let [actual (chat/remove-chat cofx chat-id)]
(is (::json-rpc/call actual))
(is (= 5 (count (::json-rpc/call actual))))))))
(is (= 4 (count (::json-rpc/call actual))))))))
(deftest multi-user-chat?
(let [chat-id "1"]

View File

@ -1,5 +1,7 @@
(ns status-im.test.chat.models.message
(:require [cljs.test :refer-macros [deftest is testing]]
[status-im.utils.gfycat.core :as gfycat]
[status-im.utils.identicon :as identicon]
[status-im.transport.message.protocol :as protocol]
[status-im.chat.models.message :as message]
[status-im.utils.datetime :as time]))
@ -144,35 +146,38 @@
(is (= cofx (message/receive-many cofx [bad-chat-id-message]))))))
(deftest receive-one-to-one
(let [cofx {:db {:chats {"matching" {}}
:multiaccount {:public-key "me"}
:current-chat-id "chat-id"
:view-id :chat}}
valid-message {:chat-id "matching"
:from "matching"
:message-type :user-message
:message-id "1"
:clock-value 1
:timestamp 0}
own-message {:chat-id "matching"
:from "me"
:message-type :user-message
:message-id "1"
:clock-value 1
:timestamp 0}
(with-redefs [gfycat/generate-gfy (constantly "generated")
identicon/identicon (constantly "generated")]
bad-chat-id-message {:chat-id "bad-chat-id"
:from "not-matching"
:message-type :user-message
:message-id "1"
:clock-value 1
:timestamp 0}]
(testing "a valid message"
(is (get-in (message/receive-many cofx [valid-message]) [:db :chats "matching" :messages "1"])))
(testing "our own message"
(is (get-in (message/receive-many cofx [own-message]) [:db :chats "matching" :messages "1"])))
(testing "a message with non matching chat-id"
(is (get-in (message/receive-many cofx [bad-chat-id-message]) [:db :chats "not-matching" :messages "1"])))))
(let [cofx {:db {:chats {"matching" {}}
:multiaccount {:public-key "me"}
:current-chat-id "chat-id"
:view-id :chat}}
valid-message {:chat-id "matching"
:from "matching"
:message-type :user-message
:message-id "1"
:clock-value 1
:timestamp 0}
own-message {:chat-id "matching"
:from "me"
:message-type :user-message
:message-id "1"
:clock-value 1
:timestamp 0}
bad-chat-id-message {:chat-id "bad-chat-id"
:from "not-matching"
:message-type :user-message
:message-id "1"
:clock-value 1
:timestamp 0}]
(testing "a valid message"
(is (get-in (message/receive-many cofx [valid-message]) [:db :chats "matching" :messages "1"])))
(testing "our own message"
(is (get-in (message/receive-many cofx [own-message]) [:db :chats "matching" :messages "1"])))
(testing "a message with non matching chat-id"
(is (get-in (message/receive-many cofx [bad-chat-id-message]) [:db :chats "not-matching" :messages "1"]))))))
(deftest delete-message
(let [timestamp (time/now)

View File

@ -1,11 +1,13 @@
(ns status-im.test.contacts.db
(:require [cljs.test :refer-macros [deftest is testing]]
[status-im.utils.gfycat.core :as gfycat]
[status-im.utils.identicon :as identicon]
[status-im.contact.db :as contact.db]))
(deftest contacts-subs
(testing "get-all-contacts-in-group-chat"
(with-redefs [identicon/identicon (constantly "generated")]
(with-redefs [gfycat/generate-gfy (constantly "generated")
identicon/identicon (constantly "generated")]
(let [chat-contact-ids #{"0x04fcf40c526b09ff9fb22f4a5dbd08490ef9b64af700870f8a0ba2133f4251d5607ed83cd9047b8c2796576bc83fa0de23a13a4dced07654b8ff137fe744047917"
"0x04985040682b77a32bb4bb58268a0719bd24ca4d07c255153fe1eb2ccd5883669627bd1a092d7cc76e8e4b9104327667b19dcda3ac469f572efabe588c38c1985f"
"0x048a2f8b80c60f89a91b4c1316e56f75b087f446e7b8701ceca06a40142d8efe1f5aa36bd0fee9e248060a8d5207b43ae98bef4617c18c71e66f920f324869c09f"}
@ -33,8 +35,8 @@
admins
contacts
current-multiaccount)
[{:name "Snappy Impressive Leonberger"
:photo-path "generated"
[{:name "generated"
:identicon "generated"
:admin? true
:address "71adb0644e2b590e37dafdfea8bd58f0c7668c7f"
:public-key "0x04fcf40c526b09ff9fb22f4a5dbd08490ef9b64af700870f8a0ba2133f4251d5607ed83cd9047b8c2796576bc83fa0de23a13a4dced07654b8ff137fe744047917"

View File

@ -1,5 +1,7 @@
(ns status-im.test.group-chats.core
(:require [cljs.test :refer-macros [deftest is testing]]
[status-im.utils.gfycat.core :as gfycat]
[status-im.utils.identicon :as identicon]
[status-im.ethereum.json-rpc :as json-rpc]
[status-im.utils.clocks :as utils.clocks]
[status-im.utils.config :as config]
@ -30,145 +32,148 @@
(is (= 3 (group-chats/get-last-clock-value {:db {:chats {chat-id {:last-clock-value 3}}}} chat-id))))
(deftest handle-group-membership-update-test
(testing "a brand new chat"
(let [actual (->
(group-chats/handle-membership-update {:now 0 :db {}} initial-message "payload" admin)
:db
:chats
(get chat-id))]
(testing "it creates a new chat"
(is actual))
(testing "it sets the right chat-name"
(is (= "chat-name"
(:name actual))))
(testing "it sets the right chat-id"
(is (= chat-id
(:chat-id actual))))
(testing "it sets the right participants"
(is (= #{member-1 member-2 member-3}
(:contacts actual))))
(testing "it sets the updates"
(is (= (:membership-updates initial-message)
(:membership-updates actual))))
(testing "it sets the right admins"
(is (= #{admin}
(:admins actual))))
(testing "it adds a system message"
(is (= 3 (count (:messages actual)))))
(testing "it adds the right text"
(is (= ["group-chat-created"
"group-chat-member-added"
"group-chat-member-added"]
(map (comp :text :content) (sort-by :clock-value (vals (:messages actual)))))))))
(testing "a chat with the wrong id"
(let [bad-chat-id (str random-id member-2)
actual (->
(group-chats/handle-membership-update
{:now 0 :db {}}
(assoc initial-message :chat-id bad-chat-id)
"payload"
admin)
:db
:chats
(get bad-chat-id))]
(testing "it does not create a chat"
(is (not actual)))))
(testing "an already existing chat"
(let [cofx (assoc
(group-chats/handle-membership-update {:now 0 :db {:multiaccount {:public-key member-3}}} initial-message "payload" admin)
:now 0)]
(testing "the message has already been received"
(let [actual (group-chats/handle-membership-update cofx initial-message "payload" admin)]
(testing "it noops"
(is (=
(get-in cofx [:db :chats chat-id])
(get-in actual [:db :chats chat-id]))))))
(testing "a chat we have deleted"
(let [after-leaving-cofx (-> (group-chats/handle-membership-update cofx
{:chat-id chat-id
:membership-updates [{:from member-1
:events [{:type "chat-created"
:clock-value 1
:name "group-name"}
{:type "admins-added"
:clock-value 10
:members [member-2]}
{:type "admin-removed"
:clock-value 11
:member member-1}]}
{:from member-3
:events [{:type "member-removed"
:clock-value 12
:member member-3}]}]}
"payload"
member-3)
(assoc-in [:db :chats chat-id :is-active] false))
after-been-invited-again-cofx (group-chats/handle-membership-update (assoc after-leaving-cofx :now 0)
{:chat-id chat-id
:membership-updates [{:from member-1
:events [{:type "chat-created"
:clock-value 1
:name "group-name"}
{:type "admins-added"
:clock-value 10
:members [member-2]}
{:type "admin-removed"
:clock-value 11
:member member-1}]}
{:from member-2
:events [{:type "members-added"
:clock-value 13
:members [member-3]}]}]}
"payload"
member-2)]
(with-redefs [gfycat/generate-gfy (constantly "generated")
identicon/identicon (constantly "generated")]
(testing "it sets the chat active after been invited again"
(is (get-in after-been-invited-again-cofx [:db :chats chat-id :is-active])))))
(testing "a new message comes in"
(let [actual (group-chats/handle-membership-update cofx
{:chat-id chat-id
:membership-updates [{:from member-1
:events [{:type "chat-created"
:clock-value 1
:name "group-name"}
{:type "admins-added"
:clock-value 10
:members [member-2]}
{:type "admin-removed"
:clock-value 11
:member member-1}]}
{:from member-2
:events [{:type "member-removed"
:clock-value 12
:member member-3}
{:type "members-added"
:clock-value 12
:members [member-4]}
{:type "name-changed"
:clock-value 13
:name "new-name"}]}]}
"payload"
member-3)
actual-chat (get-in actual [:db :chats chat-id])]
(testing "the chat is updated"
(is actual-chat))
(testing "admins are updated"
(is (= #{member-2} (:admins actual-chat))))
(testing "members are updated"
(is (= #{member-1 member-2 member-4} (:contacts actual-chat))))
(testing "the name is updated"
(is (= "new-name" (:name actual-chat))))
(testing "it adds a system message"
(is (= 7 (count (:messages actual-chat)))))
(testing "it sets the right text"
(is (= ["group-chat-created"
"group-chat-member-added"
"group-chat-member-added"
"group-chat-admin-added"
"group-chat-member-added"
"group-chat-member-removed"
"group-chat-name-changed"]
(map (comp :text :content) (sort-by :clock-value (vals (:messages actual-chat))))))))))))
(testing "a brand new chat"
(let [actual (->
(group-chats/handle-membership-update {:now 0 :db {}} initial-message "payload" admin)
:db
:chats
(get chat-id))]
(testing "it creates a new chat"
(is actual))
(testing "it sets the right chat-name"
(is (= "chat-name"
(:name actual))))
(testing "it sets the right chat-id"
(is (= chat-id
(:chat-id actual))))
(testing "it sets the right participants"
(is (= #{member-1 member-2 member-3}
(:contacts actual))))
(testing "it sets the updates"
(is (= (:membership-updates initial-message)
(:membership-updates actual))))
(testing "it sets the right admins"
(is (= #{admin}
(:admins actual))))
(testing "it adds a system message"
(is (= 3 (count (:messages actual)))))
(testing "it adds the right text"
(is (= ["group-chat-created"
"group-chat-member-added"
"group-chat-member-added"]
(map (comp :text :content) (sort-by :clock-value (vals (:messages actual)))))))))
(testing "a chat with the wrong id"
(let [bad-chat-id (str random-id member-2)
actual (->
(group-chats/handle-membership-update
{:now 0 :db {}}
(assoc initial-message :chat-id bad-chat-id)
"payload"
admin)
:db
:chats
(get bad-chat-id))]
(testing "it does not create a chat"
(is (not actual)))))
(testing "an already existing chat"
(let [cofx (assoc
(group-chats/handle-membership-update {:now 0 :db {:multiaccount {:public-key member-3}}} initial-message "payload" admin)
:now 0)]
(testing "the message has already been received"
(let [actual (group-chats/handle-membership-update cofx initial-message "payload" admin)]
(testing "it noops"
(is (=
(get-in cofx [:db :chats chat-id])
(get-in actual [:db :chats chat-id]))))))
(testing "a chat we have deleted"
(let [after-leaving-cofx (-> (group-chats/handle-membership-update cofx
{:chat-id chat-id
:membership-updates [{:from member-1
:events [{:type "chat-created"
:clock-value 1
:name "group-name"}
{:type "admins-added"
:clock-value 10
:members [member-2]}
{:type "admin-removed"
:clock-value 11
:member member-1}]}
{:from member-3
:events [{:type "member-removed"
:clock-value 12
:member member-3}]}]}
"payload"
member-3)
(assoc-in [:db :chats chat-id :is-active] false))
after-been-invited-again-cofx (group-chats/handle-membership-update (assoc after-leaving-cofx :now 0)
{:chat-id chat-id
:membership-updates [{:from member-1
:events [{:type "chat-created"
:clock-value 1
:name "group-name"}
{:type "admins-added"
:clock-value 10
:members [member-2]}
{:type "admin-removed"
:clock-value 11
:member member-1}]}
{:from member-2
:events [{:type "members-added"
:clock-value 13
:members [member-3]}]}]}
"payload"
member-2)]
(testing "it sets the chat active after been invited again"
(is (get-in after-been-invited-again-cofx [:db :chats chat-id :is-active])))))
(testing "a new message comes in"
(let [actual (group-chats/handle-membership-update cofx
{:chat-id chat-id
:membership-updates [{:from member-1
:events [{:type "chat-created"
:clock-value 1
:name "group-name"}
{:type "admins-added"
:clock-value 10
:members [member-2]}
{:type "admin-removed"
:clock-value 11
:member member-1}]}
{:from member-2
:events [{:type "member-removed"
:clock-value 12
:member member-3}
{:type "members-added"
:clock-value 12
:members [member-4]}
{:type "name-changed"
:clock-value 13
:name "new-name"}]}]}
"payload"
member-3)
actual-chat (get-in actual [:db :chats chat-id])]
(testing "the chat is updated"
(is actual-chat))
(testing "admins are updated"
(is (= #{member-2} (:admins actual-chat))))
(testing "members are updated"
(is (= #{member-1 member-2 member-4} (:contacts actual-chat))))
(testing "the name is updated"
(is (= "new-name" (:name actual-chat))))
(testing "it adds a system message"
(is (= 7 (count (:messages actual-chat)))))
(testing "it sets the right text"
(is (= ["group-chat-created"
"group-chat-member-added"
"group-chat-member-added"
"group-chat-admin-added"
"group-chat-member-added"
"group-chat-member-removed"
"group-chat-name-changed"]
(map (comp :text :content) (sort-by :clock-value (vals (:messages actual-chat)))))))))))))
(deftest build-group-test
(testing "only adds"

View File

@ -1,7 +1,8 @@
(ns status-im.test.pairing.core
(:require [cljs.test :refer-macros [deftest is testing]]
[status-im.transport.message.pairing :as transport.pairing]
[status-im.utils.gfycat.core :as gfycat]
[status-im.utils.identicon :as identicon]
[status-im.transport.message.pairing :as transport.pairing]
[status-im.utils.pairing :as pairing.utils]
[status-im.utils.config :as config]
[status-im.pairing.core :as pairing]))
@ -129,7 +130,8 @@
(is (= expected (pairing/merge-contact contact-1 contact-2))))))
(deftest handle-sync-installation-test
(with-redefs [identicon/identicon (constantly "generated")]
(with-redefs [gfycat/generate-gfy (constantly "generated")
identicon/identicon (constantly "generated")]
(testing "syncing contacts"
(let [old-contact-1 {:name "old-contact-one"
:public-key "contact-1"

View File

@ -53,7 +53,6 @@
[status-im.test.utils.contenthash]
[status-im.test.utils.datetime]
[status-im.test.utils.fx]
[status-im.test.utils.gfycat.core]
[status-im.test.utils.http]
[status-im.test.utils.money]
[status-im.test.utils.prices]
@ -135,7 +134,6 @@
'status-im.test.utils.contenthash
'status-im.test.utils.datetime
'status-im.test.utils.fx
'status-im.test.utils.gfycat.core
'status-im.test.utils.http
'status-im.test.utils.money
'status-im.test.utils.prices

View File

@ -46,6 +46,7 @@
(def sig "0x04325367620ae20dd878dbb39f69f02c567d789dd21af8a88623dc5b529827c2812571c380a2cd8236a2851b8843d6486481166c39debf60a5d30b9099c66213e4")
(def messages [{:id "someid"
:metadata {:author {:publicKey sig}}
:message {:sig sig
:ttl 10
:timestamp 1527692015

View File

@ -1,5 +1,7 @@
(ns status-im.test.tribute-to-talk.core
(:require [cljs.test :refer-macros [deftest testing is]]
[status-im.utils.gfycat.core :as gfycat]
[status-im.utils.identicon :as identicon]
[status-im.tribute-to-talk.core :as tribute-to-talk]
[status-im.utils.money :as money]))
@ -93,43 +95,45 @@
:config {:NetworkId 3}}}})
(deftest check-tribute
(testing "No contract in network, own public key"
(let [result (tribute-to-talk/check-tribute {:db test-db} my-public-key)]
(is (= (-> test-db
(assoc :navigation/screen-params {:tribute-to-talk {:unavailable? true}})
(assoc-in [:multiaccount :settings] {:tribute-to-talk {:mainnet nil}}))
(:db result)))))
(with-redefs [gfycat/generate-gfy (constantly "generated")
identicon/identicon (constantly "generated")]
(testing "No contract in network, own public key"
(let [result (tribute-to-talk/check-tribute {:db test-db} my-public-key)]
(is (= (-> test-db
(assoc :navigation/screen-params {:tribute-to-talk {:unavailable? true}})
(assoc-in [:multiaccount :settings] {:tribute-to-talk {:mainnet nil}}))
(:db result)))))
(testing "No contract in network, another public key"
(let [result (tribute-to-talk/check-tribute {:db test-db} public-key)]
(is (= {:disabled? true}
(get-in result [:db :contacts/contacts public-key :tribute-to-talk])))))
(testing "No contract in network, another public key"
(let [result (tribute-to-talk/check-tribute {:db test-db} public-key)]
(is (= {:disabled? true}
(get-in result [:db :contacts/contacts public-key :tribute-to-talk])))))
(testing "Contract in network, another public key"
(let [result (tribute-to-talk/check-tribute {:db (assoc test-db :networks/current-network "testnet_rpc")}
public-key)]
(is (= "0xC61aa0287247a0398589a66fCD6146EC0F295432"
(get-in result [:tribute-to-talk/get-tribute :contract])))))
(testing "Contract in network, another public key"
(let [result (tribute-to-talk/check-tribute {:db (assoc test-db :networks/current-network "testnet_rpc")}
public-key)]
(is (= "0xC61aa0287247a0398589a66fCD6146EC0F295432"
(get-in result [:tribute-to-talk/get-tribute :contract])))))
(testing "Added by other user"
(let [result (tribute-to-talk/check-tribute
{:db (update-in test-db
[:contacts/contacts public-key :system-tags]
conj :contact/request-received)}
public-key)]
(is (= result nil))))
(testing "Added by other user"
(let [result (tribute-to-talk/check-tribute
{:db (update-in test-db
[:contacts/contacts public-key :system-tags]
conj :contact/request-received)}
public-key)]
(is (= result nil))))
(testing "Group chat"
(let [result (tribute-to-talk/check-tribute
{:db (assoc-in test-db [:chats public-key :group-chat] true)}
public-key)]
(is (= result nil))))
(testing "Group chat"
(let [result (tribute-to-talk/check-tribute
{:db (assoc-in test-db [:chats public-key :group-chat] true)}
public-key)]
(is (= result nil))))
(testing "Added by this user"
(let [result (tribute-to-talk/check-tribute
{:db (update-in test-db
[:contacts/contacts public-key :system-tags]
conj :contact/added)}
public-key)]
(is (= {:disabled? true}
(get-in result [:db :contacts/contacts public-key :tribute-to-talk]))))))
(testing "Added by this user"
(let [result (tribute-to-talk/check-tribute
{:db (update-in test-db
[:contacts/contacts public-key :system-tags]
conj :contact/added)}
public-key)]
(is (= {:disabled? true}
(get-in result [:db :contacts/contacts public-key :tribute-to-talk])))))))

View File

@ -1,5 +1,7 @@
(ns status-im.test.tribute-to-talk.whitelist
(:require [cljs.test :refer-macros [deftest testing is]]
[status-im.utils.gfycat.core :as gfycat]
[status-im.utils.identicon :as identicon]
[status-im.tribute-to-talk.whitelist :as whitelist]))
(def user-contacts
@ -43,26 +45,30 @@
[:db :contacts/whitelist]))))))
(deftest mark-tribute-paid
(let [result (whitelist/mark-tribute-paid {:db {}} "bob")]
(testing "contact was added to whitelist"
(is (= (get-in result
[:db :contacts/whitelist])
#{"bob"})))
(testing "contact was tagged as tribute paid"
(is (= (get-in result
[:db :contacts/contacts "bob" :system-tags])
#{:tribute-to-talk/paid})))))
(with-redefs [gfycat/generate-gfy (constantly "generated")
identicon/identicon (constantly "generated")]
(let [result (whitelist/mark-tribute-paid {:db {}} "bob")]
(testing "contact was added to whitelist"
(is (= (get-in result
[:db :contacts/whitelist])
#{"bob"})))
(testing "contact was tagged as tribute paid"
(is (= (get-in result
[:db :contacts/contacts "bob" :system-tags])
#{:tribute-to-talk/paid}))))))
(deftest mark-tribute-received
(let [result (whitelist/mark-tribute-received {:db {}} "bob")]
(testing "contact was added to whitelist"
(is (= (get-in result
[:db :contacts/whitelist])
#{"bob"})))
(testing "contact was tagged as tribute paid"
(is (= (get-in result
[:db :contacts/contacts "bob" :system-tags])
#{:tribute-to-talk/received})))))
(with-redefs [gfycat/generate-gfy (constantly "generated")
identicon/identicon (constantly "generated")]
(let [result (whitelist/mark-tribute-received {:db {}} "bob")]
(testing "contact was added to whitelist"
(is (= (get-in result
[:db :contacts/whitelist])
#{"bob"})))
(testing "contact was tagged as tribute paid"
(is (= (get-in result
[:db :contacts/contacts "bob" :system-tags])
#{:tribute-to-talk/received}))))))
(def sender-pk "0x04263d74e55775280e75b4a4e9a45ba59fc372793a869c5d9c4fa2100556d9963e3f4fbfa1724ec94a46e6da057540ab248ed1f5eb956e36e3129ecd50fade2c97")
(def sender-address "0xdff1a5e4e57d9723b3294e0f4413372e3ea9a8ff")
@ -94,34 +100,36 @@
[:db :contacts/whitelist])))))
(deftest filter-message
(testing "not a user message"
(whitelist/filter-message
ttt-enabled-multiaccount
:unfiltered-fx
:not-user-message
nil
"public-key"))
(testing "user is whitelisted"
(whitelist/filter-message
(whitelist/enable-whitelist ttt-enabled-multiaccount)
:unfiltered-fx
:user-message
nil
"whitelisted because added"))
(testing "tribute to talk is disabled"
(whitelist/filter-message
ttt-disabled-multiaccount
:unfiltered-fx
:user-message
nil
"public-key"))
(testing "user is not whitelisted but transaction is valid"
(let [result (whitelist/filter-message
ttt-enabled-multiaccount
#(assoc % :message-received true)
:user-message
"transaction-hash-1"
sender-pk)]
(is (contains? (get-in result [:db :contacts/whitelist])
sender-pk))
(is (:message-received result)))))
(with-redefs [gfycat/generate-gfy (constantly "generated")
identicon/identicon (constantly "generated")]
(testing "not a user message"
(whitelist/filter-message
ttt-enabled-multiaccount
:unfiltered-fx
:not-user-message
nil
"public-key"))
(testing "user is whitelisted"
(whitelist/filter-message
(whitelist/enable-whitelist ttt-enabled-multiaccount)
:unfiltered-fx
:user-message
nil
"whitelisted because added"))
(testing "tribute to talk is disabled"
(whitelist/filter-message
ttt-disabled-multiaccount
:unfiltered-fx
:user-message
nil
"public-key"))
(testing "user is not whitelisted but transaction is valid"
(let [result (whitelist/filter-message
ttt-enabled-multiaccount
#(assoc % :message-received true)
:user-message
"transaction-hash-1"
sender-pk)]
(is (contains? (get-in result [:db :contacts/whitelist])
sender-pk))
(is (:message-received result))))))

View File

@ -1,14 +0,0 @@
(ns status-im.test.utils.gfycat.core
(:require [cljs.test :refer-macros [deftest is]]
[status-im.utils.gfycat.core :as gfy]))
(def message "Names are only deterministic as long as word lists do not change!\nIf you change the lists, please change the tests as well.")
(deftest test-generate-gfy
(is (= (gfy/generate-gfy "57348975ff9199ca636207a396b915d6b6a675b4") "Winged Fitting Mosquito") message)
(is (= (gfy/generate-gfy "e63d083d2d7a13a14632983b5820529445ca8109") "Mediumvioletred Melodic Waterdogs") message)
(is (= (gfy/generate-gfy "57348975ff9199ca636207a396b915d6b6a675b4") "Winged Fitting Mosquito") message)
(is (= (gfy/generate-gfy "26cf649aebb252a75aebc588e0d9ce93789dbe0b") "Educated Upright Arcticseal") message)
(is (= (gfy/generate-gfy "e63d083d2d7a13a14632983b5820529445ca8109") "Mediumvioletred Melodic Waterdogs") message)
(is (= (gfy/generate-gfy nil) gfy/unknown-gfy) message)
(is (= (gfy/generate-gfy "0") gfy/unknown-gfy) message))

View File

@ -1,39 +1,43 @@
(ns status-im.test.utils.universal-links.core
(:require [cljs.test :refer-macros [deftest is testing]]
[status-im.utils.gfycat.core :as gfycat]
[status-im.utils.identicon :as identicon]
[re-frame.core :as re-frame]
[status-im.utils.universal-links.core :as links]))
(deftest handle-url-test
(testing "the user is not logged in"
(testing "it stores the url for later processing"
(is (= {:db {:universal-links/url "some-url"}}
(links/handle-url {:db {}} "some-url")))))
(testing "the user is logged in"
(let [db {:multiaccount {:public-key "pk"}
:universal-links/url "some-url"}]
(testing "it clears the url"
(is (nil? (get-in (links/handle-url {:db db} "some-url")
[:db :universal-links/url]))))
(testing "a public chat link"
(testing "it joins the chat"
(is (get-in (links/handle-url {:db db} "status-im://chat/public/status")
[:db :chats "status"]))))
(with-redefs [gfycat/generate-gfy (constantly "generated")
identicon/identicon (constantly "generated")]
(testing "the user is not logged in"
(testing "it stores the url for later processing"
(is (= {:db {:universal-links/url "some-url"}}
(links/handle-url {:db {}} "some-url")))))
(testing "the user is logged in"
(let [db {:multiaccount {:public-key "pk"}
:universal-links/url "some-url"}]
(testing "it clears the url"
(is (nil? (get-in (links/handle-url {:db db} "some-url")
[:db :universal-links/url]))))
(testing "a public chat link"
(testing "it joins the chat"
(is (get-in (links/handle-url {:db db} "status-im://chat/public/status")
[:db :chats "status"]))))
(testing "a browse dapp link"
(testing "it open the dapps"
(is
(= "www.cryptokitties.co"
(:browser/show-browser-selection (links/handle-url {:db db} "status-im://browse/www.cryptokitties.co"))))))
(testing "a user profile link"
(testing "it loads the profile"
(let [actual (links/handle-url {:db db} "status-im://user/0x04fbce10971e1cd7253b98c7b7e54de3729ca57ce41a2bfb0d1c4e0a26f72c4b6913c3487fa1b4bb86125770f1743fb4459da05c1cbe31d938814cfaf36e252073")]
(is (= "0x04fbce10971e1cd7253b98c7b7e54de3729ca57ce41a2bfb0d1c4e0a26f72c4b6913c3487fa1b4bb86125770f1743fb4459da05c1cbe31d938814cfaf36e252073" (get-in actual [:db :contacts/identity]))))))
(testing "if does nothing because the link is invalid"
(is (= (links/handle-url {:db db} "status-im://user/CONTACTCODE")
nil)))
(testing "a not found url"
(testing "it does nothing"
(is (nil? (links/handle-url {:db db} "status-im://not-existing"))))))))
(testing "a browse dapp link"
(testing "it open the dapps"
(is
(= "www.cryptokitties.co"
(:browser/show-browser-selection (links/handle-url {:db db} "status-im://browse/www.cryptokitties.co"))))))
(testing "a user profile link"
(testing "it loads the profile"
(let [actual (links/handle-url {:db db} "status-im://user/0x04fbce10971e1cd7253b98c7b7e54de3729ca57ce41a2bfb0d1c4e0a26f72c4b6913c3487fa1b4bb86125770f1743fb4459da05c1cbe31d938814cfaf36e252073")]
(is (= "0x04fbce10971e1cd7253b98c7b7e54de3729ca57ce41a2bfb0d1c4e0a26f72c4b6913c3487fa1b4bb86125770f1743fb4459da05c1cbe31d938814cfaf36e252073" (get-in actual [:db :contacts/identity]))))))
(testing "if does nothing because the link is invalid"
(is (= (links/handle-url {:db db} "status-im://user/CONTACTCODE")
nil)))
(testing "a not found url"
(testing "it does nothing"
(is (nil? (links/handle-url {:db db} "status-im://not-existing")))))))))
(deftest url-event-listener
(testing "the url is not nil"