[SOLVED] Error with decoding string from the event in the database

Hello! Recently everything was fine and the strings from the events were saved as actual strings, but recently strings in events are now encoded and neither web3.js or ethers.js canโ€™t decode it, what has changed and how can I decode a string โ€œ0xa1b11a518457666a6fd51fb40c5221f77256ccfdb5c1ff2d1505bb8aec0779a9โ€ (should be a string with url), how was it working before on the moralis database side? Could you help here?

And another issue now with listeners, the same situation as before, but now I have an error in the hook useMoralisSubscription

Uncaught TypeError: (0 , _decode.default) is not a function
    at ParseObject.value (ParseObject.js:671:1)
    at Function.value (ParseObject.js:2658:1)
    at LiveQueryClient.value (LiveQueryClient.js:660:1)
    at socket.onmessage (LiveQueryClient.js:457:1)

did anything change recently on your side?

what is the server url, table, row with that event?

I just redeployed again with a new function in the contract, but the events are the same,
https://fw21fxfzipqu.usemoralis.com:2053/server
Table - Marketplace, and basically all column tokenURI is encoded now.
And the problem with hooks - as I understood the hook for cloud function is not working anymore, and hooks for listening too?

that token_uri looks like it is encoded because that is how the contract sends that event:

{"indexed":true,"internalType":"string","name":"tokenURI","type":"string"}

that indexed true will associate a hash with that tokenURI

I didnโ€™t understand the issues with the hooks

so, to make it saved as just a string - I need to delete this indexed:true, in another way how Can I decode it, libraries do not work here? The problem with hooks is the same as from the previous message, and as from another question where I had to use rest API instead of this hook to fetch data from cloud function, because now the hook const { fetch, data } = useMoralisCloudFunction("FetchHistory"); does not work, data is null and fetch returns undefined. another hook, useMoralisSubscription, return now an error Uncaught TypeError: (0 , _decode.default) is not a function at ParseObject.value (ParseObject.js:671:1) at Function.value (ParseObject.js:2658:1) at LiveQueryClient.value (LiveQueryClient.js:660:1) at socket.onmessage (LiveQueryClient.js:457:1)

seems like this problem with hooks is connected to react-moralis library, should I downgrade it to make it work again?

the problem with hooks could be related to cloud code too, you can try to double check that cloud code

for that indexed true, yes, you will have to change it in the contract if you want to see a string, what you see there is the hash of the string

As you can see from the error, it is not a problem of cloud code, because it was working and I did not change cloud code functionality at all.

Hello, cryptokid! I was right about the issue with hooks, looks like I accidentally updated moralis and react-moralis packages and these hooks do not work there, when I changed version to the old one

    "react-moralis": "^1.4.0",
    "moralis": "^1.8.1",

Hooks are working again, so probably it will be useful for you, someone can have the same issue

1 Like