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

shadow-cljs #225

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open

shadow-cljs #225

wants to merge 22 commits into from

Conversation

kwladyka
Copy link
Contributor

@kwladyka kwladyka commented Feb 6, 2023

No description provided.

moduleNamespace = 'module-' + namespace,

$module = $(this),
$context = $(settings.context),

Check warning

Code scanning / CodeQL

Unsafe jQuery plugin

Potential XSS vulnerability in the ['$.fn.modal' plugin](1).
moduleNamespace = 'module-' + namespace,

$module = $(this),
$context = $(settings.context),

Check warning

Code scanning / CodeQL

Unsafe jQuery plugin

Potential XSS vulnerability in the ['$.fn.sidebar' plugin](1).

refresh: function() {
module.verbose('Refreshing selector cache');
$context = $(settings.context);

Check warning

Code scanning / CodeQL

Unsafe jQuery plugin

Potential XSS vulnerability in the ['$.fn.sidebar' plugin](1).

$module = $(this),
$window = $(window),
$scroll = $(settings.scrollContext),

Check warning

Code scanning / CodeQL

Unsafe jQuery plugin

Potential XSS vulnerability in the ['$.fn.sticky' plugin](1).
madis and others added 18 commits February 8, 2023 13:48
Here's an explication what caused this error and later 2 possible solutions (first a bit hacky, second nicer and future proof).

The `name-bazaar.ui.core/init` function was called (which in turn emitted the `:district0x/initialize` event (that resulted in the error due to `window.Web3Modal` not being present.
It was also called 2 times: first one failed due to the previously mentioned reason. Second one works (because `window.Web3Modal` was there).

So why 2 times?
First time due to
  - https://github.com/district0x/name-bazaar/blob/ec1be3a4fbc4529b553b984aad1cda7e55217b71/shadow-cljs.edn#L4
  - loaded at https://github.com/district0x/name-bazaar/blob/ec1be3a4fbc4529b553b984aad1cda7e55217b71/resources/public/index.html#L43
Second time due to explicit call of `name_bazaar.ui.core.init()` at https://github.com/district0x/name-bazaar/blob/ec1be3a4fbc4529b553b984aad1cda7e55217b71/resources/public/index.html#L48

The solution?
1. Make sure `web3modal` is loaded before calling `name_bazaar.ui.core.init()`
2. Also: remove the duplicity of calling  `name_bazaar.ui.core.init()` twice

Solution #1 (hacky): change the order of `<script>` tags so `web3modal` gets loaded before the name bazaar app (and its `ui.core.init` function gets executed.

Solution #2 (better): this one doesn't pollute the global object (_window_). Basically loading `web3modal` via CLJS `ns` macro (ns xx `(:require ["web3modal" :as web3modal]))` and setting it up in the code

Extra: remove the duplicity
Basically removing manual call to https://github.com/district0x/name-bazaar/blob/ec1be3a4fbc4529b553b984aad1cda7e55217b71/resources/public/index.html#L48 and letting the shadow-cljs build execute once it's loaded. Again better because we don't know when `<script>` tag finishes loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants