Compare commits

...
Author SHA1 Message Date
Omar Basem 1963d478df lint 2024-07-16 08:51:28 +04:00
Omar Basem 83a2a246ff review 2024-07-16 08:50:47 +04:00
Omar Basem f7b677e557 lint 2024-07-16 08:50:47 +04:00
Omar Basem 34a1e35e9a lint 2024-07-16 08:50:47 +04:00
Omar Basem 4a8de31e73 lint 2024-07-16 08:50:46 +04:00
Omar Basem a4302aa2dd collectible unpreferred alert 2024-07-16 08:50:45 +04:00
5 changed files with 66 additions and 21 deletions
@@ -8,6 +8,7 @@
[status-im.contexts.wallet.common.utils :as utils]
[status-im.contexts.wallet.common.utils.networks :as network-utils]
[status-im.contexts.wallet.send.utils :as send-utils]
[status-im.contexts.wallet.sheets.unpreferred-networks-alert.view :as unpreferred-networks-alert]
[taoensso.timbre :as log]
[utils.address :as address]
[utils.money :as money]
@@ -184,6 +185,48 @@
:start-flow? start-flow?
:flow-id :wallet-send-flow}]]]})))
(rf/reg-event-fx
:wallet/on-asset-or-address-confirm
(fn [{:keys [db]} [{:keys [address address-prefix recipient collectible]}]]
(let [[prefix] (when address (utils/split-prefix-and-address address))
receiver-networks (network-utils/resolve-receiver-networks
{:prefix (or address-prefix prefix)
:testnet-enabled? (get-in db
[:profile/profile
:test-networks-enabled?])
:goerli-enabled? (get-in db
[:profile/profile
:is-goerli-enabled?])})
collectible-tx? (or (some? collectible)
(send-utils/tx-type-collectible?
(-> db :wallet :ui :send :tx-type)))
send-transaction-data (get-in db [:wallet :ui :send])
collectible-network (-> (or collectible (:collectible send-transaction-data))
:id
:contract-id
:chain-id)
collectible-to-unpreferred? (when collectible-tx?
(not-any? #(= collectible-network %) receiver-networks))
on-confirm (fn []
(if collectible
(rf/dispatch [:wallet/set-collectible-to-send
{:collectible collectible
:current-screen :screen/wallet.select-asset}])
(rf/dispatch [:wallet/select-send-address
{:address address
:recipient recipient
:stack-id
:screen/wallet.select-address}])))]
{:fx [(if collectible-to-unpreferred?
[:dispatch
[:show-bottom-sheet
{:content
(fn []
[unpreferred-networks-alert/view
{:on-confirm on-confirm
:collectible-tx? collectible-tx?}])}]]
(on-confirm))]})))
(rf/reg-event-fx
:wallet/update-receiver-networks
(fn [{:keys [db]} [selected-networks]]
@@ -108,10 +108,10 @@
(let [props {:on-press (fn []
(let [address (if accounts (:address (first accounts)) address)]
(when-not ens
(rf/dispatch [:wallet/select-send-address
{:address address
:recipient local-suggestion
:stack-id :screen/wallet.select-address}]))))
(rf/dispatch [:wallet/on-asset-or-address-confirm
{:address address
:recipient
local-suggestion}]))))
:active-state? false}]
(cond
(= type types/saved-address)
@@ -156,16 +156,14 @@
local-suggestion-address
input-value)
[_ splitted-address] (network-utils/split-network-full-address
address)]
(rf/dispatch
[:wallet/select-send-address
{:address address
:recipient {:label
(utils/get-shortened-address
splitted-address)
:recipient-type :address}
:stack-id
:screen/wallet.select-address}])))
address)
shortened-address (utils/get-shortened-address
splitted-address)
recipient {:label shortened-address
:recipient-type :address}]
(rf/dispatch [:wallet/on-asset-or-address-confirm
{:address address
:recipient recipient}])))
:customization-color color}
(i18n/label :t/continue)]))
@@ -28,15 +28,16 @@
(defn collectibles-grid
[search-text]
(let [collectibles (rf/sub [:wallet/current-viewing-account-collectibles-filtered search-text])
search-performed? (not (string/blank? search-text))]
search-performed? (not (string/blank? search-text))
address-prefix (rf/sub [:wallet/wallet-send-address-prefix])]
[collectibles-tab/view
{:collectibles collectibles
:filtered? search-performed?
:on-end-reached #(rf/dispatch [:wallet/request-collectibles-for-current-viewing-account])
:on-collectible-press (fn [{:keys [collectible]}]
(rf/dispatch [:wallet/set-collectible-to-send
(rf/dispatch [:wallet/on-asset-or-address-confirm
{:collectible collectible
:current-screen :screen/wallet.select-asset}]))}]))
:address-prefix address-prefix}]))}]))
(defn- tab-view
[search-text selected-tab on-change-text]
@@ -5,7 +5,7 @@
[utils.i18n :as i18n]))
(defn view
[{:keys [on-confirm]}]
[{:keys [on-confirm collectible-tx?]}]
[:<>
[quo/text
{:style style/sending-to-unpreferred-networks-title
@@ -15,7 +15,8 @@
[quo/text
{:style style/sending-to-unpreferred-networks-text
:size :paragraph-1}
(i18n/label :t/sending-to-networks-the-receiver-does-not-prefer)]
(i18n/label :t/sending-to-networks-the-receiver-does-not-prefer
{:item (if collectible-tx? (i18n/label :t/collectible) (i18n/label :t/tokens))})]
[quo/bottom-actions
{:actions :two-actions
:button-two-label (i18n/label :t/cancel)
+4 -2
View File
@@ -2712,7 +2712,7 @@
"add-networks-token-can-be-sent-to": "Add networks {{token-symbol}} can be sent to",
"not-available": "Not available",
"token-not-available-on-networks": "{{token-symbol}} is not available on {{networks}}.",
"sending-to-networks-the-receiver-does-not-prefer": "Sending to networks the receiver does not prefer may result in recipient having difficulty accessing the sent tokens.",
"sending-to-networks-the-receiver-does-not-prefer": "Sending to networks the receiver does not prefer may result in recipient having difficulty accessing the sent {{item}}.",
"proceed-anyway": "Proceed anyway",
"sending-to-unpreferred-networks": "Sending to unpreferred networks",
"review-send": "Review send",
@@ -2758,5 +2758,7 @@
"swaps-powered-by": "Swaps powered by {{provider}}",
"max-slippage": "Max slippage",
"pay": "Pay",
"store-confirmations": "Store confirmations"
"store-confirmations": "Store confirmations",
"tokens": "tokens",
"collectible": "collectible"
}