Skip to content

Commit

Permalink
Merge branch 'develop' into milad/17321-about-tab-collectible-page
Browse files Browse the repository at this point in the history
  • Loading branch information
mmilad75 authored Jan 10, 2024
2 parents 5a2bb35 + 5a707c0 commit 9d7a4ed
Show file tree
Hide file tree
Showing 12 changed files with 78 additions and 52 deletions.
35 changes: 26 additions & 9 deletions ci/tools/Jenkinsfile.nix-cache
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ pipeline {
/* See nix/README.md */
NIX_IGNORE_SYMLINK_STORE = 1
/* we source .bash_profile to be able to use nix-store */
NIX_SSHOPTS = "-o StrictHostKeyChecking=no source .profile;"
NIX_SSHOPTS = "-oStrictHostKeyChecking=no"
NIX_CONF_DIR = "${env.WORKSPACE}/nix"
NIX_STORE_CMD = '/nix/var/nix/profiles/default/bin/nix-store'
NIX_SSH_REMOTE = "ssh://${params.NIX_CACHE_USER}@${params.NIX_CACHE_HOST}?remote-program=${env.NIX_STORE_CMD}"
}

options {
Expand All @@ -42,19 +44,21 @@ pipeline {
steps { script {
nix.shell('nix-env -i openssh', sandbox: false, pure: false)
/* some build targets don't build on MacOS */
os = sh(script: 'uname', returnStdout: true)
arch = sh(script: 'arch', returnStdout: true)
os = sh(script: 'uname', returnStdout: true).trim()
arch = sh(script: 'arch', returnStdout: true).trim()
} }
}
stage('Build status-go') {
steps { script {
def platforms = ['mobile.android', 'mobile.ios', 'library']
if (os != 'Darwin') { platforms.removeAll { it == 'mobile.ios' } }
/* FIXME: Remove this when #16237 is merged. */
/* FIXME: "'x86_64-darwin' with features {} is required to build" */
if (arch == 'arm64') { platforms.removeAll { it == 'mobile.android' } }
platforms.each { os ->
platforms.each { platform ->
/* Allow for Android builds on Apple ARM. */
env.NIXPKGS_SYSTEM_OVERRIDE = nixSysOverride(os, arch, platform)
nix.build(
attr: "targets.status-go.${os}",
attr: "targets.status-go.${platform}",
sandbox: false,
link: false
)
Expand All @@ -74,6 +78,8 @@ pipeline {
}
stage('Build android deps') {
steps { script {
/* Allow for Android builds on Apple ARM. */
env.NIXPKGS_SYSTEM_OVERRIDE = nixSysOverride(os, arch, 'android')
/* Build/fetch deps required to build android release. */
nix.build(
attr: 'targets.mobile.android.release.buildInputs',
Expand All @@ -86,9 +92,13 @@ pipeline {
stage('Build nix shell deps') {
steps { script {
def shells = ['android', 'ios', 'fastlane', 'keytool', 'clojure', 'gradle']
if (os != "Darwin") { shells.removeAll { it == 'ios' } }
if (os != 'Darwin') { shells.removeAll { it == 'ios' } }
/* FIXME: "'x86_64-darwin' with features {} is required to build" */
if (arch == 'arm64') { shells.removeAll { it == 'android' } }
/* Build/fetch deps required to start default Nix shell. */
shells.each { shell ->
/* Allow for Android builds on Apple ARM. */
env.NIXPKGS_SYSTEM_OVERRIDE = nixSysOverride(os, arch, shell)
nix.build(
attr: "shells.${shell}.buildInputs",
sandbox: false,
Expand All @@ -103,8 +113,7 @@ pipeline {
nix.shell("""
find /nix/store/ -mindepth 1 -maxdepth 1 -type d \
-not -name '*.links' -and -not -name '*-status-mobile-*' \
| xargs nix copy \
--to ssh-ng://${params.NIX_CACHE_USER}@${params.NIX_CACHE_HOST}
| xargs nix copy --to ${NIX_SSH_REMOTE}
""",
pure: false
)
Expand All @@ -119,3 +128,11 @@ pipeline {
} }
}
}

def nixSysOverride(os, arch, target='android') {
return (
os == 'Darwin' &&
arch == 'arm64' &&
target =~ /.*android$/
) ? 'x86_64-darwin' : ''
}
2 changes: 1 addition & 1 deletion nix/scripts/clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ if [[ -n "${nixResultPath}" ]]; then
toDelete=$(findByResult "${nixResultPath}")
else
# use regular expression that should match all status-mobile build artifacts
toDelete=$(findByRegex '.*-status-(react|go)-(shell|source|build|patched-npm-gradle-modules).*')
toDelete=$(findByRegex '.*-status-(mobile|go)-(shell|source|build|patched-npm-gradle-modules).*')
fi

# remove duplicates and return
Expand Down
12 changes: 5 additions & 7 deletions src/status_im/contexts/profile/login/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,10 @@
(assoc :chats/loading? true
:networks/current-network current-network
:networks/networks (merge networks config/default-networks-by-id)
:profile/profile (merge profile-overview settings))
(assoc-in [:wallet :ui :tokens-loading?] true))
:fx [[:dispatch [:wallet/get-ethereum-chains]]
[:dispatch [:universal-links/generate-profile-url]]
[:dispatch [:community/fetch]]]}
:profile/profile (merge profile-overview settings)))
:fx [[:dispatch [:universal-links/generate-profile-url]]
[:dispatch [:community/fetch]]
[:dispatch [:wallet/initialize]]]}
(notifications/load-preferences)
(data-store.chats/fetch-chats-preview
{:on-success
Expand Down Expand Up @@ -125,8 +124,7 @@
:on-error #(log/error
"failed to start messenger")}]
:check-eip1559-activation {:network-id network-id}
:effects.profile/enable-local-notifications nil
:dispatch-n [[:wallet/get-accounts]]}
:effects.profile/enable-local-notifications nil}
(not (:universal-links/handling db))
(assoc :effects.chat/open-last-chat (get-in db [:profile/profile :key-uid]))
notifications-enabled?
Expand Down
2 changes: 1 addition & 1 deletion src/status_im/contexts/wallet/data_store.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
(update-vals #(cske/transform-keys csk/->kebab-case %))
(update-vals #(mapv rpc->balances-per-chain %))))

(defn <-rpc
(defn rpc->network
[network]
(-> network
(set/rename-keys
Expand Down
25 changes: 15 additions & 10 deletions src/status_im/contexts/wallet/edit_account/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
(defn- show-save-account-toast
[updated-key]
(let [message (case updated-key
:name :t/edit-wallet-account-name-updated-message
:color :t/edit-wallet-account-colour-updated-message
:emoji :t/edit-wallet-account-emoji-updated-message
:prod-preferred-chain-ids :t/edit-wallet-network-preferences-updated-message
:name :t/edit-wallet-account-name-updated-message
:color :t/edit-wallet-account-colour-updated-message
:emoji :t/edit-wallet-account-emoji-updated-message
(:prod-preferred-chain-ids
:test-preferred-chain-ids) :t/edit-wallet-network-preferences-updated-message
nil)]
(rf/dispatch [:toasts/upsert
{:id :edit-account
Expand Down Expand Up @@ -50,11 +51,15 @@
:new-value @edited-account-name}))]
(fn []
(let [{:keys [name emoji address color watch-only?]
:as account} (rf/sub [:wallet/current-viewing-account])
network-details (rf/sub [:wallet/network-preference-details])
account-name (or @edited-account-name name)
button-disabled? (or (nil? @edited-account-name)
(= name @edited-account-name))]
:as account} (rf/sub [:wallet/current-viewing-account])
network-details (rf/sub [:wallet/network-preference-details])
test-networks-enabled? (rf/sub [:profile/test-networks-enabled?])
network-preferences-key (if test-networks-enabled?
:test-preferred-chain-ids
:prod-preferred-chain-ids)
account-name (or @edited-account-name name)
button-disabled? (or (nil? @edited-account-name)
(= name @edited-account-name))]
[create-or-edit-account/view
{:page-nav-right-side [{:icon-name :i/delete
:on-press #(js/alert "Delete account: to be implemented")}]
Expand Down Expand Up @@ -95,7 +100,7 @@
(rf/dispatch [:hide-bottom-sheet])
(save-account
{:account account
:updated-key :prod-preferred-chain-ids
:updated-key network-preferences-key
:new-value chain-ids}))
:watch-only? watch-only?}])}]))
:container-style style/data-item}]]))))
10 changes: 7 additions & 3 deletions src/status_im/contexts/wallet/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,13 @@
(let [network-data
{:test (map #(->> %
:Test
data-store/<-rpc)
data-store/rpc->network)
data)
:prod (map #(->> %
:Prod
data-store/<-rpc)
data-store/rpc->network)
data)}]
{:db (assoc db :wallet/networks network-data)})))
{:db (assoc-in db [:wallet :networks] network-data)})))

(rf/reg-event-fx :wallet/find-ens
(fn [{:keys [db]} [input contacts chain-id cb]]
Expand Down Expand Up @@ -327,3 +327,7 @@
(fn [_ [explorer-link address]]
{:fx [[:dispatch [:hide-bottom-sheet]]
[:dispatch [:browser.ui/open-url (str explorer-link "/" address)]]]}))

(rf/reg-event-fx :wallet/initialize
(fn []
{:fx [[:dispatch-n [[:wallet/get-ethereum-chains] [:wallet/get-accounts]]]]}))
1 change: 0 additions & 1 deletion src/status_im/subs/profile.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@
(fn [profile]
(:test-networks-enabled? profile)))


(re-frame/reg-sub
:multiaccount/contact
:<- [:profile/profile]
Expand Down
1 change: 0 additions & 1 deletion src/status_im/subs/root.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@
(reg-root-key-sub :wallet :wallet)
(reg-root-key-sub :wallet/scanned-address :wallet/scanned-address)
(reg-root-key-sub :wallet/create-account :wallet/create-account)
(reg-root-key-sub :wallet/networks :wallet/networks)
(reg-root-key-sub :wallet/local-suggestions :wallet/local-suggestions)
(reg-root-key-sub :wallet/valid-ens-or-address? :wallet/valid-ens-or-address?)

Expand Down
14 changes: 10 additions & 4 deletions src/status_im/subs/wallet/networks.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@
[status-im.constants :as constants]))

(re-frame/reg-sub
:wallet/filtered-networks-by-mode
:wallet/networks
:<- [:wallet]
:-> :networks)

(re-frame/reg-sub
:wallet/networks-by-mode
:<- [:wallet/networks]
(fn [networks [_ test?]]
(get networks (if test? :test :prod))))
:<- [:profile/test-networks-enabled?]
(fn [[networks test-networks-enabled?]]
(get networks (if test-networks-enabled? :test :prod))))

(def mainnet-network-details
{:source (resources/get-network constants/mainnet-network-name)
Expand All @@ -32,7 +38,7 @@

(re-frame/reg-sub
:wallet/network-details
:<- [:wallet/filtered-networks-by-mode false]
:<- [:wallet/networks-by-mode]
(fn [networks]
(->> networks
(keep
Expand Down
2 changes: 1 addition & 1 deletion src/status_im/subs/wallet/networks_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
(h/deftest-sub :wallet/network-details
[sub-name]
(testing "returns data with prod"
(swap! rf-db/app-db assoc :wallet/networks network-data)
(swap! rf-db/app-db assoc-in [:wallet :networks] network-data)
(is (= [{:network-name :ethereum
:short-name "eth"
:chain-id 1
Expand Down
16 changes: 7 additions & 9 deletions src/status_im/subs/wallet/wallet.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,13 @@
:wallet/accounts
:<- [:wallet]
:<- [:wallet/network-details]
(fn [[wallet network-details]]
;; TODO(@rende11): `testnet?` value would be relevant after this implementation,
;; https://github.com/status-im/status-mobile/issues/17826
(let [testnet? false]
(->> wallet
:accounts
vals
(map #(assoc-network-preferences-names network-details % testnet?))
(sort-by :position)))))
:<- [:profile/test-networks-enabled?]
(fn [[wallet network-details test-networks-enabled?]]
(->> wallet
:accounts
vals
(map #(assoc-network-preferences-names network-details % test-networks-enabled?))
(sort-by :position))))

(rf/reg-sub
:wallet/addresses
Expand Down
10 changes: 5 additions & 5 deletions src/status_im/subs/wallet/wallet_test.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
(swap! rf-db/app-db
#(-> %
(assoc-in [:wallet :accounts] accounts)
(assoc :wallet/networks network-data)))
(assoc-in [:wallet :networks] network-data)))
(is
(=
(list {:path "m/44'/60'/0'/0/0"
Expand Down Expand Up @@ -252,7 +252,7 @@
#(-> %
(assoc-in [:wallet :accounts] accounts)
(assoc-in [:wallet :current-viewing-account-address] "0x1")
(assoc :wallet/networks network-data)))
(assoc-in [:wallet :networks] network-data)))

(let [result (rf/sub [sub-name])]
(is
Expand Down Expand Up @@ -310,7 +310,7 @@
#(-> %
(assoc-in [:wallet :accounts] accounts)
(assoc-in [:wallet :current-viewing-account-address] "0x2")
(assoc :wallet/networks network-data)))
(assoc-in [:wallet :networks] network-data)))
(is
(= (list
{:path "m/44'/60'/0'/0/0"
Expand Down Expand Up @@ -365,7 +365,7 @@
(swap! rf-db/app-db
#(-> %
(assoc-in [:wallet :accounts] accounts)
(assoc :wallet/networks network-data)))
(assoc-in [:wallet :networks] network-data)))
(is
(= (list
{:path "m/44'/60'/0'/0/0"
Expand Down Expand Up @@ -421,7 +421,7 @@
#(-> %
(assoc-in [:wallet :accounts] accounts)
(assoc-in [:wallet :current-viewing-account-address] "0x1")
(assoc :wallet/networks network-data)))
(assoc-in [:wallet :networks] network-data)))
(is
(match? [{:short-name "eth"
:network-name :ethereum
Expand Down

0 comments on commit 9d7a4ed

Please sign in to comment.