Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🧪 Extract schema to dedicated namespace #18858

Merged
merged 3 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/quo/components/wallet/account_permissions/schema.cljs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(ns quo.components.wallet.account-permissions.schema
(:require [quo.components.wallet.required-tokens.view :as required-tokens]))
(:require [quo.components.wallet.required-tokens.schema :as required-tokens-schema]))

(def ?schema
[:=>
Expand All @@ -12,7 +12,7 @@
[:address [:maybe :string]]
[:emoji [:maybe :string]]
[:customization-color {:optional true} [:maybe :schema.common/customization-color]]]]
[:token-details {:optional true} [:maybe [:sequential required-tokens/?schema]]]
[:token-details {:optional true} [:maybe [:sequential required-tokens-schema/?schema]]]
[:keycard? {:optional true} [:maybe :boolean]]
[:checked? {:optional true} [:maybe :boolean]]
[:disabled? {:optional true} [:maybe :boolean]]
Expand Down
11 changes: 11 additions & 0 deletions src/quo/components/wallet/network_amount/schema.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(ns quo.components.wallet.network-amount.schema)

(def ?schema
[:=>
[:catn
[:props
[:map {:closed true}
[:amount {:optional true} [:maybe :string]]
[:token {:optional true} [:or :keyword :string]]
[:theme :schema.common/theme]]]]
:any])
13 changes: 2 additions & 11 deletions src/quo/components/wallet/network_amount/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,12 @@
[clojure.string :as string]
[quo.components.markdown.text :as text]
[quo.components.utilities.token.view :as token]
[quo.components.wallet.network-amount.schema :as network-amount-schema]
[quo.components.wallet.network-amount.style :as style]
[quo.theme :as quo.theme]
[react-native.core :as rn]
[schema.core :as schema]))

(def ?schema
[:=>
[:catn
[:props
[:map {:closed true}
[:amount {:optional true} [:maybe :string]]
[:token {:optional true} [:or :keyword :string]]
[:theme :schema.common/theme]]]]
:any])

(defn- view-internal
[{:keys [amount token theme]}]
[rn/view {:style style/container}
Expand All @@ -30,4 +21,4 @@
[rn/view
{:style (style/divider theme)}]])

(def view (quo.theme/with-theme (schema/instrument #'view-internal ?schema)))
(def view (quo.theme/with-theme (schema/instrument #'view-internal network-amount-schema/?schema)))
17 changes: 17 additions & 0 deletions src/quo/components/wallet/network_bridge/schema.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
(ns quo.components.wallet.network-bridge.schema)

(def ^:private ?network-bridge-status
[:enum :add :loading :locked :disabled :default])

(def ?schema
[:=>
[:catn
[:props
[:map
[:theme :schema.common/theme]
[:network {:optional true} [:maybe :keyword]]
[:status {:optional true} [:maybe ?network-bridge-status]]
[:amount {:optional true} [:maybe :string]]
[:container-style {:optional true} [:maybe :map]]
[:on-press {:optional true} [:maybe fn?]]]]]
:any])
19 changes: 2 additions & 17 deletions src/quo/components/wallet/network_bridge/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[clojure.string :as string]
[quo.components.icon :as icon]
[quo.components.markdown.text :as text]
[quo.components.wallet.network-bridge.schema :as network-bridge-schema]
[quo.components.wallet.network-bridge.style :as style]
[quo.foundations.colors :as colors]
[quo.foundations.resources :as resources]
Expand All @@ -25,22 +26,6 @@
(= network :ethereum) "Mainnet"
:else (string/capitalize (name network))))

(def ^:private ?network-bridge-status
[:enum :add :loading :locked :disabled :default])

(def ?schema
[:=>
[:catn
[:props
[:map
[:theme :schema.common/theme]
[:network {:optional true} [:maybe :keyword]]
[:status {:optional true} [:maybe ?network-bridge-status]]
[:amount {:optional true} [:maybe :string]]
[:container-style {:optional true} [:maybe :map]]
[:on-press {:optional true} [:maybe fn?]]]]]
:any])

(defn view-internal
[{:keys [theme network status amount container-style on-press] :as args}]
(if (= status :add)
Expand Down Expand Up @@ -81,4 +66,4 @@

(def view
(quo.theme/with-theme
(schema/instrument #'view-internal ?schema)))
(schema/instrument #'view-internal network-bridge-schema/?schema)))
17 changes: 17 additions & 0 deletions src/quo/components/wallet/network_routing/schema.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
(ns quo.components.wallet.network-routing.schema)

(def ?schema
[:=>
[:catn
[:props
[:map
[:networks {:optional true}
[:maybe
[:sequential
[:map
[:amount :int]
[:max-amount :int]
[:network-name [:or :string :keyword]]]]]]
[:container-style {:optional true} [:maybe :map]]
[:theme :schema.common/theme]]]]
:any])
19 changes: 2 additions & 17 deletions src/quo/components/wallet/network_routing/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
(:require
[oops.core :as oops]
[quo.components.wallet.network-routing.animation :as animation]
[quo.components.wallet.network-routing.schema :as network-routing-schema]
[quo.components.wallet.network-routing.style :as style]
[quo.theme :as quo.theme]
[react-native.core :as rn]
Expand Down Expand Up @@ -173,22 +174,6 @@
[rn/view {:style (style/max-limit-bar-background network-name)}]
[dashed-line network-name]])]))))

(def ?schema
[:=>
[:catn
[:props
[:map
[:networks {:optional true}
[:maybe
[:sequential
[:map
[:amount :int]
[:max-amount :int]
[:network-name [:or :string :keyword]]]]]]
[:container-style {:optional true} [:maybe :map]]
[:theme :schema.common/theme]]]]
:any])

(defn view-internal
[{:keys [networks container-style theme] :as params}]
(reagent/with-let [total-width (reagent/atom nil)]
Expand All @@ -205,4 +190,4 @@

(def view
(quo.theme/with-theme
(schema/instrument #'view-internal ?schema)))
(schema/instrument #'view-internal network-routing-schema/?schema)))
12 changes: 12 additions & 0 deletions src/quo/components/wallet/progress_bar/schema.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(ns quo.components.wallet.progress-bar.schema)

(def ?schema
[:=>
[:catn
[:props
[:map
[:customization-color {:optional true} [:maybe :schema.common/customization-color]]
[:theme :schema.common/theme]
[:progressed-value {:optional true} [:maybe [:or :string :int]]]
[:full-width? {:optional true} [:maybe :boolean]]]]]
:any])
14 changes: 2 additions & 12 deletions src/quo/components/wallet/progress_bar/view.cljs
Original file line number Diff line number Diff line change
@@ -1,21 +1,11 @@
(ns quo.components.wallet.progress-bar.view
(:require
[quo.components.wallet.progress-bar.schema :as progress-bar-schema]
[quo.components.wallet.progress-bar.style :as style]
[quo.theme :as quo.theme]
[react-native.core :as rn]
[schema.core :as schema]))

(def ?schema
[:=>
[:catn
[:props
[:map
[:customization-color {:optional true} [:maybe :schema.common/customization-color]]
[:theme :schema.common/theme]
[:progressed-value {:optional true} [:maybe [:or :string :int]]]
[:full-width? {:optional true} [:maybe :boolean]]]]]
:any])

(defn- view-internal
[{:keys [full-width?] :as props}]
[rn/view
Expand All @@ -26,4 +16,4 @@

(def view
(quo.theme/with-theme
(schema/instrument #'view-internal ?schema)))
(schema/instrument #'view-internal progress-bar-schema/?schema)))
17 changes: 17 additions & 0 deletions src/quo/components/wallet/required_tokens/schema.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
(ns quo.components.wallet.required-tokens.schema)

(def ?schema
[:=>
[:catn
[:props
[:map {:closed true}
[:type [:enum :token :collectible]]
[:amount {:optional true} [:maybe [:or :string :int]]]
[:token {:optional true} [:maybe :string]]
[:token-img-src {:optional true} [:maybe :schema.common/image-source]]
[:collectible-img-src {:optional true} [:maybe :schema.common/image-source]]
[:collectible-name {:optional true} [:maybe :string]]
[:divider? {:optional true} [:maybe :boolean]]
[:theme :schema.common/theme]
[:container-style {:optional true} [:maybe :map]]]]]
:any])
19 changes: 2 additions & 17 deletions src/quo/components/wallet/required_tokens/view.cljs
Original file line number Diff line number Diff line change
@@ -1,27 +1,12 @@
(ns quo.components.wallet.required-tokens.view
(:require [quo.components.markdown.text :as text]
[quo.components.utilities.token.view :as token]
[quo.components.wallet.required-tokens.schema :as required-tokens-schema]
[quo.components.wallet.required-tokens.style :as style]
quo.theme
[react-native.core :as rn]
[schema.core :as schema]))

(def ?schema
[:=>
[:catn
[:props
[:map {:closed true}
[:type [:enum :token :collectible]]
[:amount {:optional true} [:maybe [:or :string :int]]]
[:token {:optional true} [:maybe :string]]
[:token-img-src {:optional true} [:maybe :schema.common/image-source]]
[:collectible-img-src {:optional true} [:maybe :schema.common/image-source]]
[:collectible-name {:optional true} [:maybe :string]]
[:divider? {:optional true} [:maybe :boolean]]
[:theme :schema.common/theme]
[:container-style {:optional true} [:maybe :map]]]]]
:any])

(defn- view-internal
[{:keys [type amount token token-img-src collectible-img-src collectible-name divider? theme
container-style]}]
Expand Down Expand Up @@ -53,4 +38,4 @@

(def view
(quo.theme/with-theme
(schema/instrument #'view-internal ?schema)))
(schema/instrument #'view-internal required-tokens-schema/?schema)))
13 changes: 13 additions & 0 deletions src/quo/components/wallet/summary_info/schema.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(ns quo.components.wallet.summary-info.schema)

(def ?schema
[:=>
[:catn
[:props
[:map
[:theme :schema.common/theme]
[:type [:enum :status-account :saved-account :account :user]]
[:account-props {:optional true} [:maybe :map]]
[:networks? {:optional true} [:maybe :boolean]]
[:values {:optional true} [:maybe :map]]]]]
:any])
15 changes: 2 additions & 13 deletions src/quo/components/wallet/summary_info/view.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[quo.components.avatars.user-avatar.view :as user-avatar]
[quo.components.avatars.wallet-user-avatar.view :as wallet-user-avatar]
[quo.components.markdown.text :as text]
[quo.components.wallet.summary-info.schema :as summary-info-schema]
[quo.components.wallet.summary-info.style :as style]
[quo.foundations.colors :as colors]
[quo.foundations.resources :as resources]
Expand Down Expand Up @@ -52,18 +53,6 @@
:amount (str (:amount arbitrum) " " (or (:token-symbol arbitrum) "ARB"))
:theme theme}])]))

(def ?schema
[:=>
[:catn
[:props
[:map
[:theme :schema.common/theme]
[:type [:enum :status-account :saved-account :account :user]]
[:account-props {:optional true} [:maybe :map]]
[:networks? {:optional true} [:maybe :boolean]]
[:values {:optional true} [:maybe :map]]]]]
:any])

(defn- view-internal
[{:keys [theme type account-props networks? values]}]
[rn/view
Expand Down Expand Up @@ -106,4 +95,4 @@

(def view
(quo.theme/with-theme
(schema/instrument #'view-internal ?schema)))
(schema/instrument #'view-internal summary-info-schema/?schema)))