Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3ff4b8d8b6 | ||
|
|
f775010691 | ||
|
|
540094c229 | ||
|
|
08b65cbcb7 | ||
|
|
d623cc8444 | ||
|
|
4b7c906df2 | ||
|
|
3b446963ef |
Binary file not shown.
|
After Width: | Height: | Size: 3.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 5.1 KiB |
@@ -28,6 +28,7 @@
|
||||
{:type :spending-cap
|
||||
:label "Spending Cap"
|
||||
:button-label "Edit"
|
||||
:button-icon :i/options
|
||||
:on-button-press on-button-press
|
||||
:avatar-props {:image "image"}}])
|
||||
(h/fire-event :press (h/get-by-text "Edit"))
|
||||
|
||||
@@ -107,7 +107,7 @@
|
||||
:style (style/description blur? theme)}
|
||||
description])]
|
||||
(when (= type :account) [tiny-tag/view {:label tag-label}])
|
||||
(when (= type :spending-cap)
|
||||
(when (and (= type :spending-cap) button-icon)
|
||||
[button/button
|
||||
{:type :outline
|
||||
:size 24
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
|
||||
(defn main
|
||||
[{:keys [type customization-color]} theme]
|
||||
{:justify-content :center
|
||||
:align-items :center
|
||||
{:align-items :center
|
||||
:height 32
|
||||
:padding-left 4
|
||||
:padding-right 10
|
||||
|
||||
@@ -67,7 +67,9 @@
|
||||
:style (style/main (assoc props :customization-color customization-color) theme)}
|
||||
[left-view props]
|
||||
[text/text
|
||||
{:style (style/label type theme)
|
||||
:weight :semi-bold
|
||||
:size :heading-1}
|
||||
{:style (style/label type theme)
|
||||
:weight :semi-bold
|
||||
:ellipsize-mode :tail
|
||||
:number-of-lines 1
|
||||
:size :heading-1}
|
||||
label]]))
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
:gnosis (js/require "../resources/images/networks/Gnosis.png")
|
||||
:hermez (js/require "../resources/images/networks/Hermez.png")
|
||||
:optimism (js/require "../resources/images/networks/Optimism.png")
|
||||
:paraswap (js/require "../resources/images/networks/Paraswap.png")
|
||||
:polygon (js/require "../resources/images/networks/Polygon.png")
|
||||
:scroll (js/require "../resources/images/networks/Scroll.png")
|
||||
:taiko (js/require "../resources/images/networks/Taiko.png")
|
||||
|
||||
@@ -62,16 +62,17 @@
|
||||
(bean/->js {:id id
|
||||
:namespaces approved-namespaces})))
|
||||
|
||||
(defn disconnect-session
|
||||
[{:keys [web3-wallet reason topic]}]
|
||||
(oops/ocall web3-wallet
|
||||
"disconnectSession"
|
||||
(bean/->js {:topic topic
|
||||
:reason reason})))
|
||||
|
||||
(defn get-active-sessions
|
||||
[web3-wallet]
|
||||
(oops/ocall web3-wallet "getActiveSessions"))
|
||||
|
||||
(defn core-pairing-disconnnect
|
||||
[web3-wallet topic]
|
||||
(oops/ocall web3-wallet
|
||||
"core.pairing.disconnect"
|
||||
(bean/->js {:topic topic})))
|
||||
|
||||
(defn core-pairing-pair
|
||||
[web3-wallet url]
|
||||
(oops/ocall web3-wallet
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
set-animating-true #(reset! animating? true)
|
||||
set-animating-false (fn [ms]
|
||||
(js/setTimeout #(reset! animating? false) ms))]
|
||||
(fn [{:keys [content skip-background? on-dismiss]}]
|
||||
(fn [{:keys [content skip-background?]}]
|
||||
(let [theme (quo.theme/use-theme)
|
||||
{:keys [top] :as insets} (safe-area/get-insets)
|
||||
alert-banners-top-margin (rf/sub [:alert-banners/top-margin])
|
||||
@@ -63,10 +63,6 @@
|
||||
(reanimated/animate opacity 0 300)
|
||||
(rf/dispatch [:navigate-back])
|
||||
true)
|
||||
dismiss (fn []
|
||||
(when on-dismiss
|
||||
(on-dismiss))
|
||||
(close))
|
||||
reset-open-sheet (fn []
|
||||
(reanimated/animate translate-y 0 300)
|
||||
(reanimated/animate opacity 1 300)
|
||||
@@ -87,7 +83,7 @@
|
||||
:opacity opacity
|
||||
:scroll-enabled? scroll-enabled?
|
||||
:curr-scroll curr-scroll
|
||||
:close dismiss
|
||||
:close close
|
||||
:reset-open-sheet reset-open-sheet
|
||||
:set-animating-true set-animating-true})}
|
||||
[reanimated/view {:style (style/main-view translate-y theme)}
|
||||
|
||||
@@ -290,9 +290,12 @@
|
||||
(def ^:const wallet-connect-session-request-event "session_request")
|
||||
(def ^:const wallet-connect-session-delete-event "session_delete")
|
||||
(def ^:const wallet-connect-user-rejected-error-key "USER_REJECTED")
|
||||
(def ^:const wallet-connect-user-disconnected-reason-key "USER_DISCONNECTED")
|
||||
|
||||
(def ^:const transaction-pending-type-wallet-connect-transfer "WalletConnectTransfer")
|
||||
|
||||
(def ^:const token-sort-priority {"SNT" 1 "STT" 1 "ETH" 2 "DAI" 3})
|
||||
|
||||
(def ^:const dapp-permission-contact-code "contact-code")
|
||||
(def ^:const dapp-permission-web3 "web3")
|
||||
(def ^:const dapp-permission-qr-code "qr-code")
|
||||
@@ -577,5 +580,8 @@
|
||||
(def ^:const max-recommended-slippage 5)
|
||||
(def ^:const max-slippage-decimal-places 2)
|
||||
(def ^:const swap-default-provider
|
||||
{:name "Paraswap"
|
||||
{:name :paraswap
|
||||
:full-name "Paraswap"
|
||||
:color :blue
|
||||
:contract-address "0xdef171fe48cf0115b1d80b88dc8eab59176fee57"
|
||||
:terms-and-conditions-url "https://files.paraswap.io/tos_v4.pdf"})
|
||||
|
||||
@@ -47,12 +47,11 @@
|
||||
:label (i18n/label :t/view-token-gating)}))
|
||||
|
||||
(defn- action-mark-as-read
|
||||
[]
|
||||
(when config/show-not-implemented-features?
|
||||
{:icon :i/mark-as-read
|
||||
:accessibility-label :chat-mark-as-read
|
||||
:on-press not-implemented/alert
|
||||
:label (i18n/label :t/mark-as-read)}))
|
||||
[chat-id]
|
||||
{:icon :i/mark-as-read
|
||||
:accessibility-label :chat-mark-as-read
|
||||
:on-press #(hide-sheet-and-dispatch [:chat.ui/mark-all-read-pressed chat-id])
|
||||
:label (i18n/label :t/mark-as-read)})
|
||||
|
||||
(defn- action-toggle-muted
|
||||
[id muted? muted-till chat-type]
|
||||
@@ -130,7 +129,7 @@
|
||||
(and (not inside-chat?) (not locked?))
|
||||
[quo/action-drawer
|
||||
[[(when-not hide-view-members? (action-view-members-and-details community-id chat-id))
|
||||
(action-mark-as-read)
|
||||
(action-mark-as-read chat-id)
|
||||
(action-toggle-muted chat-id muted muted-till chat-type)
|
||||
(action-notification-settings)
|
||||
(action-pinned-messages chat-id)
|
||||
@@ -143,7 +142,7 @@
|
||||
[[(action-view-members-and-details community-id chat-id)
|
||||
(when token-gated?
|
||||
(action-token-requirements))
|
||||
(action-mark-as-read)
|
||||
(action-mark-as-read chat-id)
|
||||
(action-toggle-muted chat-id muted muted-till chat-type)
|
||||
(action-notification-settings)
|
||||
(when config/fetch-messages-enabled?
|
||||
|
||||
@@ -307,10 +307,14 @@
|
||||
:color color
|
||||
:currency currency
|
||||
:currency-symbol currency-symbol}))
|
||||
calculated-tokens (map calculate-token tokens)
|
||||
token-priority {"SNT" 1 "STT" 1 "ETH" 2 "DAI" 3}]
|
||||
calculated-tokens (map calculate-token tokens)]
|
||||
(sort-by (fn [token]
|
||||
(let [fiat-value (get-in token [:values :fiat-unformatted-value])
|
||||
priority (get token-priority (:token token) 999)]
|
||||
priority (get constants/token-sort-priority (:token token) ##Inf)]
|
||||
[(- fiat-value) priority]))
|
||||
calculated-tokens)))
|
||||
|
||||
(defn sort-tokens
|
||||
[tokens]
|
||||
(let [priority #(get constants/token-sort-priority (:symbol %) ##Inf)]
|
||||
(sort-by (juxt (comp - :balance) priority) tokens)))
|
||||
|
||||
@@ -149,5 +149,14 @@
|
||||
expected-order ["DAI" "ETH" "SNT"]]
|
||||
(is (= expected-order sorted-tokens))))))))
|
||||
|
||||
(deftest sort-tokens-test
|
||||
(testing "sort-tokens function"
|
||||
(let [mock-tokens [{:symbol "ETH" :balance 5}
|
||||
{:symbol "DAI" :balance 10}
|
||||
{:symbol "SNT" :balance 1}]
|
||||
sorted-tokens (map :symbol (utils/sort-tokens mock-tokens))
|
||||
expected-order ["DAI" "ETH" "SNT"]]
|
||||
(is (= expected-order sorted-tokens)))))
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,38 +1,37 @@
|
||||
(ns status-im.contexts.wallet.connected-dapps.view
|
||||
(:require
|
||||
[quo.core :as quo]
|
||||
[quo.foundations.colors :as colors]
|
||||
[quo.theme]
|
||||
[react-native.core :as rn]
|
||||
[react-native.safe-area :as safe-area]
|
||||
[status-im.common.plus-button.view :as plus-button]
|
||||
[status-im.common.resources :as resources]
|
||||
[status-im.contexts.wallet.connected-dapps.disconnect-dapp.view :as disconnect-dapp]
|
||||
[status-im.contexts.wallet.connected-dapps.style :as style]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]))
|
||||
[quo.core :as quo]
|
||||
[quo.foundations.colors :as colors]
|
||||
[quo.theme]
|
||||
[react-native.core :as rn]
|
||||
[react-native.safe-area :as safe-area]
|
||||
[status-im.common.plus-button.view :as plus-button]
|
||||
[status-im.common.resources :as resources]
|
||||
[status-im.contexts.wallet.connected-dapps.disconnect-dapp.view :as disconnect-dapp]
|
||||
[status-im.contexts.wallet.connected-dapps.style :as style]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(defn- on-disconnect
|
||||
[wallet-account {:keys [name topic pairing-topic]}]
|
||||
[wallet-account {:keys [name topic]}]
|
||||
(rf/dispatch [:hide-bottom-sheet])
|
||||
(rf/dispatch
|
||||
[:wallet-connect/disconnect-dapp
|
||||
{:topic topic
|
||||
:pairing-topic pairing-topic
|
||||
:on-success (fn []
|
||||
(rf/dispatch [:toasts/upsert
|
||||
{:id :dapp-disconnect-success
|
||||
:type :positive
|
||||
:text (i18n/label :t/disconnect-dapp-success
|
||||
{:dapp name
|
||||
:account (:name wallet-account)})}]))
|
||||
:on-fail (fn []
|
||||
(rf/dispatch [:toasts/upsert
|
||||
{:id :dapp-disconnect-failure
|
||||
:type :negative
|
||||
:text (i18n/label :t/disconnect-dapp-fail
|
||||
{:dapp name
|
||||
:account (:name wallet-account)})}]))}]))
|
||||
{:topic topic
|
||||
:on-success (fn []
|
||||
(rf/dispatch [:toasts/upsert
|
||||
{:id :dapp-disconnect-success
|
||||
:type :positive
|
||||
:text (i18n/label :t/disconnect-dapp-success
|
||||
{:dapp name
|
||||
:account (:name wallet-account)})}]))
|
||||
:on-fail (fn []
|
||||
(rf/dispatch [:toasts/upsert
|
||||
{:id :dapp-disconnect-failure
|
||||
:type :negative
|
||||
:text (i18n/label :t/disconnect-dapp-fail
|
||||
{:dapp name
|
||||
:account (:name wallet-account)})}]))}]))
|
||||
|
||||
(defn- on-dapp-disconnect-press
|
||||
[wallet-account dapp]
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
(ns status-im.contexts.wallet.swap.set-spending-cap.style
|
||||
(:require [quo.foundations.colors :as colors]))
|
||||
|
||||
(def container
|
||||
{:flex 1
|
||||
:margin-top -20})
|
||||
|
||||
(def detail-item
|
||||
{:flex 1
|
||||
:height 36
|
||||
:background-color :transparent})
|
||||
|
||||
(def content-container
|
||||
{:padding-top 12
|
||||
:padding-horizontal 20
|
||||
:padding-bottom 32})
|
||||
|
||||
(def title-container
|
||||
{:margin-horizontal 4})
|
||||
|
||||
(def title-line-with-margin-top
|
||||
{:flex-direction :row
|
||||
:margin-top 4})
|
||||
|
||||
(def details-container
|
||||
{:flex-direction :row
|
||||
:justify-content :space-between
|
||||
:height 52
|
||||
:padding-top 7
|
||||
:padding-horizontal 1
|
||||
:margin-bottom 8})
|
||||
|
||||
(def summary-section-container
|
||||
{:padding-horizontal 20
|
||||
:padding-bottom 16})
|
||||
|
||||
(defn section-label
|
||||
[theme]
|
||||
{:margin-bottom 8
|
||||
:color (colors/theme-colors colors/neutral-50 colors/neutral-40 theme)})
|
||||
@@ -0,0 +1,253 @@
|
||||
(ns status-im.contexts.wallet.swap.set-spending-cap.view
|
||||
(:require
|
||||
[quo.core :as quo]
|
||||
[quo.foundations.resources :as resources]
|
||||
[quo.theme :as quo.theme]
|
||||
[react-native.core :as rn]
|
||||
[status-im.common.floating-button-page.view :as floating-button-page]
|
||||
[status-im.common.standard-authentication.core :as standard-auth]
|
||||
[status-im.contexts.wallet.common.utils.external-links :as external-links]
|
||||
[status-im.contexts.wallet.swap.set-spending-cap.style :as style]
|
||||
[utils.address :as address-utils]
|
||||
[utils.i18n :as i18n]
|
||||
[utils.navigation :as navigation]
|
||||
[utils.re-frame :as rf]))
|
||||
|
||||
(defn- swap-title
|
||||
[{:keys [pay-token-symbol pay-amount account provider]}]
|
||||
[rn/view {:style style/content-container}
|
||||
[rn/view {:style {:flex-direction :row}}
|
||||
[quo/text
|
||||
{:size :heading-1
|
||||
:weight :semi-bold
|
||||
:style style/title-container
|
||||
:accessibility-label :set-spending-cap-of}
|
||||
(i18n/label :t/set-spending-cap-of)]]
|
||||
[rn/view {:style style/title-line-with-margin-top}
|
||||
[quo/summary-tag
|
||||
{:token pay-token-symbol
|
||||
:label (str pay-amount " " pay-token-symbol)
|
||||
:type :token}]
|
||||
[quo/text
|
||||
{:size :heading-1
|
||||
:weight :semi-bold
|
||||
:style style/title-container
|
||||
:accessibility-label :for}
|
||||
(i18n/label :t/for)]]
|
||||
[rn/view {:style style/title-line-with-margin-top}
|
||||
[quo/summary-tag
|
||||
{:label (:full-name provider)
|
||||
:type :network
|
||||
:image-source (resources/get-network (:name provider))
|
||||
:customization-color (:color provider)}]
|
||||
[quo/text
|
||||
{:size :heading-1
|
||||
:weight :semi-bold
|
||||
:style style/title-container
|
||||
:accessibility-label :on}
|
||||
(i18n/label :t/on)]]
|
||||
[rn/view {:style style/title-line-with-margin-top}
|
||||
[quo/summary-tag
|
||||
{:label (:name account)
|
||||
:type :account
|
||||
:emoji (:emoji account)
|
||||
:customization-color (:color account)}]]])
|
||||
|
||||
(defn- spending-cap-section
|
||||
[{:keys [theme amount token-symbol]}]
|
||||
[rn/view {:style style/summary-section-container}
|
||||
[quo/text
|
||||
{:size :paragraph-2
|
||||
:weight :medium
|
||||
:style (style/section-label theme)
|
||||
:accessibility-label :spending-cap-label}
|
||||
(i18n/label :t/spending-cap)]
|
||||
[quo/approval-info
|
||||
{:type :spending-cap
|
||||
:unlimited-icon? false
|
||||
:label (str amount " " token-symbol)
|
||||
:avatar-props {:token token-symbol}}]])
|
||||
|
||||
(defn- account-section
|
||||
[{:keys [theme account pay-token-symbol pay-token-amount]}]
|
||||
[rn/view {:style style/summary-section-container}
|
||||
[quo/text
|
||||
{:size :paragraph-2
|
||||
:weight :medium
|
||||
:style (style/section-label theme)
|
||||
:accessibility-label :account-label}
|
||||
(i18n/label :t/account)]
|
||||
[quo/approval-info
|
||||
{:type :account
|
||||
:unlimited-icon? false
|
||||
:label (:name account)
|
||||
:description (address-utils/get-short-wallet-address (:address account))
|
||||
:tag-label (str pay-token-amount " " pay-token-symbol)
|
||||
:avatar-props {:emoji (:emoji account)
|
||||
:customization-color (:color account)}}]])
|
||||
|
||||
(defn- on-option-press
|
||||
[{:keys [chain-id contract-address]}]
|
||||
(rf/dispatch
|
||||
[:show-bottom-sheet
|
||||
{:content (fn []
|
||||
[quo/action-drawer
|
||||
[[{:icon :i/link
|
||||
:accessibility-label :view-on-etherscan
|
||||
:on-press (fn []
|
||||
(rf/dispatch
|
||||
[:wallet/navigate-to-chain-explorer-from-bottom-sheet
|
||||
(external-links/get-explorer-url-by-chain-id chain-id)
|
||||
contract-address]))
|
||||
:label (i18n/label :t/view-on-eth)
|
||||
:right-icon :i/external}]]])}]))
|
||||
|
||||
(defn- token-section
|
||||
[{:keys [theme token-address token-symbol network-chain-id]}]
|
||||
[rn/view {:style style/summary-section-container}
|
||||
[quo/text
|
||||
{:size :paragraph-2
|
||||
:weight :medium
|
||||
:style (style/section-label theme)
|
||||
:accessibility-label :token-label}
|
||||
(i18n/label :t/token)]
|
||||
[quo/approval-info
|
||||
{:type :token-contract
|
||||
:option-icon :i/options
|
||||
:on-option-press #(on-option-press {:chain-id network-chain-id
|
||||
:contract-address token-address})
|
||||
:unlimited-icon? false
|
||||
:label token-symbol
|
||||
:description (address-utils/get-short-wallet-address token-address)
|
||||
:avatar-props {:token token-symbol}}]])
|
||||
|
||||
(defn- spender-contract-section
|
||||
[{:keys [theme provider network-chain-id]}]
|
||||
[rn/view {:style style/summary-section-container}
|
||||
[quo/text
|
||||
{:size :paragraph-2
|
||||
:weight :medium
|
||||
:style (style/section-label theme)
|
||||
:accessibility-label :spender-contract-label}
|
||||
(i18n/label :t/spender-contract)]
|
||||
[quo/approval-info
|
||||
{:type :token-contract
|
||||
:option-icon :i/options
|
||||
:on-option-press #(on-option-press {:chain-id network-chain-id
|
||||
:contract-address (:contract-address provider)})
|
||||
:unlimited-icon? false
|
||||
:label (:full-name provider)
|
||||
:description (address-utils/get-short-wallet-address (:contract-address provider))
|
||||
:avatar-props {:image (resources/get-network (:name provider))}}]])
|
||||
|
||||
(defn- data-item
|
||||
[{:keys [network-image title subtitle size loading?]}]
|
||||
[quo/data-item
|
||||
{:container-style style/detail-item
|
||||
:blur? false
|
||||
:card? false
|
||||
:network-image network-image
|
||||
:subtitle-type (if network-image :network :default)
|
||||
:status (if loading? :loading :default)
|
||||
:title title
|
||||
:subtitle subtitle
|
||||
:size size}])
|
||||
|
||||
(defn- transaction-details
|
||||
[{:keys [estimated-time-min max-fees network loading-fees?]}]
|
||||
[rn/view {:style style/details-container}
|
||||
[:<>
|
||||
[data-item
|
||||
{:title (i18n/label :t/network)
|
||||
:subtitle (:full-name network)
|
||||
:network-image (:source network)}]
|
||||
[data-item
|
||||
{:title (i18n/label :t/est-time)
|
||||
:subtitle (i18n/label :t/time-in-mins {:minutes (str estimated-time-min)})}]
|
||||
[data-item
|
||||
{:title (i18n/label :t/max-fees)
|
||||
:subtitle max-fees
|
||||
:loading? loading-fees?
|
||||
:size :small}]]])
|
||||
|
||||
(defn footer
|
||||
[{:keys [estimated-time-min native-currency-symbol network theme account-color loading-fees?]}]
|
||||
(let [native-token (when native-currency-symbol
|
||||
(rf/sub [:wallet/token-by-symbol
|
||||
native-currency-symbol]))
|
||||
fee-formatted (rf/sub [:wallet/wallet-send-fee-fiat-formatted
|
||||
native-token])
|
||||
on-auth-success (rn/use-callback #(js/alert "Not implemented yet"))]
|
||||
[rn/view {:style {:margin-bottom -10}}
|
||||
[transaction-details
|
||||
{:estimated-time-min estimated-time-min
|
||||
:max-fees fee-formatted
|
||||
:network network
|
||||
:loading-fees? loading-fees?
|
||||
:theme theme}]
|
||||
[standard-auth/slide-button
|
||||
{:size :size-48
|
||||
:track-text (i18n/label :t/slide-to-swap)
|
||||
:container-style {:z-index 2}
|
||||
:customization-color account-color
|
||||
:disabled? loading-fees?
|
||||
:on-auth-success on-auth-success
|
||||
:auth-button-label (i18n/label :t/confirm)}]]))
|
||||
|
||||
(defn view
|
||||
[]
|
||||
(let [theme (quo.theme/use-theme)
|
||||
swap-transaction-data (rf/sub [:wallet/swap])
|
||||
{:keys [asset-to-pay network pay-amount
|
||||
providers swap-proposal
|
||||
loading-fees?]} swap-transaction-data
|
||||
estimated-time-min (:estimated-time swap-proposal)
|
||||
pay-token-symbol (:symbol asset-to-pay)
|
||||
pay-token-address (:address asset-to-pay)
|
||||
native-currency-symbol (get-in swap-proposal [:from :native-currency-symbol])
|
||||
account (rf/sub [:wallet/current-viewing-account])
|
||||
account-color (:color account)
|
||||
provider (first providers)]
|
||||
[rn/view {:style style/container}
|
||||
[floating-button-page/view
|
||||
{:footer-container-padding 0
|
||||
:header [quo/page-nav
|
||||
{:icon-name :i/close
|
||||
:on-press navigation/navigate-back
|
||||
:margin-top 8
|
||||
:background :blur
|
||||
:accessibility-label :top-bar}]
|
||||
:footer [footer
|
||||
{:estimated-time-min estimated-time-min
|
||||
:native-currency-symbol native-currency-symbol
|
||||
:network network
|
||||
:account-color account-color
|
||||
:provider provider
|
||||
:loading-fees? loading-fees?
|
||||
:theme theme}]
|
||||
:gradient-cover? true
|
||||
:customization-color account-color}
|
||||
[:<>
|
||||
[swap-title
|
||||
{:pay-token-symbol pay-token-symbol
|
||||
:pay-amount pay-amount
|
||||
:account account
|
||||
:provider provider}]
|
||||
[spending-cap-section
|
||||
{:token-symbol pay-token-symbol
|
||||
:amount pay-amount
|
||||
:theme theme}]
|
||||
[account-section
|
||||
{:account account
|
||||
:pay-token-symbol pay-token-symbol
|
||||
:pay-token-amount pay-amount
|
||||
:theme theme}]
|
||||
[token-section
|
||||
{:token-symbol pay-token-symbol
|
||||
:token-address pay-token-address
|
||||
:network-chain-id (:chain-id network)
|
||||
:theme theme}]
|
||||
[spender-contract-section
|
||||
{:provider provider
|
||||
:network-chain-id (:chain-id network)
|
||||
:theme theme}]]]]))
|
||||
@@ -16,4 +16,7 @@
|
||||
[quo/button
|
||||
{:on-press #(rf/dispatch [:navigate-to-within-stack
|
||||
[:screen/wallet.swap-confirmation :screen/wallet.swap-propasal]])}
|
||||
"Swap confirmation"]]))
|
||||
"Swap confirmation"]
|
||||
[quo/button
|
||||
{:on-press #(rf/dispatch [:open-modal :screen/wallet.swap-set-spending-cap])}
|
||||
"Set spending cap"]]))
|
||||
|
||||
@@ -127,3 +127,19 @@
|
||||
:url (get-in session [:peer :metadata :url])
|
||||
:accounts (get-in session [:namespaces :eip155 :accounts])
|
||||
:disconnected false})
|
||||
|
||||
(defn filter-operable-accounts
|
||||
[accounts]
|
||||
(filter #(and (:operable? %)
|
||||
(not (:watch-only? %)))
|
||||
accounts))
|
||||
|
||||
(defn filter-sessions-for-account-addresses
|
||||
[account-addresses sessions]
|
||||
(filter (fn [{:keys [accounts]}]
|
||||
(some (fn [account]
|
||||
(some (fn [account-address]
|
||||
(clojure.string/includes? account account-address))
|
||||
account-addresses))
|
||||
accounts))
|
||||
sessions))
|
||||
|
||||
@@ -41,8 +41,10 @@
|
||||
|
||||
(rf/reg-fx
|
||||
:effects.wallet-connect/disconnect
|
||||
(fn [{:keys [web3-wallet topic on-success on-fail]}]
|
||||
(-> (wallet-connect/core-pairing-disconnnect web3-wallet topic)
|
||||
(fn [{:keys [web3-wallet topic reason on-success on-fail]}]
|
||||
(-> (wallet-connect/disconnect-session {:web3-wallet web3-wallet
|
||||
:topic topic
|
||||
:reason reason})
|
||||
(promesa/then on-success)
|
||||
(promesa/catch on-fail))))
|
||||
|
||||
|
||||
@@ -55,9 +55,7 @@
|
||||
(log/info "Received Wallet Connect session proposal: " {:id (:id proposal)})
|
||||
(let [accounts (get-in db [:wallet :accounts])
|
||||
current-viewing-address (get-in db [:wallet :current-viewing-account-address])
|
||||
available-accounts (filter #(and (:operable? %)
|
||||
(not (:watch-only? %)))
|
||||
(vals accounts))
|
||||
available-accounts (wallet-connect-core/filter-operable-accounts (vals accounts))
|
||||
networks (wallet-connect-core/get-networks-by-mode db)
|
||||
session-networks (wallet-connect-core/proposal-networks-intersection proposal
|
||||
networks)
|
||||
@@ -117,14 +115,16 @@
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/disconnect-dapp
|
||||
(fn [{:keys [db]} [{:keys [pairing-topic on-success on-fail]}]]
|
||||
(fn [{:keys [db]} [{:keys [topic on-success on-fail]}]]
|
||||
(let [web3-wallet (get db :wallet-connect/web3-wallet)]
|
||||
{:fx [[:effects.wallet-connect/disconnect
|
||||
{:web3-wallet web3-wallet
|
||||
:topic pairing-topic
|
||||
:topic topic
|
||||
:reason (wallet-connect/get-sdk-error
|
||||
constants/wallet-connect-user-disconnected-reason-key)
|
||||
:on-fail on-fail
|
||||
:on-success (fn []
|
||||
(rf/dispatch [:wallet-connect/disconnect-session pairing-topic])
|
||||
(rf/dispatch [:wallet-connect/disconnect-session topic])
|
||||
(when on-success
|
||||
(on-success)))}]]})))
|
||||
|
||||
@@ -204,15 +204,23 @@
|
||||
:wallet-connect/fetch-active-sessions-success
|
||||
(fn [{:keys [db now]} [sessions]]
|
||||
(let [persisted-sessions (:wallet-connect/sessions db)
|
||||
account-addresses (->> (get-in db [:wallet :accounts])
|
||||
vals
|
||||
wallet-connect-core/filter-operable-accounts
|
||||
(map :address))
|
||||
sessions (->> (js->clj sessions :keywordize-keys true)
|
||||
vals
|
||||
(map wallet-connect-core/sdk-session->db-session))
|
||||
expired-sessions (remove
|
||||
(fn [{:keys [expiry]}]
|
||||
(> expiry (/ now 1000)))
|
||||
(map wallet-connect-core/sdk-session->db-session)
|
||||
(wallet-connect-core/filter-sessions-for-account-addresses
|
||||
account-addresses))
|
||||
session-topics (set (map :topic sessions))
|
||||
expired-sessions (filter
|
||||
(fn [{:keys [expiry topic]}]
|
||||
(or (< expiry (/ now 1000))
|
||||
(not (contains? session-topics topic))))
|
||||
persisted-sessions)]
|
||||
{:fx (mapv (fn [{:keys [pairingTopic]}]
|
||||
[:wallet-connect/disconnect-session pairingTopic])
|
||||
{:fx (mapv (fn [{:keys [topic]}]
|
||||
[:dispatch [:wallet-connect/disconnect-session topic]])
|
||||
expired-sessions)
|
||||
:db (assoc db :wallet-connect/sessions sessions)})))
|
||||
|
||||
@@ -270,15 +278,15 @@
|
||||
|
||||
(rf/reg-event-fx
|
||||
:wallet-connect/disconnect-session
|
||||
(fn [{:keys [db]} [pairing-topic]]
|
||||
(fn [{:keys [db]} [topic]]
|
||||
{:db (update db
|
||||
:wallet-connect/sessions
|
||||
(fn [sessions]
|
||||
(->> sessions
|
||||
(remove #(= (:pairingTopic %) pairing-topic))
|
||||
(remove #(= (:topic %) topic))
|
||||
(into []))))
|
||||
:fx [[:json-rpc/call
|
||||
[{:method "wallet_disconnectWalletConnectSession"
|
||||
:params [pairing-topic]
|
||||
:params [topic]
|
||||
:on-success #(log/info "Wallet Connect session disconnected")
|
||||
:on-error #(log/info "Wallet Connect session persistence failed" %)}]]]}))
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
(ns status-im.contexts.wallet.wallet-connect.modals.common.header.style)
|
||||
|
||||
(def header-container
|
||||
{:padding-vertical 12})
|
||||
{:padding-vertical 12
|
||||
:flex-direction :column
|
||||
:align-items :stretch})
|
||||
|
||||
(def header-dapp-name
|
||||
{:margin-top -4})
|
||||
{:flex-direction :row})
|
||||
|
||||
(def header-text
|
||||
{:margin-vertical 4})
|
||||
|
||||
(def header-account-name
|
||||
{:padding-top 4})
|
||||
{:align-items :flex-start})
|
||||
|
||||
@@ -5,22 +5,23 @@
|
||||
|
||||
(defn view
|
||||
[{:keys [label dapp account]}]
|
||||
[rn/view
|
||||
{:style style/header-container}
|
||||
[quo/text
|
||||
{:size :heading-1
|
||||
:weight :semi-bold}
|
||||
(let [{:keys [name iconUrl]} dapp]
|
||||
[rn/view {:style style/header-dapp-name}
|
||||
[rn/view {:style style/header-container}
|
||||
(let [{:keys [name iconUrl]} dapp]
|
||||
[rn/view {:style style/header-dapp-name}
|
||||
[rn/view {:flex 1}
|
||||
[quo/summary-tag
|
||||
{:type :dapp
|
||||
:label name
|
||||
:image-source iconUrl}]])
|
||||
(str " " label " ")
|
||||
(let [{:keys [emoji customization-color name]} account]
|
||||
[rn/view {:style style/header-account-name}
|
||||
[quo/summary-tag
|
||||
{:type :account
|
||||
:emoji emoji
|
||||
:label name
|
||||
:customization-color customization-color}]])]])
|
||||
:image-source iconUrl}]]])
|
||||
[quo/text
|
||||
{:size :heading-1
|
||||
:weight :semi-bold
|
||||
:style style/header-text}
|
||||
label]
|
||||
(let [{:keys [emoji customization-color name]} account]
|
||||
[rn/view {:style style/header-account-name}
|
||||
[quo/summary-tag
|
||||
{:type :account
|
||||
:emoji emoji
|
||||
:label name
|
||||
:customization-color customization-color}]])])
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
(:require
|
||||
[legacy.status-im.ui.screens.screens :as old-screens]
|
||||
[quo.foundations.colors :as colors]
|
||||
[re-frame.core :as rf]
|
||||
[status-im.common.emoji-picker.view :as emoji-picker]
|
||||
[status-im.common.enter-seed-phrase.view :as enter-seed-phrase]
|
||||
[status-im.common.lightbox.view :as lightbox]
|
||||
@@ -119,6 +118,7 @@
|
||||
[status-im.contexts.wallet.send.transaction-confirmation.view :as wallet-transaction-confirmation]
|
||||
[status-im.contexts.wallet.send.transaction-progress.view :as wallet-transaction-progress]
|
||||
[status-im.contexts.wallet.swap.select-asset-to-pay.view :as wallet-swap-select-asset-to-pay]
|
||||
[status-im.contexts.wallet.swap.set-spending-cap.view :as wallet-swap-set-spending-cap]
|
||||
[status-im.contexts.wallet.swap.swap-confirmation.view :as wallet-swap-confirmation]
|
||||
[status-im.contexts.wallet.swap.swap-proposal.view :as wallet-swap-propasal]
|
||||
[status-im.contexts.wallet.wallet-connect.modals.send-transaction.view :as
|
||||
@@ -527,6 +527,10 @@
|
||||
:options {:modalPresentationStyle :overCurrentContext}
|
||||
:component wallet-swap-confirmation/view}
|
||||
|
||||
{:name :screen/wallet.swap-set-spending-cap
|
||||
:options {:sheet? true}
|
||||
:component wallet-swap-set-spending-cap/view}
|
||||
|
||||
{:name :scan-profile-qr-code
|
||||
:options (merge
|
||||
options/dark-screen
|
||||
@@ -540,18 +544,15 @@
|
||||
;; Wallet Connect
|
||||
|
||||
{:name :screen/wallet-connect.sign-message
|
||||
:options {:sheet? true
|
||||
:on-dismiss-sheet #(rf/dispatch [:wallet-connect/reject-session-request])}
|
||||
:options {:sheet? true}
|
||||
:component wallet-connect-sign-message/view}
|
||||
|
||||
{:name :screen/wallet-connect.sign-transaction
|
||||
:options {:sheet? true
|
||||
:on-dismiss-sheet #(rf/dispatch [:wallet-connect/reject-session-request])}
|
||||
:options {:sheet? true}
|
||||
:component wallet-connect-sign-transaction/view}
|
||||
|
||||
{:name :screen/wallet-connect.send-transaction
|
||||
:options {:sheet? true
|
||||
:on-dismiss-sheet #(rf/dispatch [:wallet-connect/reject-session-request])}
|
||||
:options {:sheet? true}
|
||||
:component wallet-connect-send-transaction/view}
|
||||
|
||||
{:name :screen/wallet.connected-dapps
|
||||
|
||||
@@ -57,22 +57,22 @@
|
||||
[screen-key]
|
||||
(reagent.core/reactify-component
|
||||
(fn []
|
||||
(let [screen-details (get (if js/goog.DEBUG
|
||||
(get-screens)
|
||||
screens)
|
||||
(keyword screen-key))
|
||||
qualified-screen-details (get (if js/goog.DEBUG
|
||||
(get-screens)
|
||||
screens)
|
||||
(keyword "screen" screen-key))
|
||||
{:keys [component options]} (or qualified-screen-details screen-details)
|
||||
(let [screen-details (get (if js/goog.DEBUG
|
||||
(get-screens)
|
||||
screens)
|
||||
(keyword screen-key))
|
||||
qualified-screen-details (get (if js/goog.DEBUG
|
||||
(get-screens)
|
||||
screens)
|
||||
(keyword "screen" screen-key))
|
||||
{:keys [component options]} (or qualified-screen-details screen-details)
|
||||
{:keys [insets sheet? theme
|
||||
skip-background? on-dismiss-sheet]} options
|
||||
alert-banners-top-margin (rf/sub [:alert-banners/top-margin])
|
||||
background-color (or (get-in options [:layout :backgroundColor])
|
||||
(when sheet? :transparent))
|
||||
app-theme (rf/sub [:theme])
|
||||
theme (or theme app-theme)]
|
||||
skip-background?]} options
|
||||
alert-banners-top-margin (rf/sub [:alert-banners/top-margin])
|
||||
background-color (or (get-in options [:layout :backgroundColor])
|
||||
(when sheet? :transparent))
|
||||
app-theme (rf/sub [:theme])
|
||||
theme (or theme app-theme)]
|
||||
^{:key (str "root" screen-key @reloader/cnt)}
|
||||
[quo.theme/provider theme
|
||||
[rn/view
|
||||
@@ -83,8 +83,7 @@
|
||||
:alert-banners-top-margin alert-banners-top-margin))}
|
||||
[inactive]
|
||||
(if sheet?
|
||||
[bottom-sheet-screen/view
|
||||
{:content component :skip-background? skip-background? :on-dismiss on-dismiss-sheet}]
|
||||
[bottom-sheet-screen/view {:content component :skip-background? skip-background?}]
|
||||
[component])]
|
||||
(when js/goog.DEBUG
|
||||
[:<>
|
||||
|
||||
@@ -416,7 +416,7 @@
|
||||
:total-balance (utils/calculate-total-token-balance token
|
||||
chain-ids)))
|
||||
(:tokens account))
|
||||
sorted-tokens (sort-by :name compare tokens)]
|
||||
sorted-tokens (utils/sort-tokens tokens)]
|
||||
(if query
|
||||
(let [query-string (string/lower-case query)]
|
||||
(filter #(or (string/starts-with? (string/lower-case (:name %)) query-string)
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
"accepted": "Accepted",
|
||||
"access-existing-keys": "Access existing keys",
|
||||
"access-key": "Access key",
|
||||
"account": "Account",
|
||||
"account-added": "Account added",
|
||||
"account-color": "Account color",
|
||||
"account-content": "You can compare accounts in Status to bank accounts. Like a bank account, an account typically has an address and a balance; You use this account to transact on Ethereum. You can have multiple accounts in your wallet. All accessed by unlocking Status.",
|
||||
@@ -1016,6 +1017,7 @@
|
||||
"fleet-settings": "Fleet settings",
|
||||
"follow": "Follow",
|
||||
"follow-your-interests": "Jump into a public chat and meet new people",
|
||||
"for": "for",
|
||||
"for-airdrops": "For airdrops",
|
||||
"forgot-password": "Forgot password?",
|
||||
"forgot-your-password-info-create-new-password": "Create a new password",
|
||||
@@ -2189,6 +2191,7 @@
|
||||
"set-dapp-access-permissions": "Set DApp access permissions",
|
||||
"set-max": "Set max",
|
||||
"set-nickname-toast": "You have renamed {{primary-name}} as {{nickname}}",
|
||||
"set-spending-cap-of": "Set spending cap of",
|
||||
"set-up-sync": "Set up sync",
|
||||
"settings": "Settings",
|
||||
"setup-group-chat": "Setup group chat",
|
||||
@@ -2285,6 +2288,8 @@
|
||||
"specify-network-id": "Specify network id",
|
||||
"specify-server-public-key": "Enter server public key",
|
||||
"specify-symbol": "Specify a symbol",
|
||||
"spender-contract": "Spender contract",
|
||||
"spending-cap": "Spending cap",
|
||||
"start-chat": "Start chat",
|
||||
"start-conversation": "Start conversation",
|
||||
"start-group-chat": "Start group chat",
|
||||
|
||||
Reference in New Issue
Block a user