Coder Social home page Coder Social logo

Comments (7)

shazow avatar shazow commented on May 28, 2024 2

@0xpolarzero No worries at all, thank you for diving in and participating/contributing. :)

I'm open to improving the ergonomics if you have ideas in the future too.

Please share what you end up building with WhatsABI, would love to see it and showcase it. :)

from whatsabi.

0xpolarzero avatar 0xpolarzero commented on May 28, 2024 2

@shazow I'll let you know if there is anything I believe might help/improve.

And yes absolutely, I was actually planning on sharing it to you very soon. It's a Tevm example, my PR is currently being reviewed. And I'm integrating it inside a personal project as well.

I'll send you the link with a TLDR + a Vercel preview once it's ready!

from whatsabi.

shazow avatar shazow commented on May 28, 2024

@0xpolarzero Hmm this is not intended behaviour, thanks for flagging it. Definitely open to a PR if you'd like to try to fix it. :)

I'm trying to understand what's happening, so I'm going to rephrase what you explained to make sure we're on the same page:

  1. https://repo.sourcify.dev/contracts/full_match/10/0x4200000000000000000000000000000000000042/metadata.json gets hit first, which returns 404
  2. This try/catch gets hit: https://github.com/shazow/whatsabi/blob/main/src/loaders.ts#L140-L142
    if (!isSourcifyNotFound(error)) throw error;
  3. Since it's a 404, it should not throw (note the negating ! in front), and fall through to the partial block, no?

Is isSourcifyNotFound incorrect? Or am I confusing some other call flow condition?

from whatsabi.

0xpolarzero avatar 0xpolarzero commented on May 28, 2024

@shazow Oh, I completely overlooked the ! in front, sorry about that... It should definitely get to the second block then. Thanks for making it clearer.

Please let me play with it a bit to try to exhibit the issue. I'll gladly submit a PR if I can find it!

from whatsabi.

shazow avatar shazow commented on May 28, 2024

@0xpolarzero Awesome, thank you!

from whatsabi.

0xpolarzero avatar 0xpolarzero commented on May 28, 2024

@shazow Ok, that was due to a silly mistake/misunderstanding from my end, truly sorry for wasting your time...

The core issue was making the request from my Next.js app on the client side; the 404 status of the issue was due to the usual CORS header ‘Access-Control-Allow-Origin’ missing. I was too quick to attribute it to WhatsABI.

So basically, the request needs to be done on the server side—e.g. via an API route. Which unfortunately makes the use of the callbacks (onProgress, onError) not possible. But that's purely a React/Next/client components problem.

I'm not sure about that, but from my understanding, these are the few solutions (for documentation/in case anyone else faces this):

  • make the call (e.g. autoload) inside an API route, and just call that route from the client side—you won't be able to pass it any function, for instance a callback on error/progress;
  • serve the Sourcify server yourself with a flexible/customized CORS policy (see here);

from whatsabi.

shazow avatar shazow commented on May 28, 2024

Very cool! @roninjin10 will be so hyped

from whatsabi.

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.