Git Product home page Git Product logo

Comments (2)

stevel408 avatar stevel408 commented on August 29, 2024

Wow, can't believe the moment I wrote this up, things start to work all of a sudden. In any case, I was debugging this a bit earlier when I cannot get this to work repeatedly, and let me share what I found.

Basically I see that there's some logic in the code to call up the Hiro wallet, and uses the window.StacksProvider attribute (among others, perhaps) to determine if the Hiro wallet extension is installed. I noticed that this attribute is undefined in a new browser window/tab:

Screenshot 2023-04-25 at 11 16 27 PM

When the Buy button was not working before I filed this issue, I observed the same thing above. Of course, now when I go back and look again, the attribute has valid value:

Screenshot 2023-04-25 at 11 10 14 PM

I have a reliable Internet connection and don't think there is a problem on my end, but since the problem is not reproducible any more, please feel free to close it. The only reason I can think of for the cause would be that, if the logic to load up the window.StacksProvider attribute is from some remote JS file, and that the fetching of the JS file is slow or has failed, this problem might occur.

In any case, sorry for the interruption, great job on building this valuable and promising project!

from openordex.

stevel408 avatar stevel408 commented on August 29, 2024

Well well well, what do you know, the problem came right back after I disabled and re-enabled the Hiro wallet extension. And I think I might have found the cause.

First of all, there seems to be an important piece of initialization code:

Screenshot 2023-04-25 at 11 36 25 PM

This code snippet is setting up many variable for later use, such as connectUserSession, which depends on if the system detects the presence of the Hiro wallet. That further is dependent upon the getInstalledWalletName() function call. Inside that function, I set a breakpoint and found the following:

Screenshot 2023-04-25 at 11 33 05 PM

As we can see, at this time, the window.StacksProvider attribute is not defined yet, causing app.js to think that the Hiro wallet is NOT present, thus skipping the creation of connectUserSession.

Later on when I click the "Buy" button, nothing happens in the UI, and I get an error message in the console:

Screenshot 2023-04-25 at 11 34 36 PM

At this time, when I examine the system state, I see that window.StacksProvider is now defined (bottom of the screenshot above). But by now it's too late, the app.js initialization has already run, and have already determined that the Hiro wallet was NOT present, and therefore skipped the initialization of the connectUserSession object. This object is thus undefined, but used when I clicked the Buy button, resulting in the error above.

All in all, now I think there is a simple race condition somewhere, causing the execution of app.js initialization to occur BEFORE the Hiro wallet initialization (or somehow injecting variables into window).

from openordex.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.