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

QA to prod #47

Merged
merged 3 commits into from
Oct 8, 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
18 changes: 12 additions & 6 deletions src/streamtide/ui/components/connect_wallet.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
[streamtide.ui.config :refer [config-map]]))

(defonce wallet (atom nil))
(defonce connect-modal-atom (atom nil))

(defn build-chain-info []
(clj->js (-> config-map
Expand Down Expand Up @@ -54,10 +55,11 @@
"0x0"))) (:typeHex receipt))
true clj->js)))

(defn create-provider [^js connectModal ^js connect-config]
(defn create-provider [^js connect-config]
#js {:request
(fn [^js args]
(let [^js wallet @wallet
connectModal @connect-modal-atom
rpc-call (fn [rpc-method params-map parse-fn]
(js/Promise. (fn [resolve reject]
(let [rpc-client# (getRpcClient #js {:client (.-client connect-config)
Expand Down Expand Up @@ -180,16 +182,20 @@
:switchToActiveChain true})
connectModal (useConnectModal)
active-web3-provider (subscribe [::web3-subs/web3])
provider (create-provider connectModal connect-config)]
provider (create-provider connect-config)]
(reset! connect-modal-atom connectModal)
;; some libraries assume the provider is in window.ethereum, so we set our wrapper in there to intercept any call
(when-not @active-web3-provider
(set! (.-ethereum js/window) provider)
(dispatch [::web3-events/create-web3-with-user-permitted-provider {} provider]))
(react/useEffect (fn []
(when (and loaded? active-wallet)
(dispatch [::chain-events/set-chain (-> active-wallet .getChain .-id)])
(dispatch [::accounts-events/set-accounts [(-> active-wallet .getAccount .-address)]])
(reset! wallet active-wallet))
(when loaded?
(if active-wallet
(do
(dispatch [::chain-events/set-chain (-> active-wallet .getChain .-id)])
(dispatch [::accounts-events/set-accounts [(-> active-wallet .getAccount .-address)]])
(reset! wallet active-wallet))
(reset! wallet nil)))
js/undefined)
(array active-wallet))
(react/useEffect (fn []
Expand Down
44 changes: 23 additions & 21 deletions src/streamtide/ui/send_support/page.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,16 @@
(defn donations []
(let [active-account (subscribe [::accounts-subs/active-account])]
(fn []
(let [donations-search (when @active-account (subscribe [::gql/query {:queries [(build-donations-query {:user/address @active-account} nil)]}
(let [donations-search (subscribe [::gql/query {:queries [(build-donations-query {:user/address @active-account} nil)]}
{:id :user-donations
:refetch-on [::ss-events/send-support-success]}]))
loading? (or (nil? donations-search) (:graphql/loading? (last @donations-search)))
donations (when @active-account (->> @donations-search
(mapcat (fn [r] (-> r :search-donations :items)))
distinct
(sort-by #(tc/to-long (:donation/date %)))
reverse))
has-more? (when @active-account (-> (last @donations-search) :search-donations :has-next-page))]
:refetch-on [::ss-events/send-support-success]}])
loading? (:graphql/loading? (last @donations-search))
donations (->> @donations-search
(mapcat (fn [r] (-> r :search-donations :items)))
distinct
(sort-by #(tc/to-long (:donation/date %)))
reverse)
has-more? (-> (last @donations-search) :search-donations :has-next-page)]
[:div.containerDonations
(if (and (empty? donations)
(not loading?))
Expand All @@ -130,7 +130,7 @@
:has-more? has-more?
:loading-spinner-delegate (fn []
[:div.spinner-container [spinner/spin]])
:load-fn #(let [end-cursor (:end-cursor (:search-contents (last @donations-search)))]
:load-fn #(let [end-cursor (:end-cursor (:search-donations (last @donations-search)))]
(dispatch [::graphql-events/query
{:query {:queries [(build-donations-query {:user/address @active-account} end-cursor)]}
:id :user-donations
Expand All @@ -153,7 +153,8 @@
(assoc-in aggr [addr :amount] "Amount not valid")
aggr))
{} @form-data)})
tx-id (str "donate_" (random-uuid))]
tx-id (str "donate_" (random-uuid))
active-account (subscribe [::accounts-subs/active-account])]
(fn []
(let [donate-tx-pending? (subscribe [::tx-id-subs/tx-pending? {:streamtide/donate tx-id}])
donate-tx-success? (subscribe [::tx-id-subs/tx-success? {:streamtide/donate tx-id}])
Expand Down Expand Up @@ -187,13 +188,14 @@
[:button.btBasic.btBasic-light.btKeep
{:on-click #(dispatch [::router-events/navigate :route.grants/index])}
"KEEP BROWSING"]]]]
[:div.container
[:div.headerPastDonations
[:h2 "Past Donations"]]
[:div.headerDonations.d-none.d-lg-flex
[:div.cel-data
[:span.titleCel.col-user "Artist Name"]]
[:div.cel-score
[:span.titleCel.col-date "Date"]
[:span.titleCel.col-amount "Amount"]]]
[donations]]]]))))
(when @active-account
[:div.container
[:div.headerPastDonations
[:h2 "Past Donations"]]
[:div.headerDonations.d-none.d-lg-flex
[:div.cel-data
[:span.titleCel.col-user "Artist Name"]]
[:div.cel-score
[:span.titleCel.col-date "Date"]
[:span.titleCel.col-amount "Amount"]]]
[donations]])]]))))
Loading