IntersectMBO / cardano-addresses

Addresses and mnemonic manipulation & derivations
Apache License 2.0
145 stars 46 forks source link

Web demo is broken: `runCardanoAddressesApi is not defined` #264

Open Unisay opened 3 months ago

Unisay commented 3 months ago

image

paweljakubas commented 3 months ago

hi @Unisay

My strong view is that it is something on application side. Prove:

$ echo addr_test1vqq934tq2lnxp9urlltl0vj3sejl92dznu82ngzdj8g4fpc7vnz95 | cabal run cardano-address address inspect
/nix/store/q3yjgay463jbvcnk751pk4r95a31wm47-cabal-install-exe-cabal-3.10.3.0/bin/cabal --project-file=/home/pawel/Work/IntersectMBO/cardano-addresses/.nix-shell-cabal.project run cardano-address address inspect
{
    "address_style": "Shelley",
    "address_type": 6,
    "network_tag": 0,
    "spending_key_hash": "0058d56057e6609783ffd7f7b2518665f2a9a29f0ea9a04d91d15487",
    "spending_key_hash_bech32": "addr_vkh1qpvd2czhuesf0qll6lmmy5vxvhe2ng5lp656qnv3692gwcv4s9j",
    "stake_reference": "none"
}

As you see this is a valid address (enterprise one, so only spending credential present) and inspect functionality parses it properly. Maybe the web application has problem with this type of address as it expects base address (so also with delegation credential present) - just first guess. Nevertheless, I do not see problem on cardano-addresses side, so it very probably is not BUG here but on the web app side you used.

Unisay commented 3 months ago

So I looked at the web demo app and noticed the following error in the dev console:

Loading module from “http://localhost:3000/dist/cardano-addresses-jsapi.esm.js” was blocked because of a disallowed MIME type (“text/html”)

The error went away after I added this fix to the index.js:

app.use((req, res, next) => {
  res.setHeader('X-Content-Type-Options', 'nosniff');
}); 

Unfortunately this isn't enough and the app looks like this: image

It is stuck in the "Loading.." state right from the start, no errors in the dev console, but also no results after clicking the "Inspect" button.

TLDR: the demo app is broken.