feat: support sending multi collectibles (#20045)
This commit is contained in:
parent
ea58e52dc1
commit
d558c565b0
|
@ -6,7 +6,8 @@
|
||||||
[:props
|
[:props
|
||||||
[:map {:closed true}
|
[:map {:closed true}
|
||||||
[:status {:optional true} [:maybe [:enum :default :error]]]
|
[:status {:optional true} [:maybe [:enum :default :error]]]
|
||||||
[:on-change-text {:optional true} [:maybe fn?]]
|
[:on-inc-press {:optional true} [:maybe fn?]]
|
||||||
|
[:on-dec-press {:optional true} [:maybe fn?]]
|
||||||
[:container-style {:optional true} [:maybe :map]]
|
[:container-style {:optional true} [:maybe :map]]
|
||||||
[:min-value {:optional true} [:maybe :int]]
|
[:min-value {:optional true} [:maybe :int]]
|
||||||
[:max-value {:optional true} [:maybe :int]]
|
[:max-value {:optional true} [:maybe :int]]
|
||||||
|
|
|
@ -506,11 +506,18 @@
|
||||||
(def ^:const send-type-stickers-buy 4)
|
(def ^:const send-type-stickers-buy 4)
|
||||||
(def ^:const send-type-bridge 5)
|
(def ^:const send-type-bridge 5)
|
||||||
(def ^:const send-type-erc-721-transfer 6)
|
(def ^:const send-type-erc-721-transfer 6)
|
||||||
|
(def ^:const send-type-erc-1155-transfer 7)
|
||||||
|
|
||||||
(def ^:const bridge-name-transfer "Transfer")
|
(def ^:const bridge-name-transfer "Transfer")
|
||||||
(def ^:const bridge-name-erc-721-transfer "ERC721Transfer")
|
(def ^:const bridge-name-erc-721-transfer "ERC721Transfer")
|
||||||
|
(def ^:const bridge-name-erc-1155-transfer "ERC1155Transfer")
|
||||||
(def ^:const bridge-name-hop "Hop")
|
(def ^:const bridge-name-hop "Hop")
|
||||||
|
|
||||||
|
(def ^:const wallet-contract-type-uknown 0)
|
||||||
|
(def ^:const wallet-contract-type-erc-20 1)
|
||||||
|
(def ^:const wallet-contract-type-erc-721 2)
|
||||||
|
(def ^:const wallet-contract-type-erc-1155 3)
|
||||||
|
|
||||||
(def ^:const alert-banner-height 40)
|
(def ^:const alert-banner-height 40)
|
||||||
|
|
||||||
(def ^:const status-hostname "status.app")
|
(def ^:const status-hostname "status.app")
|
||||||
|
|
|
@ -250,7 +250,7 @@
|
||||||
{:db (-> db
|
{:db (-> db
|
||||||
(assoc-in [:wallet :ui :send :token] token)
|
(assoc-in [:wallet :ui :send :token] token)
|
||||||
(assoc-in [:wallet :ui :send :to-address] to-address)
|
(assoc-in [:wallet :ui :send :to-address] to-address)
|
||||||
(assoc-in [:wallet :ui :send :tx-type] :bridge))
|
(assoc-in [:wallet :ui :send :tx-type] :tx/bridge))
|
||||||
:fx [[:dispatch
|
:fx [[:dispatch
|
||||||
[:wallet/wizard-navigate-forward
|
[:wallet/wizard-navigate-forward
|
||||||
{:current-screen stack-id
|
{:current-screen stack-id
|
||||||
|
@ -259,7 +259,7 @@
|
||||||
|
|
||||||
(rf/reg-event-fx :wallet/start-bridge
|
(rf/reg-event-fx :wallet/start-bridge
|
||||||
(fn [{:keys [db]}]
|
(fn [{:keys [db]}]
|
||||||
{:db (assoc-in db [:wallet :ui :send :tx-type] :bridge)
|
{:db (assoc-in db [:wallet :ui :send :tx-type] :tx/bridge)
|
||||||
:fx [[:dispatch [:open-modal :screen/wallet.bridge-select-asset]]]}))
|
:fx [[:dispatch [:open-modal :screen/wallet.bridge-select-asset]]]}))
|
||||||
|
|
||||||
(rf/reg-event-fx :wallet/select-bridge-network
|
(rf/reg-event-fx :wallet/select-bridge-network
|
||||||
|
|
|
@ -144,7 +144,8 @@
|
||||||
{:prefix prefix
|
{:prefix prefix
|
||||||
:testnet-enabled? testnet-enabled?
|
:testnet-enabled? testnet-enabled?
|
||||||
:goerli-enabled? goerli-enabled?})
|
:goerli-enabled? goerli-enabled?})
|
||||||
collectible-tx? (= (-> db :wallet :ui :send :tx-type) :collectible)
|
collectible-tx? (send-utils/tx-type-collectible?
|
||||||
|
(-> db :wallet :ui :send :tx-type))
|
||||||
collectible (when collectible-tx?
|
collectible (when collectible-tx?
|
||||||
(-> db :wallet :ui :send :collectible))
|
(-> db :wallet :ui :send :collectible))
|
||||||
one-collectible? (when collectible-tx?
|
one-collectible? (when collectible-tx?
|
||||||
|
@ -235,13 +236,19 @@
|
||||||
:collectible
|
:collectible
|
||||||
:token-display-name
|
:token-display-name
|
||||||
:amount
|
:amount
|
||||||
(when (= transaction-type :collectible) :tx-type))})))
|
(when (send-utils/tx-type-collectible?
|
||||||
|
transaction-type)
|
||||||
|
:tx-type))})))
|
||||||
|
|
||||||
(rf/reg-event-fx
|
(rf/reg-event-fx
|
||||||
:wallet/set-collectible-to-send
|
:wallet/set-collectible-to-send
|
||||||
(fn [{db :db} [{:keys [collectible current-screen]}]]
|
(fn [{db :db} [{:keys [collectible current-screen]}]]
|
||||||
(let [collection-data (:collection-data collectible)
|
(let [collection-data (:collection-data collectible)
|
||||||
collectible-data (:collectible-data collectible)
|
collectible-data (:collectible-data collectible)
|
||||||
|
contract-type (:contract-type collectible)
|
||||||
|
tx-type (if (= contract-type constants/wallet-contract-type-erc-1155)
|
||||||
|
:tx/collectible-erc-1155
|
||||||
|
:tx/collectible-erc-721)
|
||||||
collectible-id (get-in collectible [:id :token-id])
|
collectible-id (get-in collectible [:id :token-id])
|
||||||
one-collectible? (= (collectible.utils/collectible-balance collectible) 1)
|
one-collectible? (= (collectible.utils/collectible-balance collectible) 1)
|
||||||
token-display-name (cond
|
token-display-name (cond
|
||||||
|
@ -255,7 +262,7 @@
|
||||||
(update-in [:wallet :ui :send] dissoc :token)
|
(update-in [:wallet :ui :send] dissoc :token)
|
||||||
(assoc-in [:wallet :ui :send :collectible] collectible)
|
(assoc-in [:wallet :ui :send :collectible] collectible)
|
||||||
(assoc-in [:wallet :ui :send :token-display-name] token-display-name)
|
(assoc-in [:wallet :ui :send :token-display-name] token-display-name)
|
||||||
(assoc-in [:wallet :ui :send :tx-type] :collectible))
|
(assoc-in [:wallet :ui :send :tx-type] tx-type))
|
||||||
recipient-set? (-> db :wallet :ui :send :recipient)]
|
recipient-set? (-> db :wallet :ui :send :recipient)]
|
||||||
{:db (cond-> collectible-tx
|
{:db (cond-> collectible-tx
|
||||||
one-collectible? (assoc-in [:wallet :ui :send :amount] 1))
|
one-collectible? (assoc-in [:wallet :ui :send :amount] 1))
|
||||||
|
@ -314,7 +321,7 @@
|
||||||
amount-in (send-utils/amount-in-hex amount (if token token-decimal 0))
|
amount-in (send-utils/amount-in-hex amount (if token token-decimal 0))
|
||||||
from-address wallet-address
|
from-address wallet-address
|
||||||
disabled-from-chain-ids disabled-from-chain-ids
|
disabled-from-chain-ids disabled-from-chain-ids
|
||||||
disabled-to-chain-ids (if (= transaction-type :bridge)
|
disabled-to-chain-ids (if (= transaction-type :tx/bridge)
|
||||||
(filter #(not= % bridge-to-chain-id) network-chain-ids)
|
(filter #(not= % bridge-to-chain-id) network-chain-ids)
|
||||||
(filter (fn [chain-id]
|
(filter (fn [chain-id]
|
||||||
(not (some #(= chain-id %)
|
(not (some #(= chain-id %)
|
||||||
|
@ -322,8 +329,9 @@
|
||||||
network-chain-ids))
|
network-chain-ids))
|
||||||
from-locked-amount {}
|
from-locked-amount {}
|
||||||
transaction-type-param (case transaction-type
|
transaction-type-param (case transaction-type
|
||||||
:collectible constants/send-type-erc-721-transfer
|
:tx/collectible-erc-721 constants/send-type-erc-721-transfer
|
||||||
:bridge constants/send-type-bridge
|
:tx/collectible-erc-1155 constants/send-type-erc-1155-transfer
|
||||||
|
:tx/bridge constants/send-type-bridge
|
||||||
constants/send-type-transfer)
|
constants/send-type-transfer)
|
||||||
balances-per-chain (when token (:balances-per-chain token))
|
balances-per-chain (when token (:balances-per-chain token))
|
||||||
token-available-networks-for-suggested-routes
|
token-available-networks-for-suggested-routes
|
||||||
|
@ -455,6 +463,14 @@
|
||||||
:TokenID token-id
|
:TokenID token-id
|
||||||
:ChainID to-chain-id))
|
:ChainID to-chain-id))
|
||||||
|
|
||||||
|
(= bridge-name constants/bridge-name-erc-1155-transfer)
|
||||||
|
(assoc :ERC1155TransferTx
|
||||||
|
(assoc tx-data
|
||||||
|
:Recipient to-address
|
||||||
|
:TokenID token-id
|
||||||
|
:ChainID to-chain-id
|
||||||
|
:Amount amount-in))
|
||||||
|
|
||||||
(= bridge-name constants/bridge-name-transfer)
|
(= bridge-name constants/bridge-name-transfer)
|
||||||
(assoc :TransferTx tx-data)
|
(assoc :TransferTx tx-data)
|
||||||
|
|
||||||
|
@ -494,8 +510,9 @@
|
||||||
from-address (get-in db [:wallet :current-viewing-account-address])
|
from-address (get-in db [:wallet :current-viewing-account-address])
|
||||||
transaction-type (get-in db [:wallet :ui :send :tx-type])
|
transaction-type (get-in db [:wallet :ui :send :tx-type])
|
||||||
transaction-type-param (case transaction-type
|
transaction-type-param (case transaction-type
|
||||||
:collectible constants/send-type-erc-721-transfer
|
:tx/collectible-erc-721 constants/send-type-erc-721-transfer
|
||||||
:bridge constants/send-type-bridge
|
:tx/collectible-erc-1155 constants/send-type-erc-1155-transfer
|
||||||
|
:tx/bridge constants/send-type-bridge
|
||||||
constants/send-type-transfer)
|
constants/send-type-transfer)
|
||||||
token (get-in db [:wallet :ui :send :token])
|
token (get-in db [:wallet :ui :send :token])
|
||||||
collectible (get-in db [:wallet :ui :send :collectible])
|
collectible (get-in db [:wallet :ui :send :collectible])
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
(ns status-im.contexts.wallet.send.flow-config)
|
(ns status-im.contexts.wallet.send.flow-config
|
||||||
|
(:require
|
||||||
|
[status-im.contexts.wallet.send.utils :as send-utils]))
|
||||||
|
|
||||||
(defn- collectible-selected?
|
(defn- collectible-selected?
|
||||||
[db]
|
[db]
|
||||||
(let [collectible-stored (-> db :wallet :ui :send :collectible)
|
(let [collectible-stored (-> db :wallet :ui :send :collectible)
|
||||||
tx-type (-> db :wallet :ui :send :tx-type)]
|
tx-type (-> db :wallet :ui :send :tx-type)]
|
||||||
(and (some? collectible-stored)
|
(and (some? collectible-stored)
|
||||||
(= tx-type :collectible))))
|
(send-utils/tx-type-collectible? tx-type))))
|
||||||
|
|
||||||
(defn- token-selected?
|
(defn- token-selected?
|
||||||
[db]
|
[db]
|
||||||
|
@ -19,7 +21,8 @@
|
||||||
{:screen-id :screen/wallet.select-asset
|
{:screen-id :screen/wallet.select-asset
|
||||||
:skip-step? (fn [db] (or (token-selected? db) (collectible-selected? db)))}
|
:skip-step? (fn [db] (or (token-selected? db) (collectible-selected? db)))}
|
||||||
{:screen-id :screen/wallet.send-input-amount
|
{:screen-id :screen/wallet.send-input-amount
|
||||||
:skip-step? (fn [db] (= (get-in db [:wallet :ui :send :tx-type]) :collectible))}
|
:skip-step? (fn [db]
|
||||||
|
(send-utils/tx-type-collectible? (get-in db [:wallet :ui :send :tx-type])))}
|
||||||
{:screen-id :screen/wallet.select-collectible-amount
|
{:screen-id :screen/wallet.select-collectible-amount
|
||||||
:skip-step? (fn [db]
|
:skip-step? (fn [db]
|
||||||
(or (not (collectible-selected? db))
|
(or (not (collectible-selected? db))
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
:weight :semi-bold
|
:weight :semi-bold
|
||||||
:style style/title-container
|
:style style/title-container
|
||||||
:accessibility-label :send-label}
|
:accessibility-label :send-label}
|
||||||
(if (= transaction-type :bridge)
|
(if (= transaction-type :tx/bridge)
|
||||||
(i18n/label :t/bridge)
|
(i18n/label :t/bridge)
|
||||||
(i18n/label :t/send))]
|
(i18n/label :t/send))]
|
||||||
[quo/summary-tag
|
[quo/summary-tag
|
||||||
|
@ -34,7 +34,7 @@
|
||||||
:label (str amount " " token-display-name)
|
:label (str amount " " token-display-name)
|
||||||
:type (if collectible? :collectible :token)
|
:type (if collectible? :collectible :token)
|
||||||
:image-source (if collectible? image-url :eth)}]]
|
:image-source (if collectible? image-url :eth)}]]
|
||||||
(if (= transaction-type :bridge)
|
(if (= transaction-type :tx/bridge)
|
||||||
(map-indexed
|
(map-indexed
|
||||||
(fn [idx path]
|
(fn [idx path]
|
||||||
(let [from-network (:from path)
|
(let [from-network (:from path)
|
||||||
|
@ -98,7 +98,7 @@
|
||||||
:style style/title-container
|
:style style/title-container
|
||||||
:accessibility-label :send-label}
|
:accessibility-label :send-label}
|
||||||
(i18n/label :t/to)]
|
(i18n/label :t/to)]
|
||||||
(if (= transaction-type :bridge)
|
(if (= transaction-type :tx/bridge)
|
||||||
[quo/summary-tag
|
[quo/summary-tag
|
||||||
{:type :network
|
{:type :network
|
||||||
:image-source (:source to-network)
|
:image-source (:source to-network)
|
||||||
|
@ -107,7 +107,7 @@
|
||||||
[quo/summary-tag
|
[quo/summary-tag
|
||||||
{:type :address
|
{:type :address
|
||||||
:label (utils/get-shortened-address to-address)}])]
|
:label (utils/get-shortened-address to-address)}])]
|
||||||
(when (= transaction-type :bridge)
|
(when (= transaction-type :tx/bridge)
|
||||||
[rn/view
|
[rn/view
|
||||||
{:style {:flex-direction :row
|
{:style {:flex-direction :row
|
||||||
:margin-top 4}}
|
:margin-top 4}}
|
||||||
|
@ -198,7 +198,7 @@
|
||||||
{:amount (str max-fees)
|
{:amount (str max-fees)
|
||||||
:symbol currency-symbol})}]
|
:symbol currency-symbol})}]
|
||||||
[data-item
|
[data-item
|
||||||
{:title (if (= transaction-type :bridge)
|
{:title (if (= transaction-type :tx/bridge)
|
||||||
(i18n/label :t/bridged-to
|
(i18n/label :t/bridged-to
|
||||||
{:network (:abbreviated-name to-network)})
|
{:network (:abbreviated-name to-network)})
|
||||||
(i18n/label :t/user-gets {:name (utils/get-shortened-address to-address)}))
|
(i18n/label :t/user-gets {:name (utils/get-shortened-address to-address)}))
|
||||||
|
@ -249,7 +249,7 @@
|
||||||
:footer (when (and route (seq route))
|
:footer (when (and route (seq route))
|
||||||
[standard-auth/slide-button
|
[standard-auth/slide-button
|
||||||
{:size :size-48
|
{:size :size-48
|
||||||
:track-text (if (= transaction-type :bridge)
|
:track-text (if (= transaction-type :tx/bridge)
|
||||||
(i18n/label :t/slide-to-bridge)
|
(i18n/label :t/slide-to-bridge)
|
||||||
(i18n/label :t/slide-to-send))
|
(i18n/label :t/slide-to-send))
|
||||||
:container-style {:z-index 2}
|
:container-style {:z-index 2}
|
||||||
|
@ -282,12 +282,12 @@
|
||||||
:theme theme}]
|
:theme theme}]
|
||||||
[user-summary
|
[user-summary
|
||||||
{:token-display-name token-display-name
|
{:token-display-name token-display-name
|
||||||
:summary-type (if (= transaction-type :bridge)
|
:summary-type (if (= transaction-type :tx/bridge)
|
||||||
:status-account
|
:status-account
|
||||||
:account)
|
:account)
|
||||||
:accessibility-label :summary-to-label
|
:accessibility-label :summary-to-label
|
||||||
:label (i18n/label :t/to-capitalized)
|
:label (i18n/label :t/to-capitalized)
|
||||||
:account-props (if (= transaction-type :bridge)
|
:account-props (if (= transaction-type :tx/bridge)
|
||||||
from-account-props
|
from-account-props
|
||||||
user-props)
|
user-props)
|
||||||
:network-values to-values-by-chain
|
:network-values to-values-by-chain
|
||||||
|
|
|
@ -208,3 +208,11 @@
|
||||||
:position-diff position-diff})))
|
:position-diff position-diff})))
|
||||||
[]
|
[]
|
||||||
route))
|
route))
|
||||||
|
|
||||||
|
(def ^:private collectible-tx-set
|
||||||
|
#{:tx/collectible-erc-721
|
||||||
|
:tx/collectible-erc-1155})
|
||||||
|
|
||||||
|
(defn tx-type-collectible?
|
||||||
|
[tx-type]
|
||||||
|
(contains? collectible-tx-set tx-type))
|
||||||
|
|
Loading…
Reference in New Issue